PIRL

PIRL.PVL
Class Parameter

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by PIRL.PVL.Parameter
All Implemented Interfaces:
Serializable, Cloneable, MutableTreeNode, TreeNode
Direct Known Subclasses:
Configuration, JPEG2000_Info, Message

public class Parameter
extends DefaultMutableTreeNode
implements Cloneable

A Parameter is a general-purpose named entity containing an arbitrary value. It is derived from the Parameter Value Language syntax:

Name = Value

Every Parameter has a Name which is a String of zero or more characters.

The kind of Value that a Parameter contains is indicated by its Classification code. There are three basic classifications:

TOKEN
A Parameter with a name but no value.
ASSIGNMENT
The fundamental Parameter containing a Value object.
AGGREGATE
A Parameter that contains a List of zero or more Parameters. An aggregate may have a GROUP or OBJECT specific classification; a distinction without a difference for this package (but which may be useful to the application).

There is also an UNKNOWN classification for a completely vacant Parameter (though its name is the empty string, not null). In addition, END classification Parameters may be used to mark the end of an aggregate's Parameter List without removing the Parameters beyond the end marker.

A Parameter may have Comments associated with it that contain any descriptive text.

Version:
1.44
Author:
Bradford Castalia, UA/PIRL
See Also:
Value, Parser, Serialized Form

Field Summary
static int AGGREGATE
          Non-specific classification for a Parameter associated with an aggregate list.
static int ASSIGNMENT
          Classification for a Parameter with a Value.
static int BEGIN_GROUP
          Alias for GROUP.
static int BEGIN_OBJECT
          Alias for OBJECT.
static int END
          Used to mark the end of an aggregate Parameter's List.
static int END_AGGREGATE
          Special classification for the end of an aggregate Parameter List.
static int END_GROUP
          A specific form of END_AGGREGATE.
static int END_OBJECT
          A specific form of END_AGGREGATE.
static int END_PVL
          A special classification that marks the end of all Parameters.
static int GROUP
          Classification for a Parameter that contains a List of Parameters.
static int HIGHEST_BIT
          The highest bit used by the classification code bit field.
static String ID
          Class name and version identification.
static int LOWEST_BIT
          The lowest bit used by the classification code bit field.
static int MASK
          Selects only the classification code bit fields recognized by the Parameter class.
static int OBJECT
          Classification for an aggregate Parameter; and is functionally identical to the GROUP classification.
static int TOKEN
          Classification for a Parameter with only a name.
static int UNKNOWN
          The classification of an empty Parameter.
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
Parameter()
          Creates an empty Parameter, with classification UNKNOWN and an empty string name (not null).
Parameter(Parameter parameter)
          A Parameter is constructed from a copy of another Parameter.
Parameter(Parser parser)
          Create a Parameter by getting all Parameters from a Parser.
Parameter(String name)
          Creates a token Parameter with only a name.
Parameter(String name, Parser parser)
          A Parser is used to get a new Parameter which is given the specified name.
 
Method Summary
static String Absolute_Pathname(String pathname)
          Produce an absolute pathname.
static String Absolute_Pathname(String parent_path, String base_path)
          Combines two pathnames to produce an absolute pathname.
 Parameter Add(List list)
          Adds a List of Parameters to the end of the aggregate list.
 void add(MutableTreeNode parameter)
          Invokes the Parameter's Add method.
 Parameter Add(Parameter parameter)
          Adds a Parameter to the end of the aggregate list.
 Parameter Add(Parser parser)
          Adds the Parameters obtained from a Parser to this Parameter's aggregate list.
protected  void adopt(Vector list)
          Sets the parents of a Vector of Parameters to this Parameter.
static String Basename(String pathname)
          Gets the basename portion of the pathname.
 String Classification_Name()
          Gets the name String associated with the Parameter's classification.
static String Classification_Name(int class_code)
          Gets the name String associated with the classification code.
 int Classification()
          Gets the Parameter's classification code.
 Parameter Classification(int class_code)
          Sets the classification of the Parameter.
static int Classification(Object object)
          Determine the general classification of an Object.
 Object clone()
          Makes a deep copy of the Parameter.
 String Comments()
          Gets the comments String.
 Parameter Comments(String comments)
          Sets the comments String.
 Object Data()
          Get the Parameter's data object.
 Parameter Data(Object data)
          Sets the data for the Parameter.
 Parameter Data(Parameter parameter)
          Copies the contents of a Parameter into this Parameter.
 String Description()
          Gets a PVL description of the Parameter.
 String Description(Lister lister)
          Gets a PVL description of the Parameter using a specified Lister.
 boolean equals(Object object)
          Tests if an Object is equal to this Parameter.
 boolean equalsIgnoreCase(Parameter parameter)
          Tests if a Parameter is equivalent to this Parameter, ignoring certain cases where field values are not equal.
 Parameter Find(int classification)
          Finds the Parameter having the specified classification.
 Parameter Find(int classification, Parameter last_parameter)
          Finds the Parameter having the specified classification, beginning after the specified Parameter object within the aggregate.
 Parameter Find(Parameter test_parameter)
          Finds the Parameter that completely matches a test Parameter.
 Parameter Find(Parameter test_parameter, Parameter last_parameter)
          Finds the Parameter that completely matches a test Parameter, beginning after the specified Parameter object within the aggregate.
 Parameter Find(Parameter test_parameter, Selector criteria)
          Finds the Parameter that matches a test Parameter according the Selector criteria.
 Parameter Find(Parameter test_parameter, Selector criteria, Parameter last_parameter)
          Searches for a Parameter that matches a test Parameter according the Selector criteria, optionally after some specific Parameter object has been located first.
 Parameter Find(String name)
          Finds the Parameter with the specified name, which may be a simple name or a pathname.
 Parameter Find(String name, boolean case_sensitive)
          Finds the Parameter with the specified name, which may be a simple name or a pathname.
 Parameter Find(String name, boolean case_sensitive, Parameter last_parameter)
          Finds the Parameter with the specified name, which may be a simple name or a pathname, beginning after the specified Parameter object within the aggregate.
 Parameter Find(String name, int classification)
          Finds the Parameter having the specified pathname and classification.
 Parameter Find(String name, int classification, Parameter last_parameter)
          Finds the Parameter having the specified pathname and classification, beginning after the specified Parameter object within the aggregate.
 Parameter Find(String name, Parameter last_parameter)
          Finds the Parameter with the specified name, which may be a simple name or a pathname, beginning after the specified Parameter object within the aggregate.
 PVL_Exception First_Warning()
          Returns the first warning since the last Reset_Warning.
 Parameter First_Warning(boolean first)
          Enables or disables returning the first warning that occurs as the current warning status.
protected  void graft(Parameter parameter)
          Grafts the contents of a Parameter into this Parameter.
 boolean Has_List()
          Tests if the Parameter has an aggregate list.
 boolean Has_Value()
          Tests if the Parameter has a valid Value assigment.
 Parameter Insert(List list, int index)
          Inserts a List of Parameters into the aggregate list starting at the specified index.
 void insert(MutableTreeNode parameter, int index)
          Invokes the Parameter's Insert method.
 Parameter Insert(Parameter parameter, int index)
          Inserts a Parameter into the aggregate list at the specified index.
static boolean Is_Absolute_Pathname(String pathname)
          Test if a pathname is absolute.
 boolean Is_Aggregate()
          Tests if the Parameter is classified as an aggregate.
static boolean Is_Aggregate(int class_code)
          Tests for an aggregate classification.
 boolean Is_Assignment()
          Tests if the Parameter is classified as an assignment.
static boolean Is_Assignment(int class_code)
          Tests for the assignment classification.
 boolean Is_Begin_Aggregate()
          Tests if the Parameter is classified as an aggregate beginning.
static boolean Is_Begin_Aggregate(int class_code)
          Tests for an aggregate beginning classification.
 boolean Is_Begin_Group()
          Tests if the Parameter is classified as beginning a group aggregate.
static boolean Is_Begin_Group(int class_code)
          Tests for the begin group aggregate classification.
 boolean Is_Begin_Object()
          Tests if the Parameter is classified as beginning an object aggregate.
static boolean Is_Begin_Object(int class_code)
          Tests fpr the begin object aggregate classification.
 boolean Is_Empty()
          Determines if the Parameter list is empty.
 boolean Is_End_Aggregate()
          Tests if the Parameter is classified as an aggregate ending.
static boolean Is_End_Aggregate(int class_code)
          Tests for an aggregate ending classification.
 boolean Is_End_Group()
          Tests if the Parameter is classified as ending a group aggregate list.
static boolean Is_End_Group(int class_code)
          Tests for the end group aggregate list classification.
 boolean Is_End_Object()
          Tests if the Parameter is classified as ending an object aggregate list.
static boolean Is_End_Object(int class_code)
          Tests for the end object aggregate list classification.
 boolean Is_End_PVL()
          Tests if the Parameter is the END_PVL classification.
static boolean Is_End_PVL(int class_code)
          Tests for the END_PVL classification.
 boolean Is_End()
          Tests if the Parameter is one of the END classifications.
