org.apache.torque.engine.database.model
Class Index

java.lang.Object
  extended by org.apache.torque.engine.database.model.Index
Direct Known Subclasses:
Unique

public class Index
extends Object

Information about indices of a table.

Version:
$Id: Index.java,v 1.1 2007-10-21 07:57:27 abyrne Exp $
Author:
Jason van Zyl, Greg Monroe

Constructor Summary
  Index()
          Creates a new instance with default characteristics (no name or parent table, small column list size allocation, non-unique).
protected Index(Table table, List indexColumns)
          Creates a new instance for the list of columns composing an index.
 
Method Summary
 void addColumn(Attributes attrib)
          Adds a new column to an index.
 void addOption(String key, String value)
          Add an XML Specified option key/value pair to this element's option set.
 String getColumnList()
          Return a comma delimited string of the columns which compose this index.
protected  List getColumnNames()
          Returns the list of names of the columns referenced by this index.
 List getColumns()
          Return the list of local columns.
 String getName()
          Gets the name of this index.
 String getOption(String key)
          Get the value that was associated with this key in an XML option element.
 Map getOptions()
          Gets the full ordered hashtable array of items specified by XML option statements under this element.
 Table getTable()
          Get the parent Table of the index
 String getTableName()
          Returns the Name of the table the index is in
 boolean isUnique()
          Returns the uniqueness of this index.
 void loadFromXML(Attributes attrib)
          Imports index from an XML specification
 void setName(String name)
          Set the name of this index.
 void setTable(Table parent)
          Set the parent Table of the index
 String toString()
          String representation of the index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Index

public Index()
Creates a new instance with default characteristics (no name or parent table, small column list size allocation, non-unique).


Index

protected Index(Table table,
                List indexColumns)
         throws EngineException
Creates a new instance for the list of columns composing an index. Otherwise performs as Index().

Parameters:
table - The table this index is associated with.
indexColumns - The list of Column objects which make up this index. Cannot be empty.
Throws:
EngineException - Error generating name.
See Also:
Index()
Method Detail

loadFromXML

public void loadFromXML(Attributes attrib)
Imports index from an XML specification

Parameters:
attrib - the xml attributes

isUnique

public boolean isUnique()
Returns the uniqueness of this index.

Returns:
the uniqueness of this index

getName

public String getName()
Gets the name of this index.

Returns:
the name of this index

setName

public void setName(String name)
Set the name of this index.

Parameters:
name - the name of this index

setTable

public void setTable(Table parent)
Set the parent Table of the index

Parameters:
parent - the table

getTable

public Table getTable()
Get the parent Table of the index

Returns:
the table

getTableName

public String getTableName()
Returns the Name of the table the index is in

Returns:
the name of the table

addColumn

public void addColumn(Attributes attrib)
Adds a new column to an index.

Parameters:
attrib - xml attributes for the column

getColumnList

public String getColumnList()
Return a comma delimited string of the columns which compose this index.

Returns:
a list of column names

getColumns

public List getColumns()
Return the list of local columns. You should not edit this list.

Returns:
a list of columns

getColumnNames

protected List getColumnNames()
Returns the list of names of the columns referenced by this index. Slightly over-allocates the list's buffer (just in case more elements are going to be added, such as when a name is being generated). Feel free to modify this list.

Returns:
a list of column names

toString

public String toString()
String representation of the index. This is an xml representation.

Overrides:
toString in class Object
Returns:
a xml representation

addOption

public void addOption(String key,
                      String value)
Add an XML Specified option key/value pair to this element's option set.

Parameters:
key - the key of the option.
value - the value of the option.

getOption

public String getOption(String key)
Get the value that was associated with this key in an XML option element.

Parameters:
key - the key of the option.
Returns:
The value for the key or a null.

getOptions

public Map getOptions()
Gets the full ordered hashtable array of items specified by XML option statements under this element.

Note, this is not thread save but since it's only used for generation which is single threaded, there should be minimum danger using this in Velocity.

Returns:
An Map of all options. Will not be null but may be empty.


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.