com.stata.sfi
Class SFIToolkit

java.lang.Object
  extended by com.stata.sfi.SFIToolkit

public final class SFIToolkit
extends Object

A set of core tools for interacting with Stata.


Field Summary
static int RC_GENERAL_ERROR
           
static int RC_GENERAL_EXCEPTION
           
static int RC_SYNTAX_ERROR
           
 
Method Summary
static void callGC()
          Call the Java garbage collector. Calling this method should generally be avoided.
static void display(String s)
          Output a string to the Stata Results window.
static void displayln(String s)
          Output a string to the Stata Results window and automatically add a line terminator at the end.
static void error(String s)
          Output a string to the Stata Results window as an error.
static boolean errorDebug(String s)
          Output a string to the Stata Results window as an error if set debug on is enabled.
static void errorln(String s)
          Output a string to the Stata Results window and automatically add a line terminator at the end.
static String formatValue(double val, String format)
          Format a value using a Stata format.
static double getCallerVersion()
          Get the version number of the calling program.
static String getTempFile()
          Get a valid Stata temporary file name.
static String getTempName()
          Get a valid Stata temporary name.
static String getWorkingDir()
          Get the current Stata working directory.
static boolean isValidName(String s)
          Check if a String is a valid Stata name.
static boolean isValidVariableName(String s)
          Check if a String is a valid Stata variable name.
static int pollnow()
          Request that Stata poll its GUI immediately.
static int pollstd()
          Request that Stata poll its GUI at the standard interval.
static String stackTraceToString(Exception e)
          Convert the stack trace from an Exception to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RC_GENERAL_EXCEPTION

public static final int RC_GENERAL_EXCEPTION
See Also:
Constant Field Values

RC_GENERAL_ERROR

public static final int RC_GENERAL_ERROR
See Also:
Constant Field Values

RC_SYNTAX_ERROR

public static final int RC_SYNTAX_ERROR
See Also:
Constant Field Values
Method Detail

display

public static void display(String s)
Output a string to the Stata Results window. Before the string is printed it is run through the Stata SMCL interpreter.

Parameters:
s - The string to output.

displayln

public static void displayln(String s)
Output a string to the Stata Results window and automatically add a line terminator at the end. Before the string is printed it is run through the Stata SMCL interpreter.

Parameters:
s - The string to output.

error

public static void error(String s)
Output a string to the Stata Results window as an error.

Parameters:
s - The string to output.

errorln

public static void errorln(String s)
Output a string to the Stata Results window and automatically add a line terminator at the end.

Parameters:
s - The string to output.

errorDebug

public static boolean errorDebug(String s)
Output a string to the Stata Results window as an error if set debug on is enabled.

Parameters:
s - The string to output.
Returns:
Returns true if set debug on is enabled.

pollstd

public static int pollstd()
Request that Stata poll its GUI at the standard interval. Use this method inside a time consuming task so that the Stata interface is responsive to user inputs.

Returns:
Returns 0 unless the Break key has been pressed.

pollnow

public static int pollnow()
Request that Stata poll its GUI immediately. Use this method inside a time consuming task so that the Stata interface is responsive to user inputs. Generally pollstd should be used instead.

Returns:
Returns 0 unless the Break key has been pressed.

getTempName

public static String getTempName()
Get a valid Stata temporary name.

Returns:
Returns the tempname.

getTempFile

public static String getTempFile()
Get a valid Stata temporary file name.

Returns:
Returns the filename including its path.

getWorkingDir

public static String getWorkingDir()
Get the current Stata working directory.

Returns:
Returns the path of the current working directory.

isValidName

public static boolean isValidName(String s)
Check if a String is a valid Stata name.

Parameters:
s - Name to test.
Returns:
Returns true if the String represents a valid Stata name.

isValidVariableName

public static boolean isValidVariableName(String s)
Check if a String is a valid Stata variable name.

Parameters:
s - Name to test.
Returns:
Returns true if the String represents a valid Stata variable name.

formatValue

public static String formatValue(double val,
                                 String format)
Format a value using a Stata format.

Parameters:
val - The value to format.
format - A valid Stata format.
Returns:
The formatted value in String form. If an error occurs, a null String will be returned.

getCallerVersion

public static double getCallerVersion()
Get the version number of the calling program. This function can be used to implement Stata version control.

Returns:
Returns the callers version number.

stackTraceToString

public static String stackTraceToString(Exception e)
Convert the stack trace from an Exception to a String.

Parameters:
e - Exception
Returns:
String representation of the stack trace.

callGC

public static void callGC()
Call the Java garbage collector. Calling this method should generally be avoided.