Package org.sbml.jsbml

Examples of org.sbml.jsbml.SBase


   * xmlObject, Object sbmlElementToWrite)
   */
  public void writeAttributes(SBMLObjectForXML xmlObject,
      Object sbmlElementToWrite) {
    if (sbmlElementToWrite instanceof SBase) {
      SBase sbase = (SBase) sbmlElementToWrite;
      xmlObject.addAttributes(sbase.writeXMLAttributes());
    }
  }
View Full Code Here


   * xmlObject, Object sbmlElementToWrite)
   */
  public void writeElement(SBMLObjectForXML xmlObject,
      Object sbmlElementToWrite) {
    if (sbmlElementToWrite instanceof SBase) {
      SBase sbase = (SBase) sbmlElementToWrite;
      if (!xmlObject.isSetName()) {
        xmlObject.setName(sbase.getElementName());
      }
    }
  }
View Full Code Here

   * xmlObject, Object sbmlElementToWrite)
   */
  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

  /**
   * @return the listOfLocalRenderInformation
   */
  public ListOf<LocalRenderInformation> getListOfLocalRenderInformation() {
    if (!isSetListOfLocalRenderInformation()) {
      SBase sBase = getExtendedSBase();
      listOfLocalRenderInformation = new ListOf<LocalRenderInformation>(sBase.getLevel(), sBase.getVersion());
      listOfLocalRenderInformation.setNamespace(RenderConstants.namespaceURI);
      listOfLocalRenderInformation.setSBaseListType(ListOf.Type.other);
      sBase.registerChild(listOfLocalRenderInformation);
    }
    return listOfLocalRenderInformation;
  }
View Full Code Here

  /**
   * create a new LocalRenderInformation element and adds it to the ListOfLocalRenderInformation list
   */
  public LocalRenderInformation createLocalRenderInformation(String id) {
    SBase sBase = getExtendedSBase();
    LocalRenderInformation field = new LocalRenderInformation(id, sBase.getLevel(), sBase.getVersion());
    addLocalRenderInformation(field);
    return field;
  }
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

        listOfElementsToWrite.add(children.nextElement());
      }
    }

    if (sbase instanceof SBase) {
      SBase elem = (SBase) sbase;
      log4jLogger.debug("add to write: " + elem.getElementName()
        + " namespace: " + elem.getNamespace().toString());
      if (sbase instanceof ListOf<?>) {
        log4jLogger.debug("process a ListOf instance");
        ListOf<SBase> listOf = (ListOf<SBase>) sbase;
        if (!listOf.isEmpty()) {
          listOfElementsToWrite = new LinkedList<Object>();
          for (int i = 0; i < listOf.size(); i++) {
            SBase element = listOf.get(i);
            if (element != null) {
              listOfElementsToWrite.add(element);
            }
          }
        }
      } else if (sbase instanceof Layout) {
        Layout layout = (Layout) sbase;

        if (layout.isSetListOfSpeciesGlyphs()) {
          listOfElementsToWrite.add(layout.getListOfSpeciesGlyphs());
          ListOf<SpeciesGlyph> listOfSpeciesGlyph = layout
              .getListOfSpeciesGlyphs();
          log4jLogger.debug("found list of species glyph");
          log4jLogger.debug("list of species glyph: "
              + listOfSpeciesGlyph.getElementName());
        } else if (layout.isSetListOfCompartmentGlyphs()) {
          listOfElementsToWrite.add(layout
            .getListOfCompartmentGlyphs());
        } else if (layout.isSetListOfReactionGlyphs()) {
          listOfElementsToWrite.add(layout.getListOfReactionGlyphs());
        } else if (layout.isSetListOfTextGlyphs()) {
          listOfElementsToWrite.add(layout.getListOfTextGlyphs());
        }
      } else if (sbase instanceof Point) {
        Point point = (Point) sbase;
        SBase parent = point.getParentSBMLObject();
        if (parent instanceof CurveSegment) {
          log4jLogger.debug(" curveSegment: point element name: "
              + point.getElementName());
        }
      }
View Full Code Here

   */
  @Override
  public void writeAttributes(SBMLObjectForXML xmlObject,
    Object sbmlElementToWrite) {
    if (sbmlElementToWrite instanceof SBase) {
      SBase sbase = (SBase) sbmlElementToWrite;
      xmlObject.addAttributes(sbase.writeXMLAttributes());
    }
  }
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.