Package com.stata.sfi
Class SFIToolkit
java.lang.Object
com.stata.sfi.SFIToolkit
This class provides a set of core tools for interacting with Stata.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final int
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidcallGC()Call the Java garbage collector. Calling this method should generally be avoided.static voidDisplay an object in the Stata Results window.static voidDisplay an object in the Stata Results window.static voiddisplay(Object o, DisplayMode mode) Display an object in the Stata Results window.static voiddisplay(Object o, DisplayMode mode, boolean asis) Display an object in the Stata Results window.static voidDisplay a string in the Stata Results window.static voidDisplay a string in the Stata Results window.static voiddisplay(String s, DisplayMode mode) Display a string in the Stata Results window.static voiddisplay(String s, DisplayMode mode, boolean asis) Display a string in the Stata Results window.static voidSend a line separator to the output.static voidDisplay an object in the Stata Results window and automatically add a line separator at the end.static voidDisplay an object in the Stata Results window and automatically add a line separator at the end.static voiddisplayln(Object o, DisplayMode mode) Display an object in the Stata Results window and automatically add a line separator at the end.static voiddisplayln(Object o, DisplayMode mode, boolean asis) Display an object in the Stata Results window and automatically add a line separator at the end.static voidDisplay a string in the Stata Results window and automatically add a line separator at the end.static voiddisplayln(String s, DisplayMode mode) Display a string in the Stata Results window and automatically add a line separator at the end.static voiddisplayln(String s, DisplayMode mode, boolean asis) Display a string in the Stata Results window and automatically add a line separator at the end.static voidDisplay an object in the Stata Results window as an error.static voidDisplay an object in the Stata Results window as an error.static voidDisplay a string in the Stata Results window as an error.static voidDisplay a string in the Stata Results window as an error.static booleanerrorDebug(String s) Display a string in the Stata Results window as an error if set debug on is enabled.static booleanerrorDebug(String s, boolean asis) Display a string in the Stata Results window as an error if set debug on is enabled.static booleanDisplay the stack trace as an error if set debug on is enabled.static voidDisplay an object in the Stata Results window as an error and automatically add a line separator at the end.static voidDisplay a string in the Stata Results window as an error and automatically add a line separator at the end.static interrorMsg(int rc) Display the standard Stata error message associated with return code rc in the Stata Results window.static intexecuteCommand(String command, boolean echo) Execute a Stata command.static StringformatValue(double val, String format) Format a value using a Stata format.static StringGet the User-Agent that Stata uses for web requests.static doubleGet the version number of the calling program.static StringGet a valid Stata temporary filename.static StringGet a valid Stata temporary name.static StringGet the current Stata working directory.static booleanCheck if aStringis a valid Stata name.static booleanCheck if aStringis a valid Stata variable name.static voidApply Stata's proxy settings to Java.static intpollnow()Request that Stata poll its GUI immediately.static intpollstd()Request that Stata poll its GUI at the standard interval.static StringprocessTildePath(String path) Stata utility to convert a path beginning with a tilde to a user's home directory.static FileresolvePath(String path) Resolve a path to aFile; the path may be relative to Stata's current working directory, begin with a tilde, or be an absolute path.static voidsetRC(int rc) Set the Stata return code when used with Java integration (that is, java[:] blocks).static Stringstatic String
- 
Field Details- 
RC_BREAKpublic static final int RC_BREAK- See Also:
 
- 
RC_GENERAL_ERRORpublic static final int RC_GENERAL_ERROR- See Also:
 
- 
RC_GENERAL_EXCEPTIONpublic static final int RC_GENERAL_EXCEPTION- See Also:
 
- 
RC_SYNTAX_ERRORpublic static final int RC_SYNTAX_ERROR- See Also:
 
 
- 
- 
Method Details- 
callGCCall the Java garbage collector. Calling this method should generally be avoided.
- 
displayDisplay an object in the Stata Results window. Before the string is printed, it is run through the Stata SMCL interpreter.- Parameters:
- o- The object to display.
 
- 
displayDisplay an object in the Stata Results window.- Parameters:
- o- The object to display.
- asis- When true, the string is printed without using the Stata SMCL interpreter.
 
- 
displayDisplay an object in the Stata Results window.- Parameters:
- o- The object to display.
- mode- The- DisplayMode.
 
- 
displayDisplay an object in the Stata Results window.- Parameters:
- o- The object to display.
- mode- The- DisplayMode.
- asis- When true, the string is printed without using the Stata SMCL interpreter.
 
- 
displayDisplay a string in the Stata Results window. Before the string is printed, it is run through the Stata SMCL interpreter.- Parameters:
- s- The string to display.
 
- 
displayDisplay a string in the Stata Results window.- Parameters:
- s- The string to display.
- asis- When true, the string is printed without using the Stata SMCL interpreter.
 
- 
displayDisplay a string in the Stata Results window.- Parameters:
- s- The string to display.
- mode- The- DisplayMode.
 
- 
displayDisplay a string in the Stata Results window.- Parameters:
- s- The string to display.
- mode- The- DisplayMode.
- asis- When true, the string is printed without using the Stata SMCL interpreter.
 
- 
displaylnSend a line separator to the output.
- 
displaylnDisplay an object in the Stata Results window and automatically add a line separator at the end. Before the string is printed, it is run through the Stata SMCL interpreter.- Parameters:
- o- The object to display.
 
- 
displaylnDisplay an object in the Stata Results window and automatically add a line separator at the end.- Parameters:
- o- The object to display.
- asis- When true, the string is printed without using the Stata SMCL interpreter.
 
- 
displaylnDisplay an object in the Stata Results window and automatically add a line separator at the end. Before the string is printed, it is run through the Stata SMCL interpreter.- Parameters:
- o- The object to display.
- mode- The- DisplayMode.
 
