diff --git a/src/java/org/apache/poi/hpsf/Property.java b/src/java/org/apache/poi/hpsf/Property.java index c88a3f6d9..073ac791d 100644 --- a/src/java/org/apache/poi/hpsf/Property.java +++ b/src/java/org/apache/poi/hpsf/Property.java @@ -66,46 +66,45 @@ import java.util.*; import org.apache.poi.util.LittleEndian; /** - *
+ *
A property in a {@link Section} of a {@link PropertySet}.
* - * A property in a {@link Section} of a {@link PropertySet}.+ *
The property's ID gives the property a meaning + * in the context of its {@link Section}. Each {@link Section} spans + * its own name space of property IDs.
* - * The property's ID gives the property a meaning in the - * context of its {@link Section}. Each {@link Section} spans its own name - * space of property IDs.+ *
The property's type determines how its + * value is interpreted. For example, if the type is + * {@link Variant#VT_LPSTR} (byte string), the value consists of a + * {@link DWord} telling how many bytes the string contains. The bytes + * follow immediately, including any null bytes that terminate the + * string. The type {@link Variant#VT_I4} denotes a four-byte integer + * value, {@link Variant#VT_FILETIME} some date and time (of a + * file).
* - * The property's type determines how its value - * is interpreted. For example, if the type is {@link - * Variant#VT_LPSTR} (byte string), the value consists of a {@link DWord} - * telling how many bytes the string contains. The bytes follow immediately, - * including any null bytes that terminate the string. The type {@link - * Variant#VT_I4} denotes a four-byte integer value, {@link - * Variant#VT_FILETIME} some date and time (of a file).+ *
FIXME: Reading of other types than those + * mentioned above and the dictionary property is not yet + * implemented.
* - * FIXME: Reading of other types than those mentioned above - * and the dictionary property is not yet implemented. - * - *@author Rainer Klute (klute@rainer-klute.de) - *@author Drew Varner (Drew.Varner InAndAround sc.edu) - *@created May 10, 2002 - *@see Section - *@see Variant - *@version $Id$ - *@since 2002-02-09 + * @author Rainer Klute (klute@rainer-klute.de) + * @author Drew Varner (Drew.Varner InAndAround sc.edu) + * @see Section + * @see Variant + * @version $Id$ + * @since 2002-02-09 */ -public class Property { +public class Property +{ private int id; /** - *+ *
Returns the property's ID.
* - * Returns the property's ID. - * - *@return The iD value + * @return The ID value */ - public int getID() { + public int getID() + { return id; } @@ -115,13 +114,12 @@ public class Property { /** - *+ *
Returns the property's type.
* - * Returns the property's type. - * - *@return The type value + * @return The type value */ - public long getType() { + public long getType() + { return type; } @@ -131,38 +129,38 @@ public class Property { /** - *+ *
Returns the property's value.
* - * Returns the property value's. - * - *@return The value value + * @return The property's value */ - public Object getValue() { + public Object getValue() + { return value; } /** - *+ *
Creates a {@link Property} instance by reading its bytes + * from the property set stream.
* - * Creates a {@link Property} instance by reading its bytes from the - * property set stream. - * - *@param id The property's ID. - *@param src The bytes the property set stream consists of. - *@param offset The property's type/value pair's offset in the section. - *@param length The property's type/value pair's length in bytes. list. + * @param id The property's ID. + * @param src The bytes the property set stream consists of. + * @param offset The property's type/value pair's offset in the + * section. + * @param length The property's type/value pair's length in bytes. */ public Property(final int id, final byte[] src, final long offset, - int length) { + int length) + { this.id = id; /* * ID 0 is a special case since it specifies a dictionary of * property IDs and property names. */ - if (id == 0) { + if (id == 0) + { value = readDictionary(src, offset, length); return; } @@ -237,10 +235,9 @@ public class Property { length = length - LittleEndian.INT_SIZE; final byte[] v = new byte[length]; - for (int i = 0; i < length; i++) { + for (int i = 0; i < length; i++) v[i] = src[(int)(o + i)]; - } - value = v; + value = v; break; } case Variant.VT_BOOL: @@ -252,24 +249,18 @@ public class Property { */ final int first = o + LittleEndian.INT_SIZE; long bool = LittleEndian.getUInt(src, o); - if (bool == -1) { + if (bool != 0) value = new Boolean(true); - } else if (bool == 0) { + else value = new Boolean(false); - } else { - throw new IllegalPropertySetDataException - ("Illegal property set data: A boolean must be " + - "either -1 (true) or 0 (false)."); - } - break; + break; } default: { final byte[] v = new byte[length]; - for (int i = 0; i < length; i++) { + for (int i = 0; i < length; i++) v[i] = src[(int)(offset + i)]; - } - value = v; + value = v; break; } } @@ -278,19 +269,18 @@ public class Property { /** - *+ *
Reads a dictionary.
* - * Reads a dictionary. - * - *@param src The byte array containing the bytes making out the - * dictionary. - *@param offset At this offset within src the dictionary - * starts. - *@param length The dictionary contains at most this many bytes. - *@return Description of the Return Value + * @param src The byte array containing the bytes making out the + * dictionary. + * @param offset At this offset within src the + * dictionary starts. + * @param length The dictionary contains at most this many bytes. + * @return The dictonary */ protected Map readDictionary(final byte[] src, final long offset, - final int length) { + final int length) + { /* * FIXME: Check the length! */ @@ -303,7 +293,8 @@ public class Property { o += LittleEndian.INT_SIZE; final Map m = new HashMap((int)nrEntries, (float) 1.0); - for (int i = 0; i < nrEntries; i++) { + for (int i = 0; i < nrEntries; i++) + { /* * The key */ @@ -315,13 +306,13 @@ public class Property { */ final long sLength = LittleEndian.getUInt(src, o); o += LittleEndian.INT_SIZE; + /* * Strip trailing 0x00 bytes. */ long l = sLength; - while (src[(int)(o + l - 1)] == 0x00) { + while (src[(int)(o + l - 1)] == 0x00) l--; - } final String s = new String(src, o, (int)l); o += sLength; m.put(id, s); @@ -332,16 +323,16 @@ public class Property { /** - *+ *
Reads a code page.
* - * Reads a code page. - * - *@param src The byte array containing the bytes making out the code - * page. - *@param offset At this offset within src the code page starts. - *@return Description of the Return Value + * @param src The byte array containing the bytes making out the + * code page. + * @param offset At this offset within src the code + * page starts. + * @return The code page. */ - protected int readCodePage(final byte[] src, final long offset) { + protected int readCodePage(final byte[] src, final long offset) + { throw new UnsupportedOperationException("FIXME"); }