Back to index

wims  3.65+svn20090927
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes
WIMSchem.ds.DataSheet Class Reference

List of all members.

Classes

class  Column

Public Member Functions

 DataSheet ()
int NumCols ()
int NumRows ()
boolean IsDirty ()
void SetDirty ()
void ClearDirty ()
String ColName (int N)
int ColType (int N)
String ColDescr (int N)
boolean IsNull (int RN, int CN)
Molecule GetMolecule (int RN, int CN)
String GetString (int RN, int CN)
int GetInteger (int RN, int CN)
double GetReal (int RN, int CN)
boolean GetBoolean (int RN, int CN)
Object GetObject (int RN, int CN)
void SetToNull (int RN, int CN)
void SetMolecule (int RN, int CN, Molecule V)
void SetString (int RN, int CN, String V)
void SetInteger (int RN, int CN, int V)
void SetReal (int RN, int CN, double V)
void SetBoolean (int RN, int CN, boolean V)
void SetObject (int RN, int CN, Object V)
int AppendColumn (String Name, int Type, String Descr)
int AppendRow ()
void DeleteRow (int RN)
void DeleteColumn (int CN)
void ChangeColumnName (int CN, String Name, String Descr)
boolean ChangeColumnType (int CN, int NewType, boolean Force)
void ReorderColumns (int[] Order)

Static Public Member Functions

static String TypeName (int Type)

Static Public Attributes

static final int COLTYPE_MOLECULE = 1
static final int COLTYPE_STRING = 2
static final int COLTYPE_INTEGER = 3
static final int COLTYPE_REAL = 4
static final int COLTYPE_BOOLEAN = 5

Private Attributes

ArrayList< Columncols = new ArrayList<Column>()
ArrayList< Object[]> rows = new ArrayList<Object[]>()
boolean isDirty = false

Detailed Description

Definition at line 26 of file DataSheet.java.


Constructor & Destructor Documentation

Definition at line 45 of file DataSheet.java.

    {
    }

Member Function Documentation

int WIMSchem.ds.DataSheet.AppendColumn ( String  Name,
int  Type,
String  Descr 
) [inline]

Definition at line 97 of file DataSheet.java.

    {
       Column c=new Column();
       c.Name=Name;
       c.Type=Type;
       c.Descr=Descr;
       cols.add(c);
       for (int n=0;n<rows.size();n++)
       {
           Object[] d1=rows.get(n);
           Object[] d2=new Object[d1.length+1];
           for (int i=0;i<d1.length;i++) d2[i]=d1[i];
           d2[d1.length]=null;
           rows.set(n,d2);
       }
       return cols.size()-1;
    }

Here is the caller graph for this function:

Definition at line 116 of file DataSheet.java.

    {
       rows.add(new Object[cols.size()]);
       return rows.size()-1;
    }

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.ChangeColumnName ( int  CN,
String  Name,
String  Descr 
) [inline]

Definition at line 137 of file DataSheet.java.

    {
       Column c=cols.get(CN);
       if (Name!=null) c.Name=Name;
       if (Descr!=null) c.Descr=Descr;
    }

Here is the caller graph for this function:

boolean WIMSchem.ds.DataSheet.ChangeColumnType ( int  CN,
int  NewType,
boolean  Force 
) [inline]

