com.xml_project.morganaxproc.xdm
Class ValueFactory

java.lang.Object
  extended by com.xml_project.morganaxproc.xdm.ValueFactory

public class ValueFactory
extends Object

Static methods to create Xdm values.


Method Summary
static XdmSequence cast(XdmSequence seq, Class<? extends XS_AnyType> targetClass, SequenceType.OccurrenceIndicator occurence, StaticXQueryContext context)
          Creates a new XdmSequence by casting the elements in the original sequence.
static XS_AnySimpleType castSingleValue(XdmValue value, Class<? extends XS_AnyType> targetClass)
          Creates a new XdmValue by casting the given value to another type.
static XdmValue makeNumericValue(String resp)
          Creates a numeric value (xs:double, xs:decimal or xs:integer) from a string representation
static XS_AnyAtomicType makeValue(QName typeName, String value)
          Creates a new instance of an XDM value with the given type and the given value.
static XS_AnyAtomicType newInstance(Class<? extends XS_AnyType> targetClass, XdmValue theValue)
          Creates a new instance of an XDM value with the given type and the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeNumericValue

public static XdmValue makeNumericValue(String resp)
                                 throws XPathException
Creates a numeric value (xs:double, xs:decimal or xs:integer) from a string representation

Parameters:
resp - a string representation
Returns:
an numeric value
Throws:
XPathException - throws, if no value can be created.

cast

public static XdmSequence cast(XdmSequence seq,
                               Class<? extends XS_AnyType> targetClass,
                               SequenceType.OccurrenceIndicator occurence,
                               StaticXQueryContext context)
                        throws XPathException
Creates a new XdmSequence by casting the elements in the original sequence.

Parameters:
seq - the sequence to cast.
targetClass - the target class for the cast.
occurence - the occurrence indicator for the cast.
context - a static XQuery context for this cast.
Returns:
the casted sequences.
Throws:
XPathException - thrown, if the sequence cannot be casted.

castSingleValue

public static XS_AnySimpleType castSingleValue(XdmValue value,
                                               Class<? extends XS_AnyType> targetClass)
                                        throws XPathException
Creates a new XdmValue by casting the given value to another type.

Parameters:
value - the value to cast.
targetClass - the class to cast to.
Returns:
the casted value.
Throws:
XPathException - if the value cannot be casted.

makeValue

public static XS_AnyAtomicType makeValue(QName typeName,
                                         String value)
                                  throws XPathException
Creates a new instance of an XDM value with the given type and the given value.

Parameters:
typeName - the type name (xs:....)
value - a string representation of the value.
Returns:
the created value.
Throws:
XPathException - thrown, if no class with the given type name is found.

newInstance

public static XS_AnyAtomicType newInstance(Class<? extends XS_AnyType> targetClass,
                                           XdmValue theValue)
                                    throws XPathException
Creates a new instance of an XDM value with the given type and the given value.

Parameters:
targetClass - the class for the new value.
theValue - the value for the new value.
Returns:
the new value.
Throws:
XPathException - thrown, if the value can not be created.