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 java.lang.Object

Information about indices of a table.

Version:
$Id: Index.java 473814 2006-11-11 22:30:30Z tv $
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, java.util.List indexColumns)
          Creates a new instance for the list of columns composing an index.
 
Method Summary
 void addColumn(org.xml.sax.Attributes attrib)
          Adds a new column to an index.
 void addOption(java.lang.String key, java.lang.String value)
          Add an XML Specified option key/value pair to this element's option set.
 java.lang.String getColumnList()
          Return a comma delimited string of the columns which compose this index.
protected  java.util.List getColumnNames()
          Returns the list of names of the columns referenced by this index.
 java.util.List getColumns()
          Return the list of local columns.
 java.lang.String getName()
          Gets the name of this index.
 java.lang.String getOption(java.lang.String key)
          Get the value that was associated with this key in an XML option element.
 java.util.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
 java.lang.String getTableName()
          Returns the Name of the table the index is in
 boolean isUnique()
          Returns the uniqueness of this index.
 void loadFromXML(org.xml.sax.Attributes attrib)
          Imports index from an XML specification
 void setName(java.lang.String name)
          Set the name of this index.
 void setTable(Table parent)
          Set the parent Table of the index
 java.lang.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,
                java.util.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(org.xml.sax.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 java.lang.String getName()
Gets the name of this index.

Returns:
the name of this index

setName

public void setName(java.lang.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 java.lang.String getTableName()
Returns the Name of the table the index is in

Returns:
the name of the table

addColumn

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

Parameters:
attrib - xml attributes for the column

getColumnList

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

Returns:
a list of column names

getColumns

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

Returns:
a list of columns

getColumnNames

protected java.util.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 java.lang.String toString()
String representation of the index. This is an xml representation.

Overrides:
toString in class java.lang.Object
Returns:
a xml representation

addOption

public void addOption(java.lang.String key,
                      java.lang.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 java.lang.String getOption(java.lang.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 java.util.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 © 2000-2012 Apache Software Foundation. All Rights Reserved.