org.griphyn.vdl.classes
Class Scalar

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.Scalar
All Implemented Interfaces:
Serializable, Cloneable

public class Scalar
extends Value
implements Cloneable, Serializable

This class implements one of the argument types for parameters passed to transformations from derivations.

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

Field Summary
private  ArrayList m_leafList
          Any value passed down is an arbitrary mix of the three potential Leaf types.
 
Fields inherited from class org.griphyn.vdl.classes.Value
LIST, SCALAR
 
Constructor Summary
Scalar()
          Default ctor.
Scalar(Leaf firstChild)
          Convenience ctor: Initializes the object with the first child to be put into the list of values.
 
Method Summary
 void addLeaf(int index, Leaf vLeaf)
          Accessor: Inserts a Leaf value into a specific position of the list of gathered values.
 void addLeaf(Leaf vLeaf)
          Accessor: Adds a Leaf value to the list of values gathered as the content of a Scalar.
 Object clone()
          Creates and returns a copy of this object.
 boolean containsLFN(String filename, int linkage)
          Determines if the scalar contains an LFN of the specified linkage.
 Enumeration enumerateLeaf()
          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.
 Leaf[] getLeaf()
          Deprecated. Use the new Collection based interfaces
 Leaf getLeaf(int index)
          Accessor: Obtains the Leaf at a certain position in the list of leaf values.
 int getLeafCount()
          Accessor: Obtains the size of the internal list of Leafs.
 List getLeafList()
          Accessor: Gets an array of all values that constitute the current content.
 List getLFNList(int linkage)
          Determines all LFN instances of a given scalar that match the specified linkage.
 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 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 the content of the Scalar.
 Leaf removeLeaf(int index)
          Accessor: Remove a single item from the list of nodes.
 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 LFN or Text value at a certain position in the content-constituting list.
 void setLeaf(Leaf[] leafArray)
          Deprecated. Use the new Collection based interfaces
 String toString()
          Converts the object state into textual format for human consumption.
 void toString(Writer stream)
          Converts the object state 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.classes.Value
getName, isInRange, setName
 
Methods inherited from class org.griphyn.vdl.Chimera
escape, quote, toXML, toXML, writeAttribute
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_leafList

private ArrayList m_leafList
Any value passed down is an arbitrary mix of the three potential Leaf types.

See Also:
Leaf, Text, LFN
Constructor Detail

Scalar

public Scalar()
Default ctor.


Scalar

public Scalar(Leaf firstChild)
Convenience ctor: Initializes the object with the first child to be put into the list of values.

Parameters:
firstChild - is either a LFN or Text object.
See Also:
Leaf, LFN, Text
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, Scalar objects can be distinguished from List objects without using the instanceof operator.

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

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.

addLeaf

public void addLeaf(Leaf vLeaf)
             throws IndexOutOfBoundsException
Accessor: Adds a Leaf value to the list of values gathered as the content of a Scalar.

Parameters:
vLeaf - is the value to append to the list. Note that only leaf values of LFN or Text are allowed.
Throws:
IndexOutOfBoundsException - if the value cannot be added.
See Also:
Leaf, Text, LFN

addLeaf

public void addLeaf(int index,
                    Leaf vLeaf)
             throws IndexOutOfBoundsException
Accessor: Inserts a Leaf value into a specific position of the list of gathered values.

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 LFN or Text are allowed.
Throws:
IndexOutOfBoundsException - if the value cannot be added.
See Also:
Text, LFN

enumerateLeaf

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

Accessor: Enumerates the internal values that constitute the content of the Scalar element.

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:
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:
Derivation.getLFNList( int ), LFN

containsLFN

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

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

getLeaf

public Leaf getLeaf(int index)
             throws IndexOutOfBoundsException
Accessor: Obtains the Leaf at a certain position in the list of leaf values.

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

getLeaf

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

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

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

getLeafCount

public int getLeafCount()
Accessor: Obtains the size of the internal list of Leafs.

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

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 iterator 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:
a list iterator to walk the list with.

removeAllLeaf

public void removeAllLeaf()
Accessor: Removes the content of the Scalar.


removeLeaf

public Leaf removeLeaf(int index)
Accessor: Remove a single item from the list of nodes. The list is shrunken in the process.

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

setLeaf

public void setLeaf(int index,
                    Leaf vLeaf)
             throws IndexOutOfBoundsException
Accessor: Overwrites a LFN or Text value at a certain position in the content-constituting list.

Parameters:
index - position to overwrite an elment in.
vLeaf - is either a LFN or Text object.
Throws:
IndexOutOfBoundsException - if the position pointed to is invalid.
See Also:
LFN, Text

setLeaf

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

Accessor: Overwrites internal list with an external list representing a Scalar value.

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

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

toString

public String toString()
Converts the object state into textual format for human consumption.

Overrides:
toString in class Chimera
Returns:
a textual description of the element and its sub-classes. Be advised that these strings might become large.

toString

public void toString(Writer stream)
              throws IOException
Converts the object state 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.
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.