csheets.core.formula.util
Class ReferenceTransposer

java.lang.Object
  extended by csheets.core.formula.util.ExpressionBuilder
      extended by csheets.core.formula.util.ReferenceTransposer
All Implemented Interfaces:
ExpressionVisitor

public class ReferenceTransposer
extends ExpressionBuilder

An expression visitor that transposes the references in an expression. The visitor is used for copying and moving formulas between cells.

Author:
Einar Pehrson

Constructor Summary
ReferenceTransposer(int columns, int rows)
          Creates a new reference fetcher.
 
Method Summary
 Expression getExpression(Expression expression)
          Returns a transposed copy of the given expression.
 Expression visitReference(Reference reference)
          Transposes the reference.
 
Methods inherited from class csheets.core.formula.util.ExpressionBuilder
visitBinaryOperation, visitFunctionCall, visitLiteral, visitUnaryOperation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReferenceTransposer

public ReferenceTransposer(int columns,
                           int rows)
Creates a new reference fetcher.

Parameters:
columns - the number of columns to transpose formulae
rows - the number of rows to transpose formulae
Method Detail

getExpression

public Expression getExpression(Expression expression)
Returns a transposed copy of the given expression.

Overrides:
getExpression in class ExpressionBuilder
Parameters:
expression - the expression to rebuild
Returns:
the transposed expression

visitReference

public Expression visitReference(Reference reference)
Transposes the reference.

Specified by:
visitReference in interface ExpressionVisitor
Overrides:
visitReference in class ExpressionBuilder
Parameters:
reference - the reference to visit
Returns:
an arbitrary object