@Override public boolean check(ValidationContext ctx, MathContainer mc) { if (mc.isSetMath()) { // ASTNode must return a number if (mc instanceof KineticLaw || mc instanceof StoichiometryMath || mc instanceof SimpleSpeciesReference || mc instanceof InitialAssignment || mc instanceof Delay || mc instanceof EventAssignment || mc instanceof Rule) { return ValidationTools.getDataType(mc.getMath()) == ValidationTools.DT_NUMBER; } } return true; } };
@Override public boolean check(ValidationContext ctx, Trigger t) { if (t.isSetMath()) { boolean isValid = ValidationTools.getDataType(t.getMath()) == ValidationTools.DT_BOOLEAN; // in SBML L3V2, number as equivalent to boolean if (!isValid && ctx.getLevelAndVersion().compareTo(3, 2) >= 0) { isValid = ValidationTools.getDataType(t.getMath()) == ValidationTools.DT_NUMBER; } return isValid; } return true; } };
@Override public boolean check(ValidationContext ctx, ASTNode node) { // In operators... if (node.isOperator() || set.contains(node.getType())) { // all children must be numbers for (ASTNode n : node.getChildren()) { if (ValidationTools.getDataType(n) != ValidationTools.DT_NUMBER) { return false; } } } return true; }
@Override public boolean check(ValidationContext ctx, ASTNode node) { // In comparator... if (node.isRelational() && node.getChildCount() > 0) { byte dt = ValidationTools.getDataType(node.getChild(0)); // all children must have same Type for (int i = 1; i < node.getNumChildren(); i++) { if (dt != ValidationTools.getDataType(node.getChild(i))) { return false; } } } return true; } };
@Override public boolean check(ValidationContext ctx, ASTNode node) { // If is piecewise... if (node.isPiecewise() && node.getNumChildren() > 0) { byte dt = ValidationTools.getDataType(node.getLeftChild()); if (dt == ValidationTools.DT_STRING) { return false; } // all children must have same Type for (int i = 0; i < node.getNumChildren(); i += 2) { if (dt != ValidationTools.getDataType(node.getChild(i))) { return false; } } } return true; } };
@Override public boolean check(ValidationContext ctx, ASTNode node) { // do not check inside functionDefinition if (node.getParentSBMLObject() instanceof FunctionDefinition) { return true; } // If is piecewise... if (node.getType() == Type.FUNCTION_PIECEWISE) { // every second node must be a condition and therefore return a // boolean for (int i = 1; i < node.getNumChildren(); i += 2) { ASTNode child = node.getChild(i); if (ValidationTools.getDataType( child) != ValidationTools.DT_BOOLEAN) { // System.out.println("Node " + child.getType() + " was " + // ValidationTools.getDataType(child)); return false; } } } return true; } };
byte dt = getDataType(node.getChild(0)); if (getDataType(node.getChild(i)) != dt) { return DT_UNKNOWN; return ValidationTools.getDataType(fd.getBody());