From: <nik...@us...> - 2016-01-21 16:28:11
|
Revision: 2469 http://sourceforge.net/p/jsbml/code/2469 Author: niko-rodrigue Date: 2016-01-21 16:28:08 +0000 (Thu, 21 Jan 2016) Log Message: ----------- corrected the MultiParser class so that the ASTNode multi attributes are read properly and so that it write correctly 'listOfSpeciesTypeComponentIndexes' + made MultiASTNodePlugin extends AbstractASTNodePlugin Modified Paths: -------------- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiASTNodePlugin.java trunk/extensions/multi/src/org/sbml/jsbml/xml/parsers/MultiParser.java Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiASTNodePlugin.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiASTNodePlugin.java 2016-01-21 15:37:40 UTC (rev 2468) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiASTNodePlugin.java 2016-01-21 16:28:08 UTC (rev 2469) @@ -5,7 +5,7 @@ * This file is part of JSBML. Please visit <http://sbml.org/Software/JSBML> * for the latest version of JSBML and more information about SBML. * - * Copyright (C) 2009-2014 jointly by the following organizations: + * Copyright (C) 2009-2016 jointly by the following organizations: * 1. The University of Tuebingen, Germany * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK * 3. The California Institute of Technology, Pasadena, CA, USA @@ -24,7 +24,11 @@ import java.util.HashMap; import java.util.Map; +import javax.swing.tree.TreeNode; + +import org.sbml.jsbml.ASTNode; import org.sbml.jsbml.SBMLException; +import org.sbml.jsbml.ext.AbstractASTNodePlugin; /** * @@ -32,7 +36,7 @@ * @version $Rev$ * @since 1.1 */ -public class MultiASTNodePlugin { +public class MultiASTNodePlugin extends AbstractASTNodePlugin { /** * @@ -48,9 +52,24 @@ * */ public MultiASTNodePlugin() { - // TODO + super(); } + public MultiASTNodePlugin(MultiASTNodePlugin multiASTNodePlugin) { + super(multiASTNodePlugin); + + if (multiASTNodePlugin.isSetRepresentationType()) { + setRepresentationType(multiASTNodePlugin.getRepresentationType()); + } + if (multiASTNodePlugin.isSetSpeciesReference()) { + setSpeciesReference(multiASTNodePlugin.getSpeciesReference()); + } + } + + public MultiASTNodePlugin(ASTNode astNode) { + super(astNode); + } + /** * Returns the value of {@link #speciesReference}. * @@ -84,7 +103,7 @@ public void setSpeciesReference(String speciesReference) { String oldSpeciesReference = this.speciesReference; this.speciesReference = speciesReference; - // firePropertyChange(MultiConstants.speciesReference, oldSpeciesReference, this.speciesReference); + firePropertyChange(MultiConstants.speciesReference, oldSpeciesReference, this.speciesReference); } @@ -97,7 +116,7 @@ if (isSetSpeciesReference()) { String oldSpeciesReference = speciesReference; speciesReference = null; - // firePropertyChange(MultiConstants.speciesReference, oldSpeciesReference, this.speciesReference); + firePropertyChange(MultiConstants.speciesReference, oldSpeciesReference, this.speciesReference); return true; } return false; @@ -111,13 +130,9 @@ * @return the value of {@link #representationType}. */ public RepresentationType getRepresentationType() { - //TODO: if variable is boolean, create an additional "isVar" - //TODO: return primitive data type if possible (e.g., int instead of Integer) if (isSetRepresentationType()) { return representationType; } - // This is necessary if we cannot return null here. For variables of type String return an empty String if no value is defined. - // throw new PropertyUndefinedError(MultiConstants.representationType, this); return null; } @@ -141,7 +156,7 @@ public void setRepresentationType(RepresentationType representationType) { RepresentationType oldRepresentationType = this.representationType; this.representationType = representationType; - // firePropertyChange(MultiConstants.representationType, oldRepresentationType, this.representationType); + firePropertyChange(MultiConstants.representationType, oldRepresentationType, this.representationType); } @@ -154,7 +169,7 @@ if (isSetRepresentationType()) { RepresentationType oldRepresentationType = representationType; representationType = null; - // firePropertyChange(MultiConstants.representationType, oldRepresentationType, this.representationType); + firePropertyChange(MultiConstants.representationType, oldRepresentationType, this.representationType); return true; } return false; @@ -209,8 +224,8 @@ */ @Override public int hashCode() { - final int prime = 31; - int result = 1; + final int prime = 857; + int result = super.hashCode(); result = prime * result + ((representationType == null) ? 0 : representationType.hashCode()); result = prime * result @@ -227,12 +242,11 @@ if (this == obj) { return true; } - if (obj == null) { + + if (! super.equals(obj)) { return false; } - if (getClass() != obj.getClass()) { - return false; - } + MultiASTNodePlugin other = (MultiASTNodePlugin) obj; if (representationType != other.representationType) { return false; @@ -257,5 +271,40 @@ + ", representationType=" + representationType + "]"; } + @Override + public String getPackageName() { + return MultiConstants.packageName; + } + @Override + public String getPrefix() { + return MultiConstants.packageName; + } + + @Override + public String getURI() { + return getElementNamespace(); + } + + @Override + public TreeNode getChildAt(int childIndex) { + return null; + } + + @Override + public int getChildCount() { + return 0; + } + + @Override + public boolean getAllowsChildren() { + return false; + } + + @Override + public MultiASTNodePlugin clone() { + return new MultiASTNodePlugin(this); + } + + } Modified: trunk/extensions/multi/src/org/sbml/jsbml/xml/parsers/MultiParser.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/xml/parsers/MultiParser.java 2016-01-21 15:37:40 UTC (rev 2468) +++ trunk/extensions/multi/src/org/sbml/jsbml/xml/parsers/MultiParser.java 2016-01-21 16:28:08 UTC (rev 2469) @@ -44,6 +44,7 @@ import org.sbml.jsbml.ext.ASTNodePlugin; import org.sbml.jsbml.ext.SBasePlugin; import org.sbml.jsbml.ext.multi.IntraSpeciesReaction; +import org.sbml.jsbml.ext.multi.MultiASTNodePlugin; import org.sbml.jsbml.ext.multi.MultiCompartmentPlugin; import org.sbml.jsbml.ext.multi.MultiConstants; import org.sbml.jsbml.ext.multi.MultiModelPlugin; @@ -152,7 +153,7 @@ } } else if (contextObject instanceof ASTNode) { contextObject = ((ASTNode) contextObject).getPlugin(getShortLabel()); - } // TODO - ASTNode2 ? + } // TODO - ASTNode2 when it is used for reading. super.processAttribute(elementName, attributeName, value, uri, prefix, isLastAttribute, contextObject); } @@ -281,7 +282,9 @@ if (xmlObject.isSetName() && xmlObject.getName().equals("listOfBindingSiteSpeciesTypes")) { xmlObject.setName(MultiConstants.listOfSpeciesTypes); } - + else if (xmlObject.isSetName() && xmlObject.getName().equals("listOfSpeciesTypeComponentIndexs")) { + xmlObject.setName(MultiConstants.listOfSpeciesTypeComponentIndexes); + } // listOfIntraSpeciesReactions cannot happen as core ListOf don't depend on the first element for their name. if (logger.isDebugEnabled()) { @@ -343,7 +346,7 @@ public ASTNodePlugin createPluginFor(ASTNode astNode) { if (astNode != null) { - return null; // TODO + return new MultiASTNodePlugin(astNode); } return null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |