The main class of the POI Browser. It shows the structure of POI
diff --git a/src/contrib/src/org/apache/poi/contrib/poibrowser/PropertySetDescriptor.java b/src/contrib/src/org/apache/poi/contrib/poibrowser/PropertySetDescriptor.java
index 0c98528793..9e6500c1b7 100644
--- a/src/contrib/src/org/apache/poi/contrib/poibrowser/PropertySetDescriptor.java
+++ b/src/contrib/src/org/apache/poi/contrib/poibrowser/PropertySetDescriptor.java
@@ -18,9 +18,16 @@
package org.apache.poi.contrib.poibrowser;
-import java.io.*;
-import org.apache.poi.hpsf.*;
-import org.apache.poi.poifs.filesystem.*;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.poi.hpsf.MarkUnsupportedException;
+import org.apache.poi.hpsf.NoPropertySetStreamException;
+import org.apache.poi.hpsf.PropertySet;
+import org.apache.poi.hpsf.PropertySetFactory;
+import org.apache.poi.hpsf.UnexpectedPropertySetTypeException;
+import org.apache.poi.poifs.filesystem.DocumentInputStream;
+import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
/**
*
Describes the most important (whatever that is) features of a
@@ -63,8 +70,9 @@ public class PropertySetDescriptor extends DocumentDescriptor
final POIFSDocumentPath path,
final DocumentInputStream stream,
final int nrOfBytesToDump)
- throws NoPropertySetStreamException, MarkUnsupportedException,
- UnexpectedPropertySetTypeException, IOException
+ throws UnexpectedPropertySetTypeException, NoPropertySetStreamException,
+ MarkUnsupportedException, UnsupportedEncodingException,
+ IOException
{
super(name, path, stream, nrOfBytesToDump);
propertySet = PropertySetFactory.create(stream);
diff --git a/src/documentation/content/xdocs/hpsf/how-to.xml b/src/documentation/content/xdocs/hpsf/how-to.xml
index 4b55b200a9..d7402258e0 100644
--- a/src/documentation/content/xdocs/hpsf/how-to.xml
+++ b/src/documentation/content/xdocs/hpsf/how-to.xml
@@ -41,10 +41,15 @@
The fourth section tells you how to write
- property set streams. Writing is still rudimentary in HPSF. You have to
- understand the third section before you should
- think about writing properties. Check the Javadoc API documentation to
- find out about the details!
+ property set streams. At this time HPSF provides low-level methods only
+ for writing properties. Therefore you have to understand the third section before you should think about writing
+ properties. Check the Javadoc API documentation to find out about the
+ details! Please note: HPSF's writing functionality is
+ not present in POI releases up to and including 2.5. In
+ order to write properties you have to download a later POI release (when
+ available) or retrieve the POI development version from the CVS
+ repository.
@@ -853,16 +858,24 @@ No property set stream: "/1Table"
codepage number is illegal, an UnsupportedEncodingException will be
thrown.
-
There are two exceptions to the rule that a character encoding's name
- is derived from the codepage number by prepending the string "cp" to
- it:
+
There are some exceptions to the rule saying that a character
+ encoding's name is derived from the codepage number by prepending the
+ string "cp" to it:
+
Codepage 932
+
is mapped to the character encoding "SJIS".
Codepage 1200
is mapped to the character encoding "UTF-16".
Codepage 65001
is mapped to the character encoding "UTF-8".
+
+
Probably there will be a need to add more mappings between codepage
+ numbers and character encoding names. They should be added to the method
+ codepageToEncoding in the class
+ org.apache.poi.hpsf.VariantSupport. The HPSF author will
+ appreciate any advices for mappings to be added.
@@ -873,7 +886,7 @@ No property set stream: "/1Table"
Overview of Writing Properties
Writing properties is possible at a low level only at the moment. You
- have to deal with property IDs and variant types to write
+ have to deal with things like property IDs and variant types to write
properties. There are no convenience classes or convenience methods for
dealing with summary information and document summary information streams
yet. Therefore you should have read section 3
@@ -884,7 +897,9 @@ No property set stream: "/1Table"
MutableProperty, and some helper classes. The "mutable"
classes extend their respective superclasses PropertySet,
Section, and Property and provide "set" and
- "write" methods.
+ "write" methods, following the Decorator
+ pattern.
When you are going to write a property set stream your application has
to perform the following steps:
@@ -934,15 +949,38 @@ No property set stream: "/1Table"
-
The applications first checks that there is exactly a single argument
- on the command line. If this is true, the application stores it in the
+
The application first checks that there is exactly one single argument
+ on the command line: the name of the file to write. If this single
+ argument is present, the application stores it in the
fileName variable. It will be used in the end when the POI
file system is written to a disk file.
diff --git a/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java b/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java
index 57f8e897ba..55cb35d961 100644
--- a/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java
+++ b/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -26,6 +25,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -98,9 +98,12 @@ public class CopyCompare
* create a property set from a POI document stream that is not a property
* set stream.
* @exception IOException if any I/O exception occurs.
+ * @exception UnsupportedEncodingException if a character encoding is not
+ * supported.
*/
public static void main(final String[] args)
- throws MarkUnsupportedException, NoPropertySetStreamException, IOException
+ throws NoPropertySetStreamException, MarkUnsupportedException,
+ UnsupportedEncodingException, IOException
{
String originalFileName = null;
String copyFileName = null;
@@ -174,7 +177,8 @@ public class CopyCompare
private static boolean equal(final DirectoryEntry d1,
final DirectoryEntry d2,
final StringBuffer msg)
- throws MarkUnsupportedException, NoPropertySetStreamException, IOException
+ throws NoPropertySetStreamException, MarkUnsupportedException,
+ UnsupportedEncodingException, IOException
{
boolean equal = true;
/* Iterate over d1 and compare each entry with its counterpart in d2. */
@@ -251,7 +255,8 @@ public class CopyCompare
*/
private static boolean equal(final DocumentEntry d1, final DocumentEntry d2,
final StringBuffer msg)
- throws MarkUnsupportedException, NoPropertySetStreamException, IOException
+ throws NoPropertySetStreamException, MarkUnsupportedException,
+ UnsupportedEncodingException, IOException
{
boolean equal = true;
final DocumentInputStream dis1 = new DocumentInputStream(d1);
diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java b/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java
index b0eeac2926..e3b66725ad 100644
--- a/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java
+++ b/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Copyright 2002-2004 Apache Software Foundation
@@ -24,6 +23,7 @@ import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.util.List;
import junit.framework.Assert;
@@ -133,9 +133,13 @@ public class TestBasic extends TestCase
* NoPropertySetStreamException} will be thrown when trying to
* create a {@link PropertySet}.
*
- * @exception IOException if an I/O exception occurs
+ * @exception IOException if an I/O exception occurs.
+ *
+ * @exception UnsupportedEncodingException if a character encoding is not
+ * supported.
*/
- public void testCreatePropertySets() throws IOException
+ public void testCreatePropertySets()
+ throws UnsupportedEncodingException, IOException
{
Class[] expected = new Class[]
{
diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java b/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java
index 92eb418f8f..59fe77418c 100644
--- a/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java
+++ b/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import junit.framework.Assert;
import junit.framework.TestCase;
@@ -116,9 +117,13 @@ public class TestEmptyProperties extends TestCase
* NoPropertySetStreamException} will be thrown when trying to
* create a {@link PropertySet}.
*
- * @exception IOException if an I/O exception occurs
+ * @exception IOException if an I/O exception occurs.
+ *
+ * @exception UnsupportedEncodingException if a character encoding is not
+ * supported.
*/
- public void testCreatePropertySets() throws IOException
+ public void testCreatePropertySets()
+ throws UnsupportedEncodingException, IOException
{
Class[] expected = new Class[]
{
diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestUnicode.java b/src/testcases/org/apache/poi/hpsf/basic/TestUnicode.java
index 699b211556..9c7a2b47ac 100644
--- a/src/testcases/org/apache/poi/hpsf/basic/TestUnicode.java
+++ b/src/testcases/org/apache/poi/hpsf/basic/TestUnicode.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import junit.framework.Assert;
import junit.framework.TestCase;
+import org.apache.poi.hpsf.Constants;
import org.apache.poi.hpsf.HPSFException;
import org.apache.poi.hpsf.PropertySet;
import org.apache.poi.hpsf.PropertySetFactory;
@@ -99,7 +100,7 @@ public class TestUnicode extends TestCase
Assert.assertEquals(ps.getSectionCount(), 2);
Section s = (Section) ps.getSections().get(1);
Assert.assertEquals(s.getProperty(1),
- new Integer(1200));
+ new Integer(Constants.CP_UTF16));
Assert.assertEquals(s.getProperty(2),
new Long(4198897018L));
Assert.assertEquals(s.getProperty(3),
--
2.39.5