org.elkoserver.server.context
Class Item

java.lang.Object
  extended by org.elkoserver.server.context.BasicObject
      extended by org.elkoserver.server.context.Item
All Implemented Interfaces:
DefaultDispatchTarget, DispatchTarget, MessageRetargeter, Encodable, Referenceable

public class Item
extends BasicObject

A Item is an application object contained by a context or a user (or another Item) but which is not a context or user itself. Along with Context and User it is one of the three basic object types.


Field Summary
 
Fields inherited from class org.elkoserver.server.context.BasicObject
VIS_CONTAINER, VIS_NONE, VIS_PERSONAL, VIS_PUBLIC
 
Method Summary
protected  void baseEncode(JSONLiteral result, EncodeControl control)
           
 BasicObject container()
          Obtain this item's container.
 Context context()
          Obtain the context in which this item is located, regardless of how deeply nested in containers it might be.
 void delete()
          Delete this item (and, by implication, its contents).
 void delete(User from)
          Message handler for the 'delete' message.
 JSONLiteral encode(EncodeControl control)
          Encode this item for transmission or persistence.
 BasicObject holder()
          Obtain the user or context holding this object, regardless of how deeply nested in containers it might be.
 boolean isDeletable()
          Test if unprivileged users inside the context can delete this item (by sending a 'delete' message to the server).
 boolean isPortable()
          Test if unprivileged users inside the context can move this item (by sending a 'move' message to the server).
 void sendObjectDescription(Deliverer to, Referenceable maker)
          Transmit a description of this item as a series of 'make' messages, such that the receiver will be able to construct a local presence of it.
 void setContainer(BasicObject container)
          Set or change this item's container.
 String toString()
          Obtain a printable string representation of this item.
 User user()
          Obtain the user within which this item is contained, regardless of how deeply nested in containers it might be.
 
Methods inherited from class org.elkoserver.server.context.BasicObject
baseRef, checkpoint, checkpoint, contents, contextor, createItem, findActualTarget, getMod, handleMessage, isClone, isContainer, isEphemeral, markAsChanged, markAsDeleted, markAsEphemeral, name, noteCodependent, objectIsComplete, position, ref, sendToClones, setName, setPosition, setVisibility, visibleTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

container

public BasicObject container()
Obtain this item's container.

Overrides:
container in class BasicObject
Returns:
the object this item is currently contained by.

context

public Context context()
Obtain the context in which this item is located, regardless of how deeply nested in containers it might be.

Specified by:
context in class BasicObject
Returns:
the context in which this item is located, at whatever level of container nesting, or null if it is not in any context.

delete

public void delete()
Delete this item (and, by implication, its contents). The caller is responsible for notifying any clients who need to know that this has happened.


baseEncode

protected void baseEncode(JSONLiteral result,
                          EncodeControl control)

encode

public JSONLiteral encode(EncodeControl control)
Encode this item for transmission or persistence.

Parameters:
control - Encode control determining what flavor of encoding should be done.
Returns:
a JSON literal representing this item.

holder

public BasicObject holder()
Obtain the user or context holding this object, regardless of how deeply nested in containers it might be.

Overrides:
holder in class BasicObject
Returns:
the user or context within which this object is contained, at whatever level of container nesting, or null if it is not held by anything.

isDeletable

public boolean isDeletable()
Test if unprivileged users inside the context can delete this item (by sending a 'delete' message to the server).

Returns:
true if ordinary users can delete this item, false if not.

isPortable

public boolean isPortable()
Test if unprivileged users inside the context can move this item (by sending a 'move' message to the server).

Returns:
true if ordinary users can move this item, false if not.

sendObjectDescription

public void sendObjectDescription(Deliverer to,
                                  Referenceable maker)
Transmit a description of this item as a series of 'make' messages, such that the receiver will be able to construct a local presence of it.

Specified by:
sendObjectDescription in class BasicObject
Parameters:
to - Where to send the description.
maker - Maker object to address the message(s) to.

setContainer

public void setContainer(BasicObject container)
Set or change this item's container. The participating containers will be marked as having changed, so that the change of containership will be persistent.

Parameters:
container - The new container for this item, or null to indicate that it should now have no container.

toString

public String toString()
Obtain a printable string representation of this item.

Overrides:
toString in class Object
Returns:
a printable representation of this item.

user

public User user()
Obtain the user within which this item is contained, regardless of how deeply nested in containers it might be.

Specified by:
user in class BasicObject
Returns:
the user in which this item is contained, at whatever level of container nesting, or null if it is not contained by a user.

delete

@JSONMethod
public void delete(User from)
            throws MessageHandlerException
Message handler for the 'delete' message.

If the item is deletable, the item is deleted and a 'delete' message is broadcast to everyone in the context informing them of this.

Throws:
MessageHandlerException