Package com.adobe.xmp.core
Class XMPLanguageAlternative
- java.lang.Object
-
- com.adobe.xmp.core.XMPLanguageAlternative
-
public class XMPLanguageAlternative extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Delete all elementsXMPArraygetArray()Gets underlyingXMPArrayjava.util.List<java.lang.String>getAvailableLanguages()XMPSimplegetDefaultText()Returns the default language from an alternative array.XMPSimplegetLocalizedText(java.lang.String language)Returns the language alternative array item for a specific language If language is x-default the first entry of the array is returned, even if someone accidently added an "x-default" entry at another position than the first one (not possible while using this class)booleanisEmpty()Checks if the Language Alternative is emptyjava.util.Iterator<XMPNode>iterator()static XMPLanguageAlternativenewInstance(XMPArray array)Constructs aXMPLanguageAlternativewhich wraps the givenXMPArray.voidnormalize()This will normalize the alternative array to meet the criteria of a XMPLanguage alternative.XMPSimpleremoveDefaultText()removes the default entry (the first one) and the second one will be defaultXMPSimpleremoveLocalizedText(java.lang.String language)Removes the specified language item from an alternative arrayXMPSimplesetDefaultLanguage(java.lang.String language)Sets the entry with a certain language as the default entry (pushes it to the first location)XMPSimplesetDefaultText(java.lang.String value)Sets the default text entry (first one in array) in an language alternative array.XMPSimplesetDefaultText(java.lang.String language, java.lang.String value)Set or overwrites the default localized text entry for this language alternative.XMPSimplesetLocalizedText(java.lang.String language, java.lang.String value)Set or overwrites a localized text entry for this language alternative.intsize()returns the number of elements
-
-
-
Method Detail
-
newInstance
public static XMPLanguageAlternative newInstance(XMPArray array)
Constructs aXMPLanguageAlternativewhich wraps the givenXMPArray. If thisXMPArraydoes not represent a Lang Alt as per XMP Specification this method returns null. To detect whether a language alternative, these prerequisites must be fulfilled:- the array contains only simple properties
- at least one property has an xml:lang qualifier.
- Parameters:
array-
-
normalize
public void normalize()
This will normalize the alternative array to meet the criteria of a XMPLanguage alternative. This is only important if a XMPArray is constructed outside of this facade and then used within this context. If you only use this facade, a currupt XMPArray will never be created. Normalization will do the following:- x-default is moved to top (first one if multiple)
- Items with empty languages become the default language, when there is no "x-default". (first one if multiple)
- Any other item qualifiers than xml:lang are deleted.
- language will be normalized to RFC 3066 form
-
isEmpty
public boolean isEmpty()
Checks if the Language Alternative is empty- Returns:
- True if the array is empty False otherwise
-
size
public int size()
returns the number of elements- Returns:
- the number of elements
-
clear
public void clear()
Delete all elements
-
setLocalizedText
public XMPSimple setLocalizedText(java.lang.String language, java.lang.String value)
Set or overwrites a localized text entry for this language alternative.- Parameters:
language- the language String, has to follow the RFC 3066 formatvalue- the value for this language alternative entry- Returns:
- the localized text entry just created or null if nothing was created
- Throws:
java.lang.IllegalArgumentException-IllegalArgumentExceptionis thrown if value is null
-
setDefaultText
public XMPSimple setDefaultText(java.lang.String language, java.lang.String value)
Set or overwrites the default localized text entry for this language alternative.- Parameters:
language- the language of the default entry (or null or x-default. if no specific language is given)value- the value for this language alternative entry- Returns:
- the localized text entry just created or null if nothing was created
-
setDefaultText
public XMPSimple setDefaultText(java.lang.String value)
Sets the default text entry (first one in array) in an language alternative array. If a new entry must be created (array is empty), x-default will be used as language- Parameters:
value- the value for this language alternative entry- Returns:
- the localized text entry just created or null if nothing was created
-
setDefaultLanguage
public XMPSimple setDefaultLanguage(java.lang.String language)
Sets the entry with a certain language as the default entry (pushes it to the first location)- Parameters:
language- the language to set as default- Returns:
- the new default entry or null if nothing could be set (language entry does not exist)
-
getLocalizedText
public XMPSimple getLocalizedText(java.lang.String language)
Returns the language alternative array item for a specific language If language is x-default the first entry of the array is returned, even if someone accidently added an "x-default" entry at another position than the first one (not possible while using this class)- Parameters:
language- the language for the desired array item- Returns:
- the array item requested or null if it does not exist
-
getDefaultText
public XMPSimple getDefaultText()
Returns the default language from an alternative array. This is always the first entry (even if someone accidently added an "x-default" entry at another position than the first one (not possible while using this class)- Returns:
- the array item requested or null if it does not exist
-
getAvailableLanguages
public java.util.List<java.lang.String> getAvailableLanguages()
- Returns:
- Returns a list of languages that are set in this language alternative.
-
removeLocalizedText
public XMPSimple removeLocalizedText(java.lang.String language)
Removes the specified language item from an alternative array- Parameters:
language- the language that shall be removed- Returns:
- the removed item or null if it did not exist
-
removeDefaultText
public XMPSimple removeDefaultText()
removes the default entry (the first one) and the second one will be default- Returns:
- the removed item or null if it did not exist
-
iterator
public java.util.Iterator<XMPNode> iterator()
-
-