tcl.lang
Class Util

java.lang.Object
  extended by tcl.lang.Util

public class Util
extends Object


Method Summary
static void appendElement(Interp interp, StringBuffer sbuf, String s)
          appendElement -- Append a string to the string buffer.
static TclObject concat(int from, int to, TclObject[] objv)
          Tcl_ConcatObj -> concat Concatenate the strings from a set of objects into a single string object with spaces between the original strings.
static boolean getBoolean(Interp interp, String string)
          getBoolean -- Given a string, return a boolean value corresponding to the string.
static long getInt(Interp interp, String s)
          Converts an ASCII string to an integer.
static int getIntForIndex(Interp interp, TclObject tobj, int endValue)
          TclGetIntForIndex -> Util.getIntForIndex This procedure returns an integer corresponding to the list index held in a Tcl object.
static boolean isMac()
          isMac -- Returns true if running on a Mac platform.
static boolean isUnix()
          isUnix -- Returns true if running on a Unix platform.
static boolean isWindows()
          isWindows -- Returns true if running on a Windows platform.
static boolean regExpMatch(Interp interp, String string, TclObject pattern)
          regExpMatch -- See if a string matches a regular expression.
static boolean stringMatch(String str, String pat)
          stringMatch -- See if a particular string matches a particular pattern.
static void strtod(String s, int start, int len, StrtodResult strtodResult)
          strtod -- Converts the leading decimal digits of a string into double and report the index of the character immediately following the digits.
static void strtoul(String s, int start, int base, StrtoulResult strtoulResult)
          Implements functionality of the strtoul() function used in the C Tcl library.
static String toTitle(String str)
          Tcl_UtfToTitle -> toTitle -- Changes the first character of a string to title case or uppercase and the rest of the string to lowercase.
static String TrimLeft(String str)
          TrimLeft -- Trims whitespace on the left side of a strin.g Results: The trimmed string.
static String TrimLeft(String str, String pattern)
          TrimLeft -- Trim characters in "pattern" off the left of a string If pattern isn't supplied, whitespace is trimmed Results: |>None.<| Side effects: |>None.<|
static String TrimRight(String str)
           
static String TrimRight(String str, String pattern)
          TrimRight -- Trim characters in "pattern" off the right of a string If pattern isn't supplied, whitespace is trimmed Results: |>None.<|
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

strtoul

public static void strtoul(String s,
                           int start,
                           int base,
                           StrtoulResult strtoulResult)
Implements functionality of the strtoul() function used in the C Tcl library. This method will parse digits from what should be a 64-bit (signed) integer and report the index of the character immediately following the digits. E.g.: "0x7fffffff" -> 2147483647 "0x80000000" -> -2147483648 "-0xFF" -> -255 This method behaves like the strtoul() function in NativeTcl. This method will return a signed 64-bit Java long type in the strtoulResult argument. This value is used as a signed integer in the expr module. A leading signed character like '+' or '-' is supported. Leading spaces are skipped. Results: The strtoulResult argument will be populated with the parsed value and the index of the character following the digits. If an error is detected, then the strtoulResult errno value will be set accordingly. Side effects: None.

Parameters:
s - String of ASCII digits, possibly preceded by white space. For bases greater than 10, either lower- or upper-case digits may be used.
start - The index of s where the number starts.
base - Base for conversion. Must be less than 37. If 0, then the base is chosen from the leading characters of string: "0x" means hex, "0" means octal, anything else means decimal.
strtoulResult - Location to store results

getInt

public static long getInt(Interp interp,
                          String s)
                   throws TclException
Converts an ASCII string to an integer. Results: The integer value of the string. Side effects: None.

Parameters:
interp - The current interpreter. Can be null
s - The string to convert from. Must be in valid Tcl integer format.
Returns:
integer value
Throws:
TclException

getIntForIndex

public static final int getIntForIndex(Interp interp,
                                       TclObject tobj,
                                       int endValue)
                                throws TclException
TclGetIntForIndex -> Util.getIntForIndex This procedure returns an integer corresponding to the list index held in a Tcl object. The Tcl object's value is expected to be either an integer or a string of the form "end([+-]integer)?". Results: The return value is the index that is found from the string. If the Tcl object referenced by tobj has the value "end", the value stored is endValue. If tobj's value is not of the form "end([+-]integer)?" and it can not be converted to an integer, an exception is raised. Side effects: The object referenced by tobj might be converted to an integer object.

