gishur.core
Interface ControlledCloneable
- All Superinterfaces:
- java.lang.Cloneable, Cloneable
- All Known Implementing Classes:
- BasicListItem, BasicTreeItem, BinarySearchTree, Queue, SimpleList, Stack, GraphElement, Graph, FloatPoint, SKR
- public interface ControlledCloneable
- extends Cloneable
A class implementing the ControlledCloneable
interface
indicates to the Object.clone()
method in class Object
that it is legal for that method to make a field-for-field
copy of instances of that class.
- Version:
- 1.0
- Author:
- Florian Mayer
Field Summary |
static int |
DEEP
Constant to indicate that this object should be cloned deep.
|
static int |
FLAT
Constant to indicate that this object should be cloned flat.
|
Method Summary |
java.lang.Object |
clone(java.util.Hashtable h,
int level)
Clones this object. |
DEEP
public static final int DEEP
- Constant to indicate that
this
object should be cloned deep.
That means, that every object contained by this
object, and
all following objects will be cloned recursive, if possible. The recursion
will stopp if there are no more references, or no more cloneable references.
Ring structures are cloned proper.
FLAT
public static final int FLAT
- Constant to indicate that
this
object should be cloned flat.
That means, that no object contained by this
object will be cloned.
Only the references will be maintained.
clone
public java.lang.Object clone(java.util.Hashtable h,
int level)
- Clones
this
object. According to the parameter level
,
this
object will be cloned down to level
levels.
That means, the object will be cloned. If level==-1(==DEEP)
,
every object, which can be reached by traversing the references beginning
with /this object will be cloned if possible. This recursion
stopps, if there are no more object to clone, or no reachable object implements
Cloneable. If level==0(==FLAT)
, no object contained by this
object will be cloned. Only the references will be
maintained. If level>=1
, the recursion will stopp after cloning
level
generations (or earlier if e.g. no more contained objects
are cloneable).
The recursive cloning stopps, if there's a ring
structure. In this case, all Objects implementing Cloneable
are cloned,
and connected proper, so that even ring structures are cloned as rings.
- Parameters:
h
- Hastable which containes all objects already cloned (with their original objects
as keys), to avoid multiple cloning of the same object (if h==null
a new Hashtable will be created - you can use null
to start a clone recursion)level
- indicates how many generations should be cloned recursive at most- Returns:
- the cloned Object
- Throws:
InternalError
- - if the Object could not be cloned properly