1 8 package org.lsmp.djep.djep; 9 import org.nfunk.jep.*; 10 import org.lsmp.djep.xjep.PrintVisitor; 11 12 25 public class DPrintVisitor extends PrintVisitor { 26 public static final int PRINT_PARTIAL_EQNS = 16; 27 public static final int PRINT_VARIABLE_EQNS = 32; 28 29 32 public DPrintVisitor() { 33 super(); 34 setMode(PRINT_PARTIAL_EQNS,true); 35 } 36 37 40 public Object visit(ASTVarNode node, Object data) throws ParseException 41 { 42 Variable var = node.getVar(); 43 if(var instanceof PartialDerivative) 44 { 45 PartialDerivative deriv = (PartialDerivative) var; 46 if(((mode & PRINT_PARTIAL_EQNS)!=0) && deriv.hasEquation()) 47 deriv.getEquation().jjtAccept(this,null); 48 else 49 sb.append(node.getName()); 50 } 51 else if(var instanceof DVariable) 52 { 53 DVariable dvar = (DVariable) var; 54 if(((mode & PRINT_VARIABLE_EQNS)!=0) && dvar.hasEquation()) 55 dvar.getEquation().jjtAccept(this,null); 56 else 57 sb.append(node.getName()); 58 } 59 else 60 sb.append(node.getName()); 61 62 return data; 63 } 64 } 65 | Popular Tags |