static boolean Is_End(int class_code)
          Tests for an END classification.
 boolean Is_Group()
          Tests if the Parameter is classified as a group aggregate.
static boolean Is_Group(int class_code)
          Tests for the group aggregate classification.
 boolean Is_Object()
          Tests if the Parameter is classified as an object aggregate.
static boolean Is_Object(int class_code)
          Tests for the object aggregate classification.
static boolean Is_Parameter_List(Object object)
          Tests if an Object is a List (Vector) suitable for an aggregate Parameter.
static boolean Is_Parameter_Value(Object object)
          Tests if an Object is a Value suitable for a Parameter.
static boolean Is_Parameter(Object object)
          Tests if an Object is a Parameter.
 boolean Is_Token()
          Tests if the Parameter is classified as a token.
static boolean Is_Token(int class_code)
          Tests for the token classification.
 boolean Is_Unknown()
          Tests if the Parameter is classified as UNKNOWN (an empty Parameter).
static boolean Is_Unknown(int class_code)
          Tests for the UNKNOWN classification.
 Iterator iterator()
          Provides an Iterator starting at the first element of the list.
 Iterator iterator(int index)
          Provides an Iterator for the aggregate list positioned so that the next element returned will be at the specified index of the list.
 PVL_Exception Last_Warning()
          Returns the last warning since a Reset_Warning.
 Parameter Last_Warning(boolean last)
          Enables or disables returning the last warning that occurs as the current warning status.
 int List_Size()
          Gets the size of an aggregate's list; the number of Parameters it contains.
 Vector List()
          Gets the Parameter list aggregated under this Parameter.
 Parameter List(Vector list)
          Sets the Parameter list for the Parameter.
 ListIterator listIterator()
          Provides a ListIterator starting at the first element of the list.
 ListIterator listIterator(int index)
          Provides a ListIterator for the aggregate list positioned so that the next element returned will be at the specified index of the list.
 boolean Match_Depth(Parameter parameter, Selector criteria)
          Tests if a Parameter matches this Parameter using the specified criteria.
 boolean Match(Parameter parameter, Selector criteria)
          Tests if a Parameter matches this Parameter using the specified criteria.
 String Name()
          Gets the name of the Parameter.
 Parameter Name(String name)
          Sets the Parameter's name.
protected static void orphan(List list)
          Sets a list of Parameters to have no parent.
static String Parent_Pathname(String pathname)
          Gets the portion of a pathname to the parent parameter.
 Parameter Parent()
          Gets the Parameter that is this Parameter's parent.
static char Path_Delimiter()
          Gets the current Path_Name delimiter.
static char Path_Delimiter(char delimiter)
          Sets the Path_Name delimiter.
 String Path_from(Parameter root_parent)
          Gets the pathname of the Parameter from some parent Parameter.
 String Path_Name()
          Gets the fully qualified pathname of the Parameter.
 String Path_to_Name()
          Gets the pathname of the Parameter without the Parameter's name.
 Parameter Remove_All()
          Empties the Parameter aggregate list.
 void remove(int index)
          Invokes the Parameter's Remove method.
 Parameter Remove(int index)
          Removes the Parameter at the specified index from the aggregate list.
 void remove(MutableTreeNode parameter)
          Invokes the Parameter's Remove method.
 Parameter Remove(Parameter parameter)
          Removes the specified Parameter from the aggregate list.
 Parameter Reset_Warning()
          Clears any warning status so that the Warning method will return null until the next warning condition occurs.
protected  void set_classification(int class_code)
          Sets the appropriate classification variables.
protected  void set_data(Object data)
          Set the appropriate Data variables.
 void setAllowsChildren(boolean allows)
          Overrides the base class method to ensure Parameter integrity.
 void setUserObject(Object object)
          Overrides the base class method to ensure Parameter integrity.
 String toString()
          Gets the name of the Parameter.
 Value Value()
          Gets the Value assigned to the Parameter.
 Parameter Value(byte value)
          Assigns a new Value constructed from a primitive byte value.
 Parameter Value(double value)
          Assigns a new Value constructed from a primitive double value.
 Parameter Value(float value)
          Assigns a new Value constructed from a primitive float value.
 Parameter Value(int value)
          Assigns a new Value constructed from a primitive int value.
 Parameter Value(long value)
          Assigns a new Value constructed from a primitive long value.
 Parameter Value(Object value)
          Assigns a new Value constructed from an Object.
 Parameter Value(short value)
          Assigns a new Value constructed from a primitive short value.
 Parameter Value(Value value)
          Sets the Value for the Parameter.
 PVL_Exception Warning()
          Gets the current warning status.
 int Write()
          Writes the Parameter in PVL syntax to System.out starting at level 0, not strict.
 int Write(boolean indent)
          Writes the Parameter in PVL syntax to System.out with or without indenting, not strict.
 int Write(boolean indent, boolean strict)
          Writes the Parameter in PVL syntax to output System.out with indenting and strict PVL enabled or disabled.
 int Write(Lister lister)
          Writes the Parameter in PVL syntax using a PVL Lister.
 int Write(OutputStream output)
          Writes the Parameter in PVL syntax to the output starting at level 0, not strict.
 int Write(OutputStream output, boolean indent)
          Writes the Parameter in PVL syntax to the output with or without indenting, not strict.
 int Write(OutputStream output, boolean indent, boolean strict)
          Writes the Parameter in PVL syntax to the output with indenting and strict PVL enabled or disabled.
 int Write(OutputStream output, int level, boolean strict)
          Writes the Parameter in PVL syntax to an OutputStream.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
breadthFirstEnumeration, children, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, removeAllChildren, removeFromParent, setParent
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class name and version identification.

See Also:
Constant Field Values

LOWEST_BIT

public static final int LOWEST_BIT
The lowest bit used by the classification code bit field.

See Also:
Constant Field Values

HIGHEST_BIT

public static final int HIGHEST_BIT
The highest bit used by the classification code bit field.

See Also:
Constant Field Values

TOKEN

public static final int TOKEN
Classification for a Parameter with only a name.

See Also:
Constant Field Values

ASSIGNMENT

public static final int ASSIGNMENT
Classification for a Parameter with a Value.

See Also:
Constant Field Values

AGGREGATE

public static final int AGGREGATE
Non-specific classification for a Parameter associated with an aggregate list.

This classification is a place-holder for all Parameters associated with a Parameter aggregate list. If it is used with the Classification method, the default GROUP classification will be applied.

See Also:
GROUP, Constant Field Values

END

public static final int END
Used to mark the end of an aggregate Parameter's List.

Do not set the classification of a Parameter to this value, but logically OR it with a specific classification. For example, to temporarily mark a Parameter as the end of an aggregate:

Parameter parameter = aggregate.Find ("Parameter_Name");
if (parameter != null)
    {
    // Mark the end of the list here.
    parameter.Classification (parameter.Classifcation () | END);
    // The list stops with the parameter before "Parameter_Name".
    parameter.Parent ().Write ();
    // Restore the previous classification.
    parameter.Classification (parameter.Classifcation () & ~END);
    }

Using the END_AGGREGATE classification may be easier.

See Also:
END_AGGREGATE, END_PVL, Constant Field Values

END_PVL

public static final int END_PVL
A special classification that marks the end of all Parameters.

An END_PVL Parameter will truncate any remaining Parameters in the current List and the Lists of any Parent Parameters. However, the truncated Parameters remain in place and can be restored by restoring the classification of the marked Parameter.

See Also:
END, END_AGGREGATE, Constant Field Values

END_AGGREGATE

public static final int END_AGGREGATE
Special classification for the end of an aggregate Parameter List.

The END_GROUP and END_OBJECT are specific versions of this classification.

Note that while a Parameter classified as an END_XXX Parameter may be used, they are not required (and typically not used) except in the PVL syntax seen by the Parser. The appropriate END_XXX Parameter is implicit, and will be provided automatically by the Write method, at the end of each aggregate. An END_XXX Parameter in a Parameter List will functionally truncate the List at that point; the additional Parameters of the List remain and can be functionally recovered by restoring the original classification. For example,

Parameter parameter = aggregate.Find ("Parameter_Name");
if (parameter != null)
    {
    // Save the current classification.
    int classification = parameter.Classification ();
    // Mark the end of the list here.
    parameter.Classification (Parameter.END_AGGREGATE);
    // The list stops with the parameter before "Parameter_Name".
    parameter.Parent ().Write ();
    // Restore the previous classification.
    parameter.Classification (classification);
    }

See Also:
END, END_PVL, Constant Field Values

GROUP

public static final int GROUP
Classification for a Parameter that contains a List of Parameters.

This Parameter has no Value, but instead contains a List (Vector) of children Parameters. This classification is functionally identical to OBJECT. The distinction is based on the PVL keyword syntax recognized by the Parser when an aggregate Parameter is constructed.

See Also:
Parser, Constant Field Values

BEGIN_GROUP

public static final int BEGIN_GROUP
Alias for GROUP.

See Also:
GROUP, Constant Field Values

END_GROUP

public static final int END_GROUP
A specific form of END_AGGREGATE.

See Also:
END_AGGREGATE, Constant Field Values

OBJECT

public static final int OBJECT
Classification for an aggregate Parameter; and is functionally identical to the GROUP classification.

Don't confuse this classification with the Java Object class. The name is a formal keyword in the PVL syntax.

See Also:
GROUP, Constant Field Values

BEGIN_OBJECT

public static final int BEGIN_OBJECT
Alias for OBJECT.

See Also:
OBJECT, Constant Field Values

END_OBJECT

public static final int END_OBJECT
A specific form of END_AGGREGATE.

See Also:
END_AGGREGATE, Constant Field Values

UNKNOWN

public static final int UNKNOWN
The classification of an empty Parameter.

See Also:
Constant Field Values

MASK

public static final int MASK
Selects only the classification code bit fields recognized by the Parameter class.

Logical AND with another int variable will ensure that only Parameter classification bits remain.

See Also:
Constant Field Values
Constructor Detail

Parameter

public Parameter()
Creates an empty Parameter, with classification UNKNOWN and an empty string name (not null).


Parameter

public Parameter(String name)
Creates a token Parameter with only a name.

Parameters:
name - The name of this token. If null, the name will be set to the empty String.

Parameter

public Parameter(Parser parser)
          throws PVL_Exception
Create a Parameter by getting all Parameters from a Parser.

When the source for the Parser is a String, and the String's PVL defines more than one Parameter (excluding any Parameters that may be contained within aggregate Parameters), then an aggregate Parameter will be provided to contain all of the Parameters, and will be given the name Parser.CONTAINER_NAME. However, if the String only defines a single, top-level Parameter, then that is what will be provided.

When the source for the Parser is not a String, then a container Parameter will always be used to hold the results from the Parser, regardless of the number of Parameters that are defined.

Parameters:
parser - The Parser source for PVL syntax.
Throws:
PVL_Exception - When the Parser encounters an unrecoverable error. The Parser may also generate a Warning which will associated with the new Parameter.
See Also:
Parser

Parameter

public Parameter(String name,
                 Parser parser)
          throws PVL_Exception
A Parser is used to get a new Parameter which is given the specified name.

This constructor is typically used when the source for the Parser is a File and the resultant aggregate Parameter is to be given the name of the File, rather than the default Parser.CONTAINER_NAME. Note that if the Parser source is a String that defines a single Parameter, then the name of that Parameter will be overriden by the new name from this constructor.

Parameters:
parser - The Parser source for PVL syntax. If null this is the same as using the no argument constructor.
name - The name of the new Parameter. If null, the name will be set to the empty String.
Throws:
PVL_Exception - When the Parser encounters an unrecoverable error. The Parser may also generate a Warning which will be associated with the new Parameter.
See Also:
Parser

Parameter

public Parameter(Parameter parameter)
          throws PVL_Exception
A Parameter is constructed from a copy of another Parameter.

The contents of the original Parameter are copied into the new Parameter. The warning status from the original is not copied.

When the original Parameter is an assignment, the Value is completely copied.

When the original is an aggregate, a new Parameter list is created in which each element is a recursive copy of the elements from the original list in the same order. Note: List copying stops at END_AGGREGATE parameters, and all copying stops at END_PVL parameters; the new Parameter is a logical copy of the original. Thus the new Parameter will be equivalent (equalsIgnoreCase) to the original, but may not be identical (equals).

Parameters:
parameter - The original Parameter to be copied. If null this is the same as using the no argument constructor.
Throws:
PVL_Exception -
BAD_ARGUMENT
An inappropriate object was found as the element of an aggregate Parameter list or Value array during copying.
See Also:
set_classification(int), (), Add(Parameter), Value.Value(Value)
Method Detail

Name

public String Name()
Gets the name of the Parameter.

Returns:
The name of the Parameter. This will not be null.

Name

public Parameter Name(String name)
Sets the Parameter's name.

Parameters:
name - The name String. If null the name will be set to the empty String.
Returns:
This Parameter.

toString

public String toString()
Gets the name of the Parameter.

Overrides:
toString in class DefaultMutableTreeNode
Returns:
The name String of the Parameter.

Path_Name

public String Path_Name()
Gets the fully qualified pathname of the Parameter.

The pathname is the name of the Parameter preceeded by the current Path_Delimiter character. If this Parameter has a Parent then the delimiter is preceeded by the parent's pathname. This recursion produces a pathname that starts with the delimiter character followed by the name of the root Parameter (no parent), the names of all containing aggregate Parameters leading to this Parameter separated by the delimiter, and ending with the name of this Parameter. If this Parameter has no parent, then the pathname is just its name preceeded by the delimiter.

Returns:
The pathname String for the Parameter.
See Also:
Path_Delimiter(), Parent()

Path_to_Name

public String Path_to_Name()
Gets the pathname of the Parameter without the Parameter's name.

The trailing Path_Delimiter character is included. If this Parameter has no parent, then only the delimiter will be returned.

Returns:
The pathname String up to, but not including, the Parameter.
See Also:
Path_Name()

Path_from

public String Path_from(Parameter root_parent)
Gets the pathname of the Parameter from some parent Parameter.

The pathname includes the names of each Parameter from, but not including, the root_parent up to, and including, this Parameter. The pathname will begin with the Path_Delimiter character and each Parameter name will be separated from the next by the same delimiter.

Note: The pathname returned by this method is the absolute pathname for the Parameter in the root_parent, as used by the Find method.

Parameters:
root_parent - A Parent of this Parameter.
Returns:
The absolute pathname to this Parameter from the root_parent, or null if the root_parent is not a parent of this Parameter.

Path_Delimiter

public static char Path_Delimiter()
Gets the current Path_Name delimiter.

The default delimiter is the slash ('/') character.

Returns:
The delimiter char used for constructing pathnames.

Path_Delimiter

public static char Path_Delimiter(char delimiter)
Sets the Path_Name delimiter.

Note: The delimiter is a static class variable that applies to all Parameters.

Parameters:
delimiter - The delimiter char.
Returns:
The previous delimiter character.

Absolute_Pathname

public static String Absolute_Pathname(String parent_path,
                                       String base_path)
Combines two pathnames to produce an absolute pathname.

The base_path is taken to be relative to the parent_path. Typically the base_path is a simple name (e.g. a Basename), and the parent_path is a path from the root (e.g. a Parent_Pathname). However, any pathnames will do. If the parent_path is not absolute it is made absolute. The base_path, if not null or empty, is appended to the parent_path with a single separating delimiter.

Parameters:
parent_path - The pathname of the parent parameter. If null or empty, the root pathname is used.
base_path - The pathname of the parameter relative to the parent_path.
Returns:
The absolute pathname.

Absolute_Pathname

public static String Absolute_Pathname(String pathname)
Produce an absolute pathname.

The specified pathname is converted, if needed, to a top level absolute pathname.

Parameters:
pathname - The pathname of a parameter.
Returns:
The absolute pathname.

Is_Absolute_Pathname

public static boolean Is_Absolute_Pathname(String pathname)
Test if a pathname is absolute.

An absolute pathname begins with the current () path delimiter.

Parameters:
pathname - The pathname of a parameter.
Returns:
true if the pathname is absolute; false otherwise. A null or empty pathname is not absolute.

Parent_Pathname

public static String Parent_Pathname(String pathname)
Gets the portion of a pathname to the parent parameter.

The parent pathname is the substring of the pathname preceding the last path delimiter (usually the '/' character). If there is no delimiter in the pathname, or nothing preceding the last delimiter, then there is no parent pathname.

N.B.: This function only considers the specified pathname. It does not provide the name of a Parameter's parent.

Parameters:
pathname - The String naming a pathname to a parameter.
Returns:
The String naming the pathname to the parent parameter, or null if the parameter has no parent (or the specified pathname is null).

Basename

public static String Basename(String pathname)
Gets the basename portion of the pathname.

The basename is the substring of the pathname following the last path delimiter (usually the '/' character). If the pathname does not contain a delimiter, then the entire pathname is the basename.

Parameters:
pathname - The String naming a pathname to a parameter.
Returns:
The basename substring of the pathname. This will be null if the specified pathname is null. It will be the empty String if the pathname ends with the path delimiter.

Description

public String Description(Lister lister)
Gets a PVL description of the Parameter using a specified Lister.

If no Lister is specified (the argument is null) then a default Lister will be provided.

The Lister will have its Writer set to a StringWriter used to write the PVL syntax. The Parameter is Writen using the Lister and the resultant String, without any final end-of-line sequence, is returned. If the Write method produces an exception, the exception message is returned after a Lister.NEW_LINE (this should be a unique flag that producing the PVL description failed).

Parameters:
lister - The Lister to use when writing the PVL syntax.
Returns:
The String describing the Parameter in PVL syntax.

Description

public String Description()
Gets a PVL description of the Parameter.

The Parameter is Writen to a StringWriter on a default Lister and the resultant String is returned. If the Write method produces an exception, the exception message is returned.

Returns:
The String describing the Parameter in PVL syntax.
See Also:
Description(Lister)

Value

public Value Value()
            throws PVL_Exception
Gets the Value assigned to the Parameter.

