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.stream.Stream;
21  import java.util.stream.StreamSupport;
22  
23  /**
24   * Map of properties for a database object.
25   *
26   * @author James Ahlborn
27   * @usage _general_class_
28   */
29  public interface PropertyMap extends Iterable<PropertyMap.Property>
30  {
31    ////
32    // database and summary properties
33    public static final String ACCESS_VERSION_PROP = "AccessVersion";
34    public static final String BUILD_PROP = "Build";
35    public static final String PROJ_VER_PROP = "ProjVer";
36    public static final String HAS_OFFLINE_LISTS_PROP = "HasOfflineLists";
37    public static final String ANSI_QUERY_MODE_PROP = "ANSI Query Mode";
38    public static final String AUTO_COMPACT_PROP = "Auto Compact";
39    public static final String TRACK_NAME_AUTO_CORRECT_PROP =
40      "Track Name AutoCorrect Info";
41    public static final String PERFORM_NAME_AUTO_CORRECT_PROP =
42      "Perform Name AutoCorrect";
43    public static final String CHECK_TRUNCATED_NUM_FIELDS_PROP =
44      "CheckTruncatedNumFields";
45    public static final String PICTURE_STORAGE_FORMAT_PROP =
46      "Picture Property Storage Format";
47    public static final String THEME_RESOURCE_NAME_PROP = "Theme Resource Name";
48    public static final String THEMED_FORM_CONTROLS_PROP = "Themed Form Controls";
49    public static final String SHOW_DOCUMENT_TABS_PROP = "ShowDocumentTabs";
50    public static final String USE_MDI_MODE_PROP = "UseMDIMode";
51    public static final String WEB_DESIGN_MODE_PROP = "WebDesignMode";
52    public static final String DESIGN_WITH_DATA_PROP = "DesignWithData";
53    public static final String ALLOW_BUILT_IN_TOOLBARS_PROP =
54      "AllowBuiltInToolbars";
55    public static final String ALLOW_DATASHEET_SCHEMA_PROP =
56      "AllowDatasheetSchema";
57    public static final String ALLOW_FULL_MENUS_PROP = "AllowFullMenus";
58    public static final String ALLOW_SHORTCUT_MENUS_PROP = "AllowShortcutMenus";
59    public static final String ALLOW_SPECIAL_KEYS_PROP = "AllowSpecialKeys";
60    public static final String ALLOW_TOOLBAR_CHANGES_PROP = "AllowToolbarChanges";
61    public static final String START_UP_SHOW_DB_WINDOW_PROP =
62      "StartUpShowDBWindow";
63    public static final String START_UP_SHOW_STATUS_BAR_PROP =
64      "StartUpShowStatusBar";
65    public static final String USE_APP_ICON_FOR_FRM_RPT_PROP =
66      "UseAppIconForFrmRpt";
67    public static final String NAV_PANE_CATEGORY_PROP = "NavPane Category";
68    public static final String NAV_PANE_CLOSED_PROP = "NavPane Closed";
69    public static final String NAV_PANE_SORT_BY_PROP = "NavPane Sort By";
70    public static final String NAV_PANE_VIEW_BY_PROP = "NavPane View By";
71    public static final String NAV_PANE_WIDTH_PROP = "NavPane Width";
72    public static final String NAV_PANE_SEARCH_BAR_PROP =
73      "Show Navigation Pane Search Bar";
74    public static final String SHOW_VALUES_LIMIT_PROP = "Show Values Limit";
75    public static final String SHOW_VALUES_IN_INDEXED_PROP =
76      "Show Values in Indexed";
77    public static final String SHOW_VALUES_IN_NON_INDEXED_PROP =
78      "Show Values in Non-Indexed";
79    public static final String SHOW_VALUES_IN_REMOTE_PROP =
80      "Show Values in Remote";
81    public static final String REPLICATE_PROJECT_PROP = "ReplicateProject";
82    public static final String TITLE_PROP = "Title";
83    public static final String AUTHOR_PROP = "Author";
84    public static final String COMPANY_PROP = "Company";
85  
86    ////
87    // column properties
88    public static final String DEFAULT_VALUE_PROP = "DefaultValue";
89    public static final String REQUIRED_PROP = "Required";
90    public static final String ALLOW_ZERO_LEN_PROP = "AllowZeroLength";
91    public static final String DECIMAL_PLACES_PROP = "DecimalPlaces";
92    public static final String FORMAT_PROP = "Format";
93    public static final String INPUT_MASK_PROP = "InputMask";
94    public static final String CAPTION_PROP = "Caption";
95    public static final String VALIDATION_RULE_PROP = "ValidationRule";
96    public static final String VALIDATION_TEXT_PROP = "ValidationText";
97    public static final String GUID_PROP = "GUID";
98    public static final String DESCRIPTION_PROP = "Description";
99    public static final String RESULT_TYPE_PROP = "ResultType";
100   public static final String EXPRESSION_PROP = "Expression";
101   public static final String ALLOW_MULTI_VALUE_PROP = "AllowMultipleValues";
102   public static final String ROW_SOURCE_TYPE_PROP = "RowSourceType";
103   public static final String ROW_SOURCE_PROP = "RowSource";
104   public static final String BOUND_COLUMN_PROP = "BoundColumn";
105   public static final String COLUMN_COUNT_PROP = "ColumnCount";
106   public static final String COLUMN_WIDTHS_PROP = "ColumnWidths";
107   public static final String LIMIT_TO_LIST_PROP = "LimitToList";
108   public static final String DISPLAY_CONTROL_PROP = "DisplayControl";
109   public static final String TEXT_FORMAT_PROP = "TextFormat";
110   public static final String IME_MODE_PROP = "IMEMode";
111   public static final String IME_SENTENCE_MODE_PROP = "IMESentenceMode";
112   public static final String UNICODE_COMPRESSION_PROP = "UnicodeCompression";
113   public static final String APPEND_ONLY_PROP = "AppendOnly";
114   public static final String TEXT_ALIGN_PROP = "TextAlign";
115   public static final String AGGREGATE_TYPE_PROP = "AggregateType";
116   public static final String CURRENCY_LCID_PROP = "CurrencyLCID";
117   public static final String COLUMN_HIDDEN_PROP = "ColumnHidden";
118   public static final String COLUMN_ORDER_PROP = "ColumnOrder";
119   public static final String COLUMN_WIDTH_PROP = "ColumnWidth";
120 
121   ////
122   // table and query properties
123   public static final String NAME_MAP_PROP = "NameMap";
124   public static final String DEFAULT_VIEW_PROP = "DefaultView";
125   public static final String ORIENTATION_PROP = "Orientation";
126   public static final String ORDER_BY_ON_PROP = "OrderByOn";
127   public static final String ORDER_BY_ON_LOAD_PROP = "OrderByOnLoad";
128   public static final String FILTER_ON_LOAD_PROP = "FilterOnLoad";
129   public static final String TOTALS_ROW_PROP = "TotalsRow";
130   public static final String HIDE_NEW_FIELD_PROP = "HideNewField";
131   public static final String PUBLISH_TO_WEB_PROP = "PublishToWeb";
132   public static final String READ_ONLY_WHEN_DISCONNECTED_PROP =
133     "ReadOnlyWhenDisconnected";
134   public static final String DISPLAY_VIEWS_ON_SHAREPOINT_PROP =
135     "DisplayViewsOnSharePointSite";
136   public static final String BACK_TINT_PROP = "BackTint";
137   public static final String BACK_SHADE_PROP = "BackShade";
138   public static final String ALTERNATE_BACK_TINT_PROP = "AlternateBackTint";
139   public static final String ALTERNATE_BACK_SHADE_PROP = "AlternateBackShade";
140   public static final String ALTERNATE_BACK_THEME_COLOR_INDEX_PROP =
141     "AlternateBackThemeColorIndex";
142   public static final String DATASHEET_FORE_THEME_COLOR_INDEX_PROP =
143     "DatasheetForeThemeColorIndex";
144   public static final String DATASHEET_GRIDLINES_THEME_COLOR_INDEX_PROP =
145     "DatasheetGridlinesThemeColorIndex";
146   public static final String THEME_FONT_INDEX_PROP = "ThemeFontIndex";
147 
148   public static final String QUERY_NAME_MAP_PROP = "DOL";
149   public static final String ODBC_TIMEOUT_PROP = "ODBCTimeout";
150   public static final String RECORD_LOCKS_PROP = "RecordLocks";
151   public static final String RECORDSET_TYPE_PROP = "RecordsetType";
152   public static final String USE_TRANSACTION_PROP = "UseTransaction";
153   public static final String FAIL_ON_ERROR_PROP = "FailOnError";
154   public static final String LOG_MESSAGES_PROP = "LogMessages";
155 
156 
157   public String getName();
158 
159   public int getSize();
160 
161   public boolean isEmpty();
162 
163   /**
164    * @return the property with the given name, if any
165    */
166   public Property get(String name);
167 
168   /**
169    * @return the value of the property with the given name, if any
170    */
171   public Object getValue(String name);
172 
173   /**
174    * @return the value of the property with the given name, if any, otherwise
175    *         the given defaultValue
176    */
177   public Object getValue(String name, Object defaultValue);
178 
179   /**
180    * Creates a new (or updates an existing) property in the map.  Attempts to
181    * determine the type of the property based on the name and value (the
182    * property names listed above have their types builtin, otherwise the type
183    * of the value is used).
184    * <p>
185    * Note, this change will not be persisted until the {@link #save} method
186    * has been called.
187    *
188    * @return the newly created (or updated) property
189    * @throws IllegalArgumentException if the type of the property could not be
190    *                                  determined automatically
191    */
192   public Property put(String name, Object value);
193 
194   /**
195    * Creates a new (or updates an existing) property in the map.
196    * <p>
197    * Note, this change will not be persisted until the {@link #save} method
198    * has been called.
199    *
200    * @return the newly created (or updated) property
201    */
202   public Property put(String name, DataType type, Object value);
203 
204   /**
205    * Creates a new (or updates an existing) property in the map.
206    * <p>
207    * Note, this change will not be persisted until the {@link #save} method
208    * has been called.
209    *
210    * @return the newly created (or updated) property
211    */
212   public Property put(String name, DataType type, Object value, boolean isDdl);
213 
214   /**
215    * Creates a new (or updates an existing) property in the map, setting both
216    * of the flag bits ms access defines.
217    * <p>
218    * Note, this change will not be persisted until the {@link #save} method
219    * has been called.
220    *
221    * @return the newly created (or updated) property
222    */
223   public Property put(String name, DataType type, Object value, boolean isDdl,
224                       boolean isSkipHandler);
225 
226   /**
227    * Puts all the given properties into this map.
228    *
229    * @param props the properties to put into this map ({@code null} is
230    *              tolerated and ignored).
231    */
232   public void putAll(Iterable<? extends Property> props);
233 
234   /**
235    * Removes the property with the given name
236    *
237    * @return the removed property, or {@code null} if none found
238    */
239   public Property remove(String name);
240 
241   /**
242    * Saves the current state of this map.
243    */
244   public void save() throws IOException;
245 
246   /**
247    * @return a Stream using the default Iterator.
248    */
249   default public Stream<PropertyMap.Property> stream() {
250     return StreamSupport.stream(spliterator(), false);
251   }
252 
253   /**
254    * Info about a property defined in a PropertyMap.
255    */
256   public interface Property
257   {
258     public String getName();
259 
260     public DataType getType();
261 
262     /**
263      * Whether or not this property is a DDL object.  If {@code true}, users
264      * can't change or delete the property in access without the dbSecWriteDef
265      * permission.  Additionally, certain properties must be flagged correctly
266      * or ms access may not recognize them correctly.
267      */
268     public boolean isDdl();
269 
270     /**
271      * Whether or not ms access stores this property without running the
272      * handler bound to the property name, so that writing the property
273      * records a state rather than bringing it about.  The bit is one ms
274      * access sets on its own account, and no DAO call produces it.
275      */
276     public boolean isSkipHandler();
277 
278     public Object getValue();
279 
280     /**
281      * Sets the new value for this property.
282      * <p>
283      * Note, this change will not be persisted until the {@link
284      * PropertyMap#save} method has been called.
285      */
286     public void setValue(Object newValue);
287   }
288 
289   /**
290    * Interface for enums which can be used as property values.
291    */
292   public interface EnumValue
293   {
294     /**
295      * @return the property value which should be stored in the db
296      */
297     public Object getValue();
298   }
299 
300   /**
301    * Enum value constants for the DisplayControl property
302    */
303   public enum DisplayControl implements EnumValue
304   {
305     BOUND_OBJECT_FRAME(108),
306     CHECK_BOX(106),
307     COMBO_BOX(111),
308     COMMAND_BUTTON(104),
309     CUSTOM_CONTROL(119),
310     EMPTY_CELL(127),
311     IMAGE(103),
312     LABEL(100),
313     LINE(102),
314     LIST_BOX(110),
315     NAVIGATION_BUTTON(130),
316     NAVIGATION_CONTROL(129),
317     OBJECT_FRAME(114),
318     OPTION_BUTTON(105),
319     OPTION_GROUP(107),
320     PAGE(124),
321     PAGE_BREAK(118),
322     RECTANGLE(101),
323     SUB_FORM(112),
324     TAB_CTL(123),
325     TEXT_BOX(109),
326     TOGGLE_BUTTON(122),
327     WEB_BROWSER(128);
328 
329     private final Short _value;
330 
331     private DisplayControl(int value) {
332       _value = (short)value;
333     }
334 
335     @Override
336     public Short getValue() {
337       return _value;
338     }
339 
340     @Override
341     public String toString() {
342       return name() + "[" + _value + "]";
343     }
344   }
345 
346   /**
347    * Enum value constants for the TextFormat property
348    */
349   public enum TextFormat implements EnumValue
350   {
351     HTMLRICHTEXT(1),
352     PLAIN(0);
353 
354     private final Byte _value;
355 
356     private TextFormat(int value) {
357       _value = (byte)value;
358     }
359 
360     @Override
361     public Byte getValue() {
362       return _value;
363     }
364 
365     @Override
366     public String toString() {
367       return name() + "[" + _value + "]";
368     }
369   }
370 
371   /**
372    * Enum value constants for the IMEMode property
373    */
374   public enum IMEMode implements EnumValue
375   {
376     NOCONTROL(0),
377     ON(1),
378     OFF(2),
379     DISABLE(3),
380     HIRAGANA(4),
381     KATAKANA(5),
382     KATAKANAHALF(6),
383     ALPHAFULL(7),
384     ALPHA(8),
385     HANGULFULL(9),
386     HANGUL(10);
387 
388     private final Byte _value;
389 
390     private IMEMode(int value) {
391       _value = (byte)value;
392     }
393 
394     @Override
395     public Byte getValue() {
396       return _value;
397     }
398 
399     @Override
400     public String toString() {
401       return name() + "[" + _value + "]";
402     }
403   }
404 
405   /**
406    * Enum value constants for the IMESentenceMode property
407    */
408   public enum IMESentenceMode implements EnumValue
409   {
410     NORMAL(0),
411     PLURAL(1),
412     SPEAKING(2),
413     NONE(3);
414 
415     private final Byte _value;
416 
417     private IMESentenceMode(int value) {
418       _value = (byte)value;
419     }
420 
421     @Override
422     public Byte getValue() {
423       return _value;
424     }
425 
426     @Override
427     public String toString() {
428       return name() + "[" + _value + "]";
429     }
430   }
431 
432 }