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