Modifier | Constructor and Description |
---|---|
protected |
Literals() |
Modifier and Type | Method and Description |
---|---|
static boolean |
canCreateLiteral(Object object)
Helper method for determining whether a literal could be created from an object using a
ValueFactory . |
static Literal |
createLiteral(ValueFactory valueFactory,
Object object)
Creates a typed
Literal out of the supplied object, mapping the runtime type of the object to the
appropriate XML Schema type. |
static Literal |
createLiteralOrFail(ValueFactory valueFactory,
Object object)
Creates a typed
Literal out of the supplied object, mapping the runtime type of the object to the
appropriate XML Schema type. |
static boolean |
getBooleanValue(Literal l,
boolean fallback)
Gets the boolean value of the supplied literal.
|
static boolean |
getBooleanValue(Value v,
boolean fallback)
Returns the result of
getBooleanValue((Literal)value, fallback) in
case the supplied value is a literal, returns the fallback value otherwise. |
static byte |
getByteValue(Literal l,
byte fallback)
Gets the byte value of the supplied literal.
|
static byte |
getByteValue(Value v,
byte fallback)
Returns the result of
getByteValue((Literal)value, fallback) in case the
supplied value is a literal, returns the fallback value otherwise. |
static XMLGregorianCalendar |
getCalendarValue(Literal l,
XMLGregorianCalendar fallback)
Gets the calendar value of the supplied literal.
|
static XMLGregorianCalendar |
getCalendarValue(Value v,
XMLGregorianCalendar fallback)
Returns the result of
getCalendarValue((Literal)value,
fallback) in case the supplied value is a literal, returns the fallback value otherwise. |
static BigDecimal |
getDecimalValue(Literal l,
BigDecimal fallback)
Gets the decimal value of the supplied literal.
|
static BigDecimal |
getDecimalValue(Value v,
BigDecimal fallback)
Returns the result of
getDecimalValue((Literal)value, fallback) in
case the supplied value is a literal, returns the fallback value otherwise. |
static double |
getDoubleValue(Literal l,
double fallback)
Gets the double value of the supplied literal.
|
static double |
getDoubleValue(Value v,
double fallback)
Returns the result of
getDoubleValue((Literal)value, fallback) in case
the supplied value is a literal, returns the fallback value otherwise. |
static Duration |
getDurationValue(Literal l,
Duration fallback)
Gets the
Duration value of the supplied literal. |
static float |
getFloatValue(Literal l,
float fallback)
Gets the float value of the supplied literal.
|
static float |
getFloatValue(Value v,
float fallback)
Returns the result of
getFloatValue((Literal)value, fallback) in case the
supplied value is a literal, returns the fallback value otherwise. |
static BigInteger |
getIntegerValue(Literal l,
BigInteger fallback)
Gets the integer value of the supplied literal.
|
static BigInteger |
getIntegerValue(Value v,
BigInteger fallback)
Returns the result of
getIntegerValue((Literal)value, fallback) in
case the supplied value is a literal, returns the fallback value otherwise. |
static int |
getIntValue(Literal l,
int fallback)
Gets the int value of the supplied literal.
|
static int |
getIntValue(Value v,
int fallback)
Returns the result of
getIntValue((Literal)value, fallback) in case the
supplied value is a literal, returns the fallback value otherwise. |
static String |
getLabel(Literal l,
String fallback)
Gets the label of the supplied literal.
|
static String |
getLabel(Value v,
String fallback)
Returns the result of
getLabel((Literal)v, fallback in case the supplied value
is a literal, returns the fallback value otherwise. |
static long |
getLongValue(Literal l,
long fallback)
Gets the long value of the supplied literal.
|
static long |
getLongValue(Value v,
long fallback)
Returns the result of
getLongValue((Literal)value, fallback) in case the
supplied value is a literal, returns the fallback value otherwise. |
static short |
getShortValue(Literal l,
short fallback)
Gets the short value of the supplied literal.
|
static short |
getShortValue(Value v,
short fallback)
Returns the result of
getShortValue((Literal)value, fallback) in case the
supplied value is a literal, returns the fallback value otherwise. |
static boolean |
isLanguageLiteral(Literal literal)
Helper method to determine whether a literal is a language literal, and not a typed literal.
|
static boolean |
isValidLanguageTag(String languageTag)
|
static String |
normalizeLanguageTag(String languageTag)
|
public static String getLabel(Literal l, String fallback)
l
- The literal to get the label for.fallback
- The value to fall back to in case the supplied literal is null.public static String getLabel(Value v, String fallback)
getLabel((Literal)v, fallback
in case the supplied value
is a literal, returns the fallback value otherwise.public static byte getByteValue(Literal l, byte fallback)
Literal.byteValue()
throws a NumberFormatException
.l
- The literal to get the byte value for.fallback
- The value to fall back to in case no byte value could gotten from the literal.public static byte getByteValue(Value v, byte fallback)
getByteValue((Literal)value, fallback)
in case the
supplied value is a literal, returns the fallback value otherwise.public static short getShortValue(Literal l, short fallback)
Literal.shortValue()
throws a NumberFormatException
.l
- The literal to get the short value for.fallback
- The value to fall back to in case no short value could gotten from the literal.public static short getShortValue(Value v, short fallback)
getShortValue((Literal)value, fallback)
in case the
supplied value is a literal, returns the fallback value otherwise.public static int getIntValue(Literal l, int fallback)
Literal.intValue()
throws a NumberFormatException
.l
- The literal to get the int value for.fallback
- The value to fall back to in case no int value could gotten from the literal.public static int getIntValue(Value v, int fallback)
getIntValue((Literal)value, fallback)
in case the
supplied value is a literal, returns the fallback value otherwise.public static long getLongValue(Literal l, long fallback)
Literal.longValue()
throws a NumberFormatException
.l
- The literal to get the long value for.fallback
- The value to fall back to in case no long value could gotten from the literal.public static long getLongValue(Value v, long fallback)
getLongValue((Literal)value, fallback)
in case the
supplied value is a literal, returns the fallback value otherwise.public static BigInteger getIntegerValue(Literal l, BigInteger fallback)
Literal.integerValue()
throws a NumberFormatException
.l
- The literal to get the integer value for.fallback
- The value to fall back to in case no integer value could gotten from the literal.public static BigInteger getIntegerValue(Value v, BigInteger fallback)
getIntegerValue((Literal)value, fallback)
in
case the supplied value is a literal, returns the fallback value otherwise.public static BigDecimal getDecimalValue(Literal l, BigDecimal fallback)
Literal.decimalValue()
throws a NumberFormatException
.l
- The literal to get the decimal value for.fallback
- The value to fall back to in case no decimal value could gotten from the literal.public static BigDecimal getDecimalValue(Value v, BigDecimal fallback)
getDecimalValue((Literal)value, fallback)
in
case the supplied value is a literal, returns the fallback value otherwise.public static float getFloatValue(Literal l, float fallback)
Literal.floatValue()
throws a NumberFormatException
.l
- The literal to get the float value for.fallback
- The value to fall back to in case no float value could gotten from the literal.public static float getFloatValue(Value v, float fallback)
getFloatValue((Literal)value, fallback)
in case the
supplied value is a literal, returns the fallback value otherwise.public static double getDoubleValue(Literal l, double fallback)
Literal.doubleValue()
throws a NumberFormatException
.l
- The literal to get the double value for.fallback
- The value to fall back to in case no double value could gotten from the literal.public static double getDoubleValue(Value v, double fallback)
getDoubleValue((Literal)value, fallback)
in case
the supplied value is a literal, returns the fallback value otherwise.public static boolean getBooleanValue(Literal l, boolean fallback)
Literal.booleanValue()
throws a NumberFormatException
.l
- The literal to get the boolean value for.fallback
- The value to fall back to in case no boolean value could gotten from the literal.public static boolean getBooleanValue(Value v, boolean fallback)
getBooleanValue((Literal)value, fallback)
in
case the supplied value is a literal, returns the fallback value otherwise.public static XMLGregorianCalendar getCalendarValue(Literal l, XMLGregorianCalendar fallback)
Literal.calendarValue()
throws a NumberFormatException
.l
- The literal to get the calendar value for.fallback
- The value to fall back to in case no calendar value could gotten from the literal.public static Duration getDurationValue(Literal l, Duration fallback)
Duration
value of the supplied literal. The fallback value is returned in case
XMLDatatypeUtil.parseDuration(String)
throws an exception.l
- The literal to get the Duration
value for.fallback
- The value to fall back to in case no Duration value could gotten from the literal.public static XMLGregorianCalendar getCalendarValue(Value v, XMLGregorianCalendar fallback)
getCalendarValue((Literal)value,
fallback)
in case the supplied value is a literal, returns the fallback value otherwise.public static Literal createLiteral(ValueFactory valueFactory, Object object)
Literal
out of the supplied object, mapping the runtime type of the object to the
appropriate XML Schema type. If no mapping is available, the method returns a literal with the string
representation of the supplied object as the value, and XMLSchema.STRING
as the datatype. Recognized
types are Boolean
, Byte
, Double
, Float
, Integer
, Long
,
Short
, XMLGregorianCalendar
, and Date
.valueFactory
- object
- an object to be converted to a typed literal.NullPointerException
- If the object was null.public static Literal createLiteralOrFail(ValueFactory valueFactory, Object object) throws LiteralUtilException
Literal
out of the supplied object, mapping the runtime type of the object to the
appropriate XML Schema type. If no mapping is available, the method throws a LiteralUtilException
.
Recognized types are Boolean
, Byte
, Double
, Float
, Integer
, Long
,
Short
, XMLGregorianCalendar
, and Date
.valueFactory
- object
- an object to be converted to a typed literal.LiteralUtilException
- If the literal could not be created.NullPointerException
- If the object was null.public static boolean canCreateLiteral(Object object)
ValueFactory
.object
- an object to check for the possibility of being converted to a typed literal.ValueFactory
interface and false otherwise. Returns false if the object is null.public static boolean isLanguageLiteral(Literal literal)
literal
- The literal to checkpublic static String normalizeLanguageTag(String languageTag) throws IllformedLocaleException
Locale
API.languageTag
- An unnormalized, valid, language tagIllformedLocaleException
- If the given language tag is ill-formed according to the rules specified in
BCP47.public static boolean isValidLanguageTag(String languageTag)
Locale
API.languageTag
- A language tagtrue
if the given language tag is well-formed according to the rules specified in BCP47.Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.