Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

PropertyMap.java 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. Copyright (c) 2013 James Ahlborn
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package com.healthmarketscience.jackcess;
  14. import java.io.IOException;
  15. /**
  16. * Map of properties for a database object.
  17. *
  18. * @author James Ahlborn
  19. * @usage _general_class_
  20. */
  21. public interface PropertyMap extends Iterable<PropertyMap.Property>
  22. {
  23. public static final String ACCESS_VERSION_PROP = "AccessVersion";
  24. public static final String TITLE_PROP = "Title";
  25. public static final String AUTHOR_PROP = "Author";
  26. public static final String COMPANY_PROP = "Company";
  27. public static final String DEFAULT_VALUE_PROP = "DefaultValue";
  28. public static final String REQUIRED_PROP = "Required";
  29. public static final String ALLOW_ZERO_LEN_PROP = "AllowZeroLength";
  30. public static final String DECIMAL_PLACES_PROP = "DecimalPlaces";
  31. public static final String FORMAT_PROP = "Format";
  32. public static final String INPUT_MASK_PROP = "InputMask";
  33. public static final String CAPTION_PROP = "Caption";
  34. public static final String VALIDATION_RULE_PROP = "ValidationRule";
  35. public static final String VALIDATION_TEXT_PROP = "ValidationText";
  36. public static final String GUID_PROP = "GUID";
  37. public static final String DESCRIPTION_PROP = "Description";
  38. public static final String RESULT_TYPE_PROP = "ResultType";
  39. public static final String EXPRESSION_PROP = "Expression";
  40. public static final String ALLOW_MULTI_VALUE_PROP = "AllowMultipleValues";
  41. public static final String ROW_SOURCE_TYPE_PROP = "RowSourceType";
  42. public static final String ROW_SOURCE_PROP = "RowSource";
  43. public static final String DISPLAY_CONTROL_PROP = "DisplayControl";
  44. public static final String TEXT_FORMAT_PROP = "TextFormat";
  45. public static final String IME_MODE_PROP = "IMEMode";
  46. public static final String IME_SENTENCE_MODE_PROP = "IMESentenceMode";
  47. public String getName();
  48. public int getSize();
  49. public boolean isEmpty();
  50. /**
  51. * @return the property with the given name, if any
  52. */
  53. public Property get(String name);
  54. /**
  55. * @return the value of the property with the given name, if any
  56. */
  57. public Object getValue(String name);
  58. /**
  59. * @return the value of the property with the given name, if any, otherwise
  60. * the given defaultValue
  61. */
  62. public Object getValue(String name, Object defaultValue);
  63. /**
  64. * Creates a new (or updates an existing) property in the map. Attempts to
  65. * determine the type of the property based on the name and value (the
  66. * property names listed above have their types builtin, otherwise the type
  67. * of the value is used).
  68. * <p>
  69. * Note, this change will not be persisted until the {@link #save} method
  70. * has been called.
  71. *
  72. * @return the newly created (or updated) property
  73. * @throws IllegalArgumentException if the type of the property could not be
  74. * determined automatically
  75. */
  76. public Property put(String name, Object value);
  77. /**
  78. * Creates a new (or updates an existing) property in the map.
  79. * <p>
  80. * Note, this change will not be persisted until the {@link #save} method
  81. * has been called.
  82. *
  83. * @return the newly created (or updated) property
  84. */
  85. public Property put(String name, DataType type, Object value);
  86. /**
  87. * Creates a new (or updates an existing) property in the map.
  88. * <p>
  89. * Note, this change will not be persisted until the {@link #save} method
  90. * has been called.
  91. *
  92. * @return the newly created (or updated) property
  93. */
  94. public Property put(String name, DataType type, Object value, boolean isDdl);
  95. /**
  96. * Puts all the given properties into this map.
  97. *
  98. * @param props the properties to put into this map ({@code null} is
  99. * tolerated and ignored).
  100. */
  101. public void putAll(Iterable<? extends Property> props);
  102. /**
  103. * Removes the property with the given name
  104. *
  105. * @return the removed property, or {@code null} if none found
  106. */
  107. public Property remove(String name);
  108. /**
  109. * Saves the current state of this map.
  110. */
  111. public void save() throws IOException;
  112. /**
  113. * Info about a property defined in a PropertyMap.
  114. */
  115. public interface Property
  116. {
  117. public String getName();
  118. public DataType getType();
  119. /**
  120. * Whether or not this property is a DDL object. If {@code true}, users
  121. * can't change or delete the property in access without the dbSecWriteDef
  122. * permission. Additionally, certain properties must be flagged correctly
  123. * or the access engine may not recognize them correctly.
  124. */
  125. public boolean isDdl();
  126. public Object getValue();
  127. /**
  128. * Sets the new value for this property.
  129. * <p>
  130. * Note, this change will not be persisted until the {@link
  131. * PropertyMap#save} method has been called.
  132. */
  133. public void setValue(Object newValue);
  134. }
  135. /**
  136. * Interface for enums which can be used as property values.
  137. */
  138. public interface EnumValue
  139. {
  140. /**
  141. * @return the property value which should be stored in the db
  142. */
  143. public Object getValue();
  144. }
  145. /**
  146. * Enum value constants for the DisplayControl property
  147. */
  148. public enum DisplayControl implements EnumValue
  149. {
  150. BOUND_OBJECT_FRAME(108),
  151. CHECK_BOX(106),
  152. COMBO_BOX(111),
  153. COMMAND_BUTTON(104),
  154. CUSTOM_CONTROL(119),
  155. EMPTY_CELL(127),
  156. IMAGE(103),
  157. LABEL(100),
  158. LINE(102),
  159. LIST_BOX(110),
  160. NAVIGATION_BUTTON(130),
  161. NAVIGATION_CONTROL(129),
  162. OBJECT_FRAME(114),
  163. OPTION_BUTTON(105),
  164. OPTION_GROUP(107),
  165. PAGE(124),
  166. PAGE_BREAK(118),
  167. RECTANGLE(101),
  168. SUB_FORM(112),
  169. TAB_CTL(123),
  170. TEXT_BOX(109),
  171. TOGGLE_BUTTON(122),
  172. WEB_BROWSER(128);
  173. private final Short _value;
  174. private DisplayControl(int value) {
  175. _value = (short)value;
  176. }
  177. @Override
  178. public Short getValue() {
  179. return _value;
  180. }
  181. @Override
  182. public String toString() {
  183. return name() + "[" + _value + "]";
  184. }
  185. }
  186. /**
  187. * Enum value constants for the TextFormat property
  188. */
  189. public enum TextFormat implements EnumValue
  190. {
  191. HTMLRICHTEXT(1),
  192. PLAIN(0);
  193. private final Byte _value;
  194. private TextFormat(int value) {
  195. _value = (byte)value;
  196. }
  197. @Override
  198. public Byte getValue() {
  199. return _value;
  200. }
  201. @Override
  202. public String toString() {
  203. return name() + "[" + _value + "]";
  204. }
  205. }
  206. /**
  207. * Enum value constants for the IMEMode property
  208. */
  209. public enum IMEMode implements EnumValue
  210. {
  211. NOCONTROL(0),
  212. ON(1),
  213. OFF(2),
  214. DISABLE(3),
  215. HIRAGANA(4),
  216. KATAKANA(5),
  217. KATAKANAHALF(6),
  218. ALPHAFULL(7),
  219. ALPHA(8),
  220. HANGULFULL(9),
  221. HANGUL(10);
  222. private final Byte _value;
  223. private IMEMode(int value) {
  224. _value = (byte)value;
  225. }
  226. @Override
  227. public Byte getValue() {
  228. return _value;
  229. }
  230. @Override
  231. public String toString() {
  232. return name() + "[" + _value + "]";
  233. }
  234. }
  235. /**
  236. * Enum value constants for the IMESentenceMode property
  237. */
  238. public enum IMESentenceMode implements EnumValue
  239. {
  240. NORMAL(0),
  241. PLURAL(1),
  242. SPEAKING(2),
  243. NONE(3);
  244. private final Byte _value;
  245. private IMESentenceMode(int value) {
  246. _value = (byte)value;
  247. }
  248. @Override
  249. public Byte getValue() {
  250. return _value;
  251. }
  252. @Override
  253. public String toString() {
  254. return name() + "[" + _value + "]";
  255. }
  256. }
  257. }