org.griphyn.vdl.classes
Class Argument

java.lang.Object
  extended by org.griphyn.vdl.Chimera
      extended by org.griphyn.vdl.classes.VDL
          extended by org.griphyn.vdl.classes.Argument
All Implemented Interfaces:
Serializable

public class Argument
extends VDL
implements Serializable

A class to encapsulate a command line argument line. The command line is separated into a list of distinct fragments. Each fragment can only be of type Use or Text.

Version:
$Revision: 50 $
Author:
Jens-S. V??ckler, Yong Zhao
See Also:
Leaf, Text, Use, Serialized Form

Field Summary
private static String c_error_message
          Throws this message, if neither <text> nor <use> elements are tried to be added.
private  ArrayList m_leafList
          The command line consists of an ordered list of Leaf pieces, which in their sum create the commandline.
private  String m_name
          Each Argument is a fragment of the complete command line.
 
Constructor Summary
Argument()
          Array ctor.
Argument(String name)
          Standard ctor: Constructs a named Argument group.
Argument(String name, Leaf firstChild)
          Convenience ctor: Constructs a name argument group, and enters the first (and possibly only) fragment into the group.
 
Method Summary
 void addLeaf(int index, Leaf vLeaf)
          Accessor: Inserts a Leaf value into a specific position of this commandline group.
 void addLeaf(Leaf vLeaf)
          Accessor: Appends a commandline fragment to the current group.
 Enumeration enumerateLeaf()
          Deprecated. Use the new Collection based interfaces
 Leaf[] getLeaf()
          Deprecated. Use the new Collection based interfaces
 Leaf getLeaf(int index)
          Accessor: Obtains the Leaf at a certain position in the commandline argument group.
 int getLeafCount()
          Accessor: Obtains the size of the commandline group.
 List getLeafList()
          Accessor: Gets an array of all values that constitute the current content.
 String getName()
          Accessor: Obtains the current name of this commandline group.
 Iterator iterateLeaf()
          Accessor: Enumerates the internal values that constitute the content of the Scalar element.
 ListIterator listIterateLeaf()
          Accessor: Enumerates the internal values that constitute the content of the Scalar element.
 ListIterator listIterateLeaf(int start)
          Accessor: Enumerates the internal values that constitute the content of the Scalar element.
 void removeAllLeaf()
          Accessor: Removes all values from this commandline group.
 Leaf removeLeaf(int index)
          Accessor: Removes a specific fragment from this commandline group.
 void setLeaf(Collection leaves)
          Accessor: Overwrites internal list with an external list representing a Scalar value.
 void setLeaf(int index, Leaf vLeaf)
          Accessor: Overwrites a Use or Text value fragment at a certain position in this command line group.
 void setLeaf(Leaf[] leafArray)
          Deprecated. Use the new Collection based interfaces
 void setName(String name)
          Accessor: Replaces or sets the current identifier for this commandline group.
 void toString(Writer stream)
          Converts the commandline group into textual format for human consumption.
 void toXML(Writer stream, String indent, String namespace)
          Dump the state of the current element as XML output.
 
Methods inherited from class org.griphyn.vdl.Chimera
escape, quote, toString, toXML, toXML, writeAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

c_error_message

private static final String c_error_message
Throws this message, if neither <text> nor <use> elements are tried to be added.

See Also:
Constant Field Values

m_leafList

private ArrayList m_leafList
The command line consists of an ordered list of Leaf pieces, which in their sum create the commandline. Any value passed down is an arbitrary mix of the three potential Leaf types. Each element only allows for Text and Use children in arbitrary number and order.

See Also:
Leaf, Text, Use

m_name

private String m_name
Each Argument is a fragment of the complete command line. Each such group (of fragments) can be given a name. Special names of the stdio handles refer to these handles.

Constructor Detail

Argument

public Argument()
Array ctor.


Argument

public Argument(String name)
Standard ctor: Constructs a named Argument group.

Parameters:
name - is the identifier for the argument group.

Argument

public Argument(String name,
                Leaf firstChild)
Convenience ctor: Constructs a name argument group, and enters the first (and possibly only) fragment into the group.

Parameters:
name - is the unique identifier for the argument group.
firstChild - is the element to place into the argument group. Only Leafs of type Use or Text are permissable.
See Also:
Leaf, Use, Text
Method Detail

addLeaf

public void addLeaf(Leaf vLeaf)
             throws IndexOutOfBoundsException,
                    IllegalArgumentException
Accessor: Appends a commandline fragment to the current group.

Parameters:
vLeaf - is the fragment to add. Note that only leaf values of Use or Text are allowed.
Throws:
IndexOutOfBoundsException - if the value cannot be added.
IllegalArgumentException - if the value type is neither Use nor Text.
See Also:
Leaf, Text, Use

addLeaf

public void addLeaf(int index,
                    Leaf vLeaf)
             throws IndexOutOfBoundsException,
                    IllegalArgumentException
Accessor: Inserts a Leaf value into a specific position of this commandline group.

