XCC/J 6.0-3

com.marklogic.xcc
Class ValueFactory

java.lang.Object
  extended by com.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 XdmComment newCommentNode(Object value)
          A convenience method to construct an XdmComment value.
static CtsBox newCtsBox(String south, String west, String north, String east)
          Convenience method to construct a CtsBox value.
static CtsCircle newCtsCircle(String radius, CtsPoint center)
          Convenience method to construct a CtsCircle value.
static CtsPoint newCtsPoint(String latitude, String longitude)
          Convenience method to construct a CtsPoint value.
static CtsPolygon newCtsPolygon(List<CtsPoint> vertices)
          Convenience method to construct a CtsPolygon value.
static XdmDocument newDocumentNode(Object value)
           A convenience method to construct an XdmDocument 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 XdmProcessingInstruction newProcessingInstructionNode(Object value)
          A convenience method to construct an XdmProcessingInstruction value.
static XdmSequence<XdmItem> 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.

newDocumentNode

public static XdmDocument newDocumentNode(Object value)

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

Parameters:
value - An instance of String, Document or InputStream.
Returns:
An instance of XdmDocument.
Throws:
IllegalArgumentException - If value is not a String, Document 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.

newCommentNode

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

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

newProcessingInstructionNode

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

Parameters:
value - An instance of String, ProcessingInstruction or InputStream.
Returns:
An instance of XdmProcessingInstruction.
Throws:
IllegalArgumentException - If value is not a String, ProcessingInstruction 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.

newCtsBox

public static CtsBox newCtsBox(String south,
                               String west,
                               String north,
                               String east)
Convenience method to construct a CtsBox value.

Parameters:
south - The southern boundary of the box.
west - The western boundary of the box.
north - The northern boundary of the box.
east - The eastern boundary of the box.
Returns:
An instance of CtsBox.

newCtsCircle

public static CtsCircle newCtsCircle(String radius,
                                     CtsPoint center)
Convenience method to construct a CtsCircle value.

Parameters:
radius - The radius of the circle.
center - A point representing the center of the circle.
Returns:
An instance of CtsCircle.

newCtsPoint

public static CtsPoint newCtsPoint(String latitude,
                                   String longitude)
Convenience method to construct a CtsPoint value.

Parameters:
latitude - The latitude of the point.
longitude - The longitude of the point.
Returns:
An instance of CtsPoint.

newCtsPolygon

public static CtsPolygon newCtsPolygon(List<CtsPoint> vertices)
Convenience method to construct a CtsPolygon value.

Parameters:
vertices - The vertices of the polygon, given in order.
Returns:
An instance of CtsPolygon.

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<XdmItem> newSequence(XdmValue[] values)
Factory method to construct an XdmSequence from an array of XdmValue objects. Note XdmSequence is not a supported type for external variables.

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 6.0-3

Copyright © 2013 MarkLogic Corporation. All Rights Reserved.

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