cz.psika.numerist
Class ItemMemento

java.lang.Object
  extended by cz.psika.numerist.Memento
      extended by cz.psika.numerist.ItemMemento
All Implemented Interfaces:
History, Item, ItemObservable
Direct Known Subclasses:
DiagramCanvasMemento, Entry.EntryMemento

public class ItemMemento
extends Memento
implements Item

Item history object.

Author:
Tomas Psika

Field Summary
protected  java.lang.Integer id
          Internal entry identifier.
protected  java.lang.String sourceString
          Source string.
protected  Style style
          Style.
 
Constructor Summary
protected ItemMemento()
          Constructor.
 
Method Summary
 void addObserver(ItemObserver observer)
          Attach observer to the object.
protected  void copyId(int identifier)
          Copy identifier from original Item object.
 Memento createMemento()
          Create history object.
 void deleteObserver(ItemObserver observer)
          Detach observer.
 DiagramCanvas fetchDiagram(boolean thumbnail)
           
 Entry fetchEntry()
          Get entry representing the diagram or current Entry object.
protected  java.lang.Integer getId()
          Get internal identifier.
protected  java.lang.String getString()
          Get source string.
protected  Style getStyle()
          Get entry's style.
 void notifyObservers(Constants.ItemEvents event)
          Notify all attached observers.
 void setMemento(Memento memento)
          Initialize object to state in the past.
protected  void setString(java.lang.String itemString)
          Set source string.
protected  void setStyle(Style itemStyle)
          Set style for the entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected java.lang.Integer id
Internal entry identifier.


sourceString

protected java.lang.String sourceString
Source string.


style

protected Style style
Style.

Constructor Detail

ItemMemento

protected ItemMemento()
Constructor. Initializes style to default application style.

Method Detail

setString

protected void setString(java.lang.String itemString)
Set source string.

Parameters:
itemString - source string (not truncated)

getString

protected java.lang.String getString()
Get source string.

Returns:
copy of source string

setStyle

protected void setStyle(Style itemStyle)
Set style for the entry.

Parameters:
itemStyle - style to set

getStyle

protected Style getStyle()
Get entry's style.

Returns:
entry's current style

copyId

protected void copyId(int identifier)
Copy identifier from original Item object. Be very careful about use of this method. Dont assign existing identifiers to different entries.

Parameters:
identifier - internal identifier

getId

protected java.lang.Integer getId()
Get internal identifier.

Returns:
internal identifier

fetchDiagram

public DiagramCanvas fetchDiagram(boolean thumbnail)

fetchEntry

public Entry fetchEntry()
Description copied from interface: Item
Get entry representing the diagram or current Entry object. Beware of that the object returned is always original, not just copy. This method is called often, so we need direct access to instance. Whenever you need copy of the object, implement that functionality elsewhere out of this interface.

Specified by:
fetchEntry in interface Item
Returns:
Entry object

createMemento

public Memento createMemento()
Description copied from interface: History
Create history object. Memento class is just abstract class, because items and diagram variations need to save specific values. See classes derived from Memento for next details.

Specified by:
createMemento in interface History
Returns:
object of type Memento used to save history status

setMemento

public void setMemento(Memento memento)
Description copied from interface: History
Initialize object to state in the past.

Specified by:
setMemento in interface History
Parameters:
memento - Memento object saving history status
See Also:
History.createMemento()

addObserver

public void addObserver(ItemObserver observer)
Description copied from interface: ItemObservable
Attach observer to the object.

Specified by:
addObserver in interface ItemObservable
Parameters:
observer - an observer to attach

deleteObserver

public void deleteObserver(ItemObserver observer)
Description copied from interface: ItemObservable
Detach observer.

Specified by:
deleteObserver in interface ItemObservable
Parameters:
observer - to remove

notifyObservers

public void notifyObservers(Constants.ItemEvents event)
Description copied from interface: ItemObservable
Notify all attached observers.

Specified by:
notifyObservers in interface ItemObservable
Parameters:
event - type of event to notify all registered observers