org.basex.query.value.node
Class ANode

java.lang.Object
  extended by org.basex.data.ExprInfo
      extended by org.basex.query.expr.Expr
          extended by org.basex.query.value.Value
              extended by org.basex.query.value.item.Item
                  extended by org.basex.query.value.node.ANode
All Implemented Interfaces:
java.lang.Iterable<Item>
Direct Known Subclasses:
DBNode, FNode

public abstract class ANode
extends Item

Abstract node type.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.basex.query.expr.Expr
Expr.Flag
 
Field Summary
 int id
          Unique node id.
 
Fields inherited from class org.basex.query.value.item.Item
score, UNDEF
 
Fields inherited from class org.basex.query.value.Value
type
 
Method Summary
abstract  AxisIter ancestor()
          Returns an ancestor axis iterator.
abstract  AxisIter ancestorOrSelf()
          Returns an ancestor-or-self axis iterator.
 byte[] attribute(byte[] name)
          Returns the value of the specified attribute, or null.
 byte[] attribute(QNm name)
          Returns the value of the specified attribute, or null.
 byte[] attribute(java.lang.String name)
          Returns the value of the specified attribute, or null.
abstract  AxisMoreIter attributes()
          Returns an attribute axis iterator.
 byte[] baseURI()
          Returns the base URI of the node.
 boolean bool(InputInfo ii)
          Returns a boolean representation of the value.
abstract  AxisMoreIter children()
          Returns a child axis iterator.
abstract  ANode copy()
          Creates a copy of this node.
 DBNode dbCopy(Prop prop)
          Returns a database node representation of the node.
abstract  ANode deepCopy()
          Returns a deep copy of the node.
abstract  AxisIter descendant()
          Returns a descendant axis iterator.
abstract  AxisIter descendantOrSelf()
          Returns a descendant-or-self axis iterator.
abstract  int diff(ANode node)
          Checks the document order of two nodes.
protected static int diff(ANode node1, ANode node2)
          Compares two nodes for their unique order.
 int diff(Item it, Collation coll, InputInfo ii)
          Returns the difference between the current and the specified item.
 boolean eq(Item it, Collation coll, InputInfo ii)
          Checks the items for equality.
 ANode finish()
          Returns a final node representation.
abstract  AxisIter following()
          Returns a following axis iterator.
abstract  AxisIter followingSibling()
          Returns a following-sibling axis iterator.
abstract  boolean hasChildren()
          Returns true if the node has children.
abstract  boolean is(ANode node)
          Checks if two nodes are identical.
 int kind()
          Returns a database kind for the specified node type.
static int kind(NodeType t)
          Returns a database kind for the specified node type.
 byte[] name()
          Returns the name of the node, composed of an optional prefix and the local name.
 Atts namespaces()
          Returns all namespaces defined for the nodes.
 NodeType nodeType()
          Returns this Node's node type.
 Atts nsScope()
          Returns a copy of the namespace hierarchy.
 ANode optimize()
          Minimizes the memory consumption of the node.
abstract  ANode parent()
          Returns the parent node.
abstract  ANode parent(ANode p)
          Sets the parent node.
abstract  AxisIter parentIter()
          Returns a parent axis iterator.
 AxisIter preceding()
          Returns a preceding axis iterator.
 AxisIter precedingSibling()
          Returns a preceding-sibling axis iterator.
 QNm qname()
          Returns the QName of the node.
abstract  QNm qname(QNm nm)
          Updates the specified with the information of the current node.
 AxisMoreIter self()
          Returns an self axis iterator.
abstract  byte[] string()
          Returns the string value.
 byte[] string(InputInfo ii)
          Returns a string representation of the value.
 BXNode toJava()
          Returns a Java representation of the value.
static NodeType type(int k)
          Returns a node type for the specified database kind.
 byte[] uri(byte[] pref, QueryContext ctx)
          Recursively finds the uri for the specified prefix.
 
Methods inherited from class org.basex.query.value.item.Item
castErr, comparable, dbl, dec, description, ebv, equiv, flt, hash, homogeneous, input, isItem, item, itemAt, iter, iterable, itr, materialize, plan, score, score, size, test, type, typeId, writeTo, xdmInfo
 
Methods inherited from class org.basex.query.value.Value
accept, cache, checkUp, compile, copy, count, data, exprSize, has, inline, isValue, iter, iterator, removable, serialize, value
 
Methods inherited from class org.basex.query.expr.Expr
addText, compEbv, copy, hasFreeVars, indexAccessible, indexEquivalent, inlineAll, isEmpty, isFunction, isVacuous, markTailCalls, optimize, sameAs, uses, visitAll
 
Methods inherited from class org.basex.data.ExprInfo
addPlan, addPlan, info, planAttr, planElem, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

public final int id
Unique node id.

Method Detail

bool

public final boolean bool(InputInfo ii)
Description copied from class: Item
Returns a boolean representation of the value.

Overrides:
bool in class Item
Parameters:
ii - input info
Returns:
boolean value

string

public final byte[] string(InputInfo ii)
Description copied from class: Item
Returns a string representation of the value.

Specified by:
string in class Item
Parameters:
ii - input info, use null if none is available
Returns:
string value

string

public abstract byte[] string()
Returns the string value.

Returns:
string value

eq

public final boolean eq(Item it,
                        Collation coll,
                        InputInfo ii)
                 throws QueryException
Description copied from class: Item
Checks the items for equality.

