org.exist.xquery.value
Class AtomicValue

java.lang.Object
  extended byorg.exist.xquery.value.AtomicValue
All Implemented Interfaces:
Item, Sequence
Direct Known Subclasses:
AnyURIValue, Base64Binary, BooleanValue, ComputableValue, FunctionReference, JavaObjectValue, QNameValue, StringValue, UntypedAtomicValue

public abstract class AtomicValue
extends java.lang.Object
implements Item, Sequence

Represents an atomic value. All simple values that are not nodes extend AtomicValue. As every single item is also a sequence, this class implements both: Item and Sequence.

Author:
wolf

Field Summary
static AtomicValue EMPTY_VALUE
          An empty atomic value
 
Fields inherited from interface org.exist.xquery.value.Sequence
EMPTY_SEQUENCE
 
Constructor Summary
AtomicValue()
           
 
Method Summary
 void add(Item item)
          Add an item to the current sequence.
 void addAll(Sequence other)
          Add all items of the other sequence to this item.
 AtomicValue atomize()
           
 void clearContext(int contextId)
          For every item in the sequence, clear any context-dependant information that is stored during query processing.
abstract  int compareTo(java.text.Collator collator, AtomicValue other)
           
abstract  boolean compareTo(java.text.Collator collator, int operator, AtomicValue other)
           
 boolean contains(java.text.Collator collator, AtomicValue other)
          Compares this atomic value to another.
 int conversionPreference(java.lang.Class javaClass)
          Returns a preference indicator, indicating the preference of a value to be converted into the given Java class.
abstract  AtomicValue convertTo(int requiredType)
          Convert this item into an atomic value, whose type corresponds to the specified target type.
 void copyTo(DBBroker broker, DocumentBuilderReceiver receiver)
           
 void dump(ExpressionDumper dumper)
          Dump a string representation of this value to the given ExpressionDumper.
 boolean effectiveBooleanValue()
          Get the effective boolean value of this sequence.
 boolean endsWith(java.text.Collator collator, AtomicValue other)
          Compares this atomic value to another.
 int getCardinality()
          Returns the cardinality of this sequence.
 DocumentSet getDocumentSet()
          Returns the set of documents from which the node items in this sequence have been selected.
 int getItemType()
          Return the primary type to which all items in this sequence belong.
 int getLength()
          Returns the number of items contained in the sequence.
abstract  java.lang.String getStringValue()
          Return the string value of this item (see the definition of string value in XPath).
 int getType()
          Return the type of this item according to the type constants defined in class Type.
 boolean isCached()
          Returns true if the sequence is the result of a previous operation and has been cached.
 boolean isPersistentSet()
           
 Item itemAt(int pos)
          Returns the item located at the specified position within this sequence.
 SequenceIterator iterate()
          Returns an iterator over all items in the sequence.
abstract  AtomicValue max(java.text.Collator collator, AtomicValue other)
           
abstract  AtomicValue min(java.text.Collator collator, AtomicValue other)
           
 void removeDuplicates()
          Explicitely remove all duplicate nodes from this sequence.
 void setIsCached(boolean cached)
          Indicates that the sequence is the result of a previous operation and has not been recomputed.
 void setSelfAsContext(int contextId)
           
 boolean startsWith(java.text.Collator collator, AtomicValue other)
          Compares this atomic value to another.
 java.lang.Object toJavaObject(java.lang.Class target)
          Convert the value into an instance of the specified Java class.
 NodeSet toNodeSet()
          Convert the sequence into a NodeSet.
 void toSAX(DBBroker broker, org.xml.sax.ContentHandler handler)
           
 Sequence toSequence()
          Convert this item into a sequence, containing only the item.
 java.lang.String toString()
           
 SequenceIterator unorderedIterator()
          Returns an iterator over all items in the sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_VALUE

public static final AtomicValue EMPTY_VALUE
An empty atomic value

Constructor Detail

AtomicValue

public AtomicValue()
Method Detail

