Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.attributes

public final Class IndexedAttributeHolder

extends Object
implements AttributeHolder
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.attributes.AttributeHolder
Imports
java.util.Arrays, .Collections, .HashSet, .Set, java.util.function.Supplier

AttributeHolder, which supports indexed access to stored Attributes. Access to such indexed Attributes could be as fast as access to array. This implementation is thread-safe.
Author
Alexey Stashok
See Also
AttributeHolder, NamedAttributeHolder

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
private static class

Field Summary

Modifier and TypeField and Description
protected final DefaultAttributeBuilder
private volatile int
protected final IndexedAttributeAccessor
private IndexedAttributeHolder.Snapshot
private final Object

Constructor Summary

AccessConstructor and Description
public
public
IndexedAttributeHolder(final AttributeBuilder attributeBuilder, final int initialCapacity)

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements org.glassfish.grizzly.attributes.AttributeHolder.clear.

Clear all the attributes.

public void
copyFrom(final AttributeHolder srcAttributes)

Implements org.glassfish.grizzly.attributes.AttributeHolder.copyFrom.

Copies attributes from the srcAttributes to this AttributeHolder

public void
copyTo(final AttributeHolder dstAttributes)

Implements org.glassfish.grizzly.attributes.AttributeHolder.copyTo.

Copies attributes from this AttributeHolder to the dstAttributes.

private static Object[]
ensureSize(final Object[] array, final int size)

private static int[]
ensureSize(final int[] array, final int size)

public Object
getAttribute(final String name)

Implements org.glassfish.grizzly.attributes.AttributeHolder.getAttribute.

Return an object based on a name.

public Object
getAttribute(final String name, final Supplier<T> initializer)

Implements org.glassfish.grizzly.attributes.AttributeHolder.getAttribute.

Return an object based on a name.

public AttributeBuilder
getAttributeBuilder()

Implements org.glassfish.grizzly.attributes.AttributeHolder.getAttributeBuilder.

Get AttributeBuilder, associated with this holder

public Set<String>
public IndexedAttributeAccessor
public void
public Object
public void
setAttribute(final String name, final Object value)

Implements org.glassfish.grizzly.attributes.AttributeHolder.setAttribute.

Set a name/value object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeBuilderback to summary
protected final DefaultAttributeBuilder attributeBuilder
countback to summary
private volatile int count
indexedAttributeAccessorback to summary
protected final IndexedAttributeAccessor indexedAttributeAccessor
stateback to summary
private IndexedAttributeHolder.Snapshot state
syncback to summary
private final Object sync

Constructor Detail

IndexedAttributeHolderback to summary
public IndexedAttributeHolder(final AttributeBuilder attributeBuilder)
Annotations
@Deprecated
IndexedAttributeHolderback to summary
public IndexedAttributeHolder(final AttributeBuilder attributeBuilder, final int initialCapacity)

Method Detail

clearback to summary
public void clear()

Implements org.glassfish.grizzly.attributes.AttributeHolder.clear.

Doc from org.glassfish.grizzly.attributes.AttributeHolder.clear.

Clear all the attributes.

Annotations
@Override
copyFromback to summary
public void copyFrom(final AttributeHolder srcAttributes)

Implements org.glassfish.grizzly.attributes.AttributeHolder.copyFrom.

Doc from org.glassfish.grizzly.attributes.AttributeHolder.copyFrom.

Copies attributes from the srcAttributes to this AttributeHolder

Annotations
@Override
copyToback to summary
public void copyTo(final AttributeHolder dstAttributes)

Implements org.glassfish.grizzly.attributes.AttributeHolder.copyTo.

Doc from org.glassfish.grizzly.attributes.AttributeHolder.copyTo.

Copies attributes from this AttributeHolder to the dstAttributes.

Annotations
@Override
ensureSizeback to summary
private static Object[] ensureSize(final Object[] array, final int size)
ensureSizeback to summary
private static int[] ensureSize(final int[] array, final int size)
getAttributeback to summary
public Object getAttribute(final String name)

Implements org.glassfish.grizzly.attributes.AttributeHolder.getAttribute.

Doc from org.glassfish.grizzly.attributes.AttributeHolder.getAttribute.

Return an object based on a name.

Annotations
@Override
getAttributeback to summary
public Object getAttribute(final String name, final Supplier<T> initializer)

Implements org.glassfish.grizzly.attributes.AttributeHolder.getAttribute.

Doc from org.glassfish.grizzly.attributes.AttributeHolder.getAttribute.

Return an object based on a name.

Annotations
@Override
getAttributeBuilderback to summary
public AttributeBuilder getAttributeBuilder()

Implements org.glassfish.grizzly.attributes.AttributeHolder.getAttributeBuilder.

Doc from org.glassfish.grizzly.attributes.AttributeHolder.getAttributeBuilder.

Get AttributeBuilder, associated with this holder

Annotations
@Override
getAttributeNamesback to summary
public Set<String> getAttributeNames()

Implements org.glassfish.grizzly.attributes.AttributeHolder.getAttributeNames.

Doc from org.glassfish.grizzly.attributes.AttributeHolder.getAttributeNames.