Parameters:
index - is the position to insert the item into
vLeaf - is the value to append to the list. Note that only leaf values of Use or Text are allowed.
Throws:
IndexOutOfBoundsException - if the value cannot be added.
IllegalArgumentException - if the value type is neither Use nor Text.
See Also:
Text, Use

enumerateLeaf

public Enumeration enumerateLeaf()
Deprecated. Use the new Collection based interfaces

Accessor: Enumerates the internal values that constitute the content this commandline group.

Returns:
the iterator to the commandline group internal list.

getLeaf

public Leaf getLeaf(int index)
             throws IndexOutOfBoundsException
Accessor: Obtains the Leaf at a certain position in the commandline argument group.

Parameters:
index - is the position in the list to obtain a value from
Returns:
The Use or Text at the position.
Throws:
IndexOutOfBoundsException - if the index points to an element in the list that does not contain any elments.
See Also:
Use, Text

getLeaf

public Leaf[] getLeaf()
Deprecated. Use the new Collection based interfaces

Accessor: Gets an array of all values that constitute the current value content of this commandline group. This array is a copy to avoid write-through modifications.

Returns:
an array with a mixture of either Text or Use values.
See Also:
Use, Text

getLeafCount

public int getLeafCount()
Accessor: Obtains the size of the commandline group.

Returns:
number of elements that an external array needs to be sized to.

getLeafList

public List getLeafList()
Accessor: Gets an array of all values that constitute the current content. This list is read-only.

Returns:
an array with a mixture of either Text or LFN values.
See Also:
LFN, Text

getName

public String getName()
Accessor: Obtains the current name of this commandline group.

Returns:
the name of this commandline group.
See Also:
setName(java.lang.String)

iterateLeaf

public Iterator iterateLeaf()
Accessor: Enumerates the internal values that constitute the content of the Scalar element.

Returns:
an iterator to walk the list with.

listIterateLeaf

public ListIterator listIterateLeaf()
Accessor: Enumerates the internal values that constitute the content of the Scalar element.

Returns:
an enumeration to walk the list with.

listIterateLeaf

public ListIterator listIterateLeaf(int start)
Accessor: Enumerates the internal values that constitute the content of the Scalar element.

Parameters:
start - is the start index
Returns:
an enumeration to walk the list with.

removeAllLeaf

public void removeAllLeaf()
Accessor: Removes all values from this commandline group.


removeLeaf

public Leaf removeLeaf(int index)
Accessor: Removes a specific fragment from this commandline group.

Parameters:
index - is the position at which an element is to be removed.
Returns:
the object that was removed. The removed item is either an Use or a Text.
See Also:
Use, Text

setLeaf

public void setLeaf(int index,
                    Leaf vLeaf)
             throws IndexOutOfBoundsException,
                    IllegalArgumentException
Accessor: Overwrites a Use or Text value fragment at a certain position in this command line group.

Parameters:
index - position to overwrite an elment in.
vLeaf - is either a Use or Text object.
Throws:
IndexOutOfBoundsException - if the position pointed to is invalid.
IllegalArgumentException - if the added element is of the incorrect Leaf type.
See Also:
Use, Text

setLeaf

public void setLeaf(Leaf[] leafArray)
Deprecated. Use the new Collection based interfaces

Accessor: Replaces the commandline group with another group value. Warning: The replacements are not checked for being of the correct leaf types.

Parameters:
leafArray - is the external list of Text or Use objects used to overwrite things.
See Also:
Text, Use

setLeaf

public void setLeaf(Collection leaves)
Accessor: Overwrites internal list with an external list representing a Scalar value.

Parameters:
leaves - is the external list of Text or LFN objects used to overwrite things.
See Also:
Text, LFN

setName

public void setName(String name)
Accessor: Replaces or sets the current identifier for this commandline group.

Parameters:
name - is the new identifier to use for this commandline group.
See Also:
getName()

toString

public void toString(Writer stream)
              throws IOException
Converts the commandline group into textual format for human consumption.

Specified by:
toString in class Chimera
Parameters:
stream - is a stream opened and ready for writing. This can also be a string stream for efficient output.
Throws:
IOException - if something fishy happens to the stream.

toXML

public void toXML(Writer stream,
                  String indent,
                  String namespace)
           throws IOException
Dump the state of the current element as XML output. This function traverses all sibling classes as necessary, and converts the data into pretty-printed XML output. The stream interface should be able to handle large output efficiently, if you use a buffered writer.

Specified by:
toXML in class Chimera
Parameters:
stream - is a stream opened and ready for writing. This can also be a string stream for efficient output.
indent - is a String of spaces used for pretty printing. The initial amount of spaces should be an empty string. The parameter is used internally for the recursive traversal. If a null value is specified, no indentation nor linefeeds will be generated.
namespace - is the XML schema namespace prefix. If neither empty nor null, each element will be prefixed with this prefix, and the root element will map the XML namespace.
Throws:
IOException - if something fishy happens to the stream.
See Also:
BufferedWriter


Copyright © 2007 The University of Southern California. All Rights Reserved.