tcl.lang
Class TclObject

java.lang.Object
  extended by tcl.lang.TclObject

public final class TclObject
extends java.lang.Object


Field Summary
protected static java.lang.RuntimeException DEALLOCATED
          Raise a TclRuntimeError in the case where a TclObject was already disposed of because the last ref was released.
protected  InternalRep internalRep
           
protected  int refCount
           
protected  java.lang.String stringRep
           
 
Constructor Summary
protected TclObject(int ivalue)
           
  TclObject(InternalRep rep)
           
protected TclObject(TclString rep, java.lang.String s)
           
 
Method Summary
protected  void disposedError()
           
protected  void disposeObject()
          Dispose of the TclObject when the refCount reaches 0.
 TclObject duplicate()
          Tcl_DuplicateObj -> duplicate Duplicate a TclObject, this method provides the preferred means to deal with modification of a shared TclObject.
 InternalRep getInternalRep()
          Returns the handle to the current internal rep.
 void invalidateStringRep()
          Sets the string representation of the object to null.
 boolean isDoubleType()
           
 boolean isIntType()
           
 boolean isShared()
          Returns true if the TclObject is shared, false otherwise.
 void preserve()
           
 void release()
           
 void setInternalRep(InternalRep rep)
          Change the internal rep of the object.
 TclObject takeExclusive()
          Deprecated. The takeExclusive method has been deprecated in favor of the new duplicate() method. The takeExclusive method would modify the ref count of the original object and return an object with a ref count of 1 instead of 0. These two behaviors lead to lots of useless duplication of objects that could be modified directly. This method exists only for backwards compatibility and will be removed at some point.
 java.lang.String toString()
          Returns the string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

internalRep

protected InternalRep internalRep

refCount

protected int refCount

stringRep

protected java.lang.String stringRep

DEALLOCATED

protected static final java.lang.RuntimeException DEALLOCATED
Raise a TclRuntimeError in the case where a TclObject was already disposed of because the last ref was released.

Constructor Detail

TclObject

public TclObject(InternalRep rep)

TclObject

protected TclObject(TclString rep,
                    java.lang.String s)

TclObject

protected TclObject(int ivalue)
Method Detail

preserve

public final void preserve()

release

public final void release()

isIntType

public final boolean isIntType()

isDoubleType

public final boolean isDoubleType()

getInternalRep

public final InternalRep getInternalRep()
Returns the handle to the current internal rep. This method should be called only by an InternalRep implementation.

Returns:
the handle to the current internal rep.

setInternalRep

public void setInternalRep(InternalRep rep)
Change the internal rep of the object. The old internal rep will be deallocated as a result. This method should be called only by an InternalRep implementation.

Parameters:
rep - the new internal rep.

toString

public final java.lang.String toString()
Returns the string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of the object.

invalidateStringRep

public final void invalidateStringRep()
                               throws TclRuntimeError
Sets the string representation of the object to null. Next time when toString() is called, getInternalRep().toString() will be called. This method should be called ONLY when an InternalRep is about to modify the value of a TclObject.

Throws:
TclRuntimeError - if object is not exclusively owned.

isShared

public final boolean isShared()
Returns true if the TclObject is shared, false otherwise.


duplicate

public final TclObject duplicate()
Tcl_DuplicateObj -> duplicate Duplicate a TclObject, this method provides the preferred means to deal with modification of a shared TclObject. It should be invoked in conjunction with isShared instead of using the deprecated takeExclusive method. Example: if (tobj.isShared()) { tobj = tobj.duplicate(); } TclString.append(tobj, "hello");

Returns:
an TclObject with a refCount of 0.

takeExclusive

public final TclObject takeExclusive()
                              throws TclRuntimeError
Deprecated. The takeExclusive method has been deprecated in favor of the new duplicate() method. The takeExclusive method would modify the ref count of the original object and return an object with a ref count of 1 instead of 0. These two behaviors lead to lots of useless duplication of objects that could be modified directly. This method exists only for backwards compatibility and will be removed at some point.

Throws:
TclRuntimeError

disposeObject

protected final void disposeObject()
Dispose of the TclObject when the refCount reaches 0.

Throws:
TclRuntimeError - if the object has already been deallocated.

disposedError

protected final void disposedError()