You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2010/12/30 03:35:11 UTC
svn commit: r1053791 [1/18] - in /poi/branches/NIO_32_BRANCH: ./
src/contrib/src/org/apache/poi/contrib/poibrowser/ src/java/org/apache/poi/
src/java/org/apache/poi/hpsf/ src/java/org/apache/poi/hpsf/extractor/
src/java/org/apache/poi/hssf/record/ src/...
Author: nick
Date: Thu Dec 30 02:35:06 2010
New Revision: 1053791
URL: http://svn.apache.org/viewvc?rev=1053791&view=rev
Log:
Backport the latest POIFS/NPOIFS code from trunk, along with Util to power it, and HPSF to use it. Also makes a few tweaks to let existing code compile against these new versions
Added:
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/common/POIFSBigBlockSize.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/dev/POIFSHeaderDumper.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/BlockStore.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/NPOIFSDocument.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/NPOIFSMiniStore.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/NPOIFSStream.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/ODocumentInputStream.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/Ole10Native.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/Ole10NativeException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/nio/
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/nio/ByteArrayBackedDataSource.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/nio/DataSource.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/property/NPropertyTable.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/property/PropertyTableBase.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/DataInputBlock.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/HeaderBlock.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/CloseIgnoringInputStream.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/DelayableLittleEndianOutput.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/FontMetricsDumper.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/Internal.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/LZWDecompresser.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/LittleEndianByteArrayInputStream.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/LittleEndianByteArrayOutputStream.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/LittleEndianInput.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/LittleEndianInputStream.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/LittleEndianOutput.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/LittleEndianOutputStream.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/RecordFormatException.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/POIDataSamples.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/data/BlockSize4096.zvi (with props)
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/data/BlockSize512.zvi (with props)
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/data/Notes.ole2 (with props)
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/data/ReferencesInvalidSectors.mpp (with props)
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/data/oleObject1.bin (with props)
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/data/protect.xlsx (with props)
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestOle10Native.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockReading.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockWriting.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java
Removed:
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockReader.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockWriter.java
Modified:
poi/branches/NIO_32_BRANCH/build.xml
poi/branches/NIO_32_BRANCH/src/contrib/src/org/apache/poi/contrib/poibrowser/TreeReaderListener.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/POIDocument.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/ClassID.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Constants.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/CustomProperties.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/CustomProperty.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/HPSFException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/HPSFRuntimeException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/IllegalPropertySetDataException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/IllegalVariantTypeException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MarkUnsupportedException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MissingSectionException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutableProperty.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutablePropertySet.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutableSection.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoFormatIDException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoPropertySetStreamException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoSingleSectionException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Property.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/PropertySet.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/PropertySetFactory.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/ReadingNotSupportedException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Section.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/SpecialPropertySet.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/SummaryInformation.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Thumbnail.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/TypeWriter.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/UnexpectedPropertySetTypeException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/UnsupportedVariantTypeException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Util.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Variant.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/VariantSupport.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/VariantTypeException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/WritingNotSupportedException.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hssf/record/StyleRecord.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/common/POIFSConstants.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/dev/POIFSDump.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/dev/POIFSLister.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/dev/POIFSViewable.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/DocumentOutputStream.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/POIFSDocument.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/POIFSDocumentPath.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/property/DirectoryProperty.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/property/Property.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/property/PropertyFactory.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/property/PropertyTable.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/property/RootProperty.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/BATBlock.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/BigBlock.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/BlockAllocationTableReader.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/BlockAllocationTableWriter.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/BlockList.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/BlockListImpl.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/DocumentBlock.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/HeaderBlockConstants.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/HeaderBlockWriter.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/PropertyBlock.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/RawDataBlock.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/RawDataBlockList.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/SmallBlockTableReader.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/SmallBlockTableWriter.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/SmallDocumentBlock.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/poifs/storage/SmallDocumentBlockList.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/ArrayUtil.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/BinaryTree.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/BitFieldFactory.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/HexDump.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/HexRead.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/IOUtils.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/IntList.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/IntMapper.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/LittleEndian.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/NullLogger.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/POILogFactory.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/POILogger.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/ShortList.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/StringUtil.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/SystemOutLogger.java
poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/util/TempFile.java
poi/branches/NIO_32_BRANCH/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
poi/branches/NIO_32_BRANCH/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
poi/branches/NIO_32_BRANCH/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/TestPOIDocumentMain.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/AllPOIFSFileSystemTests.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentNode.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPropertySorter.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/AllPOIFSPropertyTests.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestPropertyFactory.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestPropertyTable.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestRootProperty.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/LocalRawDataBlockList.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestBATBlock.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableWriter.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestDocumentBlock.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestPropertyBlock.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestRawDataBlock.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestRawDataBlockList.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestSmallBlockTableReader.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestSmallBlockTableWriter.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlockList.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/AllPOIUtilTests.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/DummyPOILogger.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/LocalTestNode.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestArrayUtil.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestBinaryTree.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestBitField.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestByteField.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestIntList.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestIntegerField.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestLittleEndian.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestPOILogFactory.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestPOILogger.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestShortField.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestShortList.java
poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/util/TestStringUtil.java
Modified: poi/branches/NIO_32_BRANCH/build.xml
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/build.xml?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/build.xml (original)
+++ poi/branches/NIO_32_BRANCH/build.xml Thu Dec 30 02:35:06 2010
@@ -119,11 +119,11 @@ under the License.
<property name="mavendist.poi.dir" location="build/maven-dist/poi"/>
<property name="mavendist.oap.dir" location="build/maven-dist/org.apache.poi"/>
<property name="jar.name" value="poi"/>
- <property name="version.id" value="3.2-FINAL"/>
+ <property name="version.id" value="3.2-NIObackport"/>
<property name="halt.on.test.failure" value="true"/>
- <property name="jdk.version.source" value="1.3"
+ <property name="jdk.version.source" value="1.5"
description="JDK version of source code"/>
- <property name="jdk.version.class" value="1.3"
+ <property name="jdk.version.class" value="1.5"
description="JDK version of generated class files"/>
Modified: poi/branches/NIO_32_BRANCH/src/contrib/src/org/apache/poi/contrib/poibrowser/TreeReaderListener.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/contrib/src/org/apache/poi/contrib/poibrowser/TreeReaderListener.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/contrib/src/org/apache/poi/contrib/poibrowser/TreeReaderListener.java (original)
+++ poi/branches/NIO_32_BRANCH/src/contrib/src/org/apache/poi/contrib/poibrowser/TreeReaderListener.java Thu Dec 30 02:35:06 2010
@@ -164,7 +164,7 @@ public class TreeReaderListener implemen
{
is.close();
}
- catch (IOException ex)
+ catch (Exception ex)
{
System.err.println
("Unexpected exception while closing " +
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/POIDocument.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/POIDocument.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/POIDocument.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/POIDocument.java Thu Dec 30 02:35:06 2010
@@ -20,6 +20,7 @@ package org.apache.poi;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.List;
@@ -47,27 +48,28 @@ import org.apache.poi.util.POILogger;
*/
public abstract class POIDocument {
/** Holds metadata on our document */
- protected SummaryInformation sInf;
+ private SummaryInformation sInf;
/** Holds further metadata on our document */
- protected DocumentSummaryInformation dsInf;
- /** The open POIFS FileSystem that contains our document */
- protected POIFSFileSystem filesystem;
+ private DocumentSummaryInformation dsInf;
/** The directory that our document lives in */
protected DirectoryNode directory;
/** For our own logging use */
- protected POILogger logger = POILogFactory.getLogger(this.getClass());
+ private final static POILogger logger = POILogFactory.getLogger(POIDocument.class);
/* Have the property streams been read yet? (Only done on-demand) */
- protected boolean initialized = false;
+ private boolean initialized = false;
- protected POIDocument(DirectoryNode dir, POIFSFileSystem fs) {
- this.filesystem = fs;
+ protected POIDocument(DirectoryNode dir) {
this.directory = dir;
}
+ @Deprecated
+ protected POIDocument(DirectoryNode dir, POIFSFileSystem fs) {
+ this.directory = dir;
+ }
protected POIDocument(POIFSFileSystem fs) {
- this(fs.getRoot(), fs);
+ this(fs.getRoot());
}
/**
@@ -85,6 +87,25 @@ public abstract class POIDocument {
if(!initialized) readProperties();
return sInf;
}
+
+ /**
+ * Will create whichever of SummaryInformation
+ * and DocumentSummaryInformation (HPSF) properties
+ * are not already part of your document.
+ * This is normally useful when creating a new
+ * document from scratch.
+ * If the information properties are already there,
+ * then nothing will happen.
+ */
+ public void createInformationProperties() {
+ if(!initialized) readProperties();
+ if(sInf == null) {
+ sInf = PropertySetFactory.newSummaryInformation();
+ }
+ if(dsInf == null) {
+ dsInf = PropertySetFactory.newDocumentSummaryInformation();
+ }
+ }
/**
* Find, and create objects for, the standard
@@ -120,28 +141,31 @@ public abstract class POIDocument {
* if it wasn't found
*/
protected PropertySet getPropertySet(String setName) {
- DocumentInputStream dis;
- try {
- // Find the entry, and get an input stream for it
- dis = directory.createDocumentInputStream(setName);
- } catch(IOException ie) {
- // Oh well, doesn't exist
- logger.log(POILogger.WARN, "Error getting property set with name " + setName + "\n" + ie);
- return null;
- }
+ //directory can be null when creating new documents
+ if(directory == null) return null;
- try {
- // Create the Property Set
- PropertySet set = PropertySetFactory.create(dis);
- return set;
- } catch(IOException ie) {
- // Must be corrupt or something like that
- logger.log(POILogger.WARN, "Error creating property set with name " + setName + "\n" + ie);
- } catch(org.apache.poi.hpsf.HPSFException he) {
- // Oh well, doesn't exist
- logger.log(POILogger.WARN, "Error creating property set with name " + setName + "\n" + he);
- }
- return null;
+ DocumentInputStream dis;
+ try {
+ // Find the entry, and get an input stream for it
+ dis = directory.createDocumentInputStream( directory.getEntry(setName) );
+ } catch(IOException ie) {
+ // Oh well, doesn't exist
+ logger.log(POILogger.WARN, "Error getting property set with name " + setName + "\n" + ie);
+ return null;
+ }
+
+ try {
+ // Create the Property Set
+ PropertySet set = PropertySetFactory.create(dis);
+ return set;
+ } catch(IOException ie) {
+ // Must be corrupt or something like that
+ logger.log(POILogger.WARN, "Error creating property set with name " + setName + "\n" + ie);
+ } catch(org.apache.poi.hpsf.HPSFException he) {
+ // Oh well, doesn't exist
+ logger.log(POILogger.WARN, "Error creating property set with name " + setName + "\n" + he);
+ }
+ return null;
}
/**
@@ -157,14 +181,16 @@ public abstract class POIDocument {
* @param writtenEntries a list of POIFS entries to add the property names too
*/
protected void writeProperties(POIFSFileSystem outFS, List writtenEntries) throws IOException {
- if(sInf != null) {
- writePropertySet(SummaryInformation.DEFAULT_STREAM_NAME,sInf,outFS);
+ SummaryInformation si = getSummaryInformation();
+ if(si != null) {
+ writePropertySet(SummaryInformation.DEFAULT_STREAM_NAME, si, outFS);
if(writtenEntries != null) {
writtenEntries.add(SummaryInformation.DEFAULT_STREAM_NAME);
}
}
- if(dsInf != null) {
- writePropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME,dsInf,outFS);
+ DocumentSummaryInformation dsi = getDocumentSummaryInformation();
+ if(dsi != null) {
+ writePropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME, dsi, outFS);
if(writtenEntries != null) {
writtenEntries.add(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
}
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/ClassID.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/ClassID.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/ClassID.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/ClassID.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import org.apache.poi.util.HexDump;
@@ -27,8 +27,6 @@ import org.apache.poi.util.HexDump;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id$
- * @since 2002-02-09
*/
public class ClassID
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Constants.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Constants.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Constants.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Constants.java Thu Dec 30 02:35:06 2010
@@ -22,8 +22,6 @@ package org.apache.poi.hpsf;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @since 2004-06-20
- * @version $Id$
*/
public class Constants
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/CustomProperties.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/CustomProperties.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/CustomProperties.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/CustomProperties.java Thu Dec 30 02:35:06 2010
@@ -33,7 +33,7 @@ import org.apache.poi.hpsf.wellknown.Pro
* name is the key that maps to a typed value. This implementation hides
* property IDs from the developer and regards the property names as keys to
* typed values.</p>
- *
+ *
* <p>While 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,71 +41,68 @@ import org.apache.poi.hpsf.wellknown.Pro
* 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.</p>
- *
+ *
* <p>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.</p>
- *
+ *
* <p>This class is not thread-safe; concurrent access to instances of this
- * class must be syncronized.</p>
- *
+ * class must be synchronized.</p>
+ *
+ * <p>While this class is roughly HashMap<Long,CustomProperty>, that's the
+ * internal representation. To external calls, it should appear as
+ * HashMap<String,Object> mapping between Names and Custom Property Values.</p>
+ *
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @since 2006-02-09
- * @version $Id$
*/
-public class CustomProperties extends HashMap
+@SuppressWarnings("serial")
+public class CustomProperties extends HashMap<Object,CustomProperty>
{
/**
* <p>Maps property IDs to property names.</p>
*/
- private Map dictionaryIDToName = new HashMap();
+ private Map<Long,String> dictionaryIDToName = new HashMap<Long,String>();
/**
* <p>Maps property names to property IDs.</p>
*/
- private Map dictionaryNameToID = new HashMap();
-
+ private Map<String,Long> dictionaryNameToID = new HashMap<String,Long>();
+
/**
* <p>Tells whether this object is pure or not.</p>
*/
private boolean isPure = true;
-
/**
* <p>Puts a {@link CustomProperty} into this map. It is assumed that the
* {@link CustomProperty} already has a valid ID. Otherwise use
* {@link #put(CustomProperty)}.</p>
*/
- public Object put(final Object name, final Object customProperty) throws ClassCastException
+ public CustomProperty put(final String name, final CustomProperty cp)
{
- final CustomProperty cp = (CustomProperty) customProperty;
if (name == null)
{
/* Ignoring a property without a name. */
isPure = false;
return null;
}
- if (!(name instanceof String))
- throw new ClassCastException("The name of a custom property must " +
- "be a java.lang.String, but it is a " +
- name.getClass().getName());
if (!(name.equals(cp.getName())))
throw new IllegalArgumentException("Parameter \"name\" (" + name +
") and custom property's name (" + cp.getName() +
") 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 Object oldID = dictionaryNameToID.get(name);
+ final Long idKey = Long.valueOf(cp.getID());
+ final Long oldID = dictionaryNameToID.get(name);
dictionaryIDToName.remove(oldID);
dictionaryNameToID.put(name, idKey);
dictionaryIDToName.put(idKey, name);
/* Put the custom property into this map. */
- final Object oldCp = super.remove(oldID);
+ final CustomProperty oldCp = super.remove(oldID);
super.put(idKey, cp);
return oldCp;
}
@@ -115,16 +112,16 @@ public class CustomProperties extends Ha
/**
* <p>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:</p>
- *
+ *
* <ul>
- *
+ *
* <li><p>If there is already a property with the same name, take the ID
* of that property.</p></li>
- *
+ *
* <li><p>Otherwise find the highest ID and use its value plus one.</p></li>
- *
+ *
* </ul>
- *
+ *
* @param customProperty
* @return If the was already a property with the same name, the
* @throws ClassCastException
@@ -140,9 +137,9 @@ public class CustomProperties extends Ha
else
{
long max = 1;
- for (final Iterator i = dictionaryIDToName.keySet().iterator(); i.hasNext();)
+ for (final Iterator<Long> i = dictionaryIDToName.keySet().iterator(); i.hasNext();)
{
- final long id = ((Long) i.next()).longValue();
+ final long id = i.next().longValue();
if (id > max)
max = id;
}
@@ -155,7 +152,7 @@ public class CustomProperties extends Ha
/**
* <p>Removes a custom property.</p>
- * @param name The name of the custom property to remove
+ * @param name The name of the custom property to remove
* @return The removed property or <code>null</code> if the specified property was not found.
*
* @see java.util.HashSet#remove(java.lang.Object)
@@ -172,7 +169,7 @@ public class CustomProperties extends Ha
/**
* <p>Adds a named string property.</p>
- *
+ *
* @param name The property's name.
* @param value The property's value.
* @return the property that was stored under the specified name before, or
@@ -260,10 +257,10 @@ public class CustomProperties extends Ha
return put(cp);
}
-
+
/**
* <p>Gets a named value from the custom properties.</p>
- *
+ *
* @param name the name of the value to get
* @return the value or <code>null</code> if a value with the specified
* name is not found in the custom properties.
@@ -294,18 +291,34 @@ public class CustomProperties extends Ha
final CustomProperty cp = new CustomProperty(p, name);
return put(cp);
}
-
+
/**
* Returns a set of all the names of our
- * custom properties
+ * custom properties. Equivalent to
+ * {@link #nameSet()}
*/
public Set keySet() {
- return dictionaryNameToID.keySet();
- }
+ return dictionaryNameToID.keySet();
+ }
+ /**
+ * Returns a set of all the names of our
+ * custom properties
+ */
+ public Set<String> nameSet() {
+ return dictionaryNameToID.keySet();
+ }
+
+ /**
+ * Returns a set of all the IDs of our
+ * custom properties
+ */
+ public Set<String> idSet() {
+ return dictionaryNameToID.keySet();
+ }
- /**
+ /**
* <p>Sets the codepage.</p>
*
* @param codepage the codepage
@@ -315,7 +328,7 @@ public class CustomProperties extends Ha
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));
}
@@ -324,17 +337,47 @@ public class CustomProperties extends Ha
/**
* <p>Gets the dictionary which contains IDs and names of the named custom
* properties.
- *
+ *
* @return the dictionary.
*/
- Map getDictionary()
+ Map<Long,String> getDictionary()
{
return dictionaryIDToName;
}
-
/**
+ * Checks against both String Name and Long ID
+ */
+ public boolean containsKey(Object key) {
+ if(key instanceof Long) {
+ return super.containsKey((Long)key);
+ }
+ if(key instanceof String) {
+ return super.containsKey((Long)dictionaryNameToID.get(key));
+ }
+ return false;
+ }
+
+ /**
+ * Checks against both the property, and its values.
+ */
+ public boolean containsValue(Object value) {
+ if(value instanceof CustomProperty) {
+ return super.containsValue((CustomProperty)value);
+ } else {
+ for(CustomProperty cp : super.values()) {
+ if(cp.getValue() == value) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+
+ /**
* <p>Gets the codepage.</p>
*
* @return the codepage or -1 if the codepage is undefined.
@@ -342,9 +385,9 @@ public class CustomProperties extends Ha
public int getCodepage()
{
int codepage = -1;
- for (final Iterator i = this.values().iterator(); codepage == -1 && i.hasNext();)
+ for (final Iterator<CustomProperty> i = this.values().iterator(); codepage == -1 && i.hasNext();)
{
- final CustomProperty cp = (CustomProperty) i.next();
+ final CustomProperty cp = i.next();
if (cp.getID() == PropertyIDMap.PID_CODEPAGE)
codepage = ((Integer) cp.getValue()).intValue();
}
@@ -357,7 +400,7 @@ public class CustomProperties extends Ha
* <p>Tells whether this {@link CustomProperties} instance is pure or one or
* more properties of the underlying low-level property set has been
* dropped.</p>
- *
+ *
* @return <code>true</code> if the {@link CustomProperties} is pure, else
* <code>false</code>.
*/
@@ -375,5 +418,4 @@ public class CustomProperties extends Ha
{
this.isPure = isPure;
}
-
}
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/CustomProperty.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/CustomProperty.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/CustomProperty.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/CustomProperty.java Thu Dec 30 02:35:06 2010
@@ -18,15 +18,13 @@
package org.apache.poi.hpsf;
/**
- * <p>This class represents custum properties in the document summary
+ * <p>This class represents custom properties in the document summary
* information stream. The difference to normal properties is that custom
* properties have an optional name. If the name is not <code>null</code> it
* will be maintained in the section's dictionary.</p>
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @since 2006-02-09
- * @version $Id$
*/
public class CustomProperty extends MutableProperty
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import java.util.Iterator;
@@ -32,8 +32,6 @@ import org.apache.poi.hpsf.wellknown.Sec
* @author Drew Varner (Drew.Varner closeTo sc.edu)
* @author robert_flaherty@hyperion.com
* @see SummaryInformation
- * @version $Id$
- * @since 2002-02-09
*/
public class DocumentSummaryInformation extends SpecialPropertySet
{
@@ -569,9 +567,8 @@ public class DocumentSummaryInformation
/**
* <p>Gets the custom properties.</p>
- *
+ *
* @return The custom properties.
- * @since 2006-02-09
*/
public CustomProperties getCustomProperties()
{
@@ -580,7 +577,7 @@ public class DocumentSummaryInformation
{
cps = new CustomProperties();
final Section section = (Section) getSections().get(1);
- final Map dictionary = section.getDictionary();
+ final Map<Long,String> dictionary = section.getDictionary();
final Property[] properties = section.getProperties();
int propertyCount = 0;
for (int i = 0; i < properties.length; i++)
@@ -591,7 +588,7 @@ public class DocumentSummaryInformation
{
propertyCount++;
final CustomProperty cp = new CustomProperty(p,
- (String) dictionary.get(new Long(id)));
+ dictionary.get(Long.valueOf(id)));
cps.put(cp.getName(), cp);
}
}
@@ -603,15 +600,14 @@ public class DocumentSummaryInformation
/**
* <p>Sets the custom properties.</p>
- *
+ *
* @param customProperties The custom properties
- * @since 2006-02-07
*/
public void setCustomProperties(final CustomProperties customProperties)
{
ensureSection2();
final MutableSection section = (MutableSection) getSections().get(1);
- final Map dictionary = customProperties.getDictionary();
+ final Map<Long,String> dictionary = customProperties.getDictionary();
section.clear();
/* Set the codepage. If both custom properties and section have a
@@ -625,9 +621,9 @@ public class DocumentSummaryInformation
customProperties.setCodepage(cpCodepage);
section.setCodepage(cpCodepage);
section.setDictionary(dictionary);
- for (final Iterator i = customProperties.values().iterator(); i.hasNext();)
+ for (final Iterator<CustomProperty> i = customProperties.values().iterator(); i.hasNext();)
{
- final Property p = (Property) i.next();
+ final Property p = i.next();
section.setProperty(p);
}
}
@@ -652,8 +648,6 @@ public class DocumentSummaryInformation
/**
* <p>Removes the custom properties.</p>
- *
- * @since 2006-02-08
*/
public void removeCustomProperties()
{
@@ -676,5 +670,4 @@ public class DocumentSummaryInformation
{
throw new UnsupportedOperationException(msg + " is not yet implemented.");
}
-
}
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/HPSFException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/HPSFException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/HPSFException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/HPSFException.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
/**
@@ -24,8 +24,6 @@ package org.apache.poi.hpsf;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id$
- * @since 2002-02-09
*/
public class HPSFException extends Exception
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/HPSFRuntimeException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/HPSFRuntimeException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/HPSFRuntimeException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/HPSFRuntimeException.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import java.io.PrintStream;
@@ -27,8 +27,6 @@ import java.io.PrintWriter;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id$
- * @since 2002-02-09
*/
public class HPSFRuntimeException extends RuntimeException
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/IllegalPropertySetDataException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/IllegalPropertySetDataException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/IllegalPropertySetDataException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/IllegalPropertySetDataException.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
/**
@@ -26,8 +26,6 @@ package org.apache.poi.hpsf;
* thrown.</p>
*
* @author Drew Varner(Drew.Varner atDomain sc.edu)
- * @version $Id$
- * @since 2002-05-26
*/
public class IllegalPropertySetDataException extends HPSFRuntimeException
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/IllegalVariantTypeException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/IllegalVariantTypeException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/IllegalVariantTypeException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/IllegalVariantTypeException.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import org.apache.poi.util.HexDump;
@@ -25,8 +25,6 @@ import org.apache.poi.util.HexDump;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @since 2004-06-21
- * @version $Id$
*/
public class IllegalVariantTypeException extends VariantTypeException
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MarkUnsupportedException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MarkUnsupportedException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MarkUnsupportedException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MarkUnsupportedException.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
/**
@@ -23,8 +23,6 @@ package org.apache.poi.hpsf;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id$
- * @since 2002-02-09
*/
public class MarkUnsupportedException extends HPSFException
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MissingSectionException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MissingSectionException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MissingSectionException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MissingSectionException.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
/**
@@ -26,8 +26,6 @@ package org.apache.poi.hpsf;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id: NoSingleSectionException.java 353545 2004-04-09 13:05:39Z glens $
- * @since 2006-02-08
*/
public class MissingSectionException extends HPSFRuntimeException
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutableProperty.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutableProperty.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutableProperty.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutableProperty.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import java.io.IOException;
@@ -28,8 +28,6 @@ import java.io.OutputStream;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @since 2003-08-03
- * @version $Id$
*/
public class MutableProperty extends Property
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutablePropertySet.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutablePropertySet.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutablePropertySet.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutablePropertySet.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import java.io.ByteArrayInputStream;
@@ -33,8 +33,6 @@ import org.apache.poi.poifs.filesystem.E
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
-
-
/**
* <p>Adds writing support to the {@link PropertySet} class.</p>
*
@@ -43,8 +41,6 @@ import org.apache.poi.util.LittleEndianC
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id$
- * @since 2003-02-19
*/
public class MutablePropertySet extends PropertySet
{
@@ -79,10 +75,10 @@ public class MutablePropertySet extends
/**
* <p>Constructs a <code>MutablePropertySet</code> by doing a deep copy of
- * an existing <code>PropertySet</code>. All nested elements, i.e.
+ * an existing <code>PropertySet</code>. All nested elements, i.e.
* <code>Section</code>s and <code>Property</code> instances, will be their
* mutable counterparts in the new <code>MutablePropertySet</code>.</p>
- *
+ *
* @param ps The property set to copy
*/
public MutablePropertySet(final PropertySet ps)
@@ -194,7 +190,7 @@ public class MutablePropertySet extends
/**
* <p>Writes the property set to an output stream.</p>
- *
+ *
* @param out the output stream to write the section to
* @exception IOException if an error when writing to the output stream
* occurs
@@ -236,10 +232,10 @@ public class MutablePropertySet extends
catch (HPSFRuntimeException ex)
{
final Throwable cause = ex.getReason();
- if (cause instanceof UnsupportedEncodingException)
+ if (cause instanceof UnsupportedEncodingException) {
throw new IllegalPropertySetDataException(cause);
- else
- throw ex;
+ }
+ throw ex;
}
}
@@ -263,7 +259,7 @@ public class MutablePropertySet extends
* the {@link MutablePropertySet} only.</p>
*
* @return the contents of this property set stream
- *
+ *
* @throws WritingNotSupportedException if HPSF does not yet support writing
* of a property's variant type.
* @throws IOException if an I/O exception occurs.
@@ -284,7 +280,7 @@ public class MutablePropertySet extends
* @param dir The directory in the POI filesystem to write the document to.
* @param name The document's name. If there is already a document with the
* same name in the directory the latter will be overwritten.
- *
+ *
* @throws WritingNotSupportedException
* @throws IOException
*/
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutableSection.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutableSection.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutableSection.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/MutableSection.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import java.io.ByteArrayOutputStream;
@@ -37,9 +37,6 @@ import org.apache.poi.util.LittleEndian;
*
* <p>Please be aware that this class' functionality will be merged into the
* {@link Section} class at a later time, so the API will change.</p>
- *
- * @version $Id$
- * @since 2002-02-20
*/
public class MutableSection extends Section
{
@@ -56,7 +53,7 @@ public class MutableSection extends Sect
* decision has been taken when specifying the "properties" field
* as an Property[]. It should have been a {@link java.util.List}.</p>
*/
- private List preprops;
+ private List<Property> preprops;
@@ -77,17 +74,17 @@ public class MutableSection extends Sect
dirty = true;
formatID = null;
offset = -1;
- preprops = new LinkedList();
+ preprops = new LinkedList<Property>();
}
/**
- * <p>Constructs a <code>MutableSection</code> by doing a deep copy of an
- * existing <code>Section</code>. All nested <code>Property</code>
+ * <p>Constructs a <code>MutableSection</code> by doing a deep copy of an
+ * existing <code>Section</code>. All nested <code>Property</code>
* instances, will be their mutable counterparts in the new
* <code>MutableSection</code>.</p>
- *
+ *
* @param s The section set to copy
*/
public MutableSection(final Section s)
@@ -148,7 +145,7 @@ public class MutableSection extends Sect
public void setProperties(final Property[] properties)
{
this.properties = properties;
- preprops = new LinkedList();
+ preprops = new LinkedList<Property>();
for (int i = 0; i < properties.length; i++)
preprops.add(properties[i]);
dirty = true;
@@ -185,7 +182,7 @@ public class MutableSection extends Sect
*/
public void setProperty(final int id, final int value)
{
- setProperty(id, Variant.VT_I4, new Integer(value));
+ setProperty(id, Variant.VT_I4, Integer.valueOf(value));
dirty = true;
}
@@ -202,7 +199,7 @@ public class MutableSection extends Sect
*/
public void setProperty(final int id, final long value)
{
- setProperty(id, Variant.VT_I8, new Long(value));
+ setProperty(id, Variant.VT_I8, Long.valueOf(value));
dirty = true;
}
@@ -219,7 +216,7 @@ public class MutableSection extends Sect
*/
public void setProperty(final int id, final boolean value)
{
- setProperty(id, Variant.VT_BOOL, new Boolean(value));
+ setProperty(id, Variant.VT_BOOL, Boolean.valueOf(value));
dirty = true;
}
@@ -279,8 +276,8 @@ public class MutableSection extends Sect
*/
public void removeProperty(final long id)
{
- for (final Iterator i = preprops.iterator(); i.hasNext();)
- if (((Property) i.next()).getID() == id)
+ for (final Iterator<Property> i = preprops.iterator(); i.hasNext();)
+ if (i.next().getID() == id)
{
i.remove();
break;
@@ -303,7 +300,7 @@ public class MutableSection extends Sect
*/
protected void setPropertyBooleanValue(final int id, final boolean value)
{
- setProperty(id, Variant.VT_BOOL, new Boolean(value));
+ setProperty(id, Variant.VT_BOOL, Boolean.valueOf(value));
}
@@ -342,10 +339,10 @@ public class MutableSection extends Sect
* properties) and the properties themselves.</p>
*
* @return the section's length in bytes.
- * @throws WritingNotSupportedException
- * @throws IOException
+ * @throws WritingNotSupportedException
+ * @throws IOException
*/
- private int calcSize() throws WritingNotSupportedException, IOException
+ private int calcSize() throws WritingNotSupportedException, IOException
{
final ByteArrayOutputStream out = new ByteArrayOutputStream();
write(out);
@@ -360,7 +357,7 @@ public class MutableSection extends Sect
/**
* <p>Writes this section into an output stream.</p>
- *
+ *
* <p>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
@@ -393,7 +390,7 @@ public class MutableSection extends Sect
* "propertyListStream". */
final ByteArrayOutputStream propertyListStream =
new ByteArrayOutputStream();
-
+
/* Maintain the current position in the list. */
int position = 0;
@@ -421,17 +418,15 @@ public class MutableSection extends Sect
* 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();
}
/* Sort the property list by their property IDs: */
- Collections.sort(preprops, new Comparator()
+ Collections.sort(preprops, new Comparator<Property>()
{
- public int compare(final Object o1, final Object o2)
+ public int compare(final Property p1, final Property p2)
{
- final Property p1 = (Property) o1;
- final Property p2 = (Property) o2;
if (p1.getID() < p2.getID())
return -1;
else if (p1.getID() == p2.getID())
@@ -443,11 +438,11 @@ public class MutableSection extends Sect
/* Write the properties and the property list into their respective
* streams: */
- for (final ListIterator i = preprops.listIterator(); i.hasNext();)
+ for (final ListIterator<Property> i = preprops.listIterator(); i.hasNext();)
{
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);
@@ -475,17 +470,17 @@ public class MutableSection extends Sect
/* 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);
@@ -505,14 +500,14 @@ public class MutableSection extends Sect
* @exception IOException if an I/O exception occurs.
*/
private static int writeDictionary(final OutputStream out,
- final Map dictionary, final int codepage)
+ final Map<Long,String> dictionary, final int codepage)
throws IOException
{
int length = TypeWriter.writeUIntToStream(out, dictionary.size());
- for (final Iterator i = dictionary.keySet().iterator(); i.hasNext();)
+ for (final Iterator<Long> i = dictionary.keySet().iterator(); i.hasNext();)
{
- final Long key = (Long) i.next();
- final String value = (String) dictionary.get(key);
+ final Long key = i.next();
+ final String value = dictionary.get(key);
if (codepage == Constants.CP_UNICODE)
{
@@ -565,7 +560,7 @@ public class MutableSection extends Sect
* <p>Overwrites the super class' method to cope with a redundancy:
* the property count is maintained in a separate member variable, but
* shouldn't.</p>
- *
+ *
* @return The number of properties in this section
*/
public int getPropertyCount()
@@ -577,7 +572,7 @@ public class MutableSection extends Sect
/**
* <p>Gets this section's properties.</p>
- *
+ *
* @return this section's properties.
*/
public Property[] getProperties()
@@ -590,7 +585,7 @@ public class MutableSection extends Sect
/**
* <p>Gets a property.</p>
- *
+ *
* @param id The ID of the property to get
* @return The property or <code>null</code> if there is no such property
*/
@@ -614,27 +609,17 @@ public class MutableSection extends Sect
* method.</p>
*
* @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)
+ public void setDictionary(final Map<Long,String> dictionary)
throws IllegalPropertySetDataException
{
if (dictionary != null)
{
- for (final Iterator i = dictionary.keySet().iterator();
- i.hasNext();)
- if (!(i.next() instanceof Long))
- throw new IllegalPropertySetDataException
- ("Dictionary keys must be of type Long.");
- for (final Iterator i = dictionary.values().iterator();
- i.hasNext();)
- if (!(i.next() instanceof String))
- throw new IllegalPropertySetDataException
- ("Dictionary values must be of type String.");
this.dictionary = dictionary;
/* Set the dictionary property (ID 0). Please note that the second
@@ -649,7 +634,7 @@ public class MutableSection extends Sect
(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.
@@ -661,7 +646,7 @@ public class MutableSection extends Sect
/**
* <p>Sets a property.</p>
- *
+ *
* @param id The property ID.
* @param value The property's value. The value's class must be one of those
* supported by HPSF.
@@ -710,7 +695,6 @@ public class MutableSection extends Sect
public void setCodepage(final int codepage)
{
setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2,
- new Integer(codepage));
+ Integer.valueOf(codepage));
}
-
}
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoFormatIDException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoFormatIDException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoFormatIDException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoFormatIDException.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
/**
@@ -25,8 +25,6 @@ package org.apache.poi.hpsf;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id$
- * @since 2002-09-03
*/
public class NoFormatIDException extends HPSFRuntimeException
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoPropertySetStreamException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoPropertySetStreamException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoPropertySetStreamException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoPropertySetStreamException.java Thu Dec 30 02:35:06 2010
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
/**
@@ -27,8 +26,6 @@ package org.apache.poi.hpsf;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id$
- * @since 2002-02-09
*/
public class NoPropertySetStreamException extends HPSFException
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoSingleSectionException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoSingleSectionException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoSingleSectionException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/NoSingleSectionException.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
/**
@@ -28,8 +28,6 @@ package org.apache.poi.hpsf;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id$
- * @since 2002-02-09
*/
public class NoSingleSectionException extends HPSFRuntimeException
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Property.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Property.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Property.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Property.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import java.io.UnsupportedEncodingException;
@@ -46,7 +46,7 @@ import org.apache.poi.util.POILogger;
* over time but largely depends on your feedback so that the POI team knows
* which variant types are really needed. So please feel free to submit error
* reports or patches for the types you need.</p>
- *
+ *
* <p>Microsoft documentation: <a
* href="http://msdn.microsoft.com/library/en-us/stg/stg/property_set_display_name_dictionary.asp?frame=true">
* Property Set Display Name Dictionary</a>.
@@ -56,8 +56,6 @@ import org.apache.poi.util.POILogger;
* @author Drew Varner (Drew.Varner InAndAround sc.edu)
* @see Section
* @see Variant
- * @version $Id$
- * @since 2002-02-09
*/
public class Property
{
@@ -112,7 +110,7 @@ public class Property
/**
* <p>Creates a property.</p>
- *
+ *
* @param id the property's ID.
* @param type the property's type, see {@link Variant}.
* @param value the property's value. Only certain types are allowed, see
@@ -185,7 +183,7 @@ public class Property
/**
* <p>Reads a dictionary.</p>
- *
+ *
* @param src The byte array containing the bytes making out the dictionary.
* @param offset At this offset within <var>src </var> the dictionary
* starts.
@@ -219,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
@@ -298,7 +296,7 @@ public class Property
* 4.</p>
*
* @return the property's size in bytes
- *
+ *
* @exception WritingNotSupportedException if HPSF does not yet support the
* property's variant type.
*/
@@ -339,13 +337,14 @@ public class Property
* ID == 0 is a special case: It does not have a type, and its value is the
* section's dictionary. Another special case are strings: Two properties
* may have the different types Variant.VT_LPSTR and Variant.VT_LPWSTR;</p>
- *
+ *
* @see Object#equals(java.lang.Object)
*/
public boolean equals(final Object o)
{
- if (!(o instanceof Property))
+ if (!(o instanceof Property)) {
return false;
+ }
final Property p = (Property) o;
final Object pValue = p.getValue();
final long pId = p.getID();
@@ -357,8 +356,8 @@ public class Property
return false;
/* It's clear now that both values are non-null. */
- final Class valueClass = value.getClass();
- final Class pValueClass = pValue.getClass();
+ final Class<?> valueClass = value.getClass();
+ final Class<?> pValueClass = pValue.getClass();
if (!(valueClass.isAssignableFrom(pValueClass)) &&
!(pValueClass.isAssignableFrom(valueClass)))
return false;
@@ -375,10 +374,10 @@ public class Property
{
if (t1 == t2 ||
(t1 == Variant.VT_LPSTR && t2 == Variant.VT_LPWSTR) ||
- (t2 == Variant.VT_LPSTR && t1 == Variant.VT_LPWSTR))
+ (t2 == Variant.VT_LPSTR && t1 == Variant.VT_LPWSTR)) {
return true;
- else
- return false;
+ }
+ return false;
}
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/PropertySet.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/PropertySet.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/PropertySet.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/PropertySet.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import java.io.IOException;
@@ -57,8 +57,6 @@ import org.apache.poi.util.LittleEndian;
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
* @author Drew Varner (Drew.Varner hanginIn sc.edu)
- * @version $Id$
- * @since 2002-02-09
*/
public class PropertySet
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/PropertySetFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/PropertySetFactory.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/PropertySetFactory.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/PropertySetFactory.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import java.io.InputStream;
@@ -30,8 +30,6 @@ import org.apache.poi.hpsf.wellknown.Sec
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id$
- * @since 2002-02-09
*/
public class PropertySetFactory
{
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/ReadingNotSupportedException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/ReadingNotSupportedException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/ReadingNotSupportedException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/ReadingNotSupportedException.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
/**
@@ -26,8 +26,6 @@ package org.apache.poi.hpsf;
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @since 2003-08-08
- * @version $Id$
*/
public class ReadingNotSupportedException
extends UnsupportedVariantTypeException
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Section.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Section.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Section.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/Section.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import java.io.UnsupportedEncodingException;
@@ -34,8 +34,6 @@ import org.apache.poi.util.LittleEndian;
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
* @author Drew Varner (Drew.Varner allUpIn sc.edu)
- * @version $Id$
- * @since 2002-02-09
*/
public class Section
{
@@ -44,7 +42,7 @@ public class Section
* <p>Maps property IDs to section-private PID strings. These
* strings can be found in the property with ID 0.</p>
*/
- protected Map dictionary;
+ protected Map<Long,String> dictionary;
/**
* <p>The section's format ID, {@link #getFormatID}.</p>
@@ -148,7 +146,7 @@ public class Section
* @param src Contains the complete property set stream.
* @param offset The position in the stream that points to the
* section's format ID.
- *
+ *
* @exception UnsupportedEncodingException if the section's codepage is not
* supported.
*/
@@ -185,7 +183,7 @@ public class Section
/*
* Read the properties. The offset is positioned at the first
* entry of the property list. There are two problems:
- *
+ *
* 1. For each property we have to find out its length. In the
* property list we find each property's ID and its offset relative
* to the section's beginning. Unfortunately the properties in the
@@ -193,8 +191,8 @@ public class Section
* possible to calculate the length as
* (offset of property(i+1) - offset of property(i)). Before we can
* that we first have to sort the property list by ascending offsets.
- *
- * 2. We have to read the property with ID 1 before we read other
+ *
+ * 2. We have to read the property with ID 1 before we read other
* properties, at least before other properties containing strings.
* The reason is that property 1 specifies the codepage. If it is
* 1200, all strings are in Unicode. In other words: Before we can
@@ -207,10 +205,10 @@ public class Section
* seconds pass reads the other properties.
*/
properties = new Property[propertyCount];
-
+
/* Pass 1: Read the property list. */
int pass1Offset = o1;
- final List propertyList = new ArrayList(propertyCount);
+ final List<PropertyListEntry> propertyList = new ArrayList<PropertyListEntry>(propertyCount);
PropertyListEntry ple;
for (int i = 0; i < properties.length; i++)
{
@@ -234,34 +232,22 @@ public class Section
/* Calculate the properties' lengths. */
for (int i = 0; i < propertyCount - 1; i++)
{
- final PropertyListEntry ple1 =
- (PropertyListEntry) propertyList.get(i);
- final PropertyListEntry ple2 =
- (PropertyListEntry) propertyList.get(i + 1);
+ PropertyListEntry ple1 = propertyList.get(i);
+ PropertyListEntry ple2 = propertyList.get(i + 1);
ple1.length = ple2.offset - ple1.offset;
}
if (propertyCount > 0)
{
- ple = (PropertyListEntry) propertyList.get(propertyCount - 1);
+ ple = propertyList.get(propertyCount - 1);
ple.length = size - ple.offset;
- if (ple.length <= 0)
- {
- final StringBuffer b = new StringBuffer();
- b.append("The property set claims to have a size of ");
- b.append(size);
- b.append(" bytes. However, it exceeds ");
- b.append(ple.offset);
- b.append(" bytes.");
- throw new IllegalPropertySetDataException(b.toString());
- }
}
/* Look for the codepage. */
int codepage = -1;
- for (final Iterator i = propertyList.iterator();
+ for (final Iterator<PropertyListEntry> i = propertyList.iterator();
codepage == -1 && i.hasNext();)
{
- ple = (PropertyListEntry) i.next();
+ ple = i.next();
/* Read the codepage if the property ID is 1. */
if (ple.id == PropertyIDMap.PID_CODEPAGE)
@@ -285,14 +271,14 @@ public class Section
/* Pass 2: Read all properties - including the codepage property,
* if available. */
int i1 = 0;
- for (final Iterator i = propertyList.iterator(); i.hasNext();)
+ for (final Iterator<PropertyListEntry> i = propertyList.iterator(); i.hasNext();)
{
- ple = (PropertyListEntry) i.next();
+ ple = i.next();
Property p = new Property(ple.id, src,
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;
}
@@ -308,7 +294,7 @@ public class Section
* <p>Represents an entry in the property list and holds a property's ID and
* its offset from the section's beginning.</p>
*/
- class PropertyListEntry implements Comparable
+ class PropertyListEntry implements Comparable<PropertyListEntry>
{
int id;
int offset;
@@ -321,11 +307,9 @@ public class Section
*
* @see Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(final Object o)
+ public int compareTo(final PropertyListEntry o)
{
- if (!(o instanceof PropertyListEntry))
- throw new ClassCastException(o.toString());
- final int otherOffset = ((PropertyListEntry) o).offset;
+ final int otherOffset = o.offset;
if (offset < otherOffset)
return -1;
else if (offset == otherOffset)
@@ -414,11 +398,11 @@ public class Section
protected boolean getPropertyBooleanValue(final int id)
{
final Boolean b = (Boolean) getProperty(id);
- if (b != null)
- return b.booleanValue();
- else
+ if (b == null) {
return false;
}
+ return b.booleanValue();
+ }
@@ -464,7 +448,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)
@@ -477,23 +461,23 @@ public class Section
/**
* <p>Checks whether this section is equal to another object. The result is
* <code>false</code> if one of the the following conditions holds:</p>
- *
+ *
* <ul>
- *
+ *
* <li><p>The other object is not a {@link Section}.</p></li>
- *
+ *
* <li><p>The format IDs of the two sections are not equal.</p></li>
- *
+ *
* <li><p>The sections have a different number of properties. However,
* properties with ID 1 (codepage) are not counted.</p></li>
- *
+ *
* <li><p>The other object is not a {@link Section}.</p></li>
- *
+ *
* <li><p>The properties have different values. The order of the properties
* is irrelevant.</p></li>
- *
+ *
* </ul>
- *
+ *
* @param o The object to compare this section with
* @return <code>true</code> if the objects are equal, <code>false</code> if
* not
@@ -506,7 +490,7 @@ public class Section
if (!s.getFormatID().equals(getFormatID()))
return false;
- /* Compare all properties except 0 and 1 as they must be handled
+ /* Compare all properties except 0 and 1 as they must be handled
* specially. */
Property[] pa1 = new Property[getProperties().length];
Property[] pa2 = new Property[s.getProperties().length];
@@ -561,10 +545,10 @@ public class Section
dictionaryEqual = p10.getValue().equals(p20.getValue());
else if (p10 != null || p20 != null)
dictionaryEqual = false;
- if (!dictionaryEqual)
- return false;
- else
+ if (dictionaryEqual) {
return Util.equals(pa1, pa2);
+ }
+ return false;
}
@@ -573,7 +557,7 @@ public class Section
* <p>Removes a field from a property array. The resulting array is
* compactified and returned.</p>
*
- * @param pa The property array.
+ * @param pa The property array.
* @param i The index of the field to be removed.
* @return the compactified array.
*/
@@ -644,7 +628,7 @@ public class Section
* @return the dictionary or <code>null</code> if the section does not have
* a dictionary.
*/
- public Map getDictionary()
+ public Map<Long,String> getDictionary()
{
return dictionary;
}
Modified: poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/SpecialPropertySet.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/SpecialPropertySet.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/SpecialPropertySet.java (original)
+++ poi/branches/NIO_32_BRANCH/src/java/org/apache/poi/hpsf/SpecialPropertySet.java Thu Dec 30 02:35:06 2010
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hpsf;
import java.io.IOException;
@@ -53,8 +53,6 @@ import org.apache.poi.poifs.filesystem.D
*
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @version $Id$
- * @since 2002-02-09
*/
public abstract class SpecialPropertySet extends MutablePropertySet
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org