venice
Class ModelStorage

java.lang.Object
  |
  +--venice.ModelStorage

public class ModelStorage
extends java.lang.Object

ModelStorage provides a datastructure and operations for a datastructure containing a GXL-model.

Author:
Sami Ilonen

Field Summary
private  java.util.LinkedList edges
           
private  java.util.HashMap mElementIndex
           
private  java.util.HashMap mRelationshipIndex
           
private  java.util.LinkedList nodes
           
 
Constructor Summary
ModelStorage()
           
 
Method Summary
 void addElementToIndex(MElement inElement)
           
 void addRelationshipToIndex(MRelationship inRel)
           
private  void checkRelationships()
           
 void clear()
          This method is used to clear the existing data from this GXL-model.
 void createIndex()
          Creates index for Modelstorage.
 java.util.LinkedList getAllRelationships()
          Returns all relationships in the model
 java.util.LinkedList getChildren(java.lang.String inId)
          Returns the parent MElement of a certain MElement
 java.util.LinkedList getDependencies(java.lang.String inId)
          Returns the dependencies of a certain MElement
 MElement getElement(java.lang.String inId)
          Returns the MElement with inId as id.
 java.util.LinkedList getGeneralizations(java.lang.String inId)
          Returns the generalizations of a certain MElement
 java.util.LinkedList getIncomingRelationships(java.lang.String inElemId)
          Returns all relationships entering an MElement.
 MElement getParent(java.lang.String inId)
          Returns the parent MElement of a certain MElement
 java.util.LinkedList getRealizations(java.lang.String inId)
          Returns the realizations of a certain MElement
 MRelationship getRelationship(java.lang.String inId)
           
 java.util.LinkedList getRootNodes()
          Returns the root nodes of the model.
private  java.lang.String GXLEnd()
           
private  java.lang.String GXLStart()
           
 void loadGXL(java.io.InputStream inStream)
          This method is used to load a GXL-model from a given InputStream.
 void writeGXL(java.io.OutputStream ioStream)
          This method is used to write the information from the model to a OutputStream
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

nodes

private java.util.LinkedList nodes

edges

private java.util.LinkedList edges

mElementIndex

private java.util.HashMap mElementIndex

mRelationshipIndex

private java.util.HashMap mRelationshipIndex
Constructor Detail

ModelStorage

public ModelStorage()
Method Detail

loadGXL

public void loadGXL(java.io.InputStream inStream)
             throws java.io.IOException,
                    org.xml.sax.SAXException,
                    javax.xml.parsers.ParserConfigurationException
This method is used to load a GXL-model from a given InputStream.
Parameters:
inStream - is a java.io.InputStream containing the GXL-model.

writeGXL

public void writeGXL(java.io.OutputStream ioStream)
              throws java.io.IOException
This method is used to write the information from the model to a OutputStream

checkRelationships

private void checkRelationships()

GXLStart

private java.lang.String GXLStart()

GXLEnd

private java.lang.String GXLEnd()

clear

public void clear()
This method is used to clear the existing data from this GXL-model.

getAllRelationships

public java.util.LinkedList getAllRelationships()
Returns all relationships in the model
Returns:
Returns all relatioships in the model.

getParent

public MElement getParent(java.lang.String inId)
Returns the parent MElement of a certain MElement
Parameters:
inId - Id of the child which parent is returned.
Returns:
Parent MElement if available, null if no parent exist.

getChildren

public java.util.LinkedList getChildren(java.lang.String inId)
Returns the parent MElement of a certain MElement
Parameters:
inId - Id of the parent which children are returned.
Returns:
Linked list of MElements, null if no children exist.

getElement

public MElement getElement(java.lang.String inId)
Returns the MElement with inId as id.
Parameters:
inId - Id of the MElement which is required.
Returns:
MElement with Id = inId, null if not found.

getRelationship

public MRelationship getRelationship(java.lang.String inId)

getRootNodes

public java.util.LinkedList getRootNodes()
Returns the root nodes of the model.
Returns:
Linked list of MElements which do not have parents.

getDependencies

public java.util.LinkedList getDependencies(java.lang.String inId)
Returns the dependencies of a certain MElement
Returns:
Linked list of MRelationships which are dependencies of MElement which id is inID

getRealizations

public java.util.LinkedList getRealizations(java.lang.String inId)
Returns the realizations of a certain MElement
Returns:
Linked list of MRelationships which are realizations of MElement which id is inID.

getGeneralizations

public java.util.LinkedList getGeneralizations(java.lang.String inId)
Returns the generalizations of a certain MElement
Returns:
Linked list of MRelationships which are generalizations of MElement which id is inID

addElementToIndex

public void addElementToIndex(MElement inElement)

addRelationshipToIndex

public void addRelationshipToIndex(MRelationship inRel)

createIndex

public void createIndex()
Creates index for Modelstorage.

getIncomingRelationships

public java.util.LinkedList getIncomingRelationships(java.lang.String inElemId)
Returns all relationships entering an MElement.