Package org.arakhne.afc.attrs.collection
Class HeapAttributeCollection
- java.lang.Object
-
- org.arakhne.afc.attrs.collection.AbstractAttributeProvider
-
- org.arakhne.afc.attrs.collection.AbstractAttributeCollection
-
- org.arakhne.afc.attrs.collection.HeapAttributeCollection
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Attribute>,AttributeCollection,AttributeProvider,JsonableObject
public class HeapAttributeCollection extends AbstractAttributeCollection
This class implements an attribute provider which only works with the Heap space.- Version:
- 17.0 2020-01-04 14:41:51
- Author:
- Stéphane GALLAND
- See Also:
- Serialized Form
- Maven Group Id:
- org.arakhne.afc.advanced
- Maven Artifact Id:
- attributes
-
-
Constructor Summary
Constructors Constructor Description HeapAttributeCollection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttributes(Map<String,Object> content)Put the values given as parameter in this attribute provider.voidaddAttributes(AttributeProvider content)Put the values given as parameter in this attribute provider.HeapAttributeCollectionclone()Make a deep copy of this object and replies the copy.voidflush()Force this provider to synchronized the memory state of the attributes with a remote storage area.voidfreeMemory()Clean the internal memory-storage structures if they exist.Collection<String>getAllAttributeNames()Replies all the attribute names.Collection<Attribute>getAllAttributes()Replies all the attributes.Map<AttributeType,Collection<Attribute>>getAllAttributesByType()Replies all the attributes sorted by type.AttributeValuegetAttribute(String name)Replies the value for the given attribute.AttributeValuegetAttribute(String name, AttributeValue defaultValue)Replies the value for the given attribute.intgetAttributeCount()Replies the count of attributes.AttributegetAttributeObject(String name)Replies the attribute with the given name.protected AttributegetStoredAttribute(String name, AttributeType expectedType)Replies the attribute with the given name.protected AttributeValuegetStoredAttributeValue(String name, AttributeType expectedType)Replies the attribute with the given name.booleanhasAttribute(String name)Replies if the given attribute exists.booleanremoveAllAttributes()Remove all the attributes.booleanremoveAttribute(String name)Remove the given attribute.booleanrenameAttribute(String oldname, String newname, boolean overwrite)Rename the attribute .AttributesetAttribute(String name, boolean value)Set the value for the given attribute.AttributesetAttribute(String name, double value)Set the value for the given attribute.AttributesetAttribute(String name, float value)Set the value for the given attribute.AttributesetAttribute(String name, int value)Set the value for the given attribute.AttributesetAttribute(String name, long value)Set the value for the given attribute.AttributesetAttribute(String name, Class<?> value)Set the value for the given attribute.AttributesetAttribute(String name, Enum<?> value)Set the value for the given attribute.AttributesetAttribute(String name, String value)Set the value for the given attribute.AttributesetAttribute(String name, InetAddress value)Set the value for the given attribute.AttributesetAttribute(String name, InetSocketAddress value)Set the value for the given attribute.AttributesetAttribute(String name, URI value)Set the value for the given attribute.AttributesetAttribute(String name, URL value)Set the value for the given attribute.AttributesetAttribute(String name, Date value)Set the value for the given attribute.AttributesetAttribute(String name, UUID value)Set the value for the given attribute.AttributesetAttribute(String name, AttributeValue value)Set the value for the given attribute.AttributesetAttribute(Attribute value)Set the value for the given attribute.voidsetAttributes(Map<String,Object> content)Set the content of this collection from the given map.voidsetAttributes(AttributeProvider content)Set the content of this collection from the given map.AttributesetAttributeType(String name, AttributeType type)Set the type of the attribute with the given name.voidtoMap(Map<String,Object> mapToFill)Fill the given map with the values stored in this attribute provider.-
Methods inherited from class org.arakhne.afc.attrs.collection.AbstractAttributeCollection
addAttributeChangeListener, fireAttributeAddedEvent, fireAttributeChangedEvent, fireAttributeClearedEvent, fireAttributeRemovedEvent, fireAttributeRenamedEvent, isEventFirable, removeAttributeChangeListener, renameAttribute, setEventFirable
-
Methods inherited from class org.arakhne.afc.attrs.collection.AbstractAttributeProvider
attributes, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeAsBool, getAttributeAsDate, getAttributeAsDouble, getAttributeAsEnumeration, getAttributeAsEnumeration, getAttributeAsFloat, getAttributeAsInetAddress, getAttributeAsInt, getAttributeAsJavaClass, getAttributeAsLong, getAttributeAsString, getAttributeAsURI, getAttributeAsURL, getAttributeAsUUID, iterator, protectNull, toJson, toString, unprotectNull
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.arakhne.afc.attrs.collection.AttributeProvider
attributes, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeAsBool, getAttributeAsDate, getAttributeAsDouble, getAttributeAsEnumeration, getAttributeAsEnumeration, getAttributeAsFloat, getAttributeAsInetAddress, getAttributeAsInt, getAttributeAsJavaClass, getAttributeAsLong, getAttributeAsString, getAttributeAsURI, getAttributeAsURL, getAttributeAsUUID, toMap
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.arakhne.afc.vmutil.json.JsonableObject
toJson
-
-
-
-
Method Detail
-
clone
@Pure public HeapAttributeCollection clone()
Make a deep copy of this object and replies the copy.- Specified by:
clonein interfaceAttributeCollection- Specified by:
clonein interfaceAttributeProvider- Overrides:
clonein classAbstractAttributeCollection- Returns:
- the deep copy.
-
addAttributes
public void addAttributes(Map<String,Object> content)
Description copied from interface:AttributeCollectionPut the values given as parameter in this attribute provider. Any previous content of this attribute collection will remain if the keys are not inside the given content. If the values from the given content will be used to overwrite any existing value.- Parameters:
content- is the content to add inside.- See Also:
AttributeCollection.setAttributes(Map)
-
addAttributes
public void addAttributes(AttributeProvider content) throws AttributeException
Description copied from interface:AttributeCollectionPut the values given as parameter in this attribute provider. Any previous content of this attribute collection will remain if the keys are not inside the given content. If the values from the given content will be used to overwrite any existing value.- Parameters:
content- is the content to add inside.- Throws:
AttributeException- if one attribute from the content cannot be inserted.- See Also:
AttributeCollection.addAttributes(AttributeProvider)
-
setAttributes
public void setAttributes(Map<String,Object> content)
Description copied from interface:AttributeCollectionSet the content of this collection from the given map. Any previous content of this attribute collection will be lost. This function is equivalent to:this.removeAllAttributes(); this.addAttributes(content);- Parameters:
content- is the content.- See Also:
AttributeCollection.addAttributes(Map)
-
setAttributes
public void setAttributes(AttributeProvider content) throws AttributeException
Description copied from interface:AttributeCollectionSet the content of this collection from the given map. Any previous content of this attribute collection will be lost. This function is equivalent to:this.removeAllAttributes(); this.addAttributes(content);- Parameters:
content- is the content.- Throws:
AttributeException- if one attribute from the content cannot be inserted.- See Also:
AttributeCollection.addAttributes(AttributeProvider)
-
toMap
public void toMap(Map<String,Object> mapToFill)
Description copied from interface:AttributeProviderFill the given map with the values stored in this attribute provider.- Parameters:
mapToFill- is the map to fill, nevernull.
-
getAttributeCount
@Pure public int getAttributeCount()
Description copied from interface:AttributeProviderReplies the count of attributes.- Returns:
- the count of attributes.
-
hasAttribute
@Pure public boolean hasAttribute(String name)
Description copied from interface:AttributeProviderReplies if the given attribute exists.- Parameters:
name- the name.- Returns:
trueis an attribute with the given name exists, otherwisefalse
-
getAllAttributes
@Pure public Collection<Attribute> getAllAttributes()
Description copied from interface:AttributeProviderReplies all the attributes.- Returns:
- the list of all attributes
-
getAllAttributesByType
@Pure public Map<AttributeType,Collection<Attribute>> getAllAttributesByType()
Description copied from interface:AttributeProviderReplies all the attributes sorted by type.The keys of the returned hashtable are the types and the values are array of attributes (
Vector).- Returns:
- the attributes grouped by type.
-
getAllAttributeNames
@Pure public Collection<String> getAllAttributeNames()
Description copied from interface:AttributeProviderReplies all the attribute names. This function never load the attribute values even if they are not inside the storage layer.- Returns:
- the list of all attribute names.
-
getAttribute
@Pure public AttributeValue getAttribute(String name)
Description copied from interface:AttributeProviderReplies the value for the given attribute.- Parameters:
name- the name.- Returns:
- the value or
null
-
getAttribute
@Pure public AttributeValue getAttribute(String name, AttributeValue defaultValue)
Description copied from interface:AttributeProviderReplies the value for the given attribute.- Parameters:
name- the name.defaultValue- is the default value replied if the attribute has no value.- Returns:
- the value or
null
-
getAttributeObject
@Pure public Attribute getAttributeObject(String name)
Description copied from interface:AttributeProviderReplies the attribute with the given name.- Parameters:
name- the name.- Returns:
- the attribute or
null
-
getStoredAttribute
@Pure protected Attribute getStoredAttribute(String name, AttributeType expectedType)
Replies the attribute with the given name.- Parameters:
name- is the name of the attribute to retreiveexpectedType- is the expected type for the attribute.- Returns:
- the value or
null
-
getStoredAttributeValue
@Pure protected AttributeValue getStoredAttributeValue(String name, AttributeType expectedType)
Replies the attribute with the given name.- Parameters:
name- is the name of the attribute to retreiveexpectedType- is the expected type for the attribute.- Returns:
- the value or
null
-
setAttributeType
public Attribute setAttributeType(String name, AttributeType type) throws AttributeException
Description copied from interface:AttributeCollectionSet the type of the attribute with the given name.- Parameters:
name- is the name of the attributetype- is the desired type.- Returns:
- the changed attribute or
null - Throws:
AttributeException- on error.
-
setAttribute
public Attribute setAttribute(String name, AttributeValue value) throws AttributeException
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null - Throws:
AttributeException- on error.
-
setAttribute
public Attribute setAttribute(String name, boolean value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, int value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, long value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, float value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, double value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, String value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, UUID value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, URL value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, URI value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, Date value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(Attribute value) throws AttributeException
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
value- is the value to store.- Returns:
- the changed attribute or
null - Throws:
AttributeException- on error.
-
setAttribute
public Attribute setAttribute(String name, InetAddress value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, InetSocketAddress value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, Enum<?> value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
setAttribute
public Attribute setAttribute(String name, Class<?> value)
Description copied from interface:AttributeCollectionSet the value for the given attribute.- Parameters:
name- is the name of the attribute to set.value- is the value to store.- Returns:
- the changed attribute or
null
-
removeAttribute
public boolean removeAttribute(String name)
Description copied from interface:AttributeCollectionRemove the given attribute.- Parameters:
name- is the name of the attribute to remove.- Returns:
trueon success, otherwhisefalse
-
removeAllAttributes
public boolean removeAllAttributes()
Description copied from interface:AttributeCollectionRemove all the attributes.- Returns:
falseif something wrong appends
-
renameAttribute
public boolean renameAttribute(String oldname, String newname, boolean overwrite)
Description copied from interface:AttributeCollectionRename the attribute .- Parameters:
oldname- is the name of the attribute to rename.newname- is the new name of the attribute.overwrite- must betrueif the value of an existing attribute named bynewnamemust be overwritten by the value of the attribute namedoldname.- Returns:
falseif something wrong appends
-
freeMemory
public void freeMemory()
Description copied from interface:AttributeProviderClean the internal memory-storage structures if they exist.This function permits to limit the memory usage without removing the attribute value from a hard storage area (database, files...). The attribute which are freed by this method could be reloaded in memory with a call to a getting method.
-
flush
public void flush()
Description copied from interface:AttributeCollectionForce this provider to synchronized the memory state of the attributes with a remote storage area.
-
-