org.ceryle.xnode
Class XNodeRevisionImpl

java.lang.Object
  extended by org.ceryle.xnode.XNodeRevisionImpl
All Implemented Interfaces:
Comparable, XNodeRevision

public class XNodeRevisionImpl
extends Object
implements XNodeRevision, Comparable

Provides an implementation of the XNodeRevision API as a struct representation of an XNode revision. The XNode supplied the constructor is used to copy the DOM Elements into their respective nodes in the underlying DOM Document, hence there are no setters for these Elements. The constructors for this class are protected, as XNodeRevisions are meant to be created by the XNodeRevisionManagerImpl.

The XNode Implementation (the package org.ceryle.xnode.*, both its source code and documentation), are released under the Apache 2.0 License. For more details, check the LICENSE file contained with the distribution, or see The Ceryle Project for more information. It is distributed with no warranty.

And in case this seems a bit confusing, revisions are objects specified by a version number.

Since:
XNode 1.2
Version:
$Id: XNodeRevisionImpl.java,v 3.6 2007-06-15 12:10:31 altheim Exp $
Author:
Murray Altheim

Constructor Summary
protected XNodeRevisionImpl(XNode xnode, Element revision, int version)
          Constructor for an XNodeRevision, supplied with the parent XNode.
 
Method Summary
 int compareTo(Object o)
          Compares this object with the specified object for order.
 Element getBodyElement()
          Return this revision's <xnode:Body> Element.
 Date getCreated()
          Return the creation date of this revision.
 String getCreatorOf()
          Returns the value of the XNodeRevision's creator property.
 Date getDateOf()
          Returns the revision date of the XNodeRevision as a Date.
 Element getHeaderElement()
          Return this revision's <xnode:Header> Element.
 Date getModified()
          Return the modification date of this revision.
 Set getProperties()
          Returns a Set containing the named properties of this XNodeRevision (as Strings), null if none have been set.
 Object getProperty(String name)
          Return a named property, or null if this revision does not contain it.
 Element getRevisionElement()
          Return this revision's embedded <Revision> Element.
 Boolean getSelected()
          Returns true if this revision is selected in a UI.
 int getSizeOf()
          Returns the value of the XNodeRevision's size property.
 int getVersionOf()
          Returns the value of the XNodeRevision's version number.
 XNode getXNode()
          Return this revision's parent XNode.
protected  void setBodyElement(Element body)
          Set this revision's <xnode:Body> Element.
protected  void setCreated(Date created)
          Set this XNodeRevision's creation date.
 void setCreatorOf(String creator)
          Sets the value of the XNodeRevision's creator property.
protected  void setHeaderElement(Element header)
          Set this revision's <xnode:Header> Element.
protected  void setModified(Date modified)
          Set this revision's modification date.
 void setProperty(String name, Object value)
          Set a name-value pair for a revision property with the String name and Object value.
 void setSelected(Boolean isSelected)
          Set the selected state of this revision (as used in a UI).
 void setSizeOf(int size)
          Sets the value of the XNodeRevision's size property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XNodeRevisionImpl

protected XNodeRevisionImpl(XNode xnode,
                            Element revision,
                            int version)
                     throws XNodeException
Constructor for an XNodeRevision, supplied with the parent XNode. The revision Element is the DOM container of the revision. As a validation the version parameter will be checked against the version number of the <xnode:Revision> Element's version attribute. All parameters are required.

Throws:
XNodeException
Method Detail

getXNode

public XNode getXNode()
Return this revision's parent XNode.

Specified by:
getXNode in interface XNodeRevision

getRevisionElement

public Element getRevisionElement()
Return this revision's embedded <Revision> Element.

Specified by:
getRevisionElement in interface XNodeRevision

setHeaderElement

protected void setHeaderElement(Element header)
Set this revision's <xnode:Header> Element.


getHeaderElement

public Element getHeaderElement()
Return this revision's <xnode:Header> Element.

Specified by:
getHeaderElement in interface XNodeRevision

setBodyElement

protected void setBodyElement(Element body)
Set this revision's <xnode:Body> Element.


getBodyElement

public Element getBodyElement()
Return this revision's <xnode:Body> Element.

Specified by:
getBodyElement in interface XNodeRevision

getDateOf

public Date getDateOf()
Returns the revision date of the XNodeRevision as a Date. This uses the creation date if the modified date is null. Returns null if unable to obtain a date from either created or modified dates. The Date values need to be set from the XNodeRevisionManager to be available as Dates rather than Strings from XNodeRevisionManager.getDisplayableRevisionDateOf(org.purl.xnode.XNodeRevision).

Specified by:
getDateOf in interface XNodeRevision

setCreated

protected void setCreated(Date created)
Set this XNodeRevision's creation date. This should match the creation date of the XNode itself.

This is not an XNodeRevision API method.


getCreated

public Date getCreated()
Return the creation date of this revision. This should match the creation date of the XNode itself.

This is not an XNodeRevision API method.

Specified by:
getCreated in interface XNodeRevision

setModified

protected void setModified(Date modified)
Set this revision's modification date. This is the modification date of the XNode when the revision was created.

This is not an XNodeRevision API method.


getModified

public Date getModified()
Return the modification date of this revision. This is the modification date of the XNode when the revision was created.

This is not an XNodeRevision API method.

Specified by:
getModified in interface XNodeRevision

setSelected

public void setSelected(Boolean isSelected)
Set the selected state of this revision (as used in a UI). This is part of the API since the main purpose of the revision objects is to make them accessible to users.

Specified by:
setSelected in interface XNodeRevision

getSelected

public Boolean getSelected()
Returns true if this revision is selected in a UI. This is part of the API since the main purpose of the revision objects is to make them accessible to users.

Specified by:
getSelected in interface XNodeRevision

setCreatorOf

public void setCreatorOf(String creator)
Sets the value of the XNodeRevision's creator property.


getCreatorOf

public String getCreatorOf()
Returns the value of the XNodeRevision's creator property. If there is no creator, returns an "N/A" message.

Specified by:
getCreatorOf in interface XNodeRevision

getVersionOf

public int getVersionOf()
Returns the value of the XNodeRevision's version number. If there is no set version, returns -1.

Specified by:
getVersionOf in interface XNodeRevision

setSizeOf

public void setSizeOf(int size)
Sets the value of the XNodeRevision's size property.

Specified by:
setSizeOf in interface XNodeRevision

getSizeOf

public int getSizeOf()
Returns the value of the XNodeRevision's size property. If the size has not been determined, returns 0.

Specified by:
getSizeOf in interface XNodeRevision

getProperties

public Set getProperties()
Returns a Set containing the named properties of this XNodeRevision (as Strings), null if none have been set.

Specified by:
getProperties in interface XNodeRevision

setProperty

public void setProperty(String name,
                        Object value)
                 throws NullPointerException
Set a name-value pair for a revision property with the String name and Object value. Because revision properties are immutable, this method should only be called during revision creation or recreation. If either parameter is null, a NullPointerException is thrown.

Specified by:
setProperty in interface XNodeRevision
Throws:
NullPointerException

getProperty

public Object getProperty(String name)
Return a named property, or null if this revision does not contain it. This currently returns Strings, and doesn't support multiple properties matching the name (e.g., this could return a List).

Specified by:
getProperty in interface XNodeRevision

compareTo

public int compareTo(Object o)
Compares this object with the specified object for order. Equality in this case does not necessarily mean the same XNodeRevision, only that the version numbers are equal (as this is all that is checked).

Specified by:
compareTo in interface Comparable


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.