| 1 | |
package org.webslinger.servlet; |
| 2 | |
|
| 3 | |
import java.io.Serializable; |
| 4 | |
|
| 5 | 1 | public final class HttpSessionId implements Serializable { |
| 6 | 8 | public enum Location { |
| 7 | 1 | INVALID { |
| 8 | 0 | public boolean isValid() { return false; } |
| 9 | |
}, |
| 10 | 1 | NEW { |
| 11 | 0 | public boolean isValid() { return false; } |
| 12 | 1 | }, COOKIE, URL, OTHER; |
| 13 | |
|
| 14 | 0 | public boolean isValid() { return true; } |
| 15 | |
}; |
| 16 | 1 | public static final HttpSessionId INVALID = new HttpSessionId(); |
| 17 | |
|
| 18 | |
private String id; |
| 19 | |
private Location location; |
| 20 | |
|
| 21 | 1 | private HttpSessionId() { |
| 22 | 1 | this.id = null; |
| 23 | 1 | location = Location.INVALID; |
| 24 | 1 | } |
| 25 | |
|
| 26 | 307 | public HttpSessionId(String id, Location location) { |
| 27 | 307 | assert id != null; |
| 28 | 307 | assert location != null; |
| 29 | 307 | assert location != Location.INVALID; |
| 30 | 307 | this.id = id; |
| 31 | 307 | this.location = location; |
| 32 | 307 | } |
| 33 | |
|
| 34 | |
public Location getLocation() { |
| 35 | 0 | return location; |
| 36 | |
} |
| 37 | |
|
| 38 | |
public String getId() { |
| 39 | 95 | return id; |
| 40 | |
} |
| 41 | |
|
| 42 | |
public String toString() { |
| 43 | 0 | return "ID[" + getId() + "/" + getLocation() + "]"; |
| 44 | |
} |
| 45 | |
} |