Class AttributeStore

java.lang.Object
org.red5.server.AttributeStore
All Implemented Interfaces:
IAttributeStore, ICastingAttributeStore, AttributeStoreMXBean
Direct Known Subclasses:
BaseConnection, Client, PersistableAttributeStore

public class AttributeStore extends Object implements ICastingAttributeStore
  • Field Details

    • log

      protected static org.slf4j.Logger log
    • attributes

      protected ConcurrentMap<String,Object> attributes
      Map for attributes
  • Constructor Details

    • AttributeStore

      public AttributeStore()
      Creates empty attribute store. Object is not associated with a persistence storage.
    • AttributeStore

      public AttributeStore(Map<String,Object> values)
      Creates attribute store with initial values. Object is not associated with a persistence storage.
      Parameters:
      values - map
    • AttributeStore

      public AttributeStore(IAttributeStore values)
      Creates attribute store with initial values. Object is not associated with a persistence storage.
      Parameters:
      values - map
  • Method Details

    • filterNull

      protected Map<String,Object> filterNull(Map<String,Object> values)
      Filter
       null
       
      keys and values from given map.
      Parameters:
      values - the map to filter
      Returns:
      filtered map
    • getAttributeNames

      public Set<String> getAttributeNames()
      Get the attribute names. The resulting set will be read-only.
      Specified by:
      getAttributeNames in interface AttributeStoreMXBean
      Specified by:
      getAttributeNames in interface IAttributeStore
      Returns:
      set containing all attribute names
    • getAttributes

      public Map<String,Object> getAttributes()
      Get the attributes. The resulting map will be read-only.
      Specified by:
      getAttributes in interface IAttributeStore
      Returns:
      map containing all attributes
    • getAttribute

      public Object getAttribute(String name)
      Return the value for a given attribute.
      Specified by:
      getAttribute in interface IAttributeStore
      Parameters:
      name - the name of the attribute to get
      Returns:
      the attribute value or null if the attribute doesn't exist
    • getAttribute

      public Object getAttribute(String name, Object defaultValue)
      Return the value for a given attribute and set it if it doesn't exist.
      Specified by:
      getAttribute in interface IAttributeStore
      Parameters:
      name - the name of the attribute to get
      defaultValue - the value of the attribute to set if the attribute doesn't exist
      Returns:
      the attribute value
    • hasAttribute

      public boolean hasAttribute(String name)
      Check the object has an attribute.
      Specified by:
      hasAttribute in interface AttributeStoreMXBean
      Specified by:
      hasAttribute in interface IAttributeStore
      Parameters:
      name - the name of the attribute to check
      Returns:
      true if the attribute exists otherwise false
    • setAttribute

      public boolean setAttribute(String name, Object value)
      Set an attribute on this object.
      Specified by:
      setAttribute in interface IAttributeStore
      Parameters:
      name - the name of the attribute to change
      value - the new value of the attribute
      Returns:
      true if the attribute value was added or changed, otherwise false
    • setAttributes

      public boolean setAttributes(Map<String,Object> values)
      Set multiple attributes on this object.
      Specified by:
      setAttributes in interface IAttributeStore
      Parameters:
      values - the attributes to set
      Returns:
      true if the attribute values changed otherwise false
    • setAttributes

      public boolean setAttributes(IAttributeStore values)
      Set multiple attributes on this object.
      Specified by:
      setAttributes in interface IAttributeStore
      Parameters:
      values - the attributes to set
      Returns:
      true if the attribute values changed otherwise false
    • removeAttribute

      public boolean removeAttribute(String name)
      Remove an attribute.
      Specified by:
      removeAttribute in interface AttributeStoreMXBean
      Specified by:
      removeAttribute in interface IAttributeStore
      Parameters:
      name - the name 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 interface AttributeStoreMXBean
      Specified by:
      removeAttributes in interface IAttributeStore
    • size

      public int size()
      Size of the attribute store.
      Specified by:
      size in interface IAttributeStore
      Returns:
      count of attributes
    • getBoolAttribute

      public Boolean getBoolAttribute(String name)
      Get Boolean attribute by name
      Specified by:
      getBoolAttribute in interface ICastingAttributeStore
      Parameters:
      name - Attribute name
      Returns:
      Attribute
    • getByteAttribute

      public Byte getByteAttribute(String name)
      Get Byte attribute by name
      Specified by:
      getByteAttribute in interface ICastingAttributeStore
      Parameters:
      name - Attribute name
      Returns:
      Attribute
    • getDoubleAttribute

      public Double getDoubleAttribute(String name)
      Get Double attribute by name
      Specified by:
      getDoubleAttribute in interface ICastingAttributeStore
      Parameters:
      name - Attribute name
      Returns:
      Attribute
    • getIntAttribute

      public Integer getIntAttribute(String name)
      Get Integer attribute by name
      Specified by:
      getIntAttribute in interface ICastingAttributeStore
      Parameters:
      name - Attribute name
      Returns:
      Attribute
    • getListAttribute

      public List<?> getListAttribute(String name)
      Get List attribute by name
      Specified by:
      getListAttribute in interface ICastingAttributeStore
      Parameters:
      name - Attribute name
      Returns:
      Attribute
    • getLongAttribute

      public Long getLongAttribute(String name)
      Get boolean attribute by name
      Specified by:
      getLongAttribute in interface ICastingAttributeStore
      Parameters:
      name - Attribute name
      Returns:
      Attribute
    • getMapAttribute

      public Map<?,?> getMapAttribute(String name)
      Get Long attribute by name
      Specified by:
      getMapAttribute in interface ICastingAttributeStore
      Parameters:
      name - Attribute name
      Returns:
      Attribute
    • getSetAttribute

      public Set<?> getSetAttribute(String name)
      Get Set attribute by name
      Specified by:
      getSetAttribute in interface ICastingAttributeStore
      Parameters:
      name - Attribute name
      Returns:
      Attribute
    • getShortAttribute

      public Short getShortAttribute(String name)
      Get Short attribute by name
      Specified by:
      getShortAttribute in interface ICastingAttributeStore
      Parameters:
      name - Attribute name
      Returns:
      Attribute
    • getStringAttribute

      public String getStringAttribute(String name)
      Get String attribute by name
      Specified by:
      getStringAttribute in interface ICastingAttributeStore
      Parameters:
      name - Attribute name
      Returns:
      Attribute
    • from

      public static AttributeStore from(CompositeData cd)
      Allows for reconstruction via CompositeData.
      Parameters:
      cd - composite data
      Returns:
      AttributeStore class instance