Package org.sbml.jsbml

Examples of org.sbml.jsbml.Annotation


    // an AnnotationParser can only be used for the annotations of a SBML
    // component. If the contextObject is not
    // an Annotation instance, this parser doesn't process any XML
    // attributes.
    if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;

      // If there is a prefix, the AnnotationParser will also store the
      // prefix within the key
      // and appends the attribute to the 'otherAnnotation' String of
      // annotation.
      if (!prefix.equals("")) {
        annotation.appendNoRDFAnnotation(" " + prefix + ":"
            + attributeName + "=\"" + value + "\"");
      } else {
        annotation.appendNoRDFAnnotation(" " + attributeName + "=\""
            + value + "\"");
      }

      // If the attribute is the last attribute of its element, we need to
      // close the element tag.
      if (isLastAttribute) {
        annotation.appendNoRDFAnnotation(">");
      }
    } else {
      // There is a syntax error, the attribute can't be read?
      // TODO: log the problem
    }
View Full Code Here


    // an AnnotationParser can only be used for the annotations of a SBML
    // component. If the contextObject is not
    // an Annotation instance, this parser doesn't process any texts.
    if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;
      annotation.appendNoRDFAnnotation(characters);

    } else if (characters.trim().length() > 0) {
      // There is a syntax error, the text can't be read?
      logger.warn("some characters migth be lost !! (element name = " + elementName + ", characters = " + characters + ", context = " + contextObject);      
    } else {
View Full Code Here

   
    // an AnnotationParser can only be used for the annotations of a SBML
    // component. If the contextObject is not
    // an Annotation instance, this parser doesn't process any elements.
    if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;
      StringBuilder builder = annotation.getAnnotationBuilder();

      // If the element is nested, we need to remove the default ending
      // tag of the element.
      if (isNested && annotation.getNonRDFannotation().endsWith(">")) {
        int builderLength = builder.length();
        builder.delete(builderLength - 3, builderLength);
      }

      // If the element is nested, we need to add a nested element ending
      // tag.
      if (isNested) {
        annotation.appendNoRDFAnnotation("/>");
      }
      // else, write a entire ending tag with the name of the element
      // (Store the prefix too into the String).
      else {
        if (!prefix.equals("")) {
          annotation.appendNoRDFAnnotation("</" + prefix + ":"
              + elementName + ">");
        } else {
          annotation.appendNoRDFAnnotation("</" + elementName
              + ">");
        }
      }
    } else {
      // There is a syntax error, the node can't be read?
View Full Code Here

    // If the element is an annotation and the contextObject is an
    // Annotation instance,
    // we need to add the namespace to the 'annotationNamespaces' HashMap of
    // annotation.
    if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;

      if (elementName.equals("annotation") && (annotation.getNonRDFannotation() != null) && (!annotation.getNonRDFannotation().contains("layout"))) {
        // Hack added to be able to parse properly the render annotation that are
        // stored inside: '<annotation xmlns="http://www.sbml.org/sbml/level2">'
        // It would make problem for models that contain the word layout in the non RDF annotation part as well as some namespace
        // declared on the top level annotation element... !!
        // The problem will go away as soon as the new annotation parsing is in place.
       
        // The namespaces are store using the SBMLCoreParser for the annotation element
        return;
      }

      if (prefix.trim().length() == 0) {
        annotation.appendNoRDFAnnotation(" " + localName + "=\"" + URI + "\"");
      } else {
        annotation.appendNoRDFAnnotation(" " + prefix + ":" + localName + "=\"" + URI + "\"");
      }
      annotation.appendNoRDFAnnotation("");
     
     
      // If the attribute is the last attribute of its element, we need to
      // close the element tag.
      if (isLastNamespace && !hasAttributes) {
        annotation.appendNoRDFAnnotation(">");
      }
    }
    // If the namespaces are declared in the sbml node, we need to add the
    // namespace to
    // the 'SBMLDocumentNamespaces' map of the SBMLDocument instance.
View Full Code Here

    // an AnnotationParser can only be used for the annotations of a SBML
    // component. If the contextObject is not
    // an Annotation instance, this parser doesn't process any elements.
    if (contextObject instanceof Annotation) {

      Annotation annotation = (Annotation) contextObject;

      // If there is a prefix, the AnnotationParser will also store the
      // prefix within the key
      // and appends the element to the 'otherAnnotation' String of
      // annotation.
      if (!prefix.equals("")) {
        annotation.appendNoRDFAnnotation("<" + prefix + ":"
            + elementName);
      } else {
        annotation.appendNoRDFAnnotation("<" + elementName);
      }

      // If the element has no attributes and namespaces, we need to close
      // the element tag.
      if (!hasAttributes && !hasNamespaces) {
        annotation.appendNoRDFAnnotation(">");
      }
      return annotation;
    } else {
      // There is a syntax error, the node can't be read ?
      logger.error(MessageFormat.format(
View Full Code Here

    // The namespace of this parser should be declared in a 'RDF' subnode of
    // annotation.
    // Adds the namespace to RDFAnnotationNamespaces HashMap of annotation.
    if (elementName.equals("RDF") && contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;

      annotation.addRDFAnnotationNamespace(localName, prefix, URI);
    }
  }
View Full Code Here

        logger.error(exc.getMessage());
      }
    }
    else if (contextObject instanceof Annotation)
    {
      Annotation annotation = (Annotation) contextObject;
      isAttributeRead = annotation.readAttribute(attributeName, prefix, value);
    }
    else if (contextObject instanceof SBasePlugin)
    {
      isAttributeRead = ((SBasePlugin) contextObject).readAttribute(attributeName, prefix, value);
    }
View Full Code Here

      Object contextObject) {
   
    // The namespace of this parser should be declared in the RDF subnode of the annotation.
    // Adds the namespace to the RDFAnnotationNamespaces HashMap of annotation.
    if (elementName.equals("RDF") && contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;
     
      annotation.addRDFAnnotationNamespace(localName, prefix, URI);
    }
  }
View Full Code Here

      boolean hasAttributes, boolean hasNamespaces,
      Object contextObject) {

    // A ModelQualifierParser can only modify a contextObject which is an instance of Annotation.
    if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;
     
      // This parser can parse only model Miriam qualifiers. This element should not have attributes or namespace declarations.
      // Creates a new CVTerm and
      // sets the qualifierType and modelQualifierType of this CVTerm. Then, adds the
      // initialised CVTerm to annotation.
      if (modelQualifierMap.containsKey(elementName) && !hasNamespaces && !hasAttributes) {
        CVTerm cvTerm = new CVTerm();
        cvTerm.setQualifierType(Type.MODEL_QUALIFIER);
        cvTerm.setModelQualifierType(modelQualifierMap.get(elementName));
       
        annotation.addCVTerm(cvTerm);
        return cvTerm;
      }
      else {
        // TODO: SBML syntax error, throw an exception?
      }
View Full Code Here

            value);
      } catch (Throwable exc) {
        System.err.println(exc.getMessage());
      }
    } else if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;
      isAttributeRead = annotation.readAttribute(attributeName, prefix,
          value);
    }

    if (!isAttributeRead) {
      // TODO: throw new SBMLException ("The attribute " + attributeName
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.Annotation

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.