org.basex.query.value.type
Enum NodeType

java.lang.Object
  extended by java.lang.Enum<NodeType>
      extended by org.basex.query.value.type.NodeType
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<NodeType>, Type

public enum NodeType
extends java.lang.Enum<NodeType>
implements Type

XQuery node types.

Author:
BaseX Team 2005-12, BSD License, Leo Woerteler

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.basex.query.value.type.Type
Type.ID
 
Enum Constant Summary
ATT
          Attribute type.
COM
          Comment type.
DEL
          Document element type.
DOC
          Document type.
ELM
          Element type.
NOD
          Node type.
NSP
          Namespace type.
PI
          PI type.
SCA
          Schema-attribute.
SCE
          Schema-element.
TXT
          Text type.
 
Field Summary
static NodeType[] VALUES
          Cached enums (faster).
 
Method Summary
 Item cast(Item it, QueryContext ctx, InputInfo ii)
          Casts the specified item to the XQuery data type.
 Item cast(java.lang.Object o, QueryContext ctx, InputInfo ii)
          Casts the specified Java object to the XQuery data type.
 Item castString(java.lang.String o, QueryContext ctx, InputInfo ii)
          Casts the specified string to the XQuery data type.
 boolean eq(Type t)
          Checks if this type is equal to the given one.
static NodeType find(QNm type)
          Finds and returns the specified node type.
 Type.ID id()
          Returns a type id to differentiate all types.
 boolean instanceOf(Type t)
          Checks if the current type is an instance of the specified type.
 NodeType intersect(Type t)
          Computes the intersection between this type and the given one, i.e.
 boolean isNode()
          Checks if the type refers to a node.
 boolean isNumber()
          Checks if the type refers to a number.
 boolean isNumberOrUntyped()
          Checks if the type refers to a number or an untyped item.
 boolean isStringOrUntyped()
          Checks if the type refers to a number or a string.
 boolean isUntyped()
          Checks if the type refers to an untyped item.
 boolean nsSensitive()
          Checks if the type is namespace-sensitive.
 SeqType seqType()
          Returns the sequence type of this data type.
 byte[] string()
          Returns the string representation of this type.
 java.lang.String toString()
           
 Type union(Type t)
          Computes the union between this type and the given one, i.e.
static NodeType valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static NodeType[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

NOD

public static final NodeType NOD
Node type.


TXT

public static final NodeType TXT
Text type.


PI

public static final NodeType PI
PI type.


ELM

public static final NodeType ELM
Element type.


DOC

public static final NodeType DOC
Document type.


DEL

public static final NodeType DEL
Document element type.


ATT

public static final NodeType ATT
Attribute type.


COM

public static final NodeType COM
Comment type.


NSP

public static final NodeType NSP
Namespace type.


SCE

public static final NodeType SCE
Schema-element.


SCA

public static final NodeType SCA
Schema-attribute.

Field Detail

VALUES

public static final NodeType[] VALUES
Cached enums (faster).

Method Detail

values

public static NodeType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (NodeType c : NodeType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static NodeType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

isNode

public final boolean isNode()
Description copied from interface: Type
Checks if the type refers to a node.

Specified by:
isNode in interface Type
Returns:
result of check

isNumber

public boolean isNumber()
Description copied from interface: Type
Checks if the type refers to a number.

Specified by:
isNumber in interface Type
Returns:
result of check

isUntyped

public boolean isUntyped()
Description copied from interface: Type
Checks if the type refers to an untyped item.

Specified by:
isUntyped in interface Type
Returns:
result of check

isNumberOrUntyped

public boolean isNumberOrUntyped()
Description copied from interface: Type
Checks if the type refers to a number or an untyped item.

Specified by:
isNumberOrUntyped in interface Type
Returns:
result of check

isStringOrUntyped

public boolean isStringOrUntyped()
Description copied from interface: Type
Checks if the type refers to a number or a string. Returns if this item is untyped or a string.

Specified by:
isStringOrUntyped in interface Type
Returns:
result of check

cast

public Item cast(Item it,
                 QueryContext ctx,
                 InputInfo ii)
          throws QueryException
Description copied from interface: Type
Casts the specified item to the XQuery data type.

Specified by:
cast in interface Type
Parameters:
it - item to be converted
ctx - query context
ii - input info
Returns:
new item
Throws:
QueryException - query exception

cast

public Item cast(java.lang.Object o,
                 QueryContext ctx,
                 InputInfo ii)
          throws QueryException
Description copied from interface: Type
Casts the specified Java object to the XQuery data type.

Specified by:
cast in interface Type
Parameters:
o - Java object
ctx - TODO
ii - input info
Returns:
new item
Throws:
QueryException - query exception

castString

public Item castString(java.lang.String o,
                       QueryContext ctx,
                       InputInfo ii)
                throws QueryException
Description copied from interface: Type
Casts the specified string to the XQuery data type.

Specified by:
castString in interface Type
Parameters:
o - string object
ctx - TODO
ii - input info
Returns:
new item
Throws:
QueryException - query exception

seqType

public SeqType seqType()
Description copied from interface: Type
Returns the sequence type of this data type.

Specified by:
seqType in interface Type
Returns:
sequence type

eq

public boolean eq(Type t)
Description copied from interface: Type
Checks if this type is equal to the given one.

Specified by:
eq in interface Type
Parameters:
t - other type
Returns:
true if both types are equal, false otherwise

instanceOf

public final boolean instanceOf(Type t)
Description copied from interface: Type
Checks if the current type is an instance of the specified type.

Specified by:
instanceOf in interface Type
Parameters:
t - type to be checked
Returns:
result of check

union

public Type union(Type t)
Description copied from interface: Type
Computes the union between this type and the given one, i.e. the least common ancestor of both types in the type hierarchy.

Specified by:
union in interface Type
Parameters:
t - other type
Returns:
union type

intersect

public NodeType intersect(Type t)
Description copied from interface: Type
Computes the intersection between this type and the given one, i.e. the least specific type that is sub-type of both types. If no such type exists, null is returned.

Specified by:
intersect in interface Type
Parameters:
t - other type
Returns:
intersection type or null

id

public Type.ID id()
Description copied from interface: Type
Returns a type id to differentiate all types.

Specified by:
id in interface Type
Returns:
id

string

public byte[] string()
Description copied from interface: Type
Returns the string representation of this type.

Specified by:
string in interface Type
Returns:
name

toString

public java.lang.String toString()
Specified by:
toString in interface Type
Overrides:
toString in class java.lang.Enum<NodeType>

find

public static NodeType find(QNm type)
Finds and returns the specified node type.

Parameters:
type - type as string
Returns:
type or null

nsSensitive

public boolean nsSensitive()
Description copied from interface: Type
Checks if the type is namespace-sensitive.

Specified by:
nsSensitive in interface Type
Returns:
result of check