Return a Set of attribute names.

Annotations
@Override
getIndexedAttributeAccessorback to summary
public IndexedAttributeAccessor getIndexedAttributeAccessor()

Implements org.glassfish.grizzly.attributes.AttributeHolder.getIndexedAttributeAccessor.

Returns IndexedAttributeAccessor for accessing Attributes by index.

Returns:IndexedAttributeAccessor

IndexedAttributeAccessor for accessing Attributes by index.

Annotations
@Override
recycleback to summary
public void recycle()

Implements org.glassfish.grizzly.attributes.AttributeHolder.recycle.

Doc from org.glassfish.grizzly.attributes.AttributeHolder.recycle.

Recycle AttributeHolder

Annotations
@Override
removeAttributeback to summary
public Object removeAttribute(final String name)

Implements org.glassfish.grizzly.attributes.AttributeHolder.removeAttribute.

Doc from org.glassfish.grizzly.attributes.AttributeHolder.removeAttribute.

Remove a name/value object.

Annotations
@Override
setAttributeback to summary
public void setAttribute(final String name, final Object value)

Implements org.glassfish.grizzly.attributes.AttributeHolder.setAttribute.

Doc from org.glassfish.grizzly.attributes.AttributeHolder.setAttribute.

Set a name/value object.

Annotations
@Override
org.glassfish.grizzly.attributes back to summary

protected final Class IndexedAttributeHolder.IndexedAttributeAccessorImpl

extends Object
implements IndexedAttributeAccessor
Class Inheritance
  • java.lang.Object
  • org.glassfish.grizzly.attributes.IndexedAttributeHolder.IndexedAttributeAccessorImpl
All Implemented Interfaces
org.glassfish.grizzly.attributes.IndexedAttributeAccessor

IndexedAttributeAccessor implementation.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public Object
getAttribute(final int index)

Implements org.glassfish.grizzly.attributes.IndexedAttributeAccessor.getAttribute.

Internal method for dynamic attribute support.

public Object
getAttribute(final int index, final Supplier<T> initializer)

Implements org.glassfish.grizzly.attributes.IndexedAttributeAccessor.getAttribute.

Internal method for dynamic attribute support.

public Object
removeAttribute(final int index)

Implements org.glassfish.grizzly.attributes.IndexedAttributeAccessor.removeAttribute.

Internal method for dynamic attribute support.

public void
setAttribute(final int index, final Object value)

Implements org.glassfish.grizzly.attributes.IndexedAttributeAccessor.setAttribute.

Internal method for dynamic attribute support.

private void
setSync(final int index, final Object value)

private Object
weakGet(final int index)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

IndexedAttributeAccessorImplback to summary
protected IndexedAttributeAccessorImpl()

Method Detail

getAttributeback to summary
public Object getAttribute(final int index)

Implements org.glassfish.grizzly.attributes.IndexedAttributeAccessor.getAttribute.

Doc from org.glassfish.grizzly.attributes.IndexedAttributeAccessor.getAttribute.

Internal method for dynamic attribute support. Return the value of the attribute by index.

Annotations
@Override
getAttributeback to summary
public Object getAttribute(final int index, final Supplier<T> initializer)

Implements org.glassfish.grizzly.attributes.IndexedAttributeAccessor.getAttribute.

Doc from org.glassfish.grizzly.attributes.IndexedAttributeAccessor.getAttribute.

Internal method for dynamic attribute support. Return the value of the attribute by index. If the attribute with such index is not set, set it to the default value, using the initializer, and return the default.

Annotations
@Override
removeAttributeback to summary
public Object removeAttribute(final int index)

Implements org.glassfish.grizzly.attributes.IndexedAttributeAccessor.removeAttribute.

Doc from org.glassfish.grizzly.attributes.IndexedAttributeAccessor.removeAttribute.

Internal method for dynamic attribute support. Removes the attribute with the index and returns its previous value.

Annotations
@Override
setAttributeback to summary
public void setAttribute(final int index, final Object value)

Implements org.glassfish.grizzly.attributes.IndexedAttributeAccessor.setAttribute.

Doc from org.glassfish.grizzly.attributes.IndexedAttributeAccessor.setAttribute.

Internal method for dynamic attribute support. Set the attribute with the index to value.

Annotations
@Override
setSyncback to summary
private void setSync(final int index, final Object value)
weakGetback to summary
private Object weakGet(final int index)
org.glassfish.grizzly.attributes back to summary

private Class IndexedAttributeHolder.Snapshot

extends Object
Class Inheritance
  • java.lang.Object
  • org.glassfish.grizzly.attributes.IndexedAttributeHolder.Snapshot

Field Summary

Modifier and TypeField and Description
private final int[]
private final int
private final Object[]

Constructor Summary

AccessConstructor and Description
public
Snapshot(Object[] values, int[] i2v, int size)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

i2vback to summary
private final int[] i2v
sizeback to summary
private final int size
valuesback to summary
private final Object[] values

Constructor Detail

Snapshotback to summary
public Snapshot(Object[] values, int[] i2v, int size)