AbstractDVO

public abstract class AbstractDVO implements DVO

The AbstractDVO, which implements the DVO interface, is simply a convenient abstract class for managing the data of a DVO. It implemented the methods of the DVO interface, provides some convenient methods and is backed by a Hashtable.

Author:Hugo Y. K. Lam

Constructors

AbstractDVO

protected AbstractDVO()

Creates a new instance of AbstractDVO.

AbstractDVO

protected AbstractDVO(Hashtable data)

Creates a new instance of AbstractDVO.

Parameters:
  • data – the source data of this DVO.

Methods

equals

public boolean equals(Object obj)

Indicates whether the given object is equal to this one. The objects are equal if and only if the given object is an AbstractDVO object and the values contained in that object match with this one’s.

Parameters:
  • obj – the object to be compared.
Returns:

true if the given object is equal to this one.

See also: java.lang.Object.equals(java.lang.Object)

get

public Object get(Object key)

Gets a value object back from this DVO by its key.

Parameters:
  • key – the key referencing the value to be retrieved.
Returns:

the value object retrieved by the specified key.

getBoolean

public boolean getBoolean(Object key)

Retrieves the value by the specified key in this AbstractDVO as an boolean.

Parameters:
  • key – the key referencing the value to be retrieved.
Returns:

the value retrieved by the specified key.

getData

public Hashtable getData()

Gets the source data of this DVO.

Returns:the source data of this DVO.

getDate

public java.util.Date getDate(Object key)

Retrieves the value by the specified key in this AbstractDVO as a java.util.Date.

Parameters:
  • key – the key referencing the value to be retrieved.
Returns:

the value retrieved by the specified key.

getDirties

public String[] getDirties()

Gets the keys which reference the dirty values.

Returns:the keys referencing the dirty values.

getDouble

public double getDouble(Object key)

Retrieves the value by the specified key in this AbstractDVO as a double.

Parameters:
  • key – the key referencing the value to be retrieved.
Returns:

the value retrieved by the specified key.

getInt

public int getInt(Object key)

Retrieves the value by the specified key in this AbstractDVO as an int.

Parameters:
  • key – the key referencing the value to be retrieved.
Returns:

the value retrieved by the specified key or Integer.MIN_VALUE if the underlying value is null.

getLong

public long getLong(Object key)

Retrieves the value by the specified key in this AbstractDVO as a long.

Parameters:
  • key – the key referencing the value to be retrieved.
Returns:

the value retrieved by the specified key or Long.MIN_VALUE if the underlying value is null.

getObject

public Object getObject(Object key, Class c)

Gets an Object from this DVO by its referencing key. If the value object is not of the Class specified, it will try to create an instance of the Class with the Object as the parameter.

Parameters:
  • key – The key referencing the String value.
  • c – the Class of the returning Object.
Returns:

the Object retrieved by its referencing key. If the value object is not of the Class specified, it will be an instance of the Class with the Object as the parameter. Null if the mentioned cannot be achieved.

getSQLDate

public java.sql.Date getSQLDate(Object key)

Retrieves the value by the specified key in this AbstractDVO as a java.sql.Date.

Parameters:
  • key – the key referencing the value to be retrieved.
Returns:

the value retrieved by the specified key.

getString

public String getString(Object key)

Gets a String value from this DVO by its key reference.

Parameters:
  • key – the key referencing the String value.
Returns:

the String value retrieved by the specified key.

getTimestamp

public java.sql.Timestamp getTimestamp(Object key)

Retrieves the value by the specified key in this AbstractDVO as a java.sql.Timestamp. It can transform java.sql.Date, java.util.Date and Oracle DATE and TIMESTAMP.

Parameters:
  • key – the key referencing the value to be retrieved.
Returns:

the value retrieved by the specified key.

put

public Object put(Object key, Object value)

Sets a single value to this DVO with a key as its reference.

Parameters:
  • key – the key referencing the value to be set.
  • value – the value object to be set to this DVO.
Returns:

the previous value of the specified key in this hashtable, or null if it did not have one.

remove

public Object remove(Object key)

Removes a value object from this DVO.

Parameters:
  • key – the key referencing the value to be removed.
Returns:

the value to which the key had been mapped in this DVO, or null if the key did not have a mapping.

setBoolean

public void setBoolean(Object key, boolean value)

Sets a Boolean value to this DVO.

Parameters:
  • key – the key referencing the Boolean value.
  • value – the Boolean value to be set.

setData

public void setData(Hashtable data)

Sets the source data of this DVO.

Parameters:
  • data – the source data of this DVO.

setDate

public void setDate(Object key, Object obj)

Sets a java.util.Date and java.sql.Date value to this DVO.

Parameters:
  • key – the key referencing the Date value.
  • obj – the Date value to be set.

setDouble

public void setDouble(Object key, double value)

Sets a Double value to this DVO.

Parameters:
  • key – the key referencing the Double value.
  • value – the Double value to be set.

setInt

public void setInt(Object key, int value)

Sets an Integer value to this DVO.

Parameters:
  • key – the key referencing the Integer value.
  • value – the Integer value to be set.

setLong

public void setLong(Object key, long value)

Sets a Long value to this DVO.

Parameters:
  • key – the key referencing the Long value.
  • value – the Long value to be set.

setString

public void setString(Object key, Object value)

Sets a String value to this DVO.

Parameters:
  • key – the key referencing the String value.
  • value – the String value to be set.

toString

public String toString()

Returns a string representation of this AbstractDVO object in the form of a set of entries.

Returns:a string representation of this AbstractDVO.