org.biopax.paxtools.impl
Class ModelImpl

java.lang.Object
  extended by org.biopax.paxtools.impl.ModelImpl
All Implemented Interfaces:
java.io.Serializable, Model

public class ModelImpl
extends java.lang.Object
implements Model

This is the default implementation of the Model.

See Also:
Serialized Form

Field Summary
protected  java.util.Map<java.lang.String,BioPAXElement> idMap
           
 
Constructor Summary
protected ModelImpl()
           
  ModelImpl(BioPAXFactory factory)
           
protected ModelImpl(BioPAXLevel level)
           
 
Method Summary
 void add(BioPAXElement aBioPAXElement)
          This method add the given onject to this model.
<T extends BioPAXElement>
T
addNew(java.lang.Class<T> c, java.lang.String id)
          This method creates a new object using the model's factory, adds it to the model and returns it.
 boolean contains(BioPAXElement aBioPAXElement)
          This method returns true if given element is the same object ("==") as the object stored in the model usually (for self-consistent models) but not necessarily under the element's ID.
 boolean containsID(java.lang.String id)
          This method checks for the biopax element with the given id, returns true if the object with the given id exists.
 BioPAXElement getByID(java.lang.String id)
          This method returns the biopax element with the given id, returns null if the object with the given id does not exist in this model.
 BioPAXLevel getLevel()
          This method returns the level of the objects that are contained within this model.
 java.util.Map<java.lang.String,java.lang.String> getNameSpacePrefixMap()
          This method returns a map of name space prefixes.
 java.util.Set<BioPAXElement> getObjects()
          This method returns a set of objects in the model.
