erkka
Class Relation

java.lang.Object
  |
  +--erkka.Relation

public class Relation
extends java.lang.Object

Title:

Description: Relation knows all information about a relation(table): tablaName, primarykey, attributes and the list of the lines, whose type is Reference.

Copyright: Copyright (c) 2002

Company: University of Jyväskylä

Version:
1.2 Jukka Mäntylä findAttributes - parsing NUMERIC(m,n)-type attributes fixed

Constructor Summary
Relation()
          constructor creates new Relation
 
Method Summary
 void createTable(java.io.BufferedReader breader, java.lang.String line)
          creates CREATE TABLE by placing all information at the same line.
 void findAttributes(java.lang.String attriLine)
          find attributes modified by Jukka Mäntylä 2005.
 void findConstraints(java.lang.String endLine)
          find constrains
 java.lang.String findFirstWord(java.lang.String line)
          return the first word of the line.
 java.util.Vector getAttributes()
           
 java.util.Vector getLines()
           
 java.util.Vector getPrimarykey()
           
 java.lang.String getTableName()
           
 java.util.Vector IncludeOfBracketAsVector(java.lang.String line)
          return the include of bracket as Vector.
 boolean isPrimaryKey(java.lang.String attrname)
          Is primarykey or not
 java.lang.String removeEnterInCreateTable(java.io.BufferedReader breader, java.lang.String line)
          Remove all enter from CREATE TABLE to ); -character.
 java.lang.String removeExtraSpace(java.lang.String line)
          Remove extra spaces.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Relation

public Relation()
constructor creates new Relation

Method Detail

getTableName

public java.lang.String getTableName()
Returns:
tableName

getPrimarykey

public java.util.Vector getPrimarykey()
Returns:
primarykey

getAttributes

public java.util.Vector getAttributes()
Returns:
attributes

getLines

public java.util.Vector getLines()
Returns:
lines

isPrimaryKey

public boolean isPrimaryKey(java.lang.String attrname)

Is primarykey or not

Parameters:
attrname - Name of attribute
Returns:
true if is primarykey and false if not

removeEnterInCreateTable

public java.lang.String removeEnterInCreateTable(java.io.BufferedReader breader,
                                                 java.lang.String line)

Remove all enter from CREATE TABLE to ); -character.

Parameters:
breader -
line - line whice is readed, not include CREATE TABLE -word
Returns:
tempLine: is line whice includes one table

removeExtraSpace

public java.lang.String removeExtraSpace(java.lang.String line)

Remove extra spaces. After this method there can be only one space between two words. Remove all spaces at the begin of the line.

Parameters:
line - whice we are reading
Returns:
stemp line, whice extra space are removed

createTable

public void createTable(java.io.BufferedReader breader,
                        java.lang.String line)
                 throws java.lang.Exception

creates CREATE TABLE by placing all information at the same line. The line is devided to attributeLine and endLine, then is asked functions findAttributes and findConstraints 1.line:CREATE TABLE 2.line:Osasto(OsastoID INTEGER NOT NULL,OsastoNimi VARCHAR(32)....

Parameters:
breader -
line - the first index of line is the first character after CREATE TABLE and the last character is );
java.lang.Exception

findAttributes

public void findAttributes(java.lang.String attriLine)

find attributes

modified by Jukka Mäntylä 2005. Bugfix for attributes like NUMERIC(7,2)

Parameters:
attriLine - AttriLine begin with first attribute and end with word before CONSTRAINT. The first character of the attriLine can't be empty and the last don't get be comma.

findConstraints

public void findConstraints(java.lang.String endLine)
                     throws java.lang.Exception

find constrains

Parameters:
endLine - the first character of the endLine is C (CONSTRAINT) and the last character is );
java.lang.Exception

IncludeOfBracketAsVector

public java.util.Vector IncludeOfBracketAsVector(java.lang.String line)

return the include of bracket as Vector.

Parameters:
line -
Returns:
primarykey

findFirstWord

public java.lang.String findFirstWord(java.lang.String line)

return the first word of the line.

Parameters:
line - firts character dont't get be empty
Returns:
word to next space