org.basex.query.value.type
Class FuncType

java.lang.Object
  extended by org.basex.query.value.type.FuncType
All Implemented Interfaces:
Type
Direct Known Subclasses:
MapType

public class FuncType
extends java.lang.Object
implements Type

XQuery 3.0 function data 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
 
Field Summary
 Ann ann
          Annotations.
static FuncType ANY_FUN
          Any function type.
 SeqType[] args
          Argument types.
 SeqType type
          Return type.
 
Method Summary
 Expr[] args(Var[] vs, QueryContext ctx, VarScope scp, InputInfo ii)
          Creates variables with types corresponding to this type's arguments.
static FuncType arity(int a)
          Getter for function types with a given arity.
 FItem 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 s, 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 Type find(QNm type)
          Finds and returns the specified function type.
static FuncType get(Ann a, SeqType ret, SeqType... args)
          Getter for function types.
static FuncType get(Ann an, Var[] args, SeqType ret)
          Getter for a function's type.
static FuncType get(SeqType ret, SeqType... args)
          Getter for function types without annotations.
 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.
 Type 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANY_FUN

public static final FuncType ANY_FUN
Any function type.


ann

public final Ann ann
Annotations.


args

public final SeqType[] args
Argument types.


type

public final SeqType type
Return type.

Method Detail

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 final 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 final 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 final 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 final 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

seqType

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

Specified by:
seqType in interface Type
Returns:
sequence type

string

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

Specified by:
string in interface Type
Returns:
name

cast

public FItem 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 final Item cast(java.lang.Object o,
                       QueryContext ctx,
                       InputInfo ii)
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

castString

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

Specified by:
castString in interface Type
Parameters:
s - string object
ctx - TODO
ii - input info
Returns:
new item

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 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 Type 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

get

public static FuncType get(Ann a,
                           SeqType ret,
                           SeqType... args)
Getter for function types.

Parameters:
a - annotations
ret - return type
args - argument types
Returns:
function type

get

public static FuncType get(SeqType ret,
                           SeqType... args)
Getter for function types without annotations.

Parameters:
ret - return type
args - argument types
Returns:
function type

find

public static Type find(QNm type)
Finds and returns the specified function type.

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

arity

public static FuncType arity(int a)
Getter for function types with a given arity.

Parameters:
a - number of arguments
Returns:
function type

get

public static FuncType get(Ann an,
                           Var[] args,
                           SeqType ret)
Getter for a function's type.

Parameters:
an - annotations
args - formal parameters
ret - return type
Returns:
function type

args

public Expr[] args(Var[] vs,
                   QueryContext ctx,
                   VarScope scp,
                   InputInfo ii)
Creates variables with types corresponding to this type's arguments.

Parameters:
vs - array in which to write the variables
ctx - query context
scp - variable scope
ii - input info
Returns:
calls to the variables

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

toString

public java.lang.String toString()
Specified by:
toString in interface Type
Overrides:
toString in class java.lang.Object

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