Package org.arakhne.afc.attrs.collection
Class AbstractAttributeProvider
- java.lang.Object
-
- org.arakhne.afc.attrs.collection.AbstractAttributeProvider
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<Attribute>
,AttributeProvider
,JsonableObject
- Direct Known Subclasses:
AbstractAttributeCollection
,AbstractBufferedAttributeProvider
,DBaseFileAttributeProvider
,MultiAttributeProvider
public abstract class AbstractAttributeProvider extends Object implements AttributeProvider, Iterable<Attribute>
This class implements an abstract attribute provider.- 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 AbstractAttributeProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterable<Attribute>
attributes()
Replies all the attributes.AttributeProvider
clone()
Make a deep copy of this object and replies the copy.boolean
getAttribute(String name, boolean defaultValue)
Replies the value for the given attribute.double
getAttribute(String name, double defaultValue)
Replies the value for the given attribute.float
getAttribute(String name, float defaultValue)
Replies the value for the given attribute.int
getAttribute(String name, int defaultValue)
Replies the value for the given attribute.long
getAttribute(String name, long defaultValue)
Replies the value for the given attribute.Class<?>
getAttribute(String name, Class<?> defaultValue)
Replies the value for the given attribute.String
getAttribute(String name, String defaultValue)
Replies the value for the given attribute.InetAddress
getAttribute(String name, InetAddress defaultValue)
Replies the value for the given attribute.InetAddress
getAttribute(String name, InetSocketAddress defaultValue)
Replies the value for the given attribute.URI
getAttribute(String name, URI defaultValue)
Replies the value for the given attribute.URL
getAttribute(String name, URL defaultValue)
Replies the value for the given attribute.Date
getAttribute(String name, Date defaultValue)
Replies the value for the given attribute.UUID
getAttribute(String name, UUID defaultValue)
Replies the value for the given attribute.<T extends Enum<T>>
TgetAttribute(String name, T defaultValue)
Replies the value for the given attribute.boolean
getAttributeAsBool(String name)
Replies the value for the given attribute.Date
getAttributeAsDate(String name)
Replies the value for the given attribute.double
getAttributeAsDouble(String name)
Replies the value for the given attribute.Enum<?>
getAttributeAsEnumeration(String name)
Replies the value for the given attribute.<T extends Enum<T>>
TgetAttributeAsEnumeration(String name, Class<T> type)
Replies the value for the given attribute.float
getAttributeAsFloat(String name)
Replies the value for the given attribute.InetAddress
getAttributeAsInetAddress(String name)
Replies the value for the given attribute.int
getAttributeAsInt(String name)
Replies the value for the given attribute.Class<?>
getAttributeAsJavaClass(String name)
Replies the value for the given attribute.long
getAttributeAsLong(String name)
Replies the value for the given attribute.String
getAttributeAsString(String name)
Replies the value for the given attribute.URI
getAttributeAsURI(String name)
Replies the value for the given attribute.URL
getAttributeAsURL(String name)
Replies the value for the given attribute.UUID
getAttributeAsUUID(String name)
Replies the value for the given attribute.Iterator<Attribute>
iterator()
Replies an iterator on the attributes.protected static Object
protectNull(Object rawAttributeValue, AttributeType type)
Ensure that thenull
value forrawAttributeValue
is catched and replaced by a dedicated representant object.void
toJson(JsonBuffer buffer)
Replies the Json representation of this node.String
toString()
protected static Object
unprotectNull(Object rawAttributeValue)
Ensure that thenull
value forrawAttributeValue
is catched and the dedicated representant object fornull
if replace by the realnull
java value.-
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
freeMemory, getAllAttributeNames, getAllAttributes, getAllAttributesByType, getAttribute, getAttribute, getAttributeCount, getAttributeObject, hasAttribute, toMap, toMap
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
protectNull
protected static Object protectNull(Object rawAttributeValue, AttributeType type)
Ensure that thenull
value forrawAttributeValue
is catched and replaced by a dedicated representant object. This function permits to keep the type of a value even if it isnull
.- Parameters:
rawAttributeValue
- is the value to protect.type
- is the type of the attribute to preserve over time.- Returns:
- the value, or the representant of the java
null
value. - See Also:
unprotectNull(Object)
-
unprotectNull
protected static Object unprotectNull(Object rawAttributeValue)
Ensure that thenull
value forrawAttributeValue
is catched and the dedicated representant object fornull
if replace by the realnull
java value.- Parameters:
rawAttributeValue
- is the value to protect.- Returns:
- the value.
- See Also:
protectNull(Object, AttributeType)
-
clone
@Pure public AttributeProvider clone()
Make a deep copy of this object and replies the copy.- Specified by:
clone
in interfaceAttributeProvider
- Overrides:
clone
in classObject
- Returns:
- the deep copy.
-
attributes
@Pure public Iterable<Attribute> attributes()
Description copied from interface:AttributeProvider
Replies all the attributes.- Specified by:
attributes
in interfaceAttributeProvider
- Returns:
- an iterable object that contains the attributes.
-
getAttributeAsBool
@Pure public boolean getAttributeAsBool(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsBool
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsInt
@Pure public int getAttributeAsInt(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsInt
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsLong
@Pure public long getAttributeAsLong(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsLong
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsFloat
@Pure public float getAttributeAsFloat(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsFloat
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsDouble
@Pure public double getAttributeAsDouble(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsDouble
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsString
@Pure public String getAttributeAsString(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsString
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsUUID
@Pure public UUID getAttributeAsUUID(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsUUID
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsURL
@Pure public URL getAttributeAsURL(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsURL
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsURI
@Pure public URI getAttributeAsURI(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsURI
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsDate
@Pure public Date getAttributeAsDate(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsDate
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsInetAddress
@Pure public InetAddress getAttributeAsInetAddress(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsInetAddress
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsEnumeration
@Pure public Enum<?> getAttributeAsEnumeration(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsEnumeration
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsEnumeration
@Pure public <T extends Enum<T>> T getAttributeAsEnumeration(String name, Class<T> type) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsEnumeration
in interfaceAttributeProvider
- Type Parameters:
T
- is the type of the enumeration to retreive.- Parameters:
name
- the name.type
- is the type of the enumeration to retreive.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttributeAsJavaClass
@Pure public Class<?> getAttributeAsJavaClass(String name) throws AttributeException
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttributeAsJavaClass
in interfaceAttributeProvider
- Parameters:
name
- the name.- Returns:
- the value
- Throws:
AttributeException
- if the attribute was never set.
-
getAttribute
@Pure public boolean getAttribute(String name, boolean defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public int getAttribute(String name, int defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public long getAttribute(String name, long defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public float getAttribute(String name, float defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public double getAttribute(String name, double defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public String getAttribute(String name, String defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public UUID getAttribute(String name, UUID defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public URL getAttribute(String name, URL defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public URI getAttribute(String name, URI defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public Date getAttribute(String name, Date defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public InetAddress getAttribute(String name, InetAddress defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public InetAddress getAttribute(String name, InetSocketAddress defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public <T extends Enum<T>> T getAttribute(String name, T defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Type Parameters:
T
- is the type of the enumeration.- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
getAttribute
@Pure public Class<?> getAttribute(String name, Class<?> defaultValue)
Description copied from interface:AttributeProvider
Replies the value for the given attribute.- Specified by:
getAttribute
in interfaceAttributeProvider
- Parameters:
name
- the name.defaultValue
- is the default value replied if the attribute has no value.- Returns:
- the value
-
toJson
public void toJson(JsonBuffer buffer)
Description copied from interface:JsonableObject
Replies the Json representation of this node.- Specified by:
toJson
in interfaceJsonableObject
- Parameters:
buffer
- the Json buffer.
-
-