com.davisor.data
Class VoidData

java.lang.Object
  extended bycom.davisor.data.VoidData
All Implemented Interfaces:
Data
Direct Known Subclasses:
CollectionDataSource, EnumeratorDataStream, IteratorDataStream, JoinedDataBuffer, JoinedDataStream, ResultSetDataStream, StreamDataSource, TupleDataStream, VoidValue

public abstract class VoidData
extends java.lang.Object
implements Data

VoidData is an abstract base class for concrete Data classes. Data objects know it's type, managed by the methods of this class.

Since:
JDK1.1
See Also:
Type, VoidType

Field Summary
protected  Type M_type
          The type of this data.
 
Constructor Summary
protected VoidData()
          Default constructor.
protected VoidData(Type type)
          Create a new data object.
protected VoidData(VoidData data, boolean deep)
          Deep or shallow copy constructor.
 
Method Summary
 boolean equals(java.lang.Object o)
          Tests if this object is equal with another object.
protected  DataValue getDataValue(java.lang.Object object)
          Makes a DataValue out of an object if it is not already one.
 Type getType()
          Gets data type.
 int hashCode()
          Returns a hash code value for the object.
 void setType(Type type)
          Sets the data type.
 java.lang.String toString()
          Gets the string representation of this data object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

M_type

protected Type M_type
The type of this data.

Constructor Detail

VoidData

protected VoidData()
Default constructor. Leaves the type undetermined.


VoidData

protected VoidData(VoidData data,
                   boolean deep)
Deep or shallow copy constructor. If it is shallow, then the new object shares an underlying type with the original object. If it is deep, then the type is dupped.

Parameters:
data - source data (may be null)
deep - determines if the copying is deep or shallow
See Also:
getType(), Type.dup()

VoidData

protected VoidData(Type type)
Create a new data object.

Parameters:
type - The type of data.
See Also:
getType()
Method Detail

getType

public Type getType()
             throws InvalidDataException
Gets data type.

Specified by:
getType in interface Data
Returns:
the type associated with this data object
Throws:
InvalidDataException - if type retrieval fails

equals

public boolean equals(java.lang.Object o)
Tests if this object is equal with another object.

Void data objects are by default equal to non-null instances of VoidData if the type are equal, or if the types are both null.

Subclasses are expected to extend this equality test. In particular, subclass implementations are encouraged to first test object instance equality with the == operator, then their super-class unequality with super.equals(Object) method, and finally perform their own class -spesific equality tests if neccessary. A typical test sequence should therefore look something like this:

 public boolean equals(Object o)
 {
   if(this == o) return true;
   if(!super.equals(o) || !(o instanceof SubClass)) return false;

   :
 }
 

See Also:
Compare.equals(Object,Object), Type.equals(Object)

hashCode

public int hashCode()
Returns a hash code value for the object.


toString

public java.lang.String toString()
Gets the string representation of this data object. This default implementation returns always null string.


getDataValue

protected DataValue getDataValue(java.lang.Object object)
                          throws InvalidDataException
Makes a DataValue out of an object if it is not already one. The conversion, if any, is done using the current type Type.toData(Object) method. null objects are converted, too, and weather they remain null or not depends on the behaviour of the current type.

If conversion is needed but the current type is null, null values remain null, but any other object value raises an exception.

Throws:
InvalidDataException - if the object could not be converted
See Also:
Type.toData(Object)

setType

public void setType(Type type)
Sets the data type. The new type must be somehow compatible with the current data value, otherwise runtime exceptions are to be expected when the data value is accessed later.



Copyright © 2001-2004 Davisor Oy. All Rights Reserved.