igpp.util
Class VariableList

java.lang.Object
  extended by igpp.util.VariableList

public class VariableList
extends Object

VariableList manages one or more PPIVariable object.

Since:
1.0
Version:
1.0, 09/16/05
Author:
Todd King, Planetary Data System

Field Summary
 ArrayList mVariable
          The list of elements in the label
 
Constructor Summary
VariableList()
          Creates an instance of a variable.
 
Method Summary
 void clear()
          Removes all variables from list.
 void dump()
          Prints out all variables in the variable list.
 boolean findAndSet(String name, String value)
          Finds an item in an array list and set its value.
 boolean findAndSet(String name, String value, boolean resolve)
          Finds an item in an array list and set its value.
 boolean findAndSet(Variable variable)
          Finds a variable in the variable list and set its value.
 boolean findAndSet(VariableList list)
          Finds eavery variable in a list and sets it in this list.
 boolean getBooleanValue(String name)
          Finds an item in a variable list and returns its value as an boolean.
 int getIntValue(String name)
          Finds an item in a variable list and returns its value as an integer.
 String getValue(String name)
          Finds a variable in the variable list and returns its value.
 String getValue(String name, boolean blank)
          Finds a variable in the variable list and returns its value.
 Iterator iterator()
          Returns an Iterator for the variables in the list.
 String replaceVariable(String buffer)
          Searches the passed string for variables and replaces each variable with its current value.
 String replaceVariable(String buffer, boolean plain)
          Searches the passed string for variables and replaces each variable with its current value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mVariable

public ArrayList mVariable
The list of elements in the label

Constructor Detail

VariableList

public VariableList()
Creates an instance of a variable.

Since:
1.0
Method Detail

clear

public void clear()
Removes all variables from list.

Since:
1.0

findAndSet

public boolean findAndSet(Variable variable)
Finds a variable in the variable list and set its value. If the variable does not exist one is added.

Parameters:
variable - the name of the variable to set.
Returns:
true if an variable was set or added; false if unable to add the variable.
Since:
1.0

findAndSet

public boolean findAndSet(VariableList list)
Finds eavery variable in a list and sets it in this list. If the variable does not exist one is added.

Parameters:
list - the PPIVariableList of variables to add.
Returns:
true if an variable was set or added; false if unable to add the variable.
Since:
1.0

findAndSet

public boolean findAndSet(String name,
                          String value)
Finds an item in an array list and set its value. If the item does not exist one is added.

Parameters:
name - the name of the variable to set.
value - the value to set for the variable.
Returns:
true if an variable was set or added; false if unable to add the variable.
Since:
1.0

findAndSet

public boolean findAndSet(String name,
                          String value,
                          boolean resolve)
Finds an item in an array list and set its value. If the item does not exist one is added.

Parameters:
name - the name of the variable to set.
value - the value to set for the variable.
resolve - a flag indicating whether to resolve variables in the value.
Returns:
true if an variable was set or added; false if unable to add the variable.
Since:
1.0

getValue

public String getValue(String name)
Finds a variable in the variable list and returns its value. If the variable does not exist null is returned.

Parameters:
name - the name of the variable to set.
Returns:
null if an variable does not exist; the value assigned to the variable if it does.
Since:
1.0

getValue

public String getValue(String name,
                       boolean blank)
Finds a variable in the variable list and returns its value. If the variable does not exist null is returned.

Parameters:
name - the name of the variable to set.
blank - indicates whether to return a blank string if not the variable is not found. If true a blank is returned.
Returns:
The variable null if a variable does not exist and blank is false. Returns a blank string if blank is true; the value assigned to the variable if it does.
Since:
1.0

getIntValue

public int getIntValue(String name)
Finds an item in a variable list and returns its value as an integer. If the variable does not exist 0 is returned. Since 0 is a valid integer it can not be considered and indication that a variable does not exist.

Parameters:
name - the name of the variable to set.
Returns:
integer value assigned to the variable.
Since:
1.0

getBooleanValue

public boolean getBooleanValue(String name)
Finds an item in a variable list and returns its value as an boolean. If the variable does not exist false is returned.

Parameters:
name - the name of the variable to set.
Returns:
boolean value assigned to the variable.
Since:
1.0

replaceVariable

public String replaceVariable(String buffer)
Searches the passed string for variables and replaces each variable with its current value. Variables start with a dollar sign ($) followed by the name of the variable. Variable names can not contain white space. The string is passed through only once so to nest variables within the values of variables requires multiple calls. Replaced variables are unadorned (not enclosed in quotation marks).

Parameters:
buffer - the string to search for variables.
Returns:
the string with all variables replaced with the current value.
Since:
1.0

replaceVariable

public String replaceVariable(String buffer,
                              boolean plain)
Searches the passed string for variables and replaces each variable with its current value. Variables start with a dollar sign ($) followed by the name of the variable. Variable names can not contain white space. The string is passed through only once so to nest variables within the values of variables requires multiple calls.

Parameters:
buffer - the string to search for variables.
plain - indicates whether the replaced value of a vaiable should be enclosed in quotation marks. If true, the value will be unadorned.
Returns:
the string with all variables replaced with the current value.
Since:
1.0

iterator

public Iterator iterator()
Returns an Iterator for the variables in the list.

Returns:
an Iterator for the variables in the list.
Since:
1.0

dump

public void dump()
Prints out all variables in the variable list.

Since:
1.0


Copyright © 2008-2009 Regents University of California. All Rights Reserved.