Interface AttributeValue
-
- All Superinterfaces:
Cloneable
,JsonableObject
,Serializable
- All Known Subinterfaces:
Attribute
- All Known Implementing Classes:
AttributeImpl
,AttributeValueImpl
,MapLayer.SpecialAttributeValue
,MultiAttributeProvider.ManyValueAttributeValue
public interface AttributeValue extends Cloneable, Serializable, JsonableObject
This class contains a metadata value.- Version:
- 17.0 2020-01-04 14:41:51
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.advanced
- Maven Artifact Id:
- attributes
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addToPolyline(Collection<? extends Point2D<?,?>> pts)
Add a point to the end of the polyline.void
addToPolyline(Point2D<?,?>... pts)
Add a point to the end of the polyline.void
addToPolyline3D(Collection<? extends Point3D<?,?>> pts)
Add a point to the end of the polyline.void
addToPolyline3D(Point3D<?,?>... pts)
Add a point to the end of the polyline.boolean
cast(AttributeType type)
Change the type of this attribute.void
castAndSet(AttributeType type, Object value)
Change the type of this attribute and set its value.boolean
flush()
Force this attribute to put its value into a storage system.boolean
getBoolean()
Replies the value of this metadata.Date
getDate()
Replies the value of this metadata.Enum<?>
getEnumeration()
Replies the value of this metadata.<T extends Enum<T>>
TgetEnumeration(Class<T> type)
Replies the value of this metadata.InetAddress
getInetAddress()
Replies the value of this metadata.long
getInteger()
Replies the value of this metadata.Class<?>
getInternalStorageType()
Replies the type of the internal value of this implementation of AttributeValue.Class<?>
getJavaClass()
Replies the value of this metadata.<T> T
getJavaObject()
Replies the value of this metadata.Point2D<?,?>
getPoint()
Replies the value of this metadata.Point3D<?,?>
getPoint3D()
Replies the value of this metadata.Point2D<?,?>[]
getPolyline()
Replies the value of this metadata.Point3D<?,?>[]
getPolyline3D()
Replies the value of this metadata.double
getReal()
Replies the value of this metadata.String
getString()
Replies the value of this metadata.long
getTimestamp()
Replies the value of this metadata.AttributeType
getType()
Replies the type of this metadata.URI
getURI()
Replies the value of this metadata.URL
getURL()
Replies the value of this metadata.UUID
getUUID()
Replies the value of this metadata.Object
getValue()
Replies the value attribute stored in the implementation of this interface.boolean
isAssignableFrom(AttributeType type)
Replies if a value of the given attribute type may be cast to a value of this attribute type.boolean
isAssignableFrom(AttributeValue value)
Replies if a value of the given attribute type may be cast to a value of this attribute type.boolean
isAssigned()
Replies if a value was affected to this attribute.boolean
isBaseType()
Replies if this attribute type is a base type, ie. a number, a boolean or a string.boolean
isNullAllowed()
Replies if a null value is allowed for this attribute.boolean
isObjectValue()
Replies of the value of this attribute is a data object ie, java object or icon.void
setBoolean(boolean value)
Set the value of this metadata.void
setDate(Date value)
Set the value of this metadata.void
setEnumeration(Enum<?> enumConstant)
Set the value of this metadata.void
setInetAddress(InetAddress address)
Set the value of this metadata.void
setInteger(int value)
Set the value of this metadata.void
setInteger(long value)
Set the value of this metadata.void
setJavaClass(Class<?> type)
Set the value of this metadata.<T> void
setJavaObject(T value)
Set the value of this metadata.void
setPoint(float x, float y)
Set the value of this metadata.void
setPoint(Point2D<?,?> pt)
Set the value of this metadata.void
setPoint3D(float x, float y, float z)
Set the value of this metadata.void
setPoint3D(Point3D<?,?> pt)
Set the value of this metadata.void
setPolyline(Collection<? extends Point2D<?,?>> pts)
Set the value of this metadata.void
setPolyline(Point2D<?,?>... pts)
Set the value of this metadata.void
setPolyline3D(Collection<? extends Point3D<?,?>> pts)
Set the value of this metadata.void
setPolyline3D(Point3D<?,?>... pts)
Set the value of this metadata.void
setReal(double value)
Set the value of this metadata.void
setString(String value)
Set the value of this metadata.void
setTimestamp(long value)
Set the value of this metadata.void
setToDefault()
Set the value to its default.void
setToDefaultIfUninitialized()
Set the value to its default if not init.void
setType(AttributeType type)
Change the type of this attribute.void
setURI(URI uri)
Set the value of this metadata.void
setURL(URL url)
Set the value of this metadata.void
setUUID(UUID uuid)
Set the value of this metadata.void
setValue(Object value)
Set this value with the content of the specified one.void
setValue(AttributeValue value)
Set this value with the content of the specified one.void
uninitializeValue()
Set this attribute value uninitialized.Comparator<? extends AttributeValue>
valueComparator()
Replies a comparator suitable for attribute values.-
Methods inherited from interface org.arakhne.afc.vmutil.json.JsonableObject
toJson
-
-
-
-
Method Detail
-
valueComparator
@Pure Comparator<? extends AttributeValue> valueComparator()
Replies a comparator suitable for attribute values.- Returns:
- a comparator, never
null
-
isBaseType
@Pure boolean isBaseType()
Replies if this attribute type is a base type, ie. a number, a boolean or a string.The following code is always
true
:
isObjectValue() == !isBaseValue()
- Returns:
true
if this attribute is containing a base type value, otherwisefalse
- See Also:
isNullAllowed()
,isObjectValue()
-
getType
@Pure AttributeType getType()
Replies the type of this metadata.- Returns:
- the type of the attribute
-
setType
void setType(AttributeType type) throws InvalidAttributeTypeException
Change the type of this attribute.The exception will be generated in case the current value could not be casted to the new type.
- Parameters:
type
- is the new type of this attribute- Throws:
InvalidAttributeTypeException
- if the current value was incompatible with the given type.
-
cast
boolean cast(AttributeType type)
Change the type of this attribute.The value could be lost in case the type was incompatible with the value.
- Parameters:
type
- is the new type of this attribute- Returns:
true
if the cast was sucessfully done, otherwhise, if the value was lost because of the cast operation.
-
castAndSet
void castAndSet(AttributeType type, Object value)
Change the type of this attribute and set its value.- Parameters:
type
- is the new type of this attributevalue
- is the new value.
-
getValue
@Pure Object getValue() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value attribute stored in the implementation of this interface. In opposite thangetJavaObject()
, this function replies the value for all attribute type.- Returns:
- the raw value of this attribute
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
getInternalStorageType
@Pure Class<?> getInternalStorageType()
Replies the type of the internal value of this implementation of AttributeValue.- Returns:
- the type of the value stored inside this attribute value implementation.
- Since:
- 4.0
-
setValue
void setValue(AttributeValue value)
Set this value with the content of the specified one.- Parameters:
value
- the value to copy.
-
setValue
void setValue(Object value)
Set this value with the content of the specified one.The type of the attribute will be detected from the type of the object.
- Parameters:
value
- the value.
-
setToDefault
void setToDefault()
Set the value to its default.
-
setToDefaultIfUninitialized
void setToDefaultIfUninitialized()
Set the value to its default if not init.
-
getInteger
@Pure long getInteger() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- the value
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setInteger
void setInteger(int value)
Set the value of this metadata.- Parameters:
value
- the value.
-
setInteger
void setInteger(long value)
Set the value of this metadata.- Parameters:
value
- the value.
-
getReal
@Pure double getReal() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- the value
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setReal
void setReal(double value)
Set the value of this metadata.- Parameters:
value
- the value.
-
getString
@Pure String getString() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- the value
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setString
void setString(String value)
Set the value of this metadata.- Parameters:
value
- the value.
-
getDate
@Pure Date getDate() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- the value
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setDate
void setDate(Date value)
Set the value of this metadata.- Parameters:
value
- the value.
-
getBoolean
@Pure boolean getBoolean() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- the value
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setBoolean
void setBoolean(boolean value)
Set the value of this metadata.- Parameters:
value
- the value.
-
isObjectValue
@Pure boolean isObjectValue()
Replies of the value of this attribute is a data object ie, java object or icon.The following code is always
true
:
isObjectValue() == !isBaseValue()
- Returns:
true
if this attribute contains a object as value (ie, not a base type), otherwisefalse
- See Also:
isBaseType()
,isNullAllowed()
-
getJavaObject
@Pure <T> T getJavaObject() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata. In opposite thangetValue()
, this function replies the value only if this attribute value if of typeAttributeType.OBJECT
.- Type Parameters:
T
- is the type of the value to reply- Returns:
- the value
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.- See Also:
getValue()
-
setJavaObject
<T> void setJavaObject(T value)
Set the value of this metadata.- Type Parameters:
T
- is the type of the new value- Parameters:
value
- the value.
-
getTimestamp
@Pure long getTimestamp() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- a timestamp with a precision in milliseconds
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setTimestamp
void setTimestamp(long value)
Set the value of this metadata.- Parameters:
value
- the value.
-
getPoint3D
@Pure Point3D<?,?> getPoint3D() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- a 3d point
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setPoint3D
void setPoint3D(Point3D<?,?> pt)
Set the value of this metadata.- Parameters:
pt
- the point.
-
setPoint3D
void setPoint3D(float x, float y, float z)
Set the value of this metadata.- Parameters:
x
- x coordinate.y
- y coordinate.z
- z coordinate.
-
getPoint
@Pure Point2D<?,?> getPoint() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- a 2d point
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setPoint
void setPoint(Point2D<?,?> pt)
Set the value of this metadata.- Parameters:
pt
- the point.
-
setPoint
void setPoint(float x, float y)
Set the value of this metadata.- Parameters:
x
- x coordinate.y
- y coordinate.
-
getUUID
@Pure UUID getUUID() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- an uuid
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.- Since:
- 4.0
-
setUUID
void setUUID(UUID uuid)
Set the value of this metadata.- Parameters:
uuid
- the uuid.- Since:
- 4.0
-
getURL
@Pure URL getURL() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- an url
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.- Since:
- 4.0
-
setURL
void setURL(URL url)
Set the value of this metadata.- Parameters:
url
- the url.- Since:
- 4.0
-
getURI
@Pure URI getURI() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- an uri
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.- Since:
- 4.0
-
setURI
void setURI(URI uri)
Set the value of this metadata.- Parameters:
uri
- the uri.- Since:
- 4.0
-
getPolyline3D
@Pure Point3D<?,?>[] getPolyline3D() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- a list of 3d points
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setPolyline3D
void setPolyline3D(Point3D<?,?>... pts)
Set the value of this metadata.- Parameters:
pts
- the points.
-
setPolyline3D
void setPolyline3D(Collection<? extends Point3D<?,?>> pts)
Set the value of this metadata.- Parameters:
pts
- the points.
-
addToPolyline3D
void addToPolyline3D(Point3D<?,?>... pts)
Add a point to the end of the polyline.- Parameters:
pts
- the points
-
addToPolyline3D
void addToPolyline3D(Collection<? extends Point3D<?,?>> pts)
Add a point to the end of the polyline.- Parameters:
pts
- the points.
-
getPolyline
@Pure Point2D<?,?>[] getPolyline() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- a list of 2d points
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setPolyline
void setPolyline(Point2D<?,?>... pts)
Set the value of this metadata.- Parameters:
pts
- the points.
-
setPolyline
void setPolyline(Collection<? extends Point2D<?,?>> pts)
Set the value of this metadata.- Parameters:
pts
- the points.
-
addToPolyline
void addToPolyline(Point2D<?,?>... pts)
Add a point to the end of the polyline.- Parameters:
pts
- the points
-
addToPolyline
void addToPolyline(Collection<? extends Point2D<?,?>> pts)
Add a point to the end of the polyline.- Parameters:
pts
- the points.
-
getInetAddress
@Pure InetAddress getInetAddress() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- an Internet address.
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setInetAddress
void setInetAddress(InetAddress address)
Set the value of this metadata.- Parameters:
address
- the address.
-
getEnumeration
@Pure Enum<?> getEnumeration() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- an enumeration.
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
getEnumeration
@Pure <T extends Enum<T>> T getEnumeration(Class<T> type) throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Type Parameters:
T
- is the type of the enumeration to reply.- Parameters:
type
- is the type of the enumeration to reply.- Returns:
- an enumeration.
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setEnumeration
void setEnumeration(Enum<?> enumConstant)
Set the value of this metadata.- Parameters:
enumConstant
- the constant.
-
getJavaClass
@Pure Class<?> getJavaClass() throws InvalidAttributeTypeException, AttributeNotInitializedException
Replies the value of this metadata.- Returns:
- a Java type.
- Throws:
InvalidAttributeTypeException
- when type is invalid.AttributeNotInitializedException
- when attribute is not initialized.
-
setJavaClass
void setJavaClass(Class<?> type)
Set the value of this metadata.- Parameters:
type
- the type.
-
isAssigned
@Pure boolean isAssigned()
Replies if a value was affected to this attribute.- Returns:
true
if this attribute is containing a value, otherwisefalse
-
isNullAllowed
@Pure boolean isNullAllowed()
Replies if a null value is allowed for this attribute.If
isBaseType()
repliestrue
, this function must always repliesfalse
.- Returns:
true
ifnull
is assigned to this attribute, otherwisefalse
- See Also:
isBaseType()
,isObjectValue()
-
uninitializeValue
void uninitializeValue()
Set this attribute value uninitialized.
-
flush
boolean flush()
Force this attribute to put its value into a storage system.By default, this function does nothing. It is dependant of the application implementation.
- Returns:
true
if the value was written, otherwhisefalse
-
isAssignableFrom
@Pure boolean isAssignableFrom(AttributeType type)
Replies if a value of the given attribute type may be cast to a value of this attribute type.Caution: even if isAssignableFrom is replying
true
, thecast(AttributeType)
andcastAndSet(AttributeType, Object)
may fail if the target type does not support a specifical value of the source type. The isAssignableFrom function repliestrue
if a least one value of the source type is assignable to a value of the target type.This function is equivalent to:
this.getType().isAssignableFrom(type)
- Parameters:
type
- th etype.- Returns:
true
if a value of the giventype
may be cast to a value of the same type as this; otherwisefalse
.- Since:
- 4.0
-
isAssignableFrom
@Pure boolean isAssignableFrom(AttributeValue value)
Replies if a value of the given attribute type may be cast to a value of this attribute type.Caution: even if isAssignableFrom is replying
true
, thecast(AttributeType)
andcastAndSet(AttributeType, Object)
may fail if the target type does not support a specifical value of the source type. The isAssignableFrom function repliestrue
if a least one value of the source type is assignable to a value of the target type.This function is equivalent to:
this.getType().isAssignableFrom(value.getType())
- Parameters:
value
- the value.- Returns:
true
if the given value may be cast to a value of the same type as this; otherwisefalse
.- Since:
- 4.0
-
-