Package com.stata.sfi
Class Scalar
- java.lang.Object
-
- com.stata.sfi.Scalar
-
public final class Scalar extends Object
This class provides access to Stata scalars.Examples:
Loading and saving scalars...
public static int getStringScalar(String[] args) { String name = args[0]; String contents = Scalar.getString(name); SFIToolkit.displayln(name + " = " + contents); return 0; } public static int setStringScalar(String[] args) { String name = args[0]; String contents = args[1]; int rc = Scalar.setString(name, contents); return rc; } public static int getScalar(String[] args) { String name = args[0]; Double contents = Scalar.getValue(name); SFIToolkit.displayln(name + " = " + contents); return 0; } public static int setScalar(String[] args) { String name = args[0]; Double value = Double.parseDouble(args[1]); int rc = Scalar.setValue(name, value); return rc; }
-
-
Field Summary
Fields Modifier and Type Field Description static intTYPE_AUTOMATICstatic intTYPE_CRETURNstatic intTYPE_ERETURNstatic intTYPE_GLOBALstatic intTYPE_RETURNstatic intTYPE_RRETURNstatic intTYPE_SRETURNstatic intVTYPE_HIDDENstatic intVTYPE_HISTORICALstatic intVTYPE_VISIBLE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetString(String name)Get the contents of a Stata string scalar.static StringgetString(String name, int type)Get the contents of a Stata string scalar.static DoublegetValue(String name)Get the contents of a Stata scalar.static DoublegetValue(String name, int type)Get the contents of a Stata scalar.static intsetString(String name, String value)Set the contents of a Stata string scalar.static intsetString(String name, String value, int type)Set the contents of a Stata string scalar.static intsetValue(String name, double val)Set the value of a Stata scalar.static intsetValue(String name, double value, int type)Set the value of a Stata scalar.static intsetValue(String name, double value, int type, int vtype)Set the value of a Stata scalar.static intsetValue(String name, double value, int type, String version)Set the value of a Stata scalar.
-
-
-
Field Detail
-
TYPE_AUTOMATIC
public static final int TYPE_AUTOMATIC
- See Also:
- Constant Field Values
-
TYPE_CRETURN
public static final int TYPE_CRETURN
- See Also:
- Constant Field Values
-
TYPE_ERETURN
public static final int TYPE_ERETURN
- See Also:
- Constant Field Values
-
TYPE_GLOBAL
public static final int TYPE_GLOBAL
- See Also:
- Constant Field Values
-
TYPE_RETURN
public static final int TYPE_RETURN
- See Also:
- Constant Field Values
-
TYPE_RRETURN
public static final int TYPE_RRETURN
- See Also:
- Constant Field Values
-
TYPE_SRETURN
public static final int TYPE_SRETURN
- See Also:
- Constant Field Values
-
VTYPE_HIDDEN
public static final int VTYPE_HIDDEN
- See Also:
- Constant Field Values
-
VTYPE_HISTORICAL
public static final int VTYPE_HISTORICAL
- See Also:
- Constant Field Values
-
VTYPE_VISIBLE
public static final int VTYPE_VISIBLE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getString
@Synchronized public static String getString(String name)
Get the contents of a Stata string scalar.- Parameters:
name- Name of the scalar.- Returns:
- Value of the scalar. Returns null if the scalar is not found or if the scalar is marked as binary.
-
getString
@Synchronized public static String getString(String name, int type)
Get the contents of a Stata string scalar.- Parameters:
name- Name of the scalar.type- Type of the scalar; may beTYPE_AUTOMATIC,TYPE_GLOBAL, orTYPE_CRETURN.- Returns:
- Value of the scalar. Returns null if the scalar is not found or if the scalar is marked as binary.
-
getValue
@Synchronized public static Double getValue(String name)
Get the contents of a Stata scalar.- Parameters:
name- Name of the scalar.- Returns:
- Value of the scalar. Returns null if the scalar is not found.
-
getValue
@Synchronized public static Double getValue(String name, int type)
Get the contents of a Stata scalar.- Parameters:
name- Name of the scalar.type- Type of the scalar; may beTYPE_AUTOMATIC,TYPE_GLOBAL,TYPE_RETURN,TYPE_RRETURN,TYPE_ERETURN, orTYPE_CRETURN.- Returns:
- Value of the scalar. Returns null if the scalar is not found.
-
setString
@Synchronized public static int setString(String name, String value)
Set the contents of a Stata string scalar.- Parameters:
name- Name of the scalar.value- Value to store in the scalar.- Returns:
- Return code from Stata; 0 if successful.
-
setString
@Synchronized public static int setString(String name, String value, int type)
Set the contents of a Stata string scalar.- Parameters:
name- Name of the scalar.value- Value to store in the scalar.type- Type of the scalar; may beTYPE_AUTOMATICorTYPE_GLOBAL.- Returns:
- Return code from Stata; 0 if successful.
-
setValue
@Synchronized public static int setValue(String name, double val)
Set the value of a Stata scalar. If necessary, the scalar will be created.- Parameters:
name- Name of the scalar.val- Value to store in the scalar.- Returns:
- Return code from Stata; 0 if successful.
-
setValue
@Synchronized public static int setValue(String name, double value, int type)
Set the value of a Stata scalar. If necessary, the scalar will be created.- Parameters:
name- Name of the scalar.value- Value to store in the scalar.type- Type of the scalar; may beTYPE_AUTOMATIC,TYPE_GLOBAL,TYPE_RETURN,TYPE_RRETURN, orTYPE_ERETURN.- Returns:
- Return code from Stata; 0 if successful.
-
setValue
@Synchronized public static int setValue(String name, double value, int type, int vtype)
Set the value of a Stata scalar. If necessary, the scalar will be created.- Parameters:
name- Name of the scalar.value- Value to store in the scalar.type- Type of the scalar; may beTYPE_AUTOMATIC,TYPE_GLOBAL,TYPE_RETURN,TYPE_RRETURN, orTYPE_ERETURN.vtype- If the scalar is a type of return value, sets whether the return value isVTYPE_VISIBLE,VTYPE_HIDDEN, orVTYPE_HISTORICAL. This parameter is ignored withTYPE_GLOBAL.- Returns:
- Return code from Stata; 0 if successful.
-
setValue
@Synchronized public static int setValue(String name, double value, int type, String version)
Set the value of a Stata scalar. If necessary, the scalar will be created.- Parameters:
name- Name of the scalar.value- Value to store in the scalar.type- Type of the scalar; may beTYPE_GLOBAL,TYPE_RETURN,TYPE_RRETURN, orTYPE_ERETURN.version- If the scalar is a type of return value, sets the release number in the form #[#][.[#[#]]] for a return result. This parameter is ignored withTYPE_GLOBAL.- Returns:
- Return code from Stata; 0 if successful.
-
-