ASF Bugzilla – Attachment 8807 Details for
Bug 24183
[PATCH] Added CLSID support for DirectoryNodes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
[PATCH] CLSID support for DirectoryNodes (without sun collections)
patch_POI_24183_no_collections.txt (text/plain), 10.84 KB, created by
Kirill Jacobson
on 2003-10-29 23:02:07 UTC
(
hide
)
Description:
[PATCH] CLSID support for DirectoryNodes (without sun collections)
Filename:
MIME Type:
Creator:
Kirill Jacobson
Created:
2003-10-29 23:02:07 UTC
Size:
10.84 KB
patch
obsolete
>Index: src/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java,v >retrieving revision 1.2 >diff -u -r1.2 DirectoryEntry.java >--- src/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java 30 Apr 2003 04:39:07 -0000 1.2 >+++ src/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java 29 Oct 2003 22:56:18 -0000 >@@ -160,5 +160,22 @@ > > public DirectoryEntry createDirectory(final String name) > throws IOException; >+ >+ /** >+ * @return CLSID assigned to the directory entry >+ * "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" >+ */ >+ >+ public String getCLSID(); >+ >+ /** >+ * Sets CLSID to be assigned to the directory entry. >+ * "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" >+ * >+ * @param CLSID to be assigned to the directory entry >+ */ >+ >+ public void setCLSID(final String clsid); >+ > } // end public interface DirectoryEntry > >Index: src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java,v >retrieving revision 1.2 >diff -u -r1.2 DirectoryNode.java >--- src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java 30 Apr 2003 04:39:07 -0000 1.2 >+++ src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java 29 Oct 2003 22:56:18 -0000 >@@ -346,6 +346,28 @@ > return rval; > } > >+ /** >+ * @return CLSID assigned to the directory entry >+ * "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" >+ */ >+ >+ public String getCLSID() >+ { >+ return (( DirectoryProperty )getProperty()).getCLSID(); >+ } >+ >+ /** >+ * Sets CLSID to be assigned to the directory entry. >+ * "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" >+ * >+ * @param CLSID to be assigned to the directory entry >+ */ >+ >+ public void setCLSID(final String clsid) >+ { >+ (( DirectoryProperty )getProperty()).setCLSID(clsid); >+ } >+ > /* ********** END implementation of DirectoryEntry ********** */ > /* ********** START implementation of Entry ********** */ > >Index: src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java,v >retrieving revision 1.4 >diff -u -r1.4 POIFSFileSystem.java >--- src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java 30 Apr 2003 04:39:07 -0000 1.4 >+++ src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java 29 Oct 2003 22:56:18 -0000 >@@ -423,6 +423,8 @@ > DirectoryNode new_dir = > ( DirectoryNode ) parent.createDirectory(name); > >+ ((DirectoryProperty)new_dir.getProperty()).setCLSID(property.getCLSID()); >+ > processProperties( > small_blocks, big_blocks, > (( DirectoryProperty ) property).getChildren(), new_dir); >Index: src/java/org/apache/poi/poifs/property/Property.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/poifs/property/Property.java,v >retrieving revision 1.3 >diff -u -r1.3 Property.java >--- src/java/org/apache/poi/poifs/property/Property.java 30 Apr 2003 04:39:16 -0000 1.3 >+++ src/java/org/apache/poi/poifs/property/Property.java 29 Oct 2003 22:56:18 -0000 >@@ -65,6 +65,8 @@ > import org.apache.poi.util.IntegerField; > import org.apache.poi.util.LittleEndianConsts; > import org.apache.poi.util.ShortField; >+import org.apache.poi.util.ByteArrayField; >+import org.apache.poi.util.HexDump; > > /** > * This abstract base class is the ancestor of all classes >@@ -87,6 +89,7 @@ > static final private int _previous_property_offset = 0x44; > static final private int _next_property_offset = 0x48; > static final private int _child_property_offset = 0x4C; >+ static final private int _clsid_offset = 0x50; > static final private int _seconds_1_offset = 0x64; > static final private int _days_1_offset = 0x68; > static final private int _seconds_2_offset = 0x6C; >@@ -107,6 +110,7 @@ > private IntegerField _previous_property; > private IntegerField _next_property; > private IntegerField _child_property; >+ private ByteArrayField _clsid; > private IntegerField _seconds_1; > private IntegerField _days_1; > private IntegerField _seconds_2; >@@ -136,6 +140,8 @@ > _NO_INDEX, _raw_data); > _child_property = new IntegerField(_child_property_offset, > _NO_INDEX, _raw_data); >+ _clsid = new ByteArrayField(_clsid_offset, 16, _raw_data); >+ > _seconds_1 = new IntegerField(_seconds_1_offset, 0, > _raw_data); > _days_1 = new IntegerField(_days_1_offset, 0, _raw_data); >@@ -173,6 +179,7 @@ > _raw_data); > _child_property = new IntegerField(_child_property_offset, > _raw_data); >+ _clsid = new ByteArrayField(_clsid_offset, 16, _raw_data); > _seconds_1 = new IntegerField(_seconds_1_offset, _raw_data); > _days_1 = new IntegerField(_days_1_offset, _raw_data); > _seconds_2 = new IntegerField(_seconds_2_offset, _raw_data); >@@ -445,6 +452,68 @@ > static boolean isValidIndex(int index) > { > return index != _NO_INDEX; >+ } >+ >+ /** >+ * @return CLSID assigned to the directory property >+ * >+ * "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" >+ * offset 01234567890123456789012345678901234567 >+ * [0..37] 0 1 2 3 >+ * >+ */ >+ >+ private final static int[] clsid_separator_offset = { 0, 9, 14, 19, 24, 37 }; >+ private final static char[] clsid_separator_char = { '{', '-', '-', '-', '-', '}' }; >+ private final static byte[] clsid_byte2str = { 3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15 }; >+ >+ public String getCLSID() >+ { >+ StringBuffer buf = new StringBuffer(38); >+ >+ byte[] data = _clsid.get(); >+ for (int i=0; i< data.length; i++) >+ buf.append(HexDump.toHex(data[clsid_byte2str[i]])); >+ >+ for (int i=0; i<clsid_separator_offset.length; i++) >+ buf.insert( clsid_separator_offset[i], clsid_separator_char[i]); >+ >+ return buf.toString(); >+ } >+ >+ /** >+ * Sets CLSID to be assigned to the directory property >+ * "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" >+ * >+ * @param CLSID to be assigned to the directory entry >+ * >+ * "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" >+ * offset 01234567890123456789012345678901234567 >+ * [0..37] 0 1 2 3 >+ * >+ */ >+ >+ public void setCLSID(final String clsid) >+ { >+ String msg = "Invalid clsid ('" + clsid + "'). Expected '{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}'"; >+ >+ if (clsid.length() != 38 ) >+ throw new IllegalArgumentException(msg); >+ >+ StringBuffer buf = new StringBuffer(38); >+ for (int i=1; i < clsid.length()-1; i++) >+ if (clsid.charAt(i) != '-') buf.append( clsid.charAt(i) ); >+ >+ try { >+ byte[] data = new byte[16]; >+ for (int i=0; i<data.length; i++) >+ data[clsid_byte2str[i]] = (byte)Integer.parseInt("" + buf.charAt(2*i) + buf.charAt(2*i+1), 16); >+ >+ _clsid.set(data,_raw_data); >+ } >+ catch (NumberFormatException e) { >+ throw new IllegalArgumentException(msg); >+ } > } > > /* ********** START implementation of Child ********** */ >Index: src/java/org/apache/poi/util/ByteArrayField.java >=================================================================== >RCS file: src/java/org/apache/poi/util/ByteArrayField.java >diff -N src/java/org/apache/poi/util/ByteArrayField.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/java/org/apache/poi/util/ByteArrayField.java 29 Oct 2003 22:56:18 -0000 >@@ -0,0 +1,89 @@ >+package org.apache.poi.util; >+ >+import java.io.*; >+ >+public class ByteArrayField >+ implements FixedField >+{ >+ >+ private byte[] _value; >+ private final int _offset; >+ >+ public ByteArrayField(final int offset, final int length) >+ throws ArrayIndexOutOfBoundsException >+ { >+ if (offset < 0) >+ { >+ throw new ArrayIndexOutOfBoundsException("negative offset"); >+ } >+ _offset = offset; >+ >+ if (length < 1) >+ { >+ throw new ArrayIndexOutOfBoundsException("negative or zero length"); >+ } >+ _value = new byte[length]; >+ } >+ >+ public ByteArrayField(final int offset, final int length, final byte[] data) >+ { >+ this(offset,length); >+ readFromBytes(data); >+ } >+ >+ public ByteArrayField(final int offset, final byte[] value, final byte[] data) >+ { >+ this(offset,value.length); >+ set(value,data); >+ } >+ >+ public byte[] get() >+ throws ArrayIndexOutOfBoundsException >+ { >+ byte[] data = new byte[_value.length]; >+ System.arraycopy(_value, 0, data, 0, _value.length); >+ return data; >+ } >+ >+ public void set(final byte[] data) >+ throws ArrayIndexOutOfBoundsException >+ { >+ System.arraycopy(data, 0, _value, 0, Math.min(data.length, _value.length)); >+ } >+ >+ public void set(final byte[] value, final byte[] data) >+ throws ArrayIndexOutOfBoundsException >+ { >+ set(value); >+ writeToBytes(data); >+ } >+ >+ public void readFromBytes(byte [] data) >+ throws ArrayIndexOutOfBoundsException >+ { >+ System.arraycopy(data, _offset, _value, 0, _value.length); >+ }; >+ >+ public void readFromStream(InputStream stream) >+ throws IOException, LittleEndian.BufferUnderrunException >+ { >+ stream.read(_value, 0, _value.length); >+ } >+ >+ public void writeToBytes(byte [] data) >+ throws ArrayIndexOutOfBoundsException >+ { >+ System.arraycopy(_value, 0, data, _offset, _value.length); >+ } >+ >+ public String toString() >+ { >+ StringBuffer retVal = new StringBuffer(); >+ for(int x = 0; x < _value.length; x++) >+ { >+ retVal.append(HexDump.toHex(_value[x])); >+ } >+ return retVal.toString(); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 24183
:
8772
| 8807