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.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     * @usage _general_method_
85     */
86    public DataType getType();
87  
88    /**
89     * @usage _general_method_
90     */
91    public int getSQLType() throws IOException;
92  
93    /**
94     * @usage _general_method_
95     */
96    public boolean isCompressedUnicode();
97  
98    /**
99     * @usage _general_method_
100    */
101   public byte getPrecision();
102 
103   /**
104    * @usage _general_method_
105    */
106   public byte getScale();
107 
108   /**
109    * @usage _general_method_
110    */
111   public short getLength();
112 
113   /**
114    * @usage _general_method_
115    */
116   public short getLengthInUnits();
117 
118   /**
119    * Whether or not this column is "append only" (its history is tracked by a
120    * separate version history column).
121    * @usage _general_method_
122    */
123   public boolean isAppendOnly();
124 
125   /**
126    * Returns whether or not this is a hyperlink column (only possible for
127    * columns of type MEMO).
128    * @usage _general_method_
129    */
130   public boolean isHyperlink();
131 
132   /**
133    * Returns whether or not this is a calculated column.  Note that jackess
134    * <b>won't interpret the calculation expression</b> (but the field can be
135    * written directly).
136    * @usage _general_method_
137    */
138   public boolean isCalculated();
139 
140   /**
141    * Returns extended functionality for "complex" columns.
142    * @usage _general_method_
143    */
144   public ComplexColumnInfo<? extends ComplexValue> getComplexInfo();
145 
146   /**
147    * @return the properties for this column
148    * @usage _general_method_
149    */
150   public PropertyMap getProperties() throws IOException;
151 
152   /**
153    * Returns the column which tracks the version history for an "append only"
154    * column.
155    * @usage _intermediate_method_
156    */
157   public Column getVersionHistoryColumn();
158 
159   /**
160    * Gets currently configured ColumnValidator (always non-{@code null}).
161    * @usage _intermediate_method_
162    */
163   public ColumnValidator getColumnValidator();
164 
165   /**
166    * Sets a new ColumnValidator.  If {@code null}, resets to the value
167    * returned from the Database's ColumnValidatorFactory (if the factory
168    * returns {@code null}, then the default is used).  Autonumber columns
169    * cannot have a validator instance other than the default.
170    * @throws IllegalArgumentException if an attempt is made to set a
171    *         non-{@code null} ColumnValidator instance on an autonumber column
172    * @usage _intermediate_method_
173    */
174   public void setColumnValidator(ColumnValidator newValidator);
175 
176   public Object setRowValue(Object[] rowArray, Object value);
177 
178   public Object setRowValue(Map<String,Object> rowMap, Object value);
179 
180   public Object getRowValue(Object[] rowArray);
181 
182   public Object getRowValue(Map<String,?> rowMap);
183 }