com.triactive.jdo.sco
Class Hashtable

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended bycom.triactive.jdo.sco.Hashtable
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, SCO, SCOMap, java.io.Serializable

public class Hashtable
extends java.util.Hashtable
implements SCOMap, java.lang.Cloneable

A mutable second-class Hashtable object.

SCO fields declared as type java.util.Hashtable are populated with objects of this type whenever the owning object is actively being managed by a state manager.

This class is almost identical to HashMap, except it inherits from java.util.Hashtable. Remember that any changes made to either of them will most likely need to be made to both.

Author:
Mike Martin
See Also:
HashMap, Serialized Form

Constructor Summary
Hashtable(java.lang.Object owner, java.lang.String fieldName, PersistentMap backing)
          Constructs an SCO Hashtable representing an existing persistent map.
Hashtable(java.lang.Object owner, java.lang.String fieldName, PersistentMap backing, java.util.Map value)
          Constructs an SCO Hashtable having the specified initial contents.
 
Method Summary
 boolean allowsNullValues()
          Indicates whether or not this map allows null values.
 void applyUpdates()
          Called to indicate that the owning object is being made persistent, or that the persistent state of this field is being updated.
 void clear()
           
 java.lang.Object clone()
          Creates and returns a copy of this object.
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Enumeration elements()
           
 java.util.Set entrySet()
           
 boolean equals(java.lang.Object o)
           
 java.lang.Object get(java.lang.Object key)
           
 java.lang.String getFieldName()
          Returns the field name in the owner object.
 java.lang.Class getKeyType()
          Returns the type of keys in this map.
 java.lang.Object getOwner()
          Returns the owner object of the SCO instance.
 java.lang.Class getValueType()
          Returns the type of values in this map.
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Enumeration keys()
           
 java.util.Set keySet()
           
 void makeDirty()
          Marks this object dirty.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map m)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
 java.lang.String toString()
           
 void unsetOwner()
          Disconnects this object from its owner.
 java.util.Collection values()
           
protected  java.lang.Object writeReplace()
          Replaces the object to be serialized with a java.util.Hashtable object.
 
Methods inherited from class java.util.Hashtable
contains, rehash
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hashtable

public Hashtable(java.lang.Object owner,
                 java.lang.String fieldName,
                 PersistentMap backing)
Constructs an SCO Hashtable representing an existing persistent map. The map's contents are initially not loaded.

Parameters:
owner - The object that owns this second-class object.
fieldName - The fieldName in the owning object.
backing - The backing store for this map.

Hashtable

public Hashtable(java.lang.Object owner,
                 java.lang.String fieldName,
                 PersistentMap backing,
                 java.util.Map value)
Constructs an SCO Hashtable having the specified initial contents.

If the owning object is already persistent it is assumed its field is being assigned an entirely new value. The existing map contents are cleared in the data store and the new contents are added.

Parameters:
owner - The object that owns this second-class object.
fieldName - The fieldName in the owning object.
backing - The backing store for this map.
value - The initial contents of the map.
Method Detail

getOwner

public java.lang.Object getOwner()
Description copied from interface: SCO
Returns the owner object of the SCO instance.

Specified by:
getOwner in interface SCO
Returns:
The owner object or null if currently unowned.

getFieldName

public java.lang.String getFieldName()
Description copied from interface: SCO
Returns the field name in the owner object.

Specified by:
getFieldName in interface SCO
Returns:
The field name or null if currently unowned.

getKeyType

public java.lang.Class getKeyType()
Description copied from interface: SCOMap
Returns the type of keys in this map.

Specified by:
getKeyType in interface SCOMap
Returns:
The type of keys in this map.

getValueType

public java.lang.Class getValueType()
Description copied from interface: SCOMap
Returns the type of values in this map.

Specified by:
getValueType in interface SCOMap
Returns:
The type of values in this map.

allowsNullValues

public boolean allowsNullValues()
Description copied from interface: SCOMap
Indicates whether or not this map allows null values.

Specified by:
allowsNullValues in interface SCOMap
Returns:
true if null values are allowed, false otherwise.

makeDirty

public void makeDirty()
Description copied from interface: SCO
Marks this object dirty. If the SCO is currently owned this method should mark the corresponding field in the owning object as dirty.

Specified by:
makeDirty in interface SCO

applyUpdates

public void applyUpdates()
Description copied from interface: SCO
Called to indicate that the owning object is being made persistent, or that the persistent state of this field is being updated.

Specified by:
applyUpdates in interface SCO

unsetOwner

public void unsetOwner()
Description copied from interface: SCO
Disconnects this object from its owner.

Specified by:
unsetOwner in interface SCO

clone

public java.lang.Object clone()
Creates and returns a copy of this object.

Mutable second-class Objects are required to provide a public clone method in order to allow for copying PersistenceCapable objects. In contrast to Object.clone(), this method must not throw a CloneNotSupportedException.

Specified by:
clone in interface SCO

size

public int size()
Specified by:
size in interface java.util.Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map

putAll

public void putAll(java.util.Map m)
Specified by:
putAll in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map

clear

public void clear()
Specified by:
clear in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

keys

public java.util.Enumeration keys()

elements

public java.util.Enumeration elements()

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map

toString

public java.lang.String toString()

writeReplace

protected java.lang.Object writeReplace()
Replaces the object to be serialized with a java.util.Hashtable object. Invoked by the serialization mechanism to obtain an alternative object to be used when writing an object to the stream.

Returns:
The Hashtable to be serialized instead of this object.


Copyright 2001-2007 The TJDO Project All Rights Reserved.