Parameters:
interp - interp, can be null
tobj - the index object, an integer, "end", or "end-n"
endValue - the index value to use as "end"
Throws:
TclException

strtod

public static void strtod(String s,
                          int start,
                          int len,
                          StrtodResult strtodResult)
strtod -- Converts the leading decimal digits of a string into double and report the index of the character immediately following the digits. Results: Converts the leading decimal digits of a string into double and report the index of the character immediately following the digits. Side effects: None.

Parameters:
s - String of ASCII digits, possibly preceded by white space. For bases greater than 10, either lower- or upper-case digits may be used.
start - The index of the string to start on.
len - The string length, or -1
strtodResult - place to store results

concat

public static TclObject concat(int from,
                               int to,
                               TclObject[] objv)
                        throws TclException
Tcl_ConcatObj -> concat Concatenate the strings from a set of objects into a single string object with spaces between the original strings. Results: The return value is a new string object containing a concatenation of the strings in objv. Its ref count is zero. Side effects: None.

Parameters:
from - The starting index.
to - The ending index (inclusive).
objv - Array of objects to concatenate.
Returns:
new String object
Throws:
TclException

stringMatch

public static final boolean stringMatch(String str,
                                        String pat)
stringMatch -- See if a particular string matches a particular pattern. The matching operation permits the following special characters in the pattern: *?\[] (see the manual entry for details on what these mean). Results: True if the string matches with the pattern. Side effects: None.

Parameters:
str - String to compare pattern against
pat - Pattern which may contain special characters.
Returns:
true if string matches within the pattern

toTitle

public static String toTitle(String str)
Tcl_UtfToTitle -> toTitle -- Changes the first character of a string to title case or uppercase and the rest of the string to lowercase. Results: Returns the generated string. Side effects: None.

Parameters:
str - String to convert.
Returns:
new string

regExpMatch

public static final boolean regExpMatch(Interp interp,
                                        String string,
                                        TclObject pattern)
                                 throws TclException
regExpMatch -- See if a string matches a regular expression. Results: Returns a boolean whose value depends on whether a match was made. Side effects: None.

Parameters:
interp - Current interpreter
string - The string to match.
pattern - The regular expression.
Returns:
true if matched
Throws:
TclException

appendElement

public static final void appendElement(Interp interp,
                                       StringBuffer sbuf,
                                       String s)
                                throws TclException
appendElement -- Append a string to the string buffer. If the string buffer is not empty, append a space before appending "s". Results: None. Side effects: The value of "sbuf" is changesd.

Parameters:
interp - Current interpreter.
sbuf - The buffer to append to.
s - The string to append.
Throws:
TclException

TrimLeft

public static String TrimLeft(String str,
                              String pattern)
TrimLeft -- Trim characters in "pattern" off the left of a string If pattern isn't supplied, whitespace is trimmed Results: |>None.<| Side effects: |>None.<|

Parameters:
str - The string to trim
pattern - The pattern string used to trim.
Returns:
string

TrimLeft

public static String TrimLeft(String str)
TrimLeft -- Trims whitespace on the left side of a strin.g Results: The trimmed string.

Parameters:
str - The string to trim.
Returns:
The trimmed string.

TrimRight

public static String TrimRight(String str,
                               String pattern)
TrimRight -- Trim characters in "pattern" off the right of a string If pattern isn't supplied, whitespace is trimmed Results: |>None.<|

Parameters:
str - The string to trim.
pattern - The pattern to trim.
Returns:
The trimmed string.

TrimRight

public static String TrimRight(String str)

getBoolean

public static boolean getBoolean(Interp interp,
                                 String string)
                          throws TclException
getBoolean -- Given a string, return a boolean value corresponding to the string. Results: Side effects: None.

Parameters:
interp - The current interpreter.
string - The string representation of the boolean.
Returns:
boolean value of string
Throws:
TclException - For malformed boolean values.

isUnix

public static final boolean isUnix()
isUnix -- Returns true if running on a Unix platform. Results: Returns a boolean. Side effects: None.

Returns:
true if Unix

isMac

public static final boolean isMac()
isMac -- Returns true if running on a Mac platform. Note that this method returns false for Mac OSX. Results: Returns a boolean. Side effects: None.

Returns:
true if Mac

isWindows

public static final boolean isWindows()
isWindows -- Returns true if running on a Windows platform. Results: Returns a boolean. Side effects: None.

Returns:
true if Windows


Copyright © 2013. All Rights Reserved.