org.openrdf.model.util
Class LiteralUtil

java.lang.Object
  extended by org.openrdf.model.util.LiteralUtil

public class LiteralUtil
extends Object

Various utility methods related to Literal.

Author:
Arjohn Kampman

Constructor Summary
LiteralUtil()
           
 
Method Summary
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 getByteValue((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 getByteValue((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 getByteValue((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 getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.
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 getByteValue((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 getByteValue((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 getByteValue((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 getByteValue((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 getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LiteralUtil

public LiteralUtil()
Method Detail

getLabel

public static String getLabel(Literal l,
                              String fallback)
Gets the label of the supplied literal. The fallback value is returned in case the supplied literal is null.

Parameters:
l - The literal to get the label for.
fallback - The value to fall back to in case the supplied literal is null.
Returns:
Either the literal's label, or the fallback value.

getLabel

public 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.


getByteValue

public static byte getByteValue(Literal l,
                                byte fallback)
Gets the byte value of the supplied literal. The fallback value is returned in case Literal.byteValue() throws a NumberFormatException.

Parameters:
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.
Returns:
Either the literal's byte value, or the fallback value.

getByteValue

public 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.


getShortValue

public static short getShortValue(Literal l,
                                  short fallback)
Gets the short value of the supplied literal. The fallback value is returned in case Literal.shortValue() throws a NumberFormatException.

Parameters:
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.
Returns:
Either the literal's short value, or the fallback value.

getShortValue

public static short getShortValue(Value v,
                                  short fallback)
Returns the result of getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.


getIntValue

public static int getIntValue(Literal l,
                              int fallback)
Gets the int value of the supplied literal. The fallback value is returned in case Literal.intValue() throws a NumberFormatException.

Parameters:
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.
Returns:
Either the literal's int value, or the fallback value.

getIntValue

public static int getIntValue(Value v,
                              int fallback)
Returns the result of getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.


getLongValue

public static long getLongValue(Literal l,
                                long fallback)
Gets the long value of the supplied literal. The fallback value is returned in case Literal.longValue() throws a NumberFormatException.

Parameters:
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.
Returns:
Either the literal's long value, or the fallback value.

getLongValue

public static long getLongValue(Value v,
                                long fallback)
Returns the result of getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.


getIntegerValue

public static BigInteger getIntegerValue(Literal l,
                                         BigInteger fallback)
Gets the integer value of the supplied literal. The fallback value is returned in case Literal.integerValue() throws a NumberFormatException.

Parameters:
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.
Returns:
Either the literal's integer value, or the fallback value.

getIntegerValue

public static BigInteger getIntegerValue(Value v,
                                         BigInteger fallback)
Returns the result of getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.


getDecimalValue

public static BigDecimal getDecimalValue(Literal l,
                                         BigDecimal fallback)
Gets the decimal value of the supplied literal. The fallback value is returned in case Literal.decimalValue() throws a NumberFormatException.

Parameters:
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.
Returns:
Either the literal's decimal value, or the fallback value.

getDecimalValue

public static BigDecimal getDecimalValue(Value v,
                                         BigDecimal fallback)
Returns the result of getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.


getFloatValue

public static float getFloatValue(Literal l,
                                  float fallback)
Gets the float value of the supplied literal. The fallback value is returned in case Literal.floatValue() throws a NumberFormatException.

Parameters:
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.
Returns:
Either the literal's float value, or the fallback value.

getFloatValue

public static float getFloatValue(Value v,
                                  float fallback)
Returns the result of getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.


getDoubleValue

public static double getDoubleValue(Literal l,
                                    double fallback)
Gets the double value of the supplied literal. The fallback value is returned in case Literal.doubleValue() throws a NumberFormatException.

Parameters:
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.
Returns:
Either the literal's double value, or the fallback value.

getDoubleValue

public static double getDoubleValue(Value v,
                                    double fallback)
Returns the result of getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.


getBooleanValue

public static boolean getBooleanValue(Literal l,
                                      boolean fallback)
Gets the boolean value of the supplied literal. The fallback value is returned in case Literal.booleanValue() throws a NumberFormatException.

Parameters:
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.
Returns:
Either the literal's boolean value, or the fallback value.

getBooleanValue

public static boolean getBooleanValue(Value v,
                                      boolean fallback)
Returns the result of getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.


getCalendarValue

public static XMLGregorianCalendar getCalendarValue(Literal l,
                                                    XMLGregorianCalendar fallback)
Gets the calendar value of the supplied literal. The fallback value is returned in case Literal.calendarValue() throws a NumberFormatException.

Parameters:
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.
Returns:
Either the literal's calendar value, or the fallback value.

getCalendarValue

public static XMLGregorianCalendar getCalendarValue(Value v,
                                                    XMLGregorianCalendar fallback)
Returns the result of getByteValue((Literal)value, fallback) in case the supplied value is a literal, returns the fallback value otherwise.



Copyright © 2001-2008 Aduna. All Rights Reserved.