All Packages Class Hierarchy This Package Previous Next Index
Class nsjava.internal.TclObject
java.lang.Object
|
+----nsjava.internal.TclObject
- public final class TclObject
- extends Object
This class implements the basic notion of an "object" in Tcl. The
fundamental representation of an object is its string value. However,
an object can also have an internal representation, which is a "cached"
reprsentation of this object in another form. The type of the internal
rep of Tcl objects can mutate. This class provides the storage of the
string rep and the internal rep, as well as the facilities for mutating
the internal rep.
-
TclObject(InternalRep)
- Creates a TclObject with the given InternalRep.
-
getInternalRep()
- Returns the handle to the current internal rep.
-
invalidateStringRep()
- Sets the string representation of the object to null.
-
isShared()
- Returns true if the TclObject is shared, false otherwise.
-
preserve()
- Tcl_IncrRefCount -> preserve
Increments the refCount to indicate the caller's intent to
preserve the value of this object.
-
release()
- Tcl_DecrRefCount -> release
Decrements the refCount to indicate that the caller is no longer
interested in the value of this object.
-
setInternalRep(InternalRep)
- Change the internal rep of the object.
-
takeExclusive()
- Takes exclusive ownership of this object.
-
toString()
- Returns the string representation of the object.
TclObject
public TclObject(InternalRep rep)
- Creates a TclObject with the given InternalRep. This method should be
called only by an InternalRep implementation.
- Parameters:
- rep - the initial InternalRep for this object.
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 final 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 String toString()
- Returns the string representation of the object.
- Returns:
- the string representation of the object.
- Overrides:
- toString in class Object
invalidateStringRep
public final void invalidateStringRep() throws TclException
- 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: TclException
- if object is not exclusively owned.
isShared
public final boolean isShared()
- Returns true if the TclObject is shared, false otherwise.
- Returns:
- true if the TclObject is shared, false otherwise.
takeExclusive
public final TclObject takeExclusive() throws TclException
- Takes exclusive ownership of this object. This method should be
called before invoking any method that will modify the value of
the object. E.g.
tobj = tobj.takeExclusive();
TclString.append(tobj, "hello");
The result of this method depends on the refCount of the object:
refCount == 1: the object itself is returned.
refCount > 1: a copy of the object will be returned. The refCount
of the copy is set to 1.
refCount < 1: TclRuntimeError will be thrown.
- Returns:
- an TclObject with a refCount of 1.
- Throws: TclException
- if the refCount <= 0
preserve
public final void preserve() throws TclException
- Tcl_IncrRefCount -> preserve
Increments the refCount to indicate the caller's intent to
preserve the value of this object. Each preserve() call must be matched
by a corresponding release() call.
- Throws: TclException
- if the object has already been deallocated.
release
public final void release()
- Tcl_DecrRefCount -> release
Decrements the refCount to indicate that the caller is no longer
interested in the value of this object. If the refCount reaches 0,
the obejct will be deallocated.
All Packages Class Hierarchy This Package Previous Next Index