XCC/J 3.1-9

com.marklogic.xcc
Class ValueFactory

java.lang.Object
  extended bycom.marklogic.xcc.ValueFactory

public final class ValueFactory
extends Object

This class contains various static factory methods that return instances of XdmValue and XdmVariable.


Method Summary
static XdmBinary newBinaryNode(Object value)
           
static XdmDuration newDuration(String serializedString)
          Convenience method to construct an XdmDuration value.
static XdmElement newElement(Object value)
           A convenience method to construct an XdmElement value.
static XdmSequence newSequence(XdmValue[] values)
          Factory method to construct an XdmSequence from an array of XdmValue objects.
static XdmText newTextNode(Object value)
          A convenience method to construct an XdmText value.
static XdmValue newValue(ValueType valueType, Object value)
           Generic XdmValue creation factory method.
static XdmVariable newVariable(XName name, XdmValue value)
          Factory method to create a variable (named value) from the given XName and XdmValue objects.
static XSBoolean newXSBoolean(boolean value)
          A convenience method to construct an XSBoolean value.
static XSDate newXSDate(String value, TimeZone timeZone, Locale locale)
          A convenience method to construct an XSDate value.
static XSDateTime newXSDateTime(String value, TimeZone timeZone, Locale locale)
          A convenience method to construct an XSDateTime value.
static XSDuration newXSDuration(String value)
          A convenience method to construct an XSDuration value.
static XSDuration newXSDuration(XdmDuration duration)
          A convenience method to construct an XSDuration value from an XdmDuration object.
static XSInteger newXSInteger(BigInteger value)
          A convenience method to construct an XSInteger value.
static XSInteger newXSInteger(long value)
          A convenience method to construct an XSInteger value.
static XSString newXSString(String value)
          A convenience method to construct an XSString value.
static XSTime newXSTime(String value, TimeZone timeZone, Locale locale)
          A convenience method to construct an XSTime value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newValue

public static XdmValue newValue(ValueType valueType,
                                Object value)

Generic XdmValue creation factory method. Value types are enumerated in ValueType. Examples are ValueType.XS_INTEGER, ValueType.XS_BOOLEAN, ValueType.SEQUENCE, ValueType.XS_STRING, etc.

NOTE: If you pass a valueType of ValueType.NODE, it will be treated as ValueType.ELEMENT. Using ValueType.NODE directly is discouraged, it is defined as the common super-type for all node types. Other node types that may be constructed are ValueType.TEXT and ValueType.BINARY. In future releases, creation of additional node value types will be supported.

Parameters:
valueType - An concrete subclass of ValueType which indicates the type of value to create.
value - An Object containing the actual value to construct the object with. The specific class of this object is be dependent on the valueType argument. If the provided value is not consistent with the valueType then a IllegalArgumentException may be thrown.
Returns:
An instance of XdmValue.
Throws:
IllegalArgumentException - If the provided value is not consistent with the valueType.

newElement

public static XdmElement newElement(Object value)

A convenience method to construct an XdmElement value. XdmElement objects can be constructed from an XML String, a W3C DOM Element or an InputStream.

Parameters:
value - An instance of String, Element or InputStream.
Returns:
An instance of XdmElement.
Throws:
IllegalArgumentException - If value is not a String, Element or InputStream.

newTextNode

public static XdmText newTextNode(Object value)
A convenience method to construct an XdmText value. XdmText objects can be constructed from an XML String, a W3C DOM Text node or an InputStream.

Parameters:
value - An instance of String, Text or InputStream.
Returns:
An instance of XdmText.
Throws:
IllegalArgumentException - If value is not a String, Text or InputStream.

newBinaryNode

public static XdmBinary newBinaryNode(Object value)

newXSString

public static XSString newXSString(String value)
A convenience method to construct an XSString value.

Parameters:
value - A String to construct the XSString object with.
Returns:
An instance of XSString.

newXSInteger

public static XSInteger newXSInteger(long value)
A convenience method to construct an XSInteger value. Note that an XQuery xs:integer can hold values larger than a Java int or long.

Parameters:
value - A long to construct the XSInteger object with.
Returns:
An instance of XSInteger.

newXSInteger

public static XSInteger newXSInteger(BigInteger value)
A convenience method to construct an XSInteger value. Note that an XQuery xs:integer can hold values larger than a Java int or long, but these large value may be represented with a BigInteger object.

Parameters:
value - A BigInteger to construct the XSInteger object with.
Returns:
An instance of XSInteger.

newXSBoolean

public static XSBoolean newXSBoolean(boolean value)
A convenience method to construct an XSBoolean value.

Parameters:
value - A boolean to construct the XSBoolean object with.
Returns:
An instance of XSBoolean.

newXSDateTime

public static XSDateTime newXSDateTime(String value,
                                       TimeZone timeZone,
                                       Locale locale)
A convenience method to construct an XSDateTime value.

Parameters:
value - A String representation of the date/time in standard XQuery form (ie 2006-04-23T11:32:46).
timeZone - A TimeZone object to apply to value, null for default.
locale - A Locale object to apply to the value, null for default.
Returns:
An instance of XSDateTime.

newXSDate

public static XSDate newXSDate(String value,
                               TimeZone timeZone,
                               Locale locale)
A convenience method to construct an XSDate value.

Parameters:
value - A String representation of the date/time in standard XQuery form (ie 2006-04-23).
timeZone - A TimeZone object to apply to value, null for default.
locale - A Locale object to apply to the value, null for default.
Returns:
An instance of XSDate.

newXSTime

public static XSTime newXSTime(String value,
                               TimeZone timeZone,
                               Locale locale)
A convenience method to construct an XSTime value.

Parameters:
value - A String representation of the date/time in standard XQuery form (ie 11:32:46).
timeZone - A TimeZone object to apply to value, null for default.
locale - A Locale object to apply to the value, null for default.
Returns:
An instance of XSDate.

newXSDuration

public static XSDuration newXSDuration(String value)
A convenience method to construct an XSDuration value.

Parameters:
value - A String representation of the duration (ie P2Y3M141DT12H46M12.34S).
Returns:
An instance of XSDuration.

newXSDuration

public static XSDuration newXSDuration(XdmDuration duration)
A convenience method to construct an XSDuration value from an XdmDuration object.

Parameters:
duration - An instance XdmDuration
Returns:
An instance of XSDuration.

newDuration

public static XdmDuration newDuration(String serializedString)
Convenience method to construct an XdmDuration value.

Parameters:
serializedString - A String representation of the duration (ie P2Y3M141DT12H46M12.34S).
Returns:
An instance of XdmDuration.

newSequence

public static XdmSequence newSequence(XdmValue[] values)
Factory method to construct an XdmSequence from an array of XdmValue objects.

Parameters:
values - An array of XdmValue instances.
Returns:
A new XdmSequence object.

newVariable

public static XdmVariable newVariable(XName name,
                                      XdmValue value)
Factory method to create a variable (named value) from the given XName and XdmValue objects.

Parameters:
name - An XName that defines the name and (optional) namespace of the XdmVariable.
value - An instance of XdmValue which is the value of the variable.
Returns:
An instance of XdmVariable that encapsulates the name and value parameters.

XCC/J 3.1-9

Copyright © 2003-2008 Mark Logic Corporation, All Rights Reserved.

Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com