/** * @see java.lang.Object#toString() */ public String toString() { return "(" + left.toString() + " " + getExpressionSymbol() + " " + right.toString() + ")"; }
/** * Finds the CacheExpression that has been associated with an expression. If * it is the first time the Expression is being added to the Cache, a new * CacheExpression is created and associated with the expression. <p/> This * method updates the reference counters on the CacheExpression to know when * it is no longer needed. */ private CacheExpression addToCache(Expression expr) { CacheExpression n = cachedExpressions.get(expr); if (n == null) { n = new CacheExpression(expr); cachedExpressions.put(expr, n); if (expr instanceof UnaryExpression) { // Cache the sub expressions too UnaryExpression un = (UnaryExpression)expr; un.setRight(addToCache(un.getRight())); } else if (expr instanceof BinaryExpression) { // Cache the sub expressions too. BinaryExpression bn = (BinaryExpression)expr; bn.setRight(addToCache(bn.getRight())); bn.setLeft(addToCache(bn.getLeft())); } } n.refCount++; return n; }
/** * TODO: more efficient hashCode() * * @see java.lang.Object#hashCode() */ public int hashCode() { return toString().hashCode(); }
/** * Removes an expression from the cache. Updates the reference counters on * the CacheExpression object. When the refernce counter goes to zero, the * entry int the Expression to CacheExpression map is removed. * * @param cn */ private void removeFromCache(CacheExpression cn) { cn.refCount--; Expression realExpr = cn.getRight(); if (cn.refCount == 0) { cachedExpressions.remove(realExpr); } if (realExpr instanceof UnaryExpression) { UnaryExpression un = (UnaryExpression)realExpr; removeFromCache((CacheExpression)un.getRight()); } if (realExpr instanceof BinaryExpression) { BinaryExpression bn = (BinaryExpression)realExpr; removeFromCache((CacheExpression)bn.getRight()); } }
/** * Removes an expression from the cache. Updates the reference counters on * the CacheExpression object. When the refernce counter goes to zero, the * entry int the Expression to CacheExpression map is removed. * * @param cn */ private void removeFromCache(CacheExpression cn) { cn.refCount--; Expression realExpr = cn.getRight(); if (cn.refCount == 0) { cachedExpressions.remove(realExpr); } if (realExpr instanceof UnaryExpression) { UnaryExpression un = (UnaryExpression)realExpr; removeFromCache((CacheExpression)un.getRight()); } if (realExpr instanceof BinaryExpression) { BinaryExpression bn = (BinaryExpression)realExpr; removeFromCache((CacheExpression)bn.getRight()); } }
/** * Finds the CacheExpression that has been associated with an expression. If * it is the first time the Expression is being added to the Cache, a new * CacheExpression is created and associated with the expression. <p/> This * method updates the reference counters on the CacheExpression to know when * it is no longer needed. */ private CacheExpression addToCache(Expression expr) { CacheExpression n = cachedExpressions.get(expr); if (n == null) { n = new CacheExpression(expr); cachedExpressions.put(expr, n); if (expr instanceof UnaryExpression) { // Cache the sub expressions too UnaryExpression un = (UnaryExpression)expr; un.setRight(addToCache(un.getRight())); } else if (expr instanceof BinaryExpression) { // Cache the sub expressions too. BinaryExpression bn = (BinaryExpression)expr; bn.setRight(addToCache(bn.getRight())); bn.setLeft(addToCache(bn.getLeft())); } } n.refCount++; return n; }
/** * TODO: more efficient hashCode() * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object o) { if (o == null || !this.getClass().equals(o.getClass())) { return false; } return toString().equals(o.toString()); }
/** * @see java.lang.Object#toString() */ public String toString() { return "(" + left.toString() + " " + getExpressionSymbol() + " " + right.toString() + ")"; }
/** * Removes an expression from the cache. Updates the reference counters on * the CacheExpression object. When the refernce counter goes to zero, the * entry int the Expression to CacheExpression map is removed. * * @param cn */ private void removeFromCache(CacheExpression cn) { cn.refCount--; Expression realExpr = cn.getRight(); if (cn.refCount == 0) { cachedExpressions.remove(realExpr); } if (realExpr instanceof UnaryExpression) { UnaryExpression un = (UnaryExpression)realExpr; removeFromCache((CacheExpression)un.getRight()); } if (realExpr instanceof BinaryExpression) { BinaryExpression bn = (BinaryExpression)realExpr; removeFromCache((CacheExpression)bn.getRight()); } }
/** * Finds the CacheExpression that has been associated with an expression. If * it is the first time the Expression is being added to the Cache, a new * CacheExpression is created and associated with the expression. <p/> This * method updates the reference counters on the CacheExpression to know when * it is no longer needed. */ private CacheExpression addToCache(Expression expr) { CacheExpression n = cachedExpressions.get(expr); if (n == null) { n = new CacheExpression(expr); cachedExpressions.put(expr, n); if (expr instanceof UnaryExpression) { // Cache the sub expressions too UnaryExpression un = (UnaryExpression)expr; un.setRight(addToCache(un.getRight())); } else if (expr instanceof BinaryExpression) { // Cache the sub expressions too. BinaryExpression bn = (BinaryExpression)expr; bn.setRight(addToCache(bn.getRight())); bn.setLeft(addToCache(bn.getLeft())); } } n.refCount++; return n; }
/** * TODO: more efficient hashCode() * * @see java.lang.Object#hashCode() */ public int hashCode() { return toString().hashCode(); }
/** * @see java.lang.Object#toString() */ public String toString() { return "(" + left.toString() + " " + getExpressionSymbol() + " " + right.toString() + ")"; }
/** * Removes an expression from the cache. Updates the reference counters on * the CacheExpression object. When the refernce counter goes to zero, the * entry int the Expression to CacheExpression map is removed. * * @param cn */ private void removeFromCache(CacheExpression cn) { cn.refCount--; Expression realExpr = cn.getRight(); if (cn.refCount == 0) { cachedExpressions.remove(realExpr); } if (realExpr instanceof UnaryExpression) { UnaryExpression un = (UnaryExpression)realExpr; removeFromCache((CacheExpression)un.getRight()); } if (realExpr instanceof BinaryExpression) { BinaryExpression bn = (BinaryExpression)realExpr; removeFromCache((CacheExpression)bn.getRight()); } }
/** * Finds the CacheExpression that has been associated with an expression. If * it is the first time the Expression is being added to the Cache, a new * CacheExpression is created and associated with the expression. <p/> This * method updates the reference counters on the CacheExpression to know when * it is no longer needed. */ private CacheExpression addToCache(Expression expr) { CacheExpression n = cachedExpressions.get(expr); if (n == null) { n = new CacheExpression(expr); cachedExpressions.put(expr, n); if (expr instanceof UnaryExpression) { // Cache the sub expressions too UnaryExpression un = (UnaryExpression)expr; un.setRight(addToCache(un.getRight())); } else if (expr instanceof BinaryExpression) { // Cache the sub expressions too. BinaryExpression bn = (BinaryExpression)expr; bn.setRight(addToCache(bn.getRight())); bn.setLeft(addToCache(bn.getLeft())); } } n.refCount++; return n; }
/** * TODO: more efficient hashCode() * * @see java.lang.Object#hashCode() */ public int hashCode() { return toString().hashCode(); }
/** * @see java.lang.Object#toString() */ public String toString() { return "(" + left.toString() + " " + getExpressionSymbol() + " " + right.toString() + ")"; }
/** * Removes an expression from the cache. Updates the reference counters on * the CacheExpression object. When the refernce counter goes to zero, the * entry int the Expression to CacheExpression map is removed. * * @param cn */ private void removeFromCache(CacheExpression cn) { cn.refCount--; Expression realExpr = cn.getRight(); if (cn.refCount == 0) { cachedExpressions.remove(realExpr); } if (realExpr instanceof UnaryExpression) { UnaryExpression un = (UnaryExpression)realExpr; removeFromCache((CacheExpression)un.getRight()); } if (realExpr instanceof BinaryExpression) { BinaryExpression bn = (BinaryExpression)realExpr; removeFromCache((CacheExpression)bn.getRight()); } }
/** * Finds the CacheExpression that has been associated with an expression. If * it is the first time the Expression is being added to the Cache, a new * CacheExpression is created and associated with the expression. <p/> This * method updates the reference counters on the CacheExpression to know when * it is no longer needed. */ private CacheExpression addToCache(Expression expr) { CacheExpression n = cachedExpressions.get(expr); if (n == null) { n = new CacheExpression(expr); cachedExpressions.put(expr, n); if (expr instanceof UnaryExpression) { // Cache the sub expressions too UnaryExpression un = (UnaryExpression)expr; un.setRight(addToCache(un.getRight())); } else if (expr instanceof BinaryExpression) { // Cache the sub expressions too. BinaryExpression bn = (BinaryExpression)expr; bn.setRight(addToCache(bn.getRight())); bn.setLeft(addToCache(bn.getLeft())); } } n.refCount++; return n; }
/** * TODO: more efficient hashCode() * * @see java.lang.Object#hashCode() */ public int hashCode() { return toString().hashCode(); }
/** * @see java.lang.Object#toString() */ public String toString() { return "(" + left.toString() + " " + getExpressionSymbol() + " " + right.toString() + ")"; }