sisc.util
Class InternedValue

java.lang.Object
  extended by sisc.util.InternedValue
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class InternedValue
extends java.lang.Object
implements java.io.Externalizable

This class serves two purposes. Firstly, it contains static members that maintain a bijective map between symbols and values. Secondly, instances of this class are used in Java serialisation as wrappers for interned values. Since the bijective map is static it is shared between app contexts and hence interned values can leak between apps. This is an unavoidable consequence of wanting to fit in with standard Java serialisation in, e.g., J2EE containers, which may happen in threads with no associated app context. In practice this shouldn't cause much of a problem. Firstly, many J2EE containers have separate class loaders for separate web apps etc. Secondly, the main purpose of interned values is to store globally unique types, for which there is little harm in sharing between apps. Access to the bijective map is thread-safe. The map is *not* weak - symbols and values of map entries will not be garbage collected. It would be desirable for map entries to be removed when they are no longer referenced. However, it is impossible to do so reliably, so the current set up is the only safe solution.

See Also:
Serialized Form

Constructor Summary
InternedValue()
           
 
Method Summary
static Value deserResolve(Symbol name, java.lang.Class clazz)
           
 Symbol getName()
           
 Value getValue()
           
static InternedValue intern(Symbol name, Value value)
           
static InternedValue lookupByName(Symbol name)
           
static InternedValue lookupByValue(Value value)
           
 void readExternal(java.io.ObjectInput in)
           
 java.lang.Object readResolve()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InternedValue

public InternedValue()
Method Detail

getName

public Symbol getName()

getValue

public Value getValue()

lookupByName

public static InternedValue lookupByName(Symbol name)

lookupByValue

public static InternedValue lookupByValue(Value value)

intern

public static InternedValue intern(Symbol name,
                                   Value value)

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

deserResolve

public static Value deserResolve(Symbol name,
                                 java.lang.Class clazz)
                          throws java.io.IOException
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readResolve

public java.lang.Object readResolve()
                             throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException