org.elkoserver.server.context.mods
Class Note

java.lang.Object
  extended by org.elkoserver.server.context.Mod
      extended by org.elkoserver.server.context.mods.Note
All Implemented Interfaces:
Cloneable, DispatchTarget, Encodable, ItemMod

public class Note
extends Mod
implements ItemMod

Mod to hold a free-floating chunk of text. This mod must be attached to an item, not to a user or context.


Constructor Summary
Note(String text, StyleDesc style)
          JSON-driven constructor.
 
Method Summary
 void edit(User from, OptString text, StyleDesc style)
          Message handler for the 'edit' message.
 JSONLiteral encode(EncodeControl control)
          Encode this mod for transmission or persistence.
 
Methods inherited from class org.elkoserver.server.context.Mod
attachTo, clone, context, ensureHolding, ensureInContext, ensureReachable, ensureSameContext, ensureSameUser, holder, isEphemeral, markAsChanged, markAsEphemeral, object
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Note

@JSONMethod(value={"text","style"})
public Note(String text,
                            StyleDesc style)
JSON-driven constructor.

Parameters:
text - The text of this note.
style - How its text is to be displayed.
Method Detail

encode

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

Specified by:
encode in interface Encodable
Parameters:
control - Encode control determining what flavor of encoding should be done.
Returns:
a JSON literal representing this mod.

edit

@JSONMethod(value={"text","?style"})
public void edit(User from,
                                 OptString text,
                                 StyleDesc style)
          throws MessageHandlerException
Message handler for the 'edit' message.

This message is a request from a client to change the text of this note or one or more of its style attributes. If the change is successful, a corresponding 'edit' message is broadcast to the context.

recv: { to:REF, op:"edit", text:optSTR, style:optSTYLE }
send: { to:REF, op:"edit", text:optSTR, style:optSTYLE }

Parameters:
from - The user who sent the message.
text - New text string value (optional).
style - New style information (optional).
Throws:
MessageHandlerException - if 'from' is not in the same context as this mod or if invalid style information is provided.