oscript.data
Class Symbol

java.lang.Object
  extended byoscript.data.Value
      extended byoscript.data.OObject
          extended byoscript.data.OString
              extended byoscript.data.Symbol
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class Symbol
extends OString
implements java.io.Externalizable

The Symbol is a type used internally by the scripting engine to represent identifiers, ie. variable or function names. Each symbol has a unique integer id. Furthermore, the mapping between symbols and ids is preserved in /cache so any cache entries (ie. compiled code, etc.) can assume that the same mapping between symbol and id exists as when it was created. (In other words, compiled code can discard the symbol object, and put the symbol's id in it's constant table.)

Version:
1.56
Author:
Rob Clark (rob@ti.com)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class oscript.data.OString
MEMBER_NAMES, PARENT_TYPE_NAME, TYPE, TYPE_NAME
 
Fields inherited from class oscript.data.OObject
EMPTY_EXPR_LIST_EVALUATOR
 
Fields inherited from class oscript.data.Value
DEBUG, NULL, UNDEFINED
 
Constructor Summary
Symbol()
           
 
Method Summary
 int getId()
          Get the unique id for this symbol.
static Symbol getSymbol(int id)
          Given a symbol id, return the symbol object.
static Symbol getSymbol(java.lang.String str)
          Given a string, return a symbol object.
static Symbol getSymbol(Value val)
          Given a script object, return a symbol object.
 void readExternal(java.io.ObjectInput in)
          Derived class that implements Externalizable must call this if it overrides it.
 void writeExternal(java.io.ObjectOutput out)
          Derived class that implements Externalizable must call this if it overrides it.
 
Methods inherited from class oscript.data.OString
_bopCast, bopEquals, bopEqualsR, bopGreaterThan, bopGreaterThanOrEquals, bopGreaterThanOrEqualsR, bopGreaterThanR, bopLessThan, bopLessThanOrEquals, bopLessThanOrEqualsR, bopLessThanR, bopNotEquals, bopNotEqualsR, bopPlus, bopPlusR, castToBoolean, castToExactNumber, castToInexactNumber, castToJavaObject, castToString, chop, elementAt, elementsAt, endsWith, equals, getTypeImpl, hashCode, indexOf, indexOf, intern, lastIndexOf, lastIndexOf, length, makeString, match, replace, search, startsWith, substring, substring, toLowerCase, toUpperCase, trim, value
 
Methods inherited from class oscript.data.OObject
getMember, populateMemberSet
 
Methods inherited from class oscript.data.Value
_getTypeMember, _populateTypeMemberSet, bopBitwiseAnd, bopBitwiseAndR, bopBitwiseOr, bopBitwiseOrR, bopBitwiseXor, bopBitwiseXorR, bopCast, bopCastR, bopDivide, bopDivideR, bopInstanceOf, bopInstanceOfR, bopLeftShift, bopLeftShiftR, bopLogicalAnd, bopLogicalAndR, bopLogicalOr, bopLogicalOrR, bopMinus, bopMinusR, bopMultiply, bopMultiplyR, bopRemainder, bopRemainderR, bopSignedRightShift, bopSignedRightShiftR, bopUnsignedRightShift, bopUnsignedRightShiftR, callAsConstructor, callAsConstructor, callAsConstructor, callAsExtends, callAsExtends, callAsExtends, callAsFunction, callAsFunction, callAsFunction, getMember, getMember, getMember, getMember, getMember, getMonitor, getType, getTypeMember, getTypeMember, isA, memberSet, noSuchMember, opAssign, populateTypeMemberSet, toString, unhand, uopBitwiseNot, uopDecrement, uopIncrement, uopLogicalNot, uopMinus, uopPlus
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Symbol

public Symbol()
Method Detail

getId

public int getId()
Get the unique id for this symbol. If two symbols are equal (in terms of OString.bopEquals(oscript.data.Value)), then they will map to the same id, and likewise the id will always map to symbols that are equal.

Returns:
the integer id

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException
Derived class that implements Externalizable must call this if it overrides it. It should override it to save/restore it's own state.

Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class OString
Throws:
java.io.IOException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Derived class that implements Externalizable must call this if it overrides it. It should override it to save/restore it's own state.

Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class OString
Throws:
java.io.IOException

getSymbol

public static Symbol getSymbol(Value val)
Given a script object, return a symbol object. If two objects have the same string representation (OString.castToString()) then they will always map to the same symbol.


getSymbol

public static Symbol getSymbol(java.lang.String str)
Given a string, return a symbol object. If two strings are equals() then they will always map to the same symbol.


getSymbol

public static Symbol getSymbol(int id)
Given a symbol id, return the symbol object. The same integer id will always map to the same symbol. If a symbol with the specified id does not exist, this will return null.