package ruleset.plugin; import pds.ruleset.*; import pds.label.*; import pds.util.*; import java.util.*; import java.io.*; /** * LabelValue.java July 22, 2003 * LabelValue is a program that returns every item in the label as a value of * the following type: * * $KEYWORD_OCCURENCE = VALUE * * Where the keyword is the keyword in the label. The occurence is the * number of the object the keyword occurs in. * * parameters are:
 *		LABEL 		The complete path of the label file
 *              
* default values:
 *		NONE
 *              
* * error handling:
* if the label does not exist or can not be parsed an error message is * returned. *
* * @author Erin Means * @author Planetary Data System * @version 2.0, 09/19/03 * @since 1.0 */ public class LabelValue { public static void main(String args[]) { //Get the parameters from the command line. String lbl = PPIOption.find(args, "LABEL", null, 0); PDSItem item = null; PDSElement element = null; String value = null; if(lbl == null) { errorMessage("LabelValue called incorrectly, usage java LabelVal LABEL='location of the label'. ", true); } PDSLabel label = new PDSLabel(); //If the label is able to be read by the PDSLabel it finds the element and //and sets the value variable equal to the label value. //If the file is not able to be read it prints an error message to the screen. try { label.parse(lbl); label.printVariable(System.out); } catch(Exception e) { errorMessage("LabelValue called incorrectly", true); label.printMessage(e.getMessage()); } } // Prints out the error message in appropriate format for the // ruleset parser. private static void errorMessage(String message, boolean abort) { PPIRuleset.showRule(PPIAction.MESSAGE, "$RULE_SET"); PPIRuleset.showRule(PPIAction.MESSAGE, "\t$FILE_PATH/$FILE_NAME"); PPIRuleset.showRule(PPIAction.MESSAGE, "\t" + message); if (abort) { PPIRuleset.showRule(PPIAction.ABORT, ""); System.exit(1); } } }