From ada61241db41581285703006fd364660027eb63f Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Tue, 26 Jun 2007 08:00:37 +0000 Subject: [PATCH] make the code compatible with JDK 1.4.2 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@550726 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/usermodel/HSSFDateUtil.java | 2 +- .../eventusermodel/examples/XLS2CSVmra.java | 2 +- .../org/apache/poi/hdgf/dev/VSDDumper.java | 2 +- .../poi/hdgf/exceptions/HDGFException.java | 44 +++++++++++++++++++ .../org/apache/poi/hdgf/streams/Stream.java | 3 +- 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 src/scratchpad/src/org/apache/poi/hdgf/exceptions/HDGFException.java diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java b/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java index a12f12623..00ca868fe 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java @@ -173,7 +173,7 @@ public class HSSFDateUtil } // Translate \- into just -, before matching - String fs = formatString.replace("\\-","-"); + String fs = formatString.replaceAll("\\\\-","-"); // Otherwise, check it's only made up of: // y m d - / diff --git a/src/scratchpad/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java b/src/scratchpad/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java index d54a091a3..5f7392739 100644 --- a/src/scratchpad/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java +++ b/src/scratchpad/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java @@ -280,7 +280,7 @@ public class XLS2CSVmra implements HSSFListener { // Java wants M not m for month format = format.replace('m','M'); // Change \- into -, if it's there - format = format.replace("\\-","-"); + format = format.replaceAll("\\\\-","-"); // Format as a date Date d = HSSFDateUtil.getJavaDate(value); diff --git a/src/scratchpad/src/org/apache/poi/hdgf/dev/VSDDumper.java b/src/scratchpad/src/org/apache/poi/hdgf/dev/VSDDumper.java index 3a4328858..3c20e4f3f 100644 --- a/src/scratchpad/src/org/apache/poi/hdgf/dev/VSDDumper.java +++ b/src/scratchpad/src/org/apache/poi/hdgf/dev/VSDDumper.java @@ -71,7 +71,7 @@ public class VSDDumper { System.out.println(ind + " Length is\t" + ptr.getLength() + " - " + Integer.toHexString(ptr.getLength())); System.out.println(ind + " Compressed is\t" + ptr.destinationCompressed()); - System.out.println(ind + " Stream is\t" + stream.getClass().getCanonicalName()); + System.out.println(ind + " Stream is\t" + stream.getClass().getName()); byte[] db = stream._getStore()._getContents(); String ds = ""; diff --git a/src/scratchpad/src/org/apache/poi/hdgf/exceptions/HDGFException.java b/src/scratchpad/src/org/apache/poi/hdgf/exceptions/HDGFException.java new file mode 100644 index 000000000..ae22b95ca --- /dev/null +++ b/src/scratchpad/src/org/apache/poi/hdgf/exceptions/HDGFException.java @@ -0,0 +1,44 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + + +package org.apache.poi.hdgf.exceptions; + +/** + * The superclass of all HDGF exceptions + * + * @author Yegor Kozlov + */ +public class HDGFException extends RuntimeException { + + public HDGFException() { + super(); + } + + public HDGFException(String message) { + super(message); + } + + public HDGFException(String message, Throwable cause) { + super(message, cause); + } + + public HDGFException(Throwable cause) { + super(cause); + } + +} diff --git a/src/scratchpad/src/org/apache/poi/hdgf/streams/Stream.java b/src/scratchpad/src/org/apache/poi/hdgf/streams/Stream.java index 0d26686e2..35aa7e529 100644 --- a/src/scratchpad/src/org/apache/poi/hdgf/streams/Stream.java +++ b/src/scratchpad/src/org/apache/poi/hdgf/streams/Stream.java @@ -21,6 +21,7 @@ import java.io.IOException; import org.apache.poi.hdgf.chunks.ChunkFactory; import org.apache.poi.hdgf.pointers.Pointer; import org.apache.poi.hdgf.pointers.PointerFactory; +import org.apache.poi.hdgf.exceptions.HDGFException; /** * Base of all Streams within a HDGF document. @@ -63,7 +64,7 @@ public abstract class Stream { ); } catch(IOException e) { // Should never occur - throw new IllegalStateException(e); + throw new HDGFException(e); } } else { store = new StreamStore(