org.basex.query.value.type
Class SeqType

java.lang.Object
  extended by org.basex.query.value.type.SeqType

public final class SeqType
extends java.lang.Object

Stores a sequence type definition.

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

Nested Class Summary
static class SeqType.Occ
          Number of occurrences (cardinality).
 
Field Summary
static SeqType AAT
          Zero or one xs:anyAtomicType.
static SeqType AAT_ZM
          Zero or more xs:anyAtomicType.
static SeqType AAT_ZO
          Zero or one xs:anyAtomicType.
static MapType ANY_MAP
          The general map type.
static SeqType ATT
          One attribute node.
static SeqType B64
          Single xs:base64Binary.
static SeqType B64_ZM
          Zero or more xs:base64Binary.
static SeqType BIN
          Single binary.
static SeqType BIN_ZM
          Zero or more binaries.
static SeqType BLN
          Single xs:boolean.
static SeqType BLN_ZO
          Zero or one xs:boolean.
static SeqType BYT_OM
          One or more bytes.
static SeqType BYT_ZM
          Zero or more bytes.
static SeqType COM
          One comment node.
static SeqType DAT
          Single date.
static SeqType DAT_ZO
          Zero or one date.
static SeqType DBL
          Double number.
static SeqType DBL_ZM
          Double number.
static SeqType DBL_ZO
          Zero or one double.
static SeqType DEC_ZO
          Zero or one decimal number.
static SeqType DOC_O
          One document node.
static SeqType DOC_OM
          One or more document node.
static SeqType DOC_ZM
          Zero or more document node.
static SeqType DOC_ZO
          Zero or one document node.
static SeqType DTD
          One day-time-duration.
static SeqType DTD_ZO
          Zero or one day-time-duration.
static SeqType DTM
          One date-time.
static SeqType DTM_ZO
          Zero or one date-time.
static SeqType DUR_ZO
          Zero or one duration.
static SeqType ELM
          One element node.
static SeqType ELM_ZM
          Zero or more element nodes.
static SeqType EMP
          Zero items.
static SeqType FUN_O
          Single function.
static SeqType FUN_OZ
          Zero of single function.
static SeqType FUN_ZM
          Zero of more functions.
static SeqType HEX
          One xs:hexBinary.
static SeqType ITEM
          Single item.
static SeqType ITEM_OM
          One or more items.
static SeqType ITEM_ZM
          Zero or more items.
static SeqType ITEM_ZO
          Zero or one item.
static SeqType ITR
          Single integer; for simplicity, numbers are summarized by this type.
static SeqType ITR_OM
          One or more integers.
static SeqType ITR_ZM
          Zero or more integers.
static SeqType ITR_ZO
          Zero or one integer.
static SeqType MAP_O
          Single function.
static SeqType MAP_ZM
          Single function.
static SeqType NCN_ZO
          Zero or one NCName.
static SeqType NOD
          Single node.
static SeqType NOD_ZM
          Zero or more nodes.
static SeqType NOD_ZO
          Zero or one nodes.
static SeqType NSP
          Namespace node.
 SeqType.Occ occ
          Number of occurrences.
static SeqType PI
          Namespace node.
static SeqType QNM
          Single QName.
static SeqType QNM_ZO
          Zero or one QNames.
static SeqType STR
          Single string.
static SeqType STR_ZM
          Zero or more strings.
static SeqType STR_ZO
          Zero or one strings.
static SeqType TIM
          One time.
static SeqType TIM_ZO
          Zero or one time.
static SeqType TXT_ZO
          Namespace node.
 Type type
          Sequence type.
static SeqType URI
          Single URI.
static SeqType URI_ZM
          Zero or more URIs.
static SeqType URI_ZO
          Zero or one URIs.
 
Method Summary
 Value cast(Item it, QueryContext ctx, InputInfo ii, ExprInfo e)
          Tries to cast the given item to this sequence type.
 Value cast(Value val, QueryContext ctx, InputInfo ii, ExprInfo e)
          Casts a sequence to this type.
 boolean convertibleTo(SeqType t)
          Checks if this type could be converted to the given one by function conversion.
 boolean eq(SeqType t)
          Checks the types for equality.
 Value funcConvert(QueryContext ctx, InputInfo ii, Value val)
          Performs function conversion on the given value.
static SeqType get(Type t, long o)
          Returns a sequence type.
static SeqType get(Type t, SeqType.Occ o)
          Returns a sequence type.