Returns:
The Parameter's Value. If the Parameter has no Value, null is returned.
Throws:
PVL_Exception -
ILLEGAL_SYNTAX
If the Parameter is not an assignment or token.

List

public Vector List()
            throws PVL_Exception
Gets the Parameter list aggregated under this Parameter.

Returns:
The Parameter's list as a Vector object. If the Parameter has no Parameter list, null is returned. If the Parameter has no list because it is not classified as an aggregate, then a PVL_Exception.ILLEGAL_SYNTAX warning status is set.
Throws:
PVL_Exception -
ILLEGAL_SYNTAX
If the Parameter is not an aggregate.

Is_Empty

public boolean Is_Empty()
Determines if the Parameter list is empty.

Returns:
true if the Parameter list is empty, or the Parameter has no list (a Parameter that is not classified as an aggregate will have no list). Otherwise, false.
See Also:
Vector.isEmpty()

Data

public Object Data()
Get the Parameter's data object.

Returns:
The Parameter's data object. If the Parameter is classified as an aggregate, this will be the Parameter list (Vector). Otherwise it will be the Parameter's Value. In either case, the object may be null.

Value

public Parameter Value(Value value)
Sets the Value for the Parameter.

The Parameter is classified as an assignment and the specified Value is assigned. If the Parameter previously had data, it is replaced. In the case where previous data was an aggregate Parameter list, all elements of the list are orphaned (they are marked as having no parent). Note: The Value is not copied.

Parameters:
value - The Value object to be assigned.
Returns:
This Parameter.
See Also:
set_classification(int), set_data(Object)

Value

public Parameter Value(byte value)
                throws PVL_Exception
Assigns a new Value constructed from a primitive byte value.

Parameters:
value - The primitive datum for the new Value.
Returns:
This Parameter.
Throws:
PVL_Exception - If a new Value could not be constructed from the value.
See Also:
Value(Value)

Value

public Parameter Value(short value)
                throws PVL_Exception
Assigns a new Value constructed from a primitive short value.

Parameters:
value - The primitive datum for the new Value.
Returns:
This Parameter.
Throws:
PVL_Exception - If a new Value could not be constructed from the value.
See Also:
Value(Value)

Value

public Parameter Value(int value)
                throws PVL_Exception
Assigns a new Value constructed from a primitive int value.

Parameters:
value - The primitive datum for the new Value.
Returns:
This Parameter.
Throws:
PVL_Exception - If a new Value could not be constructed from the value.
See Also:
Value(Value)

Value

public Parameter Value(long value)
                throws PVL_Exception
Assigns a new Value constructed from a primitive long value.

Parameters:
value - The primitive datum for the new Value.
Returns:
This Parameter.
Throws:
PVL_Exception - If a new Value could not be constructed from the value.
See Also:
Value(Value)

Value

public Parameter Value(float value)
                throws PVL_Exception
Assigns a new Value constructed from a primitive float value.

Parameters:
value - The primitive datum for the new Value.
Returns:
This Parameter.
Throws:
PVL_Exception - If a new Value could not be constructed from the value.
See Also:
Value(Value)

Value

public Parameter Value(double value)
                throws PVL_Exception
Assigns a new Value constructed from a primitive double value.

Parameters:
value - The primitive datum for the new Value.
Returns:
This Parameter.
Throws:
PVL_Exception - If a new Value could not be constructed from the value.
See Also:
Value(Value)

Value

public Parameter Value(Object value)
                throws PVL_Exception
Assigns a new Value constructed from an Object.

Parameters:
value - The Object from which to construct the new Value.
Returns:
This Parameter.
Throws:
PVL_Exception - If a new Value could not be constructed from the value.
See Also:
Value(Value)

List

public Parameter List(Vector list)
               throws PVL_Exception
Sets the Parameter list for the Parameter.

The Parameter is classified as an AGGREGATE (i.e. GROUP) and the contents of the Vector are adopted. The new list must contain only Parameter elements, each of which has its parent set to this Parameter. If the Parameter previously had data, it is replaced. In the case where previous data was an aggregate Parameter list, all elements of the list are orphaned (they are marked as having no parent). Note: The list is not copied.

Parameters:
list - The Vector of Parameters to be adopted.
Returns:
This Parameter.
Throws:
PVL_Exception - From set_data.
See Also:
set_classification(int), set_data(Object)

List_Size

public int List_Size()
Gets the size of an aggregate's list; the number of Parameters it contains.

Returns:
The number of Parameters in the aggregate list. If the Parameter is not an aggregate or has no list, zero will be returned; i.e. returning zero is not determinate that the Parameter is an aggregate with an empty list. N.B.: This value does not include the number of Parameters in any aggregates in this Parameters list.

Data

public Parameter Data(Parameter parameter)
               throws PVL_Exception
Copies the contents of a Parameter into this Parameter.

This Parameter is made equivalent (equalsIgnoreCase not necessarily equals) to the specified Parameter.

Parameters:
parameter - The Parameter to be copied into this Parameter. If null, and empty parameter will be used.
Returns:
This Parameter.
Throws:
PVL_Exception - From graft.
See Also:
Parameter(Parameter), graft(Parameter)

Data

public Parameter Data(Object data)
               throws PVL_Exception
Sets the data for the Parameter.

If the data is a Parameter object then its contents are copied into this Parameter; i.e. this Parameter is made equivalent (equalsIgnoreCase not necessarily equals) to the specified Parameter. Otherwise the Parameter is classified based on the Classification of the data Object specified. The classification will be an ASSIGNMENT if the data is a Value, an AGGREGATE (i.e. GROUP) for Parameter list data, or a TOKEN if the data is null (unless the Parameter has no name, in which case the classification is UNKNOWN). The data is applied to the Parameter appropriately as if either the Value (Value) or List (Vector) method were used.

Parameters:
data - The data Object to be applied.
Returns:
This Parameter.
Throws:
PVL_Exception - From set_data.
See Also:
Data(Parameter), Classification(Object), set_classification(int), set_data(Object), Value(Value), List(Vector)

Insert

public Parameter Insert(Parameter parameter,
                        int index)
                 throws PVL_Exception
Inserts a Parameter into the aggregate list at the specified index.

If the Parameter is not already classified as an aggregate, and does not have a Value assigned, it is given the GROUP classification. The specified Parameter is inserted at the specified index in the aggregate Parameter list. Any Parameters in the list at, or beyond the index are moved to the next index.

After the specified Parameter is inserted its parent is set to this Parameter.

Warning: Inserted parameters are not removed from any Aggregate list they may already be in.

Parameters:
parameter - The Parameter object to be inserted.
index - The location in the list for the insertion.
Returns:
This Parameter.
Throws:
PVL_Exception -
ILLEGAL_SYNTAX
The Parameter is an assignment with a Value.
See Also:
Classification(int), Remove(Parameter), Vector.insertElementAt(Object, int)

Insert

public Parameter Insert(List list,
                        int index)
                 throws PVL_Exception
Inserts a List of Parameters into the aggregate list starting at the specified index.

The elements of the List are Inserted in the order they occur from the List's listIterator at sequential locations starting with the specified index.

Parameters:
list - The List of Parameters to Insert.
index - The first of sequential Insert locations.
Returns:
This Parameter.
Throws:
PVL_Exception -
BAD_ARGUMENT
An element of the List is not a Parameter.
See Also:
Insert(Parameter, int), List.listIterator()

Add

public Parameter Add(Parameter parameter)
              throws PVL_Exception
Adds a Parameter to the end of the aggregate list.

Uses the Insert method where the index is the end of the list.

Parameters:
parameter - The Parameter to be added.
Returns:
This Parameter.
Throws:
PVL_Exception - From Insert.
See Also:
Insert(Parameter, int)

Add

public Parameter Add(List list)
              throws PVL_Exception
Adds a List of Parameters to the end of the aggregate list.

Performs an Insert where the index is the end of the list.

Parameters:
list - The List of Parameters to be added.
Returns:
This Parameter.
Throws:
PVL_Exception - From Insert.
See Also:
Insert(List, int)

Add

public Parameter Add(Parser parser)
              throws PVL_Exception
Adds the Parameters obtained from a Parser to this Parameter's aggregate list.

Parameters:
parser - The Parser to use as the source of PVL statements.
Returns:
This Parameter.
Throws:
PVL_Exception - From the Parser. Note: The warning status for the Parser is cleared before it is called, and then applied to this Parameter afterwards.
See Also:
Parser.Add_To(Parameter), Parser.Warning()

Remove

public Parameter Remove(int index)
Removes the Parameter at the specified index from the aggregate list.

After being removed from the aggregate list the Parameter is marked as having no parent.

Parameters:
index - The aggregate list index of the Parameter to be removed.
Returns:
The Parameter removed. If this Parameter is not an aggregate, or has no list, null is returned. If this Parameter is not an aggregate a PVL_Exception.ILLEGAL_SYNTAX Warning status is set.
See Also:
Vector.remove(int)

Remove

public Parameter Remove(Parameter parameter)
Removes the specified Parameter from the aggregate list.

