Holger's
Java API

com.antelmann.util.revision
Class DefaultRevisable

java.lang.Object
  extended by com.antelmann.util.revision.DefaultRevisable
All Implemented Interfaces:
Revisable

public class DefaultRevisable
extends Object
implements Revisable

a default implementation for a Revisable object, suitable as a base for specialized subclasses

Since:
30. November 2006, 22:54
Author:
Holger Antelmann

Field Summary
protected  ArrayList<Revision> history
           
protected  Revision last
           
protected  ArrayList<RevisionListener> listeners
           
protected  Status status
           
protected  ArrayList<RevisionVeto> vetos
           
 
Constructor Summary
DefaultRevisable(Status status)
          derives a special IDFactory from the given store
 
Method Summary
 void addListener(RevisionListener listener)
           
 void addRevisionVeto(RevisionVeto veto)
           
protected  void checkRevision(Revision revision)
          if returning without an exception, the revision is effectively accepted and all listeners are informed.
 void clearHistory()
           
 Revision getLastRevision()
          provides access to the last revision that was applied to this instance
 RevisionListener[] getRevisionListeners()
           
 Enumeration<Revision> getRevisions(Filter<? super Revision> filter)
          optionally allows to access revisions that were performed on this instance
 RevisionVeto[] getRevisionVetos()
           
 Status getStatus()
          reflects the current status of this instance
 void initHistory(Collection<? extends Revision> list)
          initializes the history list accessible through getRevisions(Filter)
 void removeListener(RevisionListener listener)
           
 boolean removeRevisionVeto(RevisionVeto veto)
           
 void revise(Object source, Object changes, Status newStatus, String comment)
          this implementation calls checkRevision(Revision), adds the revision to the history and then informs the listeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

status

protected Status status

last

protected Revision last

vetos

protected final ArrayList<RevisionVeto> vetos

listeners

protected final ArrayList<RevisionListener> listeners

history

protected final ArrayList<Revision> history
Constructor Detail

DefaultRevisable

public DefaultRevisable(Status status)
derives a special IDFactory from the given store

Method Detail

addListener

public void addListener(RevisionListener listener)
Specified by:
addListener in interface Revisable

removeListener

public void removeListener(RevisionListener listener)
Specified by:
removeListener in interface Revisable

getRevisionListeners

public RevisionListener[] getRevisionListeners()

getStatus

public Status getStatus()
Description copied from interface: Revisable
reflects the current status of this instance

Specified by:
getStatus in interface Revisable

addRevisionVeto

public void addRevisionVeto(RevisionVeto veto)

removeRevisionVeto

public boolean removeRevisionVeto(RevisionVeto veto)

getRevisionVetos

public RevisionVeto[] getRevisionVetos()

checkRevision

protected void checkRevision(Revision revision)
                      throws IOException,
                             RevisionException
if returning without an exception, the revision is effectively accepted and all listeners are informed. In addition to calling the VetoableRevisionListener in use, this implementation also checks whether the source of the given revision is indeed this instance and whether the given revision is indeed after any previous one in the history. overriding classes should also honor the RevisionVeto (in addition to other possible necessities).

Throws:
IOException
RevisionException

revise

public void revise(Object source,
                   Object changes,
                   Status newStatus,
                   String comment)
            throws RevisionException,
                   IOException
this implementation calls checkRevision(Revision), adds the revision to the history and then informs the listeners

Specified by:
revise in interface Revisable
Throws:
RevisionException - if this Revisable doesn't accept the given revision
IOException - if the any resources could not be access to perform the revision

clearHistory

public void clearHistory()

getLastRevision

public Revision getLastRevision()
Description copied from interface: Revisable
provides access to the last revision that was applied to this instance

Specified by:
getLastRevision in interface Revisable

initHistory

public void initHistory(Collection<? extends Revision> list)
                 throws IllegalArgumentException
initializes the history list accessible through getRevisions(Filter)

Throws:
IllegalArgumentException

getRevisions

public Enumeration<Revision> getRevisions(Filter<? super Revision> filter)
                                   throws UnsupportedOperationException
Description copied from interface: Revisable
optionally allows to access revisions that were performed on this instance

Specified by:
getRevisions in interface Revisable
Throws:
UnsupportedOperationException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads