com.xml_project.morganaxdm
Class ValueFactory

java.lang.Object
  extended by com.xml_project.morganaxdm.ValueFactory

public class ValueFactory
extends java.lang.Object

Static methods to create Xdm values.


Method Summary
static XdmSequence cast(XdmSequence seq, java.lang.Class<? extends XS_AnyType> targetClass, SequenceType.OccurrenceIndicator occurence, StaticXQueryContext context)
          Creates a new XdmSequence by casting the element in the original sequence.
static XS_AnySimpleType castSingleValue(XdmValue value, java.lang.Class<? extends XS_AnyType> targetClass)
          Creates a new XdmValue by casting the given value to another type.
static XdmSequence convertSequence(XdmSequence sequence, SequenceType sequenceType, com.xml_project.morganaxquery.configuration.NamespaceResolver namespaceResolver, StaticXQueryContext context)
          Converts a sequence to a sequence conforming to sequenceType with atomization (if possible).
static XdmValue makeNumericValue(java.lang.String resp)
          Creates a numeric value (xs:double, xs:decimal or xs:integer) from a string representation
static XS_AnyAtomicType makeValue(javax.xml.namespace.QName typeName, java.lang.String value)
          Creates a new instance of an XDM value with the given type and the given value.
static XS_AnyAtomicType newInstance(java.lang.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(java.lang.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.

convertSequence

public static XdmSequence convertSequence(XdmSequence sequence,
                                          SequenceType sequenceType,
                                          com.xml_project.morganaxquery.configuration.NamespaceResolver namespaceResolver,
                                          StaticXQueryContext context)
                                   throws XPathException
Converts a sequence to a sequence conforming to sequenceType with atomization (if possible).

Parameters:
sequence -
sequenceType -
namespaceResolver -
context -
Returns:
the converted sequence.
Throws:
XPathException

cast

public static XdmSequence cast(XdmSequence seq,
                               java.lang.Class<? extends XS_AnyType> targetClass,
                               SequenceType.OccurrenceIndicator occurence,
                               StaticXQueryContext context)
                        throws XPathException
Creates a new XdmSequence by casting the element 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,
                                               java.lang.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(javax.xml.namespace.QName typeName,
                                         java.lang.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(java.lang.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.