Class ModelImpl

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

public class ModelImpl extends Object implements Model
This is the default implementation of the Model. Use a factory to create a model.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Map<String,BioPAXElement>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
     
     
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(BioPAXElement aBioPAXElement)
    This method adds the given object to this model.
    <T extends BioPAXElement>
    T
    addNew(Class<T> c, 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
    This method checks for the biopax element with the given id, returns true if the object with the given id exists.
    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.
    This method returns the level of the objects that are contained within this model.
    URI of this BioPAX Model.
    This method returns a map of name space prefixes.
    This method returns a set of objects in the model.
    <T extends BioPAXElement>
    Set<T>
    getObjects(Class<T> filterBy)
    This method returns a set of objects in the model of the given class.
    URI of this BioPAX Model.
    Gets the model's xml:base (URI prefix/namespace), which normally the majority of the BioPAX object's absolute URIs in the model begin with.
    boolean
    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
    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)
    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
    This method sets the factory this model will use for creating BioPAX objects.
    void
    setName(String modelName)
     
    void
    setUri(String modelUri)
     
    void
    Sets the xml:base to use when exporting a BioPAX model.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ModelImpl

      protected ModelImpl()
    • ModelImpl

      protected ModelImpl(BioPAXLevel level)
    • ModelImpl

      public ModelImpl(BioPAXFactory factory)
  • Method Details

    • containsID

      public boolean containsID(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(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 Map<String,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 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> Set<T> getObjects(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
      Type Parameters:
      T - a BioPAX type
      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(Class<T> c, 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
      Type Parameters:
      T - a BioPAX type
      Parameters:
      c - the BioPAX model interface class
      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 - BioPAX object (individual)
      Returns:
      true/false - whether this model contains the object or not
      See Also:
    • getUri

      public String getUri()
      Description copied from interface: Model
      URI of this BioPAX Model. This can be used in many ways to refer to this model when: - logging; - merging several models; - converting to or from another data format, such as GMT (GSEA); - saving to or reading from RDF/XML file (e.g., save/read a special Provenance object)
      Specified by:
      getUri in interface Model
      Returns:
      model's uri
    • setUri

      public void setUri(String modelUri)
      Specified by:
      setUri in interface Model
    • getName

      public String getName()
      Description copied from interface: Model
      URI of this BioPAX Model. This can be used in many ways; see Model.getUri().
      Specified by:
      getName in interface Model
      Returns:
      model's name
    • setName

      public void setName(String modelName)
      Specified by:
      setName in interface Model
    • add

      public void add(BioPAXElement aBioPAXElement)
      Description copied from interface: Model
      This method adds the given object 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
      Parameters:
      existing - object to be replaced
      replacement - the replacement BioPAX object
    • 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:
    • 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)
      Specified by:
      repair in interface Model
    • setXmlBase

      public void setXmlBase(String base)
      Description copied from interface: Model
      Sets the xml:base to use when exporting a BioPAX model. Usually, is is a data-provider's URI prefix, e.g., xml:base="http://www.pantherdb.org/pathways/biopax#" Setting this to null makes the exporter print using absolute URIs (and rdf:about) instead of relative ones (and rdf:ID).
      Specified by:
      setXmlBase in interface Model
      Parameters:
      base - a URI prefix or null.
    • getXmlBase

      public String getXmlBase()
      Description copied from interface: Model
      Gets the model's xml:base (URI prefix/namespace), which normally the majority of the BioPAX object's absolute URIs in the model begin with. Note: it's not required that all the BioPAX objects in the model have the same URI prefix/namespace; e.g., there are can be (and perfectly legal) objects that use other URI bases, such as http://identifiers.org/, http://purl.org/, etc. (- usually these are well-known standard xml bases, or these result from merging several BioPAX models of different data providers into one model.)
      Specified by:
      getXmlBase in interface Model
      Returns:
      xml:base value