public final class MultilingualStringHelper extends Object
MultilingualString
metadataModifier and Type | Field and Description |
---|---|
private static String |
__ENTRIES_SEPARATOR
The separator between the entries for the string representation of a multilingual string
|
private static String |
__LOCALE_AND_VALUE_SEPARATOR
The separator between the locale and the value for the string representation of a multilingual string
|
static Locale |
DEFAULT_LOCALE
The default locale
|
Modifier | Constructor and Description |
---|---|
private |
MultilingualStringHelper() |
Modifier and Type | Method and Description |
---|---|
static MultilingualString |
fromConfiguration(Configuration configuration)
Get the
MultilingualString object from the given Configuration |
static MultilingualString |
fromJSON(Map<String,? extends Object> json)
Get the
MultilingualString object from its JSON representation |
static MultilingualString |
fromString(String string)
Retrieves the
MultilingualString from its string representation |
static Locale |
getClosestNonEmptyLocale(MultilingualString multilingualString,
Locale locale)
Returns the closest non-empty locale for a
MultilingualString in a given locale. |
static String |
getValue(CompositeMetadata parentMetadata,
String metadataName,
Locale locale)
Deprecated.
|
static String |
getValue(ModelAwareDataHolder dataHolder,
String dataName,
Locale locale)
Returns the closest non-empty value for a
MultilingualString element in a given locale. |
static String |
getValue(ModelLessDataHolder dataHolder,
String dataName,
Locale locale)
Returns the closest non-empty value for a
MultilingualString element in a given locale. |
static String |
getValue(MultilingualString multilingualString,
Locale locale)
Returns the closest non-empty value for a
MultilingualString in a given locale. |
static List<Locale> |
localeLookupList(Locale locale)
Return the list of closest locales to search
|
static void |
sax(ContentHandler contentHandler,
String tagName,
MultilingualString multilingualString,
Locale locale)
Saxes the given multilingual string
|
static Map<String,Object> |
toJson(MultilingualString multilingualString)
Get the JSON representation of a
MultilingualString |
static String |
toString(MultilingualString multilingualString)
Retrieves a string representation of a
MultilingualString |
public static final Locale DEFAULT_LOCALE
private static final String __LOCALE_AND_VALUE_SEPARATOR
private static final String __ENTRIES_SEPARATOR
private MultilingualStringHelper()
@Deprecated public static String getValue(CompositeMetadata parentMetadata, String metadataName, Locale locale) throws AmetysRepositoryException
getValue(ModelAwareDataHolder, String, Locale)
or getValue(ModelLessDataHolder, String, Locale)
insteadMultilingualString
metadata in a given locale.
If no close locale is found, return the value for Locale.ENGLISH
if exists.parentMetadata
- The metadata holdermetadataName
- The metadata namelocale
- The requested localenull
if not found.AmetysRepositoryException
- if an errors occurs.public static String getValue(ModelLessDataHolder dataHolder, String dataName, Locale locale) throws AmetysRepositoryException
MultilingualString
element in a given locale.
If no close locale is found, return the value for Locale.ENGLISH
if exists.dataHolder
- data holderdataName
- The data namelocale
- The requested localenull
if not found.AmetysRepositoryException
- if an errors occurs.public static String getValue(ModelAwareDataHolder dataHolder, String dataName, Locale locale) throws AmetysRepositoryException
MultilingualString
element in a given locale.
If no close locale is found, return the value for Locale.ENGLISH
if exists.dataHolder
- The data holderdataName
- The data namelocale
- The requested localenull
if not found.AmetysRepositoryException
- if an errors occurs.public static String getValue(MultilingualString multilingualString, Locale locale) throws AmetysRepositoryException
MultilingualString
in a given locale.
If no close locale is found, return the value for Locale.ENGLISH
if exists.multilingualString
- The multilingual stringlocale
- The requested locale. Can be null.null
if not found.AmetysRepositoryException
- if an errors occurs.public static Locale getClosestNonEmptyLocale(MultilingualString multilingualString, Locale locale) throws AmetysRepositoryException
MultilingualString
in a given locale.
If no close locale is found, return the Locale.ENGLISH
if a values exists.multilingualString
- The multilingual stringlocale
- The requested locale. Can be null.null
if not found.AmetysRepositoryException
- if an errors occurs.public static List<Locale> localeLookupList(Locale locale)
locale
- the locale to start from. If null, returns the default localepublic static void sax(ContentHandler contentHandler, String tagName, MultilingualString multilingualString, Locale locale) throws SAXException
contentHandler
- the content handler where to SAX into.tagName
- the name of the tag to sax the multilingual stringmultilingualString
- the multilingual string to saxlocale
- the requested locale. Can be null.SAXException
- if an errors occurs during the value saxingpublic static MultilingualString fromConfiguration(Configuration configuration)
MultilingualString
object from the given Configuration
configuration
- the configuration containing the multilingual string dataMultilingualString
objectpublic static Map<String,Object> toJson(MultilingualString multilingualString) throws AmetysRepositoryException
MultilingualString
multilingualString
- The multilingual string. Cannot be null.AmetysRepositoryException
- if an error occurspublic static MultilingualString fromJSON(Map<String,? extends Object> json)
MultilingualString
object from its JSON representationjson
- the JSON representation of the multilingual stringMultilingualString
objectpublic static String toString(MultilingualString multilingualString)
MultilingualString
multilingualString
- the multilingual stringpublic static MultilingualString fromString(String string) throws IllegalArgumentException
MultilingualString
from its string representationstring
- the string representation of the multilingual stringnull
if the given string value is null or emptyIllegalArgumentException
- if the given string value can't be cast to a multilingual string