From: <and...@us...> - 2015-04-22 15:57:18
|
Revision: 2222 http://sourceforge.net/p/jsbml/code/2222 Author: andreas-draeger Date: 2015-04-22 15:57:10 +0000 (Wed, 22 Apr 2015) Log Message: ----------- Implemented a new constructor for CVTerm that reads the content of XMLNode objects. This needs more testing, but it should work in principle. Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/CVTerm.java trunk/core/src/org/sbml/jsbml/xml/XMLAttributes.java Modified: trunk/core/src/org/sbml/jsbml/CVTerm.java =================================================================== --- trunk/core/src/org/sbml/jsbml/CVTerm.java 2015-04-22 15:54:01 UTC (rev 2221) +++ trunk/core/src/org/sbml/jsbml/CVTerm.java 2015-04-22 15:57:10 UTC (rev 2222) @@ -29,10 +29,13 @@ import java.util.regex.Pattern; import javax.swing.tree.TreeNode; +import javax.xml.stream.XMLStreamException; import org.sbml.jsbml.util.StringTools; import org.sbml.jsbml.util.TreeNodeAdapter; import org.sbml.jsbml.util.TreeNodeChangeEvent; +import org.sbml.jsbml.xml.XMLAttributes; +import org.sbml.jsbml.xml.XMLNode; /** * Contains all the MIRIAM URIs for a MIRIAM qualifier in the annotation element @@ -507,6 +510,42 @@ } /** + * + * @param miriam + */ + public CVTerm(XMLNode miriam) { + this(); + if (miriam.getName().equals("annotation")) { + miriam = miriam.getChildAt(0); + } + if (miriam.getName().equals("RDF")) { + miriam = miriam.getChildAt(0); + } + if (miriam.getName().equals("Description")) { + miriam = miriam.getChildAt(0); + } + if (miriam.getURI().equals("http://biomodels.net/biology-qualifiers/")) { + if (miriam.getPrefix().equals("bqbiol")) { + setQualifier(Qualifier.getBiologicalQualifierFor(miriam.getName())); + } else { + setQualifier(Qualifier.getModelQualifierFor(miriam.getName())); + } + miriam = miriam.getChildAt(0); + } + if (miriam.getName().equals("Bag")) { + for (int j = 0; j < miriam.getChildCount(); j++) { + XMLNode child = miriam.getChildAt(j); + if (child.getName().equals("li")) { + XMLAttributes attributes = child.getAttributes(); + for (int i = 0; i < attributes.size(); i++) { + addResource(attributes.getValue(i)); + } + } + } + } + } + + /** * Creates a {@link CVTerm} instance from a given {@link CVTerm}. * * @param term the {@link CVTerm} to clone Modified: trunk/core/src/org/sbml/jsbml/xml/XMLAttributes.java =================================================================== --- trunk/core/src/org/sbml/jsbml/xml/XMLAttributes.java 2015-04-22 15:54:01 UTC (rev 2221) +++ trunk/core/src/org/sbml/jsbml/xml/XMLAttributes.java 2015-04-22 15:57:10 UTC (rev 2222) @@ -510,11 +510,18 @@ * @return the number of attributes in this {@link XMLAttributes} set. */ public int getLength() { + return attributeNames.size(); + } + /** + * + * @return + * @see #getLength() + */ + public int size() { return attributeNames.size(); } - /** * Returns the local name of an attribute in this {@link XMLAttributes} set (by position). * <p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |