View Javadoc
1   /*
2   Copyright (c) 2013 James Ahlborn
3   
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7   
8       http://www.apache.org/licenses/LICENSE-2.0
9   
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16  
17  package com.healthmarketscience.jackcess;
18  
19  import java.io.IOException;
20  import java.util.List;
21  
22  /**
23   * Access database index definition.  A {@link Table} has a list of Index
24   * instances.  Indexes can enable fast searches and ordered traversal on a
25   * Table (for the indexed columns).  These features can be utilized via an
26   * {@link IndexCursor}.
27   *
28   * @author James Ahlborn
29   * @usage _general_class_
30   */
31  public interface Index 
32  {
33  
34    public Table getTable();
35  
36    public String getName();
37  
38    public boolean isPrimaryKey();
39  
40    public boolean isForeignKey();
41  
42    /**
43     * @usage _general_method_
44     */
45    public int getColumnCount();
46  
47    /**
48     * @return the Columns for this index (unmodifiable)
49     */
50    public List<? extends Index.Column> getColumns();
51  
52    /**
53     * @return the Index referenced by this Index's ForeignKeyReference (if it
54     *         has one), otherwise {@code null}.
55     */
56    public Index getReferencedIndex() throws IOException;
57  
58    /**
59     * Whether or not {@code null} values are actually recorded in the index.
60     */
61    public boolean shouldIgnoreNulls();
62  
63    /**
64     * Whether or not index entries must be unique.
65     * <p>
66     * Some notes about uniqueness:
67     * <ul>
68     * <li>Access does not seem to consider multiple {@code null} entries
69     *     invalid for a unique index</li>
70     * <li>text indexes collapse case, and Access seems to compare <b>only</b>
71     *     the index entry bytes, therefore two strings which differ only in
72     *     case <i>will violate</i> the unique constraint</li>
73     * </ul>
74     */
75    public boolean isUnique();
76  
77    /**
78     * Whether or not values are required for index columns.
79     */
80    public boolean isRequired();
81  
82    /**
83     * Convenience method for constructing a new CursorBuilder for this Index.
84     */
85    public CursorBuilder newCursor();
86  
87    /**
88     * Information about a Column in an Index
89     */
90    public interface Column {
91  
92      public com.healthmarketscience.jackcess.Column getColumn();
93  
94      public boolean isAscending();
95  
96      public int getColumnIndex();
97      
98      public String getName();
99    }
100 }