net.sf.saxon.expr

Class RoleLocator

public class RoleLocator extends Object implements Serializable

A RoleLocator identifies the role in which an expression is used, for example as the third argument of the concat() function. This information is stored in an ItemChecker or CardinalityChecker so that good diagnostics can be achieved when run-time type errors are detected.
Field Summary
static intBINARY_EXPR
static intFUNCTION
static intFUNCTION_RESULT
static intGROUPING_KEY
static intINSTRUCTION
static intORDER_BY
static intPARAM
static intTEMPLATE_RESULT
static intTYPE_OP
static intUNARY_EXPR
static intUPDATING_EXPR
static intVARIABLE
Constructor Summary
RoleLocator(int kind, Serializable operation, int operand)
Create information about the role of a subexpression within its parent expression
Method Summary
StringcomposeErrorMessage(ItemType requiredItemType, ItemType suppliedItemType, NamePool pool)
Construct a full error message
StringcomposeRequiredMessage(ItemType requiredItemType, NamePool pool)
Construct the part of the message giving the required item type
StringgetErrorCode()
Get the error code to be produced if a type error is detected
StringgetMessage()
Construct and return the error message indicating a type error
voidsetErrorCode(String code)
Set the error code to be produced if a type error is detected

Field Detail

BINARY_EXPR

public static final int BINARY_EXPR

FUNCTION

public static final int FUNCTION

FUNCTION_RESULT

public static final int FUNCTION_RESULT

GROUPING_KEY

public static final int GROUPING_KEY

INSTRUCTION

public static final int INSTRUCTION

ORDER_BY

public static final int ORDER_BY

PARAM

public static final int PARAM

TEMPLATE_RESULT

public static final int TEMPLATE_RESULT

TYPE_OP

public static final int TYPE_OP

UNARY_EXPR

public static final int UNARY_EXPR

UPDATING_EXPR

public static final int UPDATING_EXPR

VARIABLE

public static final int VARIABLE

Constructor Detail

RoleLocator

public RoleLocator(int kind, Serializable operation, int operand)
Create information about the role of a subexpression within its parent expression

Parameters: kind the kind of parent expression, e.g. a function call or a variable reference operation the name of the object in the parent expression, e.g. a function name or instruction name. May be expressed either as a String or as a StructuredQName. For a string, the special format element/attribute is recognized, for example xsl:for-each/select, to identify the role of an XPath expression in a stylesheet. operand Ordinal position of this subexpression, e.g. the position of an argument in a function call

Method Detail

composeErrorMessage

public String composeErrorMessage(ItemType requiredItemType, ItemType suppliedItemType, NamePool pool)
Construct a full error message

Parameters: requiredItemType the item type required by the context of a particular expression suppliedItemType the item type inferred by static analysis of an expression pool the name pool

Returns: a message of the form "Required item type of A is R; supplied value has item type S"

composeRequiredMessage

public String composeRequiredMessage(ItemType requiredItemType, NamePool pool)
Construct the part of the message giving the required item type

Parameters: requiredItemType the item type required by the context of a particular expression pool the name pool

Returns: a message of the form "Required item type of X is Y"

getErrorCode

public String getErrorCode()
Get the error code to be produced if a type error is detected

Returns: code The error code

getMessage

public String getMessage()
Construct and return the error message indicating a type error

Returns: the constructed error message

setErrorCode

public void setErrorCode(String code)
Set the error code to be produced if a type error is detected

Parameters: code The error code