com.stata.sfi
Class ValueLabel

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

public final class ValueLabel
extends Object

Routines for interacting with Stata value labels.


Method Summary
static int createLabel(String name)
          Create a new value-label name.
static String getLabel(String name, int value)
          Get the label for a specified value-label value.
static String[] getLabels(String name)
          Get the labels for a specified value-label name.
static String[] getNames()
          Get the names of all value labels in the current dataset.
static Map<Integer,String> getValueLabels(String name)
          Get the values and labels for a specified value-label name.
static int[] getValues(String name)
          Get the values associated with a single value-label name.
static String getVarValueLabel(int index)
          Get the value-label name associated with a variable.
static int removeLabel(String name)
          Remove a value-label name.
static int removeLabelValue(String name, int value)
          Remove a value-label value.
static int removeVarValueLabel(int index)
          Remove a value-label name from a variable.
static int setLabelValue(String name, int value, String label)
          Set a value and label for a value-label name.
static int setVarValueLabel(int index, String labelName)
          Set the value label for a variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getNames

public static String[] getNames()
Get the names of all value labels in the current dataset.

Returns:
An array of value-label names.

getValues

public static int[] getValues(String name)
Get the values associated with a single value-label name. Use this method in conjunction with getLabels to obtain two arrays where array indexes are used to lookup each value label pairing.

Parameters:
name - The value label name.
Returns:
An array of the values for the specified value-label name. Returns null if an error occurs.

getLabels

public static String[] getLabels(String name)
Get the labels for a specified value-label name. Use this method in conjunction with getValues to obtain two arrays where array indexes are used to lookup each value label pairing.

Parameters:
name - The name of the value label.
Returns:
An array of the labels for the specified value-label name. Returns null if an error occurs.

getValueLabels

public static Map<Integer,String> getValueLabels(String name)
Get the values and labels for a specified value-label name.

Parameters:
name - The name of the value label.
Returns:
A Map containing the values and label pairings for the specified value-label name.

getLabel

public static String getLabel(String name,
                              int value)
Get the label for a specified value-label value.

Parameters:
name - The name of the value label.
value - The value to lookup.
Returns:
The label for the specified value-label value. Returns null if an error occurs.

createLabel

public static int createLabel(String name)
Create a new value-label name.

Parameters:
name - The new name.
Returns:
The return code; 0 if successful.

removeLabel

public static int removeLabel(String name)
Remove a value-label name.

Parameters:
name - The name of the value label to remove.
Returns:
The return code; 0 if successful.

setLabelValue

public static int setLabelValue(String name,
                                int value,
                                String label)
Set a value and label for a value-label name.

Parameters:
name - The name of the value label.
value - The value.
label - The label.
Returns:
The return code; 0 if successful.

removeLabelValue

public static int removeLabelValue(String name,
                                   int value)
Remove a value-label value.

Parameters:
name - The name of the value label.
value - The value to remove.
Returns:
The return code; 0 if successful.

getVarValueLabel

public static String getVarValueLabel(int index)
Get the value-label name associated with a variable.

Parameters:
index - Index of the variable.
Returns:
The value-label name associated with a variable. If a value label is not associated with the specified variable, then an empty String is returned. IF an error occurs then a null String will be returned.

setVarValueLabel

public static int setVarValueLabel(int index,
                                   String labelName)
Set the value label for a variable.

Parameters:
index - Index of the variable.
labelName - The value-label name.
Returns:
The return code; 0 if successful.

removeVarValueLabel

public static int removeVarValueLabel(int index)
Remove a value-label name from a variable.

Parameters:
index - Index of the variable.
Returns:
The return code; 0 if successful.