Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/src/org/sbml/jsbml/ASTNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -5056,4 +5056,15 @@ public void canonicalize() {
}
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
14 changes: 13 additions & 1 deletion core/src/org/sbml/jsbml/AbstractSBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -3492,4 +3492,16 @@ public String toSBML() {
}
}

}
/**
* Accepts a generic visitor to traverse this SBase component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
@Override
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
13 changes: 12 additions & 1 deletion core/src/org/sbml/jsbml/Annotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -940,4 +940,15 @@ public void unsetNonRDFannotation() {
}
}

}
/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
14 changes: 13 additions & 1 deletion core/src/org/sbml/jsbml/CVTerm.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.swing.tree.TreeNode;
import javax.xml.stream.XMLStreamException;

import org.sbml.jsbml.CVTerm.Qualifier;
import org.sbml.jsbml.util.StringTools;
import org.sbml.jsbml.util.TreeNodeAdapter;
import org.sbml.jsbml.util.TreeNodeChangeEvent;
Expand Down Expand Up @@ -1405,4 +1406,15 @@ public void setUnknownQualifierName(String unknownQualifierName) {
this.unknownQualifierName = unknownQualifierName;
}

}
/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
13 changes: 12 additions & 1 deletion core/src/org/sbml/jsbml/Creator.java
Original file line number Diff line number Diff line change
Expand Up @@ -550,4 +550,15 @@ public void unsetOrganization() {
firePropertyChange(TreeNodeChangeEvent.organization, oldValue, organisation);
}

}
/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
14 changes: 13 additions & 1 deletion core/src/org/sbml/jsbml/History.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,4 +506,16 @@ public String toString() {
}
return result.toString();
}
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
32 changes: 32 additions & 0 deletions core/src/org/sbml/jsbml/TreeNodeVisitor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.sbml.jsbml;

import org.sbml.jsbml.util.TreeNodeWithChangeSupport;

/**
* A generic visitor interface for traversing the JSBML tree structure.
* This allows external classes to operate on SBML components without
* modifying the core classes.
*
* @param <T> The return type of the visitor operations. Note that this generic
* type may also be {@link Void} if nothing is to be returned.
* @author Deepak Yadav
*/
public interface TreeNodeVisitor<T> {

/**
* Primary traversal method for core SBML components.
*
* @param sbase the core SBML element to visit
* @return a result of type T
*/
T visit(SBase sbase);

/**
* Fallback traversal method for auxiliary nodes (e.g., annotations, notes)
* that do not inherit from SBase but do inherit from TreeNodeWithChangeSupport.
*
* @param node the tree node to visit
* @return a result of type T
*/
T visit(TreeNodeWithChangeSupport node);
}
13 changes: 13 additions & 0 deletions core/src/org/sbml/jsbml/ext/AbstractASTNodePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.sbml.jsbml.AbstractTreeNode;
import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.SBase;
import org.sbml.jsbml.TreeNodeVisitor;
import org.sbml.jsbml.util.TreeNodeChangeEvent;

