org.moremotion.adom
Class ADOM

java.lang.Object
  extended by org.moremotion.adom.ADOMNode
      extended by org.moremotion.adom.ADOM
All Implemented Interfaces:
java.lang.Cloneable

public class ADOM
extends ADOMNode
implements java.lang.Cloneable

Application Data Object Model (ADOM)

ADOMs are MoreMotion's data objects to store hiearchically structured data in Request, Session or Application scopes. The responsibility of a MoreMotion programmer is to create ADOMs that contains the data required by the next MoreMotion page. The converting the ADOMs to XML strings is MoreMotion's responsibility.

The data of an ADOM is stored as ADOMNode objects which is linked to the root node of the ADOM. Note that The data of an ADOM can also be plain XML string instead of ADOMNode collections.

Version:
$Id: ADOM.java 51 2008-03-10 11:46:54Z erkan $

Field Summary
 
Fields inherited from class org.moremotion.adom.ADOMNode
DT_BOOL, DT_INTEGER, DT_NUMBER, DT_STRING
 
Constructor Summary
ADOM()
          Create a new ADOM object.
 
Method Summary
 void clear()
          Clears all the child nodes.
 java.lang.Object clone()
          Clones this ADOM object and returns it
 java.lang.String getResBundleName()
          Gets the resource bundle name of this ADOM
 ADOMNode getRootNode()
          Returns the root node
 java.lang.String getSequence()
           
 java.lang.String getXmlExplicit()
          Returns the XML string which was set explicitly.
 boolean hasXmlExplicit()
          Checks whether this ADOM stores its data as XML string or as ADOMNodes.
 boolean isProtected()
           
 boolean isStale(long timeoutInSecs)
          Checks whether this ADOM requires refreshing or not.
 java.util.Date lastTimeRefreshed()
          Returns the date when this ADOM last refreshed.
 void loadFromFile(java.io.File file)
          Loads the ADOM from the specified text file that contains a valid XML document.
 void loadFromFile(java.lang.String fileName)
          Loads the ADOM from the specified text file that contains a valid XML document.
 void parseXML(java.lang.String xml)
          Parses the given XML string and creates the ADOMNodes for this ADOM object
 void saveToFile(java.io.File file)
          Saves the ADOM to the specified file as XML string using the encoding UTF-8.
 void saveToFile(java.lang.String fileName)
          Saves the ADOM to the specified file as XML string using the encoding UTF-8.
 void setProtected(boolean value)
           
 void setResBundleName(java.lang.String resBundName)
           
 void setXmlExplicit(java.lang.String value)
          Sets the value of this ADOM with a XML string.
 java.lang.String toString()
          Returns the String representation of this node.
 
Methods inherited from class org.moremotion.adom.ADOMNode
addAttribute, addNode, equals, findNode, getAttribute, getAttributeCount, getAttributes, getName, getNode, getNodeCount, getNodes, getNodesArray, getNodeValue, getNodeValues, getParent, getPath, getSubNode, getValue, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsObject, getValueAsString, getValueForXML, hasChild, isRoot, main, removeAttribute, removeLast, removeNode, setName, setNodeValue, setNodeValues, setParent, setValue, setValue, setValue, setValue, sort, toXml, toXml, toXmlWithIndent
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ADOM

public ADOM()
Create a new ADOM object.

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this ADOM object and returns it

Overrides:
clone in class ADOMNode
Throws:
java.lang.CloneNotSupportedException

getSequence

public java.lang.String getSequence()

setResBundleName

public void setResBundleName(java.lang.String resBundName)

getResBundleName

public java.lang.String getResBundleName()
Gets the resource bundle name of this ADOM


setProtected

public void setProtected(boolean value)

isProtected

public boolean isProtected()

getRootNode

public ADOMNode getRootNode()
Description copied from class: ADOMNode
Returns the root node

Overrides:
getRootNode in class ADOMNode

setXmlExplicit

public void setXmlExplicit(java.lang.String value)
Sets the value of this ADOM with a XML string.

If this method is used for an ADOM, the XML string given will be used as it is when converting this ADOM to XML. If the ADOM has child nodes they will be ignored.

Parameters:
value - The XML string.

hasXmlExplicit

public boolean hasXmlExplicit()
Checks whether this ADOM stores its data as XML string or as ADOMNodes.

Returns:
true if the ADOM stores its data as XML string, false otherwise.

getXmlExplicit

public java.lang.String getXmlExplicit()
Returns the XML string which was set explicitly.


isStale

public boolean isStale(long timeoutInSecs)
Checks whether this ADOM requires refreshing or not.

Parameters:
timeoutInSecs - in seconds
Returns:
True if refresh is required, false otherwise.

lastTimeRefreshed

public java.util.Date lastTimeRefreshed()
Returns the date when this ADOM last refreshed.


clear

public void clear()
Clears all the child nodes.

Overrides:
clear in class ADOMNode

toString

public java.lang.String toString()
Returns the String representation of this node.

Overrides:
toString in class ADOMNode

saveToFile

public void saveToFile(java.lang.String fileName)
                throws ADOMException
Saves the ADOM to the specified file as XML string using the encoding UTF-8.

Parameters:
fileName - Name of the target file
Throws:
ADOMException - if save operation is not successful.

saveToFile

public void saveToFile(java.io.File file)
                throws ADOMException
Saves the ADOM to the specified file as XML string using the encoding UTF-8.

Parameters:
file - File object of the target file
Throws:
ADOMException - if save operation is not successful.

loadFromFile

public void loadFromFile(java.lang.String fileName)
                  throws ADOMException
Loads the ADOM from the specified text file that contains a valid XML document.

Parameters:
fileName - File name to load
Throws:
ADOMException - if load is not successful

loadFromFile

public void loadFromFile(java.io.File file)
                  throws ADOMException
Loads the ADOM from the specified text file that contains a valid XML document.

Parameters:
file - File object of the file to load
Throws:
ADOMException - if load is not successful

parseXML

public void parseXML(java.lang.String xml)
              throws ADOMException
Parses the given XML string and creates the ADOMNodes for this ADOM object

Parameters:
xml - The string that contains XML string to parse
Throws:
ADOMException - if parse is not successful


Copyright © 2002-2008 MOR YAZILIM. All Rights Reserved.