net.user1.union.core.attribute
Interface AttributeHolder

All Known Subinterfaces:
Account, Client, Room, Server

public interface AttributeHolder

An AttributeHolder can have attributes. When setting an attribute you can set zero to many flags that will customize how the attribute behaves on the server. You can set more than one flag on an attribute using the bitwise OR (|) operator. Example: setAttribute("name", "Chatter", "chatRoom", Attribute.FLAG_SHARED | Attribute.FLAG_IMMUTABLE)

See Also:
Attribute

Method Summary
 Attribute getAttribute(java.lang.String name)
          Gets a global scope (Attribute.SCOPE_GLOBAL) attribute with the given name or null if no such attribute exists.
 Attribute getAttribute(java.lang.String name, java.lang.String scope)
          Gets an attribute or null if no such attribute exists.
 java.util.List<Attribute> getAttributes()
          Returns all of the attributes for this AttributeHolder.
 java.util.List<Attribute> getAttributes(java.lang.String scope, int flags)
          Returns the list of attributes in the given scope that match the given flags.
 java.util.Map<java.lang.String,java.util.Map<java.lang.String,Attribute>> getAttributesByScope()
          Returns all of the attributes on the server.
 java.lang.Object getAttributeValue(java.lang.String name)
          Returns the value of the attribute with the given name from the global scope (Attribute.SCOPE_GLOBAL) or null if the attribute doesn't exist.
 java.lang.Object getAttributeValue(java.lang.String name, java.lang.String scope)
          Returns the value of the attribute with the given name from the given scope or null if the attribute doesn't exist.
 void onChangeAttribute(Attribute attr)
          Callback to attribute holders when an attribute changes.
 void onRemoveAttribute(Attribute attr)
          Callback to attribute holders when an attribute is removed.
 void removeAttribute(java.lang.String name)
          Removes the global scoped attribute with the given name.
 void removeAttribute(java.lang.String name, java.lang.String scope)
          Removes the attribute with the given name from the given scope.
 Attribute setAttribute(java.lang.String name, java.lang.Object value, java.lang.String scope, int flags)
          Sets or updates an attribute on the attribute holder.
 

Method Detail

getAttributeValue

java.lang.Object getAttributeValue(java.lang.String name)
Returns the value of the attribute with the given name from the global scope (Attribute.SCOPE_GLOBAL) or null if the attribute doesn't exist.

Parameters:
name - - the name of the attribute
Returns:
the value of the attribute with the given name from the global scope or null if the attribute doesn't exist

getAttributeValue

java.lang.Object getAttributeValue(java.lang.String name,
                                   java.lang.String scope)
Returns the value of the attribute with the given name from the given scope or null if the attribute doesn't exist.

Parameters:
name - - the name of the attribute
scope - - the scope of the attribute
Returns:
the value of the attribute with the given name from the given scope or null if the attribute doesn't exist

setAttribute

Attribute setAttribute(java.lang.String name,
                       java.lang.Object value,
                       java.lang.String scope,
                       int flags)
                       throws AttributeException
Sets or updates an attribute on the attribute holder. Scope only applies to client attributes. When set it is the room ID of the room that the attribute applies. It allows clients to have duplicate named attributes across rooms (eg. "score" attribute scoped to "games.Chess" and a "score" attribute scoped to "games.Hockey")

Parameters:
name - - the name of the attribute
value - - the value of the attribute
scope - - the scope of the attribute
flags - - the flags set for the attribute (eg. Attribute.FLAG_SHARED | Attribute.FLAG_IMMUTABLE)
Returns:
the attribute that was set
Throws:
AttributeException

getAttribute

Attribute getAttribute(java.lang.String name,
                       java.lang.String scope)
Gets an attribute or null if no such attribute exists.

Parameters:
name - - the name of the attribute to get
scope - - the scope of the attribute
Returns:
the attribute

getAttribute

Attribute getAttribute(java.lang.String name)
Gets a global scope (Attribute.SCOPE_GLOBAL) attribute with the given name or null if no such attribute exists.

Parameters:
name - - the name of the attribute to get
Returns:
the attribute

removeAttribute

void removeAttribute(java.lang.String name,
                     java.lang.String scope)
                     throws AttributeException
Removes the attribute with the given name from the given scope.

Parameters:
name - - the name of the attribute to remove
scope - - the scope of the attribute being removed
Throws:
AttributeException

removeAttribute

void removeAttribute(java.lang.String name)
                     throws AttributeException
Removes the global scoped attribute with the given name.

Parameters:
name - - the name of the attribute to remove
Throws:
AttributeException

onChangeAttribute

void onChangeAttribute(Attribute attr)
Callback to attribute holders when an attribute changes. Should not be invoked directly.

Parameters:
attr - - the attribute that was changed

onRemoveAttribute

void onRemoveAttribute(Attribute attr)
Callback to attribute holders when an attribute is removed. Should not be invoked directly.

Parameters:
attr - - the attribute that was removed

getAttributes

java.util.List<Attribute> getAttributes(java.lang.String scope,
                                        int flags)
Returns the list of attributes in the given scope that match the given flags.

Parameters:
scope - - the scope the attributes must exist in
flags - - the flags the attributes must have
Returns:
a list of attributes that match the given scope and flags

getAttributes

java.util.List<Attribute> getAttributes()
Returns all of the attributes for this AttributeHolder.

Returns:
a list of all attributes set on this AttributeHolder

getAttributesByScope

java.util.Map<java.lang.String,java.util.Map<java.lang.String,Attribute>> getAttributesByScope()
Returns all of the attributes on the server.

Returns:
all of the attributes on the server


Copyright USER1 Subsystems Corporation - Tue Jan 28 2014, 05:05 PM -0500