public final class ValueFactory
extends java.lang.Object
This class contains various static factory methods that return
instances of XdmValue
and XdmVariable
.
Modifier and Type | Method and Description |
---|---|
static ArrayNode |
newArrayNode(java.lang.Object value)
Convenience method to construct an
ArrayNode
value. |
static XdmBinary |
newBinaryNode(java.lang.Object value) |
static BooleanNode |
newBooleanNode(boolean value)
Convenience method to construct an
BooleanNode
value. |
static BooleanNode |
newBooleanNode(java.lang.Object value)
Convenience method to construct an
BooleanNode
value. |
static XdmComment |
newCommentNode(java.lang.Object value)
A convenience method to construct an
XdmComment
value. |
static CtsBox |
newCtsBox(java.lang.String south,
java.lang.String west, java.lang.String north,
java.lang.String east)
Convenience method to construct a
CtsBox
value. |
static CtsCircle |
newCtsCircle(java.lang.String radius,
CtsPoint center)
Convenience method to construct a
CtsCircle
value. |
static CtsPoint |
newCtsPoint(java.lang.String latitude,
java.lang.String longitude)
Convenience method to construct a
CtsPoint
value. |
static CtsPolygon |
newCtsPolygon(java.util.List<CtsPoint> vertices)
Convenience method to construct a
CtsPolygon
value. |
static XdmDocument |
newDocumentNode(java.lang.Object value)
A convenience method to construct an
XdmDocument
value. |
static XdmDuration |
newDuration(java.lang.String serializedString)
Convenience method to construct an
XdmDuration
value. |
static XdmElement |
newElement(java.lang.Object value)
A convenience method to construct an
XdmElement
value. |
static JSArray |
newJSArray(com.fasterxml.jackson.databind.node.ArrayNode value)
Convenience method to construct an
JSArray
value from a Jackson ArrayNode. |
static JSArray |
newJSArray(java.lang.String serializedString)
Convenience method to construct an
JSArray
value. |
static JSNull |
newJSNull()
Convenience method to construct an
JSNull
value. |
static JSObject |
newJSObject(com.fasterxml.jackson.databind.node.ObjectNode value)
Convenience method to construct an
JSObject
value from a Jackson ObjectNode. |
static JSObject |
newJSObject(java.lang.String serializedString)
Convenience method to construct an
JSObject
value. |
static NullNode |
newNullNode(java.lang.Object value)
Convenience method to construct an
NullNode
value. |
static NumberNode |
newNumberNode(double value)
Convenience method to construct an
NumberNode
value. |
static NumberNode |
newNumberNode(java.lang.Object value)
Convenience method to construct an
NumberNode
value. |
static XdmNode |
newObjectNode(java.lang.Object value)
Convenience method to construct an
ObjectNode
value. |
static XdmProcessingInstruction |
newProcessingInstructionNode(java.lang.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(java.lang.Object value)
A convenience method to construct an
XdmText
value. |
static XdmValue |
newValue(ValueType valueType,
java.lang.Object value)
Generic
XdmValue
creation factory method. |
static XdmVariable |
newVariable(XName name,
XdmValue value)
|
static XSBoolean |
newXSBoolean(boolean value)
A convenience method to construct an
XSBoolean
value. |
static XSDate |
newXSDate(java.lang.String value,
java.util.TimeZone timeZone,
java.util.Locale locale)
A convenience method to construct an
XSDate
value. |
static XSDateTime |
newXSDateTime(java.lang.String value,
java.util.TimeZone timeZone,
java.util.Locale locale)
A convenience method to construct an
XSDateTime
value. |
static XSDuration |
newXSDuration(java.lang.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(java.math.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(java.lang.String value)
A convenience method to construct an
XSString
value. |
static XSTime |
newXSTime(java.lang.String value,
java.util.TimeZone timeZone,
java.util.Locale locale)
A convenience method to construct an
XSTime
value. |
public static XdmValue newValue(ValueType valueType, java.lang.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.
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.XdmValue
.java.lang.IllegalArgumentException
- If the
provided value is not consistent with the valueType.public static XdmElement newElement(java.lang.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
.
value
- An instance of String
,
Element
or InputStream
.XdmElement
.java.lang.IllegalArgumentException
- If value is
not a String
, Element
or
InputStream
.public static XdmDocument newDocumentNode(java.lang.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
.
value
- An instance of String
,
Document
or InputStream
.XdmDocument
.java.lang.IllegalArgumentException
- If value is
not a String
, Document
or
InputStream
.public static XdmText newTextNode(java.lang.Object value)
XdmText
value. XdmText
objects can be constructed from an XML String
, a W3C
DOM Text
node or an InputStream
.value
- An instance of String
,
Text
or InputStream
.XdmText
.java.lang.IllegalArgumentException
- If value is
not a String
, Text
or
InputStream
.public static XdmComment newCommentNode(java.lang.Object value)
XdmComment
value. XdmComment
objects can be constructed from an XML String
, a W3C
DOM Comment
node or an InputStream
.value
- An instance of String
,
Comment
or InputStream
.XdmComment
.java.lang.IllegalArgumentException
- If value is
not a String
, Comment
or
InputStream
.public static XdmProcessingInstruction newProcessingInstructionNode(java.lang.Object value)
XdmProcessingInstruction
value. XdmProcessingInstruction
objects can be constructed from an XML String
, a W3C
DOM ProcessingInstruction
node or an
InputStream
.value
- An instance of String
,
ProcessingInstruction
or
InputStream
.XdmProcessingInstruction
.java.lang.IllegalArgumentException
- If value is
not a String
, ProcessingInstruction
or
InputStream
.public static XdmBinary newBinaryNode(java.lang.Object value)
public static ArrayNode newArrayNode(java.lang.Object value)
ArrayNode
value. Object can be constructed from String
,
ArrayNode
, or InputStream
.value
- An instance of String
,
ArrayNode
or InputStream
.ArrayNode
.public static BooleanNode newBooleanNode(java.lang.Object value)
BooleanNode
value. Object can be constructed from String
,
BooleanNode
, or InputStream
.value
- An instance of String
,
BooleanNode
or InputStream
.BooleanNode
.public static BooleanNode newBooleanNode(boolean value)
BooleanNode
value.value
- a boolean valueBooleanNode
.public static XSString newXSString(java.lang.String value)
XSString
value.public static XSInteger newXSInteger(long value)
XSInteger
value. Note that an XQuery xs:integer can hold values larger than a
Java int or long.public static XSInteger newXSInteger(java.math.BigInteger value)
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.public static XSBoolean newXSBoolean(boolean value)
XSBoolean
value.public static CtsBox newCtsBox(java.lang.String south, java.lang.String west, java.lang.String north, java.lang.String east)
CtsBox
value.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.CtsBox
.public static CtsCircle newCtsCircle(java.lang.String radius, CtsPoint center)
CtsCircle
value.radius
- The radius of the circle.center
- A point representing the center of the
circle.CtsCircle
.public static CtsPoint newCtsPoint(java.lang.String latitude, java.lang.String longitude)
CtsPoint
value.latitude
- The latitude of the point.longitude
- The longitude of the point.CtsPoint
.public static CtsPolygon newCtsPolygon(java.util.List<CtsPoint> vertices)
CtsPolygon
value.vertices
- The vertices of the polygon, given in
order.CtsPolygon
.public static XSDateTime newXSDateTime(java.lang.String value, java.util.TimeZone timeZone, java.util.Locale locale)
XSDateTime
value.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.XSDateTime
.public static XSDate newXSDate(java.lang.String value, java.util.TimeZone timeZone, java.util.Locale locale)
XSDate
value.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.XSDate
.public static XSTime newXSTime(java.lang.String value, java.util.TimeZone timeZone, java.util.Locale locale)
XSTime
value.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.XSDate
.public static XSDuration newXSDuration(java.lang.String value)
XSDuration
value.value
- A String
representation of
the duration (ie P2Y3M141DT12H46M12.34S).XSDuration
.public static XSDuration newXSDuration(XdmDuration duration)
XSDuration
value from an XdmDuration
object.duration
- An instance XdmDurationXSDuration
.public static XdmDuration newDuration(java.lang.String serializedString)
XdmDuration
value.serializedString
- A String
representation of the duration (ie P2Y3M141DT12H46M12.34S).XdmDuration
.public static JSObject newJSObject(java.lang.String serializedString)
JSObject
value.serializedString
- A String
representation of the JavaScript Object (ie {a:1}).JSObject
.public static JSObject newJSObject(com.fasterxml.jackson.databind.node.ObjectNode value)
JSObject
value from a Jackson ObjectNode.value
- A ObjectNode
representation
of the JavaScript Object.JSObject
.public static JSArray newJSArray(java.lang.String serializedString)
JSArray
value.serializedString
- A String
representation of the JavaScript Array (ie [a,b]).JSObject
.public static JSArray newJSArray(com.fasterxml.jackson.databind.node.ArrayNode value)
JSArray
value from a Jackson ArrayNode.value
- A
com.fasterxml.jackson.databind.node.ArraytNode
representation of the JavaScript Object.JSObject
.public static JSNull newJSNull()
JSNull
value.JSNull
.public static XdmSequence<XdmItem> newSequence(XdmValue[] values)
XdmSequence
from an array of XdmValue
objects. Note XdmSequence is not a supported type for external
variables.values
- An array of XdmValue
instances.XdmSequence
object.public static XdmVariable newVariable(XName name, XdmValue value)
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.XdmVariable
that encapsulates the name and value parameters.public static NullNode newNullNode(java.lang.Object value)
NullNode
value. Object can be constructed from String
,
NullNode
, or InputStream
.value
- An instance of String
,
NullNode
or InputStream
.NullNode
.public static NumberNode newNumberNode(java.lang.Object value)
NumberNode
value. Object can be constructed from String
,
NumericNode
, or InputStream
.value
- An instance of String
,
com.fasterxml.jackson.databind.node.NumberNode
or
InputStream
.NumberNode
.public static NumberNode newNumberNode(double value)
NumberNode
value.value
- A value in double.NumberNode
.public static XdmNode newObjectNode(java.lang.Object value)
ObjectNode
value. Object can be constructed from String
,
ObjectNode
, or InputStream
.value
- An instance of String
,
ObjectNode
or InputStream
.ObjectNode
.
Copyright © 2024 MarkLogic
Corporation
Complete online documentation for MarkLogic Server,
XQuery and related components may
be found at
developer.marklogic.com