Package com.healthmarketscience.jackcess
Class IndexBuilder
- java.lang.Object
-
- com.healthmarketscience.jackcess.IndexBuilder
-
public class IndexBuilder extends Object
Builder style class for constructing anIndex. SeeTableBuilderfor example usage. Additionally, an Index can be added to an existing Table using theaddToTable(Table)method.- Author:
- James Ahlborn
- See Also:
TableBuilder- Usage:
- General: This class is general use.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIndexBuilder.ColumnInformation about a column in this index (name and ordering).
-
Field Summary
Fields Modifier and Type Field Description static StringPRIMARY_KEY_NAMEname typically used by MS Access for the primary key index
-
Constructor Summary
Constructors Constructor Description IndexBuilder(String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexBuilderaddColumns(boolean ascending, String... names)Adds the columns with the given ordering to the index.IndexBuilderaddColumns(String... names)Adds the columns with ASCENDING ordering to the index.IndexaddToTable(Table table)Adds a new Index to the given Table with the currently configured attributes.IndexaddToTableDefinition(TableDefinition table)Adds a new Index to the given TableDefinition with the currently configured attributes.List<IndexBuilder.Column>getColumns()bytegetFlags()intgetIndexNumber()StringgetName()bytegetType()booleanisIgnoreNulls()booleanisPrimaryKey()booleanisUnique()IndexBuildersetIgnoreNulls()Sets this index to ignore null values.voidsetIndexNumber(int newIndexNumber)IndexBuildersetName(String name)Sets the name of the index.IndexBuildersetPrimaryKey()Sets this index to be a primary key index (additionally sets the index as unique and required).IndexBuildersetRequired()Sets this index to enforce required.IndexBuildersetType(byte type)IndexBuildersetUnique()Sets this index to enforce uniqueness.StringtoString()voidvalidate(Set<String> tableColNames, JetFormat format)Checks that this index definition is valid.
-
-
-
Field Detail
-
PRIMARY_KEY_NAME
public static final String PRIMARY_KEY_NAME
name typically used by MS Access for the primary key index- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IndexBuilder
public IndexBuilder(String name)
-
-
Method Detail
-
getName
public String getName()
-
getType
public byte getType()
-
getFlags
public byte getFlags()
-
isPrimaryKey
public boolean isPrimaryKey()
-
isUnique
public boolean isUnique()
-
isIgnoreNulls
public boolean isIgnoreNulls()
-
getColumns
public List<IndexBuilder.Column> getColumns()
-
setName
public IndexBuilder setName(String name)
Sets the name of the index.
-
addColumns
public IndexBuilder addColumns(String... names)
Adds the columns with ASCENDING ordering to the index.
-
addColumns
public IndexBuilder addColumns(boolean ascending, String... names)
Adds the columns with the given ordering to the index.
-
setPrimaryKey
public IndexBuilder setPrimaryKey()
Sets this index to be a primary key index (additionally sets the index as unique and required).
-
setType
public IndexBuilder setType(byte type)
- Usage:
- Advanced: This method is for advanced/internal use.
-
setUnique
public IndexBuilder setUnique()
Sets this index to enforce uniqueness.
-
setRequired
public IndexBuilder setRequired()
Sets this index to enforce required.
-
setIgnoreNulls
public IndexBuilder setIgnoreNulls()
Sets this index to ignore null values.
-
getIndexNumber
public int getIndexNumber()
- Usage:
- Advanced: This method is for advanced/internal use.
-
setIndexNumber
public void setIndexNumber(int newIndexNumber)
- Usage:
- Advanced: This method is for advanced/internal use.
-
validate
public void validate(Set<String> tableColNames, JetFormat format)
Checks that this index definition is valid.- Throws:
IllegalArgumentException- if this index definition is invalid.- Usage:
- Advanced: This method is for advanced/internal use.
-
addToTable
public Index addToTable(Table table) throws IOException
Adds a new Index to the given Table with the currently configured attributes.- Throws:
IOException
-
addToTableDefinition
public Index addToTableDefinition(TableDefinition table) throws IOException
Adds a new Index to the given TableDefinition with the currently configured attributes.- Throws:
IOException
-
-