<T extends BioPAXElement>
java.util.Set<T>
getObjects(java.lang.Class<T> filterBy)
          This method returns a set of objects in the model of the given class.
 boolean isAddDependencies()
          When addDependencies is false, the model will not check for the dependent objects of a newly added object.
 void merge(Model source)
          This is default implementation that uses the id-based merging (SimpleMerger.merge(Model, Model...)) NOTE: some applications, such as those dealing with persistence/transactions or advanced BioPAX alignment/comparison algorithms (like the Patch), may have to implement and use a more specific method instead.
 void remove(BioPAXElement aBioPAXElement)
          This method removes the given BioPAX Element from the model.
 void repair()
          This implementation "repairs" the model without unnecessarily copying objects: - recursively adds lost "children" (not null object property values for which Model.contains(BioPAXElement) returns False) - updates object properties (should refer to model's elements) - repairs the internal map so that a object returned by getByID(String) does actually have this ID
 void replace(BioPAXElement existing, BioPAXElement replacement)
          It does not automatically replace or clean up the old element's object properties, therefore, some child elements may become "dangling" if they were used by the replaced element only.
 void setAddDependencies(boolean value)
          When set to false, the model will not check for the dependent objects of a newly added object.
 void setFactory(BioPAXFactory factory)
          This method sets the factory this model will use for creating BioPAX objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

idMap

protected final java.util.Map<java.lang.String,BioPAXElement> idMap
Constructor Detail

ModelImpl

protected ModelImpl()

ModelImpl

protected ModelImpl(BioPAXLevel level)

ModelImpl

public ModelImpl(BioPAXFactory factory)
Method Detail

containsID

public boolean containsID(java.lang.String id)
Description copied from interface: Model
This method checks for the biopax element with the given id, returns true if the object with the given id exists. in this model.

Specified by:
containsID in interface Model
Parameters:
id - of the object to be retrieved.
Returns:
biopax element with the given id.

getByID

public BioPAXElement getByID(java.lang.String id)
Description copied from interface: Model
This method returns the biopax element with the given id, returns null if the object with the given id does not exist in this model.

Specified by:
getByID in interface Model
Parameters:
id - of the object to be retrieved.
Returns:
biopax element with the given id.

getNameSpacePrefixMap

public java.util.Map<java.lang.String,java.lang.String> getNameSpacePrefixMap()
Description copied from interface: Model
This method returns a map of name space prefixes. This map can be modified.

Specified by:
getNameSpacePrefixMap in interface Model
Returns:
a map, mapping prefixes to full namespaces.

setFactory

public void setFactory(BioPAXFactory factory)
Description copied from interface: Model
This method sets the factory this model will use for creating BioPAX objects. For example Model.addNew(Class, String) method uses this factory.

Specified by:
setFactory in interface Model
Parameters:
factory - this model will use for creating BioPAX objects.

getObjects

public java.util.Set<BioPAXElement> getObjects()
Description copied from interface: Model
This method returns a set of objects in the model. Contents of this set can not be modified.

Specified by:
getObjects in interface Model
Returns:
an unmodifiable set of objects.

getObjects

public <T extends BioPAXElement> java.util.Set<T> getObjects(java.lang.Class<T> filterBy)
Description copied from interface: Model
This method returns a set of objects in the model of the given class. Contents of this set should not be modified.

Specified by:
getObjects in interface Model
Parameters:
filterBy - class to be used as a filter.
Returns:
an unmodifiable set of objects of the given class.

remove

public void remove(BioPAXElement aBioPAXElement)
Description copied from interface: Model
This method removes the given BioPAX Element from the model. Other objects in the model can still point to this object. It is user's responsibility to properly excise these properties.

Specified by:
remove in interface Model
Parameters:
aBioPAXElement - to be removed.

addNew

public <T extends BioPAXElement> T addNew(java.lang.Class<T> c,
                                          java.lang.String id)
Description copied from interface: Model
This method creates a new object using the model's factory, adds it to the model and returns it.

Specified by:
addNew in interface Model
Parameters:
c - a biopax model interface
id - of the new object
Returns:
newly created object

contains

public boolean contains(BioPAXElement aBioPAXElement)
This method returns true if given element is the same object ("==") as the object stored in the model usually (for self-consistent models) but not necessarily under the element's ID.

Specified by:
contains in interface Model
Parameters:
aBioPAXElement -
Returns:

add

public void add(BioPAXElement aBioPAXElement)
Description copied from interface: Model
This method add the given onject to this model. If the object points to other objects that are not in the model, it is user's responsibility to add them into the model as well. If an object with the same id already exists, it will throw an IllegalBioPAXArgumentException

Specified by:
add in interface Model
Parameters:
aBioPAXElement - to be added

getLevel

public BioPAXLevel getLevel()
Description copied from interface: Model
This method returns the level of the objects that are contained within this model.

Specified by:
getLevel in interface Model
Returns:
level of the objects within this model.

setAddDependencies

public void setAddDependencies(boolean value)
Description copied from interface: Model
When set to false, the model will not check for the dependent objects of a newly added object. When true it will traverse and add all dependent objects that are not already in the model. This feature is currently experimental.

Specified by:
setAddDependencies in interface Model
Parameters:
value - defining the dependency adding behaviour

isAddDependencies

public boolean isAddDependencies()
Description copied from interface: Model
When addDependencies is false, the model will not check for the dependent objects of a newly added object. When true it will traverse and add all dependent objects that are not already in the model. This feature is currently experimental.

Specified by:
isAddDependencies in interface Model
Returns:
whether adding dependencies.

replace

public void replace(BioPAXElement existing,
                    BioPAXElement replacement)
It does not automatically replace or clean up the old element's object properties, therefore, some child elements may become "dangling" if they were used by the replaced element only. Can also clear object properties (- replace with null).

Specified by:
replace in interface Model

merge

public void merge(Model source)
This is default implementation that uses the id-based merging (SimpleMerger.merge(Model, Model...)) NOTE: some applications, such as those dealing with persistence/transactions or advanced BioPAX alignment/comparison algorithms (like the Patch), may have to implement and use a more specific method instead.

Specified by:
merge in interface Model
Parameters:
source - a model to merge
See Also:
SimpleMerger, Model.merge(Model)

repair

public void repair()
This implementation "repairs" the model without unnecessarily copying objects: - recursively adds lost "children" (not null object property values for which Model.contains(BioPAXElement) returns False) - updates object properties (should refer to model's elements) - repairs the internal map so that a object returned by getByID(String) does actually have this ID

Specified by:
repair in interface Model


Copyright © 2011 BioPAX. All Rights Reserved.