Package org.apache.sis.internal.jaxb
Class ModifiableIdentifierMap
java.lang.Object
java.util.AbstractMap<org.opengis.metadata.citation.Citation,String>
org.apache.sis.internal.jaxb.IdentifierMapAdapter
org.apache.sis.internal.jaxb.ModifiableIdentifierMap
- All Implemented Interfaces:
Serializable
,Map<org.opengis.metadata.citation.Citation,
,String> IdentifierMap
A map of identifiers which support
put
and remove
operations.
Thread safety
This class is thread safe if the underlying identifier collection is thread safe.- Since:
- 0.7
- Version:
- 0.7
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.internal.jaxb.IdentifierMapAdapter
EMPTY, identifiers
-
Constructor Summary
ConstructorsConstructorDescriptionModifiableIdentifierMap
(Collection<org.opengis.metadata.Identifier> identifiers) Creates a new map which will be a view over the given identifiers. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes every entries in the underlying collection.(package private) final boolean
Returnstrue
since this map supportput
andremove
operations.Sets the code of the identifier having the given authority to the given value.<T> T
putSpecialized
(IdentifierSpace<T> authority, T value) Sets the identifier associated with the given authority, and returns the previous value.Removes all identifiers associated with the given authority.private URI
Sets thexlink:href
value, which may be null.private <T> T
store
(IdentifierSpace<T> authority, T value) Sets the identifier associated with the given authority, without processing for special cases.Methods inherited from class org.apache.sis.internal.jaxb.IdentifierMapAdapter
containsKey, containsValue, entrySet, get, getIdentifier, getIdentifiers, getSpecialized, isEmpty, size, specialCase, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, values
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
-
Constructor Details
-
ModifiableIdentifierMap
Creates a new map which will be a view over the given identifiers.- Parameters:
identifiers
- the identifiers to wrap in a map view.
-
-
Method Details
-
setHRef
Sets thexlink:href
value, which may be null. If an explicitxlink:href
identifier exists, then it will removed before to set the newhref
in theXLink
object. The intent is to give precedence to theXLink.getHRef()
property in every cases where thehref
is parsable as aURI
, and use the value associated to theHREF
key only as a fallback when the string cannot be parsed.- Parameters:
href
- the new value, ornull
for removing the value.- Returns:
- the previous value, or
null
if none. - See Also:
-
isModifiable
final boolean isModifiable()Returnstrue
since this map supportput
andremove
operations.- Overrides:
isModifiable
in classIdentifierMapAdapter
-
clear
public void clear()Removes every entries in the underlying collection.- Specified by:
clear
in interfaceMap<org.opengis.metadata.citation.Citation,
String> - Overrides:
clear
in classIdentifierMapAdapter
-
remove
Removes all identifiers associated with the given authority. The default implementation delegates toput(Citation, String)
with anull
value.- Specified by:
remove
in interfaceMap<org.opengis.metadata.citation.Citation,
String> - Overrides:
remove
in classIdentifierMapAdapter
- Parameters:
authority
- the authority to search, which should be an instance ofCitation
.- Returns:
- the code of the identifier for the given authority, or
null
if none.
-
put
Sets the code of the identifier having the given authority to the given value. If no identifier is found for the given authority, a new one is created. If more than one identifier is found for the given authority, then all previous identifiers may be removed in order to ensure that the new entry will be the first entry, so it can be find by theget
method.If the given
authority
isHREF
and if the given string is parsable as aURI
, then this method will actually store the value as theXLink.getHRef()
property of theXLink
associated to theXLINK
key. Only if the given string cannot be parsed, then the value is stored as-is under theHREF
key.- Specified by:
put
in interfaceMap<org.opengis.metadata.citation.Citation,
String> - Overrides:
put
in classIdentifierMapAdapter
- Parameters:
authority
- the authority for which to set the code.code
- the new code for the given authority, ornull
for removing the entry.- Returns:
- the previous code for the given authority, or
null
if none.
-
putSpecialized
Sets the identifier associated with the given authority, and returns the previous value.If the given
authority
isHREF
, then this method will actually store the value as theXLink.getHRef()
property of theXLink
associated to theXLINK
key. The previousHREF
value, if any, is discarded.- Specified by:
putSpecialized
in interfaceIdentifierMap
- Overrides:
putSpecialized
in classIdentifierMapAdapter
- Type Parameters:
T
- the identifier type.- Parameters:
authority
- the namespace with which the given identifier is to be associated.value
- the identifier to be associated with the given namespace.- Returns:
- the previous identifier associated with
authority
, ornull
if there was no mapping of the specialized type forauthority
.
-
store
Sets the identifier associated with the given authority, without processing for special cases.- Type Parameters:
T
- the identifier type.- Parameters:
authority
- the namespace with which the given identifier is to be associated.value
- the identifier to be associated with the given namespace.- Returns:
- the previous identifier associated with
authority
, ornull
if there was no mapping of the specialized type forauthority
.
-