private static class DefaultIoSessionDataStructureFactory.DefaultIoSessionAttributeMap extends java.lang.Object implements IoSessionAttributeMap
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.ConcurrentHashMap<java.lang.Object,java.lang.Object> |
attributes |
| Constructor and Description |
|---|
DefaultIoSessionAttributeMap()
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsAttribute(IoSession session,
java.lang.Object key)
Returns true if this session contains the attribute with
the specified key.
|
void |
dispose(IoSession session)
Disposes any releases associated with the specified session.
|
java.lang.Object |
getAttribute(IoSession session,
java.lang.Object key,
java.lang.Object defaultValue)
Returns the value of user defined attribute associated with the
specified key.
|
java.util.Set<java.lang.Object> |
getAttributeKeys(IoSession session)
Returns the set of keys of all user-defined attributes.
|
java.lang.Object |
removeAttribute(IoSession session,
java.lang.Object key)
Removes a user-defined attribute with the specified key.
|
boolean |
removeAttribute(IoSession session,
java.lang.Object key,
java.lang.Object value)
Removes a user defined attribute with the specified key if the current
attribute value is equal to the specified value.
|
boolean |
replaceAttribute(IoSession session,
java.lang.Object key,
java.lang.Object oldValue,
java.lang.Object newValue)
Replaces a user defined attribute with the specified key if the
value of the attribute is equals to the specified old value.
|
java.lang.Object |
setAttribute(IoSession session,
java.lang.Object key,
java.lang.Object value)
Sets a user-defined attribute.
|
java.lang.Object |
setAttributeIfAbsent(IoSession session,
java.lang.Object key,
java.lang.Object value)
Sets a user defined attribute if the attribute with the specified key
is not set yet.
|
private final java.util.concurrent.ConcurrentHashMap<java.lang.Object,java.lang.Object> attributes
public DefaultIoSessionAttributeMap()
public java.lang.Object getAttribute(IoSession session, java.lang.Object key, java.lang.Object defaultValue)
if (containsAttribute(key)) {
return getAttribute(key);
} else {
setAttribute(key, defaultValue);
return defaultValue;
}
getAttribute in interface IoSessionAttributeMappublic java.lang.Object setAttribute(IoSession session, java.lang.Object key, java.lang.Object value)
setAttribute in interface IoSessionAttributeMapkey - the key of the attributevalue - the value of the attributepublic java.lang.Object setAttributeIfAbsent(IoSession session, java.lang.Object key, java.lang.Object value)
if (containsAttribute(key)) {
return getAttribute(key);
} else {
return setAttribute(key, value);
}
setAttributeIfAbsent in interface IoSessionAttributeMappublic java.lang.Object removeAttribute(IoSession session, java.lang.Object key)
removeAttribute in interface IoSessionAttributeMappublic boolean removeAttribute(IoSession session, java.lang.Object key, java.lang.Object value)
if (containsAttribute(key) && getAttribute(key).equals(value)) {
removeAttribute(key);
return true;
} else {
return false;
}
removeAttribute in interface IoSessionAttributeMappublic boolean replaceAttribute(IoSession session, java.lang.Object key, java.lang.Object oldValue, java.lang.Object newValue)
if (containsAttribute(key) && getAttribute(key).equals(oldValue)) {
setAttribute(key, newValue);
return true;
} else {
return false;
}
replaceAttribute in interface IoSessionAttributeMappublic boolean containsAttribute(IoSession session, java.lang.Object key)
containsAttribute in interface IoSessionAttributeMappublic java.util.Set<java.lang.Object> getAttributeKeys(IoSession session)
getAttributeKeys in interface IoSessionAttributeMappublic void dispose(IoSession session) throws java.lang.Exception
dispose in interface IoSessionAttributeMapjava.lang.Exception