|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The interface ListItem
is used for doubly connected lists, stacks and
queues for example.
Although BasicList
, etc. implements Serializable
,
ListItem
doesn't. Thus you can avoid serialization from list's
using ListItem
s not implementing Serializable
. Take
care not to forget to implement Serializable
, if you need to.
Field Summary | |
static int |
CLEAR_CONNECTIONS
Delete connections. |
static int |
CONNECT_BACKWARD
Connect object backwards only. |
static int |
CONNECT_FORWARD
Connect object forwards only. |
static int |
REMOVE
Remove object from list. |
static int |
SET_OWNER
Set new owner. |
Fields inherited from interface gishur.core.KeyValueHolder |
SET_KEY, SET_VALUE |
Method Summary | |
boolean |
answerConnect(ListItem link,
boolean forward)
Completes the connection and should therefore only be called by . |
boolean |
clearConnections()
Deletes all connections originating from this ListItem .
|
java.lang.Object |
clone()
Clones the object flat. |
java.lang.Object |
clone(java.util.Hashtable h,
int level)
Clones the object according to ControlledCloneable . |
boolean |
connect(ListItem link,
boolean forward)
Connects this ListItem to the ListItem
link . |
ListItem |
find(java.lang.Object O)
Searches for object O in the chain. |
ListItem |
findFirst()
Searches for the first ListItem of the chain and returns that ListItem . |
ListItem |
findLast()
Searches for the last ListItem of the chain and returns that ListItem . |
int |
getIndex(boolean fromStart)
Calculates the index of this ListItem within the chain, beginning from
the first or the last element. |
Owner |
getOwningList()
Returns the owner of the ListItem . |
boolean |
isFirst()
Tests if the ListItem is the first element of a chain. |
boolean |
isLast()
Tests if the ListItem is the last element of a chain. |
ListItem |
next()
Returns the next connected ListItem . |
ListItem |
prev()
Returns the previous ListItem . |
boolean |
remove()
Deletes the connections to other ListItem s. { |
boolean |
setOwningList(Owner owner)
Sets the owner of the ListItem . |
Methods inherited from interface gishur.core.KeyValueHolder |
key, setKey, setValue, value |
Field Detail |
public static final int SET_OWNER
public static final int REMOVE
public static final int CLEAR_CONNECTIONS
public static final int CONNECT_FORWARD
public static final int CONNECT_BACKWARD
Method Detail |
public java.lang.Object clone()
ListItem
is not connected and has no
owner. The attached keys and objects will not be cloned. They will occure as reference
in the Object. To avoid cloning, just don't implement the Cloneable
interface.clone
in class java.lang.Object
InternalError
- - if the Object could not be cloned properlypublic java.lang.Object clone(java.util.Hashtable h, int level)
ControlledCloneable
. The new
ListItem
is not connected.
To avoid cloning, just don't implement the ControlledCloneable
interface.h
- Hashtable to indicate which objects are already clonedlevel
- indicates how deep the objects should be clonedInternalError
- - if the Object could not be cloned properlyControlledCloneable
public boolean setOwningList(Owner owner)
ListItem
. If an owner already exists, he is
asked for permission. The new owner is also asked for permission. A change
only occurs, if
both agree.
If the old and the new owner is the same object, no one is asked for permission
and true
is returned.
Connections remain untouched by the change.owner
- new ownertrue
, if the change is successfulpublic Owner getOwningList()
ListItem
.public ListItem next()
ListItem
.ListItem
public ListItem prev()
ListItem
.ListItem
public ListItem findFirst()
ListItem
of the chain and returns that ListItem
.ListItem
of the chainpublic ListItem findLast()
ListItem
of the chain and returns that ListItem
.ListItem
of the chainpublic boolean isFirst()
ListItem
is the first element of a chain.true
, if the ListItem
is the first object of the
chainpublic boolean isLast()
ListItem
is the last element of a chain.true
, if the ListItem
is the last ListItem
of the chainpublic ListItem find(java.lang.Object O)
O
in the chain.O
- object to be foundListItem
object or null
, if search not
successful.public int getIndex(boolean fromStart)
ListItem
within the chain, beginning from
the first or the last element.fromStart
- if true
then the first element has index
0
, else the last element has index 0
public boolean answerConnect(ListItem link, boolean forward)
connect
(link,forward)
. Here the owner may not
again be asked for permission (all the necessary tests were already conducted
by connect
(link,forward)
), but
answerConnect
must make sure that it can only be called by
connect
. This can be achieved for example, by testing if a 'half
connection' is already established.link
- ListItem
, with which a connection should be establishedforward,
- direction of the connection (forward, if true
)true
, if connection successfulpublic boolean connect(ListItem link, boolean forward)
this
ListItem
to the ListItem
link
. This is a forward connection, if
forward==true
, otherwise it is a backward connection. To achieve
a double connection, the method answerConnect
(link,forward)
of the ListItem
link
is called (if link!=null
). The owner is asked for permission
before the connection takes place. For two ListItem
s to be connected,
they must both have the same owner.link
- ListItem with which this
is to be connectedforward,
- direction of the connection (forward, if true
)true
, if connection is permitted and successful.public boolean remove()
ListItem
s. prev()
is directly
connected to next()
. After the operation this
will be
ownerless.true
, if remove()
is permitted and
successful.public boolean clearConnections()
this
ListItem
.
The connections are not removed completely (in both directions). In contrast
to remove()
the owner is asked only once for permission! The owner
remains unchanged.true
, if successful
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |