001 package com.sptci.rwt;
002
003 /**
004 * A metadata object that represents table indices.
005 *
006 * <p>© Copyright 2007 <a href='http://sptci.com/' target='_new'>Sans Pareil Technologies, Inc.</a></p>
007 * @author Rakesh Vidyadharan 2007-09-26
008 * @version $Id: IndexMetaData.java 4123 2008-05-25 21:49:01Z rakesh $
009 */
010 public class IndexMetaData extends KeyMetaData
011 {
012 /**
013 * An enumeration for the index types.
014 */
015 public enum Type { Statistic, Clustered, Hashed, Other };
016
017 /**
018 * An enumerationg for the sort sequence of indices.
019 */
020 public enum SortSequence { Ascending, Descending, Unsorted };
021
022 /**
023 * A flag indicating whether this index represents unique values or not.
024 */
025 private boolean unique;
026
027 /**
028 * A field indicating the type of the index.
029 */
030 private Type type;
031
032 /**
033 * A field indicating the sort order used by the index.
034 */
035 private SortSequence sortSequence;
036
037 /**
038 * The cardinality for the index. When {@link #type} is {@link
039 * Type#Statistic}, then this is the number of rows in the table;
040 * otherwise, it is the number of unique values in the index.
041 */
042 private int cardinality;
043
044 /**
045 * The number of pages used for the index. When {@link #type} is {@link
046 * Type#Statistic}, then this is the number of pages used for the table;
047 * otherwise, it is the number of pages used for the index.
048 */
049 private int pages;
050
051 /**
052 * Returns {@link #unique}.
053 *
054 * @return The value/reference of/to unique.
055 */
056 public boolean isUnique()
057 {
058 return unique;
059 }
060
061 /**
062 * Returns {@link #unique}.
063 *
064 * @return The value/reference of/to unique.
065 */
066 public boolean getUnique()
067 {
068 return isUnique();
069 }
070
071 /**
072 * Set {@link #unique}.
073 *
074 * @param unique The value to set.
075 */
076 protected void setUnique( final boolean unique )
077 {
078 this.unique = unique;
079 }
080
081 /**
082 * Returns {@link #type}.
083 *
084 * @return The value/reference of/to type.
085 */
086 public String getType()
087 {
088 return type.toString();
089 }
090
091 /**
092 * Set {@link #type}.
093 *
094 * @param type The value to set.
095 */
096 protected void setType( final Type type )
097 {
098 this.type = type;
099 }
100
101 /**
102 * Returns {@link #sortSequence}.
103 *
104 * @return The value/reference of/to sortSequence.
105 */
106 public String getSortSequence()
107 {
108 return sortSequence.toString();
109 }
110
111 /**
112 * Set {@link #sortSequence}.
113 *
114 * @param sortSequence The value to set.
115 */
116 protected void setSortSequence( final SortSequence sortSequence )
117 {
118 this.sortSequence = sortSequence;
119 }
120
121 /**
122 * Returns {@link #cardinality}.
123 *
124 * @return The value/reference of/to cardinality.
125 */
126 public int getCardinality()
127 {
128 return cardinality;
129 }
130
131 /**
132 * Set {@link #cardinality}.
133 *
134 * @param cardinality The value to set.
135 */
136 protected void setCardinality( final int cardinality )
137 {
138 this.cardinality = cardinality;
139 }
140
141 /**
142 * Returns {@link #pages}.
143 *
144 * @return The value/reference of/to pages.
145 */
146 public int getPages()
147 {
148 return pages;
149 }
150
151 /**
152 * Set {@link #pages}.
153 *
154 * @param pages The value to set.
155 */
156 protected void setPages( final int pages )
157 {
158 this.pages = pages;
159 }
160 }