org.griphyn.vdl.classes
Class List

java.lang.Object
  extended by org.griphyn.vdl.Chimera
      extended by org.griphyn.vdl.classes.VDL
          extended by org.griphyn.vdl.classes.Value
              extended by org.griphyn.vdl.classes.List
All Implemented Interfaces:
Serializable, Cloneable

public class List
extends Value
implements Cloneable, Serializable

This class implements the list argument type used for parameters passed to transformations from derivations.

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

Field Summary
private  ArrayList m_scalarList
          A list is just an ordered bunch of Scalar.
 
Fields inherited from class org.griphyn.vdl.classes.Value
LIST, SCALAR
 
Constructor Summary
List()
          Default ctor.
List(Scalar firstChild)
          Convenience ctor: Initializes the list, and stores the given Scalar as first child into the list.
 
Method Summary
 void addScalar(int index, Scalar vScalar)
          Accessor: Insert a Scalar at a specific position.
 void addScalar(Scalar vScalar)
          Accessor: Appends as Scalar value to the list.
 Object clone()
          Creates and returns a copy of this object.
 boolean containsLFN(String filename, int linkage)
          Determines if the list contains an LFN of the specified linkage.
 Enumeration enumerateScalar()
          Deprecated. Use the new Collection based interfaces
 List getAllLFN(int linkage)
          Determines all LFN instances of a given scalar that match the specified linkage.
 int getContainerType()
          Accessor: Obtains the value type of this class.
 List getLFNList(int linkage)
          Determines all LFN instances of a given scalar that match the specified linkage.
 Scalar[] getScalar()
          Deprecated. Use the new Collection based interfaces
 Scalar getScalar(int index)
          Accessor: Obtains the value of a specific item in the list.
 int getScalarCount()
          Accessor: Obtains the element count of the internal list
 List getScalarList()
          Accessor: Gets an array of all Scalars in the list.
 String getSymbolicType()
          This method determines which container is being used in the abstract base class in order to kludgy statements when printing debug info.
 Iterator iterateScalar()
          Accessor: constructs the iterator for the List items.
 ListIterator listIterateScalar()
          Accessor: constructs the iterator for the List items.
 ListIterator listIterateScalar(int start)
          Accessor: constructs the iterator for the List items.
 void removeAllScalar()
          Accessor: Removes all elements in the List.
 Scalar removeScalar(int index)
          Accessor: Removes a single element from the List.
 void setScalar(Collection scalars)
          Accessor: Replaces all elements with a new list of Scalars.
 void setScalar(int index, Scalar vScalar)
          Accessor: Overwrite an element at a given position.
 void setScalar(Scalar[] scalarArray)
          Deprecated. Use the new Collection based interfaces
 void toString(Writer stream)
          Dumps the list and all its contents into a string.
 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.classes.Value
getName, isInRange, setName
 
Methods inherited from class org.griphyn.vdl.Chimera
escape, quote, toString, toXML, toXML, writeAttribute
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_scalarList

private ArrayList m_scalarList
A list is just an ordered bunch of Scalar.

Constructor Detail

List

public List()
Default ctor.


List

public List(Scalar firstChild)
Convenience ctor: Initializes the list, and stores the given Scalar as first child into the list.

Parameters:
firstChild - is the first element in the list
Method Detail

clone

public Object clone()
Creates and returns a copy of this object.

Specified by:
clone in class Value
Returns:
a new instance.

getContainerType

public int getContainerType()
Accessor: Obtains the value type of this class. By using the abstract method in the parent class, List objects can be distinguished from Scalar objects without using the instanceof operator.

Specified by:
getContainerType in class Value
Returns:
the fixed value of being a scalar.
See Also:
Value.LIST

getSymbolicType

public String getSymbolicType()
This method determines which container is being used in the abstract base class in order to kludgy statements when printing debug info.

Specified by:
getSymbolicType in class Value
Returns:
the symblic identifier for the type of the Value.

addScalar

public void addScalar(Scalar vScalar)
               throws IndexOutOfBoundsException
Accessor: Appends as Scalar value to the list.

Parameters:
vScalar - is the Scalar to append to the list.
Throws:
IndexOutOfBoundsException - if the value cannot be added.
See Also:
Scalar

addScalar

public void addScalar(int index,
                      Scalar vScalar)
               throws IndexOutOfBoundsException
Accessor: Insert a Scalar at a specific position.

Parameters:
index - is the position to insert the item into
vScalar - is the Scalar to append to the list.
Throws:
IndexOutOfBoundsException - if the value cannot be added.
See Also:
Scalar

