QJCC homepage

biz.chitec.quarterback.gjsa
Class ChatSymbolHolder

java.lang.Object
  extended bybiz.chitec.quarterback.gjsa.ChatSymbolHolder
Direct Known Subclasses:
BasicReplySymbols, BasicRequestSymbols, BasicStateSymbols, ConnectionEncoding, DynamicChatSymbolHolder, EncryptionRulesSymbols, EncryptionStrategySymbols, GChatReplySymbols, GChatRequestSymbols, IntChatSymbolHolder, LocaleFlagTypes

public abstract class ChatSymbolHolder
extends java.lang.Object

Symbol holder class. For speed reasons, chat symbols should be represented as integer numbers in a program. For convenience and error preventing reasons, chat symbols should be represented as strings in a programm. To allow both representation schemes, ChatSymbolHolder objects can be used to hold the objects as constant values (allowing switch-case-constructs in the program) and access them also in string form.

Normally, a real chat symbol holder is built on top of this small abstract class through the SymbolToJava programm, which acts as a kind of preprocessor.

Version:
$Id: 00313982112a71d051e3d024107eeb2f93939105 $
Author:
Dirk Hillbrecht 1997-1999, chitec/Dirk Hillbrecht 2000. Distributed under the terms of the GNU LGPL.
See Also:
biz.chitec.qapp.symboltojava.SymbolToJava

Constructor Summary
ChatSymbolHolder()
           
 
Method Summary
 int anyToNumeric(java.lang.Object x)
          Returns the integer representation of the symbol which has been referenced by any means.
 boolean equals(java.lang.Object o)
          Checks equality based on the classes only.
 int[] getAllSymbols()
          Return an array with all numeric symbol values.
 QuickIntArray getAllSymbolsQIA()
          Returns a QuickIntArray with all numeric symbol values.
abstract  java.lang.String getSymbolSetName()
          Return the name of the symbol set.
abstract  int[] getSymbolSetVersion()
          Version of the symbol set in version-subversion-patchlevel type.
 java.util.List getSymbolSetVersionV()
          Return the version number as a list.
abstract  java.lang.String numericToSymbol(int numeric)
          Return the string-based representation of the symbol.
abstract  int symbolToNumeric(java.lang.String symbol)
          Return the numeric equivalent to a symbol given as String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChatSymbolHolder

public ChatSymbolHolder()
Method Detail

symbolToNumeric

public abstract int symbolToNumeric(java.lang.String symbol)
Return the numeric equivalent to a symbol given as String. Usually, this method is implemented in the subclasses by a preprocessor.

Parameters:
symbol - Value of the symbol as String
Returns:
The symbol's integer value.

numericToSymbol

public abstract java.lang.String numericToSymbol(int numeric)
Return the string-based representation of the symbol. Usually, this method is implemented in the subclasses by a preprocessor.

Parameters:
numeric - The symbol's integer value.
Returns:
Value of the symbol as String.

getSymbolSetName

public abstract java.lang.String getSymbolSetName()
Return the name of the symbol set. Usually, this method is implemented in the subclasses by a preprocessor.

Returns:
Arbitrary name of the symbol set.

getSymbolSetVersion

public abstract int[] getSymbolSetVersion()
Version of the symbol set in version-subversion-patchlevel type. Usually, this method is implemented in the subclasses by a preprocessor.

Returns:
int-array with three elements being version (index 0), subversion (index 1) and patchlevel (index 2) of the symbol set.

getSymbolSetVersionV

public java.util.List getSymbolSetVersionV()
Return the version number as a list.

Returns:
Version number as a list.

anyToNumeric

public int anyToNumeric(java.lang.Object x)
Returns the integer representation of the symbol which has been referenced by any means. If the given referencing object is a Number, its intValue() is returned. It is not checked whether a symbol of this number really exists. In any other case, the toString() result of the given Object is passed through symbolToNumeric().

Parameters:
x - An object somehow representing a symbol.
Returns:
The numeric representation of the symbol.

equals

public boolean equals(java.lang.Object o)
Checks equality based on the classes only. Due to the preprocessor-based design of the ChatSymbolHolders, a true singleton scheme cannot be realized. However, multiple instances of the same ChatSymbolHolder class do not differ at all. Therefore, equals() only checks for the class of the given object and compares it to its own.

Returns:
true if classes are the same, false otherwise

getAllSymbols

public int[] getAllSymbols()
Return an array with all numeric symbol values. Usually, this method is implemented in the subclasses by a preprocessor. It can be left out, however. In this case, an UnsupportedOperationException is thrown.

Returns:
Array with all defined symbols.
Throws:
java.lang.UnsupportedOperationException - If the method has not been defined in the subclass.

getAllSymbolsQIA

public QuickIntArray getAllSymbolsQIA()
Returns a QuickIntArray with all numeric symbol values. This method depends on getAllSymbols() and can therefor also throw an UnsupportedOperationException.

Returns:
QuickIntArray with all defined symbols.
Throws:
java.lang.UnsupportedOperationException - If getAllSymbols() has not been defined in the subclass.

QJCC homepage