diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2018-05-25 03:22:43 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2018-05-25 03:22:43 +0000 |
commit | 9fc9133e7ac8aa072020f6100fce1ff37b6e504a (patch) | |
tree | d6e6fff91b734d3f954919fb043f44c47ef8d4b1 | |
parent | a0e9ce63ee510723c60d2db8ce6569c2cca356ea (diff) | |
parent | f5659151a36e02a82b6b52795cb9788ad2c74a4d (diff) | |
download | jackcess-9fc9133e7ac8aa072020f6100fce1ff37b6e504a.tar.gz jackcess-9fc9133e7ac8aa072020f6100fce1ff37b6e504a.zip |
merge trunk changes through r1152
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/exprs@1153 f203690c-595d-4dc9-a70b-905162fa7fd2
5 files changed, 199 insertions, 18 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 1b20b4a..13ed1c9 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -4,6 +4,15 @@ <author email="javajedi@users.sf.net">Tim McCune</author> </properties> <body> + <release version="2.1.12" date="TBD"> + <action dev="jahlborn" type="update"> + Add some additional property keys and relevant enums for values. + </action> + <action dev="jahlborn" type="fix" system="SourceForge2" issue="147"> + Create new usage map correctly when adding an index to an existing + table. + </action> + </release> <release version="2.1.11" date="2018-03-04"> <action dev="jahlborn" type="fix" system="SourceForge2" issue="145"> Expose the "ddl" attribute on properties. Set the attribute @@ -144,7 +153,7 @@ system property), per-database, and per-table. </action> </release> - <release version="2.1.0" date="2015-04-16" + <release version="2.1.0" date="2015-04-16" description="Relicense to Apache License"> <action dev="jahlborn" type="add"> OpenHMS relicenses to Apache License, 2.0! @@ -264,7 +273,7 @@ <action dev="jahlborn" type="fix"> Make reading long value columns more lenient (MEMO/OLE). </action> - <action dev="jahlborn" type="add" system="SourceForge2Features" + <action dev="jahlborn" type="add" system="SourceForge2Features" issue="16"> Add support for modifying PropertyMaps. </action> @@ -284,7 +293,7 @@ <action dev="jahlborn" type="fix"> Make reading long value columns more lenient (MEMO/OLE). </action> - </release> + </release> <release version="1.2.14.2" date="2013-08-25"> <action dev="jahlborn" type="fix" system="SourceForge2" issue="96"> Fix reading of Properties with multiple value blocks. @@ -811,7 +820,7 @@ characters (and other situations where tables could not be opened in Access). Remove hack which forced every table name to have uppercase first character. - </action> + </action> <action dev="jahlborn" type="update"> Clean up compressed text handling. </action> diff --git a/src/main/java/com/healthmarketscience/jackcess/PropertyMap.java b/src/main/java/com/healthmarketscience/jackcess/PropertyMap.java index c93d896..516a098 100644 --- a/src/main/java/com/healthmarketscience/jackcess/PropertyMap.java +++ b/src/main/java/com/healthmarketscience/jackcess/PropertyMap.java @@ -47,6 +47,10 @@ public interface PropertyMap extends Iterable<PropertyMap.Property> public static final String ALLOW_MULTI_VALUE_PROP = "AllowMultipleValues"; public static final String ROW_SOURCE_TYPE_PROP = "RowSourceType"; public static final String ROW_SOURCE_PROP = "RowSource"; + public static final String DISPLAY_CONTROL_PROP = "DisplayControl"; + public static final String TEXT_FORMAT_PROP = "TextFormat"; + public static final String IME_MODE_PROP = "IMEMode"; + public static final String IME_SENTENCE_MODE_PROP = "IMESentenceMode"; public String getName(); @@ -113,7 +117,7 @@ public interface PropertyMap extends Iterable<PropertyMap.Property> * tolerated and ignored). */ public void putAll(Iterable<? extends Property> props); - + /** * Removes the property with the given name * @@ -128,8 +132,8 @@ public interface PropertyMap extends Iterable<PropertyMap.Property> /** * Info about a property defined in a PropertyMap. - */ - public interface Property + */ + public interface Property { public String getName(); @@ -153,4 +157,144 @@ public interface PropertyMap extends Iterable<PropertyMap.Property> */ public void setValue(Object newValue); } + + /** + * Interface for enums which can be used as property values. + */ + public interface EnumValue + { + /** + * @return the property value which should be stored in the db + */ + public Object getValue(); + } + + /** + * Enum value constants for the DisplayControl property + */ + public enum DisplayControl implements EnumValue + { + BOUND_OBJECT_FRAME(108), + CHECK_BOX(106), + COMBO_BOX(111), + COMMAND_BUTTON(104), + CUSTOM_CONTROL(119), + EMPTY_CELL(127), + IMAGE(103), + LABEL(100), + LINE(102), + LIST_BOX(110), + NAVIGATION_BUTTON(130), + NAVIGATION_CONTROL(129), + OBJECT_FRAME(114), + OPTION_BUTTON(105), + OPTION_GROUP(107), + PAGE(124), + PAGE_BREAK(118), + RECTANGLE(101), + SUB_FORM(112), + TAB_CTL(123), + TEXT_BOX(109), + TOGGLE_BUTTON(122), + WEB_BROWSER(128); + + private final Short _value; + + private DisplayControl(int value) { + _value = (short)value; + } + + public Short getValue() { + return _value; + } + + @Override + public String toString() { + return name() + "[" + _value + "]"; + } + } + + /** + * Enum value constants for the TextFormat property + */ + public enum TextFormat implements EnumValue + { + HTMLRICHTEXT(1), + PLAIN(0); + + private final Byte _value; + + private TextFormat(int value) { + _value = (byte)value; + } + + public Byte getValue() { + return _value; + } + + @Override + public String toString() { + return name() + "[" + _value + "]"; + } + } + + /** + * Enum value constants for the IMEMode property + */ + public enum IMEMode implements EnumValue + { + NOCONTROL(0), + ON(1), + OFF(2), + DISABLE(3), + HIRAGANA(4), + KATAKANA(5), + KATAKANAHALF(6), + ALPHAFULL(7), + ALPHA(8), + HANGULFULL(9), + HANGUL(10); + + private final Byte _value; + + private IMEMode(int value) { + _value = (byte)value; + } + + public Byte getValue() { + return _value; + } + + @Override + public String toString() { + return name() + "[" + _value + "]"; + } + } + + /** + * Enum value constants for the IMESentenceMode property + */ + public enum IMESentenceMode implements EnumValue + { + NORMAL(0), + PLURAL(1), + SPEAKING(2), + NONE(3); + + private final Byte _value; + + private IMESentenceMode(int value) { + _value = (byte)value; + } + + public Byte getValue() { + return _value; + } + + @Override + public String toString() { + return name() + "[" + _value + "]"; + } + } + } diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java index 137426c..be3a249 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java @@ -55,11 +55,15 @@ public class PropertyMapImpl implements PropertyMap DEFAULT_TYPES.put(DESCRIPTION_PROP, new PropDef(DataType.MEMO, false)); DEFAULT_TYPES.put(RESULT_TYPE_PROP, new PropDef(DataType.BYTE, true)); DEFAULT_TYPES.put(EXPRESSION_PROP, new PropDef(DataType.MEMO, true)); + DEFAULT_TYPES.put(DISPLAY_CONTROL_PROP, new PropDef(DataType.INT, false)); + DEFAULT_TYPES.put(TEXT_FORMAT_PROP, new PropDef(DataType.BYTE, false)); + DEFAULT_TYPES.put(IME_MODE_PROP, new PropDef(DataType.BYTE, false)); + DEFAULT_TYPES.put(IME_SENTENCE_MODE_PROP, new PropDef(DataType.BYTE, false)); } private final String _mapName; private final short _mapType; - private final Map<String,Property> _props = + private final Map<String,Property> _props = new LinkedHashMap<String,Property>(); private final PropertyMaps _owner; @@ -122,8 +126,8 @@ public class PropertyMapImpl implements PropertyMap for(Property prop : props) { put(prop); } - } - + } + public PropertyImpl put(Property prop) { return put(prop.getName(), prop.getType(), prop.getValue(), prop.isDdl()); } @@ -131,7 +135,7 @@ public class PropertyMapImpl implements PropertyMap /** * Puts a property into this map with the given information. */ - public PropertyImpl put(String name, DataType type, Object value, + public PropertyImpl put(String name, DataType type, Object value, boolean isDdl) { PropertyImpl prop = (PropertyImpl)createProperty(name, type, value, isDdl); _props.put(DatabaseImpl.toLookupName(name), prop); @@ -153,7 +157,7 @@ public class PropertyMapImpl implements PropertyMap @Override public String toString() { return toString(this); - } + } public static String toString(PropertyMap map) { StringBuilder sb = new StringBuilder(); @@ -173,12 +177,17 @@ public class PropertyMapImpl implements PropertyMap public static Property createProperty(String name, DataType type, Object value) { return createProperty(name, type, value, false); } - - public static Property createProperty(String name, DataType type, + + public static Property createProperty(String name, DataType type, Object value, boolean isDdl) { // see if this is a builtin property that we already understand PropDef pd = DEFAULT_TYPES.get(name); + if(value instanceof PropertyMap.EnumValue) { + // convert custom enum to stored value + value = ((PropertyMap.EnumValue)value).getValue(); + } + if(pd != null) { // update according to the default info type = ((type == null) ? pd._type : type); @@ -211,13 +220,13 @@ public class PropertyMapImpl implements PropertyMap " with value " + value); } } - + return new PropertyImpl(name, type, value, isDdl); } /** * Info about a property defined in a PropertyMap. - */ + */ static final class PropertyImpl implements PropertyMap.Property { private final String _name; diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java index 7e996e1..c084ae8 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java @@ -1679,12 +1679,18 @@ public class TableImpl implements Table, PropertyMaps.Owner umapBuf.putShort(getRowStartOffset(umapRowNum, format), (short)rowStart); umapBuf.put(rowStart, UsageMap.MAP_TYPE_INLINE); + int dataOffset = rowStart + 1; if(firstUsedPage != null) { // fill in the first used page of the usage map - umapBuf.putInt(rowStart + 1, firstUsedPage); - umapBuf.put(rowStart + 5, (byte)1); + umapBuf.putInt(dataOffset, firstUsedPage); + dataOffset += 4; + umapBuf.put(dataOffset, (byte)1); + dataOffset++; } + // zero remaining row data + ByteUtil.clearRange(umapBuf, dataOffset, (rowStart + umapRowLength)); + rowStart -= umapRowLength; ++umapRowNum; } diff --git a/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java b/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java index 08cedc0..056ca68 100644 --- a/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java @@ -516,6 +516,19 @@ public class PropertiesTest extends TestCase } } + public void testEnumValues() throws Exception + { + PropertyMaps maps = new PropertyMaps(10, null, null, null); + + PropertyMapImpl colMap = maps.get("testcol"); + + colMap.put(PropertyMap.DISPLAY_CONTROL_PROP, + PropertyMap.DisplayControl.TEXT_BOX); + + assertEquals(PropertyMap.DisplayControl.TEXT_BOX.getValue(), + colMap.getValue(PropertyMap.DISPLAY_CONTROL_PROP)); + } + private static void checkProperties(PropertyMap propMap1, PropertyMap propMap2) { |