se.kth.cid.metadata
Class MetaDataUtils
java.lang.Object
|
+--se.kth.cid.metadata.MetaDataUtils
- public class MetaDataUtils
- extends Object
This class contains utility functions for use with MetaData.
Method Summary |
static void |
addObject(MetaData md,
String tag,
Object obj)
|
static boolean |
containsString(MetaData.LangStringType lstr,
String str)
|
static MIMEType[] |
getDigitalFormats(MetaData.LangStringType format)
Returns a list of MIMETypes contained in a LangStringType,
such as the one in technical.format. |
static String |
getLanguageString(Locale l)
Returns an IMS meta-data conforming string representing
the given language. |
static Locale |
getLocale(String language)
Converts an IMS meta-data language specification into a Java Locale. |
static MetaData.LangString |
getLocalizedString(String defaultLang,
MetaData.LangStringType langstring)
Returns the string in the LangStringType most matching the
current default Locale. |
static boolean |
isClassifiedAs(MetaData.Classification[] classific,
String purpose,
String source,
String[] entries)
|
static void |
removeObject(MetaData md,
String tag,
Object obj)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EMPTY_LOCALE
public static final Locale EMPTY_LOCALE
getLanguageString
public static String getLanguageString(Locale l)
- Returns an IMS meta-data conforming string representing
the given language.
- Parameters:
l
- the Locale to convert.- Returns:
- a IMS meta-data conforming string representing the given locale.
getLocale
public static Locale getLocale(String language)
- Converts an IMS meta-data language specification into a Java Locale.
Please note that getLanguageString(getLocale(str))
is not always the identity mapping, when the string
given does not conform to the specification.
Valid example: en-US -> en-US,
Invalid example: en_US -> en_us.
- Parameters:
language
- the string to convert.- Returns:
- a Locale object representing the language.
getLocalizedString
public static MetaData.LangString getLocalizedString(String defaultLang,
MetaData.LangStringType langstring)
- Returns the string in the LangStringType most matching the
current default Locale.
This takes into account both country codes, if applicable,
and the default metadata language (which is "en" if not given).
If no good match is found, the first string is returned.
- Parameters:
defaultLang
- the default language, as given by
MetaData.get_metametadata_language().langstring
- the LangStringType to search. If null, the empty
string is returned.- Returns:
- a string in the most matching language, or "".
getDigitalFormats
public static MIMEType[] getDigitalFormats(MetaData.LangStringType format)
- Returns a list of MIMETypes contained in a LangStringType,
such as the one in technical.format.
Ignores non-parsable MIME types.
- Parameters:
format
- the element to search.- Returns:
- the parsed MIMETypes. Never null, but possibly empty.
addObject
public static void addObject(MetaData md,
String tag,
Object obj)
removeObject
public static void removeObject(MetaData md,
String tag,
Object obj)
containsString
public static boolean containsString(MetaData.LangStringType lstr,
String str)
isClassifiedAs
public static boolean isClassifiedAs(MetaData.Classification[] classific,
String purpose,
String source,
String[] entries)
Centre for user-oriented IT -design