|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gishur.core.BasicListItem
Basic ListItem
, which only contains connections and an owner, but no
object or key.
Fields inherited from interface gishur.core.ListItem |
CLEAR_CONNECTIONS, CONNECT_BACKWARD, CONNECT_FORWARD, REMOVE, SET_OWNER |
Fields inherited from interface gishur.core.KeyValueHolder |
SET_KEY, SET_VALUE |
Fields inherited from interface gishur.core.ControlledCloneable |
DEEP, FLAT |
Constructor Summary | |
BasicListItem()
|
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 . |
boolean |
equals(java.lang.Object object)
Compares two ListItems . |
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. |
java.lang.Object |
key()
Returns the stored key of the object. |
ListItem |
next()
Returns the next connected ListItem . |
ListItem |
prev()
Returns the previous ListItem . |
boolean |
remove()
Deletes the connections to other ListItems . { |
protected boolean |
requestListAccess(int accesstype,
java.lang.Object argument)
Asks the owner for permission to perform an action of the type accesstype with the argument
argument . |
boolean |
setKey(java.lang.Object key)
Sets the key |
boolean |
setOwningList(Owner owner)
Sets the owner of the ListItem . |
boolean |
setValue(java.lang.Object object)
Stores the object object . |
java.lang.String |
toString()
Overrides Object.toString() . |
java.lang.Object |
value()
Returns the stored value. |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public BasicListItem()
Method Detail |
public boolean equals(java.lang.Object object)
ListItems
. Two ListItems
are
equal, if their keys are equal (according to their equals
-function).
true
is returned, if object
refers to
this, object.equals(key())
returns true,
or object
is a ListItem
which is identical to
this
ListItem
Overrides Object.equals()
- Overrides:
equals
in class java.lang.Object
- Parameters:
object
- to be compared to- Returns:
true
, if successful
public java.lang.String toString()
Object.toString()
.toString
in class java.lang.Object
public java.lang.Object clone()
ListItem
is not connected and has no
owner. The attached keys and values will be cloned as well.clone
in interface ListItem
clone
in class java.lang.Object
Cloneable
public java.lang.Object clone(java.util.Hashtable h, int level)
ControlledCloneable
. The new
ListItem
is not connected. If
level==ControlledCloneable.FLAT
, the key and value of
this BasicListItem
are not cloned, but their original references are
given as key and value to the new BasicListItem
.clone
in interface ListItem
h
- Hashtable to indicate which objects are already clonedlevel
- indicates how deep the objects should be clonedInternalError
- if the Object could not be cloned properlyjava.lang.IllegalAccessException
- if an element was encountered, which implemented the
java.lang.Cloneable
-interface, but whose clone
-method was
not publicControlledCloneable
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.setOwningList
in interface ListItem
owner
- new ownertrue
, if the change is successfulpublic Owner getOwningList()
ListItem
.getOwningList
in interface ListItem
protected boolean requestListAccess(int accesstype, java.lang.Object argument)
accesstype
with the argument
argument
.accesstype
- specifies the actionargument
- argument of the actiontrue
, if the owner permits the action, else
false
public ListItem next()
ListItem
.next
in interface ListItem
ListItem
public ListItem prev()
ListItem
.prev
in interface ListItem
ListItem
public ListItem findFirst()
ListItem
of the chain and returns that ListItem
.findFirst
in interface ListItem
ListItem
of the chainpublic ListItem findLast()
ListItem
of the chain and returns that ListItem
.findLast
in interface ListItem
ListItem
of the chainpublic boolean isFirst()
ListItem
is the first element of a chain.isFirst
in interface ListItem
true
, if the ListItem
is the first object of the
chainpublic boolean isLast()
ListItem
is the last element of a chain.isLast
in interface ListItem
true
, if the ListItem
is the last ListItem
of the chainpublic ListItem find(java.lang.Object O)
O
in the chain.find
in interface ListItem
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.getIndex
in interface ListItem
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.answerConnect
in interface ListItem
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 ListItems
to be connected,
they must both have the same owner.connect
in interface ListItem
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()
ListItems
. prev()
is
directly connected to next()
. After the operation this
will be ownerless.remove
in interface ListItem
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.clearConnections
in interface ListItem
true
, if successfulpublic java.lang.Object key()
key
in interface KeyValueHolder
public boolean setKey(java.lang.Object key)
setKey
in interface KeyValueHolder
key
- new keypublic java.lang.Object value()
value
in interface KeyValueHolder
public boolean setValue(java.lang.Object object)
object
.setValue
in interface KeyValueHolder
object
- object to be stored
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |