edu.wpi.cs.dsrg.xmldb.xat.common.xatnode
Class XATTableImp

java.lang.Object
  |
  +--edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATPropertiesImp
        |
        +--edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATQueryObjectImp
              |
              +--edu.wpi.cs.dsrg.xmldb.xat.common.xatnode.XATDataSourceImp
                    |
                    +--edu.wpi.cs.dsrg.xmldb.xat.common.xatnode.XATTableImp

public class XATTableImp
extends XATDataSourceImp
implements XATTable

The class defines the data model of the XAT, which is a table of XML fragments.

Since:
1.0
See Also:
Serialized Form

Field Summary
protected  java.lang.String sTableName
          The name of XATTable.
protected  java.util.Vector vColList
          The content of columns within XATTable.
protected  java.util.Vector vColNames
          The name of columns within XATTable.
 
Fields inherited from class edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATQueryObjectImp
stats, statsPresent
 
Constructor Summary
XATTableImp()
          The default XATTableImp Constructor.
XATTableImp(java.lang.String sName, java.lang.Object oValue)
          The XATTableImp constructor.
XATTableImp(XATTable xtabInit)
          The XATTableImp Constructor.
 
Method Summary
 void accept(Visitor visitor)
          This method is used to implement a visitor pattern.
 int appendColumn(java.lang.String sColumnName)
          Append an empty column to the end of the table.
 int appendColumn(java.lang.String sName, java.util.Vector new_column)
          Append a new column to the end of the table.
 void appendTable(XATTable sour)
          Append this table to given table.
 int appendTuple(java.util.Vector new_tuple)
          Append a new tuple to the end of the table.
 XATTable cloneSchema()
          Construct a new XATTable which has the same column names as this XATTable.
static java.util.Vector collectionDistinct(java.util.Vector vecDis)
          Remove duplicates from a collection.
 void deleteAllTuples()
          Delete all the tuples in this XATTable.
 java.util.Vector deleteColumn(int position)
          Delete a column from the specific position.
 java.util.Vector deleteTuple(int position)
          Delete a tuple of the specified position.
static java.lang.String elementToString(org.w3c.dom.Element o)
          Convert the XML element with the cell of XAT into a String.
 java.util.Vector getColList()
          Get the vector containing all the columns content within the XATTable.
 java.util.Vector getColNames()
          Get the vector containing all the column names within the XATTable.
 java.util.Vector getColumn(int position)
          Get one column content from the specified position.
 java.lang.String getColumnName(int position)
          Get the column name for a specific column position.
 int getColumnPosition(java.lang.String column_name)
          Get the Position of a column with the given Column Name.
 java.util.Vector getCommonColumnNames(XATTable tab2)
          This method takes two XATTables, finds all matching columns.
 java.lang.String getName()
          Get the Name of the XATTable.
 int getNumberOfColumns()
          Get total number of columns in this table.
 int getNumberOfTuples()
          Get total number of tuples in this table.
 java.util.Vector getRowList()
          Get the vector containing the columns contents.
 java.util.Vector getTuple(int position)
          Get a tuple in a specified position.
 java.util.Vector getUnCommonColumnNames(XATTable tab2)
          This method takes two XATTables, and finds all un-matching columns.
 XATValue getValue(int column_position, int tuple_position)
          Get a cell by column and tuple positions.
 int insertColumn(int position, java.lang.String sName, java.util.Vector new_column)
          Insert a new column to the table before specific position.
 int insertTuple(int position, java.util.Vector ntuple)
          Insert a new tuple to the table before specific position.
static boolean isDebug()
          Get the value of the propertity 'DEBUG_NavTaggerCancelout'.
 java.util.Vector mergeColumnNames(XATTable tab2)
          Merge the column names of two XATTables.
 void moveColumn(int from_position, int to_position)
          Move a column to a specific position.
 void moveTuple(int from_position, int to_position)
          Move a tuple to a specific position.
 void print()
          Prints the XATTable
 void setColumnName(java.lang.String newName, int position)
          Set Column Name in the specified position.
 java.lang.String setName(java.lang.String newName)
          Set the Name of the Table.
 java.lang.String toString()
          Convert the XATTable into a String for output.
 java.util.Vector updateColumn(int position, java.util.Vector new_column)
          Update a column in the specified position.
 java.util.Vector updateTuple(int position, java.util.Vector new_tuple)
          Update a tuple.
 XATValue updateValue(int column_position, int tuple_position, XATDataValue new_value)
          Update a cell with a specific object.
 XATValue updateValue(int column_position, int tuple_position, XATValue new_value)
          Update a cell with a specific object.
 
