Class RoleLocator

  • All Implemented Interfaces:
    java.io.Serializable

    public class RoleLocator
    extends java.lang.Object
    implements java.io.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
    • Constructor Detail

      • RoleLocator

        public RoleLocator​(int kind,
                           java.lang.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​(java.lang.String code)
        Set the error code to be produced if a type error is detected
        Parameters:
        code - The error code
      • getErrorCode

        public java.lang.String getErrorCode()
        Get the error code to be produced if a type error is detected
        Returns:
        code The error code
      • getMessage

        public java.lang.String getMessage()
        Construct and return the error message indicating a type error
        Returns:
        the constructed error message
      • composeRequiredMessage

        public java.lang.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 java.lang.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 java.lang.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