static SeqType get(Type t, SeqType.Occ o, Test k)
          Returns a sequence type.
 boolean instance(Value val)
          Matches a value against this sequence type.
 boolean instanceOf(SeqType t)
          Checks if the specified SeqType is an instance of the current SeqType.
 SeqType intersect(SeqType t)
          Computes the intersection of two sequence types, i.e.
 boolean mayBeNumber()
          Tests if the type may be numeric.
 boolean mayBeZero()
          Tests if the type may yield zero items.
 long occ()
          Returns the number of occurrences, or -1 if the number is unknown.
 boolean one()
          Tests if the type exactly one item.
 java.lang.String toString()
           
 Value treat(Value val, InputInfo ii)
          Treats the specified value as this sequence type.
 java.lang.String typeString()
          Returns a string representation of the type.
 SeqType union(SeqType t)
          Computes the union of two sequence types, i.e.
 SeqType withOcc(SeqType.Occ o)
          Returns a version of this sequence type that is adapted to the given SeqType.Occ.
 boolean zeroOrOne()
          Tests if the type yields at most one item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMP

public static final SeqType EMP
Zero items.


ITEM

public static final SeqType ITEM
Single item.


ITEM_ZO

public static final SeqType ITEM_ZO
Zero or one item.


ITEM_ZM

public static final SeqType ITEM_ZM
Zero or more items.


ITEM_OM

public static final SeqType ITEM_OM
One or more items.


AAT

public static final SeqType AAT
Zero or one xs:anyAtomicType.


AAT_ZO

public static final SeqType AAT_ZO
Zero or one xs:anyAtomicType.


AAT_ZM

public static final SeqType AAT_ZM
Zero or more xs:anyAtomicType.


BLN

public static final SeqType BLN
Single xs:boolean.


BLN_ZO

public static final SeqType BLN_ZO
Zero or one xs:boolean.


DBL

public static final SeqType DBL
Double number.


DBL_ZM

public static final SeqType DBL_ZM
Double number.


DBL_ZO

public static final SeqType DBL_ZO
Zero or one double.


DEC_ZO

public static final SeqType DEC_ZO
Zero or one decimal number.


ITR

public static final SeqType ITR
Single integer; for simplicity, numbers are summarized by this type.


ITR_ZO

public static final SeqType ITR_ZO
Zero or one integer.


ITR_ZM

public static final SeqType ITR_ZM
Zero or more integers.


ITR_OM

public static final SeqType ITR_OM
One or more integers.


BYT_OM

public static final SeqType BYT_OM
One or more bytes.


NOD

public static final SeqType NOD
Single node.


NOD_ZO

public static final SeqType NOD_ZO
Zero or one nodes.


NOD_ZM

public static final SeqType NOD_ZM
Zero or more nodes.


QNM

public static final SeqType QNM
Single QName.


QNM_ZO

public static final SeqType QNM_ZO
Zero or one QNames.


URI

public static final SeqType URI
Single URI.


URI_ZO

public static final SeqType URI_ZO
Zero or one URIs.


URI_ZM

public static final SeqType URI_ZM
Zero or more URIs.


STR

public static final SeqType STR
Single string.


STR_ZO

public static final SeqType STR_ZO
Zero or one strings.


STR_ZM

public static final SeqType STR_ZM
Zero or more strings.


NCN_ZO

public static final SeqType NCN_ZO
Zero or one NCName.


DAT

public static final SeqType DAT
Single date.


DAT_ZO

public static final SeqType DAT_ZO
Zero or one date.


DTD

public static final SeqType DTD
One day-time-duration.


DTD_ZO

public static final SeqType DTD_ZO
Zero or one day-time-duration.


DTM

public static final SeqType DTM
One date-time.


DTM_ZO

public static final SeqType DTM_ZO
Zero or one date-time.


TIM

public static final SeqType TIM
One time.


TIM_ZO

public static final SeqType TIM_ZO
Zero or one time.


DUR_ZO

public static final SeqType DUR_ZO
Zero or one duration.


FUN_OZ

public static final SeqType FUN_OZ
Zero of single function.


FUN_O

public static final SeqType FUN_O
Single function.


FUN_ZM

public static final SeqType FUN_ZM
Zero of more functions.


BYT_ZM

public static final SeqType BYT_ZM
Zero or more bytes.


ATT

public static final SeqType ATT
One attribute node.


COM

public static final SeqType COM
One comment node.


DOC_O

public static final SeqType DOC_O
One document node.


DOC_ZO

public static final SeqType DOC_ZO
Zero or one document node.


DOC_OM

public static final SeqType DOC_OM
One or more document node.