getType

public int getType()
Description copied from interface: Item
Return the type of this item according to the type constants defined in class Type.

Specified by:
getType in interface Item
Returns:

getStringValue

public abstract java.lang.String getStringValue()
                                         throws XPathException
Description copied from interface: Item
Return the string value of this item (see the definition of string value in XPath).

Specified by:
getStringValue in interface Item
Returns:
Throws:
XPathException

convertTo

public abstract AtomicValue convertTo(int requiredType)
                               throws XPathException
Description copied from interface: Item
Convert this item into an atomic value, whose type corresponds to the specified target type. requiredType should be one of the type constants defined in Type. An XPathException is thrown if the conversion is impossible.

Specified by:
convertTo in interface Item
Parameters:
requiredType -
Returns:
Throws:
XPathException

compareTo

public abstract boolean compareTo(java.text.Collator collator,
                                  int operator,
                                  AtomicValue other)
                           throws XPathException
Throws:
XPathException

compareTo

public abstract int compareTo(java.text.Collator collator,
                              AtomicValue other)
                       throws XPathException
Throws:
XPathException

max

public abstract AtomicValue max(java.text.Collator collator,
                                AtomicValue other)
                         throws XPathException
Throws:
XPathException

min

public abstract AtomicValue min(java.text.Collator collator,
                                AtomicValue other)
                         throws XPathException
Throws:
XPathException

startsWith

public boolean startsWith(java.text.Collator collator,
                          AtomicValue other)
                   throws XPathException
Compares this atomic value to another. Returns true if the current value is of type string and its value starts with the string value of the other value.

Parameters:
collator - Collator used for string comparison.
other -
Returns:
Throws:
XPathException - if this is not a string.

endsWith

public boolean endsWith(java.text.Collator collator,
                        AtomicValue other)
                 throws XPathException
Compares this atomic value to another. Returns true if the current value is of type string and its value ends with the string value of the other value.

Parameters:
collator - Collator used for string comparison.
other -
Returns:
Throws:
XPathException - if this is not a string.

contains

public boolean contains(java.text.Collator collator,
                        AtomicValue other)
                 throws XPathException
Compares this atomic value to another. Returns true if the current value is of type string and its value contains the string value of the other value.

Parameters:
collator - Collator used for string comparison.
other -
Returns:
Throws:
XPathException - if this is not a string.

getLength

public int getLength()
Description copied from interface: Sequence
Returns the number of items contained in the sequence.

Specified by:
getLength in interface Sequence
Returns:

getCardinality

public int getCardinality()
Description copied from interface: Sequence
Returns the cardinality of this sequence. The returned value is a combination of flags as defined in Cardinality.

Specified by:
getCardinality in interface Sequence
Returns:
See Also:
Cardinality

removeDuplicates

public void removeDuplicates()
Description copied from interface: Sequence
Explicitely remove all duplicate nodes from this sequence.

Specified by:
removeDuplicates in interface Sequence

iterate

public SequenceIterator iterate()
Description copied from interface: Sequence
Returns an iterator over all items in the sequence. The items are returned in document order where applicable.

Specified by:
iterate in interface Sequence
Returns:

unorderedIterator

public SequenceIterator unorderedIterator()
Description copied from interface: Sequence
Returns an iterator over all items in the sequence. The returned items may - but need not - to be in document order.

Specified by:
unorderedIterator in interface Sequence
Returns:

getItemType

public int getItemType()
Description copied from interface: Sequence
Return the primary type to which all items in this sequence belong. This is Type.NODE for node sets, Type.ITEM for other sequences with mixed items.

Specified by:
getItemType in interface Sequence
Returns:
the primary type of the items in this sequence.

itemAt

public Item itemAt(int pos)
Description copied from interface: Sequence
Returns the item located at the specified position within this sequence. Items are counted beginning at 0.

Specified by:
itemAt in interface Sequence
Parameters:
pos -
Returns:

toSequence

