|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.data.Schema
public class Schema
The Schema class represents a description of a Table's columns, including
column names, data types, and default values. New Table
instances can be created directly from Schema objects through the use of
the instantiate()
method. If a schema is subsequently changed,
instantiated table instances are not affected, keeping their original
schema.
Schema instances can be locked to prevent further changes. Any attempt to alter a locked schema will result in a runtime exception being thrown. If a schema is not locked, clients are free to add new columns and edit default values.
Constructor Summary | |
---|---|
Schema()
Creates a new empty schema. |
|
Schema(int ncols)
Creates a new empty schema with a starting capacity for a given number of columns. |
|
Schema(java.lang.String[] names,
java.lang.Class[] types)
Create a new schema consisting of the given column names and types. |
|
Schema(java.lang.String[] names,
java.lang.Class[] types,
java.lang.Object[] defaults)
Create a new schema consisting of the given column names, types, and default column values. |
Method Summary | |
---|---|
void |
addColumn(java.lang.String name,
java.lang.Class type)
Add a column to this schema. |
void |
addColumn(java.lang.String name,
java.lang.Class type,
java.lang.Object defaultValue)
Add a column to this schema. |
void |
addInterpolatedColumn(java.lang.String name,
java.lang.Class type)
Add an interpolated column with a null default value. |
void |
addInterpolatedColumn(java.lang.String name,
java.lang.Class type,
java.lang.Object dflt)
Add a new interpolated column to this data schema. |
java.lang.Object |
clone()
Creates a copy of this Schema. |
boolean |
equals(java.lang.Object o)
Compares this schema with another one for equality. |
int |
getColumnCount()
Get the number of columns in this schema. |
int |
getColumnIndex(java.lang.String field)
The column index for the column with the given name. |
java.lang.String |
getColumnName(int col)
The name of the column at the given position. |
java.lang.Class |
getColumnType(int col)
The type of the column at the given position. |
java.lang.Class |
getColumnType(java.lang.String field)
The type of the column with the given name. |
java.lang.Object |
getDefault(int col)
The default value of the column at the given position. |
java.lang.Object |
getDefault(java.lang.String field)
The default value of the column with the given name. |
int |
hashCode()
Computes a hashcode for this schema. |
protected void |
initLookup()
Lazily construct the lookup table for this schema. |
Table |
instantiate()
Instantiate this schema as a new Table instance. |
Table |
instantiate(int nrows)
Instantiate this schema as a new Table instance. |
boolean |
isAssignableFrom(Schema s)
Indicates if values from a given Schema can be safely assigned to data using this Schema. |
boolean |
isLocked()
Indicates if this schema is locked. |
Schema |
lockSchema()
Locks the schema, preventing any additional changes. |
void |
setDefault(int col,
java.lang.Object val)
Set the default value for the given field. |
void |
setDefault(java.lang.String field,
boolean val)
Set the default value for the given field as a boolean. |
void |
setDefault(java.lang.String field,
double val)
Set the default value for the given field as a double. |
void |
setDefault(java.lang.String field,
float val)
Set the default value for the given field as a float. |
void |
setDefault(java.lang.String field,
int val)
Set the default value for the given field as an int. |
void |
setDefault(java.lang.String field,
long val)
Set the default value for the given field as a long. |
void |
setDefault(java.lang.String field,
java.lang.Object val)
Set the default value for the given field. |
void |
setInterpolatedDefault(java.lang.String field,
boolean val)
Set default values for the current, start, and end columns of an interpolated column as a boolean. |
void |
setInterpolatedDefault(java.lang.String field,
double val)
Set default values for the current, start, and end columns of an interpolated column as a double. |
void |
setInterpolatedDefault(java.lang.String field,
float val)
Set default values for the current, start, and end columns of an interpolated column as a float. |
void |
setInterpolatedDefault(java.lang.String field,
int val)
Set default values for the current, start, and end columns of an interpolated column as an int. |
void |
setInterpolatedDefault(java.lang.String field,
long val)
Set default values for the current, start, and end columns of an interpolated column as a long. |
void |
setInterpolatedDefault(java.lang.String field,
java.lang.Object val)
Set default values for the current, start, and end columns of an interpolated column. |
java.lang.String |
toString()
Returns a descriptive String for this schema. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Schema()
public Schema(int ncols)
ncols
- the number of columns in this schemapublic Schema(java.lang.String[] names, java.lang.Class[] types)
names
- the column namestypes
- the column types (as Class instances)public Schema(java.lang.String[] names, java.lang.Class[] types, java.lang.Object[] defaults)
names
- the column namestypes
- the column types (as Class instances)defaults
- the default values for each columnMethod Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
Object.clone()
protected void initLookup()
public Schema lockSchema()
public boolean isLocked()
public void addColumn(java.lang.String name, java.lang.Class type)
name
- the column nametype
- the column type (as a Class instance)
java.lang.IllegalArgumentException
- is either name or type are null or
the name already exists in this schema.public void addColumn(java.lang.String name, java.lang.Class type, java.lang.Object defaultValue)
name
- the column nametype
- the column type (as a Class instance)
java.lang.IllegalArgumentException
- is either name or type are null or
the name already exists in this schema.public void addInterpolatedColumn(java.lang.String name, java.lang.Class type, java.lang.Object dflt)
Add a new interpolated column to this data schema. This actually adds three columns to the schema: a column for the current value of the field, and columns for starting and ending values. During animation or operations spread over a time span, the current value can be interpolated between the start and end values.
The name for the current value column is the name parameter provided
to the method. The name for the start and end columns will be determined
by the return value of PrefuseLib.getStartField(String)
and
PrefuseLib.getEndField(String)
. The default behavior for these
methods is to append ":start" to the name of a stating value column
and append ":end" to the the name of an ending value column.
name
- the name of the interpolated column to addtype
- the data type the columns will containdflt
- the default value for each of the columnspublic void addInterpolatedColumn(java.lang.String name, java.lang.Class type)
name
- the name of the interpolated column to addtype
- the data type the columns will containaddInterpolatedColumn(String, Class, Object)
public int getColumnCount()
public java.lang.String getColumnName(int col)
col
- the column index
public int getColumnIndex(java.lang.String field)
field
- the column name
public java.lang.Class getColumnType(int col)
col
- the column index
public java.lang.Class getColumnType(java.lang.String field)
field
- the column name
public java.lang.Object getDefault(int col)
col
- the column index
public java.lang.Object getDefault(java.lang.String field)
field
- the column name
public void setDefault(int col, java.lang.Object val)
col
- the column index of the field to set the default forval
- the new default valuepublic void setDefault(java.lang.String field, java.lang.Object val)
field
- the name of column to set the default forval
- the new default valuepublic void setDefault(java.lang.String field, int val)
field
- the name of column to set the default forval
- the new default valuepublic void setDefault(java.lang.String field, long val)
field
- the name of column to set the default forval
- the new default valuepublic void setDefault(java.lang.String field, float val)
field
- the name of column to set the default forval
- the new default valuepublic void setDefault(java.lang.String field, double val)
field
- the name of column to set the default forval
- the new default valuepublic void setDefault(java.lang.String field, boolean val)
field
- the name of column to set the default forval
- the new default valuepublic void setInterpolatedDefault(java.lang.String field, java.lang.Object val)
field
- the field name of the interpolated columnval
- the new default value for all three implicated columnspublic void setInterpolatedDefault(java.lang.String field, int val)
field
- the field name of the interpolated columnval
- the new default value for all three implicated columnspublic void setInterpolatedDefault(java.lang.String field, long val)
field
- the field name of the interpolated columnval
- the new default value for all three implicated columnspublic void setInterpolatedDefault(java.lang.String field, float val)
field
- the field name of the interpolated columnval
- the new default value for all three implicated columnspublic void setInterpolatedDefault(java.lang.String field, double val)
field
- the field name of the interpolated columnval
- the new default value for all three implicated columnspublic void setInterpolatedDefault(java.lang.String field, boolean val)
field
- the field name of the interpolated columnval
- the new default value for all three implicated columnspublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean isAssignableFrom(Schema s)
s
- the input Schema
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public Table instantiate()
public Table instantiate(int nrows)
nrows
- the number of starting rows in the table
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |