public class Column extends CompareTerm
Modifier and Type | Field and Description |
---|---|
static int |
CHAR
A column of type CHAR
|
static int |
INTEGER
A column of type INTEGER
|
static int |
MAX_WIDTH_INTEGER
The print width of an INTEGER column.
|
static int |
MAX_WIDTH_REAL
The print width of a REAL column.
|
static int |
REAL
A column of type REAL
|
static int |
VARCHAR
A column of type VARCHAR
|
STRING
Constructor and Description |
---|
Column(Column col)
Constructs a Column object that has the same initial field
values as the specified column.
|
Column(String name)
Constructs a Column object with the specified name.
|
Column(String name,
Table t)
Constructs a Column object with the specified name from the
specified table.
|
Modifier and Type | Method and Description |
---|---|
Object |
adjustValue(Object val)
Returns an adjusted value for this column, based on its type
and length.
|
void |
applyOpts(ColumnOptions opts)
Applies the specified column options to this column.
|
int |
getIndex()
Returns the index of the column in the table to which it
belongs.
|
int |
getLength()
Returns the length of the column -- i.e., the number of bytes used to
represent its values.
|
String |
getName()
Returns the name of the column.
|
Table |
getTable()
Returns the table to which this column belongs.
|
TableIterator |
getTableIterator()
Returns the table iterator used to obtain values of this column
IMPORTANT: if you invoke this method on a Column from a Table
object's array of column information, it will return null.
|
int |
getType()
Returns the type of the column
|
Object |
getUpdateVal()
Returns the update value associated with this column -- i.e., the value
it should be assigned by an update command.
|
Object |
getValue()
Returns the current value of this column, based on the row on which
the corresponding table iterator is currently positioned.
|
boolean |
isNotNull()
Returns a boolean value indicating whether this column is prevented
from taking on null values.
|
boolean |
isPrimaryKey()
Returns a boolean value indicating whether this column is the
primary key of its table
|
boolean |
nameMatches(Column other,
Table otherTable)
Determines if the column represented by the called object has
the same name as the column represented by the two parameters.
|
int |
printWidth()
Returns the maximum print width for values from this column.
|
void |
resetUpdateVal()
Removes any update value associated with this column, which means
that an update command will not try to update it unless a new
update value is specified using
setUpdateVal . |
void |
setIndex(int i)
Sets the index of this column -- i.e., its index in the
table to which it belongs.
|
void |
setLength(int length)
Sets the length of this column.
|
void |
setLength(Integer length)
Sets the length of this column -- i.e., the number of bytes used to
represent its values.
|
void |
setTableIterator(TableIterator iter)
Sets the table iterator used to obtain the values of this column.
|
void |
setType(int type)
Sets the type of this column -- which must be one of the constants
specified in this class (INTEGER, REAL, CHAR, or VARCHAR).
|
void |
setUpdateVal(Object val)
Sets the update value associated with this column, which means
that any update commands will try to update it until the update
value is removed using
resetUpdateVal . |
boolean |
shouldUpdate()
Determines whether this column should be updated by an update command
-- i.e., if it has an up-to-date update value.
|
String |
toString() |
void |
useColInfo(Column other)
Gives the column specified by the called object the same
metadata (type, length, etc.) as the specified other column.
|
getValType, setValType
public static final int INTEGER
public static final int REAL
public static final int CHAR
public static final int VARCHAR
public static final int MAX_WIDTH_INTEGER
public static final int MAX_WIDTH_REAL
public Column(String name)
name
- the name of the columnpublic Column(String name, Table t)
name
- the name of the columnt
- the table to which the column belongspublic Column(Column col)
col
- the column we want to copypublic boolean nameMatches(Column other, Table otherTable)
other
- the other column whose name we are comparing
againstotherTable
- the other column's tablepublic Object adjustValue(Object val)
IllegalArgumentException
if the value cannot be converted (e.g., if a string is specified
for an integer column).val
- the unadjusted valueIllegalArgumentException
- if the specified value cannot be
converted to a valid value for this columnpublic Object getValue()
getValue
in class CompareTerm
public int printWidth()
IllegalStateException
- if the column has an unknown typepublic void setType(int type)
type
- the column's typeIllegalArgumentException
- if an invalid type is specifiedpublic void setLength(int length)
length
- the column's lengthIllegalArgumentException
- if a 0 or negative length is specifiedpublic void setLength(Integer length)
length
- the column's lengthIllegalArgumentException
- if a 0 or negative length is specified
or if the argument is nullpublic void applyOpts(ColumnOptions opts)
opts
- the column optionspublic void setIndex(int i)
i
- the indexIllegalArgumentException
- if a negative index is specifiedpublic void resetUpdateVal()
setUpdateVal
.public boolean shouldUpdate()
public void setUpdateVal(Object val)
resetUpdateVal
.val
- the value the column should be assignedpublic void useColInfo(Column other)
other
- the column whose metadata we want to copyIllegalArgumentException
- if a null argument is specifiedpublic void setTableIterator(TableIterator iter)
iter
- the table iteratorpublic String getName()
public Table getTable()
public int getType()
public int getLength()
public boolean isNotNull()
public boolean isPrimaryKey()
public int getIndex()
public Object getUpdateVal()
null
both when there is no update value and when
there is an update value of null
. To determine if a
column should be updated, use the shouldUpdate()
method.public TableIterator getTableIterator()
public String toString()
toString
in class CompareTerm