From 78e643fe2184d931b08120ee5f29e2b2e9daf3c1 Mon Sep 17 00:00:00 2001
From: Josh Micich
Open the POI filesystem.
Read the summary information.
Read and print the "author" property.
Change the author to "Rainer Klute".
Read the document summary information.
Read and print the "category" property.
Change the category to "POI example".
Read the custom properties (if available).
Insert a new custom property.
Write the custom properties back to the document summary * information.
Write the summary information to the POI filesystem.
Write the document summary information to the POI filesystem.
Write the POI filesystem back to the original file.
Main method - see class description.
* * @param args The command-line parameters. - * @throws IOException - * @throws MarkUnsupportedException - * @throws NoPropertySetStreamException - * @throws UnexpectedPropertySetTypeException - * @throws WritingNotSupportedException + * @throws IOException + * @throws MarkUnsupportedException + * @throws NoPropertySetStreamException + * @throws UnexpectedPropertySetTypeException + * @throws WritingNotSupportedException */ public static void main(final String[] args) throws IOException, NoPropertySetStreamException, MarkUnsupportedException, @@ -165,12 +164,12 @@ public class ModifyDocumentSummaryInformation CustomProperties customProperties = dsi.getCustomProperties(); if (customProperties == null) customProperties = new CustomProperties(); - + /* Insert some custom properties into the container. */ customProperties.put("Key 1", "Value 1"); customProperties.put("Schl\u00fcssel 2", "Wert 2"); customProperties.put("Sample Number", new Integer(12345)); - customProperties.put("Sample Boolean", new Boolean(true)); + customProperties.put("Sample Boolean", Boolean.TRUE); customProperties.put("Sample Date", new Date()); /* Read a custom property. */ @@ -191,6 +190,5 @@ public class ModifyDocumentSummaryInformation OutputStream out = new FileOutputStream(poiFilesystem); poifs.writeFilesystem(out); out.close(); - } - + } } diff --git a/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java b/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java index 57e8c6d32b..c5d21edd23 100644 --- a/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java +++ b/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java @@ -89,7 +89,7 @@ public class DefaultEscherRecordFactory implements EscherRecordFactory { return r; } - Constructor extends EscherRecord> recordConstructor = recordsMap.get(new Short(header.getRecordId())); + Constructor extends EscherRecord> recordConstructor = recordsMap.get(Short.valueOf(header.getRecordId())); EscherRecord escherRecord = null; if (recordConstructor == null) { return new UnknownEscherRecord(); @@ -135,7 +135,7 @@ public class DefaultEscherRecordFactory implements EscherRecordFactory { } catch (NoSuchMethodException e) { throw new RuntimeException(e); } - result.put(new Short(sid), constructor); + result.put(Short.valueOf(sid), constructor); } return result; } diff --git a/src/java/org/apache/poi/ddf/EscherOptRecord.java b/src/java/org/apache/poi/ddf/EscherOptRecord.java index 157375a4ea..916afb985a 100644 --- a/src/java/org/apache/poi/ddf/EscherOptRecord.java +++ b/src/java/org/apache/poi/ddf/EscherOptRecord.java @@ -158,7 +158,7 @@ public class EscherOptRecord { EscherProperty p1 = (EscherProperty) o1; EscherProperty p2 = (EscherProperty) o2; - return new Short( p1.getPropertyNumber() ).compareTo( new Short( p2.getPropertyNumber() ) ); + return Short.valueOf( p1.getPropertyNumber() ).compareTo( Short.valueOf( p2.getPropertyNumber() ) ); } } ); } diff --git a/src/java/org/apache/poi/ddf/EscherProperties.java b/src/java/org/apache/poi/ddf/EscherProperties.java index 458e83d3be..767e92be98 100644 --- a/src/java/org/apache/poi/ddf/EscherProperties.java +++ b/src/java/org/apache/poi/ddf/EscherProperties.java @@ -586,20 +586,20 @@ public final class EscherProperties { } private static void addProp(MapWhile this class provides a simple API to custom properties, it ignores * the fact that not names, but IDs are the real keys to properties. Under the * hood this class maintains a 1:1 relationship between IDs and names. Therefore @@ -41,14 +41,14 @@ import org.apache.poi.hpsf.wellknown.PropertyIDMap; * mapping to the same name or with properties without a name: the result will * contain only a subset of the original properties. If you really need to deal * such property sets, use HPSF's low-level access methods.
- * + * *An application can call the {@link #isPure} method to check whether a * property set parsed by {@link CustomProperties} is still pure (i.e. * unmodified) or whether one or more properties have been dropped.
- * + * *This class is not thread-safe; concurrent access to instances of this * class must be synchronized.
- * + * * @author Rainer Klute <klute@rainer-klute.de> */ @@ -64,7 +64,7 @@ public class CustomProperties extends HashMap *Maps property names to property IDs.
*/ private Map dictionaryNameToID = new HashMap(); - + /** *Tells whether this object is pure or not.
*/ @@ -96,7 +96,7 @@ public class CustomProperties extends HashMap ") do not match."); /* Register name and ID in the dictionary. Mapping in both directions is possible. If there is already a */ - final Long idKey = new Long(cp.getID()); + final Long idKey = Long.valueOf(cp.getID()); final Object oldID = dictionaryNameToID.get(name); dictionaryIDToName.remove(oldID); dictionaryNameToID.put(name, idKey); @@ -113,16 +113,16 @@ public class CustomProperties extends HashMap /** *Puts a {@link CustomProperty} that has not yet a valid ID into this * map. The method will allocate a suitable ID for the custom property:
- * + * *If there is already a property with the same name, take the ID * of that property.
Otherwise find the highest ID and use its value plus one.
Removes a custom property.
- * @param name The name of the custom property to remove + * @param name The name of the custom property to remove * @return The removed property ornull
if the specified property was not found.
*
* @see java.util.HashSet#remove(java.lang.Object)
@@ -170,7 +170,7 @@ public class CustomProperties extends HashMap
/**
* Adds a named string property.
- * + * * @param name The property's name. * @param value The property's value. * @return the property that was stored under the specified name before, or @@ -258,10 +258,10 @@ public class CustomProperties extends HashMap return put(cp); } - + /** *Gets a named value from the custom properties.
- * + * * @param name the name of the value to get * @return the value ornull
if a value with the specified
* name is not found in the custom properties.
@@ -292,18 +292,18 @@ public class CustomProperties extends HashMap
final CustomProperty cp = new CustomProperty(p, name);
return put(cp);
}
-
+
/**
* Returns a set of all the names of our
* custom properties
*/
public Set keySet() {
- return dictionaryNameToID.keySet();
- }
+ return dictionaryNameToID.keySet();
+ }
- /**
+ /**
* Sets the codepage.
* * @param codepage the codepage @@ -313,7 +313,7 @@ public class CustomProperties extends HashMap final MutableProperty p = new MutableProperty(); p.setID(PropertyIDMap.PID_CODEPAGE); p.setType(Variant.VT_I2); - p.setValue(new Integer(codepage)); + p.setValue(Integer.valueOf(codepage)); put(new CustomProperty(p)); } @@ -322,7 +322,7 @@ public class CustomProperties extends HashMap /** *Gets the dictionary which contains IDs and names of the named custom * properties. - * + * * @return the dictionary. */ Map getDictionary() @@ -355,7 +355,7 @@ public class CustomProperties extends HashMap *
Tells whether this {@link CustomProperties} instance is pure or one or * more properties of the underlying low-level property set has been * dropped.
- * + * * @returntrue
if the {@link CustomProperties} is pure, else
* false
.
*/
@@ -373,5 +373,4 @@ public class CustomProperties extends HashMap
{
this.isPure = isPure;
}
-
}
diff --git a/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java b/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
index 016870a9e4..bfee086e45 100644
--- a/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
+++ b/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
@@ -567,9 +567,8 @@ public class DocumentSummaryInformation extends SpecialPropertySet
/**
* Gets the custom properties.
- * + * * @return The custom properties. - * @since 2006-02-09 */ public CustomProperties getCustomProperties() { @@ -589,7 +588,7 @@ public class DocumentSummaryInformation extends SpecialPropertySet { propertyCount++; final CustomProperty cp = new CustomProperty(p, - (String) dictionary.get(new Long(id))); + (String) dictionary.get(Long.valueOf(id))); cps.put(cp.getName(), cp); } } @@ -601,9 +600,8 @@ public class DocumentSummaryInformation extends SpecialPropertySet /** *Sets the custom properties.
- * + * * @param customProperties The custom properties - * @since 2006-02-07 */ public void setCustomProperties(final CustomProperties customProperties) { @@ -650,8 +648,6 @@ public class DocumentSummaryInformation extends SpecialPropertySet /** *Removes the custom properties.
- * - * @since 2006-02-08 */ public void removeCustomProperties() { @@ -674,5 +670,4 @@ public class DocumentSummaryInformation extends SpecialPropertySet { throw new UnsupportedOperationException(msg + " is not yet implemented."); } - } diff --git a/src/java/org/apache/poi/hpsf/MutableSection.java b/src/java/org/apache/poi/hpsf/MutableSection.java index 084896ff64..0e521dc44d 100644 --- a/src/java/org/apache/poi/hpsf/MutableSection.java +++ b/src/java/org/apache/poi/hpsf/MutableSection.java @@ -80,11 +80,11 @@ public class MutableSection extends Section /** - *Constructs a MutableSection
by doing a deep copy of an
- * existing Section
. All nested Property
+ *
Constructs a MutableSection
by doing a deep copy of an
+ * existing Section
. All nested Property
* instances, will be their mutable counterparts in the new
* MutableSection
.
Writes this section into an output stream.
- * + * *Internally this is done by writing into three byte array output * streams: one for the properties, one for the property list and one for * the section as such. The two former are appended to the latter when they @@ -390,7 +390,7 @@ public class MutableSection extends Section * "propertyListStream". */ final ByteArrayOutputStream propertyListStream = new ByteArrayOutputStream(); - + /* Maintain the current position in the list. */ int position = 0; @@ -418,7 +418,7 @@ public class MutableSection extends Section * dictionary is present. In order to cope with this problem we * add the codepage property and set it to Unicode. */ setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2, - new Integer(Constants.CP_UNICODE)); + Integer.valueOf(Constants.CP_UNICODE)); codepage = getCodepage(); } @@ -444,7 +444,7 @@ public class MutableSection extends Section { final MutableProperty p = (MutableProperty) i.next(); final long id = p.getID(); - + /* Write the property list entry. */ TypeWriter.writeUIntToStream(propertyListStream, p.getID()); TypeWriter.writeUIntToStream(propertyListStream, position); @@ -472,17 +472,17 @@ public class MutableSection extends Section /* Write the section: */ byte[] pb1 = propertyListStream.toByteArray(); byte[] pb2 = propertyStream.toByteArray(); - + /* Write the section's length: */ TypeWriter.writeToStream(out, LittleEndian.INT_SIZE * 2 + pb1.length + pb2.length); - + /* Write the section's number of properties: */ TypeWriter.writeToStream(out, getPropertyCount()); - + /* Write the property list: */ out.write(pb1); - + /* Write the properties: */ out.write(pb2); @@ -562,7 +562,7 @@ public class MutableSection extends Section *
Overwrites the super class' method to cope with a redundancy: * the property count is maintained in a separate member variable, but * shouldn't.
- * + * * @return The number of properties in this section */ public int getPropertyCount() @@ -574,7 +574,7 @@ public class MutableSection extends Section /** *Gets this section's properties.
- * + * * @return this section's properties. */ public Property[] getProperties() @@ -587,7 +587,7 @@ public class MutableSection extends Section /** *Gets a property.
- * + * * @param id The ID of the property to get * @return The property ornull
if there is no such property
*/
@@ -611,10 +611,10 @@ public class MutableSection extends Section
* method.
*
* @param dictionary The dictionary
- *
+ *
* @exception IllegalPropertySetDataException if the dictionary's key and
* value types are not correct.
- *
+ *
* @see Section#getDictionary()
*/
public void setDictionary(final Map dictionary)
@@ -646,7 +646,7 @@ public class MutableSection extends Section
(Integer) getProperty(PropertyIDMap.PID_CODEPAGE);
if (codepage == null)
setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2,
- new Integer(Constants.CP_UNICODE));
+ Integer.valueOf(Constants.CP_UNICODE));
}
else
/* Setting the dictionary to null means to remove property 0.
@@ -658,7 +658,7 @@ public class MutableSection extends Section
/**
* Sets a property.
- * + * * @param id The property ID. * @param value The property's value. The value's class must be one of those * supported by HPSF. @@ -707,7 +707,6 @@ public class MutableSection extends Section public void setCodepage(final int codepage) { setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2, - new Integer(codepage)); + Integer.valueOf(codepage)); } - } diff --git a/src/java/org/apache/poi/hpsf/Property.java b/src/java/org/apache/poi/hpsf/Property.java index 38ce0d5660..c06a807ef3 100644 --- a/src/java/org/apache/poi/hpsf/Property.java +++ b/src/java/org/apache/poi/hpsf/Property.java @@ -217,7 +217,7 @@ public class Property for (int i = 0; i < nrEntries; i++) { /* The key. */ - final Long id = new Long(LittleEndian.getUInt(src, o)); + final Long id = Long.valueOf(LittleEndian.getUInt(src, o)); o += LittleEndian.INT_SIZE; /* The value (a string). The length is the either the diff --git a/src/java/org/apache/poi/hpsf/Section.java b/src/java/org/apache/poi/hpsf/Section.java index 525450e799..917929a64a 100644 --- a/src/java/org/apache/poi/hpsf/Section.java +++ b/src/java/org/apache/poi/hpsf/Section.java @@ -278,7 +278,7 @@ public class Section this.offset + ple.offset, ple.length, codepage); if (p.getID() == PropertyIDMap.PID_CODEPAGE) - p = new Property(p.getID(), p.getType(), new Integer(codepage)); + p = new Property(p.getID(), p.getType(), Integer.valueOf(codepage)); properties[i1++] = p; } @@ -450,7 +450,7 @@ public class Section { String s = null; if (dictionary != null) - s = (String) dictionary.get(new Long(pid)); + s = (String) dictionary.get(Long.valueOf(pid)); if (s == null) s = SectionIDMap.getPIDString(getFormatID().getBytes(), pid); if (s == null) diff --git a/src/java/org/apache/poi/hpsf/Variant.java b/src/java/org/apache/poi/hpsf/Variant.java index 358924130a..a37cbf0479 100644 --- a/src/java/org/apache/poi/hpsf/Variant.java +++ b/src/java/org/apache/poi/hpsf/Variant.java @@ -351,32 +351,32 @@ public class Variant /** *Denotes a variant type with a length that is unknown to HPSF yet.
*/ - public static final Integer LENGTH_UNKNOWN = new Integer(-2); + public static final Integer LENGTH_UNKNOWN = Integer.valueOf(-2); /** *Denotes a variant type with a variable length.
*/ - public static final Integer LENGTH_VARIABLE = new Integer(-1); + public static final Integer LENGTH_VARIABLE = Integer.valueOf(-1); /** *Denotes a variant type with a length of 0 bytes.
*/ - public static final Integer LENGTH_0 = new Integer(0); + public static final Integer LENGTH_0 = Integer.valueOf(0); /** *Denotes a variant type with a length of 2 bytes.
*/ - public static final Integer LENGTH_2 = new Integer(2); + public static final Integer LENGTH_2 = Integer.valueOf(2); /** *Denotes a variant type with a length of 4 bytes.
*/ - public static final Integer LENGTH_4 = new Integer(4); + public static final Integer LENGTH_4 = Integer.valueOf(4); /** *Denotes a variant type with a length of 8 bytes.
*/ - public static final Integer LENGTH_8 = new Integer(8); + public static final Integer LENGTH_8 = Integer.valueOf(8); @@ -384,92 +384,92 @@ public class Variant { /* Initialize the number-to-name map: */ Map tm1 = new HashMap(); - tm1.put(new Long(0), "VT_EMPTY"); - tm1.put(new Long(1), "VT_NULL"); - tm1.put(new Long(2), "VT_I2"); - tm1.put(new Long(3), "VT_I4"); - tm1.put(new Long(4), "VT_R4"); - tm1.put(new Long(5), "VT_R8"); - tm1.put(new Long(6), "VT_CY"); - tm1.put(new Long(7), "VT_DATE"); - tm1.put(new Long(8), "VT_BSTR"); - tm1.put(new Long(9), "VT_DISPATCH"); - tm1.put(new Long(10), "VT_ERROR"); - tm1.put(new Long(11), "VT_BOOL"); - tm1.put(new Long(12), "VT_VARIANT"); - tm1.put(new Long(13), "VT_UNKNOWN"); - tm1.put(new Long(14), "VT_DECIMAL"); - tm1.put(new Long(16), "VT_I1"); - tm1.put(new Long(17), "VT_UI1"); - tm1.put(new Long(18), "VT_UI2"); - tm1.put(new Long(19), "VT_UI4"); - tm1.put(new Long(20), "VT_I8"); - tm1.put(new Long(21), "VT_UI8"); - tm1.put(new Long(22), "VT_INT"); - tm1.put(new Long(23), "VT_UINT"); - tm1.put(new Long(24), "VT_VOID"); - tm1.put(new Long(25), "VT_HRESULT"); - tm1.put(new Long(26), "VT_PTR"); - tm1.put(new Long(27), "VT_SAFEARRAY"); - tm1.put(new Long(28), "VT_CARRAY"); - tm1.put(new Long(29), "VT_USERDEFINED"); - tm1.put(new Long(30), "VT_LPSTR"); - tm1.put(new Long(31), "VT_LPWSTR"); - tm1.put(new Long(64), "VT_FILETIME"); - tm1.put(new Long(65), "VT_BLOB"); - tm1.put(new Long(66), "VT_STREAM"); - tm1.put(new Long(67), "VT_STORAGE"); - tm1.put(new Long(68), "VT_STREAMED_OBJECT"); - tm1.put(new Long(69), "VT_STORED_OBJECT"); - tm1.put(new Long(70), "VT_BLOB_OBJECT"); - tm1.put(new Long(71), "VT_CF"); - tm1.put(new Long(72), "VT_CLSID"); + tm1.put(Long.valueOf(0), "VT_EMPTY"); + tm1.put(Long.valueOf(1), "VT_NULL"); + tm1.put(Long.valueOf(2), "VT_I2"); + tm1.put(Long.valueOf(3), "VT_I4"); + tm1.put(Long.valueOf(4), "VT_R4"); + tm1.put(Long.valueOf(5), "VT_R8"); + tm1.put(Long.valueOf(6), "VT_CY"); + tm1.put(Long.valueOf(7), "VT_DATE"); + tm1.put(Long.valueOf(8), "VT_BSTR"); + tm1.put(Long.valueOf(9), "VT_DISPATCH"); + tm1.put(Long.valueOf(10), "VT_ERROR"); + tm1.put(Long.valueOf(11), "VT_BOOL"); + tm1.put(Long.valueOf(12), "VT_VARIANT"); + tm1.put(Long.valueOf(13), "VT_UNKNOWN"); + tm1.put(Long.valueOf(14), "VT_DECIMAL"); + tm1.put(Long.valueOf(16), "VT_I1"); + tm1.put(Long.valueOf(17), "VT_UI1"); + tm1.put(Long.valueOf(18), "VT_UI2"); + tm1.put(Long.valueOf(19), "VT_UI4"); + tm1.put(Long.valueOf(20), "VT_I8"); + tm1.put(Long.valueOf(21), "VT_UI8"); + tm1.put(Long.valueOf(22), "VT_INT"); + tm1.put(Long.valueOf(23), "VT_UINT"); + tm1.put(Long.valueOf(24), "VT_VOID"); + tm1.put(Long.valueOf(25), "VT_HRESULT"); + tm1.put(Long.valueOf(26), "VT_PTR"); + tm1.put(Long.valueOf(27), "VT_SAFEARRAY"); + tm1.put(Long.valueOf(28), "VT_CARRAY"); + tm1.put(Long.valueOf(29), "VT_USERDEFINED"); + tm1.put(Long.valueOf(30), "VT_LPSTR"); + tm1.put(Long.valueOf(31), "VT_LPWSTR"); + tm1.put(Long.valueOf(64), "VT_FILETIME"); + tm1.put(Long.valueOf(65), "VT_BLOB"); + tm1.put(Long.valueOf(66), "VT_STREAM"); + tm1.put(Long.valueOf(67), "VT_STORAGE"); + tm1.put(Long.valueOf(68), "VT_STREAMED_OBJECT"); + tm1.put(Long.valueOf(69), "VT_STORED_OBJECT"); + tm1.put(Long.valueOf(70), "VT_BLOB_OBJECT"); + tm1.put(Long.valueOf(71), "VT_CF"); + tm1.put(Long.valueOf(72), "VT_CLSID"); Map tm2 = new HashMap(tm1.size(), 1.0F); tm2.putAll(tm1); numberToName = Collections.unmodifiableMap(tm2); /* Initialize the number-to-length map: */ tm1.clear(); - tm1.put(new Long(0), LENGTH_0); - tm1.put(new Long(1), LENGTH_UNKNOWN); - tm1.put(new Long(2), LENGTH_2); - tm1.put(new Long(3), LENGTH_4); - tm1.put(new Long(4), LENGTH_4); - tm1.put(new Long(5), LENGTH_8); - tm1.put(new Long(6), LENGTH_UNKNOWN); - tm1.put(new Long(7), LENGTH_UNKNOWN); - tm1.put(new Long(8), LENGTH_UNKNOWN); - tm1.put(new Long(9), LENGTH_UNKNOWN); - tm1.put(new Long(10), LENGTH_UNKNOWN); - tm1.put(new Long(11), LENGTH_UNKNOWN); - tm1.put(new Long(12), LENGTH_UNKNOWN); - tm1.put(new Long(13), LENGTH_UNKNOWN); - tm1.put(new Long(14), LENGTH_UNKNOWN); - tm1.put(new Long(16), LENGTH_UNKNOWN); - tm1.put(new Long(17), LENGTH_UNKNOWN); - tm1.put(new Long(18), LENGTH_UNKNOWN); - tm1.put(new Long(19), LENGTH_UNKNOWN); - tm1.put(new Long(20), LENGTH_UNKNOWN); - tm1.put(new Long(21), LENGTH_UNKNOWN); - tm1.put(new Long(22), LENGTH_UNKNOWN); - tm1.put(new Long(23), LENGTH_UNKNOWN); - tm1.put(new Long(24), LENGTH_UNKNOWN); - tm1.put(new Long(25), LENGTH_UNKNOWN); - tm1.put(new Long(26), LENGTH_UNKNOWN); - tm1.put(new Long(27), LENGTH_UNKNOWN); - tm1.put(new Long(28), LENGTH_UNKNOWN); - tm1.put(new Long(29), LENGTH_UNKNOWN); - tm1.put(new Long(30), LENGTH_VARIABLE); - tm1.put(new Long(31), LENGTH_UNKNOWN); - tm1.put(new Long(64), LENGTH_8); - tm1.put(new Long(65), LENGTH_UNKNOWN); - tm1.put(new Long(66), LENGTH_UNKNOWN); - tm1.put(new Long(67), LENGTH_UNKNOWN); - tm1.put(new Long(68), LENGTH_UNKNOWN); - tm1.put(new Long(69), LENGTH_UNKNOWN); - tm1.put(new Long(70), LENGTH_UNKNOWN); - tm1.put(new Long(71), LENGTH_UNKNOWN); - tm1.put(new Long(72), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(0), LENGTH_0); + tm1.put(Long.valueOf(1), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(2), LENGTH_2); + tm1.put(Long.valueOf(3), LENGTH_4); + tm1.put(Long.valueOf(4), LENGTH_4); + tm1.put(Long.valueOf(5), LENGTH_8); + tm1.put(Long.valueOf(6), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(7), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(8), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(9), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(10), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(11), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(12), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(13), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(14), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(16), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(17), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(18), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(19), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(20), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(21), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(22), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(23), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(24), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(25), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(26), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(27), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(28), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(29), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(30), LENGTH_VARIABLE); + tm1.put(Long.valueOf(31), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(64), LENGTH_8); + tm1.put(Long.valueOf(65), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(66), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(67), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(68), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(69), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(70), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(71), LENGTH_UNKNOWN); + tm1.put(Long.valueOf(72), LENGTH_UNKNOWN); tm2 = new HashMap(tm1.size(), 1.0F); tm2.putAll(tm1); numberToLength = Collections.unmodifiableMap(tm2); @@ -486,7 +486,7 @@ public class Variant */ public static String getVariantName(final long variantType) { - final String name = (String) numberToName.get(new Long(variantType)); + final String name = (String) numberToName.get(Long.valueOf(variantType)); return name != null ? name : "unknown variant type"; } @@ -501,7 +501,7 @@ public class Variant */ public static int getVariantLength(final long variantType) { - final Long key = new Long((int) variantType); + final Long key = Long.valueOf((int) variantType); final Long length = (Long) numberToLength.get(key); if (length == null) return -2; diff --git a/src/java/org/apache/poi/hpsf/VariantSupport.java b/src/java/org/apache/poi/hpsf/VariantSupport.java index e96e6739df..c01b3c57c5 100644 --- a/src/java/org/apache/poi/hpsf/VariantSupport.java +++ b/src/java/org/apache/poi/hpsf/VariantSupport.java @@ -29,10 +29,10 @@ import org.apache.poi.util.LittleEndianConsts; /** *Supports reading and writing of variant data.
- * + * *FIXME (3): Reading and writing should be made more * uniform than it is now. The following items should be resolved: - * + * *
Reading requires a length parameter that is 4 byte greater than the @@ -68,7 +68,7 @@ public class VariantSupport extends Variant * on or off.
* * @returntrue
if logging is turned on, else
- * false
.
+ * false
.
*/
public static boolean isLogUnsupportedTypes()
{
@@ -97,7 +97,7 @@ public class VariantSupport extends Variant
{
if (unsupportedMessage == null)
unsupportedMessage = new LinkedList();
- Long vt = new Long(ex.getVariantType());
+ Long vt = Long.valueOf(ex.getVariantType());
if (!unsupportedMessage.contains(vt))
{
System.err.println(ex.getMessage());
@@ -121,7 +121,7 @@ public class VariantSupport extends Variant
* Checks whether HPSF supports the specified variant type. Unsupported * types should be implemented included in the {@link #SUPPORTED_TYPES} * array.
- * + * * @see Variant * @param variantType the variant type to check * @returntrue
if HPFS supports this type, else
@@ -139,7 +139,7 @@ public class VariantSupport extends Variant
/**
* Reads a variant type from a byte array.
- * + * * @param src The byte array * @param offset The offset in the byte array where the variant starts * @param length The length of the variant including the variant type field @@ -182,7 +182,7 @@ public class VariantSupport extends Variant * Read a short. In Java it is represented as an * Integer object. */ - value = new Integer(LittleEndian.getShort(src, o1)); + value = Integer.valueOf(LittleEndian.getShort(src, o1)); break; } case Variant.VT_I4: @@ -191,7 +191,7 @@ public class VariantSupport extends Variant * Read a word. In Java it is represented as an * Integer object. */ - value = new Integer(LittleEndian.getInt(src, o1)); + value = Integer.valueOf(LittleEndian.getInt(src, o1)); break; } case Variant.VT_I8: @@ -200,7 +200,7 @@ public class VariantSupport extends Variant * Read a double word. In Java it is represented as a * Long object. */ - value = new Long(LittleEndian.getLong(src, o1)); + value = Long.valueOf(LittleEndian.getLong(src, o1)); break; } case Variant.VT_R8: @@ -279,7 +279,7 @@ public class VariantSupport extends Variant * while the current implementation calculates it in the Section constructor. * Test files in Bugzilla 42726 and 45583 clearly show that this approach does not always work. * The workaround below attempts to gracefully handle such cases instead of throwing exceptions. - * + * * August 20, 2009 */ l1 = LittleEndian.getInt(src, o1); o1 += LittleEndian.INT_SIZE; @@ -318,16 +318,16 @@ public class VariantSupport extends Variant /** - *Turns a codepage number into the equivalent character encoding's + *
Turns a codepage number into the equivalent character encoding's * name.
* * @param codepage The codepage number - * - * @return The character encoding's name. If the codepage number is 65001, + * + * @return The character encoding's name. If the codepage number is 65001, * the encoding name is "UTF-8". All other positive numbers are mapped to - * "cp" followed by the number, e.g. if the codepage number is 1252 the + * "cp" followed by the number, e.g. if the codepage number is 1252 the * returned character encoding name will be "cp1252". - * + * * @exception UnsupportedEncodingException if the specified codepage is * less than zero. */ @@ -500,7 +500,7 @@ public class VariantSupport extends Variant } case Variant.VT_LPWSTR: { - final int nrOfChars = ((String) value).length() + 1; + final int nrOfChars = ((String) value).length() + 1; length += TypeWriter.writeUIntToStream(out, nrOfChars); char[] s = Util.pad4((String) value); for (int i = 0; i < s.length; i++) @@ -546,7 +546,7 @@ public class VariantSupport extends Variant + value.getClass().toString() + ", " + value.toString()); } - length += TypeWriter.writeToStream(out, + length += TypeWriter.writeToStream(out, ((Integer) value).intValue()); break; } @@ -558,7 +558,7 @@ public class VariantSupport extends Variant } case Variant.VT_R8: { - length += TypeWriter.writeToStream(out, + length += TypeWriter.writeToStream(out, ((Double) value).doubleValue()); break; } @@ -579,7 +579,7 @@ public class VariantSupport extends Variant * is a byte array we can write it nevertheless. */ if (value instanceof byte[]) { - final byte[] b = (byte[]) value; + final byte[] b = (byte[]) value; out.write(b); length = b.length; writeUnsupportedTypeMessage @@ -593,5 +593,4 @@ public class VariantSupport extends Variant return length; } - } diff --git a/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java b/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java index 9c8fe488b9..4eef8c4b02 100644 --- a/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java +++ b/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java @@ -102,7 +102,7 @@ public class PropertyIDMap extends HashMap { /**ID of the property that denotes whether read/write access to the * document is allowed or whether is should be opened as read-only. It can * have the following values:
- * + * *