Methods inherited from class edu.wpi.cs.dsrg.xmldb.xat.common.xatnode.XATDataSourceImp
deepCloneDataSource, setDefaultProperties
 
Methods inherited from class edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATQueryObjectImp
addStatistic, compareTo, getStatistics, isValidStatistic, setDefaultStatistics
 
Methods inherited from class edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATPropertiesImp
addProperty, getProperties, getProperty, isValidPropertyName, setNewPropertyValue, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sTableName

protected java.lang.String sTableName
The name of XATTable.
Since:
1.0

vColNames

protected java.util.Vector vColNames
The name of columns within XATTable.
Since:
1.0

vColList

protected java.util.Vector vColList
The content of columns within XATTable.
Since:
1.0
Constructor Detail

XATTableImp

public XATTableImp()
The default XATTableImp Constructor.
Since:
1.0

XATTableImp

public XATTableImp(XATTable xtabInit)
The XATTableImp Constructor.
Parameters:
xtabInit - The XATTable to initialize this XATTable.
Since:
1.0

XATTableImp

public XATTableImp(java.lang.String sName,
                   java.lang.Object oValue)
The XATTableImp constructor.
Parameters:
sName - The Table name.
oValue - The table content.
Since:
1.0
Method Detail

accept

public void accept(Visitor visitor)
This method is used to implement a visitor pattern.
Parameters:
visitor -  
Returns:
void
Since:
1.0

appendColumn

public int appendColumn(java.lang.String sColumnName)
                 throws XATTableTupleNoMatchException
Append an empty column to the end of the table. When we append the column, we have to make sure the column never exists in the XAT table before, Otherwise, delete the original column, and print out an error message.
Parameters:
new_column - The new column going to be appended.
Returns:
int The column position of the appended new column.
Throws:
XATTableTupleNoMatchException -  
Since:
1.0

appendColumn

public int appendColumn(java.lang.String sName,
                        java.util.Vector new_column)
                 throws XATTableTupleNoMatchException
Append a new column to the end of the table.
Parameters:
sName - The name of the new appended column.
new_column - The new column going to be appended.
Returns:
int The column position of the new appended column.
Since:
1.0

appendTable

public void appendTable(XATTable sour)
Append this table to given table.
Specified by:
appendTable in interface XATTable
Parameters:
sour - The source table will be appended.
Returns:
void
Since:
1.0

appendTuple

public int appendTuple(java.util.Vector new_tuple)
                throws XATTableSchemaNoMatchException
Append a new tuple to the end of the table.
Specified by:
appendTuple in interface XATTable
Parameters:
new_tuple - The new tuple going to be appended.
Returns:
int The position of the new appended tuple.
Since:
1.0

cloneSchema

public XATTable cloneSchema()
Construct a new XATTable which has the same column names as this XATTable.
Specified by:
cloneSchema in interface XATTable
Returns:
XATTable The new constructed XATTable.
Since:
1.0

collectionDistinct

public static java.util.Vector collectionDistinct(java.util.Vector vecDis)
Remove duplicates from a collection.
Parameters:
vecDis - The Vector clearing for.
Returns:
Vector The result Vector.
Since:
1.0

deleteAllTuples

public void deleteAllTuples()
Delete all the tuples in this XATTable.
Specified by:
deleteAllTuples in interface XATTable
Returns:
void
Since:
1.0

deleteColumn

public java.util.Vector deleteColumn(int position)
                              throws XATTableOutOfRangeException,
                                     XATTableEmptyException
Delete a column from the specific position. Note: Col Index starts from 1.
Parameters:
position - The position of column going to be deleted.
Returns:
Vector The content of the deleted column.
Since:
1.0

deleteTuple

public java.util.Vector deleteTuple(int position)
                             throws XATTableOutOfRangeException,
                                    XATTableEmptyException