Definition at line 147 of file DataSheet.java.

    {
       if (CN<0 || CN>=NumCols()) return false;
       if (ColType(CN)==NewType) return true;
       
       boolean incompatible=ColType(CN)==COLTYPE_MOLECULE || NewType==COLTYPE_MOLECULE;
       if (incompatible && !Force) return false;
       
       Column col=cols.get(CN);
       int prevType=col.Type;
       col.Type=NewType;
       
       for (int n=0,nrows=rows.size();n<nrows;n++)
       {
           Object[] row=rows.get(n);
           
           if (row[CN]==null) continue;
           if (incompatible) {row[CN]=null; continue;}
           
           String val="";
           if (prevType==COLTYPE_STRING) val=(String)row[CN];
           else if (prevType==COLTYPE_INTEGER) val=String.valueOf(((Integer)row[CN]).intValue());
           else if (prevType==COLTYPE_REAL) val=String.valueOf(((Double)row[CN]).intValue());
           else if (prevType==COLTYPE_BOOLEAN) val=((Boolean)row[CN]).booleanValue() ? "true" : "false";
           
           row[CN]=null;
           
           try
           {
              if (NewType==COLTYPE_STRING) row[CN]=val;
              else if (NewType==COLTYPE_INTEGER) row[CN]=new Integer(val);
              else if (NewType==COLTYPE_REAL) row[CN]=new Double(val);
              else if (NewType==COLTYPE_BOOLEAN) row[CN]=val.toLowerCase().compareTo("true")==0 ? Boolean.TRUE : Boolean.FALSE;
           }
           catch (NumberFormatException e) {} // stays null
       }
       
       return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 63 of file DataSheet.java.

{isDirty=false;}

Here is the caller graph for this function:

String WIMSchem.ds.DataSheet.ColDescr ( int  N) [inline]

Definition at line 68 of file DataSheet.java.

{return cols.get(N).Descr;}

Here is the caller graph for this function:

String WIMSchem.ds.DataSheet.ColName ( int  N) [inline]

Definition at line 66 of file DataSheet.java.

{return cols.get(N).Name;}

Here is the caller graph for this function:

int WIMSchem.ds.DataSheet.ColType ( int  N) [inline]

Definition at line 67 of file DataSheet.java.

{return cols.get(N).Type;}

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.DeleteColumn ( int  CN) [inline]

Definition at line 125 of file DataSheet.java.

    {
       cols.remove(CN);
       for (int n=0;n<rows.size();n++)
       {
           Object[] prev=rows.get(n),cur=new Object[cols.size()-1];
           for (int i=0,j=0;i<prev.length;i++) if (i!=CN) cur[j++]=prev[i];
           rows.set(n,cur);
       }
    }

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.DeleteRow ( int  RN) [inline]

Definition at line 122 of file DataSheet.java.

{rows.remove(RN);}

Here is the caller graph for this function:

boolean WIMSchem.ds.DataSheet.GetBoolean ( int  RN,
int  CN 
) [inline]

Definition at line 78 of file DataSheet.java.

{return ((Boolean)(rows.get(RN))[CN]).booleanValue();}

Here is the caller graph for this function:

int WIMSchem.ds.DataSheet.GetInteger ( int  RN,
int  CN 
) [inline]

Definition at line 76 of file DataSheet.java.

{return ((Integer)(rows.get(RN))[CN]).intValue();}

Here is the caller graph for this function:

Molecule WIMSchem.ds.DataSheet.GetMolecule ( int  RN,
int  CN 
) [inline]

Definition at line 74 of file DataSheet.java.

{return (Molecule)(rows.get(RN))[CN];}

Here is the caller graph for this function:

Object WIMSchem.ds.DataSheet.GetObject ( int  RN,
int  CN 
) [inline]

Definition at line 81 of file DataSheet.java.

{return (rows.get(RN))[CN];}

Here is the caller graph for this function:

double WIMSchem.ds.DataSheet.GetReal ( int  RN,
int  CN 
) [inline]

Definition at line 77 of file DataSheet.java.

{return ((Double)(rows.get(RN))[CN]).doubleValue();}

Here is the caller graph for this function:

String WIMSchem.ds.DataSheet.GetString ( int  RN,
int  CN 
) [inline]

Definition at line 75 of file DataSheet.java.

{return (String)(rows.get(RN))[CN];}

Here is the caller graph for this function:

Definition at line 61 of file DataSheet.java.

{return isDirty;}

Here is the caller graph for this function:

boolean WIMSchem.ds.DataSheet.IsNull ( int  RN,
int  CN 
) [inline]

Definition at line 71 of file DataSheet.java.

{return (rows.get(RN))[CN]==null;}

Here is the caller graph for this function:

Definition at line 49 of file DataSheet.java.

{return cols.size();}

Here is the caller graph for this function:

Definition at line 50 of file DataSheet.java.

{return rows.size();}

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.ReorderColumns ( int[]  Order) [inline]

Definition at line 188 of file DataSheet.java.

    {
       boolean identity=true;
       for (int n=0;n<Order.length-1;n++) if (Order[n]!=Order[n+1]+1) {identity=false; break;}
       if (identity) return; // nothing to do
       
       ArrayList<Column> newcols=new ArrayList<Column>();
       for (int n=0;n<cols.size();n++) newcols.add(cols.get(Order[n]));
       cols=newcols;
       
       for (int n=0;n<rows.size();n++)
       {
           Object[] row=rows.get(n),newrow=new Object[row.length];
           for (int i=0;i<row.length;i++) newrow[i]=row[Order[i]];
           rows.set(n,newrow);
       }
    }

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.SetBoolean ( int  RN,
int  CN,
boolean  V 
) [inline]

Definition at line 91 of file DataSheet.java.

{if (ColType(CN)==COLTYPE_BOOLEAN) (rows.get(RN))[CN]=new Boolean(V);}

Here is the call graph for this function:

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.SetDirty ( ) [inline]

Definition at line 62 of file DataSheet.java.

{isDirty=true;}

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.SetInteger ( int  RN,
int  CN,
int  V 
) [inline]

Definition at line 89 of file DataSheet.java.

{if (ColType(CN)==COLTYPE_INTEGER) (rows.get(RN))[CN]=new Integer(V);}

Here is the call graph for this function:

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.SetMolecule ( int  RN,
int  CN,
Molecule  V 
) [inline]

Definition at line 87 of file DataSheet.java.

{if (ColType(CN)==COLTYPE_MOLECULE) (rows.get(RN))[CN]=V==null ? V : V.Clone();}

Here is the call graph for this function:

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.SetObject ( int  RN,
int  CN,
Object  V 
) [inline]

Definition at line 94 of file DataSheet.java.

{(rows.get(RN))[CN]=V;}

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.SetReal ( int  RN,
int  CN,
double  V 
) [inline]

Definition at line 90 of file DataSheet.java.

{if (ColType(CN)==COLTYPE_REAL) (rows.get(RN))[CN]=new Double(V);}

Here is the call graph for this function:

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.SetString ( int  RN,
int  CN,
String  V 
) [inline]

Definition at line 88 of file DataSheet.java.

{if (ColType(CN)==COLTYPE_STRING) (rows.get(RN))[CN]=V;}

Here is the call graph for this function:

Here is the caller graph for this function:

void WIMSchem.ds.DataSheet.SetToNull ( int  RN,
int  CN 
) [inline]

Definition at line 84 of file DataSheet.java.

{(rows.get(RN))[CN]=null;}

Here is the caller graph for this function:

static String WIMSchem.ds.DataSheet.TypeName ( int  Type) [inline, static]

Definition at line 52 of file DataSheet.java.

    {
       return Type==DataSheet.COLTYPE_MOLECULE ? "molecule" :
              Type==DataSheet.COLTYPE_STRING ? "string" :
              Type==DataSheet.COLTYPE_REAL ? "real" :
              Type==DataSheet.COLTYPE_INTEGER ? "integer" :
              Type==DataSheet.COLTYPE_BOOLEAN ? "boolean" : "?";
    }

Here is the caller graph for this function:


Member Data Documentation

ArrayList<Column> WIMSchem.ds.DataSheet.cols = new ArrayList<Column>() [private]

Definition at line 40 of file DataSheet.java.

final int WIMSchem.ds.DataSheet.COLTYPE_BOOLEAN = 5 [static]

Definition at line 32 of file DataSheet.java.

final int WIMSchem.ds.DataSheet.COLTYPE_INTEGER = 3 [static]

Definition at line 30 of file DataSheet.java.

Definition at line 28 of file DataSheet.java.

final int WIMSchem.ds.DataSheet.COLTYPE_REAL = 4 [static]

Definition at line 31 of file DataSheet.java.

final int WIMSchem.ds.DataSheet.COLTYPE_STRING = 2 [static]

Definition at line 29 of file DataSheet.java.

Definition at line 43 of file DataSheet.java.

ArrayList<Object[]> WIMSchem.ds.DataSheet.rows = new ArrayList<Object[]>() [private]

Definition at line 41 of file DataSheet.java.


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