Top Description Fields Constructors Methods
org.antlr.v4.runtime.tree.pattern

pack-priv Class TagChunk

extends Chunk
Class Inheritance
Imports
org.antlr.v4.runtime.misc.NotNull, .Nullable

Represents a placeholder tag in a tree pattern. A tag can have any of the following forms. 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

Modifier and TypeField and Description
private final String
label

This is the backing field for getLabel.

private final String
tag

This is the backing field for getTag.

Constructor Summary

AccessConstructor and Description
public
TagChunk(String
The tag, which should be the name of a parser rule or token type.
tag
)

Construct a new instance of TagChunk using the specified tag and no label.

public
TagChunk(String
The label for the tag. If this is null, the TagChunk represents an unlabeled tag.
label
,
String
The tag, which should be the name of a parser rule or token type.
tag
)

Construct a new instance of TagChunk using the specified label and tag.

Method Summary

Modifier and TypeMethod and Description
public final String

Returns:

The label assigned to this chunk, or null if no label is assigned to the chunk.
getLabel
()

Get the label, if any, assigned to this chunk.

public final String

Returns:

The tag for the chunk.
getTag
()

Get the tag for this chunk.

public String
toString()

Overrides java.lang.Object.toString.

This method returns a text representation of the tag chunk.

Field Detail

labelback to summary
private final String label

This is the backing field for getLabel.

tagback to summary
private final String tag

This is the backing field for getTag.

Constructor Detail

TagChunkback to summary
public TagChunk(String tag)

Construct a new instance of TagChunk using the specified tag and no label.

Parameters
tag:String

The tag, which should be the name of a parser rule or token type.

Exceptions
IllegalArgumentException:
if tag is null or empty.
TagChunkback to summary
public TagChunk(String label, String tag)

Construct a new instance of TagChunk using the specified label and tag.

Parameters
label:String

The label for the tag. If this is null, the TagChunk represents an unlabeled tag.

tag:String

The tag, which should be the name of a parser rule or token type.

Exceptions
IllegalArgumentException:
if tag is null or empty.

Method Detail

getLabelback to summary
public final String getLabel()

Get the label, if any, assigned to this chunk.

Returns:String

The label assigned to this chunk, or null if no label is assigned to the chunk.

Annotations
@Nullable
getTagback to summary
public final String getTag()

Get the tag for this chunk.

Returns:String

The tag for the chunk.

Annotations
@NotNull
toStringback to summary
public String toString()

Overrides java.lang.Object.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.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override