Delete a tuple of the specified position.
Specified by:
deleteTuple in interface XATTable
Parameters:
position - The position of the tuple going to be deleted.
Returns:
Vector The content of the deleted tuple.
Since:
1.0

elementToString

public static java.lang.String elementToString(org.w3c.dom.Element o)
Convert the XML element with the cell of XAT into a String.
Parameters:
o - The element will be converted.
Returns:
String The result string.
Since:
1.0

getColList

public java.util.Vector getColList()
Get the vector containing all the columns content within the XATTable.
Returns:
Vector The vector containing the columns content.
Since:
1.0

getColNames

public java.util.Vector getColNames()
Get the vector containing all the column names within the XATTable.
Returns:
Vector The Vector containing the column names.
Since:
1.0

getColumn

public java.util.Vector getColumn(int position)
                           throws XATTableOutOfRangeException
Get one column content from the specified position.
Parameters:
The - position of the column start from 1.
Returns:
a Vector of cells in one column.

getColumnName

public java.lang.String getColumnName(int position)
                               throws XATTableOutOfRangeException
Get the column name for a specific column position.
Parameters:
The - column position.
Returns:
column Name for a give position.

getColumnPosition

public int getColumnPosition(java.lang.String column_name)
                      throws XATTableColumnNoExistException
Get the Position of a column with the given Column Name. Note: The column is not case sensitive.
Parameters:
column_name - The column name searching for.
Returns:
int The position of the column.
Since:
1.0

getCommonColumnNames

public java.util.Vector getCommonColumnNames(XATTable tab2)
This method takes two XATTables, finds all matching columns.
Specified by:
getCommonColumnNames in interface XATTable
Parameters:
tab2 - The another source XATTable.
Returns:
Vector The vector containning all common columns of two XATTable.
Since:
1.0

getName

public java.lang.String getName()
Get the Name of the XATTable.
Specified by:
getName in interface XATTable
Returns:
String The name of the XATTable.
Since:
1.0

getNumberOfColumns

public int getNumberOfColumns()
Get total number of columns in this table.
Returns:
int The total number of columns in this XATTable.
Since:
1.0

getNumberOfTuples

public int getNumberOfTuples()
Get total number of tuples in this table.
Specified by:
getNumberOfTuples in interface XATTable
Returns:
int The total number of tuples with this XATTable.
Since:
1.0

getRowList

public java.util.Vector getRowList()
Get the vector containing the columns contents.
Specified by:
getRowList in interface XATTable
Returns:
Vector The Vector containing the columns contents.
Since:
1.0

getTuple

public java.util.Vector getTuple(int position)
                          throws XATTableEmptyException,
                                 XATTableOutOfRangeException
Get a tuple in a specified position.
Specified by:
getTuple in interface XATTable
Parameters:
position - The position of the tuple start from 1.
Returns:
Vector The Vector of cells in one tuple.
Since:
1.0

getUnCommonColumnNames

public java.util.Vector getUnCommonColumnNames(XATTable tab2)
This method takes two XATTables, and finds all un-matching columns.
Specified by:
getUnCommonColumnNames in interface XATTable
Parameters:
tab2 - The another source XATTable.
Returns:
Vector Containing all the un-matching columns.
Since:
1.0

getValue

public XATValue getValue(int column_position,
                         int tuple_position)
                  throws XATTableEmptyException,
                         XATTableOutOfRangeException
Get a cell by column and tuple positions.
Parameters:
column_position - The column position of the cell we are looking for.
tuple_position - The tuple position of the cell we are looking for.
Returns:
edu.wpi.cs.dsrg.xmldb.xat.common.xatnode.XATValue - The value in the cell specified by column_positon and tuple_positon.
Throws:
XATTableOutOfRangeException -  
XATTableEmptyException -  
Since:
1.0

insertColumn

public int insertColumn(int position,
                        java.lang.String sName,
                        java.util.Vector new_column)
                 throws XATTableOutOfRangeException,
                        XATTableTupleNoMatchException
Insert a new column to the table before specific position.
Parameters:
position - The position for new inserted column.
sName - The new column name.
new_column - The new column content.
Returns:
int The number of Columns after the insertion.
Throws:
XATTableOutOfRangeException -  
XATTableTupleNoMatchException -  
Since:
1.0

