poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r688642 - in /poi/trunk/src/scratchpad/src/org/apache/poi/hpbf: HPBFDocument.java model/EscherDelayStm.java model/EscherPart.java model/EscherStm.java model/HPBFPart.java model/MainContents.java model/QuillContents.java
Date Mon, 25 Aug 2008 07:56:38 GMT
Author: josh
Date: Mon Aug 25 00:56:37 2008
New Revision: 688642

URL: http://svn.apache.org/viewvc?rev=688642&view=rev
Log:
JDK 1.4 fixes for new hpbf stuff. Some clean-up

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherDelayStm.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherStm.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java?rev=688642&r1=688641&r2=688642&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java Mon Aug 25 00:56:37
2008
@@ -14,9 +14,9 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -34,7 +34,7 @@
  *  for HPBF, our implementation of the publisher
  *  file format. 
  */
-public class HPBFDocument extends POIDocument {
+public final class HPBFDocument extends POIDocument {
 	private MainContents mainContents;
 	private QuillContents quillContents;
 	private EscherStm escherStm;
@@ -59,28 +59,12 @@
 		
 		// Go looking for our interesting child
 		//  streams
-		try {
-			mainContents = new MainContents(dir);
-		} catch(FileNotFoundException e) {
-			throw new IllegalArgumentException("File invalid - missing required main Contents part",
e);
-		}
-		try {
-			quillContents = new QuillContents(dir);
-		} catch(FileNotFoundException e) {
-			throw new IllegalArgumentException("File invalid - missing required Quill CONTENTS part",
e);
-		}
+		mainContents = new MainContents(dir);
+		quillContents = new QuillContents(dir);
 		
 		// Now the Escher bits
-		try {
-			escherStm = new EscherStm(dir);
-		} catch(FileNotFoundException e) {
-			throw new IllegalArgumentException("File invalid - missing required EscherStm part", e);
-		}
-		try {
-			escherDelayStm = new EscherDelayStm(dir);
-		} catch(FileNotFoundException e) {
-			throw new IllegalArgumentException("File invalid - missing required EscherDelayStm part",
e);
-		}
+		escherStm = new EscherStm(dir);
+		escherDelayStm = new EscherDelayStm(dir);
 	}
 
 	public MainContents getMainContents() {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherDelayStm.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherDelayStm.java?rev=688642&r1=688641&r2=688642&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherDelayStm.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherDelayStm.java Mon Aug 25
00:56:37 2008
@@ -14,22 +14,17 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 
-public class EscherDelayStm extends EscherPart {
-	public EscherDelayStm(DirectoryNode baseDir) throws FileNotFoundException,
-			IOException {
-		super(baseDir);
-	}
+public final class EscherDelayStm extends EscherPart {
+	private static final String[] PATH = { "Escher", "EscherDelayStm", };
 
-	public String[] getPath() {
-		return new String[] {
-				"Escher", "EscherDelayStm"
-		};
+	public EscherDelayStm(DirectoryNode baseDir) throws IOException {
+		super(baseDir, PATH);
 	}
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java?rev=688642&r1=688641&r2=688642&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java Mon Aug 25 00:56:37
2008
@@ -14,9 +14,9 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
 
@@ -34,9 +34,8 @@
 	 * Creates the Escher Part, and finds our child
 	 *  escher records
 	 */
-	public EscherPart(DirectoryNode baseDir) throws FileNotFoundException,
-			IOException {
-		super(baseDir);
+	public EscherPart(DirectoryNode baseDir, String[] parts) throws IOException {
+		super(baseDir, parts);
 		
 		// Now create our Escher children
 		DefaultEscherRecordFactory erf = 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherStm.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherStm.java?rev=688642&r1=688641&r2=688642&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherStm.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherStm.java Mon Aug 25 00:56:37
2008
@@ -14,22 +14,16 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 
-public class EscherStm extends EscherPart {
-	public EscherStm(DirectoryNode baseDir) throws FileNotFoundException,
-			IOException {
-		super(baseDir);
-	}
-
-	public String[] getPath() {
-		return new String[] {
-				"Escher", "EscherStm"
-		};
+public final class EscherStm extends EscherPart {
+	private static final String[] PATH = { "Escher", "EscherStm", };
+	public EscherStm(DirectoryNode baseDir) throws IOException {
+		super(baseDir, PATH);
 	}
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java?rev=688642&r1=688641&r2=688642&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java Mon Aug 25 00:56:37
2008
@@ -30,23 +30,35 @@
  */
 public abstract class HPBFPart {
 	protected byte[] data;
-	
-	public HPBFPart(DirectoryNode baseDir) throws FileNotFoundException, IOException {
-		String[] path = getPath(); 
+	/**
+	 * @param path  the path to the part, eg Contents or Quill, QuillSub, CONTENTS
+	 */
+	public HPBFPart(DirectoryNode baseDir, String[] path) throws IOException {
+		 
 		DirectoryNode dir = getDir(path, baseDir);
 		String name = path[path.length-1];
 		
-		DocumentEntry docProps =
-			(DocumentEntry)dir.getEntry(name);
+		DocumentEntry docProps;
+		try {
+			docProps = (DocumentEntry)dir.getEntry(name);
+		} catch (FileNotFoundException e) {
+			throw new IllegalArgumentException("File invalid - failed to find document entry '" 
+					+ name + "'");
+		}
 
 		// Grab the data from the part stream
 		data = new byte[docProps.getSize()];
 		dir.createDocumentInputStream(name).read(data);
 	}
-	private DirectoryNode getDir(String[] path, DirectoryNode baseDir) throws FileNotFoundException
{
+	private DirectoryNode getDir(String[] path, DirectoryNode baseDir) {
 		DirectoryNode dir = baseDir;
 		for(int i=0; i<path.length-1; i++) {
-			dir = (DirectoryNode)dir.getEntry(path[i]);
+			try {
+				dir = (DirectoryNode)dir.getEntry(path[i]);
+			} catch (FileNotFoundException e) {
+				throw new IllegalArgumentException("File invalid - failed to find directory entry '"

+						+ path[i] + "'");
+			}
 		}
 		return dir;
 	}
@@ -86,8 +98,7 @@
 	public byte[] getData() { return data; }
 
 	/**
-	 * Returns the path to the part, eg Contents
-	 *  or Quill, QuillSub, CONTENTS
+	 * Returns
 	 */
-	public abstract String[] getPath();
+	public final String[] getPath() {return null;}
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java?rev=688642&r1=688641&r2=688642&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java Mon Aug 25 00:56:37
2008
@@ -14,9 +14,9 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 
 import org.apache.poi.poifs.filesystem.DirectoryNode;
@@ -24,14 +24,11 @@
 /**
  * The main Contents. Not yet understood
  */
-public class MainContents extends HPBFPart {
-	public MainContents(DirectoryNode baseDir)
-			throws FileNotFoundException, IOException {
-		super(baseDir);
-	}
-
-	public String[] getPath() {
-		return new String[] { "Contents" };
+public final class MainContents extends HPBFPart {
+	private static final String[] PATH = { "Contents", };
+	
+	public MainContents(DirectoryNode baseDir) throws IOException {
+		super(baseDir, PATH);
 	}
 
 	protected void generateData() {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java?rev=688642&r1=688641&r2=688642&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java Mon Aug 25 00:56:37
2008
@@ -16,7 +16,6 @@
 ==================================================================== */
 package org.apache.poi.hpbf.model;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 
 import org.apache.poi.hpbf.model.qcbits.QCBit;
@@ -28,12 +27,12 @@
 /**
  * Quill -> QuillSub -> CONTENTS
  */
-public class QuillContents extends HPBFPart {
+public final class QuillContents extends HPBFPart {
+	private static final String[] PATH = { "Quill", "QuillSub", "CONTENTS", };
 	private QCBit[] bits;
 	
-	public QuillContents(DirectoryNode baseDir)
-			throws FileNotFoundException, IOException {
-		super(baseDir);
+	public QuillContents(DirectoryNode baseDir) throws IOException {
+		super(baseDir, PATH);
 		
 		// Now parse the first 512 bytes, and produce
 		//  all our bits
@@ -85,10 +84,4 @@
 		// TODO
 		throw new IllegalStateException("Not done yet!");
 	}
-
-	public String[] getPath() {
-		return new String[] {
-			"Quill", "QuillSub", "CONTENTS"
-		};
-	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message