|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Objectnet.sf.saxon.xqj.Closable
net.sf.saxon.xqj.SaxonXQItem
public class SaxonXQItem
This Saxon class is used to implement both the XQItem and XQResultItem interfaces in XQJ. Where the item is not a real XQResultItem, getConnection() will return null.
| Constructor Summary | |
|---|---|
SaxonXQItem(Item item,
SaxonXQDataFactory factory)
|
|
| Method Summary | |
|---|---|
java.lang.String |
getAtomicValue()
Gets the current item as a Java String. |
boolean |
getBoolean()
Gets the current item as a boolean. |
byte |
getByte()
Gets the current item as a byte. |
javax.xml.xquery.XQConnection |
getConnection()
Gets the XQuery connection associated with this result item |
double |
getDouble()
Gets the current item as a double. |
float |
getFloat()
Gets the current item as a float. |
int |
getInt()
Gets the current item as an int. |
javax.xml.stream.XMLStreamReader |
getItemAsStream()
Read the current item as an XMLStreamReader object, as described
in Section 12.1 Serializing an XDM instance into a StAX event stream
(XMLStreamReader), XQuery API for Java (XQJ) 1.0. |
java.lang.String |
getItemAsString(java.util.Properties props)
Serializes the current item according to the XSLT 2.0 and XQuery 1.0 serialization. |
javax.xml.xquery.XQItemType |
getItemType()
Gets the type of the item. |
long |
getLong()
Gets the current item as a long. |
org.w3c.dom.Node |
getNode()
Gets the item as a DOM node. |
java.net.URI |
getNodeUri()
Returns the URI for this item. |
java.lang.Object |
getObject()
Gets the current item as an Object. |
Item |
getSaxonItem()
Get the current item |
short |
getShort()
Gets the current item as a short. |
boolean |
instanceOf(javax.xml.xquery.XQItemType type)
Checks if the item "matches" an item type, as defined in 2.5.4.2 Matching an Item Type and an Item, XQuery 1.0: An XML Query Language. |
void |
writeItem(java.io.OutputStream os,
java.util.Properties props)
Serializes the current item to a Writer according to
XSLT 2.0 and XQuery 1.0 serialization. |
void |
writeItem(java.io.Writer ow,
java.util.Properties props)
Serializes the current item to a Writer according to
XSLT 2.0 and XQuery 1.0 serialization. |
void |
writeItemToResult(javax.xml.transform.Result result)
Writes the current item to a Result. |
void |
writeItemToSAX(org.xml.sax.ContentHandler saxHandler)
Writes the current item to a SAX handler, as described in in Section 12.2 Serializing an XDM instance into a SAX event stream, XQuery API for Java (XQJ) 1.0. |
| Methods inherited from class net.sf.saxon.xqj.Closable |
|---|
close, isClosed, setClosableContainer |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.xml.xquery.XQItem |
|---|
close, isClosed |
| Constructor Detail |
|---|
public SaxonXQItem(Item item,
SaxonXQDataFactory factory)
| Method Detail |
|---|
public Item getSaxonItem()
SaxonXQItemAccessor
getSaxonItem in interface SaxonXQItemAccessor
public javax.xml.xquery.XQConnection getConnection()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQResultItem
getConnection in interface javax.xml.xquery.XQResultItemjavax.xml.xquery.XQException - if the result item is in a closed state
public java.lang.String getAtomicValue()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorString. The current item
must be an atomic value. This function casts the current item to an
xs:string value according to the casting rules defined in
17.1.2 Casting to xs:string and xs:untypedAtomic, XQuery 1.0 and
XPath 2.0 Functions and Operators,
and then returns the value as a Java String.
getAtomicValue in interface javax.xml.xquery.XQItemAccessorjavax.xml.xquery.XQException - if (1) there are errors accessing the item's value,
(2) the item is not an atomic value,
(3) there is an error when casting the
item to a string representation,
(4) the underlying sequence or item is in a
closed state, or (5) in the case of forward only
sequences, a get or write method was already
invoked on the current item
public boolean getBoolean()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorboolean.
The current item must be an atomic value of type xs:boolean
or a subtype.
getBoolean in interface javax.xml.xquery.XQItemAccessorboolean representing the current item
javax.xml.xquery.XQException - if (1) the conversion of the current item to a
boolean fails, (2) if there are
errors accessing the current item, (3) if the
underlying sequence or item is in a closed state,
or (4) in the case of forward only sequences, a
get or write method was already invoked on the
current item
public byte getByte()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorbyte.
The current item must be an atomic value of type xs:decimal
or a subtype, and its value must be in the value space of byte.
getByte in interface javax.xml.xquery.XQItemAccessorbyte representing the current item
javax.xml.xquery.XQException - if (1) the conversion of the current item to a
byte fails, (2) if there are
errors accessing the current item, (3) if the
underlying sequence or item is in a closed state,
or (4) in the case of forward only sequences, a
get or write method was already invoked on the
current item
public double getDouble()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessordouble.
The current item must be an atomic value of type xs:double
or a subtype.
getDouble in interface javax.xml.xquery.XQItemAccessordouble representing the current item
javax.xml.xquery.XQException - if (1) the conversion of the current item to a
double fails, (2) if there are
errors accessing the current item, (3) if the
underlying sequence or item is in a closed state,
or (4) in the case of forward only sequences, a
get or write method was already invoked on the
current item
public float getFloat()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorfloat.
The current item must be an atomic value of type xs:float
or a subtype.
getFloat in interface javax.xml.xquery.XQItemAccessorfloat representing the current item
javax.xml.xquery.XQException - if (1) the conversion of the current item to a
float fails, (2) if there are
errors accessing the current item, (3) if the
underlying sequence or item is in a closed state,
or (4) in the case of forward only sequences, a
get or write method was already invoked on the
current item
public int getInt()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorint.
The current item must be an atomic value of type xs:decimal
or a subtype, and its value must be in the value space of int.
getInt in interface javax.xml.xquery.XQItemAccessorint representing the current item
javax.xml.xquery.XQException - if (1) the conversion of the current item to a
int fails, (2) if there are
errors accessing the current item, (3) if the
underlying sequence or item is in a closed state,
or (4) in the case of forward only sequences, a
get or write method was already invoked on the
current item
public javax.xml.stream.XMLStreamReader getItemAsStream()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorXMLStreamReader object, as described
in Section 12.1 Serializing an XDM instance into a StAX event stream
(XMLStreamReader), XQuery API for Java (XQJ) 1.0.
Note that the serialization process might fail, in which case a
XQException is thrown.
While the stream is being read, the application MUST NOT do any other
concurrent operations on the underlying item or sequence.
The operation on the stream is undefined if the underlying sequence
is repositioned or the state of the underlying item or sequence
is changed by concurrent operations.
getItemAsStream in interface javax.xml.xquery.XQItemAccessorXMLStreamReader
javax.xml.xquery.XQException - if (1) there are errors accessing the current item
or the underlying sequence, (2) the underlying sequence
or item is in a closed state, (3) in the case of a forward
only sequence, a get or write method has already been
invoked on the current item, or (4) in case of an error
during serialization of the current item into a StAX event
stream as defined in Section 12.1 Serializing an XDM
instance into a StAX event stream (XMLStreamReader), XQuery
API for Java (XQJ) 1.0
public java.lang.String getItemAsString(java.util.Properties props)
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessor
getItemAsString in interface javax.xml.xquery.XQItemAccessorprops - specifies the serialization parameters,
null is considered equivalent to an empty
Properties object
javax.xml.xquery.XQException - if (1) there are errors accessing the current
item or the underlying sequence, (2) the underlying
sequence or item is in a closed state,
(3) in the case of a forward only sequence,
a get or write method has already been
invoked on the current item, or (4)
if there are errors during serialization
public javax.xml.xquery.XQItemType getItemType()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessor
getItemType in interface javax.xml.xquery.XQItemAccessorjavax.xml.xquery.XQException - if (1) there are errors accessing the type of the item,
or (2) the underlying sequence or item is in a closed state
public long getLong()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorlong.
The current item must be an atomic value of type xs:decimal
or a subtype, and its value must be in the value space of long.
getLong in interface javax.xml.xquery.XQItemAccessorlong representing the current item
javax.xml.xquery.XQException - if (1) the conversion of the current item to a
long fails, (2) if there are
errors accessing the current item, (3) if the
underlying sequence or item is in a closed state,
or (4) in the case of forward only sequences, a
get or write method was already invoked on the
current item
public org.w3c.dom.Node getNode()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessor
getNode in interface javax.xml.xquery.XQItemAccessorjavax.xml.xquery.XQException - if (1) if there are errors accessing the current item,
(2) the current item is not a node, (3) if the
underlying sequence or item is in a closed state,
or (4) in the case of forward only sequences, a
get or write method was already invoked on the
current item
public java.net.URI getNodeUri()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorfn:document-uri were evaluated on this document
node. If the item is of a node kind other than document node, then the
returned URI is implementation-defined.
getNodeUri in interface javax.xml.xquery.XQItemAccessorjavax.xml.xquery.XQException - if (1) if there are errors accessing the current item,
(2) the current item is not a node, (3) if the
underlying sequence or item is in a closed state
public java.lang.Object getObject()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorObject.
The data type of the returned object will be the Java Object
type as specified in 14.4 Mapping an XQuery Atomic Value to a
Java Object Type and 14.5 Mapping an XQuery Node to a Java Object Type,
XQuery API for Java (XQJ) 1.0.
getObject in interface javax.xml.xquery.XQItemAccessorjavax.xml.xquery.XQException - if (1) if there are errors accessing the current item,
(2) if the underlying sequence or item is in a closed state,
or (3) in the case of forward only sequences, a
get or write method was already invoked on the
current item
public short getShort()
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorshort.
The current item must be an atomic value of type xs:decimal
or a subtype, and its value must be in the value space of short.
getShort in interface javax.xml.xquery.XQItemAccessorshort representing the current item
javax.xml.xquery.XQException - if (1) the conversion of the current item to a
short fails, (2) if there are
errors accessing the current item, (3) if the
underlying sequence or item is in a closed state,
or (4) in the case of forward only sequences, a
get or write method was already invoked on the
current item
public boolean instanceOf(javax.xml.xquery.XQItemType type)
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessor
...
XQItemType strType = conn.createAtomicType(XQItemType.XQBASETYPE_STRING);
XQItemType nodeType = conn.createNodeType();
XQSequence result = preparedExpr.executeQuery();
while (result.next())
{
// Generic check for node..
if (result.instanceOf(nodeType))
org.w3.dom.Node node = result.getNode();
else if (result.instanceOf(strType))
String str = result.getAtomicValue();
}
XQItemAccessor or the input
XQItemType is not a built-in type, then this method is
allowed to raise exception if it can NOT determine the instanceOf
relationship due to the lack of the access of
the XML schema that defines the user defined schema types if the
XQMetaData.isUserDefinedXMLSchemaTypeSupported() method
returns false.
XQItemAccessor is an instance of the input
XQItemType. Note even if
isUserDefinedXMLSchemaTypeSupported() returns false,
an XQJ implementation may still be able to determine the instanceOf
relationship for certain cases involving user defined schema type.
For example, if the type of an XQItemAccessor is of
mySchema:hatSize sequence type and the input parameter
XQItemType is of item() sequence type,
the return value for instanceOf relationship should always be true
even though the XQJ implementation does not know the precise type
information of mySchema:hatSize type defined in XML
schema 'mySchema'.
instanceOf in interface javax.xml.xquery.XQItemAccessortype - item type to match
true if this item matches
the input item type as defined in
2.5.4.2 Matching an Item Type and an Item,
XQuery 1.0: An XML Query Language,
and false if it does not
javax.xml.xquery.XQException - if (1) there are errors accessing the item's
type, (2) if the underlying sequence or item
is in a closed state, (3) if the implementation
is unable to determine the schema definition of a
user defined schema type, or (4) the type
parameter is null
public void writeItem(java.io.OutputStream os,
java.util.Properties props)
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorWriter according to
XSLT 2.0 and XQuery 1.0 serialization.
Serialization parameters, which influence how serialization is
performed, can be specified. Refer to the
XSLT 2.0 and XQuery 1.0 serialization
and Section 12 Serialization, XQuery
API for Java (XQJ) 1.0 for more information.
writeItem in interface javax.xml.xquery.XQItemAccessoros - the output stream into which the current item is
to be serializedprops - specifies the serialization parameters,
null is considered equivalent to an empty
Properties object
javax.xml.xquery.XQException - if (1) there are errors accessing the current
item or the underlying sequence, (2) the underlying
sequence or item is in a closed state,
(3) in the case of a forward only sequence, a get or
write method has already been invoked on the current item,
(4) if there are errors during serialization, or
(5) the os parameter is null
public void writeItem(java.io.Writer ow,
java.util.Properties props)
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorWriter according to
XSLT 2.0 and XQuery 1.0 serialization.
Serialization parameters, which influence how serialization is
performed, can be specified. Refer to the
XSLT 2.0 and XQuery 1.0 serialization
and Section 12 Serialization, XQuery
API for Java (XQJ) 1.0 for more information.
Writer, make sure the writer's encoding
matches the encoding parameter if specified as a property or the default
encoding.
writeItem in interface javax.xml.xquery.XQItemAccessorow - the writer object into which the current item is to be
serializedprops - specifies the serialization parameters,
null is considered equivalent to an empty
Properties object
javax.xml.xquery.XQException - if (1) there are errors accessing the current
item or the underlying sequence, (2) the underlying
sequence or item is in a closed state,
(3) in the case of a forward only sequence, a get or
write method has already been invoked on the current item,
(4) if there are errors during serialization, or
(5) the ow parameter is null
public void writeItemToResult(javax.xml.transform.Result result)
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorResult. First the item is
normalized as described in
XSLT 2.0 and XQuery 1.0 serialization. Subsequently it is
serialized to the Result object.XQException is thrown.
An XQJ implementation must at least support the following implementations:
javax.xml.transform.dom.DOMResultjavax.xml.transform.sax.SAXResultjavax.xml.transform.stream.StreamResult
writeItemToResult in interface javax.xml.xquery.XQItemAccessorresult - the result object into which the item is to be serialized
javax.xml.xquery.XQException - if (1) there are errors accessing the current
item or the underlying sequence, (2) the underlying
sequence or item is in a closed state, (3) in the case
of a forward only sequence, a get or write method has
already been invoked on the current item, (4) in case
of an error while serializing the current item into the
Result object, or (5) the result
parameter is null
public void writeItemToSAX(org.xml.sax.ContentHandler saxHandler)
throws javax.xml.xquery.XQException
javax.xml.xquery.XQItemAccessorXQException is thrown.
The specified org.xml.sax.ContentHandler can optionally implement the
org.xml.sax.LexicalHandler interface. An implementation must check if the
specified ContentHandler implements LexicalHandler.
If the handler is a LexicalHandler comment nodes are reported, otherwise
they will be silently ignored.
writeItemToSAX in interface javax.xml.xquery.XQItemAccessorsaxHandler - the SAX content handler, optionally a lexical handler
javax.xml.xquery.XQException - if (1) there are errors accessing the current
item or the underlying sequence, (2) the underlying
sequence or item is in a closed state, (3) in the case
of a forward only sequence, a get or write method has
already been invoked on the current item, (4) in case
of an error while serializing the XDM instance
into a SAX event stream, or (5) the saxhdlr
parameter is null
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||