insertTuple

public int insertTuple(int position,
                       java.util.Vector ntuple)
                throws XATTableOutOfRangeException,
                       XATTableSchemaNoMatchException
Insert a new tuple to the table before specific position.
Specified by:
insertTuple in interface XATTable
Parameters:
positoin - The inserted tuple position.
new_tuple - The new tuple content.
Returns:
int The number of tuples after the insertion.
Since:
1.0

isDebug

public static boolean isDebug()
Get the value of the propertity 'DEBUG_NavTaggerCancelout'.
Returns:
boolean True: With debug information. False: No debug information.
Since:
1.0

mergeColumnNames

public java.util.Vector mergeColumnNames(XATTable tab2)
Merge the column names of two XATTables. This method takes two XATTables, and try to find all matching columns, adds those to the head of a vector, and appends all other column names at the end.
Parameters:
tab2 - The another source XATTable.
Returns:
java.util.Vector The result column name vector.
Since:
1.0

moveColumn

public void moveColumn(int from_position,
                       int to_position)
                throws XATTableOutOfRangeException,
                       XATTableEmptyException
Move a column to a specific position.
Parameters:
from_position - Specify the position of column to be moved.
to_position - Identfiy the dest position moved to.
Returns:
void
Throws:
XATTableOutOfRangeException -  
XATTableEmptyException -  
XATTableTupleNoMatchException -  
Since:
1.0

moveTuple

public void moveTuple(int from_position,
                      int to_position)
               throws XATTableOutOfRangeException,
                      XATTableEmptyException
Move a tuple to a specific position.
Specified by:
moveTuple in interface XATTable
Parameters:
from_position - The position of tuple to be moved.
to_position - Identify the dest position moved to.
Returns:
void
Since:
1.0

print

public void print()
Prints the XATTable
Specified by:
print in interface XATTable
Returns:
void
Since:
1.0

setColumnName

public void setColumnName(java.lang.String newName,
                          int position)
                   throws XATTableOutOfRangeException
Set Column Name in the specified position.
Specified by:
setColumnName in interface XATTable
Parameters:
newName - The new name for column.
position - The position for this new column name.
Returns:
void
Since:
1.0

setName

public java.lang.String setName(java.lang.String newName)
Set the Name of the Table.
Specified by:
setName in interface XATTable
Parameters:
newName - The new name of the XATTable.
Returns:
The old name of the XATTable.
Since:
1.0

toString

public java.lang.String toString()
Convert the XATTable into a String for output.
Specified by:
toString in interface XATTable
Overrides:
toString in class java.lang.Object
Returns:
String The result string.
Since:
1.0

updateColumn

public java.util.Vector updateColumn(int position,
                                     java.util.Vector new_column)
                              throws XATTableOutOfRangeException,
                                     XATTableEmptyException,
                                     XATTableTupleNoMatchException
Update a column in the specified position.
Parameters:
position - The position of updated column.
new_column - The new column.
Returns:
Vector The old column.
Since:
1.0

updateTuple

public java.util.Vector updateTuple(int position,
                                    java.util.Vector new_tuple)
                             throws XATTableOutOfRangeException,
                                    XATTableEmptyException,
                                    XATTableSchemaNoMatchException
Update a tuple.
Specified by:
updateTuple in interface XATTable
Parameters:
position - The position of tuple to be updated.
new_tuple - The new tuple.
Returns:
Vector The old tuple updated.
Since:
1.0

updateValue

public XATValue updateValue(int column_position,
                            int tuple_position,
                            XATDataValue new_value)
                     throws XATTableOutOfRangeException,
                            XATTableEmptyException
Update a cell with a specific object.
Parameters:
column_position - The Column position of the cell.
tuple_position - The Tuple position of the cell.
new_value - The new value of the cell.
Returns:
XATValue The old value in the cell.
Since:
1.0

updateValue

public XATValue updateValue(int column_position,
                            int tuple_position,
                            XATValue new_value)
                     throws XATTableOutOfRangeException,
                            XATTableEmptyException
Update a cell with a specific object.
Parameters:
column_position - The Column position.
tuple_position - The Tuple position.
new_value - The new value of the cell.
Returns:
XATValue The old value in the cell.
Since:
1.0