Package org.apache.sis.feature
Class CharacteristicMap
java.lang.Object
org.apache.sis.internal.util.AbstractMap<String,AbstractAttribute<?>>
org.apache.sis.feature.CharacteristicMap
- All Implemented Interfaces:
Cloneable,Map<String,AbstractAttribute<?>>
Implementation of
AbstractAttribute.characteristics() map.
This map holds only the attribute characteristics which have been explicitly set or requested.- Since:
- 0.5
- Version:
- 0.6
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classAn entry returned by theAbstractMap.entrySet()iterator.Nested classes/interfaces inherited from class org.apache.sis.internal.util.AbstractMap
AbstractMap.EntryIterator<K,V>, AbstractMap.IteratorAdapter<K, V>, AbstractMap.KeyIterator -
Field Summary
FieldsModifier and TypeFieldDescription(package private) AbstractAttribute<?>[]Characteristics of thesourceattribute, created when first needed.private final AbstractAttribute<?>The attribute source for which to provide characteristics.(package private) final CharacteristicTypeMapDescription of the attribute characteristics. -
Constructor Summary
ConstructorsConstructorDescriptionCharacteristicMap(AbstractAttribute<?> source, CharacteristicTypeMap types) Creates an initially empty map of attribute characteristics. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanIf no characteristic exists for the given name and that name is valid, creates a new map entry with a defaultAttributecharacteristic.protected booleanaddValue(AbstractAttribute<?> value) Adds the given characteristic if none is currently associated for the same characteristic name.voidclear()Removes all entries in this map.clone()Returns a copy of this map.protected AbstractMap.EntryIterator<String,AbstractAttribute<?>> Returns an iterator over the entries.Returns the attribute characteristic for the given name, ornullif none.private intReturns the index for the characteristic of the given name.booleanisEmpty()Returnsfalseif this map contains at least one characteristic.put(String key, AbstractAttribute<?> value) Sets the attribute characteristic for the given name.Removes the attribute characteristic for the given name.intsize()Returns the number of attribute characteristics.(package private) final voidverifyAttributeType(int index, DefaultAttributeType<?> type) Ensures that the given attribute type is the instance that we expect at the given index.Methods inherited from class org.apache.sis.internal.util.AbstractMap
containsKey, containsValue, entrySet, equals, getOrDefault, hashCode, keySet, putAll, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
source
The attribute source for which to provide characteristics. -
characterizedBy
AbstractAttribute<?>[] characterizedByCharacteristics of thesourceattribute, created when first needed. -
types
Description of the attribute characteristics.
-
-
Constructor Details
-
CharacteristicMap
CharacteristicMap(AbstractAttribute<?> source, CharacteristicTypeMap types) Creates an initially empty map of attribute characteristics.- Parameters:
source- the attribute which is characterized bycharacterizedBy.types- description of the characteristics ofsource.
-
-
Method Details
-
clone
Returns a copy of this map. Characteristics are also cloned.- Overrides:
clonein classObject- Returns:
- a copy of this map.
- Throws:
CloneNotSupportedException
-
clear
public void clear()Removes all entries in this map.- Specified by:
clearin interfaceMap<String,AbstractAttribute<?>> - Overrides:
clearin classAbstractMap<String,AbstractAttribute<?>>
-
isEmpty
public boolean isEmpty()Returnsfalseif this map contains at least one characteristic.- Specified by:
isEmptyin interfaceMap<String,AbstractAttribute<?>> - Overrides:
isEmptyin classAbstractMap<String,AbstractAttribute<?>> - Returns:
trueif this map contains no element.
-
size
public int size()Returns the number of attribute characteristics.- Specified by:
sizein interfaceMap<String,AbstractAttribute<?>> - Overrides:
sizein classAbstractMap<String,AbstractAttribute<?>>
-
get
Returns the attribute characteristic for the given name, ornullif none.- Specified by:
getin interfaceMap<String,AbstractAttribute<?>>
-
remove
Removes the attribute characteristic for the given name.- Specified by:
removein interfaceMap<String,AbstractAttribute<?>> - Overrides:
removein classAbstractMap<String,AbstractAttribute<?>> - Parameters:
key- the key of the entry to remove.- Returns:
- the previous value, or
nullif none.
-
indexOf
Returns the index for the characteristic of the given name.- Parameters:
key- the name for which to get the characteristic index.- Returns:
- the index for the characteristic of the given name.
- Throws:
IllegalArgumentException- if the given key is not the name of a characteristic in this map.
-
verifyAttributeType
Ensures that the given attribute type is the instance that we expect at the given index. If the given instance is not the expected one, then anIllegalArgumentExceptionwill be thrown with an error message formatted using the name of expected and given types.- Parameters:
index- index of the expected attribute type.type- the actual attribute type.
-
put
Sets the attribute characteristic for the given name.- Specified by:
putin interfaceMap<String,AbstractAttribute<?>> - Overrides:
putin classAbstractMap<String,AbstractAttribute<?>> - Parameters:
key- the name of the characteristic to set.value- the value to associate to the given key.- Returns:
- the previous value, or
nullif none. - Throws:
IllegalArgumentException- if the given key is not the name of a characteristic in this map.
-
addKey
If no characteristic exists for the given name and that name is valid, creates a new map entry with a defaultAttributecharacteristic.- Overrides:
addKeyin classAbstractMap<String,AbstractAttribute<?>> - Parameters:
name- the name of the characteristic to create, if it does not already exist.- Returns:
trueif a new characteristic has been created for the given name.- Throws:
IllegalArgumentException- if the given key is not the name of a characteristic in this map.
-
addValue
Adds the given characteristic if none is currently associated for the same characteristic name.- Overrides:
addValuein classAbstractMap<String,AbstractAttribute<?>> - Parameters:
value- the characteristic to add.- Returns:
trueif the characteristic has been added.- Throws:
IllegalArgumentException- if given characteristic is not valid for this map.IllegalStateException- if another characteristic already exists for the characteristic name.
-
entryIterator
Returns an iterator over the entries.- Specified by:
entryIteratorin classAbstractMap<String,AbstractAttribute<?>> - Returns:
- an iterator over the entries in this map, or
null.
-