net.sf.saxon.expr.parser
Class RoleLocator

java.lang.Object
  extended by net.sf.saxon.expr.parser.RoleLocator
All Implemented Interfaces:
Serializable

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.

See Also:
Serialized Form

Field Summary
static int BINARY_EXPR
           
static int CONTEXT_ITEM
           
static int EVALUATE_RESULT
           
static int FUNCTION
           
static int FUNCTION_RESULT
           
static int GROUPING_KEY
           
static int INSTRUCTION
           
static int ORDER_BY
           
static int PARAM
           
static int TEMPLATE_RESULT
           
static int TYPE_OP
           
static int UNARY_EXPR
           
static int UPDATING_EXPR
           
static int VARIABLE
           
 
Constructor Summary
RoleLocator(int kind, Object operation, int operand)
          Create information about the role of a subexpression within its parent expression
 
Method Summary
 String composeErrorMessage(ItemType requiredItemType, ItemType suppliedItemType, NamePool pool)
          Construct a full error message
 String composeRequiredMessage(ItemType requiredItemType, NamePool pool)
          Construct the part of the message giving the required item type
 String getErrorCode()
          Get the error code to be produced if a type error is detected
 String getMessage()
          Construct and return the error message indicating a type error
static String ordinal(int n)
          Get the ordinal representation of a number (used to identify which argument of a function is in error)
 void setErrorCode(String code)
          Set the error code to be produced if a type error is detected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FUNCTION

public static final int FUNCTION
See Also:
Constant Field Values

BINARY_EXPR

public static final int BINARY_EXPR
See Also:
Constant Field Values

TYPE_OP

public static final int TYPE_OP
See Also:
Constant Field Values

VARIABLE

public static final int VARIABLE
See Also:
Constant Field Values

INSTRUCTION

public static final int INSTRUCTION
See Also:
Constant Field Values

FUNCTION_RESULT

public static final int FUNCTION_RESULT
See Also:
Constant Field Values

ORDER_BY

public static final int ORDER_BY
See Also:
Constant Field Values

TEMPLATE_RESULT

public static final int TEMPLATE_RESULT
See Also:
Constant Field Values

PARAM

public static final int PARAM
See Also:
Constant Field Values

UNARY_EXPR

public static final int UNARY_EXPR
See Also:
Constant Field Values

UPDATING_EXPR

public static final int UPDATING_EXPR
See Also:
Constant Field Values

GROUPING_KEY

public static final int GROUPING_KEY
See Also:
Constant Field Values

EVALUATE_RESULT

public static final int EVALUATE_RESULT
See Also:
Constant Field Values

CONTEXT_ITEM

public static final int CONTEXT_ITEM
See Also:
Constant Field Values
Constructor Detail

RoleLocator

public RoleLocator(int kind,
                   Object 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

setErrorCode

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

Parameters:
code - The error code

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

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"

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"

ordinal

public static String ordinal(int n)
Get the ordinal representation of a number (used to identify which argument of a function is in error)

Parameters:
n - the cardinal number
Returns:
the ordinal representation


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.