- 
displaylnDisplay an object in the Stata Results window and automatically add a line separator at the end.- Parameters:
- o- The object to display.
- mode- The- DisplayMode.
- asis- When true, the string is printed without using the Stata SMCL interpreter.
 
- 
displaylnDisplay a string in the Stata Results window and automatically add a line separator at the end. Before the string is printed, it is run through the Stata SMCL interpreter.- Parameters:
- s- The string to display.
 
- 
displaylnDisplay a string in the Stata Results window and automatically add a line separator at the end.- Parameters:
- s- The string to display.
- mode- The- DisplayMode.
 
- 
displaylnDisplay a string in the Stata Results window and automatically add a line separator at the end.- Parameters:
- s- The string to display.
- mode- The- DisplayMode.
- asis- When true, the string is printed without using the Stata SMCL interpreter.
 
- 
errorDisplay an object in the Stata Results window as an error. Before the string is printed, it is run through the Stata SMCL interpreter.- Parameters:
- o- The object to display.
 
- 
errorDisplay an object in the Stata Results window as an error.- Parameters:
- o- The object to display.
- asis- When true, the string is printed without using the Stata SMCL interpreter.
 
- 
errorDisplay a string in the Stata Results window as an error. Before the string is printed, it is run through the Stata SMCL interpreter.- Parameters:
- s- The string to display.
 
- 
errorDisplay a string in the Stata Results window as an error.- Parameters:
- s- The string to display.
- asis- When true, the string is printed without using the Stata SMCL interpreter.
 
- 
errorDebugDisplay a string in the Stata Results window as an error if set debug on is enabled. The string will not be run through the Stata SMCL interpreter.- Parameters:
- s- The string to display.
- Returns:
- True if set debug on is enabled.
 
- 
errorDebugDisplay a string in the Stata Results window as an error if set debug on is enabled.- Parameters:
- s- The string to display.
- asis- When true, the string is printed without using the Stata SMCL interpreter.
- Returns:
- True if set debug on is enabled.
 
- 
errorDebugDisplay the stack trace as an error if set debug on is enabled.- Parameters:
- t- The throwable containing the stack trace to display.
- Returns:
- True if set debug on is enabled.
 
- 
errorlnDisplay an object in the Stata Results window as an error and automatically add a line separator at the end. Before the string is printed, it is run through the Stata SMCL interpreter.- Parameters:
- o- The object to display.
 
- 
errorlnDisplay a string in the Stata Results window as an error and automatically add a line separator at the end. Before the string is printed, it is run through the Stata SMCL interpreter.- Parameters:
- s- The string to display.
 
- 
errorMsgDisplay the standard Stata error message associated with return code rc in the Stata Results window.- Parameters:
- rc- The return code for the error.
- Returns:
- The return code for the error.
 
- 
executeCommandExecute a Stata command. This feature is not supported for use with Java integration (that is, java[:] blocks).- Parameters:
- command- The command to execute.
- echo- Echo the command.
- Returns:
- Return code from Stata; 0 if successful.
 
- 
formatValueFormat a value using a Stata format.
- 
getAgentStringGet the User-Agent that Stata uses for web requests. This can be useful for setting the request property for aURLConnection.
 For example,URLConnection conn = url.openConnection(); conn.setRequestProperty("User-Agent", SFIToolkit.getAgentString());- Returns:
- The agent string.
 
- 
getCallerVersionGet the version number of the calling program. This function can be used to implement Stata version control.- Returns:
- The caller's version number.
 
- 
getTempFileGet a valid Stata temporary filename.- Returns:
- The filename, including its path.
 
- 
getTempNameGet a valid Stata temporary name.- Returns:
- The temporary name.
 
- 
getWorkingDirGet the current Stata working directory.- Returns:
- The path of the current working directory.
 
- 
isValidNameCheck if aStringis a valid Stata name.- Parameters:
- s- Name to test.
- Returns:
- True if the Stringrepresents a valid Stata name.
 
- 
isValidVariableNameCheck if aStringis a valid Stata variable name.- Parameters:
- s- Name to test.
- Returns:
- True if the Stringrepresents a valid Stata variable name.
 
- 
loadStataProxySettingspublic static void loadStataProxySettings()Apply Stata's proxy settings to Java. Call this prior to making a web request where you want proxy settings to be applied. This method only needs to be called once.
- 
pollnowRequest 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,pollstdshould be used instead. This method must be called from the main thread. If called from a worker thread, this method does nothing and returns 0.- Returns:
- A 0 unless the Break key has been pressed.
 
- 
pollstdRequest 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. This method must be called from the main thread. If called from a worker thread, this method does nothing and returns 0.- Returns:
- A 0 unless the Break key has been pressed.
 
- 
processTildePathStata utility to convert a path beginning with a tilde to a user's home directory. If the path does not begin with a tilde, then the path will not be modified.- Parameters:
- path- Path to process.
- Returns:
- The processed path.
 
- 
resolvePathResolve a path to aFile; the path may be relative to Stata's current working directory, begin with a tilde, or be an absolute path.- Parameters:
- path- Path to process.
- Returns:
- A File.
- Throws:
- InvalidPathException- If an error occurs an InvalidPathException is thrown.
 
- 
setRCSet the Stata return code when used with Java integration (that is, java[:] blocks). If this method is called within a plugin invoked with javacall, the return code will be overwritten when javacall exits.- Parameters:
- rc- The return code to set.
 
- 
stackTraceToString- Parameters:
- e- Exception.
- Returns:
- The Stringrepresentation of the stack trace.
 
- 
stackTraceToString- Parameters:
- t- Throwable.
- Returns:
- The Stringrepresentation of the stack trace.
 
 
-