xtc.parser
Class CharSwitch

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

public class CharSwitch
extends CharTerminal
implements InternalElement

A character switch terminal. This internal element is used to improve parser performance in recognizing terminals.

Version:
$Revision: 1.8 $
Author:
Robert Grimm

Nested Class Summary
 
Nested classes/interfaces inherited from class xtc.parser.Element
Element.Tag
 
Field Summary
 Element base
          The optional default element.
 java.util.List<CharCase> cases
          The list of character cases.
 
Constructor Summary
CharSwitch(CharClass klass, Element element)
          Create a new character switch element which includes a case for the specified character class and corresponding element.
CharSwitch(java.util.List<CharCase> cases)
          Create a new character switch element.
CharSwitch(java.util.List<CharCase> cases, Element base)
          Create a new character switch element.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 CharCase hasCase(CharClass klass)
          Determine whether this character switch has a character case for the specified character class.
 int hashCode()
           
 boolean overlaps(CharClass klass)
          Determine whether this character switch has a character case that overlaps the specified character class.
 Element.Tag tag()
          Get this element's tag.
 
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, toString, toToken, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

cases

public java.util.List<CharCase> cases
The list of character cases.


base

public Element base
The optional default element.

Constructor Detail

CharSwitch

public CharSwitch(java.util.List<CharCase> cases)
Create a new character switch element.

Parameters:
cases - The list of cases.

CharSwitch

public CharSwitch(java.util.List<CharCase> cases,
                  Element base)
Create a new character switch element.

Parameters:
cases - The list of cases.
base - The default element.

CharSwitch

public CharSwitch(CharClass klass,
                  Element element)
Create a new character switch element which includes a case for the specified character class and corresponding element. If the class is exclusive, the element of the case is left null and the base is set to the specified element. Furthermore, the specified class is modified to be non-exclusive.

Parameters:
klass - The character class.
element - The corresponding element.
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.

hasCase

public CharCase hasCase(CharClass klass)
Determine whether this character switch has a character case for the specified character class. The specified character class must be non-exclusive.

Parameters:
klass - The character class.
Returns:
The corresponding character case or null if this character switch does not have a case for the character class.

overlaps

public boolean overlaps(CharClass klass)
Determine whether this character switch has a character case that overlaps the specified character class. The specified character class must be non-exclusive.

Parameters:
klass - The character class.
Returns:
true if this character switch has an overlapping character case.
See Also:
CharClass.overlaps(CharClass)

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


Copyright © 2012. All Rights Reserved.