diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2013-08-16 02:09:48 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2013-08-16 02:09:48 +0000 |
commit | 417fb06208f50cbf164a1c101ac03c7bae0856d8 (patch) | |
tree | 52217c1c09bc71377ca0f422ed43d24d6917a178 /src/main/java/com/healthmarketscience/jackcess/complex | |
parent | 790b943d773fc72a11089b6acaf17aa341f92ae4 (diff) | |
download | jackcess-417fb06208f50cbf164a1c101ac03c7bae0856d8.tar.gz jackcess-417fb06208f50cbf164a1c101ac03c7bae0856d8.zip |
move files into standard maven dir structure
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@781 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main/java/com/healthmarketscience/jackcess/complex')
12 files changed, 718 insertions, 0 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/Attachment.java b/src/main/java/com/healthmarketscience/jackcess/complex/Attachment.java new file mode 100644 index 0000000..c569315 --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/Attachment.java @@ -0,0 +1,59 @@ +/* +Copyright (c) 2011 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +import java.io.IOException; +import java.util.Date; + +/** + * Complex value corresponding to an attachment. + * + * @author James Ahlborn + */ +public interface Attachment extends ComplexValue +{ + public byte[] getFileData() throws IOException; + + public void setFileData(byte[] data); + + public byte[] getEncodedFileData() throws IOException; + + public void setEncodedFileData(byte[] data); + + public String getFileName(); + + public void setFileName(String fileName); + + public String getFileUrl(); + + public void setFileUrl(String fileUrl); + + public String getFileType(); + + public void setFileType(String fileType); + + public Date getFileTimeStamp(); + + public void setFileTimeStamp(Date fileTimeStamp); + + public Integer getFileFlags(); + + public void setFileFlags(Integer fileFlags); +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/AttachmentColumnInfo.java b/src/main/java/com/healthmarketscience/jackcess/complex/AttachmentColumnInfo.java new file mode 100644 index 0000000..f2f605a --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/AttachmentColumnInfo.java @@ -0,0 +1,30 @@ +/* +Copyright (c) 2013 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +/** + * Complex column info for a column holding 0 or more attachments per row. + * + * @author James Ahlborn + */ +public interface AttachmentColumnInfo extends ComplexColumnInfo<Attachment> +{ + +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/ComplexColumnInfo.java b/src/main/java/com/healthmarketscience/jackcess/complex/ComplexColumnInfo.java new file mode 100644 index 0000000..14851f6 --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/ComplexColumnInfo.java @@ -0,0 +1,74 @@ +/* +Copyright (c) 2013 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import com.healthmarketscience.jackcess.Row; + +/** + * Base class for the additional information tracked for complex columns. + * + * @author James Ahlborn + */ +public interface ComplexColumnInfo<V extends ComplexValue> +{ + public ComplexDataType getType(); + + public int countValues(int complexValueFk) throws IOException; + + public List<Row> getRawValues(int complexValueFk) + throws IOException; + + public List<Row> getRawValues(int complexValueFk, + Collection<String> columnNames) + throws IOException; + + public List<V> getValues(ComplexValueForeignKey complexValueFk) + throws IOException; + + public ComplexValue.Id addRawValue(Map<String,?> rawValue) + throws IOException; + + public ComplexValue.Id addValue(V value) throws IOException; + + public void addValues(Collection<? extends V> values) throws IOException; + + public ComplexValue.Id updateRawValue(Row rawValue) throws IOException; + + public ComplexValue.Id updateValue(V value) throws IOException; + + public void updateValues(Collection<? extends V> values) throws IOException; + + public void deleteRawValue(Row rawValue) throws IOException; + + public void deleteValue(V value) throws IOException; + + public void deleteValues(Collection<? extends V> values) throws IOException; + + public void deleteAllValues(int complexValueFk) throws IOException; + + public void deleteAllValues(ComplexValueForeignKey complexValueFk) + throws IOException; + +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/ComplexDataType.java b/src/main/java/com/healthmarketscience/jackcess/complex/ComplexDataType.java new file mode 100644 index 0000000..c0ae495 --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/ComplexDataType.java @@ -0,0 +1,30 @@ +/* +Copyright (c) 2011 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +/** + * Secondary type classification for the data in a complex column. + * + * @author James Ahlborn + */ +public enum ComplexDataType +{ + ATTACHMENT, MULTI_VALUE, VERSION_HISTORY, UNSUPPORTED; +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/ComplexValue.java b/src/main/java/com/healthmarketscience/jackcess/complex/ComplexValue.java new file mode 100644 index 0000000..29b62d3 --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/ComplexValue.java @@ -0,0 +1,153 @@ +/* +Copyright (c) 2011 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +import java.io.IOException; +import java.io.ObjectStreamException; + +import com.healthmarketscience.jackcess.Column; +import com.healthmarketscience.jackcess.RowId; +import com.healthmarketscience.jackcess.impl.complex.ComplexColumnInfoImpl; + +/** + * Base interface for a value in a complex column (where there may be multiple + * values for a single row in the main table). + * + * @author James Ahlborn + */ +public interface ComplexValue +{ + /** + * Returns the unique identifier of this complex value (this value is unique + * among all values in all rows of the main table). + * + * @return the current id or {@link ComplexColumnInfoImpl#INVALID_ID} for a new, + * unsaved value. + */ + public Id getId(); + + /** + * Called once when a new ComplexValue is saved to set the new unique + * identifier. + */ + public void setId(Id newId); + + /** + * Returns the foreign key identifier for this complex value (this value is + * the same for all values in the same row of the main table). + * + * @return the current id or {@link ComplexColumnInfoImpl#INVALID_FK} + * for a new, unsaved value. + */ + public ComplexValueForeignKey getComplexValueForeignKey(); + + public void setComplexValueForeignKey(ComplexValueForeignKey complexValueFk); + + /** + * @return the column in the main table with which this complex value is + * associated + */ + public Column getColumn(); + + /** + * Writes any updated data for this complex value to the database. + */ + public void update() throws IOException; + + /** + * Deletes the data for this complex value from the database. + */ + public void delete() throws IOException; + + + /** + * Identifier for a ComplexValue. Only valid for comparing complex values + * for the same column. + */ + public abstract class Id extends Number + { + private static final long serialVersionUID = 20130318L; + + @Override + public byte byteValue() { + return (byte)get(); + } + + @Override + public short shortValue() { + return (short)get(); + } + + @Override + public int intValue() { + return get(); + } + + @Override + public long longValue() { + return get(); + } + + @Override + public float floatValue() { + return get(); + } + + @Override + public double doubleValue() { + return get(); + } + + @Override + public int hashCode() { + return get(); + } + + @Override + public boolean equals(Object o) { + return ((this == o) || + ((o != null) && (getClass() == o.getClass()) && + (get() == ((Id)o).get()))); + } + + @Override + public String toString() { + return String.valueOf(get()); + } + + protected final Object writeReplace() throws ObjectStreamException { + // if we are going to serialize this ComplexValue.Id, convert it back to + // a normal Integer (in case it is restored outside of the context of + // jackcess) + return Integer.valueOf(get()); + } + + /** + * Returns the unique identifier of this complex value (this value is unique + * among all values in all rows of the main table for the complex column). + */ + public abstract int get(); + + /** + * Returns the rowId of this ComplexValue within the secondary table. + */ + public abstract RowId getRowId(); + } +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/ComplexValueForeignKey.java b/src/main/java/com/healthmarketscience/jackcess/complex/ComplexValueForeignKey.java new file mode 100644 index 0000000..aeff8c9 --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/ComplexValueForeignKey.java @@ -0,0 +1,174 @@ +/* +Copyright (c) 2013 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +import java.io.IOException; +import java.io.ObjectStreamException; +import java.util.Date; +import java.util.List; +import java.util.Map; +import com.healthmarketscience.jackcess.Column; + + +/** + * Value which is returned for a complex column. This value corresponds to a + * foreign key in a secondary table which contains the actual complex data for + * this row (which could be 0 or more complex values for a given row). This + * class contains various convenience methods for interacting with the actual + * complex values. + * <p> + * This class will cache the associated complex values returned from one of + * the lookup methods. The various modification methods will clear this cache + * automatically. The {@link #reset} method may be called manually to clear + * this internal cache. + * + * @author James Ahlborn + */ +public abstract class ComplexValueForeignKey extends Number +{ + private static final long serialVersionUID = 20130319L; + + @Override + public byte byteValue() { + return (byte)get(); + } + + @Override + public short shortValue() { + return (short)get(); + } + + @Override + public int intValue() { + return get(); + } + + @Override + public long longValue() { + return get(); + } + + @Override + public float floatValue() { + return get(); + } + + @Override + public double doubleValue() { + return get(); + } + + protected final Object writeReplace() throws ObjectStreamException { + // if we are going to serialize this ComplexValueForeignKey, convert it + // back to a normal Integer (in case it is restored outside of the context + // of jackcess) + return Integer.valueOf(get()); + } + + @Override + public int hashCode() { + return get(); + } + + @Override + public boolean equals(Object o) { + return ((this == o) || + ((o != null) && (getClass() == o.getClass()) && + (get() == ((ComplexValueForeignKey)o).get()))); + } + + @Override + public String toString() { + return String.valueOf(get()); + } + + public abstract int get(); + + public abstract Column getColumn(); + + public abstract ComplexDataType getComplexType(); + + public abstract int countValues() throws IOException; + + public abstract List<? extends ComplexValue> getValues() throws IOException; + + public abstract List<Version> getVersions() throws IOException; + + public abstract List<Attachment> getAttachments() + throws IOException; + + public abstract List<SingleValue> getMultiValues() + throws IOException; + + public abstract List<UnsupportedValue> getUnsupportedValues() + throws IOException; + + public abstract void reset(); + + public abstract Version addVersion(String value) + throws IOException; + + public abstract Version addVersion(String value, Date modifiedDate) + throws IOException; + + public abstract Attachment addAttachment(byte[] data) + throws IOException; + + public abstract Attachment addAttachment( + String url, String name, String type, byte[] data, + Date timeStamp, Integer flags) + throws IOException; + + public abstract Attachment addEncodedAttachment(byte[] encodedData) + throws IOException; + + public abstract Attachment addEncodedAttachment( + String url, String name, String type, byte[] encodedData, + Date timeStamp, Integer flags) + throws IOException; + + public abstract Attachment updateAttachment(Attachment attachment) + throws IOException; + + public abstract Attachment deleteAttachment(Attachment attachment) + throws IOException; + + public abstract SingleValue addMultiValue(Object value) + throws IOException; + + public abstract SingleValue updateMultiValue(SingleValue value) + throws IOException; + + public abstract SingleValue deleteMultiValue(SingleValue value) + throws IOException; + + public abstract UnsupportedValue addUnsupportedValue(Map<String,?> values) + throws IOException; + + public abstract UnsupportedValue updateUnsupportedValue(UnsupportedValue value) + throws IOException; + + public abstract UnsupportedValue deleteUnsupportedValue(UnsupportedValue value) + throws IOException; + + public abstract void deleteAllValues() + throws IOException; + +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/MultiValueColumnInfo.java b/src/main/java/com/healthmarketscience/jackcess/complex/MultiValueColumnInfo.java new file mode 100644 index 0000000..406908e --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/MultiValueColumnInfo.java @@ -0,0 +1,30 @@ +/* +Copyright (c) 2013 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +/** + * Complex column info for a column holding multiple simple values per row. + * + * @author James Ahlborn + */ +public interface MultiValueColumnInfo extends ComplexColumnInfo<SingleValue> +{ + +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/SingleValue.java b/src/main/java/com/healthmarketscience/jackcess/complex/SingleValue.java new file mode 100644 index 0000000..2e4c509 --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/SingleValue.java @@ -0,0 +1,32 @@ +/* +Copyright (c) 2011 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +/** + * Complex value corresponding to an single value in a multi-value column. + * + * @author James Ahlborn + */ +public interface SingleValue extends ComplexValue +{ + public Object get(); + + public void set(Object value); +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/UnsupportedColumnInfo.java b/src/main/java/com/healthmarketscience/jackcess/complex/UnsupportedColumnInfo.java new file mode 100644 index 0000000..646ecfc --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/UnsupportedColumnInfo.java @@ -0,0 +1,30 @@ +/* +Copyright (c) 2013 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +/** + * Complex column info for an unsupported complex type. + * + * @author James Ahlborn + */ +public interface UnsupportedColumnInfo extends ComplexColumnInfo<UnsupportedValue> +{ + +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/UnsupportedValue.java b/src/main/java/com/healthmarketscience/jackcess/complex/UnsupportedValue.java new file mode 100644 index 0000000..11a8907 --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/UnsupportedValue.java @@ -0,0 +1,36 @@ +/* +Copyright (c) 2011 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +import java.util.Map; + +/** + * Complex value corresponding to an unsupported complex column type. + * + * @author James Ahlborn + */ +public interface UnsupportedValue extends ComplexValue +{ + public Map<String,Object> getValues(); + + public Object get(String columnName); + + public void set(String columnName, Object value); +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/Version.java b/src/main/java/com/healthmarketscience/jackcess/complex/Version.java new file mode 100644 index 0000000..376eb32 --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/Version.java @@ -0,0 +1,34 @@ +/* +Copyright (c) 2011 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +import java.util.Date; + +/** + * Complex value corresponding to a version of a memo column. + * + * @author James Ahlborn + */ +public interface Version extends ComplexValue, Comparable<Version> +{ + public String getValue(); + + public Date getModifiedDate(); +} diff --git a/src/main/java/com/healthmarketscience/jackcess/complex/VersionHistoryColumnInfo.java b/src/main/java/com/healthmarketscience/jackcess/complex/VersionHistoryColumnInfo.java new file mode 100644 index 0000000..db1f1cf --- /dev/null +++ b/src/main/java/com/healthmarketscience/jackcess/complex/VersionHistoryColumnInfo.java @@ -0,0 +1,36 @@ +/* +Copyright (c) 2013 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess.complex; + +/** + * Complex column info for a column which tracking the version history of an + * "append only" memo column. + * <p> + * Note, the strongly typed update/delete methods are <i>not</i> supported for + * version history columns (the data is supposed to be immutable). That said, + * the "raw" update/delete methods are supported for those that <i>really</i> + * want to muck with the version history data. + * + * @author James Ahlborn + */ +public interface VersionHistoryColumnInfo extends ComplexColumnInfo<Version> +{ + +} |