public final class ValueLabel extends Object
Obtain and print all value labels in the current dataset...
public static int listLabel(String args[]) {
// get all the value-label names
String[] names = ValueLabel.getNames();
if (names == null || names.length == 0) {
SFIToolkit.errorln("No value labels found.");
return 111;
}
// print the labels for each value label
Map<Integer, String> map;
for (int i = 0; i < names.length; i++) {
map = ValueLabel.getValueLabels(names[i]);
SFIToolkit.displayln("\n" + names[i] + ":");
for (Map.Entry<Integer, String> entry : map.entrySet()) {
SFIToolkit.displayln(entry.getKey() + " " + entry.getValue());
}
}
return 0;
}
Modifier and Type | Method and Description |
---|---|
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.
|
public static String[] getNames()
public static int[] getValues(String name)
getLabels
to obtain two arrays, where array indexes are used to look up each
value-label pairing.name
- The name of the value label.public static String[] getLabels(String name)
getValues
to obtain
two arrays, where array indexes are used to look up each value-label
pairing.name
- The name of the value label.public static Map<Integer,String> getValueLabels(String name)
name
- The name of the value label.Map
containing the values and
label pairings for the specified value-label name.public static String getLabel(String name, int value)
name
- The name of the value label.value
- The value to look up.public static int createLabel(String name)
name
- The new name.public static int removeLabel(String name)
name
- The name of the value label to remove.public static int setLabelValue(String name, int value, String label)
name
- The name of the value label.value
- The value.label
- The label.public static int removeLabelValue(String name, int value)
name
- The name of the value label.value
- The value to remove.public static String getVarValueLabel(int index)
public static int setVarValueLabel(int index, String labelName)
index
- Index of the variable.labelName
- The value-label name.public static int removeVarValueLabel(int index)
index
- Index of the variable.