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 intINSTRUCTION
static intORDER_BY
static intTEMPLATE_RESULT
static intTYPE_OP
static intVARIABLE
Constructor Summary
RoleLocator(int kind, Object container, int operand, NamePool namePool)
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
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
SourceLocatorgetSourceLocator()
Get the source location (if known - return null if not known)
voidsetErrorCode(String code)
Set the error code to be produced if a type error is detected
voidsetSourceLocator(SourceLocator locator)
Set the source location

Field Detail

BINARY_EXPR

public static final int BINARY_EXPR

FUNCTION

public static final int FUNCTION

FUNCTION_RESULT

public static final int FUNCTION_RESULT

INSTRUCTION

public static final int INSTRUCTION

ORDER_BY

public static final int ORDER_BY

TEMPLATE_RESULT

public static final int TEMPLATE_RESULT

TYPE_OP

public static final int TYPE_OP

VARIABLE

public static final int VARIABLE

Constructor Detail

RoleLocator

public RoleLocator(int kind, Object container, int operand, NamePool namePool)
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 container 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 an Integer nameCode in the name pool. operand Ordinal position of this subexpression, e.g. the position of an argument in namePool The name pool. Must be supplied if the second argument is an Integer namecode. Otherwise, may be null.

Method Detail

composeErrorMessage

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

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

getSourceLocator

public SourceLocator getSourceLocator()
Get the source location (if known - return null if not known)

setErrorCode

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

Parameters: code The error code

setSourceLocator

public void setSourceLocator(SourceLocator locator)
Set the source location