Class XmlRef

All Implemented Interfaces:
Comparable<AstNode>, Iterable<Node>
Direct Known Subclasses:
XmlElemRef, XmlPropRef

public abstract class XmlRef extends AstNode
Base class for E4X XML attribute-access or property-get expressions. Such expressions can take a variety of forms. The general syntax has three parts:
  1. optional: an @ (specifying an attribute access)
  2. optional: a namespace (a Name) and double-colon
  3. required: either a Name or a bracketed [expression]
The property-name expressions (examples: ns::name, @name) are represented as XmlPropRef nodes. The bracketed-expression versions (examples: ns::[name], @[name]) become XmlElemRef nodes.

This node type (or more specifically, its subclasses) will sometimes be the right-hand child of a PropertyGet node or an XmlMemberGet node. The XmlRef node may also be a standalone primary expression with no explicit target, which is valid in certain expression contexts such as company..employee.(@id &lt; 100) - in this case, the @id is an XmlRef that is part of an infix '<' expression whose parent is an XmlDotQuery node.

  • Field Details

    • namespace

      protected Name namespace
    • atPos

      protected int atPos
    • colonPos

      protected int colonPos
  • Constructor Details

    • XmlRef

      public XmlRef()
    • XmlRef

      public XmlRef(int pos)
    • XmlRef

      public XmlRef(int pos, int len)
  • Method Details

    • getNamespace

      public Name getNamespace()
      Return the namespace. May be @null.
    • setNamespace

      public void setNamespace(Name namespace)
      Sets namespace, and sets its parent to this node. Can be null.
    • isAttributeAccess

      public boolean isAttributeAccess()
      Returns true if this expression began with an @-token.
    • getAtPos

      public int getAtPos()
      Returns position of @-token, or -1 if this is not an attribute-access expression.
    • setAtPos

      public void setAtPos(int atPos)
      Sets position of @-token, or -1
    • getColonPos

      public int getColonPos()
      Returns position of :: token, or -1 if not present. It will only be present if the namespace node is non-null.
    • setColonPos

      public void setColonPos(int colonPos)
      Sets position of :: token, or -1 if not present