EVEDemo.SWEEP
Class RelationSchema

java.lang.Object
  |
  +--EVEDemo.SWEEP.RelationSchema

public class RelationSchema
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Schema will be empty.

See Also:
Serialized Form

Field Summary
(package private)  java.util.Vector labels
           
 
Constructor Summary
RelationSchema()
          This is for View and Clone functions.
RelationSchema(java.io.DataInputStream din)
           
RelationSchema(java.sql.ResultSet rs)
          Here we generate each name as "R_A".
RelationSchema(java.sql.ResultSet rs, Relation rel, java.lang.String sign)
          Should erase SWEEPSIGN field from the Schema.
RelationSchema(java.sql.ResultSet rs, java.lang.String sign)
          Should erase SWEEPSIGN field from the Schema.
RelationSchema(java.lang.String[] newSchema)
           
 
Method Summary
private  void addCol(java.lang.String colName)
           
 void changeAttrName(java.lang.String newName, int index)
          Change specific Attribute Name in this schema.
 java.lang.Object clone()
           
 java.lang.String createSQL()
          this function will return SQL, for create table.
 java.lang.String createSQL(java.lang.String sign)
          this function will return SQL, for create table.
 void doProject(int[] flags)
          This function will decrease the Schema based on the flags.
 boolean equals(RelationSchema rs)
          Check if two Schemas are quivaluent.
private  boolean find(java.lang.String colName)
          Check if such column name stored in such schema.
 java.lang.String getAttrName(int index)
          Get one specific Attribute 's name.
 java.lang.String getColName(int index)
          Return column Name of specific Column Number.
 java.lang.String getCommon(RelationSchema theSchema)
          get the only one common Attribute of two schemas
 int[] getFlags(RelationSchema schema)
          Return a set of flags to show which column is projected.
 int[] getFlags(java.lang.String colName)
          This will return flags for projection.
(package private)  int getIndex(java.lang.String colName)
          Get Index of one labels in the schema.
 java.lang.String getSQL()
          Get SQL from this Schema List.
 boolean isSubsetOf(RelationSchema theSchema)
          Check is current Schema is a subset of other Schema.
 int size()
          this function return the Number of labels in the schema
 java.lang.String toString()
          Convert to String.
private  int whereIs(java.lang.String colName)
          Find where is such column name stored in this schema.
 void write(java.io.DataOutputStream dout)
          write the schema to the file
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

labels

java.util.Vector labels
Constructor Detail

RelationSchema

public RelationSchema()
This is for View and Clone functions.

RelationSchema

public RelationSchema(java.lang.String[] newSchema)

RelationSchema

public RelationSchema(java.io.DataInputStream din)

RelationSchema

public RelationSchema(java.sql.ResultSet rs)
               throws java.lang.Exception
Here we generate each name as "R_A".

RelationSchema

public RelationSchema(java.sql.ResultSet rs,
                      java.lang.String sign)
               throws java.lang.Exception
Should erase SWEEPSIGN field from the Schema.

RelationSchema

public RelationSchema(java.sql.ResultSet rs,
                      Relation rel,
                      java.lang.String sign)
               throws java.lang.Exception
Should erase SWEEPSIGN field from the Schema.
Method Detail

clone

public java.lang.Object clone()
Parameters:
r - is the new cloned relation.
Overrides:
clone in class java.lang.Object

addCol

private void addCol(java.lang.String colName)

size

public int size()
this function return the Number of labels in the schema

createSQL

public java.lang.String createSQL()
this function will return SQL, for create table. because I cannot get the type from the ResultSet, so, here, I just assume everything is char(250).

createSQL

public java.lang.String createSQL(java.lang.String sign)
this function will return SQL, for create table. because I cannot get the type from the ResultSet, so, here, I just assume everything is char(250). It will add a SWEEPSIGN field.

getCommon

public java.lang.String getCommon(RelationSchema theSchema)
get the only one common Attribute of two schemas

write

public void write(java.io.DataOutputStream dout)
write the schema to the file

getSQL

public java.lang.String getSQL()
Get SQL from this Schema List. For View Definition E.g. CREATE VIEW V (PRICE, RETIME) ..., it will returns "PRICE, RETIME"

toString

public java.lang.String toString()
Convert to String.
Overrides:
toString in class java.lang.Object

getColName

public java.lang.String getColName(int index)
Return column Name of specific Column Number. E.g. a relation schema is: 'col1', 'col2', 'col3'. if input index is 0, return 'col1'; 1, return 'col2'; 2, return 'col3'.

getIndex

int getIndex(java.lang.String colName)
Get Index of one labels in the schema. the Index start from 1.
Parameters:
colname - name of label.
Returns:
index of the Label; 0 means not found.

getFlags

public int[] getFlags(RelationSchema schema)
Return a set of flags to show which column is projected. E.g. the relation shema is 'col1', 'col2', 'col3'. projected schema is "col3, col2", then the flags are "0,2,1".

getFlags

public int[] getFlags(java.lang.String colName)
This will return flags for projection. The flag of the specific colName will be set to zero. At later doProject() it will be deleted from the Relation. E.g. we have schema "col1, col2, col3", we want to delete "col3", the flags are "1,1,0".

find

private boolean find(java.lang.String colName)
Check if such column name stored in such schema. This is a linear searching.

whereIs

private int whereIs(java.lang.String colName)
             throws NotFoundException
Find where is such column name stored in this schema. This is a linear searching.

isSubsetOf

public boolean isSubsetOf(RelationSchema theSchema)
Check is current Schema is a subset of other Schema. It is used for the Projection operation of Relation class.

doProject

public void doProject(int[] flags)
               throws java.lang.Exception
This function will decrease the Schema based on the flags. E.g. if the original schema is "col1, col2, col3", flags is "2, 0, 1", then the new schema is "col3, col1".

equals

public boolean equals(RelationSchema rs)
               throws java.lang.Exception
Check if two Schemas are quivaluent.

changeAttrName

public void changeAttrName(java.lang.String newName,
                           int index)
Change specific Attribute Name in this schema.

getAttrName

public java.lang.String getAttrName(int index)
Get one specific Attribute 's name.