org.openbandy.io
Class SerializableVector

java.lang.Object
  extended by org.openbandy.io.SerializableVector
All Implemented Interfaces:
Serializable

public class SerializableVector
extends java.lang.Object
implements Serializable


Field Summary
static java.lang.String CONTAINED_OBJS_CLASSNAME
           
static java.lang.String CONTAINED_OBJS_IDS
           
 
Constructor Summary
SerializableVector()
           
 
Method Summary
 boolean add(Serializable serializable)
          returns true if the serializable could be added, false if it could not be added because it has a different type than already stored objects
 boolean contains(Serializable serializable)
          Checks if an object with the same id is in the vector.
 void deserialize(Serializer serializer, SerializationBuffer buffer)
          This method must overwrite the attributes denoted in getAttributeNames() with values read from the container provided.
 void deserializeSuper(Serializer serializer, SerializationBuffer buffer)
           
 java.util.Enumeration elements()
           
 Serializable firstElement()
           
 void getAttributeNames(java.util.Vector attributes)
          This method must put the name of every attribute that needs to be serialized in the given Vector.
 java.lang.String getContainedObjectsClassName()
           
 Serializable getCopy()
          Must return a copy of the object that is equal according to the method isEuqalTo().
 java.lang.String getIdName()
          Must return the name of the id (e.g.
 int getIdValue()
          Must return the value of the id.
 java.lang.String getLegibleString()
          Must return a human readable String representation of the object.
 Serializable getNewInstance()
          Must return a new and initialized instance.
 void getReferencedIdNames(java.util.Vector referenceNames)
          This method must put every id name of referenced objects, i.e.
 void getReferences(java.util.Vector references)
          This method must put every reference to Serializable objects, i.e.
 java.lang.String getSerializationName()
           
 Serializable getSuperCopy()
           
 java.util.Vector getVector()
           
 boolean isEqual(Serializable serializableObject)
          Must return true if the serializableObject is equal to this, except for the id but INCLUDING equality of referenced serializables.
 boolean isEqualShallow(Serializable serializableObject)
          Must return true if the serializableObject is equal to this, except for the id, EXCLUDING equality of referenced serializables.
 void prepareStorageDeserialization(StorageValueContainer container)
          This method prepares the Vector for deserialization by a StorageSerializer.
 void prepareStorageSerialization(Storage storage, StorageSerializer storageSerializer)
          If the vector is serialized to a storage, check if an older version if the vector already exists in the persistent storage.
 boolean remove(Serializable serializable)
          If the serializable object is contained in this vector, it will be deleted.
 boolean removeFirstElement()
           
 void serialize(Serializer serializer, SerializationBuffer buffer)
          This method must fill the container provided with the serialization- Object with values for every attribute denoted in getAttributeNames().
 void setContainedObjectsClassName(java.lang.String containedObjectsClassName)
           
 void setIdValue(int idValue)
          Set the id to the given value.
 void setSerializationName(java.lang.String serializationName)
           
 int size()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTAINED_OBJS_CLASSNAME

public static final java.lang.String CONTAINED_OBJS_CLASSNAME
See Also:
Constant Field Values

CONTAINED_OBJS_IDS

public static final java.lang.String CONTAINED_OBJS_IDS
See Also:
Constant Field Values
Constructor Detail

SerializableVector

public SerializableVector()
Method Detail

getSerializationName

public java.lang.String getSerializationName()

setSerializationName

public void setSerializationName(java.lang.String serializationName)

setContainedObjectsClassName

public void setContainedObjectsClassName(java.lang.String containedObjectsClassName)

getContainedObjectsClassName

public java.lang.String getContainedObjectsClassName()

size

public int size()

add

public boolean add(Serializable serializable)
returns true if the serializable could be added, false if it could not be added because it has a different type than already stored objects

Parameters:
serializable -
Returns:

firstElement

public Serializable firstElement()

remove

public boolean remove(Serializable serializable)
If the serializable object is contained in this vector, it will be deleted. If it has already been stored to a storage, it will also be deleted from the storage.

Parameters:
serializable -
Returns:
true if removed successfully

removeFirstElement

public boolean removeFirstElement()
Returns:
true if removed successfully

getVector

public java.util.Vector getVector()

elements

public java.util.Enumeration elements()

contains

public boolean contains(Serializable serializable)
Checks if an object with the same id is in the vector.

Parameters:
serializable - The object to look for.
Returns:
True if an object of the same type with the same id is in the vector. False else.

serialize

public void serialize(Serializer serializer,
                      SerializationBuffer buffer)
Description copied from interface: Serializable
This method must fill the container provided with the serialization- Object with values for every attribute denoted in getAttributeNames(). Subsequently it must serialize member objects as denoted in getReferences().

Specified by:
serialize in interface Serializable
Parameters:
serializer - - the serializer used for call-backs
buffer - - the serializationBuffer containing the container to write values to

deserialize

public void deserialize(Serializer serializer,
                        SerializationBuffer buffer)
Description copied from interface: Serializable
This method must overwrite the attributes denoted in getAttributeNames() with values read from the container provided. Subsequently it must de- serialize member objects as denoted in getReferences().

Specified by:
deserialize in interface Serializable
Parameters:
serializer - - the serializer used for call-backs
buffer - - the buffer to read values from

deserializeSuper

public void deserializeSuper(Serializer serializer,
                             SerializationBuffer buffer)

prepareStorageSerialization

public void prepareStorageSerialization(Storage storage,
                                        StorageSerializer storageSerializer)
If the vector is serialized to a storage, check if an older version if the vector already exists in the persistent storage. If so, delete the affected entries (i.e. objects that are in the stored vector but not in the actual object) from the persistent storage.

Parameters:
storage - Storage that shall be used for serialization
storageSerializer - Serializer that will be used for serialization

prepareStorageDeserialization

public void prepareStorageDeserialization(StorageValueContainer container)
This method prepares the Vector for deserialization by a StorageSerializer.

Parameters:
container - The vectors value buffer.container().

getLegibleString

public java.lang.String getLegibleString()
Description copied from interface: Serializable
Must return a human readable String representation of the object.

Specified by:
getLegibleString in interface Serializable
Returns:
human legible string

isEqualShallow

public boolean isEqualShallow(Serializable serializableObject)
                       throws java.lang.ClassCastException
Description copied from interface: Serializable
Must return true if the serializableObject is equal to this, except for the id, EXCLUDING equality of referenced serializables.

Specified by:
isEqualShallow in interface Serializable
Parameters:
serializableObject - - the object to compare
Returns:
true if serializableObject is equal to this
Throws:
java.lang.ClassCastException

isEqual

public boolean isEqual(Serializable serializableObject)
                throws java.lang.ClassCastException
Description copied from interface: Serializable
Must return true if the serializableObject is equal to this, except for the id but INCLUDING equality of referenced serializables.

Specified by:
isEqual in interface Serializable
Parameters:
serializableObject - - the object to compare
Returns:
true if serializableObject is equal to this
Throws:
java.lang.ClassCastException

getNewInstance

public Serializable getNewInstance()
Description copied from interface: Serializable
Must return a new and initialized instance.

Specified by:
getNewInstance in interface Serializable
Returns:
New instance of concrete class.

getCopy

public Serializable getCopy()
Description copied from interface: Serializable
Must return a copy of the object that is equal according to the method isEuqalTo().

Specified by:
getCopy in interface Serializable
Returns:
copy of this

getIdName

public java.lang.String getIdName()
Description copied from interface: Serializable
Must return the name of the id (e.g. eventId).

Specified by:
getIdName in interface Serializable
Returns:
the name of the id

getIdValue

public int getIdValue()
Description copied from interface: Serializable
Must return the value of the id.

Specified by:
getIdValue in interface Serializable
Returns:
the actual value of id

setIdValue

public void setIdValue(int idValue)
Description copied from interface: Serializable
Set the id to the given value.

Specified by:
setIdValue in interface Serializable
Parameters:
idValue - - the new id value

getAttributeNames

public void getAttributeNames(java.util.Vector attributes)
Description copied from interface: Serializable
This method must put the name of every attribute that needs to be serialized in the given Vector. For every String value contained in attributes, there must be a corresponding field in the database for example.

Specified by:
getAttributeNames in interface Serializable
Parameters:
attributes - - the vector to be filled

getReferences

public void getReferences(java.util.Vector references)
Description copied from interface: Serializable
This method must put every reference to Serializable objects, i.e. member objects, in the given Vector.

Specified by:
getReferences in interface Serializable
Parameters:
references - - the vector to be filled

getReferencedIdNames

public void getReferencedIdNames(java.util.Vector referenceNames)
Description copied from interface: Serializable
This method must put every id name of referenced objects, i.e. member objects that need to be serialized, in the given Vector.

Specified by:
getReferencedIdNames in interface Serializable
Parameters:
referenceNames - - the vector to be filled

getSuperCopy

public Serializable getSuperCopy()