Package org.red5.server
Class AttributeStore
java.lang.Object
org.red5.server.AttributeStore
- All Implemented Interfaces:
IAttributeStore
,ICastingAttributeStore
,AttributeStoreMXBean
- Direct Known Subclasses:
BaseConnection
,Client
,PersistableAttributeStore
,SharedObject
,WebSocketConnection
AttributeStore class.
- Author:
- mondain
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates empty attribute store.AttributeStore
(Map<String, Object> values) Creates attribute store with initial values.AttributeStore
(IAttributeStore values) Creates attribute store with initial values. -
Method Summary
Modifier and TypeMethodDescriptionfilterNull
(Map<String, Object> values) Filterstatic AttributeStore
from
(CompositeData cd) Allows for reconstruction via CompositeData.getAttribute
(Enum<?> enm) Return the value for a given attribute.getAttribute
(String name) Return the value for a given attribute.getAttribute
(String name, Object defaultValue) Return the value for a given attribute and set it if it doesn't exist.Get the attribute names.Get the attributes.getBoolAttribute
(String name) Get Boolean attribute by namegetByteAttribute
(String name) Get Byte attribute by namegetDoubleAttribute
(String name) Get Double attribute by namegetIntAttribute
(String name) Get Integer attribute by nameList
<?> getListAttribute
(String name) Get List attribute by namegetLongAttribute
(String name) Get boolean attribute by nameMap
<?, ?> getMapAttribute
(String name) Get Long attribute by nameSet
<?> getSetAttribute
(String name) Get Set attribute by namegetShortAttribute
(String name) Get Short attribute by namegetStringAttribute
(String name) Get String attribute by nameboolean
hasAttribute
(Enum<?> enm) Check the object has an attribute.boolean
hasAttribute
(String name) hasAttribute.boolean
removeAttribute
(Enum<?> enm) Remove an attribute.boolean
removeAttribute
(String name) removeAttribute.void
Remove all attributes.boolean
setAttribute
(Enum<?> enm, Object value) Set an attribute on this object.boolean
setAttribute
(String name, Object value) Set an attribute on this object.boolean
setAttributes
(Map<String, Object> values) Set multiple attributes on this object.boolean
setAttributes
(IAttributeStore values) Set multiple attributes on this object.int
size()
Size of the attribute store.
-
Field Details
-
log
protected org.slf4j.Logger log -
isTrace
protected boolean isTrace -
isDebug
protected boolean isDebug -
attributes
Map for attributes with initialCapacity = 1, loadFactor = .9, concurrencyLevel = (# of processors)
-
-
Constructor Details
-
AttributeStore
public AttributeStore()Creates empty attribute store. Object is not associated with a persistence storage. -
AttributeStore
Creates attribute store with initial values. Object is not associated with a persistence storage.- Parameters:
values
- map
-
AttributeStore
Creates attribute store with initial values. Object is not associated with a persistence storage.- Parameters:
values
- map
-
-
Method Details
-
filterNull
Filternull
keys and values from given map.- Parameters:
values
- the map to filter- Returns:
- filtered map
-
hasAttribute
hasAttribute.
Check the object has an attribute.- Specified by:
hasAttribute
in interfaceAttributeStoreMXBean
- Specified by:
hasAttribute
in interfaceIAttributeStore
- Parameters:
name
- aString
object- Returns:
- a boolean
-
hasAttribute
Check the object has an attribute.- Specified by:
hasAttribute
in interfaceIAttributeStore
- Parameters:
enm
- the enum for the attribute to check- Returns:
- true if the attribute exists otherwise false
-
getAttributeNames
Get the attribute names. The resulting set will be read-only.- Specified by:
getAttributeNames
in interfaceAttributeStoreMXBean
- Specified by:
getAttributeNames
in interfaceIAttributeStore
- Returns:
- a
Set
object
-
getAttributes
Get the attributes. The resulting map will be read-only.- Specified by:
getAttributes
in interfaceIAttributeStore
- Returns:
- a
Map
object
-
getAttribute
Return the value for a given attribute.- Specified by:
getAttribute
in interfaceIAttributeStore
- Parameters:
name
- aString
object- Returns:
- a
Object
object
-
getAttribute
Return the value for a given attribute.- Specified by:
getAttribute
in interfaceIAttributeStore
- Parameters:
enm
- the enum for the attribute to get- Returns:
- the attribute value or null if the attribute doesn't exist
-
getAttribute
Return the value for a given attribute and set it if it doesn't exist. This is a utility function that internally performs the following code:
if (!hasAttribute(name)) setAttribute(name, defaultValue); return getAttribute(name);
- Specified by:
getAttribute
in interfaceIAttributeStore
- Parameters:
name
- the name of the attribute to getdefaultValue
- the value of the attribute to set if the attribute doesn't exist- Returns:
- the attribute value
-
setAttribute
Set an attribute on this object. Set an attribute on this object.- Specified by:
setAttribute
in interfaceIAttributeStore
- Parameters:
name
- the name of the attribute to changevalue
- the new value of the attribute- Returns:
- true if the attribute value changed otherwise false
-
setAttribute
Set an attribute on this object.- Specified by:
setAttribute
in interfaceIAttributeStore
- Parameters:
enm
- the enum of the attribute to changevalue
- the new value of the attribute- Returns:
- true if the attribute value was added or changed, otherwise false
-
setAttributes
Set multiple attributes on this object.- Specified by:
setAttributes
in interfaceIAttributeStore
- Parameters:
values
- aMap
object- Returns:
- a boolean
-
setAttributes
Set multiple attributes on this object.- Specified by:
setAttributes
in interfaceIAttributeStore
- Parameters:
values
- the attributes to set- Returns:
- true if the attribute values changed otherwise false
-
removeAttribute
removeAttribute.
Remove an attribute.- Specified by:
removeAttribute
in interfaceAttributeStoreMXBean
- Specified by:
removeAttribute
in interfaceIAttributeStore
- Parameters:
name
- aString
object- Returns:
- a boolean
-
removeAttribute
Remove an attribute.- Specified by:
removeAttribute
in interfaceIAttributeStore
- Parameters:
enm
- the enum of the attribute to remove- Returns:
- true if the attribute was found and removed otherwise false
-
removeAttributes
public void removeAttributes()Remove all attributes.- Specified by:
removeAttributes
in interfaceAttributeStoreMXBean
- Specified by:
removeAttributes
in interfaceIAttributeStore
-
size
public int size()Size of the attribute store.- Specified by:
size
in interfaceIAttributeStore
- Returns:
- a int
-
getBoolAttribute
Get Boolean attribute by name Get Boolean attribute by name- Specified by:
getBoolAttribute
in interfaceICastingAttributeStore
- Parameters:
name
- Attribute name- Returns:
- Attribute
-
getByteAttribute
Get Byte attribute by name Get Byte attribute by name- Specified by:
getByteAttribute
in interfaceICastingAttributeStore
- Parameters:
name
- Attribute name- Returns:
- Attribute
-
getDoubleAttribute
Get Double attribute by name Get Double attribute by name- Specified by:
getDoubleAttribute
in interfaceICastingAttributeStore
- Parameters:
name
- Attribute name- Returns:
- Attribute
-
getIntAttribute
Get Integer attribute by name Get Integer attribute by name- Specified by:
getIntAttribute
in interfaceICastingAttributeStore
- Parameters:
name
- Attribute name- Returns:
- Attribute
-
getListAttribute
Get List attribute by name Get List attribute by name- Specified by:
getListAttribute
in interfaceICastingAttributeStore
- Parameters:
name
- Attribute name- Returns:
- Attribute
-
getLongAttribute
Get boolean attribute by name Get boolean attribute by name- Specified by:
getLongAttribute
in interfaceICastingAttributeStore
- Parameters:
name
- Attribute name- Returns:
- Attribute
-
getMapAttribute
Get Long attribute by name Get Long attribute by name- Specified by:
getMapAttribute
in interfaceICastingAttributeStore
- Parameters:
name
- Attribute name- Returns:
- Attribute
-
getSetAttribute
Get Set attribute by name Get Set attribute by name- Specified by:
getSetAttribute
in interfaceICastingAttributeStore
- Parameters:
name
- Attribute name- Returns:
- Attribute
-
getShortAttribute
Get Short attribute by name Get Short attribute by name- Specified by:
getShortAttribute
in interfaceICastingAttributeStore
- Parameters:
name
- Attribute name- Returns:
- Attribute
-
getStringAttribute
Get String attribute by name Get String attribute by name- Specified by:
getStringAttribute
in interfaceICastingAttributeStore
- Parameters:
name
- Attribute name- Returns:
- Attribute
-
from
Allows for reconstruction via CompositeData.- Parameters:
cd
- composite data- Returns:
- AttributeStore class instance
-