Esempio n. 1
0
  /**
   * Gets a short <code>String</code> representation of the node's formula.
   *
   * @param auxiliaryNode2id auxiliary node to id mapping
   * @param constantNode2id constant node to id mapping
   * @param levelNode2id level node to id mapping
   * @return short <code>String</code> representation of the node's formula
   */
  public String getShortStringRepresentation(
      HashMap<AuxiliaryNode, Integer> auxiliaryNode2id,
      HashMap<ConstantNode, Integer> constantNode2id,
      HashMap<LevelNode, Integer> levelNode2id) {
    if (auxiliaryNode2id == null) {
      throw new IllegalArgumentException("'auxiliaryNode2id' must not be null.");
    }
    if (constantNode2id == null) {
      throw new IllegalArgumentException("'constantNode2id' must not be null.");
    }
    if (levelNode2id == null) {
      throw new IllegalArgumentException("'levelNode2id' must not be null.");
    }

    if (rightElement instanceof ASTPlus || rightElement instanceof ASTMinus) {
      return leftElement.getShortStringRepresentation(
              auxiliaryNode2id, constantNode2id, levelNode2id)
          + " - ("
          + rightElement.getShortStringRepresentation(
              auxiliaryNode2id, constantNode2id, levelNode2id)
          + ")";
    } else {
      return leftElement.getShortStringRepresentation(
              auxiliaryNode2id, constantNode2id, levelNode2id)
          + " - "
          + rightElement.getShortStringRepresentation(
              auxiliaryNode2id, constantNode2id, levelNode2id);
    }
  }
Esempio n. 2
0
  /**
   * Creates and returns a <b>deep</b> copy of this object. Only the nodes in the leaves are not
   * cloned.
   *
   * @return a deep clone of this instance
   */
  @Override
  public Object clone() {
    ASTElement leftClone = (ASTElement) leftElement.clone();
    ASTElement rightClone = (ASTElement) rightElement.clone();

    return new ASTMinus(leftClone, rightClone);
  }
Esempio n. 3
0
 /**
  * Gets a <code>String</code> representation of the node's formula.
  *
  * @return <code>String</code> representation of the node's formula
  */
 public String getStringRepresentation() {
   if (rightElement instanceof ASTPlus || rightElement instanceof ASTMinus) {
     return leftElement.getStringRepresentation()
         + " - ("
         + rightElement.getStringRepresentation()
         + ")";
   } else {
     return leftElement.getStringRepresentation() + " - " + rightElement.getStringRepresentation();
   }
 }
Esempio n. 4
0
 /**
  * Gets all nodes in this AST subtree (inclusive this ASTElement).
  *
  * @return set of all nodes in AST subtree
  */
 public HashSet<AbstractNode> getAllNodesInASTSubtree() {
   HashSet<AbstractNode> nodeSet = leftElement.getAllNodesInASTSubtree();
   nodeSet.addAll(rightElement.getAllNodesInASTSubtree());
   return nodeSet;
 }
Esempio n. 5
0
 /**
  * Evaluates the ASTElement.
  *
  * @return ASTElement value
  */
 public double evaluate() {
   return leftElement.evaluate() - rightElement.evaluate();
 }