org.keridwen.core.data.model.impl
Class DefaultDataModel

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by org.keridwen.core.data.model.impl.DefaultDataModel
All Implemented Interfaces:
Serializable, TreeModel, DataModel

public class DefaultDataModel
extends DefaultTreeModel
implements DataModel

Default implementation of Keridwen hierarchical data model.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
DefaultDataModel()
          Default constructor.
DefaultDataModel(Node<?> root)
          Creates a DataModel with the given root Node.
 
Method Summary
 void addModificationStateListener(ModificationStateListener listenerToAdd)
          Adds the given ModificationStateListener to the list of listeners.
 int addNode(Node<?> newChild, Node<?> parent)
          Adds the given child Node as the last child of the given parent Node.
 void addNodeReaderForPath(NodeReader<?> readerToAdd, String nodePath)
          Associates the given NodeReader to the provided node absolute path in the XML file.
 DataModelInformation getDataModelInformation()
          Gets the DataModel metadata
 ModificationState getModificationState()
          Gets the ModificationState of the DataModel.
 NodeReader<?> getNodeReader(String nodePath)
          Gets the NodeReader associated with the given file format.
 Node<?> getRootNode()
          Gets the DataModel root Node.
 void insertNodeInto(Node<?> newChild, Node<?> parent, int index)
          Inserts the given child Node in the given parent Node, at the given index.
 void loadModel(URI rootURI)
          Loads the DataModel from the given root Node URI.
 void removeModificationStateListener(ModificationStateListener listenerToRemove)
          Removes the given ModificationStateListener from the list of listeners.
 void removeReaderForPath(String nodePath)
          Removes the association between the given node path and its NodeReader.
 void saveModel()
          Saves the whole model.
 void saveModelAs(URI rootURI)
          Saves the DataModel, with the given URI as the root Node.
 void setModificationState(ModificationState newState)
          Sets the ModificationState of the DataModel to the given new state.
 void setRootNode(Node<?> rootNode)
          Sets the root Node of the DataModel.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.tree.TreeModel
addTreeModelListener, getChild, getChildCount, getIndexOfChild, getRoot, isLeaf, removeTreeModelListener, valueForPathChanged
 

Constructor Detail

DefaultDataModel

public DefaultDataModel()
Default constructor.


DefaultDataModel

public DefaultDataModel(Node<?> root)
Creates a DataModel with the given root Node.

Parameters:
root - the root Node to set
Method Detail

getRootNode

public Node<?> getRootNode()
Description copied from interface: DataModel
Gets the DataModel root Node.

Specified by:
getRootNode in interface DataModel
Returns:
the root Node of the DataModel

setRootNode

public void setRootNode(Node<?> rootNode)
Description copied from interface: DataModel
Sets the root Node of the DataModel.

Specified by:
setRootNode in interface DataModel
Parameters:
rootNode - the root Node to set

insertNodeInto

public void insertNodeInto(Node<?> newChild,
                           Node<?> parent,
                           int index)
Description copied from interface: DataModel
Inserts the given child Node in the given parent Node, at the given index.

Specified by:
insertNodeInto in interface DataModel
Parameters:
newChild - the child Node to add
parent - the parent Node in which to add the new Node
index - the index of insertion

addNode

public int addNode(Node<?> newChild,
                   Node<?> parent)
Description copied from interface: DataModel
Adds the given child Node as the last child of the given parent Node.

Specified by:
addNode in interface DataModel
Parameters:
newChild - the Node to add
parent - the Node in which to add the new Node
Returns:
the index of the inserted Node

saveModel

public void saveModel()
Description copied from interface: DataModel
Saves the whole model.

Specified by:
saveModel in interface DataModel

saveModelAs

public void saveModelAs(URI rootURI)
Description copied from interface: DataModel
Saves the DataModel, with the given URI as the root Node.

Specified by:
saveModelAs in interface DataModel
Parameters:
rootURI - the root Node URI

loadModel

public void loadModel(URI rootURI)
Description copied from interface: DataModel
Loads the DataModel from the given root Node URI.

Specified by:
loadModel in interface DataModel
Parameters:
rootURI - the root Node URI

getDataModelInformation

public DataModelInformation getDataModelInformation()
Description copied from interface: DataModel
Gets the DataModel metadata

Specified by:
getDataModelInformation in interface DataModel
Returns:
the DataModelInformation of the DataModel

getModificationState

public ModificationState getModificationState()
Description copied from interface: DataModel
Gets the ModificationState of the DataModel.

Specified by:
getModificationState in interface DataModel
Returns:
the ModificationState of the DataModel

setModificationState

public void setModificationState(ModificationState newState)
Description copied from interface: DataModel
Sets the ModificationState of the DataModel to the given new state.

Specified by:
setModificationState in interface DataModel
Parameters:
newState - the ModificationState to set.

addModificationStateListener

public void addModificationStateListener(ModificationStateListener listenerToAdd)
Description copied from interface: DataModel
Adds the given ModificationStateListener to the list of listeners.

Specified by:
addModificationStateListener in interface DataModel
Parameters:
listenerToAdd - the ModificationStateListener to add

removeModificationStateListener

public void removeModificationStateListener(ModificationStateListener listenerToRemove)
Description copied from interface: DataModel
Removes the given ModificationStateListener from the list of listeners.

Specified by:
removeModificationStateListener in interface DataModel
Parameters:
listenerToRemove - the ModificationStateListener to remove

getNodeReader

public NodeReader<?> getNodeReader(String nodePath)
Description copied from interface: DataModel
Gets the NodeReader associated with the given file format.

Specified by:
getNodeReader in interface DataModel
Parameters:
nodePath - the file format of the node currently read
Returns:
the NodeReader for the given file format

addNodeReaderForPath

public void addNodeReaderForPath(NodeReader<?> readerToAdd,
                                 String nodePath)
Description copied from interface: DataModel
Associates the given NodeReader to the provided node absolute path in the XML file.

Specified by:
addNodeReaderForPath in interface DataModel
Parameters:
readerToAdd - the NodeReader to add
nodePath - the absolute path of the node in the XML file

removeReaderForPath

public void removeReaderForPath(String nodePath)
Description copied from interface: DataModel
Removes the association between the given node path and its NodeReader.

Specified by:
removeReaderForPath in interface DataModel
Parameters:
nodePath - the absolute node path in the XML file


Copyright © 2010-2013 Artenum. All Rights Reserved.