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
ConstructorsModifierConstructorDescriptionprivateOtherLocales(Set<PT_Locale> locales) Private constructor forfilter(Map)only. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds 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_Localefollowed by other locales in the givenaddTomap.intsize()Returns the number of elements in this collection.Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream
-
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
Thelocalesargument may benullat XML marshalling time. In such case, this method returnsnullinstead of an empty set in order to instruct JAXB to not marshal theotherLocaleelement (an empty set would cause JAXB to marshal an empty element). Since thelocalesargument 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
languageselements except the first one, ornull.
-
size
public int size()Returns the number of elements in this collection.- Specified by:
sizein interfaceCollection<PT_Locale>- Specified by:
sizein interfaceSet<PT_Locale>- Specified by:
sizein 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
otherLocaleproperty withoutdefaultLocaleproperty, which is probably invalid.- Specified by:
addin interfaceCollection<PT_Locale>- Specified by:
addin interfaceSet<PT_Locale>- Overrides:
addin classAbstractCollection<PT_Locale>- Parameters:
locale- the element to add.- Returns:
trueif the "other locales" collection has been modified as a result of this method call.
-
setFirst
Returns a map containing the givenPT_Localefollowed by other locales in the givenaddTomap.- 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.
-