Back to index

wims  3.65+svn20090927
Public Member Functions | Static Public Member Functions | Static Public Attributes | Package Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
SharpTools.Node Class Reference

Node is basic unit for Formula processing. More...

Collaboration diagram for SharpTools.Node:
Collaboration graph
[legend]

List of all members.

Public Member Functions

int getType ()
 get/set functions
boolean isType (int type)
float getNumber ()
String getData ()
LinkedList getParams ()
Node getNextRange ()
LinkedList getExp ()
int getRow ()
int getCol ()
void setType (int type)
void setNumber (float number)
void setData (String data)
void appendData (char data)
void appendData (String data)
void setParams (LinkedList list)
void addParam (Node node)
void setNextRange (Node node)
void setExp (LinkedList exp)
void setPending (boolean pending)
boolean isPending ()
void setRow (int row)
void setCol (int col)
boolean hasValue ()
String toString ()
 This string funciton is for debug purpose only.
CellPoint toCellPoint (int row, int col)
 Node -> CellPoint.
CellPoint[] getAddressRange (int row, int col)
 Given one Node, this returns two CellPoints that identify the upleft and downright cells.

Static Public Member Functions

static int translateRow (String row)
 This translates the string form of row into row number ('12' -> 12).
static String translateRow (int row)
 This translates the int value of row into a string (12 -> '12').
static int translateColumn (String column)
 This translates the string form of column into column number ('A' -> 1)
static String translateColumn (int column)
 This translates the int form of column into column string (1 -> 'A')

Static Public Attributes

static final int DEFAULT = 0
static final int REL_ADDR = 1
static final int ABS_ADDR = 2
static final int FUNCTION = 3
static final int LPAREN = 4
static final int RPAREN = 5
static final int NUMBER = 6
static final int OPERATOR = 7
static final int COMMA = 8
static final int COLON = 9
static final int EXP = 10

Package Functions

 Node ()
 This is an empty node constructor.
 Node (Node node)
 Node constructor.

Static Private Member Functions

static int min (int m, int n)
static int max (int m, int n)

Private Attributes

int type
String data
float number
int row
int col
LinkedList exp
Node nextRange
boolean pending

Static Private Attributes

static final String[] desc

Detailed Description

Node is basic unit for Formula processing.

It can be one of the following:

  1. Relative Address (LETTERS+numbers: A1)
  2. Absolute Address ($LETTERS
    numbers:
    A$1)
  3. Function (LETTERS)
  4. Left Parenthese
  5. Right Parenthese
  6. Number (a float number)
  7. Operator (+ - * / % ^)
  8. Comma (separating parameters)
  9. Colon (used in range addresses: A1:C6)
See also:
Formula
Author:
Hua Zhong huaz@.nosp@m.cs.c.nosp@m.olumb.nosp@m.ia.e.nosp@m.du
Version:
Revision:
1.28

Definition at line 33 of file Node.java.


Constructor & Destructor Documentation

SharpTools.Node.Node ( ) [inline, package]

This is an empty node constructor.

Definition at line 75 of file Node.java.

           {
    }
SharpTools.Node.Node ( Node  node) [inline, package]

Node constructor.

Parameters:
node

Definition at line 83 of file Node.java.

                    {
       type = node.type;
       if (data != null)
           data = new String(node.data);
       number = node.number;
       row = node.row;
       col = node.col;
    }

Member Function Documentation

void SharpTools.Node.addParam ( Node  node) [inline]

Definition at line 114 of file Node.java.

                                    {
       if (node.getExp().size()>0)
           exp.add(node);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.Node.appendData ( char  data) [inline]

Definition at line 110 of file Node.java.

{ this.data += data; }

Here is the caller graph for this function:

void SharpTools.Node.appendData ( String  data) [inline]

Definition at line 111 of file Node.java.

{ this.data += data; }
CellPoint [] SharpTools.Node.getAddressRange ( int  row,
int  col 
) [inline]

Given one Node, this returns two CellPoints that identify the upleft and downright cells.

row and col matter because relative addresses need them.

Parameters:
rowthe int value fo the row
colthe int value of the column
Returns:
two CellPoint value for the range

Definition at line 270 of file Node.java.

                                                         {

       CellPoint[] addr = new CellPoint[2];
       if (isType(Node.COLON)) {
           // if it's an address range
           // get the start address
           CellPoint addr1 = getNextRange().toCellPoint(row, col);
           // get the end address
           CellPoint addr2 = getNextRange().getNextRange().
              toCellPoint(row, col);

           addr[0] = new CellPoint(
                                min(addr1.getRow(), addr2.getRow()),
                                min(addr1.getCol(), addr2.getCol())
                                );
           addr[1] = new CellPoint(
                                max(addr1.getRow(), addr2.getRow()),    
                                max(addr1.getCol(), addr2.getCol())
                                );
       }
       else {
           // otherwise it's a normal address
           CellPoint cell = toCellPoint(row, col);
           addr[0] = cell;
           addr[1] = cell;
       }
           
       return addr;  
    }

Here is the call graph for this function:

Here is the caller graph for this function:

int SharpTools.Node.getCol ( ) [inline]

Definition at line 104 of file Node.java.

{ return col; }

Here is the caller graph for this function:

String SharpTools.Node.getData ( ) [inline]

Definition at line 97 of file Node.java.

{ return data; }

Here is the caller graph for this function:

LinkedList SharpTools.Node.getExp ( ) [inline]

Definition at line 101 of file Node.java.

{ return exp; }

Here is the caller graph for this function:

Definition at line 100 of file Node.java.

{ return nextRange; }

Here is the caller graph for this function:

float SharpTools.Node.getNumber ( ) [inline]

Definition at line 96 of file Node.java.

{ return number; }

Here is the caller graph for this function:

LinkedList SharpTools.Node.getParams ( ) [inline]

Definition at line 99 of file Node.java.

{ return exp; }

Here is the caller graph for this function:

int SharpTools.Node.getRow ( ) [inline]

Definition at line 103 of file Node.java.

{ return row; }

Here is the caller graph for this function:

int SharpTools.Node.getType ( ) [inline]

get/set functions

Definition at line 93 of file Node.java.

{ return type; }

Here is the caller graph for this function:

Definition at line 128 of file Node.java.

                              {
       return (type == Node.NUMBER || type == Node.REL_ADDR ||
              type == Node.ABS_ADDR || type == Node.FUNCTION ||
              type == Node.RPAREN);
    }

Definition at line 123 of file Node.java.

{ return pending; }

Here is the caller graph for this function:

boolean SharpTools.Node.isType ( int  type) [inline]

Definition at line 94 of file Node.java.

{ return this.type == type; }

Here is the caller graph for this function:

static int SharpTools.Node.max ( int  m,
int  n 
) [inline, static, private]

Definition at line 257 of file Node.java.

                                         {
       return m>n ? m:n;
    }

Here is the caller graph for this function:

static int SharpTools.Node.min ( int  m,
int  n 
) [inline, static, private]

Definition at line 253 of file Node.java.

                                         {
       return m<n ? m:n;
    }

Here is the caller graph for this function:

void SharpTools.Node.setCol ( int  col) [inline]

Definition at line 126 of file Node.java.

{ this.col = col; }

Here is the caller graph for this function:

void SharpTools.Node.setData ( String  data) [inline]

Definition at line 109 of file Node.java.

{ this.data = data; }

Here is the caller graph for this function:

void SharpTools.Node.setExp ( LinkedList  exp) [inline]

Definition at line 120 of file Node.java.

{ this.exp = exp; }

Here is the caller graph for this function:

void SharpTools.Node.setNextRange ( Node  node) [inline]

Definition at line 119 of file Node.java.

{ nextRange = node; }

Here is the caller graph for this function:

void SharpTools.Node.setNumber ( float  number) [inline]

Definition at line 107 of file Node.java.

{ this.number = number; }

Here is the caller graph for this function:

void SharpTools.Node.setParams ( LinkedList  list) [inline]

Definition at line 113 of file Node.java.

{ exp = list; }

Here is the caller graph for this function:

void SharpTools.Node.setPending ( boolean  pending) [inline]

Definition at line 122 of file Node.java.

{ this.pending = pending; }

Here is the caller graph for this function:

void SharpTools.Node.setRow ( int  row) [inline]

Definition at line 125 of file Node.java.

{ this.row = row; }

Here is the caller graph for this function:

void SharpTools.Node.setType ( int  type) [inline]

Definition at line 106 of file Node.java.

{ this.type = type; }

Here is the caller graph for this function:

CellPoint SharpTools.Node.toCellPoint ( int  row,
int  col 
) [inline]

Node -> CellPoint.

Definition at line 246 of file Node.java.

                                                   {
       if (isType(Node.REL_ADDR))
           return new CellPoint(getRow()+row, getCol()+col);
       else
           return new CellPoint(getRow(), getCol());
    }

Here is the call graph for this function:

Here is the caller graph for this function:

String SharpTools.Node.toString ( ) [inline]

This string funciton is for debug purpose only.

Node -> String

Definition at line 138 of file Node.java.

                             {
       //     return String.valueOf(type);

       switch (type) {
       case Node.NUMBER:        
           return Float.toString(number);
       case Node.REL_ADDR:
           StringBuffer buf1 = new StringBuffer();
           buf1.append('(');
           buf1.append(String.valueOf(col));
           buf1.append(',');
           buf1.append(row);
           buf1.append(')');
           return buf1.toString();
       case Node.ABS_ADDR:
           StringBuffer buf2 = new StringBuffer();
           buf2.append('$');
           buf2.append(translateColumn(col));
           buf2.append('$');
           buf2.append(translateRow(row));
           return buf2.toString();
       case Node.FUNCTION:
           return data+exp.toString();
       case Node.EXP:
           return exp.toString();
       case Node.LPAREN:
           return "(";
       case Node.RPAREN:
           return ")";
       case Node.COMMA:
           return ",";
       case Node.COLON:
           return nextRange.toString()+":"+nextRange.nextRange.toString();
           
       default:
           return data;
       }

    }

Here is the call graph for this function:

Here is the caller graph for this function:

static int SharpTools.Node.translateColumn ( String  column) [inline, static]

This translates the string form of column into column number ('A' -> 1)

Parameters:
columnthe string value of the column to be converted
Returns:
the int value of the column

Definition at line 208 of file Node.java.

                                                     {
       int col = 0;

       for (int i = 0; i < column.length(); i++) {
           col  = col * 26 + (column.charAt(i) - 'A' + 1);
       }

       return col + SharpTools.baseCol -1;
    }

Here is the caller graph for this function:

static String SharpTools.Node.translateColumn ( int  column) [inline, static]

This translates the int form of column into column string (1 -> 'A')

Parameters:
columnthe int value of the column to be converted
Returns:
the string value of the column

Definition at line 224 of file Node.java.

                                                     {

       column = column - SharpTools.baseCol +1;
       if (column < 1)
           return null;

       StringBuffer buf = new StringBuffer();
       
       int div = 1;

       while (div > 0) {
           div = (column-1)/26;
           buf.insert(0, (char)('A'+(column-1 - div*26)));
           column = div;
       }
       
       return buf.toString();
    }
static int SharpTools.Node.translateRow ( String  row) [inline, static]

This translates the string form of row into row number ('12' -> 12).

Parameters:
rowthe string value of the row to be converted
Returns:
the int value of the row

Definition at line 184 of file Node.java.

                                               {
       int r = Integer.parseInt(row);
       return r + SharpTools.baseRow - 1;
    }

Here is the caller graph for this function:

static String SharpTools.Node.translateRow ( int  row) [inline, static]

This translates the int value of row into a string (12 -> '12').

Parameters:
rowthe int value of the row to be converted
Returns:
the string value of the row

Definition at line 195 of file Node.java.

                                               {
       if (row < 0)
           return null;
       else
           return String.valueOf(row+1-SharpTools.baseRow);
    }

Member Data Documentation

final int SharpTools.Node.ABS_ADDR = 2 [static]

Definition at line 36 of file Node.java.

int SharpTools.Node.col [private]

Definition at line 56 of file Node.java.

final int SharpTools.Node.COLON = 9 [static]

Definition at line 43 of file Node.java.

final int SharpTools.Node.COMMA = 8 [static]

Definition at line 42 of file Node.java.

String SharpTools.Node.data [private]

Definition at line 53 of file Node.java.

final int SharpTools.Node.DEFAULT = 0 [static]

Definition at line 34 of file Node.java.

final String [] SharpTools.Node.desc [static, private]
Initial value:
 {
       "Default", "Rel_Addr", "Abs_Addr", "Function",
       "LBracket", "RBracket", "Number", "Operator",
       "Comma", "Colon", "Param" }

Definition at line 47 of file Node.java.

final int SharpTools.Node.EXP = 10 [static]

Definition at line 44 of file Node.java.

LinkedList SharpTools.Node.exp [private]

Definition at line 58 of file Node.java.

final int SharpTools.Node.FUNCTION = 3 [static]

Definition at line 37 of file Node.java.

final int SharpTools.Node.LPAREN = 4 [static]

Definition at line 38 of file Node.java.

Definition at line 68 of file Node.java.

final int SharpTools.Node.NUMBER = 6 [static]

Definition at line 40 of file Node.java.

float SharpTools.Node.number [private]

Definition at line 54 of file Node.java.

final int SharpTools.Node.OPERATOR = 7 [static]

Definition at line 41 of file Node.java.

Definition at line 70 of file Node.java.

final int SharpTools.Node.REL_ADDR = 1 [static]

Definition at line 35 of file Node.java.

int SharpTools.Node.row [private]

Definition at line 55 of file Node.java.

final int SharpTools.Node.RPAREN = 5 [static]

Definition at line 39 of file Node.java.

int SharpTools.Node.type [private]

Definition at line 52 of file Node.java.


The documentation for this class was generated from the following file: