Class XPathParser.NestedLocation

  • All Implemented Interfaces:
    javax.xml.transform.SourceLocator, Location, org.xml.sax.Locator
    Enclosing class:
    XPathParser

    public static class XPathParser.NestedLocation
    extends java.lang.Object
    implements Location
    A nested location: for use with XPath expressions and queries nested within some larger document. The location information comes in two parts: the location of the query or expression within the containing document, and the location of an error within the query or XPath expression.
    • Constructor Summary

      Constructors 
      Constructor Description
      NestedLocation​(Location containingLocation, int localLineNumber, int localColumnNumber, java.lang.String nearbyText)
      Create a NestedLocation
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getColumnNumber()
      Get the column number of the error within the expression or query
      Location getContainingLocation()
      Get the location of the container.
      int getLineNumber()
      Get the line number within the containing entity.
      int getLocalLineNumber()
      Get the local line number, that is the line number relative to the start of the expression or query.
      java.lang.String getNearbyText()
      Get text appearing near to the error (typically a syntax error) within the source text of the expression or query.
      java.lang.String getPublicId()
      Get the public identifier.
      java.lang.String getSystemId()
      Get the system identifier of the expression's container.
      Location saveLocation()
      Save an immutable copy of the location information.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NestedLocation

        public NestedLocation​(Location containingLocation,
                              int localLineNumber,
                              int localColumnNumber,
                              java.lang.String nearbyText)
        Create a NestedLocation
        Parameters:
        containingLocation - the location of the containing construct, typically an attribute or text node in an XML document
        localLineNumber - the line number within the containing construct, starting at zero
        localColumnNumber - the column number within the containing construct, starting at zero
        nearbyText - text appearing in the vicinity of the error location
    • Method Detail

      • getContainingLocation

        public Location getContainingLocation()
        Get the location of the container. This is normally used for expressions nested within an XML document, where the container location gives the location of the attribute or text node holding the XPath expression as a whole
        Returns:
        the location of the containing expression or query
      • getColumnNumber

        public int getColumnNumber()
        Get the column number of the error within the expression or query
        Specified by:
        getColumnNumber in interface Location
        Specified by:
        getColumnNumber in interface org.xml.sax.Locator
        Specified by:
        getColumnNumber in interface javax.xml.transform.SourceLocator
        Returns:
        the column number. This is generally maintained only during parsing, so it will be returned as -1 (meaning not available) in the case of dynamic errors. Column numbers start at 0. For expressions held within XML attributes, the position is within the attribute after XML attribute-value normalization, which replaces newlines by spaces and expands entity references.
      • getSystemId

        public java.lang.String getSystemId()
        Get the system identifier of the expression's container. This will normally be the URI of the document (or external entity) in which the expression appears.
        Specified by:
        getSystemId in interface Location
        Specified by:
        getSystemId in interface org.xml.sax.Locator
        Specified by:
        getSystemId in interface javax.xml.transform.SourceLocator
        Returns:
        the system identifier of the expression's container, or null if not known
      • getPublicId

        public java.lang.String getPublicId()
        Get the public identifier. This will normally be null, but is provided for compatibility with SAX and JAXP interfaces
        Specified by:
        getPublicId in interface Location
        Specified by:
        getPublicId in interface org.xml.sax.Locator
        Specified by:
        getPublicId in interface javax.xml.transform.SourceLocator
        Returns:
        the public identifier - usually null
      • getLocalLineNumber

        public int getLocalLineNumber()
        Get the local line number, that is the line number relative to the start of the expression or query. For expressions held within XML attributes, the position is within the attribute after XML attribute-value normalization, which replaces newlines by spaces and expands entity references; the value will therefore in many cases not be usable. Local line numbers start at 0.
        Returns:
        the local line number within the expression or query. Set to -1 if not known.
      • getLineNumber

        public int getLineNumber()
        Get the line number within the containing entity. This is the sum of the containing location's line number, plus the local line number. Returns -1 if unknown.
        Specified by:
        getLineNumber in interface Location
        Specified by:
        getLineNumber in interface org.xml.sax.Locator
        Specified by:
        getLineNumber in interface javax.xml.transform.SourceLocator
        Returns:
        the line number within the containing entity, or -1 if unknown.
      • getNearbyText

        public java.lang.String getNearbyText()
        Get text appearing near to the error (typically a syntax error) within the source text of the expression or query.
        Returns:
        nearby text to the error. May be null.
      • saveLocation

        public Location saveLocation()
        Save an immutable copy of the location information. This implementation does nothing, because the object is already immutable
        Specified by:
        saveLocation in interface Location
        Returns:
        immutable location information.