DOC_ZM

public static final SeqType DOC_ZM
Zero or more document node.


ELM

public static final SeqType ELM
One element node.


ELM_ZM

public static final SeqType ELM_ZM
Zero or more element nodes.


NSP

public static final SeqType NSP
Namespace node.


PI

public static final SeqType PI
Namespace node.


TXT_ZO

public static final SeqType TXT_ZO
Namespace node.


ANY_MAP

public static final MapType ANY_MAP
The general map type.


MAP_ZM

public static final SeqType MAP_ZM
Single function.


MAP_O

public static final SeqType MAP_O
Single function.


HEX

public static final SeqType HEX
One xs:hexBinary.


B64

public static final SeqType B64
Single xs:base64Binary.


B64_ZM

public static final SeqType B64_ZM
Zero or more xs:base64Binary.


BIN

public static final SeqType BIN
Single binary.


BIN_ZM

public static final SeqType BIN_ZM
Zero or more binaries.


type

public final Type type
Sequence type.


occ

public final SeqType.Occ occ
Number of occurrences.

Method Detail

get

public static SeqType get(Type t,
                          SeqType.Occ o)
Returns a sequence type.

Parameters:
t - type
o - occurrences
Returns:
sequence type

get

public static SeqType get(Type t,
                          long o)
Returns a sequence type.

Parameters:
t - type
o - number of occurrences
Returns:
sequence type

get

public static SeqType get(Type t,
                          SeqType.Occ o,
                          Test k)
Returns a sequence type.

Parameters:
t - type
o - occurrences
k - kind test
Returns:
sequence type

withOcc

public SeqType withOcc(SeqType.Occ o)
Returns a version of this sequence type that is adapted to the given SeqType.Occ.

Parameters:
o - occurrence indicator
Returns:
sequence type

instance

public boolean instance(Value val)
Matches a value against this sequence type.

Parameters:
val - value to be checked
Returns:
result of check

cast

public Value cast(Item it,
                  QueryContext ctx,
                  InputInfo ii,
                  ExprInfo e)
           throws QueryException
Tries to cast the given item to this sequence type.

Parameters:
it - item to cast
ctx - query context
ii - input info
e - expression for error message
Returns:
promoted item
Throws:
QueryException - query exception

cast

public Value cast(Value val,
                  QueryContext ctx,
                  InputInfo ii,
                  ExprInfo e)
           throws QueryException
Casts a sequence to this type.

Parameters:
val - value to cast
ctx - query context
ii - input info
e - expression
Returns:
resulting value
Throws:
QueryException - query exception

treat

public Value treat(Value val,
                   InputInfo ii)
            throws QueryException
Treats the specified value as this sequence type.

Parameters:
val - value to promote
ii - input info
Returns:
the value
Throws:
QueryException - query exception

funcConvert

public Value funcConvert(QueryContext ctx,
                         InputInfo ii,
                         Value val)
                  throws QueryException
Performs function conversion on the given value.

Parameters:
ctx - query context
ii - input info
val - value to convert
Returns:
converted value
Throws:
QueryException - if the conversion ws not possible

convertibleTo

public boolean convertibleTo(SeqType t)
Checks if this type could be converted to the given one by function conversion.

Parameters:
t - type to convert to
Returns:
result of check

union

public SeqType union(SeqType t)
Computes the union of two sequence types, i.e. the lowest common ancestor of both types.

Parameters:
t - second type
Returns:
resulting type

intersect

public SeqType intersect(SeqType t)
Computes the intersection of two sequence types, i.e. the most general type that is sub-type of both types. If no such type exists, null is returned

Parameters:
t - second type
Returns:
resulting type or null

occ

public long occ()
Returns the number of occurrences, or -1 if the number is unknown.

Returns:
result of check

zeroOrOne

public boolean zeroOrOne()
Tests if the type yields at most one item.

Returns:
result of check

one

public boolean one()
Tests if the type exactly one item.

Returns:
result of check

mayBeZero

public boolean mayBeZero()
Tests if the type may yield zero items.

Returns:
result of check

mayBeNumber

public boolean mayBeNumber()
Tests if the type may be numeric.

Returns:
result of check

eq

public boolean eq(SeqType t)
Checks the types for equality.

Parameters:
t - type
Returns:
result of check

instanceOf

public boolean instanceOf(SeqType t)
Checks if the specified SeqType is an instance of the current SeqType.

Parameters:
t - SeqType to check
Returns:
result of check

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

typeString

public java.lang.String typeString()
Returns a string representation of the type.

Returns:
string