/**
Expand Down Expand Up @@ -355,4 +356,16 @@ public Map<String, String> writeXMLAttributes() {
return new TreeMap<String, String>();
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
@Override
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
13 changes: 13 additions & 0 deletions core/src/org/sbml/jsbml/ext/AbstractSBasePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.sbml.jsbml.AbstractTreeNode;
import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.SBase;
import org.sbml.jsbml.TreeNodeVisitor;
import org.sbml.jsbml.util.TreeNodeChangeEvent;

/**
Expand Down Expand Up @@ -327,4 +328,16 @@ public Map<String, String> writeXMLAttributes() {
return new TreeMap<String, String>();
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
@Override
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
12 changes: 12 additions & 0 deletions core/src/org/sbml/jsbml/math/ASTBoolean.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.sbml.jsbml.ASTNode.Type;
import org.sbml.jsbml.PropertyUndefinedError;
import org.sbml.jsbml.SBMLException;
import org.sbml.jsbml.TreeNodeVisitor;
import org.sbml.jsbml.math.compiler.ASTNode2Compiler;
import org.sbml.jsbml.math.compiler.ASTNode2Value;
import org.sbml.jsbml.math.compiler.FormulaCompiler;
Expand Down Expand Up @@ -197,4 +198,15 @@ public String toMathML() {
}
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
12 changes: 12 additions & 0 deletions core/src/org/sbml/jsbml/math/ASTCSymbolAvogadroNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.sbml.jsbml.ASTNode;
import org.sbml.jsbml.ASTNode.Type;
import org.sbml.jsbml.PropertyUndefinedError;
import org.sbml.jsbml.TreeNodeVisitor;
import org.sbml.jsbml.math.compiler.ASTNode2Compiler;
import org.sbml.jsbml.math.compiler.ASTNode2Value;
import org.sbml.jsbml.util.Maths;
Expand Down Expand Up @@ -316,4 +317,15 @@ public void setName(String name) {
firePropertyChange(TreeNodeChangeEvent.name, old, this.name);
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
12 changes: 12 additions & 0 deletions core/src/org/sbml/jsbml/math/ASTCSymbolDelayNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.sbml.jsbml.ASTNode.Type;
import org.sbml.jsbml.PropertyUndefinedError;
import org.sbml.jsbml.SBMLException;
import org.sbml.jsbml.TreeNodeVisitor;
import org.sbml.jsbml.math.compiler.ASTNode2Compiler;
import org.sbml.jsbml.math.compiler.ASTNode2Value;
import org.sbml.jsbml.math.compiler.FormulaCompiler;
Expand Down Expand Up @@ -289,4 +290,15 @@ public String toMathML() {
}
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
12 changes: 12 additions & 0 deletions core/src/org/sbml/jsbml/math/ASTCSymbolTimeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.sbml.jsbml.ASTNode.Type;
import org.sbml.jsbml.PropertyUndefinedError;
import org.sbml.jsbml.SBMLException;
import org.sbml.jsbml.TreeNodeVisitor;
import org.sbml.jsbml.math.compiler.ASTNode2Compiler;
import org.sbml.jsbml.math.compiler.ASTNode2Value;
import org.sbml.jsbml.math.compiler.FormulaCompiler;
Expand Down Expand Up @@ -313,4 +314,15 @@ public String toMathML() {
}
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
12 changes: 12 additions & 0 deletions core/src/org/sbml/jsbml/math/ASTCiFunctionNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.sbml.jsbml.Model;
import org.sbml.jsbml.PropertyUndefinedError;
import org.sbml.jsbml.SBMLException;
import org.sbml.jsbml.TreeNodeVisitor;
import org.sbml.jsbml.math.compiler.ASTNode2Compiler;
import org.sbml.jsbml.math.compiler.ASTNode2Value;
import org.sbml.jsbml.math.compiler.FormulaCompiler;
Expand Down Expand Up @@ -367,4 +368,15 @@ public String toMathML() {
}
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
12 changes: 12 additions & 0 deletions core/src/org/sbml/jsbml/math/ASTCiNumberNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.sbml.jsbml.PropertyUndefinedError;
import org.sbml.jsbml.QuantityWithUnit;
import org.sbml.jsbml.SBMLException;
import org.sbml.jsbml.TreeNodeVisitor;
import org.sbml.jsbml.math.compiler.ASTNode2Compiler;
import org.sbml.jsbml.math.compiler.ASTNode2Value;
import org.sbml.jsbml.math.compiler.FormulaCompiler;
Expand Down Expand Up @@ -383,4 +384,15 @@ public String toMathML() {
}
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
12 changes: 12 additions & 0 deletions core/src/org/sbml/jsbml/math/ASTCnNumberNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.sbml.jsbml.Model;
import org.sbml.jsbml.PropertyUndefinedError;
import org.sbml.jsbml.SBMLException;
import org.sbml.jsbml.TreeNodeVisitor;
import org.sbml.jsbml.Unit;
import org.sbml.jsbml.UnitDefinition;
import org.sbml.jsbml.math.compiler.ASTNode2Compiler;
Expand Down Expand Up @@ -388,4 +389,15 @@ public void unsetUnits() {
firePropertyChange(TreeNodeChangeEvent.units, oldValue, null);
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
12 changes: 12 additions & 0 deletions core/src/org/sbml/jsbml/math/ASTConstantNumber.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.sbml.jsbml.ASTNode.Type;
import org.sbml.jsbml.PropertyUndefinedError;
import org.sbml.jsbml.SBMLException;
import org.sbml.jsbml.TreeNodeVisitor;
import org.sbml.jsbml.math.compiler.ASTNode2Compiler;
import org.sbml.jsbml.math.compiler.ASTNode2Value;
import org.sbml.jsbml.math.compiler.FormulaCompiler;
Expand Down Expand Up @@ -219,4 +220,15 @@ public String toMathML() {
}
}

/**
* Accepts a generic visitor to traverse this component.
*
* @param <T> the return type of the visitor
* @param visitor the visitor implementation
* @return the result of the visitor operation
*/
public <T> T accept(TreeNodeVisitor<T> visitor) {
return visitor.visit(this);
}

}
Loading