Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.common.sql.schema.DatabaseColumn Class Reference

List of all members.

Public Member Functions

 DatabaseColumn (String name, boolean isUnique)
 DatabaseColumn (String name, boolean isUnique, int type)
String getName ()
boolean isUnique ()
void setIsUnique (boolean bool)
int getType ()
boolean equals (Object other)
boolean equalsIgnoreType (Object other)
String getXml ()

Detailed Description

A DatabaseColumn represents a column of a database table. It is composed of a name, type (not used yet) and a boolean indicated whether or not rows are unique or not (like primary keys or columns created explicitely with the UNIQUE keyword).

Author:
Emmanuel Cecchet

Julie Marguerite

Version:
1.0

Definition at line 42 of file DatabaseColumn.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.DatabaseColumn String  name,
boolean  isUnique
 

Creates a new DatabaseColumn instance.

Parameters:
name name of the column
isUnique true if this column has a UNIQUE constraint

Definition at line 63 of file DatabaseColumn.java.

00064   {
00065     this(name, isUnique, Types.NULL);
00066   }

org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.DatabaseColumn String  name,
boolean  isUnique,
int  type
 

Creates a new DatabaseColumn instance.

Parameters:
name name of the column
isUnique true if this column has a UNIQUE constraint
type type of the column (VARCHAR,TEXT, ...)

Definition at line 77 of file DatabaseColumn.java.

00078   {
00079     if (name == null)
00080       throw new IllegalArgumentException("Illegal null column name in DatabaseColumn constructor");
00081 
00082     this.name = name;
00083     this.isUnique = isUnique;
00084     this.type = type;
00085   }


Member Function Documentation

boolean org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.equals Object  other  ) 
 

Two DatabaseColumn are considered equal if they have the same name and type and if they are both unique or both non unique.

Parameters:
other the object to compare with
Returns:
true if the columns are equal

Definition at line 139 of file DatabaseColumn.java.

References org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.getName(), org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.getType(), and org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.isUnique.

00140   {
00141     if ((other == null) || !(other instanceof DatabaseColumn))
00142       return false;
00143 
00144     DatabaseColumn c = (DatabaseColumn) other;
00145     return (isUnique == c.isUnique())
00146       && name.equals(c.getName())
00147       && (type == c.getType());
00148   }

boolean org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.equalsIgnoreType Object  other  ) 
 

This function is the same as equal but ignores the column type.

Parameters:
other the object to compare with
Returns:
true if the columns are equal ignoring their type.
See also:
equals(Object)

Definition at line 157 of file DatabaseColumn.java.

References org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.getName(), and org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.isUnique.

Referenced by org.objectweb.cjdbc.common.sql.schema.DatabaseTable.equalsIgnoreType(), and org.objectweb.cjdbc.common.sql.schema.DatabaseTable.mergeColumns().

00158   {
00159     if ((other == null) || !(other instanceof DatabaseColumn))
00160       return false;
00161 
00162     DatabaseColumn c = (DatabaseColumn) other;
00163     return (isUnique == c.isUnique()) && name.equals(c.getName());
00164   }

String org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.getName  ) 
 

Gets the column name.

Returns:
a String value.

Definition at line 92 of file DatabaseColumn.java.

Referenced by org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.equals(), org.objectweb.cjdbc.common.sql.schema.DatabaseTable.equalsIgnoreType(), org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.equalsIgnoreType(), org.objectweb.cjdbc.common.sql.schema.DatabaseTable.getColumn(), org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseDynamicMetaData.getColumns(), org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseDynamicMetaData.getPrimaryKeys(), org.objectweb.cjdbc.common.sql.schema.DatabaseTable.mergeColumns(), org.objectweb.cjdbc.common.sql.UpdateRequest.parse(), and org.objectweb.cjdbc.common.sql.InsertRequest.parse().

00093   {
00094     return name;
00095   }

int org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.getType  ) 
 

Returns the column type according to java.sql.Types.

Returns:
the column type. Returns Types.NULL if the type is not set.
See also:
java.sql.Types

Definition at line 127 of file DatabaseColumn.java.

Referenced by org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.equals(), org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseDynamicMetaData.getColumns(), and org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseDynamicMetaData.getPrimaryKeys().

00128   {
00129     return type;
00130   }

String org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.getXml  ) 
 

Get xml information about this column.

Returns:
xml formatted information on this database column.

Definition at line 171 of file DatabaseColumn.java.

00172   {
00173     StringBuffer info = new StringBuffer();
00174     info.append(
00175       "<"
00176         + DatabasesXmlTags.ELT_DatabaseColumn
00177         + " "
00178         + DatabasesXmlTags.ATT_columnName
00179         + "=\""
00180         + name
00181         + "\" "
00182         + DatabasesXmlTags.ATT_isUnique
00183         + "=\""
00184         + isUnique
00185         + "\">");
00186     info.append("</" + DatabasesXmlTags.ELT_DatabaseColumn + ">");
00187     return info.toString();
00188   }

boolean org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.isUnique  ) 
 

Tests if the column has a UNIQUE constraint (like primary keys for example).

Returns:
true if the column has a UNIQUE constraint

Definition at line 104 of file DatabaseColumn.java.

00105   {
00106     return isUnique;
00107   }

void org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.setIsUnique boolean  bool  ) 
 

Sets the value of isUnique.

Parameters:
bool true if the column has a UNIQUE constraint (like primary keys for example).

Definition at line 115 of file DatabaseColumn.java.

Referenced by org.objectweb.cjdbc.common.sql.CreateRequest.parse().

00116   {
00117     isUnique = bool;
00118   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:02:13 2005 for C-JDBC by  doxygen 1.3.9.1