Package org.apache.sis.internal.jaxb.lan
Class OtherLocales
Helper methods for handling the ISO 19115
defaultLocale
and otherLocale
legacy properties.
The ISO standard defines them as two separated properties while GeoAPI handles them in a single collection
for integration with JDK standard API like Locale.lookup(List, Collection)
.
The first element of the languages
collection is taken as the defaultLocale
, and all
remaining ones are taken as otherLocale
elements. Instances of this OtherLocales
class
are for those remaining elements and are created by the filter(Map)
method.
- Since:
- 0.5
- Version:
- 1.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
OtherLocales
(Set<PT_Locale> locales) Private constructor forfilter(Map)
only. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a new element to the collection of "other locales".Returns a collection for all elements except the first one from the given collection.iterator()
Returns an iterator over all elements in this collection except the first one.Returns a map containing the givenPT_Locale
followed by other locales in the givenaddTo
map.int
size()
Returns the number of elements in this collection.Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Field Details
-
locales
The default locale followed by all other locales.
-
-
Constructor Details
-
OtherLocales
Private constructor forfilter(Map)
only.
-
-
Method Details
-
filter
Returns a collection for all elements except the first one from the given collection.Null values and XML marshalling
Thelocales
argument may benull
at XML marshalling time. In such case, this method returnsnull
instead of an empty set in order to instruct JAXB to not marshal theotherLocale
element (an empty set would cause JAXB to marshal an empty element). Since thelocales
argument given to this method should never be null except at XML marshalling time, this rule should not be a violation of public API.- Parameters:
locales
- the collection containing the default locale followed by the other ones, ornull
.- Returns:
- a collection containing all
languages
elements except the first one, ornull
.
-
size
public int size()Returns the number of elements in this collection.- Specified by:
size
in interfaceCollection<PT_Locale>
- Specified by:
size
in interfaceSet<PT_Locale>
- Specified by:
size
in classAbstractCollection<PT_Locale>
- Returns:
- number of other locales.
-
iterator
Returns an iterator over all elements in this collection except the first one. -
add
Adds a new element to the collection of "other locales". If we had no "default locale" prior this method call, then this method will choose one before to add the given locale. This is needed since the other locales begin only after the first element, so a first element needs to exist.The above rule could be a risk of confusion for the users, since it could cause the apparition of a default locale which has never been specified. However, this risk exists only when invoking the deprecated methods, or when unmarshalling a XML document having a
otherLocale
property withoutdefaultLocale
property, which is probably invalid.- Specified by:
add
in interfaceCollection<PT_Locale>
- Specified by:
add
in interfaceSet<PT_Locale>
- Overrides:
add
in classAbstractCollection<PT_Locale>
- Parameters:
locale
- the element to add.- Returns:
true
if the "other locales" collection has been modified as a result of this method call.
-
setFirst
Returns a map containing the givenPT_Locale
followed by other locales in the givenaddTo
map.- Parameters:
addTo
- the map where to set the first locale, ornull
.newValue
- the value to add in the map, ornull
.- Returns:
- a map containing this locale followed by other locales in the given map.
-