enumerateScalar

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

Accessor: constructs the iterator for the List items.

Returns:
an enumeration to walk the list with.

getAllLFN

public List getAllLFN(int linkage)
Determines all LFN instances of a given scalar that match the specified linkage. This is a higher-level method employing the given API.

Specified by:
getAllLFN in class Value
Parameters:
linkage - is the linkage to check for, -1 for all filenames.
Returns:
a set of logical filename instances that match the linkage and were part of the scalar. The result may be an empty set, if no such result were to be found.
See Also:
Scalar.getAllLFN( int ), LFN

getLFNList

public List getLFNList(int linkage)
Determines all LFN instances of a given scalar that match the specified linkage. This is a higher-level method employing the given API. Note that also linkage of NONE will not be found in wildcard search mode.

Specified by:
getLFNList in class Value
Parameters:
linkage - is the linkage to check for, -1 for all filenames.
Returns:
a set of all logical filenames that match the linkage and were part of the scalar. The result may be an empty set, if no such result were to be found. For a linkage of -1, complete LFNs will be returned, for any other linkage, just the filename will be returned.
See Also:
Scalar.getLFNList( int ), Derivation.getLFNList( int ), LFN

containsLFN

public boolean containsLFN(String filename,
                           int linkage)
Determines if the list contains an LFN of the specified linkage. The logic uses short-circuit evaluation, thus finding things is faster than not finding things. Searching a list is a potentially expensive method.

Specified by:
containsLFN in class Value
Parameters:
filename - is the name of the LFN
linkage - is the linkage to check for, -1 for any linkage type.
Returns:
true if the LFN is contained in the scalar, false otherwise.
See Also:
LFN, Scalar.containsLFN( String, int )

getScalar

public Scalar getScalar(int index)
                 throws IndexOutOfBoundsException
Accessor: Obtains the value of a specific item in the list.

Parameters:
index - is the position of which to obtain the value of.
Returns:
The Scalar at the specified position.
Throws:
IndexOutOfBoundsException - if the index points to an element that is beyond the list boundaries.

getScalar

public Scalar[] getScalar()
Deprecated. Use the new Collection based interfaces

Accessor: Gets an array of all Scalars in the list.

Returns:
an array of Scalars.
See Also:
Scalar

getScalarCount

public int getScalarCount()
Accessor: Obtains the element count of the internal list

Returns:
number of elements in the internal list

getScalarList

public List getScalarList()
Accessor: Gets an array of all Scalars in the list. This list is read-only.

Returns:
an array of Scalars.
See Also:
Scalar

iterateScalar

public Iterator iterateScalar()
Accessor: constructs the iterator for the List items.

Returns:
an enumeration to walk the list with.

listIterateScalar

public ListIterator listIterateScalar()
Accessor: constructs the iterator for the List items.

Returns:
an enumeration to walk the list with.

listIterateScalar

public ListIterator listIterateScalar(int start)
Accessor: constructs the iterator for the List items.

Parameters:
start - is the starting position for the sub-iteration.
Returns:
an enumeration to walk the list with.

removeAllScalar

public void removeAllScalar()
Accessor: Removes all elements in the List.


removeScalar

public Scalar removeScalar(int index)
Accessor: Removes a single element from the List. Each component in this vector with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously. The size of this vector is decreased by 1.

Parameters:
index - is the position at which an element is to be removed.
Returns:
the Scalar that was removed.
Throws:
ArrayIndexOutOfBoundsException - if the index was invalid.

setScalar

public void setScalar(int index,
                      Scalar vScalar)
               throws IndexOutOfBoundsException
Accessor: Overwrite an element at a given position.

Parameters:
index - is the position to use. It must be within the list.
vScalar - is the new value to replace the element with.
Throws:
IndexOutOfBoundsException - if the position is outside the list.

setScalar

public void setScalar(Scalar[] scalarArray)
Deprecated. Use the new Collection based interfaces

Accessor: Replaces all elements with a new list of Scalars.

Parameters:
scalarArray - is the list to replace the original list with.

setScalar

public void setScalar(Collection scalars)
Accessor: Replaces all elements with a new list of Scalars.

Parameters:
scalars - is the list to replace the original list with.

toString

public void toString(Writer stream)
              throws IOException
Dumps the list and all its contents into a string. The list will be terminated by brackets, elements separated by komma, space. Elements itself will be dumped by recursive calls to the element specific method of the same name.

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.
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.