satin.aro
Class AROcompoundDatum

java.lang.Object
  |
  +--satin.aro.AROdatum
        |
        +--satin.aro.AROcompoundDatum
Direct Known Subclasses:
AROincomingRequest, AROincomingResponse

public class AROcompoundDatum
extends AROdatum

This class defines an element of incoming data which contains other data elements. It is used to transmit arrays and structures, and also forms the base class for an entire incoming response to an ARO request. The elements contained within an AROcompoundDatum may be named or unnamed, but all the elements must be either named or unnamed. This rule does not recurse; if an AROcompoundDatum is contained within another, its contents may be either named or unnamed, regardless of whether the element itself is named or unnamed. By convention, the order of the data elements is not considered significant if the data elements are named.

Author:
Ed Stauff

Field Summary
static boolean debug
          Enables debugging statements.
 
Fields inherited from class satin.aro.AROdatum
gotten, name
 
Constructor Summary
protected AROcompoundDatum()
          Constructs an empty compound datum.
 
Method Summary
protected boolean addDatum(AROdatum d)
          Adds a datum.
void addToOutput(AROoutgoingData d, java.lang.String name)
          Copies the incoming data (this object) into the given outgoing data.
void dump(java.lang.String indent)
          Dumps the contents of the object for debugging.
boolean exists(int position, java.lang.String paramName)
          Returns whether a contained element, defined by name or position, exists.
AROdatum findByName(java.lang.String name)
          Returns the contained data element with the given name.
protected char firstChar(java.lang.StringBuffer input)
          Returns the first character of input.
java.lang.String getAROtypeName()
          Returns the ARO type name of the data element.
boolean getBoolean(int position)
          Returns the boolean value of the nth contained element.
boolean getBoolean(int position, java.lang.String paramName)
          Returns the boolean value of a contained element.
AROcompoundDatum getCompound()
          Returns the value of a compound data element.
AROcompoundDatum getCompound(int position)
          Returns the compound value of the nth contained element.
AROcompoundDatum getCompound(int position, java.lang.String paramName)
          Returns the compound value of a contained element.
int getCount()
          Returns the number of elements contained in this data element.
AROdatum getDatum(int position, java.lang.String paramName)
          Returns a contained element by name or position.
int getInteger(int position)
          Returns the integer value of the nth contained element.
int getInteger(int position, java.lang.String paramName)
          Returns the integer value of a contained element.
java.lang.String getName(int position)
          Returns the name of the nth contained data element.
AROdatum getNth(int position)
          Returns the nth contained data element.
AROobjectID getObjectID(int position)
          Returns the object value of the nth contained element.
AROobjectID getObjectID(int position, java.lang.String paramName)
          Returns the object value of a contained element.
double getReal(int position)
          Returns the real (floating point) value of the nth contained element.
double getReal(int position, java.lang.String paramName)
          Returns the real (floating point) value of a contained element.
java.lang.String getString(int position)
          Returns the string value of the nth contained element.
java.lang.String getString(int position, java.lang.String paramName)
          Returns the string value of a contained element.
protected java.lang.String parseAssignment(java.lang.StringBuffer input)
          Parses a name followed by an equals sign.
protected AROdatum parseDatum(java.lang.StringBuffer input)
          Parses one datum, and returns the new object.
protected java.lang.String parseName(java.lang.StringBuffer input)
          Looks for a symbolic name; returns the name or null if it didn't find one.
protected void removeAll()
          Removes all contained elements.
java.lang.String toString()
          Converts the value of the data element to a string.
protected void trimLeadingSpaces(java.lang.StringBuffer str)
          Trims leading spaces from the given StringBuffer.
 
Methods inherited from class satin.aro.AROdatum
addToOutput, dump, getBoolean, getInteger, getName, getObjectID, getReal, getString, wasGotten
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static boolean debug
Enables debugging statements. For use only during development and maintenance of this class.
Constructor Detail

AROcompoundDatum

protected AROcompoundDatum()
Constructs an empty compound datum.
Method Detail

getCompound

