xtc.parser
Class NonTerminal

java.lang.Object
  extended by xtc.tree.Node
      extended by xtc.parser.Element
          extended by xtc.parser.NonTerminal
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, Locatable

public class NonTerminal
extends Element

A nonterminal.

Version:
$Revision: 1.22 $
Author:
Robert Grimm

Nested Class Summary
 
Nested classes/interfaces inherited from class xtc.parser.Element
Element.Tag
 
Field Summary
 java.lang.String name
          The name.
 
Constructor Summary
NonTerminal(NonTerminal nt)
          Create a new nonterminal that is a copy of the specified nonterminal.
NonTerminal(java.lang.String name)
          Create a new nonterminal with the specified name.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.String getQualifier()
          Get this nonterminal's qualifier.
 int hashCode()
           
 boolean isQualified()
          Determine whether this nonterminal is qualified.
 NonTerminal qualify(java.lang.String module)
          Qualify this nonterminal.
 NonTerminal rename(ModuleMap renaming)
          Rename this nonterminal.
 Element.Tag tag()
          Get this element's tag.
 java.lang.String toIdentifier()
          Convert this nonterminal to the corresponding Java identifier.
 java.lang.String toString()
          Return a human readable representation of this node.
 NonTerminal unqualify()
          Unqualify this nonterminal.
 void write(java.lang.Appendable out)
          Write a human readable representation to the specified appendable.
 
Methods inherited from class xtc.tree.Node
add, add, addAll, addAll, addAll, addAll, addAllTo, addNode, contains, get, getBoolean, getBooleanProperty, getGeneric, getList, getLocation, getName, getNode, getProperty, getString, getStringProperty, getTokenText, hasLocation, hasName, hasProperty, hasTraversal, hasVariable, indexOf, isAnnotation, isEmpty, isGeneric, isList, isToken, iterator, lastIndexOf, properties, remove, removeProperty, set, setLocation, setLocation, setProperty, size, strip, toAnnotation, toList, toToken
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public final java.lang.String name
The name.

Constructor Detail

NonTerminal

public NonTerminal(java.lang.String name)
Create a new nonterminal with the specified name.

Parameters:
name - The name.

NonTerminal

public NonTerminal(NonTerminal nt)
Create a new nonterminal that is a copy of the specified nonterminal.

Parameters:
nt - The nonterminal.
Method Detail

tag

public Element.Tag tag()
Description copied from class: Element
Get this element's tag.

Specified by:
tag in class Element
Returns:
The tag.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

isQualified

public boolean isQualified()
Determine whether this nonterminal is qualified.

Returns:
true if this nonterminal is qualified.

getQualifier

public java.lang.String getQualifier()
Get this nonterminal's qualifier. If this nonterminal is qualified, this method returns the qualifier. Otherwise, it returns null.

Returns:
The qualifier.

qualify

public NonTerminal qualify(java.lang.String module)
Qualify this nonterminal. If this nonterminal is not qualified, this method returns a new nonterminal representing a fully qualified name. Otherwise, it returns this nonterminal.

Parameters:
module - The module name.
Returns:
The corresponding, qualified nonterminal.

unqualify

public NonTerminal unqualify()
Unqualify this nonterminal. If this nonterminal is qualified, this method returns a new nonterminal representing the unqualified name. Otherwise, it returns this nonterminal.

Returns:
The corresponding, unqualified nonterminal.

rename

public NonTerminal rename(ModuleMap renaming)
Rename this nonterminal. If this nonterminal is qualified and the qualifier is a key in the specified module map, this method returns a new nonterminal with the mapping's value as the new qualifier. The new nonterminal's original property is set to be this nonterminal's original name (i.e., this nonterminal's original property if it has that property or this nonterminal if it does not). Otherwise, this method returns this nonterminal.

Parameters:
renaming - The module map.
Returns:
The renamed nonterminal.

toIdentifier

public java.lang.String toIdentifier()
Convert this nonterminal to the corresponding Java identifier.

Returns:
The corresponding Java identifier.

write

public void write(java.lang.Appendable out)
           throws java.io.IOException
Description copied from class: Node
Write a human readable representation to the specified appendable. If this node supports generic traversal, the default implementation writes this node in algebraic term-format; otherwise, it writes the string returned by Object.toString().

Overrides:
write in class Node
Parameters:
out - The appendable.
Throws:
java.io.IOException - Signals an I/O error.

toString

public java.lang.String toString()
Description copied from class: Node
Return a human readable representation of this node. The default implementation creates a new string builder, writes this node to the builder, and then returns the corresponding string. Subclasses should typically override Node.write(Appendable).

Overrides:
toString in class Node
Returns:
A human readable representation.


Copyright © 2012. All Rights Reserved.