Package org.glassfish.grizzly.attributes
Class IndexedAttributeHolder
- java.lang.Object
-
- org.glassfish.grizzly.attributes.IndexedAttributeHolder
-
- All Implemented Interfaces:
AttributeHolder
public final class IndexedAttributeHolder extends Object implements AttributeHolder
AttributeHolder, which supports indexed access to storedAttributes. Access to such indexedAttributes could be as fast as access to array. This implementation is thread-safe.- Author:
- Alexey Stashok
- See Also:
AttributeHolder,NamedAttributeHolder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classIndexedAttributeHolder.IndexedAttributeAccessorImplIndexedAttributeAccessorimplementation.
-
Field Summary
Fields Modifier and Type Field Description protected DefaultAttributeBuilderattributeBuilderprotected IndexedAttributeAccessorindexedAttributeAccessor
-
Constructor Summary
Constructors Constructor Description IndexedAttributeHolder(AttributeBuilder attributeBuilder)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear all the attributes.voidcopyFrom(AttributeHolder srcAttributes)Copies attributes from the srcAttributes to this AttributeHoldervoidcopyTo(AttributeHolder dstAttributes)Copies attributes from this AttributeHolder to the dstAttributes.ObjectgetAttribute(String name)Return an object based on a name.ObjectgetAttribute(String name, NullaryFunction initializer)Return an object based on a name.AttributeBuildergetAttributeBuilder()Get AttributeBuilder, associated with this holderSet<String>getAttributeNames()Return aSetof attribute names.IndexedAttributeAccessorgetIndexedAttributeAccessor()ReturnsIndexedAttributeAccessorfor accessingAttributes by index.voidrecycle()Recycle AttributeHolderObjectremoveAttribute(String name)Remove a name/value object.voidsetAttribute(String name, Object value)Set a name/value object.
-
-
-
Field Detail
-
attributeBuilder
protected final DefaultAttributeBuilder attributeBuilder
-
indexedAttributeAccessor
protected final IndexedAttributeAccessor indexedAttributeAccessor
-
-
Constructor Detail
-
IndexedAttributeHolder
@Deprecated public IndexedAttributeHolder(AttributeBuilder attributeBuilder)
Deprecated.- Parameters:
attributeBuilder-
-
-
Method Detail
-
getAttribute
public Object getAttribute(String name)
Return an object based on a name.- Specified by:
getAttributein interfaceAttributeHolder- Parameters:
name- - name of an attribute- Returns:
- - attribute value for the name, null if name does not exist in attributes
-
getAttribute
public Object getAttribute(String name, NullaryFunction initializer)
Return an object based on a name.- Specified by:
getAttributein interfaceAttributeHolder- Parameters:
name- - name of an attributeinitializer- the initializer to be used to assign a default attribute value, in case it hasn't been assigned- Returns:
- - attribute value for the name, null if name does not exist in attributes
-
setAttribute
public void setAttribute(String name, Object value)
Set a name/value object.- Specified by:
setAttributein interfaceAttributeHolder- Parameters:
name- - name of an attributevalue- - value of named attribute
-
removeAttribute
public Object removeAttribute(String name)
Remove a name/value object.- Specified by:
removeAttributein interfaceAttributeHolder- Parameters:
name- - name of an attribute- Returns:
- attribute which has been removed
-
getAttributeNames
public Set<String> getAttributeNames()
Return aSetof attribute names.- Specified by:
getAttributeNamesin interfaceAttributeHolder- Returns:
- -
Setof attribute names
-
copyFrom
public void copyFrom(AttributeHolder srcAttributes)
Description copied from interface:AttributeHolderCopies attributes from the srcAttributes to this AttributeHolder- Specified by:
copyFromin interfaceAttributeHolder
-
copyTo
public void copyTo(AttributeHolder dstAttributes)
Description copied from interface:AttributeHolderCopies attributes from this AttributeHolder to the dstAttributes.- Specified by:
copyToin interfaceAttributeHolder
-
recycle
public void recycle()
Recycle AttributeHolder- Specified by:
recyclein interfaceAttributeHolder
-
clear
public void clear()
Clear all the attributes.- Specified by:
clearin interfaceAttributeHolder
-
getAttributeBuilder
public AttributeBuilder getAttributeBuilder()
Get AttributeBuilder, associated with this holder- Specified by:
getAttributeBuilderin interfaceAttributeHolder- Returns:
- AttributeBuilder
-
getIndexedAttributeAccessor
public IndexedAttributeAccessor getIndexedAttributeAccessor()
ReturnsIndexedAttributeAccessorfor accessingAttributes by index.- Specified by:
getIndexedAttributeAccessorin interfaceAttributeHolder- Returns:
IndexedAttributeAccessorfor accessingAttributes by index.
-
-