public AROcompoundDatum getCompound()
Description copied from class: AROdatum
Returns the value of a compound data element. Throws an assertion if the data element is not compound.

Overrides:
getCompound in class AROdatum

Following copied from class: satin.aro.AROdatum

Returns:
The value of the data element.

getAROtypeName

public java.lang.String getAROtypeName()
Returns the ARO type name of the data element.

Returns:
the ARO type name, or null.

getCount

public int getCount()
Returns the number of elements contained in this data element. This is not a recursive count; for example, if data element X contains elements A, B and C, and element B is a compound data element containing 4 elements, X.getCount will return 3, not 6.

Returns:
the number of contained elements.

getNth

public AROdatum getNth(int position)
Returns the nth contained data element.

Parameters:
position
identifies which contained element to return.
Returns:
the contained data element at the given position.

findByName

public AROdatum findByName(java.lang.String name)
Returns the contained data element with the given name. If the element does not exist, an exception is thrown.

Parameters:
name
identifies which contained element to return.
Returns:
the contained data element with the given name.

getName

public java.lang.String getName(int position)
Returns the name of the nth contained data element. If the element does not exist, an exception is thrown.

Parameters:
position
identifies which contained element to return the name of.
Returns:
the name of the contained data element at the given position, or null if it has no name.

getDatum

public AROdatum getDatum(int position,
                         java.lang.String paramName)
Returns a contained element by name or position. If data elements are named and paramName is not null or empty, the position arg is ignored. If the element does not exist, an exception is thrown.

Parameters:
position
the position of the data element.
paramName
the name of the data element, or null.
Returns:
the contained data element.

exists

public boolean exists(int position,
                      java.lang.String paramName)
Returns whether a contained element, defined by name or position, exists. If data elements are named and paramName is not null or empty, the position arg is ignored.

Parameters:
position
the position of the data element.
paramName
the name of the data element, or null.
Returns:
the contained data element.

getBoolean

public boolean getBoolean(int position)
Returns the boolean value of the nth contained element. Fails an assertion if the contained element is not a boolean.

Parameters:
position
identified which contained element to return the value of.
Returns:
the boolean value of the contained element.

getInteger

public int getInteger(int position)
Returns the integer value of the nth contained element. Fails an assertion if the contained element is not an integer.

Parameters:
position
identified which contained element to return the value of.
Returns:
the integer value of the contained element.

getReal

public double getReal(int position)
Returns the real (floating point) value of the nth contained element. Fails an assertion if the contained element is not a real.

Parameters:
position
identified which contained element to return the value of.
Returns:
the real value of the contained element.

getString

public java.lang.String getString(int position)
Returns the string value of the nth contained element. Fails an assertion if the contained element is not a string.

Parameters:
position
identified which contained element to return the value of.
Returns:
the string value of the contained element.

getObjectID

public AROobjectID getObjectID(int position)
Returns the object value of the nth contained element. Throws an exception of the contained element is not an ARO object.

Parameters:
position
identified which contained element to return the value of.
Returns:
the object value of the contained element.

getCompound

public AROcompoundDatum getCompound(int position)
Returns the compound value of the nth contained element. Fails an assertion if the contained element is not compound.

Parameters:
position
identified which contained element to return the value of.
Returns:
the compound value of the contained element.

getBoolean

public boolean getBoolean(int position,
                          java.lang.String paramName)
Returns the boolean value of a contained element. If the elements are named and paramName is not null, then the element is identified by name. Otherwise, the element is identified by position. Fails an assertion if the contained element is not a boolean.

Parameters:
position
the position of the desired element; ignored if elements are named and paramName is not null.
paramName
the name of the desired element.
Returns:
the boolean value of the contained element.

getInteger

public int getInteger(int position,
                      java.lang.String paramName)
Returns the integer value of a contained element. If the elements are named and paramName is not null, then the element is identified by name. Otherwise, the element is identified by position. Fails an assertion if the contained element is not an integer.

Parameters:
position
the position of the desired element; ignored if elements are named and paramName is not null.
paramName
the name of the desired element.
Returns:
the integer value of the contained element.

getReal

public double getReal(int position,
                      java.lang.String paramName)
Returns the real (floating point) value of a contained element. If the elements are named and paramName is not null, then the element is identified by name. Otherwise, the element is identified by position. Fails an assertion if the contained element is not a real.

Parameters:
position
the position of the desired element; ignored if elements are named and paramName is not null.
paramName
the name of the desired element.
Returns:
the real value of the contained element.

getString

public java.lang.String getString(int position,
                                  java.lang.String paramName)
Returns the string value of a contained element. If the elements are named and paramName is not null, then the element is identified by name. Otherwise, the element is identified by position. Fails an assertion if the contained element is not a string.

Parameters:
position
the position of the desired element; ignored if elements are named and paramName is not null.
paramName
the name of the desired element.
Returns:
the string value of the contained element.

getObjectID

public AROobjectID getObjectID(int position,
                               java.lang.String paramName)
Returns the object value of a contained element. If the elements are named and paramName is not null, then the element is identified by name. Otherwise, the element is identified by position. Fails an assertion if the contained element is not an ARO object.

Parameters:
position
the position of the desired element; ignored if elements are named and paramName is not null.
paramName
the name of the desired element.
Returns:
the object value of the contained element.

getCompound

public AROcompoundDatum getCompound(int position,
                                    java.lang.String paramName)
Returns the compound value of a contained element. If the elements are named and paramName is not null, then the element is identified by name. Otherwise, the element is identified by position. Fails an assertion if the contained element is not compound.

Parameters:
position
the position of the desired element; ignored if elements are named and paramName is not null.
paramName
the name of the desired element.
Returns:
the compound value of the contained element.

addDatum

protected boolean addDatum(AROdatum d)
Adds a datum. Remembers whether the first datum added was named or not.

Returns:
true on success, false if it has a name when it shouldn't, or vice versa.

removeAll

protected void removeAll()
Removes all contained elements.

firstChar

protected char firstChar(java.lang.StringBuffer input)
Returns the first character of input.

trimLeadingSpaces

protected void trimLeadingSpaces(java.lang.StringBuffer str)
Trims leading spaces from the given StringBuffer.

parseName

protected java.lang.String parseName(java.lang.StringBuffer input)
Looks for a symbolic name; returns the name or null if it didn't find one. Removes the successfully parsed portion of the string.

parseAssignment

protected java.lang.String parseAssignment(java.lang.StringBuffer input)
Parses a name followed by an equals sign. Removes the successfully parsed portion of the string.

Returns:
the name, or null if it didn't find one.

parseDatum

protected AROdatum parseDatum(java.lang.StringBuffer input)
Parses one datum, and returns the new object. Removes the successfully parsed portion of the string.

Returns:
the datum, or null if it can't parse one.

addToOutput

public void addToOutput(AROoutgoingData d,
                        java.lang.String name)
Description copied from class: AROdatum
Copies the incoming data (this object) into the given outgoing data.

Overrides:
addToOutput in class AROdatum

Following copied from class: satin.aro.AROdatum

Parameters:
d
the outgoing data
name
the outgoing parameter name, or null for no parameter name.

toString

public java.lang.String toString()
Description copied from class: AROdatum
Converts the value of the data element to a string.

Overrides:
toString in class AROdatum

Following copied from class: satin.aro.AROdatum

Returns:
the value of the data element as a string.

dump

public void dump(java.lang.String indent)
Description copied from class: AROdatum
Dumps the contents of the object for debugging. The output consists of the class name, the datum's name in quotes, a colon, and the datum's value. The output goes to System.out.

Overrides:
dump in class AROdatum

Following copied from class: satin.aro.AROdatum

Parameters:
indent
this string is prepended to each line of output.
Revision History

4/6/01 Ed Stauff - changes per initial code review.

4/5/01 Ed Stauff - made changes per review.

3/27/01 Ed Stauff - initial review.



Generated on 5/9/2001 19:37 from AROcompoundDatum.java (PRIVATE SOURCES)