public Sequence toSequence()
Description copied from interface: Item
Convert this item into a sequence, containing only the item.

Specified by:
toSequence in interface Item
Returns:

toSAX

public void toSAX(DBBroker broker,
                  org.xml.sax.ContentHandler handler)
           throws org.xml.sax.SAXException
Specified by:
toSAX in interface Item
Throws:
org.xml.sax.SAXException

copyTo

public void copyTo(DBBroker broker,
                   DocumentBuilderReceiver receiver)
            throws org.xml.sax.SAXException
Specified by:
copyTo in interface Item
Throws:
org.xml.sax.SAXException

add

public void add(Item item)
         throws XPathException
Description copied from interface: Sequence
Add an item to the current sequence. An XPathException may be thrown if the item's type is incompatible with this type of sequence (e.g. if the sequence is a node set). The sequence may or may not allow duplicate values.

Specified by:
add in interface Sequence
Parameters:
item -
Throws:
XPathException

addAll

public void addAll(Sequence other)
            throws XPathException
Description copied from interface: Sequence
Add all items of the other sequence to this item. An XPathException may be thrown if the type of the items in the other sequence is incompatible with the primary type of this sequence.

Specified by:
addAll in interface Sequence
Parameters:
other -
Throws:
XPathException

atomize

public AtomicValue atomize()
                    throws XPathException
Specified by:
atomize in interface Item
Throws:
XPathException

effectiveBooleanValue

public boolean effectiveBooleanValue()
                              throws XPathException
Description copied from interface: Sequence
Get the effective boolean value of this sequence. Will be false if the sequence is empty, true otherwise.

Specified by:
effectiveBooleanValue in interface Sequence
Returns:
Throws:
XPathException

toNodeSet

public NodeSet toNodeSet()
                  throws XPathException
Description copied from interface: Sequence
Convert the sequence into a NodeSet. If the sequence contains items which are not nodes, an XPathException is thrown.

Specified by:
toNodeSet in interface Sequence
Returns:
Throws:
XPathException - if the sequence contains items which are not nodes.

getDocumentSet

public DocumentSet getDocumentSet()
Description copied from interface: Sequence
Returns the set of documents from which the node items in this sequence have been selected. This is for internal use only.

Specified by:
getDocumentSet in interface Sequence
Returns:

dump

public void dump(ExpressionDumper dumper)
Dump a string representation of this value to the given ExpressionDumper.

Parameters:
dumper -

conversionPreference

public int conversionPreference(java.lang.Class javaClass)
Description copied from interface: Sequence
Returns a preference indicator, indicating the preference of a value to be converted into the given Java class. Low numbers mean that the value can be easily converted into the given class.

Specified by:
conversionPreference in interface Item

toJavaObject

public java.lang.Object toJavaObject(java.lang.Class target)
                              throws XPathException
Description copied from interface: Sequence
Convert the value into an instance of the specified Java class.

Specified by:
toJavaObject in interface Item
Throws:
XPathException

toString

public java.lang.String toString()

isCached

public boolean isCached()
Description copied from interface: Sequence
Returns true if the sequence is the result of a previous operation and has been cached.

Specified by:
isCached in interface Sequence
Returns:

setIsCached

public void setIsCached(boolean cached)
Description copied from interface: Sequence
Indicates that the sequence is the result of a previous operation and has not been recomputed.

Specified by:
setIsCached in interface Sequence
Parameters:
cached -

clearContext

public void clearContext(int contextId)
Description copied from interface: Sequence
For every item in the sequence, clear any context-dependant information that is stored during query processing. This feature is used for node sets, which may store information about their context node.

Specified by:
clearContext in interface Sequence

setSelfAsContext

public void setSelfAsContext(int contextId)
Specified by:
setSelfAsContext in interface Sequence

isPersistentSet

public boolean isPersistentSet()
Specified by:
isPersistentSet in interface Sequence


<oXygen/> XML Editor provides support for editing and debugging XQuery expressions against the eXist XML Database.