The first occurance of the Parameter in the list is removed. The aggregate list, if there is one, is searched regardless of the classification of this Parameter. Only this Parameter list is searched, not the lists of any aggregate Parameters in the list. The Parameter is found in the aggregate list by equality of Parameter object reference, not by the equals method. To remove a Parameter that equals another Parameter, use Find:

// Use Path_from only if the specific location matters.
parameter = aggregate.Find (parameter.Name (parameter.Path_from (aggregate)));
if (parameter != null)
    parameter.Parent ().Remove (parameter);

Parameters:
parameter - The Parameter object to be removed. If null nothing is done and null is returned.
Returns:
The Parameter removed. If this Parameter is not an aggregate, or has no list, null is returned. If this Parameter is not an aggregate an ILLEGAL_SYNTAX Warning status is produced.
See Also:
Remove(int)

Remove_All

public Parameter Remove_All()
Empties the Parameter aggregate list.

The aggregate list, if it exists, is removed regardless of the classification of this Parameter. All Parameters in the list (but not sub-lists) are marked as not having a parent.

Returns:
This Parameter.

set_data

protected void set_data(Object data)
                 throws PVL_Exception
Set the appropriate Data variables.

The Classification of the data object determines how the internal data variables are set. Consistency of the Parameter's data is ensured by always setting it with this method.

For Vector data, the data becomes the base class aggregate list (children) Vector. Its contents are adopted which confirms that each element is a Parameter and its parent is set to this Parameter. This Parameter's Value is set to null.

For Value data, the data becomes the Value of the Parameter. The aggregate list (children) contents are orphaned and then the children Vector is set to null.

>>> WARNING <<< The classification of the Parameter is not updated. Accordingly, this method should only be used by methods that will also set the classification appropriately.

Parameters:
data - The Object to become the Parameter's data.
Throws:
PVL_Exception -
BAD_ARGUMENT
If the data object is not a valid class for a Parameter (null is acceptable), or the data object is a Vector and one of its elements is not a Parameter.
See Also:
Classification(Object), adopt(Vector), orphan(List)

graft

protected void graft(Parameter parameter)
              throws PVL_Exception
Grafts the contents of a Parameter into this Parameter.

In effect, this Parameter becomes the specified Parameter.

