org.mulgara.mrg
Class XSDMapper

java.lang.Object
  extended by org.mulgara.mrg.XSDMapper

public class XSDMapper
extends Object

A utility class for mapping datatypes in Java to XSD datatypes and back.


Constructor Summary
XSDMapper()
           
 
Method Summary
static Literal literal(boolean n)
           
static Literal literal(byte n)
           
static Literal literal(byte[] data)
           
static Literal literal(Date d)
           
static Literal literal(double n)
           
static Literal literal(float n)
           
static Literal literal(int n)
           
static Literal literal(long n)
           
static Literal literal(Number n)
           
static Literal literal(Object o)
          Create a literal based on a Java object.
static Literal literal(short n)
           
static void setLocale(int dateStyle, int timeStyle, Locale aLocale)
          Sets the locale for date parsing.
static void setLocale(int style, Locale aLocale)
          Sets the static locale for date parsing.
static Object toData(URI type, String text)
          Uses the type URI to select a parser for the text and returns the appropriate kinds of Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XSDMapper

public XSDMapper()
Method Detail

toData

public static Object toData(URI type,
                            String text)
Uses the type URI to select a parser for the text and returns the appropriate kinds of Object.

Parameters:
type - The URI of the data type.
text - The text of the data.
Returns:
The newly constructed data.
Throws:
IllegalArgumentException - If the type is unkonwn, or the type cannot be parsed.
NumberFormatException - If the type is numeric and the text cannot be parsed.

setLocale

public static void setLocale(int style,
                             Locale aLocale)
Sets the static locale for date parsing. This is used for the fallback parser when dates have a non-canonical form.

Parameters:
style - The formatting style for dates.
aLocale - The locale to use for date parsing.
See Also:
DateFormat.getDateInstance(int,Locale)

setLocale

public static void setLocale(int dateStyle,
                             int timeStyle,
                             Locale aLocale)
Sets the locale for date parsing. This is used for the fallback parser when dates have a non-canonical form.

Parameters:
dateStyle - The formatting style for dates.
timeStyle - The formatting style for dates.
aLocale - The locale to use for date parsing.
See Also:
DateFormat.getDateTimeInstance(int, int, Locale)

literal

public static Literal literal(Object o)
Create a literal based on a Java object. The best possible type is chosen.

Parameters:
o - The object to convert to a literal.
Returns:
a new literal with the data and types set, if possible.

literal

public static Literal literal(Date d)

literal

public static Literal literal(float n)

literal

public static Literal literal(double n)

literal

public static Literal literal(byte n)

literal

public static Literal literal(short n)

literal

public static Literal literal(int n)

literal

public static Literal literal(long n)

literal

public static Literal literal(boolean n)

literal

public static Literal literal(byte[] data)

literal

public static Literal literal(Number n)


Copyright © 2011. All Rights Reserved.