simpledb.record
Class Schema

java.lang.Object
  extended by simpledb.record.Schema

public class Schema
extends Object

The record schema of a table. A schema contains the name and type of each field of the table, as well as the length of each varchar field.

Author:
Edward Sciore

Constructor Summary
Schema()
          Creates an empty schema.
 
Method Summary
 void add(String fldname, Schema sch)
          Adds a field to the schema having the same type and length as the corresponding field in another schema.
 void addAll(Schema sch)
          Adds all of the fields in the specified schema to the current schema.
 void addField(String fldname, int type, int length)
          Adds a field to the schema having a specified name, type, and length.
 void addIntField(String fldname)
          Adds an integer field to the schema.
 void addStringField(String fldname, int length)
          Adds a string field to the schema.
 Collection<String> fields()
          Returns a collection containing the name of each field in the schema.
 boolean hasField(String fldname)
          Returns true if the specified field is in the schema
 int length(String fldname)
          Returns the conceptual length of the specified field.
 int type(String fldname)
          Returns the type of the specified field, using the constants in Types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Schema

public Schema()
Creates an empty schema. Field information can be added to a schema via the five addXXX methods.

Method Detail

addField

public void addField(String fldname,
                     int type,
                     int length)
Adds a field to the schema having a specified name, type, and length. If the field type is "integer", then the length value is irrelevant.

Parameters:
fldname - the name of the field
type - the type of the field, according to the constants in simpledb.sql.types
length - the conceptual length of a string field.

addIntField

public void addIntField(String fldname)
Adds an integer field to the schema.

Parameters:
fldname - the name of the field

addStringField

public void addStringField(String fldname,
                           int length)
Adds a string field to the schema. The length is the conceptual length of the field. For example, if the field is defined as varchar(8), then its length is 8.

Parameters:
fldname - the name of the field
length - the number of chars in the varchar definition

add

public void add(String fldname,
                Schema sch)
Adds a field to the schema having the same type and length as the corresponding field in another schema.

Parameters:
fldname - the name of the field
sch - the other schema

addAll

public void addAll(Schema sch)
Adds all of the fields in the specified schema to the current schema.

Parameters:
sch - the other schema

fields

public Collection<String> fields()
Returns a collection containing the name of each field in the schema.

Returns:
the collection of the schema's field names

hasField

public boolean hasField(String fldname)
Returns true if the specified field is in the schema

Parameters:
fldname - the name of the field
Returns:
true if the field is in the schema

type

public int type(String fldname)
Returns the type of the specified field, using the constants in Types.

Parameters:
fldname - the name of the field
Returns:
the integer type of the field

length

public int length(String fldname)
Returns the conceptual length of the specified field. If the field is not a string field, then the return value is undefined.

Parameters:
fldname - the name of the field
Returns:
the conceptual length of the field


Copyright © 2011. All Rights Reserved.