platypus
Class Value<A>

java.lang.Object
  extended by platypus.Value<A>

public class Value<A>
extends java.lang.Object

Class that contains a value and the line number of its last modification. Uses generics. Note: because of the use of generics, getValue() returns a *string*. This should be converted to the right numeric type through the usual Java library methods.

Author:
alb

Field Summary
private  int lineNumber
          the input line # at which value was set
private  A value
          the actual value (of unknown type)
 
Constructor Summary
Value(A initialValue)
           
Value(A val, int line)
           
 
Method Summary
 java.lang.String dump()
          Creates a partial string containing the dump information for the value.
 int getLineNumber()
          Returns an integer containing the line number of when the value was last modified
 java.lang.String getValue()
          In a parameterized class, this returns an Object even if declared as A getValue(), so instead return a string and convert it at point of use via Float.valueOf(), Integer.valueOf(), Boolean.valueOf, etc.
 A setValue(A newValue)
          Setter for value (but returns set value object as a convenience.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

private A value
the actual value (of unknown type)


lineNumber

private int lineNumber
the input line # at which value was set

Constructor Detail

Value

public Value(A initialValue)

Value

public Value(A val,
             int line)
Method Detail

getValue

public java.lang.String getValue()
In a parameterized class, this returns an Object even if declared as A getValue(), so instead return a string and convert it at point of use via Float.valueOf(), Integer.valueOf(), Boolean.valueOf, etc.

Returns:
value as a String

getLineNumber

public int getLineNumber()
Returns an integer containing the line number of when the value was last modified

Returns:
the line number

setValue

public A setValue(A newValue)
Setter for value (but returns set value object as a convenience. Note: despite the use of a generic for a return value, the returned item is of class Object

Parameters:
newValue - the value to set value to.
Returns:
an Object equal to the newValue.

dump

public java.lang.String dump()
Creates a partial string containing the dump information for the value.

Returns:
a string containing the line number in parens followed by the value.


Copyright © 2006-7 Pacific Data Works LLC