tcl.lang
Class TclInteger

java.lang.Object
  extended by tcl.lang.TclInteger
All Implemented Interfaces:
InternalRep

public class TclInteger
extends Object
implements InternalRep

This class implements the integer object type in Tcl.


Method Summary
 void dispose()
          Implement this no-op for the InternalRep interface.
 InternalRep duplicate()
          Should never be invoked.
static int get(Interp interp, TclObject tobj)
          Deprecated. 
static int getInt(Interp interp, TclObject tobj)
          Tcl_GetIntFromObj -> TclInteger.getValue Returns the integer value of the object as a Java int.
static long getLong(Interp interp, TclObject tobj)
          Tcl_GetIntFromObj -> TclInteger.getValue Returns the integer value of the object as a Java long.
static void incr(Interp interp, TclObject tobj, long incrAmount)
          Increments the integer value of the object by the given amount.
static boolean isWithinIntRange(Interp interp, TclObject tobj)
          Tests whether TclInteger.getInt() will return a valid Java int value
static boolean isWithinLongRange(Interp interp, TclObject tobj)
          Tests whether TclInteger.getLong() will return a valid Java long value
static TclObject newInstance(long i)
          Tcl_NewIntObj -> TclInteger.newInstance Creates a new instance of a TclObject with a TclInteger internal representation.
static void set(TclObject tobj, long i)
          Changes the integer value of the object.
 String toString()
          Should never be invoked.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

duplicate

public InternalRep duplicate()
Should never be invoked.

Specified by:
duplicate in interface InternalRep

dispose

public void dispose()
Implement this no-op for the InternalRep interface.

Specified by:
dispose in interface InternalRep

toString

public String toString()
Should never be invoked.

Overrides:
toString in class Object

newInstance

public static TclObject newInstance(long i)
Tcl_NewIntObj -> TclInteger.newInstance Creates a new instance of a TclObject with a TclInteger internal representation.

Parameters:
i - initial value of the integer object.
Returns:
the TclObject with the given integer value.

get

@Deprecated
public static int get(Interp interp,
                                 TclObject tobj)
               throws TclException
Deprecated. 

Tcl_GetIntFromObj -> TclInteger.get Returns the integer value of the object as a Java int. This method is @deprecated, because the internal representation is now long. Use getLong() or getInt() instead.

Parameters:
interp - current interpreter.
tobj - the object to operate on.
Returns:
the integer value of the object. Use getLong() to return a Java long, or getInt() to return int.
Throws:
TclException

getLong

public static long getLong(Interp interp,
                           TclObject tobj)
                    throws TclException
Tcl_GetIntFromObj -> TclInteger.getValue Returns the integer value of the object as a Java long.

Parameters:
interp - current interpreter.
tobj - the object to operate on.
Returns:
the integer value of the object.
Throws:
TclException

getInt

public static int getInt(Interp interp,
                         TclObject tobj)
                  throws TclException
Tcl_GetIntFromObj -> TclInteger.getValue Returns the integer value of the object as a Java int.

Parameters:
interp - current interpreter.
tobj - the object to operate on.
Returns:
the integer value of the object as a Java int
Throws:
TclException - if value will exceed limits of a Java int

isWithinLongRange

public static boolean isWithinLongRange(Interp interp,
                                        TclObject tobj)
Tests whether TclInteger.getLong() will return a valid Java long value

Parameters:
interp - current interpreter, may be null
tobj - The TclObject to be tested
Returns:
true if getLong() will return a long. false if object cannot be converted to a TclInteger, or if it is out of range for a long.

isWithinIntRange

public static boolean isWithinIntRange(Interp interp,
                                       TclObject tobj)
Tests whether TclInteger.getInt() will return a valid Java int value

Parameters:
interp - current interpreturn, may be null
tobj - The TclObject to be tested
Returns:
true if getInt() will return an int; false if object cannot be converted to a TclInteger or if it is out of range for an int

set

public static void set(TclObject tobj,
                       long i)
Changes the integer value of the object.

Parameters:
tobj - the object to operate on.
i - the new integer value.

incr

public static void incr(Interp interp,
                        TclObject tobj,
                        long incrAmount)
                 throws TclException
Increments the integer value of the object by the given amount. One could implement this same operation by calling get() and then set(), this method provides an optimized implementation. This method is not public since it will only be invoked by the incr command.

Parameters:
interp - current interpreter.
tobj - the object to operate on.
incrAmount - amount to increment
Throws:
TclException


Copyright © 2015. All rights reserved.