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.Map;
21
22 import com.healthmarketscience.jackcess.complex.ComplexColumnInfo;
23 import com.healthmarketscience.jackcess.complex.ComplexValue;
24 import com.healthmarketscience.jackcess.util.ColumnValidator;
25
26 /**
27 * Access database column definition. A {@link Table} has a list of Column
28 * instances describing the table schema.
29 * <p>
30 * A Column instance is not thread-safe (see {@link Database} for more
31 * thread-safety details).
32 *
33 * @author James Ahlborn
34 * @usage _general_class_
35 */
36 public interface Column
37 {
38 /**
39 * Meaningless placeholder object for inserting values in an autonumber
40 * column. it is not required that this value be used (any passed in value
41 * is ignored), but using this placeholder may make code more obvious.
42 * @usage _general_field_
43 */
44 public static final Object AUTO_NUMBER = "<AUTO_NUMBER>";
45
46 /**
47 * Meaningless placeholder object for updating rows which indicates that a
48 * given column should keep its existing value.
49 * @usage _general_field_
50 */
51 public static final Object KEEP_VALUE = "<KEEP_VALUE>";
52
53 /**
54 * @usage _general_method_
55 */
56 public Table getTable();
57
58 /**
59 * @usage _general_method_
60 */
61 public Database getDatabase();
62
63 /**
64 * @usage _general_method_
65 */
66 public String getName();
67
68 /**
69 * @usage _advanced_method_
70 */
71 public boolean isVariableLength();
72
73 /**
74 * @usage _general_method_
75 */
76 public boolean isAutoNumber();
77
78 /**
79 * @usage _advanced_method_
80 */
81 public int getColumnIndex();
82
83 /**
84 * Returns the id which ms access gave this column when it was created. An
85 * id is never renumbered, so a table which has had a column deleted has gaps
86 * in its ids and the id of a column differs from its index.
87 * @usage _advanced_method_
88 */
89 public short getColumnId();
90
91 /**
92 * @usage _general_method_
93 */
94 public DataType getType();
95
96 /**
97 * @usage _general_method_
98 */
99 public int getSQLType() throws IOException;
100
101 /**
102 * @usage _general_method_
103 */
104 public boolean isCompressedUnicode();
105
106 /**
107 * @usage _general_method_
108 */
109 public byte getPrecision();
110
111 /**
112 * @usage _general_method_
113 */
114 public byte getScale();
115
116 /**
117 * @usage _general_method_
118 */
119 public short getLength();
120
121 /**
122 * @usage _general_method_
123 */
124 public short getLengthInUnits();
125
126 /**
127 * Whether or not this column is "append only" (its history is tracked by a
128 * separate version history column).
129 * @usage _general_method_
130 */
131 public boolean isAppendOnly();
132
133 /**
134 * Returns whether or not this is a hyperlink column (only possible for
135 * columns of type MEMO).
136 * @usage _general_method_
137 */
138 public boolean isHyperlink();
139
140 /**
141 * Returns whether or not this is a calculated column. Note that jackess
142 * <b>won't interpret the calculation expression</b> (but the field can be
143 * written directly).
144 * @usage _general_method_
145 */
146 public boolean isCalculated();
147
148 /**
149 * Returns whether or not ms access maintains this column and hides it. The
150 * columns of the system catalog tables, {@code MSysComplexColumns} included,
151 * and the replication columns do.
152 * @usage _general_method_
153 */
154 public boolean isHidden();
155
156 /**
157 * Returns whether or not this column holds a windows security identifier.
158 * Only {@code MSysObjects.Owner} and {@code MSysACEs.SID} do.
159 * @usage _advanced_method_
160 */
161 public boolean isSecurityIdentifier();
162
163 /**
164 * Returns extended functionality for "complex" columns.
165 * @usage _general_method_
166 */
167 public ComplexColumnInfo<? extends ComplexValue> getComplexInfo();
168
169 /**
170 * @return the properties for this column
171 * @usage _general_method_
172 */
173 public PropertyMap getProperties() throws IOException;
174
175 /**
176 * Returns the column which tracks the version history for an "append only"
177 * column.
178 * @usage _intermediate_method_
179 */
180 public Column getVersionHistoryColumn();
181
182 /**
183 * Gets currently configured ColumnValidator (always non-{@code null}).
184 * @usage _intermediate_method_
185 */
186 public ColumnValidator getColumnValidator();
187
188 /**
189 * Sets a new ColumnValidator. If {@code null}, resets to the value
190 * returned from the Database's ColumnValidatorFactory (if the factory
191 * returns {@code null}, then the default is used). Autonumber columns
192 * cannot have a validator instance other than the default.
193 * @throws IllegalArgumentException if an attempt is made to set a
194 * non-{@code null} ColumnValidator instance on an autonumber column
195 * @usage _intermediate_method_
196 */
197 public void setColumnValidator(ColumnValidator newValidator);
198
199 public Object setRowValue(Object[] rowArray, Object value);
200
201 public Object setRowValue(Map<String,Object> rowMap, Object value);
202
203 public Object getRowValue(Object[] rowArray);
204
205 public Object getRowValue(Map<String,?> rowMap);
206 }