Package org.sbml.jsbml

Examples of org.sbml.jsbml.SBase


   * xml.stax.SBMLObjectForXML, java.lang.Object)
   */
  public void writeNamespaces(SBMLObjectForXML xmlObject,
      Object sbmlElementToWrite) {
    if (sbmlElementToWrite instanceof SBase) {
      SBase sbase = (SBase) sbmlElementToWrite;

      if (sbase instanceof SBMLDocument) {
        SBMLDocument sbmlDocument = (SBMLDocument) sbmlElementToWrite;

        xmlObject.addAttributes(sbmlDocument
View Full Code Here


      XMLNode xmlNode = (XMLNode) contextObject;

      xmlNode.addChild(textNode);
     
    } else if (contextObject instanceof SBase) {
      SBase parentSBMLElement = (SBase) contextObject;
     
      XMLNode xmlNode = null;

      if (parentSBMLElement.isSetNotes() && typeOfNotes.equals("notes"))
      {
        xmlNode = parentSBMLElement.getNotes();
      }
      else if (typeOfNotes.equals("message") && parentSBMLElement instanceof Constraint
          && ((Constraint) parentSBMLElement).isSetMessage())
      {
        xmlNode = ((Constraint) parentSBMLElement).getMessage();
      }
      else
      {
        logger.warn("The type of String " + typeOfNotes + " on the element " +
            parentSBMLElement.getElementName() + " is unknown !! Some data might be lost");
        return;
      }

      xmlNode.addChild(textNode);
     
View Full Code Here

  {
    logger.debug("processStartElement : element name = " + elementName);
   
    if (elementName.equals("notes")
        && (contextObject instanceof SBase)) {
      SBase sbase = (SBase) contextObject;
      sbase.setNotes(new XMLNode(new XMLTriple("notes", null, null), new XMLAttributes()));
      return contextObject;
    }
   
    // Creating a StartElement XMLNode !! 
    XMLNode xmlNode = new XMLNode(new XMLTriple(elementName, null, prefix), new XMLAttributes(), new XMLNamespaces());
   
    if (contextObject instanceof SBase) {
      SBase parentSBMLElement = (SBase) contextObject;
     
      if (typeOfNotes.equals("notes")) {
        parentSBMLElement.getNotes().addChild(xmlNode);
      } else if (typeOfNotes.equals("message") && parentSBMLElement instanceof Constraint) {
        ((Constraint) parentSBMLElement).getMessage().addChild(xmlNode);
      } else {
        logger.warn("The type of String " + typeOfNotes + " on the element " +
            parentSBMLElement.getElementName() + " is unknown !! Some data might be lost");
      }
     
    } else if (contextObject instanceof XMLNode) {
      XMLNode parentNode = (XMLNode) contextObject;
     
View Full Code Here

        }
      } else if (pattern != null) {
        return cvt.filterResources(pattern).size() > 0;
      }
    } else if (o instanceof SBase) {
      SBase sbase = (SBase) o;
      if (qualifier != null) {
        if (pattern != null) {
          if (sbase.filterCVTerms(qualifier, pattern).size() > 0) {
            return true;
          }
        } else if (sbase.filterCVTerms(qualifier).size() > 0) {
          return true;
        }
      }
    }
    return false;
View Full Code Here

   *
   * @see org.sbml.jsbml.util.Filter#accepts(java.lang.Object)
   */
  public boolean accepts(Object o) {
    if (o instanceof SBase) {
      SBase sbase = (SBase) o;
      if (sbase.isSetSBOTerm() && (SBO.isChildOf(sbase.getSBOTerm(), term))) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

    Object sbmlElementToWrite) {

    logger.debug("FBCParser: writeElement");

    if (sbmlElementToWrite instanceof SBase) {
      SBase sbase = (SBase) sbmlElementToWrite;

      if (!xmlObject.isSetName()) {
        if (sbase instanceof ListOf<?>) {
          ListOf<?> listOf = (ListOf<?>) sbase;

          if (listOf.size() > 0) {
            if (listOf.get(0) instanceof FluxBound) {
              xmlObject.setName(FBCList.listOfFluxBounds.toString());
            } else if (listOf.get(0) instanceof Objective) {
              xmlObject.setName(FBCList.listOfObjectives.toString());
            } else if (listOf.get(0) instanceof FluxObjective) {
              xmlObject.setName(FBCList.listOfFluxObjectives.toString());
            }
          }
        } else {
          xmlObject.setName(sbase.getElementName());
        }
      }
      //      if (!xmlObject.isSetPrefix()) {
      //        xmlObject.setPrefix(FBCConstants.shortLabel);
      //      }
View Full Code Here

        return layoutModel.getListOfLayouts();
      }
    }
    else if (contextObject instanceof Layout) {
      Layout layout = (Layout) contextObject;
      SBase newElement = null;

      if (elementName.equals(listOfCompartmentGlyphs)) {

        newElement = layout.getListOfCompartmentGlyphs();
      }
      else if (elementName.equals(listOfSpeciesGlyphs)) {

        newElement = layout.getListOfSpeciesGlyphs();
      }
      else if (elementName.equals(listOfReactionGlyphs)) {

        newElement = layout.getListOfReactionGlyphs();
      }
      else if (elementName.equals(listOfTextGlyphs)) {

        newElement = layout.getListOfTextGlyphs();
      }
      else if (elementName.equals(listOfAdditionalGraphicalObjects)) {

        newElement = layout.getListOfAdditionalGraphicalObjects();
      }
      else if (elementName.equals(dimensions)) {
        Dimensions dimension = new Dimensions();
        layout.setDimensions(dimension);

        newElement = dimension;
      }

      if (newElement != null) {
        return newElement;
      }
    }
    else if (contextObject instanceof GraphicalObject) {
      GraphicalObject graphicalObject = (GraphicalObject) contextObject;

      if (elementName.equals(boundingBox)) {
        BoundingBox bbox = new BoundingBox();
        graphicalObject.setBoundingBox(bbox);

        return bbox;
      }

      if (graphicalObject instanceof ReactionGlyph)
      {
        ReactionGlyph reactionGlyph = (ReactionGlyph) graphicalObject;

        if (elementName.equals(curve)) {
          Curve curve = new Curve();
          reactionGlyph.setCurve(curve);

          return curve;
        }
        else if (elementName.equals(listOfSpeciesReferenceGlyphs))
        {
          ListOf<SpeciesReferenceGlyph> list = reactionGlyph.getListOfSpeciesReferenceGlyphs();
          return list;
        }

      }
      else if (graphicalObject instanceof SpeciesReferenceGlyph)
      {
        SpeciesReferenceGlyph speciesRefGlyph = (SpeciesReferenceGlyph) contextObject;

        if (elementName.equals(curve)) {
          Curve curve = new Curve();
          speciesRefGlyph.setCurve(curve);

          return curve;
        }

      }
      else if (graphicalObject instanceof GeneralGlyph)
      {
        GeneralGlyph generalGlyph = (GeneralGlyph) graphicalObject;

        if (elementName.equals(curve)) {
          Curve curve = new Curve();
          generalGlyph.setCurve(curve);

          return curve;
        }
        else if (elementName.equals(listOfSubGlyphs))
        {
          ListOf<GraphicalObject> list = generalGlyph.getListOfSubGlyphs();
          return list;
        }
        else if (elementName.equals(listOfReferenceGlyphs))
        {
          ListOf<ReferenceGlyph> list = generalGlyph.getListOfReferenceGlyphs();
          return list;
        }

      }
      else if (graphicalObject instanceof ReferenceGlyph)
      {
        ReferenceGlyph refGlyph = (ReferenceGlyph) contextObject;

        if (elementName.equals(curve)) {
          Curve curve = new Curve();
          refGlyph.setCurve(curve);

          return curve;
        }
      }

    }
    else if (contextObject instanceof BoundingBox)
    {
      BoundingBox bbox = (BoundingBox) contextObject;

      if (elementName.equals(position)) {
        Position position = new Position();
        bbox.setPosition(position);

        return position;
      }
      else if (elementName.equals(dimensions)) {
        Dimensions dimension = new Dimensions();
        bbox.setDimensions(dimension);

        return dimension;
      }
    }
    else if (contextObject instanceof Curve) {
      Curve curve = (Curve) contextObject;
      SBase newElement = null;

      if (elementName.equals(listOfCurveSegments)) {

        newElement = curve.getListOfCurveSegments();
      }

      if (newElement != null) {
        return newElement;
      }
    }
    else if (contextObject instanceof CurveSegment) {
      CubicBezier curveSegment = (CubicBezier) contextObject;

      if (elementName.equals(start)) {
        Start point = new Start();
        curveSegment.setStart(point);

        return point;
      }
      else if (elementName.equals(end)) {
        End point = new End();
        curveSegment.setEnd(point);

        return point;
      }
      else if (elementName.equals(basePoint1)) {
        BasePoint1 point = new BasePoint1();
        curveSegment.setBasePoint1(point);

        return point;
      }
      else if (elementName.equals(basePoint2)) {
        BasePoint2 point = new BasePoint2();
        curveSegment.setBasePoint2(point);

        return point;
      }

    }
    else if (contextObject instanceof ListOf<?>) {
      ListOf<SBase> listOf = (ListOf<SBase>) contextObject;
      SBase newElement = null;

      if (elementName.equals(layout)) {
        newElement = new Layout();
      }
      else if (elementName.equals(compartmentGlyph)) {
View Full Code Here

    Set<String> packageNamespaces = null;

    // logger.debug("getInitializedParsers : name space, object = " + name space + ", " + object);

    if (object instanceof SBase) {
      SBase sbase = (SBase) object;
      packageNamespaces = sbase.getNamespaces();
    } else if (object instanceof Annotation) {
      Annotation annotation = (Annotation) object;
      packageNamespaces = annotation.getNamespaces();
    } else {
      logger.warn("getInitializedParsers : I don't know what to do with " + object);
View Full Code Here

      // TODO : add all other namespaces !!

      if (isSBMLNamespaceNeeded) {
        // writing the SBML namespace
        SBMLDocument doc = null;
        SBase sbase = m.getMath().getParentSBMLObject();
        String sbmlNamespace = SBMLDocument.URI_NAMESPACE_L3V1Core;
       
        if (sbase != null) {
          doc = sbase.getSBMLDocument();
          sbmlNamespace = doc.getSBMLDocumentNamespaces().get("xmlns");
         
          if (sbmlNamespace == null) {
            logger.warn("writeMathML : the SBML namespace of this SBMLDocument" +
                " could not be found, using the default namespace (" +
View Full Code Here

           * and Version).
           */
          if (nextObjectToWrite instanceof ListOf<?>) {
            ListOf<?> list = (ListOf<?>) nextObjectToWrite;
            if (list.size() > 0) {
              SBase sb = list.getFirst();
              if ((sb instanceof UnitDefinition) && (parser
                      .getListOfSBMLElementsToWrite(nextObjectToWrite) == null)) {
                streamWriter.writeCharacters(whiteSpaces.substring(0, indent - indentCount));
                continue;
              }
            } else {
              streamWriter.writeCharacters(whiteSpaces.substring(0, indent - indentCount));
              continue;
            }
          }

          parentXmlObject.clear();

          /*
           * The following containers are all optional in a
           * <reaction>, but if any is present, it must not be empty:
           * <listOfReactants>, <listOfProducts>, <listOfModifiers>,
           * <kineticLaw>. (References: L2V2 Section 4.13; L2V3
           * Section 4.13; L2V4 Section 4.13)
           */
          if (nextObjectToWrite instanceof ListOf<?>) {
            ListOf<?> toTest = (ListOf<?>) nextObjectToWrite;
           
            if (toTest.size() > 0) {
              elementIsNested = true;
            }
           
            Type listType = toTest.getSBaseListType();
            if (listType == Type.none) {
              // Prevent writing invalid SBML if list types are
              // not set appropriately.
              throw new SBMLException(String.format(
                  "Unknown ListOf type \"%s\".",
                  toTest.getElementName()));
            }
            if (listType.equals(ListOf.Type.listOfReactants)
                || listType.equals(ListOf.Type.listOfProducts)
                || listType.equals(ListOf.Type.listOfModifiers)) {
              if (toTest.size() < 1) {
                continue; // Skip these, see reference in
                // comment above.
              }
            }
          } else if (nextObjectToWrite instanceof KineticLaw) {
            // TODO: Is there any chance, that an KineticLaw get's
            // an empty XML entity?
          }
         
          // Writing the element, starting by the indent
          streamWriter.writeCharacters(whiteSpaces);
          parser.writeElement(parentXmlObject, nextObjectToWrite);
          parser.writeNamespaces(parentXmlObject, nextObjectToWrite);
          parser.writeAttributes(parentXmlObject, nextObjectToWrite);
         
         
          SMOutputElement newOutPutElement = null;
          if (parentXmlObject.isSetName()) {
            boolean isClosedMathContainer = false, isClosedAnnotation = false;
           
            if (parentXmlObject.isSetNamespace()) {
              SMNamespace namespaceContext = smOutputParentElement
                  .getNamespace(
                      parentXmlObject.getNamespace(),
                      parentXmlObject.getPrefix());
              newOutPutElement = smOutputParentElement
                  .addElement(namespaceContext,
                      parentXmlObject.getName());
            } else {
              newOutPutElement = smOutputParentElement
                  .addElement(smOutputParentElement
                      .getNamespace(), parentXmlObject
                      .getName());
            }

            Iterator<Entry<String, String>> it = parentXmlObject
                .getAttributes().entrySet().iterator();
            while (it.hasNext()) {
              Entry<String, String> entry = it.next();
              newOutPutElement.addAttribute(entry.getKey(),
                  entry.getValue());
            }
            if (nextObjectToWrite instanceof SBase) {
              SBase s = (SBase) nextObjectToWrite;
              if (s.isSetNotes()) {
                writeNotes(s, newOutPutElement, streamWriter,
                    newOutPutElement.getNamespace()
                        .getURI(), indent + indentCount);
                elementIsNested = isClosedAnnotation = true;
              }
              if (s.isSetAnnotation()) {
                writeAnnotation(s, newOutPutElement,
                    streamWriter,
                    indent + indentCount, false);
                elementIsNested = true;
              }
              if (s.getChildCount() > 0) {
                // make sure that we'll have line breaks if an element has any sub elements.
                elementIsNested = true;
              }
            }
            if (nextObjectToWrite instanceof Constraint) {
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.SBase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.