Specified by:
eq in class Item
Parameters:
it - item to be compared
coll - collation
ii - input info
Returns:
result of check
Throws:
QueryException - query exception

diff

public final int diff(Item it,
                      Collation coll,
                      InputInfo ii)
               throws QueryException
Description copied from class: Item
Returns the difference between the current and the specified item.

Overrides:
diff in class Item
Parameters:
it - item to be compared
coll - query context
ii - input info
Returns:
difference
Throws:
QueryException - query exception

copy

public abstract ANode copy()
Creates a copy of this node.

Returns:
copy

deepCopy

public abstract ANode deepCopy()
Returns a deep copy of the node.

Returns:
node copy

dbCopy

public DBNode dbCopy(Prop prop)
Returns a database node representation of the node.

Parameters:
prop - properties
Returns:
database node

name

public byte[] name()
Returns the name of the node, composed of an optional prefix and the local name. This function must only be called for element and attribute nodes. It is more efficient than calling qname(), as no QNm instance is created.

Returns:
name

qname

public QNm qname()
Returns the QName of the node. This function must only be called for elements, attributes and pi's.

Returns:
name

qname

public abstract QNm qname(QNm nm)
Updates the specified with the information of the current node. This is more efficient than calling qname(), as an existing QNm instance is reused. This function must only be called for elements, attributes and pi's.

Parameters:
nm - temporary qname
Returns:
name

optimize

public ANode optimize()
Minimizes the memory consumption of the node.

Returns:
self reference

namespaces

public Atts namespaces()
Returns all namespaces defined for the nodes. Overwritten by FElem and DBNode.

Returns:
namespace array

nsScope

public final Atts nsScope()
Returns a copy of the namespace hierarchy.

Returns:
namespaces

uri

public final byte[] uri(byte[] pref,
                        QueryContext ctx)
Recursively finds the uri for the specified prefix.

Parameters:
pref - prefix
ctx - query context
Returns:
uri

baseURI

public byte[] baseURI()
Returns the base URI of the node.

Returns:
base URI

is

public abstract boolean is(ANode node)
Checks if two nodes are identical.

Parameters:
node - node to be compared
Returns:
result of check

diff

public abstract int diff(ANode node)
Checks the document order of two nodes.

Parameters:
node - node to be compared
Returns:
0 if the nodes are identical, or 1/-1 if the node appears after/before the argument

diff

protected static int diff(ANode node1,
                          ANode node2)
Compares two nodes for their unique order.

Parameters:
node1 - first node
node2 - node to be compared
Returns:
0 if the nodes are identical, or 1/-1 if the first node appears after/before the second

finish

public ANode finish()
Returns a final node representation. This method is called by the step expressions, before it is passed on as result.

Returns:
node

parent

public abstract ANode parent()
Returns the parent node.

Returns:
parent node

parent

public abstract ANode parent(ANode p)
Sets the parent node.

Parameters:
p - parent node
Returns:
self reference

hasChildren

public abstract boolean hasChildren()
Returns true if the node has children.

Returns:
result of test

attribute

public byte[] attribute(java.lang.String name)
Returns the value of the specified attribute, or null.

Parameters:
name - attribute to be found
Returns:
attribute value

attribute

public byte[] attribute(byte[] name)
Returns the value of the specified attribute, or null.

Parameters:
name - attribute to be found
Returns:
attribute value

attribute

public byte[] attribute(QNm name)
Returns the value of the specified attribute, or null.

Parameters:
name - attribute to be found
Returns:
attribute value

ancestor

public abstract AxisIter ancestor()
Returns an ancestor axis iterator.

Returns:
iterator

ancestorOrSelf

public abstract AxisIter ancestorOrSelf()
Returns an ancestor-or-self axis iterator.

Returns:
iterator

attributes

public abstract AxisMoreIter attributes()
Returns an attribute axis iterator.

Returns:
iterator

children

public abstract AxisMoreIter children()
Returns a child axis iterator.

Returns:
iterator

descendant

public abstract AxisIter descendant()
Returns a descendant axis iterator.

Returns:
iterator

descendantOrSelf

public abstract AxisIter descendantOrSelf()
Returns a descendant-or-self axis iterator.

Returns:
iterator

following

public abstract AxisIter following()
Returns a following axis iterator.

Returns:
iterator

followingSibling

public abstract AxisIter followingSibling()
Returns a following-sibling axis iterator.

Returns:
iterator

parentIter

public abstract AxisIter parentIter()
Returns a parent axis iterator.

Returns:
iterator

preceding

public final AxisIter preceding()
Returns a preceding axis iterator.

Returns:
iterator

precedingSibling

public final AxisIter precedingSibling()
Returns a preceding-sibling axis iterator.

Returns:
iterator

self

public final AxisMoreIter self()
Returns an self axis iterator.

Returns:
iterator

kind

public int kind()
Returns a database kind for the specified node type.

Returns:
node kind

kind

public static int kind(NodeType t)
Returns a database kind for the specified node type.

Parameters:
t - node type
Returns:
node kind

type

public static NodeType type(int k)
Returns a node type for the specified database kind.

Parameters:
k - database kind
Returns:
node type

toJava

public final BXNode toJava()
Description copied from class: Value
Returns a Java representation of the value.

Specified by:
toJava in class Value
Returns:
Java object

nodeType

public final NodeType nodeType()
Returns this Node's node type.

Returns:
node type