classifierLibrary
Class SymbolSet

java.lang.Object
  extended byclassifierLibrary.SymbolSet
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Language

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

Library classifierLibrary, Classe SymbolSet

Encapsulates a HashTable, representing a set of Symbols.

Copyright by Klaus Hufschlag 2004,2005,2006

This file is part of the Generic Classifier Library. The Generic Classifier Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The Generic Classifier Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the Generic Classifier Library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Version:
1.4
Author:
Klaus Hufschlag

Constructor Summary
SymbolSet()
          Constructor.
SymbolSet(java.lang.String name)
          Constructor.
SymbolSet(java.lang.String name, java.lang.String[] symbolNames)
           
 
Method Summary
 void add(Symbol s)
          Method for adding a Symbol to the set.
 void add(SymbolSet s)
          Method for adding all Symbols of another SymbolSet to the set.
 void addMultiSymbols(java.lang.String[] names)
          Adds Symbols following a list of names to the instance.
 java.util.Collection asCollection()
          Returns a collection-view on the instance, giving access to further java standard methods.
 java.lang.Object clone()
           
 boolean contains(java.lang.String name)
          Checks, whether a Symbol given by its name is contained in the set.
 boolean contains(Symbol s)
          Checks, whether a given Symbol is contained in the set.
 boolean contains(SymbolSet s)
          Checks, whether a given SymbolSet is a subset of the set.
 void debug_out()
          Method for debugging-purposes.
 Symbol getDefault()
          Returns the default-Symbol of the instance.
 java.lang.String getName()
          Method returns the name of the instance.
 int getSize()
          Returns the number of Symbols contained.
 java.util.Iterator iterator()
          Returns an iterator through alle elements contained.
 java.util.ArrayList powerSet()
          Generates an ArrayList of SymbolSets, representing the power set of the instance (ie. the set of all possible subsets of the set represented by the instance).
 Symbol randomSymbol()
          Returns a randomly selected Symbol contained in the instance.
 void remove()
          Removes all Symbols from the instance.
 void remove(Symbol s)
          Removes a Symbol from the set.
 void remove(SymbolSet s)
          Removes a Set of Symbols from the instance.
 void setDefault(java.lang.String Name)
          Method to define a Symbol as default-Symbol of the instance.
 void setDefault(Symbol s)
          Method to define a Symbol as default-Symbol of the instance.
 void setName(java.lang.String name)
          Method for Setting the name of the instance.
 Symbol symbolByName(java.lang.String Name)
          Returns a Symbol given by its Name, if contained in the instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SymbolSet

public SymbolSet()
Constructor. Creates a new (nameless) instance of SymbolSet.


SymbolSet

public SymbolSet(java.lang.String name)
Constructor. Creates a new instance of SymbolSet with a given name.

Parameters:
name - Name for the new SymbolSet.

SymbolSet

public SymbolSet(java.lang.String name,
                 java.lang.String[] symbolNames)
Method Detail

clone

public java.lang.Object clone()

setName

public void setName(java.lang.String name)
Method for Setting the name of the instance.

Parameters:
name - Name to be set.

getName

public java.lang.String getName()
Method returns the name of the instance.

Returns:
Name of the instance.

add

public void add(Symbol s)
Method for adding a Symbol to the set.

Parameters:
s - Symbol to be added.

add

public void add(SymbolSet s)
Method for adding all Symbols of another SymbolSet to the set.

Parameters:
s - SymbolSet of Symbols to be added.

addMultiSymbols

public void addMultiSymbols(java.lang.String[] names)
Adds Symbols following a list of names to the instance. If a Symbol is not yet existing, it is created.

Parameters:
names -

contains

public boolean contains(Symbol s)
Checks, whether a given Symbol is contained in the set.

Parameters:
s - Symbol to check
Returns:
true, if Symbol is contained

contains

public boolean contains(java.lang.String name)
Checks, whether a Symbol given by its name is contained in the set.

Parameters:
name - Name of the Symbol to check
Returns:
true, if Symbol is contained

contains

public boolean contains(SymbolSet s)
Checks, whether a given SymbolSet is a subset of the set.

Parameters:
s - SymbolSet to check for being a subset of the instance
Returns:
true, if all Symbols are contained in the instance

remove

public void remove(Symbol s)
Removes a Symbol from the set.

Parameters:
s - Symbol to remove

remove

public void remove(SymbolSet s)

Removes a Set of Symbols from the instance.

Parameters:
s - SymbolSet of elements to be removed.

remove

public void remove()
Removes all Symbols from the instance.


symbolByName

public Symbol symbolByName(java.lang.String Name)
Returns a Symbol given by its Name, if contained in the instance.

Parameters:
Name - Name of Symbol.
Returns:
Symbol

randomSymbol

public Symbol randomSymbol()
Returns a randomly selected Symbol contained in the instance.

Returns:
Symbol randomly selected from the instance

debug_out

public void debug_out()
Method for debugging-purposes.


setDefault

public void setDefault(java.lang.String Name)
Method to define a Symbol as default-Symbol of the instance.

Parameters:
Name - Name of the Symbol to be set as default

setDefault

public void setDefault(Symbol s)
Method to define a Symbol as default-Symbol of the instance.

Parameters:
s - Symbol to be set as default

getDefault

public Symbol getDefault()
Returns the default-Symbol of the instance.

Returns:
Symbol which is default

getSize

public int getSize()
Returns the number of Symbols contained.

Returns:
Number of Symbols (as int)

asCollection

public java.util.Collection asCollection()
Returns a collection-view on the instance, giving access to further java standard methods.

Returns:
View implementing the collection-interface

iterator

public java.util.Iterator iterator()
Returns an iterator through alle elements contained.

Returns:
Iterator

powerSet

public java.util.ArrayList powerSet()
Generates an ArrayList of SymbolSets, representing the power set of the instance (ie. the set of all possible subsets of the set represented by the instance).

Returns:
ArrayList of SymbolSets representing the power set of the instance.