scanner
Class Set

java.lang.Object
  extended byscanner.Set
All Implemented Interfaces:
java.lang.Cloneable

public class Set
extends java.lang.Object
implements java.lang.Cloneable

This class defines sets used to group token types while parsing.


Constructor Summary
Set()
          Default constructor.
Set(Set set)
          Creates a new set from the specified one.
Set(TokenType tokenType)
          Creates a new set containing the specified tokenType.
Set(TokenType[] tokenTypes)
          Creates a new set.
 
Method Summary
 void add(TokenType tokenType)
          Adds the specified token type in the set.
 java.lang.Object clone()
           
 boolean contains(Set aSet)
           
 boolean contains(TokenType tokenType)
          Checks if a token type if contained in this set or not.
 Set createUnion(Set aSet)
          Creates a new set containing tokens types from this set AND tokens types from the given set.
 Set createUnion(TokenType tokenType)
          Creates a new set containing tokens types from this set AND the specified token type.
 boolean equals(java.lang.Object o)
           
 TokenType[] getTypes()
          Returns an array representation of the types contained in this set.
 Set intersect(Set aSet)
          Returns a new set containing elements contained in this set AND in the given one.
 void remove(Set aSet)
          Removes all elements of the given set from this set.
 boolean remove(TokenType tokenType)
          Removes the spcified token type from this set.
 int size()
          Returns the number of elements in this set.
 java.lang.String toString()
          Returns a string representation of this set.
 Set union(Set aSet)
          Adds the tokens types from the specified set to this set (without creating any new set).
 Set union(TokenType tokenType)
          Performs an union with the specified token type without creating any new set.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Set

public Set(TokenType[] tokenTypes)
Creates a new set.

Parameters:
tokenTypes - Token types to be put in the created set.

Set

public Set()
Default constructor. Constructs an empty set.


Set

public Set(Set set)
Creates a new set from the specified one.

Parameters:
set - The set from which this set has to be initialized.

Set

public Set(TokenType tokenType)
Creates a new set containing the specified tokenType.

Parameters:
tokenType - Token type to be put in the created set.
Method Detail

getTypes

public TokenType[] getTypes()
Returns an array representation of the types contained in this set.

Returns:
An array representation of the types contained in this set. An array with size 0 is returned if the set is empty.

size

public int size()
Returns the number of elements in this set.

Returns:
The number of elements in this set.

add

public void add(TokenType tokenType)
Adds the specified token type in the set. This token type is added even if the set already contains it.

Parameters:
tokenType - The token type added in the set.

remove

public boolean remove(TokenType tokenType)
Removes the spcified token type from this set.

Parameters:
tokenType - The token type to be removed from this set.
Returns:
true if the token type was contained in this set. false otherwise.

contains

public boolean contains(TokenType tokenType)
Checks if a token type if contained in this set or not.

Parameters:
tokenType - The type of token that may be contained in this set.
Returns:
true if the token type is contained in this set. false otherwise.

contains

public boolean contains(Set aSet)

remove

public void remove(Set aSet)
Removes all elements of the given set from this set.

Parameters:
aSet - Elements to be removed from this set.

createUnion

public Set createUnion(Set aSet)
Creates a new set containing tokens types from this set AND tokens types from the given set.

Parameters:
aSet - The set to be unioned with this one.
Returns:
A set containing tokens types from this set AND tokens types from the given set.

createUnion

public Set createUnion(TokenType tokenType)
Creates a new set containing tokens types from this set AND the specified token type.

Parameters:
tokenType - The token type to be added to this set to create the union result.
Returns:
A set containing tokens types from this set AND the specified token type.

union

public Set union(Set aSet)
Adds the tokens types from the specified set to this set (without creating any new set).

Parameters:
aSet - A set containing tokens types to be added to this set.
Returns:
A reference on this.

union

public Set union(TokenType tokenType)
Performs an union with the specified token type without creating any new set.

Parameters:
tokenType - The token type to be unioned with this set.
Returns:
A reference on this.

intersect

public Set intersect(Set aSet)
Returns a new set containing elements contained in this set AND in the given one.

Parameters:
aSet - The set to be intersected with this one.
Returns:
A new set containing elements contained in this set AND in the given one.

clone

public java.lang.Object clone()

equals

public boolean equals(java.lang.Object o)

toString

public java.lang.String toString()
Returns a string representation of this set.

Returns:
A string representation of this set.