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.AttributeProviderclone()Make a deep copy of this object and replies the copy.booleangetAttribute(String name, boolean defaultValue)Replies the value for the given attribute.doublegetAttribute(String name, double defaultValue)Replies the value for the given attribute.floatgetAttribute(String name, float defaultValue)Replies the value for the given attribute.intgetAttribute(String name, int defaultValue)Replies the value for the given attribute.longgetAttribute(String name, long defaultValue)Replies the value for the given attribute.Class<?>getAttribute(String name, Class<?> defaultValue)Replies the value for the given attribute.StringgetAttribute(String name, String defaultValue)Replies the value for the given attribute.InetAddressgetAttribute(String name, InetAddress defaultValue)Replies the value for the given attribute.InetAddressgetAttribute(String name, InetSocketAddress defaultValue)Replies the value for the given attribute.URIgetAttribute(String name, URI defaultValue)Replies the value for the given attribute.URLgetAttribute(String name, URL defaultValue)Replies the value for the given attribute.DategetAttribute(String name, Date defaultValue)Replies the value for the given attribute.UUIDgetAttribute(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.booleangetAttributeAsBool(String name)Replies the value for the given attribute.DategetAttributeAsDate(String name)Replies the value for the given attribute.doublegetAttributeAsDouble(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.floatgetAttributeAsFloat(String name)Replies the value for the given attribute.InetAddressgetAttributeAsInetAddress(String name)Replies the value for the given attribute.intgetAttributeAsInt(String name)Replies the value for the given attribute.Class<?>getAttributeAsJavaClass(String name)Replies the value for the given attribute.longgetAttributeAsLong(String name)Replies the value for the given attribute.StringgetAttributeAsString(String name)Replies the value for the given attribute.URIgetAttributeAsURI(String name)Replies the value for the given attribute.URLgetAttributeAsURL(String name)Replies the value for the given attribute.UUIDgetAttributeAsUUID(String name)Replies the value for the given attribute.Iterator<Attribute>iterator()Replies an iterator on the attributes.protected static ObjectprotectNull(Object rawAttributeValue, AttributeType type)Ensure that thenullvalue forrawAttributeValueis catched and replaced by a dedicated representant object.voidtoJson(JsonBuffer buffer)Replies the Json representation of this node.StringtoString()protected static ObjectunprotectNull(Object rawAttributeValue)Ensure that thenullvalue forrawAttributeValueis catched and the dedicated representant object fornullif replace by the realnulljava 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 thenullvalue forrawAttributeValueis 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
nullvalue. - See Also:
unprotectNull(Object)
-
unprotectNull
protected static Object unprotectNull(Object rawAttributeValue)
Ensure that thenullvalue forrawAttributeValueis catched and the dedicated representant object fornullif replace by the realnulljava 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:
clonein interfaceAttributeProvider- Overrides:
clonein classObject- Returns:
- the deep copy.
-
attributes
@Pure public Iterable<Attribute> attributes()
Description copied from interface:AttributeProviderReplies all the attributes.- Specified by:
attributesin interfaceAttributeProvider- Returns:
- an iterable object that contains the attributes.
-
getAttributeAsBool
@Pure public boolean getAttributeAsBool(String name) throws AttributeException
Description copied from interface:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsBoolin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsIntin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsLongin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsFloatin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsDoublein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsStringin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsUUIDin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsURLin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsURIin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsDatein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsInetAddressin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsEnumerationin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsEnumerationin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributeAsJavaClassin 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:AttributeProviderReplies the value for the given attribute.- Specified by:
getAttributein 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:JsonableObjectReplies the Json representation of this node.- Specified by:
toJsonin interfaceJsonableObject- Parameters:
buffer- the Json buffer.
-
-