The Value reference is set (not copied) to the specified Parameter's Value reference along with the name, comments, and warning status. The aggregate list (children) Vector reference is set to the specified Parameter's Vector and if it has contents they are adopted by this Parameter (the specified Parameter's children Vector is set to null to avoid any possible confusion). The classification is set to be the same as the specified Parameter. Note: The parent of this Parameter remains unchanged; i.e. the contents of are replaced but the context stays the same.

Parameters:
parameter - The Parameter object to graft into this Parameter. If null, nothing is done.
Throws:
PVL_Exception - From adopt.
See Also:
adopt(Vector), set_classification(int)

adopt

protected void adopt(Vector list)
              throws PVL_Exception
Sets the parents of a Vector of Parameters to this Parameter.

>>> WARNING <<< Only the parent references for the Parameters in the Vector are set to this Parameter. The Vector itself may still be referenced by some other Parameter. In this case the adoption of the Vector will not be complete until the reference in the former parent is changed (e.g. to null).

Parameters:
list - The Vector of Parameters to adopt.
Throws:
PVL_Exception -
BAD_ARGUMENT
If an entry in the list is not a Parameter.

orphan

protected static void orphan(List list)
Sets a list of Parameters to have no parent.

>>> WARNING <<< Only the parent references for the Parameters in the list are set to null. The list itself may still be referenced by some other Parameter. In this case the orphaning of the Vector will not be complete until the reference in the former parent is changed (e.g. to null).

Parameters:
list - The List of Parameters to orphan.

Classification

public int Classification()
Gets the Parameter's classification code.

Returns:
The classification code.

Classification

public static int Classification(Object object)
Determine the general classification of an Object.

The Object is considered to be potential Parameter data and is tested to see if it is an instance of an acceptable Java Class for Parameter data. Note that only a general classification can be determined by examining an Object.

Parameters:
object - The Object to be tested.
Returns:
The basic classification code category int that would be associated with a Parameter having the object for its data. If the object is a Value, then the ASSIGNMENT classification is returned; if a Vector, then the AGGREGATE code is returned; and if the argument is null then the UNKNOWN classification is returned. If an invalid object is specified, then the return value is -1.

Classification

public Parameter Classification(int class_code)
Sets the classification of the Parameter.

Note: Changing to a new classification may result in loss of data if the Parameter's previous data is invalid under the new classification. If the new classification is not for assignment, then any Value is dropped; if the new classification is not for an aggregate, then any existing list is removed. However, END_XXX classifications are exempt: END_XXX classification Parameters are normally implicit at the end of aggregate Parameter lists. They are used explicitly to mark, probably temporarily, the end of a list or an entire hierarchy (END_PVL). Therefore, when these classifications are applied to a Parameter its underlying data is left intact.

Parameters:
class_code - The new Parameter classification int.
Returns:
This Parameter.
See Also:
END_AGGREGATE, END_PVL, set_classification(int), Remove_All()

set_classification

protected void set_classification(int class_code)
Sets the appropriate classification variables.

Consistency of the Parameter's classification is ensured by always setting it with this method. If the classification code is for an AGGREGATE, then the allowsChildren variable of the DefaultMutableTreeNode base class will be set to true; otherwise it will be set to false.

>>> WARNING <<< The data of the Parameter is not checked for consistency with the classification. Accordingly, this method should only be used by methods that will also set the data appropriately.

Parameters:
class_code - The int classification code for the Parameter.

Classification_Name

public static String Classification_Name(int class_code)
Gets the name String associated with the classification code.

Classification names are identical to the names of the classification code constants, except that the BEGIN_XXX aliases are not used.

Parameters:
class_code - The classification code int.
Returns:
The appropriate classification name String. An invalid classification code will return a null.

Classification_Name

public String Classification_Name()
Gets the name String associated with the Parameter's classification.

Returns:
The appropriate classification name String.

Is_Parameter

public static boolean Is_Parameter(Object object)
Tests if an Object is a Parameter.

Parameters:
object - The Object to be tested.
Returns:
true if the object is an instance of the Parameter class; otherwise false (also false if the object is null).

Is_Parameter_Value

public static boolean Is_Parameter_Value(Object object)
Tests if an Object is a Value suitable for a Parameter.

Parameters:
object - The Object to be tested.
Returns:
true if the object is an instance of the Value class; otherwise false (also false if the object is null).
See Also:
Value.Is_Value(Object)

Is_Parameter_List

public static boolean Is_Parameter_List(Object object)
Tests if an Object is a List (Vector) suitable for an aggregate Parameter.

Note: The contents of the list are recursively checked to all be Parameters. Aggregates without lists are acceptable Parameters.

Parameters:
object - The Object to be tested.
Returns:
true if the object is an instance of the Vector class and all its elements are Parameters; otherwise false (also false if the object is null, though a null list is acceptable [hmmm]).
See Also:
Is_Parameter(Object), Is_Begin_Aggregate()

Is_Token

public boolean Is_Token()
Tests if the Parameter is classified as a token.

Returns:
true if the Parameter is a token.
See Also:
TOKEN

Is_End

public boolean Is_End()
Tests if the Parameter is one of the END classifications.

END classifcations include both the end of aggregates (END_GROUP and END_OBJECT) and the end the entire hierarchy (END_PVL)

Returns:
true if the the Parameter has an END classification.
See Also:
END

Is_End_PVL

public boolean Is_End_PVL()
Tests if the Parameter is the END_PVL classification.

Returns:
true if the Parameter has the END_PVL classification.
See Also:
END_PVL

Is_Assignment

public boolean Is_Assignment()
Tests if the Parameter is classified as an assignment.

An assignment Parameter does not necessarily have a Value (it may be null).

Returns:
true if the Parameter is a Value assignment.
See Also:
ASSIGNMENT

Has_Value

public boolean Has_Value()
Tests if the Parameter has a valid Value assigment.

Returns:
true if the Parameter has a Value assignment.
See Also:
Is_Assignment()

Is_Aggregate

public boolean Is_Aggregate()
Tests if the Parameter is classified as an aggregate.

An aggregate Parameter does not necessarily have a aggregate list (it may be null). Aggregate classifications include GROUP (and its alias BEGIN_GROUP), OBJECT (and its alias BEGIN_OBJECT), and the END_GROUP and END_OBJECT forms.

Returns:
true if the Parameter has an aggregate classification.
See Also:
AGGREGATE

Has_List

public boolean Has_List()
Tests if the Parameter has an aggregate list.

The contents of the list are not checked (use Is_Parameter_List to check the list contents).

Returns:
true if the Parameter has an aggregate list.
See Also:
Is_Aggregate()

Is_Begin_Aggregate

public boolean Is_Begin_Aggregate()
Tests if the Parameter is classified as an aggregate beginning.

An aggregate beginning is the Parameter that contains a list of Parameters (the aggregate list, which may be empty or null); i.e. it "begins" an aggregate list. Begin aggregate classifications include GROUP (and its alias BEGIN_GROUP) and OBJECT (and its alias BEGIN_OBJECT).

Returns:
true if the Parameter begins (contains) an aggregate.
See Also:
AGGREGATE

Is_End_Aggregate

public boolean Is_End_Aggregate()
Tests if the Parameter is classified as an aggregate ending.

An aggregate ending is the Parameter that ends a list of Parameters (the aggregate list). End aggregate classifications include END_GROUP and END_OBJECT.

Returns:
true if the Parameter ends an aggregate list.
See Also:
END_AGGREGATE

Is_Object

public boolean Is_Object()
Tests if the Parameter is classified as an object aggregate.

The OBJECT classification is identical to the BEGIN_OBJECT classification.

Returns:
true if the Parameter is an object aggregate.

Is_Begin_Object

public boolean Is_Begin_Object()
Tests if the Parameter is classified as beginning an object aggregate.

The BEGIN_OBJECT classification is identical to the OBJECT classification.

Returns:
true if the Parameter begins an object aggregate.

Is_End_Object

public boolean Is_End_Object()
Tests if the Parameter is classified as ending an object aggregate list.

Returns:
true if the Parameter ends an object aggregate.
See Also:
Is_End_Aggregate()

Is_Group

public boolean Is_Group()
Tests if the Parameter is classified as a group aggregate.

The GROUP classification is identical to the BEGIN_GROUP classification.

Returns:
true if the Parameter is a group aggregate.

Is_Begin_Group

public boolean Is_Begin_Group()
Tests if the Parameter is classified as beginning a group aggregate.

The BEGIN_GROUP classification is identical to the GROUP classification.

Returns:
true if the Parameter begins a group aggregate.

Is_End_Group

public boolean Is_End_Group()
Tests if the Parameter is classified as ending a group aggregate list.

Returns:
true if the Parameter ends a group aggregate.
See Also:
Is_End_Aggregate()

Is_Unknown

public boolean Is_Unknown()
Tests if the Parameter is classified as UNKNOWN (an empty Parameter).

Returns:
true if the Parameter is an UNKNOWN classification.
See Also:
UNKNOWN

Is_Token

public static boolean Is_Token(int class_code)
Tests for the token classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for a token.
See Also:
TOKEN

Is_End

public static boolean Is_End(int class_code)
Tests for an END classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for an END classification.
See Also:
Is_End(), END_AGGREGATE, END_PVL

Is_End_PVL

public static boolean Is_End_PVL(int class_code)
Tests for the END_PVL classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is the END_PVL classification.
See Also:
END_PVL

Is_Assignment

public static boolean Is_Assignment(int class_code)
Tests for the assignment classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for an assignment.
See Also:
ASSIGNMENT

Is_Aggregate

public static boolean Is_Aggregate(int class_code)
Tests for an aggregate classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for an aggregate classification.
See Also:
Is_Aggregate()

Is_Begin_Aggregate

public static boolean Is_Begin_Aggregate(int class_code)
Tests for an aggregate beginning classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for an aggregate beginning.
See Also:
Is_Begin_Aggregate()

Is_End_Aggregate

public static boolean Is_End_Aggregate(int class_code)
Tests for an aggregate ending classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for the end of an aggregate list.
See Also:
Is_End_Aggregate(), END_AGGREGATE

Is_Object

public static boolean Is_Object(int class_code)
Tests for the object aggregate classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for an object aggregate.
See Also:
Is_Object()

Is_Begin_Object

public static boolean Is_Begin_Object(int class_code)
Tests fpr the begin object aggregate classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for a begin object aggregate.
See Also:
Is_Begin_Object()

Is_End_Object

public static boolean Is_End_Object(int class_code)
Tests for the end object aggregate list classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for the end of an object aggregate list.
See Also:
Is_End_Object()

Is_Group

public static boolean Is_Group(int class_code)
Tests for the group aggregate classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for a group aggregate.
See Also:
Is_Group()

Is_Begin_Group

public static boolean Is_Begin_Group(int class_code)
Tests for the begin group aggregate classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for a begin group aggregate.
See Also:
Is_Begin_Group()

Is_End_Group

public static boolean Is_End_Group(int class_code)
Tests for the end group aggregate list classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is for the end of a group aggregate list.
See Also:
Is_End_Group()

Is_Unknown

public static boolean Is_Unknown(int class_code)
Tests for the UNKNOWN classification.

Parameters:
class_code - The classification code int.
Returns:
true if the class_code is the UNKNOWN classification.
See Also:
UNKNOWN

Comments

public String Comments()
Gets the comments String.

Returns:
The String of comments associated with the Parameter. This will be null if the Parameter has no comments.

Comments

public Parameter Comments(String comments)
Sets the comments String.

Parameters:
comments - The String to become the Parameter comments. This may be null to remove all comments.
Returns:
This Parameter.

Parent

public Parameter Parent()
Gets the Parameter that is this Parameter's parent.

A parent Parameter is always an aggregate that contains this Parameter in its aggregate list.

Returns:
The parent aggregate Parameter that contains this Parameter, or null if this Parameter has no parent.

Warning

public PVL_Exception Warning()
Gets the current warning status.

When conditions are encountered that are unusual enough to warrant attention, but not an error condition that would prevent successful processing which would cause an exception to be thrown, a warning condition is registered. The warning is in the form of a PVL_Exception that was not thrown. The current warning status is either the First_Warning or the Last_Warning since a Reset_Warning.

Returns:
The current warning status as a PVL_Exception object, or null if no warning condition is registered.
See Also:
PVL_Exception, First_Warning(boolean), Last_Warning(boolean), Reset_Warning()

Reset_Warning

public Parameter Reset_Warning()
Clears any warning status so that the Warning method will return null until the next warning condition occurs.

Returns:
This Parameter.
See Also:
Warning()

First_Warning

public Parameter First_Warning(boolean first)
Enables or disables returning the first warning that occurs as the current warning status.

The first warning is one that occurs when the current warning status is null.

Parameters:
first - true to enable returning the first warning status; false to return the last warning that occurred as the current warning status.
Returns:
This Parameter.
See Also:
Warning(), First_Warning(), Reset_Warning()

First_Warning

public PVL_Exception First_Warning()
Returns the first warning since the last Reset_Warning.

Returns:
The first warning status as a PVL_Exception object, or null if no warning condition is registered.
See Also:
PVL_Exception, Warning(), First_Warning(boolean), Reset_Warning()

Last_Warning

public Parameter Last_Warning(boolean last)
Enables or disables returning the last warning that occurs as the current warning status.

The last warning is the most recent one regarless of any previous warning conditions that may have occured without an intervening Reset_Warning.

Parameters:
last - true to enable returning the last warning status; false to return the first warning condition that occurred as the current warning status.
Returns:
This Parameter.
See Also:
Warning(), Last_Warning(), Reset_Warning()

Last_Warning

public PVL_Exception Last_Warning()
Returns the last warning since a Reset_Warning.

Returns:
The last warning status as a PVL_Exception object, or null if no warning condition is registered.
See Also:
PVL_Exception, Warning(), Last_Warning(boolean), Reset_Warning()

clone

public Object clone()
Makes a deep copy of the Parameter.

Overrides:
clone in class DefaultMutableTreeNode
Returns:
An Object of class Parameter that is a copy of this Parameter.
See Also:
Parameter(Parameter), Object.clone(), Cloneable

Match

public boolean Match(Parameter parameter,
                     Selector criteria)
Tests if a Parameter matches this Parameter using the specified criteria.

Parameters:
parameter - The Parameter to be compared to this Parameter.
criteria - The Selector providing the comparison criteria.
Returns:
true if there is a criteria match; false otherwise.
See Also:
Selector, Selection

Match_Depth

public boolean Match_Depth(Parameter parameter,
                           Selector criteria)
Tests if a Parameter matches this Parameter using the specified criteria.

If the Parameter is an Aggregate matching is done recursively on all Parameters of the Aggregate. The match succeeds if all Parameters match.

N.B.: To avoid unnecessary redundant recursive comparisons of Aggregate parameter values if the Value criteria is included in the selection the data comparison is only done for non-Aggregate Parameters.

Parameters:
parameter - The Parameter to be compared to this Parameter.
criteria - The Selector providing the comparison criteria.
Returns:
true if there is a criteria match; false otherwise.
See Also:
Selector, Selection

equals

public boolean equals(Object object)
Tests if an Object is equal to this Parameter.

An Object is equal to this Parameter when it is also a Parameter object and all of its contents are equal to this Parameter's contents. A Selection object with PARAMETER_MATCH criteria is used with the Match_Depth method.

Overrides:
equals in class Object
Parameters:
object - The Object to be compared to this Parameter.
Returns:
true if the object equals this Parameter, false otherwise.
See Also:
Match_Depth(Parameter, Selector), Selection, Selector.PARAMETER_MATCH

equalsIgnoreCase

public boolean equalsIgnoreCase(Parameter parameter)
Tests if a Parameter is equivalent to this Parameter, ignoring certain cases where field values are not equal.

Unlike equals, for a Parameter to be equivalent to this Parameter the contents need only be logically equivalent, rather than containing the identical contents. For example, shortening the parameter list of an Aggregate by setting to END_AGGREGATE the classification of the first entry that is different from the entries of another aggregate will result in the two aggregates being logically equivalent. A Selection object with PARAMETER_MATCH but Specific (false) criteria is used with the Match_Depth method.

Parameters:
parameter - The Parameter to be compared to this Parameter.
Returns:
true if the Parameter is logically equivalent to this Parameter, false otherwise.
See Also:
Match_Depth(Parameter, Selector), Selection, Selector.PARAMETER_MATCH, Selection.Specific(boolean)

Write

public int Write(Lister lister)
          throws PVL_Exception,
                 IOException
Writes the Parameter in PVL syntax using a PVL Lister.

Parameters:
lister - The Lister to write the Parameter.
Returns:
The total number of bytes written.
Throws:
PVL_Exception -
BAD_ARGUMENT
If an element in an aggregate list is not a Parameter.
IOException - From the Lister's Write method.
See Also:
Lister.Write(Parameter)

Write

public int Write(OutputStream output,
                 int level,
                 boolean strict)
          throws PVL_Exception,
                 IOException
Writes the Parameter in PVL syntax to an OutputStream.

A Lister is created with the output stream as its list destination using specified indent level and syntax strictness.

Parameters:
output - The OutputStream to receive what is written. If output is null System.out is used.
level - The indent level at which to start the listing. If the level is negative, indenting is disabled.
strict - Use strict PVL syntax if true; otherwise use an easier to read format.
Returns:
The total number of bytes written.
Throws:
PVL_Exception -
BAD_ARGUMENT
If an element in an aggregate list is not a Parameter.
IOException - From the Lister's Write method.
See Also:
Lister.Write(Parameter)

Write

public int Write()
          throws PVL_Exception,
                 IOException
Writes the Parameter in PVL syntax to System.out starting at level 0, not strict.

Returns:
The total number of bytes written.
Throws:
PVL_Exception -
BAD_ARGUMENT
If an element in an aggregate list is not a Parameter.
IOException - From the OutputStream write method.
See Also:
Write(OutputStream, int, boolean)

Write

public int Write(boolean indent)
          throws PVL_Exception,
                 IOException
Writes the Parameter in PVL syntax to System.out with or without indenting, not strict.

Parameters:
indent - Enable indenting starting at level 0 if true; disable indenting otherwise.
Returns:
The total number of bytes written.
Throws:
PVL_Exception -
BAD_ARGUMENT
If an element in an aggregate list is not a Parameter.
IOException - From the OutputStream write method.
See Also:
Write(OutputStream, int, boolean)

Write

public int Write(boolean indent,
                 boolean strict)
          throws PVL_Exception,
                 IOException
Writes the Parameter in PVL syntax to output System.out with indenting and strict PVL enabled or disabled.

Parameters:
indent - Enable indenting starting at level 0 if true; disable indenting otherwise.
strict - Use strict PVL syntax if true; otherwise use an easier to read format.
Returns:
The total number of bytes written.
Throws:
PVL_Exception -
BAD_ARGUMENT
If an element in an aggregate list is not a Parameter.
IOException - From the OutputStream write method.
See Also:
Write(OutputStream, int, boolean)

Write

public int Write(OutputStream output)
          throws PVL_Exception,
                 IOException
Writes the Parameter in PVL syntax to the output starting at level 0, not strict.

Parameters:
output - The OutputStream to receive what is written.
Returns:
The total number of bytes written.
Throws:
PVL_Exception -
BAD_ARGUMENT
If an element in an aggregate list is not a Parameter.
IOException - From the OutputStream write method.
See Also:
Write(OutputStream, int, boolean)

Write

public int Write(OutputStream output,
                 boolean indent)
          throws PVL_Exception,
                 IOException
Writes the Parameter in PVL syntax to the output with or without indenting, not strict.

Parameters:
output - The OutputStream to receive what is written.
indent - Enable indenting starting at level 0 if true; disable indenting otherwise.
Returns:
The total number of bytes written.
Throws:
PVL_Exception -
BAD_ARGUMENT
If an element in an aggregate list is not a Parameter.
IOException - From the OutputStream write method.
See Also:
Write(OutputStream, int, boolean)

Write

public int Write(OutputStream output,
                 boolean indent,
                 boolean strict)
          throws PVL_Exception,
                 IOException
Writes the Parameter in PVL syntax to the output with indenting and strict PVL enabled or disabled.

Parameters:
output - The OutputStream to receive what is written.
indent - Enable indenting starting at level 0 if true; disable indenting otherwise.
strict - Use strict PVL syntax if true; otherwise use an easier to read format.
Returns:
The total number of bytes written.
Throws:
PVL_Exception -
BAD_ARGUMENT
If an element in an aggregate list is not a Parameter.
IOException - From the OutputStream write method.
See Also:
Write(OutputStream, int, boolean)

iterator

public Iterator iterator(int index)
Provides an Iterator for the aggregate list positioned so that the next element returned will be at the specified index of the list.

This Iterator does not descend into the lists of aggregate Parameters in the current list. The DefaultMutableTreeNode base class provdes various Enumeration objects that will traverse the hierarchy in different orders.

In addition to implementing the Iterator interface, the implementation for a Parameter treats END Parameters as the end of the list. The hasNext method will return false when the next Parameter in the list has an END classification. To distinguish this case from the usual case when the end of the list has been reached, the next method will include this information when it throws NoSuchElementException at the end of the list. If the end of the list is as result of an END Parameter, then the getMessage method for the exception will contain the Classification_Name as the first line (String terminated by a new-line ('\n') character) of the message String. Otherwise the message will only contain the ID of the Parameter class module (in all cases a non-null message String will be provided). For example:

Iterator list = aggregate.iterator ();
while (list.hasNext ())
    {
    Parameter parameter = (Parameter)list.next ();
    // Do something with the parameter.
    }
try {list.next ();}
catch (NoSuchElementException exception)
    {
    if (exception.getMessage ().startsWith
        (Parameter.Classification_Name (Parameter.END)))
        {
        if (exception.getMessage ().startsWith
            (Parameter.Classification_Name (Parameter.END_PVL) + '\n'))
            // The END_PVL Parameter was encountered.
        else
            // An END_AGGREGATE was encountered.
        }
    }

A starting index beyond an END Parameter may be specified to skip over it.

For non-aggregate Parameters an "empty" Iterator will be provided. This will act the same as an Iterator on an empty list.

Parameters:
index - The starting list element.
Returns:
An Iterator object.
See Also:
Iterator, Classification_Name(), DefaultMutableTreeNode

iterator

public Iterator iterator()
Provides an Iterator starting at the first element of the list.

Returns:
An Iterator object.
See Also:
iterator(int)

listIterator

public ListIterator listIterator(int index)
Provides a ListIterator for the aggregate list positioned so that the next element returned will be at the specified index of the list.

The functionality of the Parameter Iterator is provided (which it extends) with the ListIterator interface implemented.

As with the Parameter Iterator, END Parameters are treated as the end of the list. During reverse iteration (hasPrevious and previous) END Parameters mark an artificial beginning of the list, when the start index is positioned beyond one. In this case the same special message is provided with the NoSuchElementException object as for the next method.

Note: When the Parameter is an aggregate, but has no list, an empty one is provided so the add method will be able to insert new Parameters into the list.

Parameters:
index - The starting list element.
Returns:
A ListIterator object.
See Also:
iterator(), ListIterator

listIterator

public ListIterator listIterator()
Provides a ListIterator starting at the first element of the list.

Returns:
A ListIterator object.
See Also:
listIterator(int)

Find

public Parameter Find(Parameter test_parameter,
                      Selector criteria,
                      Parameter last_parameter)
Searches for a Parameter that matches a test Parameter according the Selector criteria, optionally after some specific Parameter object has been located first.

A search is made of the Parameters contained in this aggregate, and, recursively, any aggregates it contains. The search is depth-wise: each aggregate Parameter is searched when it is encountered.

The search must first find the last_parameter (having the same object reference) before proceeding with the search for the test_parameter beginning with the Parameter following the last_parameter. If the last_parameter is null, then the search for the test_parameter begins with the first Parameter contained in this aggregate.

The search compares each Parameter encountered against the test_parameter using the Selector criteria's Parameters_Match method. The first Parameter that matches the test_parameter is returned. If the last_parameter or a match for the test_parameter is not found, null is returned. If the last_parameter could not be found a PVL_Exception.NO_LAST_LOCATION warning status is registered with this Parameter. If this Parameter in which to Find is not an aggregate, null will be returned and a PVL_Exception.ILLEGAL_SYNTAX warning status will be set.

The test_parameter may be any parameter, pre-existing or created ad hoc as a template for the Selector criteria. A Selector offers numerous criteria that may be conditionally applied when comparing the test_parameter with prospective mathing parameters. Note: The PIRL.PVL package provides a Selection class that implements the Selector interface.

In addition, when the Selector criteria enables Name matching the search engine will provide pathname tracking. This allows the name of the test_parameter to be a full (absolute) or partial (relative) pathname to a Parameter, of the form:

[ / ] Name [ /Name [...] ]

The name of the test_parameter may be a simple name; i.e. it contains no Path_Delimiter characters. In this case a Parameter will be selected when its name matches the test_parameter name entirely. A pathname beginning with a Path_Delimiter character is "absolute" in that a Parameter with a Name that matches the first segment of the pathname must be found in this Parameter's aggregate list - the root of the Find - before the next segment of the pathname will qualify for a match of a Parameter Name in the aggregate list of the first Parameter matched; etc. Note: The first name of an absolute pathname is not the name of this Parameter, it is the name of the Parameter to find in the root aggregate list. All Parameters in the pathname sequence must, of course, be aggregates except the last Parameter (which may be of any classification). This is the same as file pathnames in Unix. A pathname that does not begin with a Path_Delimiter is "relative" in that the first Name is searched for like a simple name and then the remainder of the path is searched for relative to the location of the first Parameter found. The remainder of the pathname after the first name is treated like an absolute pathname.

N.B.: The current warning status is reset before the search begins.

Parameters:
test_parameter - A Parameter object to use for testing Parameters in this aggregate for a match. If null, or its Name is null, null is immediately returned.
criteria - A Selector object providing the methods to determine if Parameters match.
last_parameter - A Parameter object to be found within the aggregate before search comparisons begin. If null, begin the search at the first element of the aggregate list.
Returns:
The Parameter object that was found, or null if not found. If the Parameter in which to Find is not an aggregate, null will be returned and a PVL_Exception.ILLEGAL_SYNTAX warning status will be set. If the last_parameter could not be found a PVL_Exception.NO_LAST_LOCATION warning status is registered with this Parameter.
See Also:
Selector, Selection.Parameters_Match(Parameter, Parameter), Path_Name()

Find

public Parameter Find(String name)
Finds the Parameter with the specified name, which may be a simple name or a pathname.

The name string matching is case sensitive.

Parameters:
name - The name or pathname String to search for. If null, the empty String will be used.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(String, boolean, Parameter)

Find

public Parameter Find(String name,
                      Parameter last_parameter)
Finds the Parameter with the specified name, which may be a simple name or a pathname, beginning after the specified Parameter object within the aggregate.

The name string matching is case sensitive.

Parameters:
name - The name or pathname String to search for. If null, the empty String will be used.
last_parameter - A Parameter object to be found within the aggregate before search comparisons begin. If null, begin the search at the first element of the aggregate list.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(String, boolean, Parameter)

Find

public Parameter Find(String name,
                      boolean case_sensitive)
Finds the Parameter with the specified name, which may be a simple name or a pathname.

Parameters:
name - The name or pathname String to search for. If null, the empty String will be used.
case_sensitive - true for the case sensitive name matching; false for case insensitive name matching.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(String, boolean, Parameter)

Find

public Parameter Find(String name,
                      boolean case_sensitive,
                      Parameter last_parameter)
Finds the Parameter with the specified name, which may be a simple name or a pathname, beginning after the specified Parameter object within the aggregate.

Parameters:
name - The name or pathname String to search for. If null, the empty String will be used.
case_sensitive - true for the case sensitive name matching; false for case insensitive name matching.
last_parameter - A Parameter object to be found within the aggregate before search comparisons begin. If null, begin the search at the first element of the aggregate list.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(Parameter, Selector, Parameter), Selection.Name(boolean), Selection.Specific(boolean)

Find

public Parameter Find(int classification)
Finds the Parameter having the specified classification.

The classification matching is exact. For a general classification match - e.g. a GROUP will match with an OBJECT - use:

Find (new Parameter ().Classification (classification),
      new Selection ().Classification (true).Specific (false));

Parameters:
classification - The classification code to search for.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(Parameter, Selector, Parameter)

Find

public Parameter Find(int classification,
                      Parameter last_parameter)
Finds the Parameter having the specified classification, beginning after the specified Parameter object within the aggregate.

Parameters:
classification - The classification code to search for.
last_parameter - A Parameter object to be found within the aggregate before search comparisons begin. If null, begin the search at the first element of the aggregate list.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(int), Find(Parameter, Selector, Parameter)

Find

public Parameter Find(String name,
                      int classification)
Finds the Parameter having the specified pathname and classification.

Parameter pathname matching is specific (case sensitive) but classification matching is non-specific (any Aggregate type).

Parameters:
name - The name or pathname String to search for. If null, the empty String will be used.
classification - The classification code to search for.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(String, int, Parameter)

Find

public Parameter Find(String name,
                      int classification,
                      Parameter last_parameter)
Finds the Parameter having the specified pathname and classification, beginning after the specified Parameter object within the aggregate.

Parameter pathname matching is specific (case sensitive) but classification matching is non-specific (any Aggregate type).

Parameters:
name - The name or pathname String to search for. If null, the empty String will be used.
classification - The classification code to search for.
last_parameter - A Parameter object to be found within the aggregate before search comparisons begin. If null, begin the search at the first element of the aggregate list.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(String), Find(int), Find(Parameter, Selector, Parameter)

Find

public Parameter Find(Parameter test_parameter)
Finds the Parameter that completely matches a test Parameter.

A complete match requires an exact match of the name (which may be a pathname), classification, comments, and Value when the Parameter is an assignment. The Value match requires that the data and its type (as well as the numeric base for integers), and any units String all be exactly equal. Note: Parameter contents, not Parameter object references, are compared.

Parameters:
test_parameter - The Parameter to use when testing for a match.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(Parameter, Selector, Parameter)

Find

public Parameter Find(Parameter test_parameter,
                      Parameter last_parameter)
Finds the Parameter that completely matches a test Parameter, beginning after the specified Parameter object within the aggregate.

Parameters:
test_parameter - The Parameter to use when testing for a match.
last_parameter - A Parameter object to be found within the aggregate before search comparisons begin. If null, begin the search at the first element of the aggregate list.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(Parameter), Find(Parameter, Selector, Parameter)

Find

public Parameter Find(Parameter test_parameter,
                      Selector criteria)
Finds the Parameter that matches a test Parameter according the Selector criteria.

Parameters:
test_parameter - The Parameter to use when testing for a match.
criteria - A Selector object providing the methods to determine if Parameters match.
Returns:
The Parameter object that was found, or null if not found.
See Also:
Find(Parameter, Selector, Parameter)

setUserObject

public void setUserObject(Object object)
Overrides the base class method to ensure Parameter integrity.

Specified by:
setUserObject in interface MutableTreeNode
Overrides:
setUserObject in class DefaultMutableTreeNode
Parameters:
object - Since the userObject of a Parameter is it's name, only String objects are allowed for the argument. Anything else is ignored and a PVL_Exception.BAD_ARGUMENT warning status is set.
See Also:
DefaultMutableTreeNode.setUserObject(Object)

setAllowsChildren

public void setAllowsChildren(boolean allows)
Overrides the base class method to ensure Parameter integrity.

Overrides:
setAllowsChildren in class DefaultMutableTreeNode
Parameters:
allows - Since the ability of a Parameter to have children is totally determined by its classification (only aggregates may have a children list), this argument is ignored and a PVL_Exception.ILLEGAL_SYNTAX warning status is set.
See Also:
DefaultMutableTreeNode.setAllowsChildren(boolean)

add

public void add(MutableTreeNode parameter)
         throws IllegalArgumentException
Invokes the Parameter's Add method.

Overrides:
add in class DefaultMutableTreeNode
Parameters:
parameter - A MutableTreeNode that must be a Parameter object.
Throws:
IllegalArgumentException - If the parameter argument is not a Parameter object, or the Add method threw a PVL_Exception (in which case it's message is used for the exception message).
See Also:
Add(Parameter), DefaultMutableTreeNode.add(MutableTreeNode)

insert

public void insert(MutableTreeNode parameter,
                   int index)
            throws IllegalArgumentException
Invokes the Parameter's Insert method.

Specified by:
insert in interface MutableTreeNode
Overrides:
insert in class DefaultMutableTreeNode
Parameters:
parameter - A MutableTreeNode that must be a Parameter object.
index - The index in the aggregate list where the Parameter is to be inserted.
Throws:
IllegalArgumentException - If the parameter argument is not a Parameter object, or the Insert method threw a PVL_Exception (in which case it's message is used for the exception message).
See Also:
Insert(Parameter, int), DefaultMutableTreeNode.insert(MutableTreeNode, int)

remove

public void remove(int index)
Invokes the Parameter's Remove method.

Specified by:
remove in interface MutableTreeNode
Overrides:
remove in class DefaultMutableTreeNode
Parameters:
index - The index of the element in the aggregate list to remove.
See Also:
Remove(int), DefaultMutableTreeNode.remove(int)

remove

public void remove(MutableTreeNode parameter)
            throws IllegalArgumentException
Invokes the Parameter's Remove method.

Specified by:
remove in interface MutableTreeNode
Overrides:
remove in class DefaultMutableTreeNode
Parameters:
parameter - A MutableTreeNode that must be a Parameter object.
Throws:
IllegalArgumentException - If the parameter argument is not a Parameter object.
See Also:
Remove(Parameter), DefaultMutableTreeNode.remove(MutableTreeNode)

PIRL

Copyright (C) \ 2003-2009 Bradford Castalia, University of Arizona