/* * Copyright 2006 www.webtair.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.webtair.session.artifact; import java.util.Calendar; /** * Class is a basic SessionInfo implementation * with min needed fields. * * @author Vaclav (Vyacheslav Yakovenko) */ public class SimpleSessionInfo implements SessionInfo { /** default name of unknown user, for example guest */ private static final String UNKNOWN_USER = "unknown"; /** Storage of last used session moment */ private long lastTimeUsed; /** Storage of user id or login */ private String idUser; /** * Default constrctor inti SimpleSessionInfo * and populate lastTimeUsed with current time value */ public SimpleSessionInfo(){ this(UNKNOWN_USER); } /** * Constructor that populate SimpleSessionInfo * with mentioned time value * @param lastTimeUsed - mentioned time value */ public SimpleSessionInfo(long lastTimeUsed){ this(UNKNOWN_USER, lastTimeUsed); } /** * Constructor that populate SimpleSessionInfo * with mentioned time value and user id (login) * @param idUser - user id, login or nickname * @param lastTimeUsed - mentioned time value */ public SimpleSessionInfo(String idUser, long lastTimeUsed){ this.idUser = idUser; this.lastTimeUsed = lastTimeUsed; } /** * Constructor that populate SimpleSessionInfo * with current time value and user id (login) * @param idUser - user id, login or nickname */ public SimpleSessionInfo(String idUser){ this(idUser, Calendar.getInstance().getTimeInMillis()); } /** * Return last time of session used in ms */ public long getLastTimeUsed() { return lastTimeUsed; } /** * Set last time of session used in ms * @param lastTimeUsed - last time when session used, ms */ public void setLastTimeUsed(long lastTimeUsed) { this.lastTimeUsed = lastTimeUsed; } /** * @return the idUser */ public String getIdUser() { return idUser; } /** * @param idUser the idUser to set */ public void setIdUser(String idUser) { this.idUser = idUser; } }