Class TraceExpression

All Implemented Interfaces:
Serializable, SourceLocator, LocationProvider, SaxonLocator, Container, Expression, TailCallReturner, InstructionInfo, InstructionInfoProvider, Locator

public class TraceExpression extends TraceWrapper implements InstructionInfo
A subclass of TraceWrapper used to trace expressions in XPath and XQuery. Unlike the TraceInstruction class, this class contains all information needed for tracing, rather than referencing a separate InstructionDetails object.
See Also:
  • Constructor Details

    • TraceExpression

      public TraceExpression(Expression child)
      Create a trace expression that traces execution of a given child expression
      Parameters:
      child - the expression to be traced. This will be available to the TraceListener as the value of the "expression" property of the InstructionInfo.
  • Method Details

    • setLineNumber

      public void setLineNumber(int line)
      Set the line number of the expression being traced
      Parameters:
      line -
    • setColumnNumber

      public void setColumnNumber(int column)
      Set the column number of the expression being traced
      Parameters:
      column -
    • setConstructType

      public void setConstructType(int type)
      Set the type of construct. This will generally be a constant in class Location
    • getConstructType

      public int getConstructType()
      Get the construct type. This will generally be a constant in class Location
      Specified by:
      getConstructType in interface InstructionInfo
      Overrides:
      getConstructType in class ComputedExpression
      Returns:
      the type of expression, as enumerated in class Location
    • setNamespaceResolver

      public void setNamespaceResolver(NamespaceResolver resolver)
      Set the namespace context for the instruction being traced. This is needed if the tracelistener wants to evaluate XPath expressions in the context of the current instruction
    • getNamespaceResolver

      public NamespaceResolver getNamespaceResolver()
      Get the namespace resolver to supply the namespace context of the instruction that is being traced
      Specified by:
      getNamespaceResolver in interface InstructionInfo
    • setSystemId

      public void setSystemId(String systemId)
      Set the URI of the module containing the instruction
      Parameters:
      systemId - the module's URI
    • getSystemId

      public String getSystemId()
      Get the URI of the module containing the instruction
      Specified by:
      getSystemId in interface InstructionInfo
      Specified by:
      getSystemId in interface Locator
      Specified by:
      getSystemId in interface SourceLocator
      Overrides:
      getSystemId in class ComputedExpression
      Returns:
      the module's URI
    • getLineNumber

      public int getLineNumber()
      Get the line number of the instruction within its module
      Specified by:
      getLineNumber in interface InstructionInfo
      Specified by:
      getLineNumber in interface Locator
      Specified by:
      getLineNumber in interface SourceLocator
      Overrides:
      getLineNumber in class ComputedExpression
      Returns:
      the line number
    • setObjectNameCode

      public void setObjectNameCode(int nameCode)
      Set a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc. This is used only where the name is known statically.
    • getObjectNameCode

      public int getObjectNameCode()
      Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc. This is used only where the name is known statically.
      Specified by:
      getObjectNameCode in interface InstructionInfo
    • setProperty

      public void setProperty(String name, Object value)
      Set a named property of the instruction/expression
    • getProperty

      public Object getProperty(String name)
      Get a named property of the instruction/expression
      Specified by:
      getProperty in interface InstructionInfo
      Parameters:
      name - The name of the required property
      Returns:
      The value of the requested property, or null if the property is not available
    • getProperties

      public Iterator getProperties()
      Get an iterator over all the properties available. The values returned by the iterator will be of type String, and each string can be supplied as input to the getProperty() method to retrieve the value of the property.
      Specified by:
      getProperties in interface InstructionInfo
    • getColumnNumber

      public int getColumnNumber()
      Get the column number identifying the position of the instruction. This method is provided to satisfy the SourceLocator interface. However, the column number is not maintained by Saxon, and the method always returns -1
      Specified by:
      getColumnNumber in interface Locator
      Specified by:
      getColumnNumber in interface SourceLocator
      Overrides:
      getColumnNumber in class ComputedExpression
      Returns:
      -1
    • getInstructionInfo

      public InstructionInfo getInstructionInfo()
      Get the InstructionInfo details about the construct. This is to satisfy the InstructionInfoProvider interface.
      Specified by:
      getInstructionInfo in interface InstructionInfoProvider
      Overrides:
      getInstructionInfo in class Instruction
    • getSystemId

      public String getSystemId(int locationId)
      Get the system identifier (that is the base URI) of the static context of the expression being traced. This returns the same result as getSystemId(), it is provided to satisfy the LocationProvider interface.
      Specified by:
      getSystemId in interface LocationProvider
      Parameters:
      locationId - not used
      Returns:
      the URI of the module containing the expression
    • getLineNumber

      public int getLineNumber(int locationId)
      Get the line number of the expression being traced. This returns the same result as getLineNumber(), it is provided to satisfy the LocationProvider interface.
      Specified by:
      getLineNumber in interface LocationProvider
      Parameters:
      locationId - not used
      Returns:
      the line number of the expression within its module