Class TagChunk


  • class TagChunk
    extends Chunk
    Represents a placeholder tag in a tree pattern. A tag can have any of the following forms.
    • expr: An unlabeled placeholder for a parser rule expr.
    • ID: An unlabeled placeholder for a token of type ID.
    • e:expr: A labeled placeholder for a parser rule expr.
    • id:ID: A labeled placeholder for a token of type ID.
    This class does not perform any validation on the tag or label names aside from ensuring that the tag is a non-null, non-empty string.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String label
      This is the backing field for getLabel().
      private java.lang.String tag
      This is the backing field for getTag().
    • Constructor Summary

      Constructors 
      Constructor Description
      TagChunk​(java.lang.String tag)
      Construct a new instance of TagChunk using the specified tag and no label.
      TagChunk​(java.lang.String label, java.lang.String tag)
      Construct a new instance of TagChunk using the specified label and tag.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getLabel()
      Get the label, if any, assigned to this chunk.
      java.lang.String getTag()
      Get the tag for this chunk.
      java.lang.String toString()
      This method returns a text representation of the tag chunk.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • tag

        private final java.lang.String tag
        This is the backing field for getTag().
      • label

        private final java.lang.String label
        This is the backing field for getLabel().
    • Constructor Detail

      • TagChunk

        public TagChunk​(java.lang.String tag)
        Construct a new instance of TagChunk using the specified tag and no label.
        Parameters:
        tag - The tag, which should be the name of a parser rule or token type.
        Throws:
        java.lang.IllegalArgumentException - if tag is null or empty.
      • TagChunk

        public TagChunk​(java.lang.String label,
                        java.lang.String tag)
        Construct a new instance of TagChunk using the specified label and tag.
        Parameters:
        label - The label for the tag. If this is null, the TagChunk represents an unlabeled tag.
        tag - The tag, which should be the name of a parser rule or token type.
        Throws:
        java.lang.IllegalArgumentException - if tag is null or empty.
    • Method Detail

      • getTag

        public final java.lang.String getTag()
        Get the tag for this chunk.
        Returns:
        The tag for the chunk.
      • getLabel

        public final java.lang.String getLabel()
        Get the label, if any, assigned to this chunk.
        Returns:
        The label assigned to this chunk, or null if no label is assigned to the chunk.
      • toString

        public java.lang.String toString()
        This method returns a text representation of the tag chunk. Labeled tags are returned in the form label:tag, and unlabeled tags are returned as just the tag name.
        Overrides:
        toString in class java.lang.Object