Package org.arakhne.afc.attrs.collection
Class AbstractBufferedAttributeProvider
- java.lang.Object
-
- org.arakhne.afc.attrs.collection.AbstractAttributeProvider
-
- org.arakhne.afc.attrs.collection.AbstractBufferedAttributeProvider
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<Attribute>
,AttributeProvider
,JsonableObject
- Direct Known Subclasses:
DBaseFileAttributeAccessor
public abstract class AbstractBufferedAttributeProvider extends AbstractAttributeProvider
This class implements an abstract attribute container that use a memory cache.- 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 AbstractBufferedAttributeProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AbstractBufferedAttributeProvider
clone()
Make a deep copy of this object and replies the copy.void
freeMemory()
Clean the internal memory-storage structures if they exist.abstract 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.AttributeValue
getAttribute(String name)
Replies the value for the given attribute.AttributeValue
getAttribute(String name, AttributeValue defaultValue)
Replies the value for the given attribute.Attribute
getAttributeObject(String name)
Replies the attribute with the given name.boolean
hasAttribute(String name)
Replies if the given attribute exists.protected abstract AttributeValue
loadValue(String name)
Load a value from the data source.-
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
getAttributeCount, toMap, toMap
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
clone
public AbstractBufferedAttributeProvider clone()
Make a deep copy of this object and replies the copy.- Specified by:
clone
in interfaceAttributeProvider
- Overrides:
clone
in classAbstractAttributeProvider
- Returns:
- the deep copy.
-
loadValue
protected abstract AttributeValue loadValue(String name) throws AttributeException
Load a value from the data source.- Parameters:
name
- is the name of the attribute to load- Returns:
- the value of the attribute.
- Throws:
AttributeException
- on error or when the attribute does not exist
-
getAllAttributeNames
@Pure public abstract Collection<String> getAllAttributeNames()
Description copied from interface:AttributeProvider
Replies 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.
-
hasAttribute
@Pure public boolean hasAttribute(String name)
Description copied from interface:AttributeProvider
Replies if the given attribute exists.- Parameters:
name
- the name.- Returns:
true
is an attribute with the given name exists, otherwisefalse
-
getAllAttributes
@Pure public Collection<Attribute> getAllAttributes()
Description copied from interface:AttributeProvider
Replies all the attributes.- Returns:
- the list of all attributes
-
getAllAttributesByType
@Pure public Map<AttributeType,Collection<Attribute>> getAllAttributesByType()
Description copied from interface:AttributeProvider
Replies 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.
-
getAttribute
@Pure public AttributeValue getAttribute(String name)
Description copied from interface:AttributeProvider
Replies 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:AttributeProvider
Replies 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:AttributeProvider
Replies the attribute with the given name.- Parameters:
name
- the name.- Returns:
- the attribute or
null
-
freeMemory
public void freeMemory()
Description copied from interface:AttributeProvider
Clean 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.
-
-