its.SQL
Class Variable

java.lang.Object
  extended byits.SQL.Variable
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

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

Provides an object-oriented view of a table column from an SDD Schema. Created and used by the SDD Parser to store information parsed from the SDD Schema frame. Represents the column name, data type, and associated constraints such as NOT NULL or DEFAULT.

See Also:
Serialized Form

Field Summary
static int BIT
           
static int CHAR
           
static int DEC
           
static int DEFAULT
           
static int DOUBLE
           
static int FLOAT
           
static int INTEGER
           
static int NOT_NULL
           
static int NUMERIC
           
static int PRIMARY_KEY
           
static int RAW
           
static int REAL
           
static int SMALLINT
           
static int UNIQUE
           
 
Constructor Summary
Variable(int type)
          Constructs a Variable with the given type.
Variable(int type, int size)
          Constructs a Variable with the given type and size.
Variable(int type, int size, int decimal_digits)
          Constructs a Variable given its type, precision or size, and scale.
Variable(java.lang.String name, int type)
          Constructs a Variable given its name and type
Variable(java.lang.String name, int type, int constraints)
          Constructs a Variable given its name, type, and constraints.
Variable(java.lang.String name, int type, int size, int constraints)
          Constructs a Variable given its name, type, size, and constraints.
Variable(java.lang.String name, int type, int size, int decimal_digits, int constraints)
          Constructs a Variable given its name, type, precision, scale, and constraints.
 
Method Summary
 void addConstraint(int constraint)
          Specifies an SQL constraint to apply to this variable.
 java.lang.Object clone()
           
 boolean equals(Variable v)
          Equality comparison for data types.
 java.lang.String getName()
           
 int getPrecision()
           
static java.lang.Object getResultSetData(Variable var, java.sql.ResultSet rs)
          static method to extract appropriate types from result set.
 int getScale()
           
 int getSize()
          returns the number of elements in a string or array data type such as fixed-length character and bit strings.
 int getType()
           
 java.lang.String getTypeName()
           
 boolean isDefault()
           
 boolean isNotNull()
           
 boolean isPrimaryKey()
           
 boolean isUnique()
           
static int JDBC2Variable(int jdbcType)
          maps java.sql.Types types to its.SQL.Variable types
 void removeConstraint(int constraint)
          Specifies an SQL constraint to remove from this variable.
 void setName(java.lang.String s)
           
 java.lang.String toSql()
          Generates the SQL column definition string for this variable
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAR

public static final int CHAR
See Also:
Constant Field Values

BIT

public static final int BIT
See Also:
Constant Field Values

INTEGER

public static final int INTEGER
See Also:
Constant Field Values

SMALLINT

public static final int SMALLINT
See Also:
Constant Field Values

NUMERIC

public static final int NUMERIC
See Also:
Constant Field Values

DEC

public static final int DEC
See Also:
Constant Field Values

FLOAT

public static final int FLOAT
See Also:
Constant Field Values

REAL

public static final int REAL
See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE
See Also:
Constant Field Values

RAW

public static final int RAW
See Also:
Constant Field Values

NOT_NULL

public static final int NOT_NULL
See Also:
Constant Field Values

DEFAULT

public static final int DEFAULT
See Also:
Constant Field Values

PRIMARY_KEY

public static final int PRIMARY_KEY
See Also:
Constant Field Values

UNIQUE

public static final int UNIQUE
See Also:
Constant Field Values
Constructor Detail

Variable

public Variable(java.lang.String name,
                int type)
Constructs a Variable given its name and type

Parameters:
name - the name of the column this object describes
type - one of the type constants defined in this class

Variable

public Variable(java.lang.String name,
                int type,
                int constraints)
Constructs a Variable given its name, type, and constraints.

Parameters:
name - the name of the column this object describes
type - one of the type constants defined in this class
constraints - bitwise combination of constraint constants defined in this class

Variable

public Variable(java.lang.String name,
                int type,
                int size,
                int constraints)
Constructs a Variable given its name, type, size, and constraints.

Parameters:
name - the name of the column this object describes
type - one of the type constants defined in this class
size - array length for CHAR and BIT fields
constraints - bitwise combination of constraint constants defined in this class

Variable

public Variable(java.lang.String name,
                int type,
                int size,
                int decimal_digits,
                int constraints)
Constructs a Variable given its name, type, precision, scale, and constraints.

Parameters:
name - the name of the column this object describes
type - one of the type constants defined in this class
size - for CHAR and BIT types, this is the max number of characters; NUMERIC and DECIMAL types, this is the precision.
decimal_digits - for NUMERIC and DECIMAL types only, the number of fractional digits
constraints - bitwise combination of constraint constants defined in this class

Variable

public Variable(int type,
                int size,
                int decimal_digits)
Constructs a Variable given its type, precision or size, and scale.

Parameters:
type - one of the type constants defined in this class
size - for CHAR and BIT types, this is the max number of characters; NUMERIC and DECIMAL types, this is the precision.
decimal_digits - for NUMERIC and DECIMAL types only, the number of fractional digits

Variable

public Variable(int type,
                int size)
Constructs a Variable with the given type and size.

Parameters:
type - one of the type constants defined in this class
size - array length for CHAR and BIT fields

Variable

public Variable(int type)
Constructs a Variable with the given type.

Parameters:
type - one of the type constants defined in this class
Method Detail

getTypeName

public java.lang.String getTypeName()

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException

JDBC2Variable

public static int JDBC2Variable(int jdbcType)
maps java.sql.Types types to its.SQL.Variable types

Parameters:
jdbcType - int value of JDBC type

addConstraint

public void addConstraint(int constraint)
Specifies an SQL constraint to apply to this variable.


removeConstraint

public void removeConstraint(int constraint)
Specifies an SQL constraint to remove from this variable.


getName

public java.lang.String getName()
Returns:
the name of the variable

setName

public void setName(java.lang.String s)
Parameters:
s - the name of the variable

getType

public int getType()
Returns:
the variable type (one of the constants defined in this class)

getSize

public int getSize()
returns the number of elements in a string or array data type such as fixed-length character and bit strings.

Returns:
the fixed length of this data type, or 1 if not a string type.

getPrecision

public int getPrecision()
Returns:
precision of a numeric datatype, or 0 if non-numeric or not specified.

getScale

public int getScale()
Returns:
scale of a numeric datatype, or 0 if non-numeric or not specified.

isNotNull

public boolean isNotNull()
Returns:
true if the NOT NULL constraint applies to this variable

isDefault

public boolean isDefault()
Returns:
true if the DEFAULT constraint applies to this variable

isUnique

public boolean isUnique()
Returns:
true if the UNIQUE constraint applies to this variable

isPrimaryKey

public boolean isPrimaryKey()
Returns:
true if the PRIMARY KEY constraint applies to this variable

getResultSetData

public static java.lang.Object getResultSetData(Variable var,
                                                java.sql.ResultSet rs)
                                         throws java.sql.SQLException
static method to extract appropriate types from result set. values returned as String.

Parameters:
var - the Variable
rs - the ResultSet
Throws:
java.sql.SQLException

equals

public boolean equals(Variable v)
Equality comparison for data types. Column name and constraints are irrelevant.


toSql

public java.lang.String toSql()
Generates the SQL column definition string for this variable