]> source.dussan.org Git - poi.git/commitdiff
Fix some compiler/IntelliJ warnings
authorDominik Stadler <centic@apache.org>
Tue, 31 May 2016 13:48:25 +0000 (13:48 +0000)
committerDominik Stadler <centic@apache.org>
Tue, 31 May 2016 13:48:25 +0000 (13:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1746274 13f79535-47bb-0310-9956-ffa450edef68

15 files changed:
src/java/org/apache/poi/util/ByteField.java
src/java/org/apache/poi/util/CloseIgnoringInputStream.java
src/java/org/apache/poi/util/FixedField.java
src/java/org/apache/poi/util/IntegerField.java
src/java/org/apache/poi/util/LittleEndianConsts.java
src/java/org/apache/poi/util/LittleEndianInputStream.java
src/java/org/apache/poi/util/LongField.java
src/java/org/apache/poi/util/POILogFactory.java
src/java/org/apache/poi/util/RLEDecompressingInputStream.java
src/java/org/apache/poi/util/ShortField.java
src/java/org/apache/poi/util/StringUtil.java
src/java/org/apache/poi/util/SystemOutLogger.java
src/java/org/apache/poi/util/TempFileCreationStrategy.java
src/java/org/apache/poi/util/Units.java
src/java/org/apache/poi/util/XMLHelper.java

index 323fee8d67bd937fd647c96a6487da0f0c245605..ca6227791842806b13abc2e0e3f2f737cb1ab18b 100644 (file)
@@ -182,7 +182,7 @@ public class ByteField
      */
 
     public void readFromStream(final InputStream stream)
-        throws IOException, BufferUnderrunException
+        throws IOException
     {
        // TODO - are these ~Field used / necessary
        int ib = stream.read();
index 66e42c258c9c6baa39e4bb5236a80afa60f61248..82247b13af35b07a3a0a839ad624512fb5725410 100644 (file)
@@ -33,7 +33,6 @@ public class CloseIgnoringInputStream extends FilterInputStream {
    }
 
    public void close() {
-      // Does nothing and ignores you
-      return;
+      // Does nothing and ignores closing the wrapped stream
    }
 }
index efc74e69888750fb5ac565a89835eba15c11f219..45d6c6f714268abbfcff7e56d4d8b941c8df18bd 100644 (file)
@@ -41,7 +41,7 @@ public interface FixedField
      *            of the array's valid index range
      */
 
-    public void readFromBytes(byte [] data)
+    void readFromBytes(byte [] data)
         throws ArrayIndexOutOfBoundsException;
 
     /**
@@ -56,8 +56,8 @@ public interface FixedField
      *            the InputStream
      */
 
-    public void readFromStream(InputStream stream)
-        throws IOException, BufferUnderrunException;
+    void readFromStream(InputStream stream)
+        throws IOException;
 
     /**
      * write the value out to an array of bytes at the appropriate
@@ -70,7 +70,7 @@ public interface FixedField
      *            of the array's valid index range
      */
 
-    public void writeToBytes(byte [] data)
+    void writeToBytes(byte [] data)
         throws ArrayIndexOutOfBoundsException;
 
     /**
@@ -79,6 +79,6 @@ public interface FixedField
      * @return the value as a String
      */
 
-    public String toString();
+    String toString();
 }   // end public interface FixedField
 
index 39f5a21aeb6fee05b3e91072075949edd293df17..c86a008b779b1a70635427a733663a936382bb37 100644 (file)
@@ -182,7 +182,7 @@ public class IntegerField
      */
 
     public void readFromStream(final InputStream stream)
-        throws IOException, BufferUnderrunException
+        throws IOException
     {
         _value = LittleEndian.readInt(stream);
     }
index 472fa3dba34cbfe243196cbc70a0e558ea150f04..9f7e4a21a5e9d309875d9b7dcb59fe496bd9e1db 100644 (file)
@@ -26,14 +26,11 @@ package org.apache.poi.util;
  * @author Andrew C. Oliver (acoliver at apache dot org)
  */
 
-public interface LittleEndianConsts
-{
-
+public interface LittleEndianConsts {
     // sizes of various numbers in this environment
-    public static final int BYTE_SIZE   = 1;
-    public static final int SHORT_SIZE  = 2;
-    public static final int INT_SIZE    = 4;
-    public static final int LONG_SIZE   = 8;
-    public static final int DOUBLE_SIZE = 8;
+    int BYTE_SIZE   = 1;
+    int SHORT_SIZE  = 2;
+    int INT_SIZE    = 4;
+    int LONG_SIZE   = 8;
+    int DOUBLE_SIZE = 8;
 }   // end public interface LittleEndianConsts
-
index 406570f82f50fdff07c9885279a7f002b9c7d163..da42caf3d72661eaf2a3280345cbc7a4c64c743c 100644 (file)
@@ -21,8 +21,6 @@ import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.poi.util.LittleEndian.BufferUnderrunException;
-
 /**
  * Wraps an {@link InputStream} providing {@link LittleEndianInput}<p/>
  *
@@ -76,14 +74,12 @@ public class LittleEndianInputStream extends FilterInputStream implements Little
      * get an unsigned int value from an InputStream
      * 
      * @return the unsigned int (32-bit) value
-     * @exception IOException
-     *                will be propagated back to the caller
-     * @exception BufferUnderrunException
-     *                if the stream cannot provide enough bytes
+     * @exception RuntimeException
+     *                wraps any IOException thrown from reading the stream.
      */
     public long readUInt() {
        long retNum = readInt();
-       return retNum & 0x00FFFFFFFFl;
+       return retNum & 0x00FFFFFFFFL;
     }
        
        public long readLong() {
index 8f4fbe263abd73a4a6fa25d2ce396c960140d36d..9aeffb36ea4fe545fa5bada1d3034694aca1a27b 100644 (file)
@@ -179,7 +179,7 @@ public class LongField
      */
 
     public void readFromStream(final InputStream stream)
-        throws IOException, BufferUnderrunException
+        throws IOException
     {
         _value = LittleEndian.readLong(stream);
     }
index 1227a0d5ca6bb63b643f1bcda08200886102cc3e..ba2551de7b7c397fa0cd2e99fcd3cead59988c13 100644 (file)
@@ -72,8 +72,6 @@ public final class POILogFactory {
      * @return a POILogger for the specified class
      */
     public static POILogger getLogger(final String cat) {
-        POILogger logger = null;
-
         // If we haven't found out what logger to use yet,
         //  then do so now
         // Don't look it up until we're first asked, so
@@ -82,7 +80,9 @@ public final class POILogFactory {
         if(_loggerClassName == null) {
                try {
                        _loggerClassName = System.getProperty("org.apache.poi.util.POILogger");
-               } catch(Exception e) {}
+               } catch(Exception e) {
+                // ignore any exception here
+            }
 
                // Use the default logger if none specified,
                //  or none could be fetched
@@ -100,7 +100,7 @@ public final class POILogFactory {
 
         // Fetch the right logger for them, creating
         //  it if that's required
-        logger = _loggers.get(cat);
+        POILogger logger = _loggers.get(cat);
         if (logger == null) {
             try {
                 @SuppressWarnings("unchecked")
index 08d9c2f9834a26253e9b8bb163439f951c12fec1..de18fee36c7dd2bc389459e242e59b91e46e3f4d 100644 (file)
@@ -67,7 +67,7 @@ public class RLEDecompressingInputStream extends InputStream {
     /**
      * Creates a new wrapper RLE Decompression InputStream.
      * 
-     * @param in
+     * @param in The stream to wrap with the RLE Decompression
      * @throws IOException
      */
     public RLEDecompressingInputStream(InputStream in) throws IOException {
@@ -275,11 +275,11 @@ public class RLEDecompressingInputStream extends InputStream {
         return (b0 & 0xFF) | ((b1 & 0xFF) << 8) | ((b2 & 0xFF) << 16) | ((b3 & 0xFF) << 24);
     }
 
-    public static final byte[] decompress(byte[] compressed) throws IOException {
+    public static byte[] decompress(byte[] compressed) throws IOException {
         return decompress(compressed, 0, compressed.length);
     }
     
-    public static final byte[] decompress(byte[] compressed, int offset, int length) throws IOException {
+    public static byte[] decompress(byte[] compressed, int offset, int length) throws IOException {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         InputStream instream = new ByteArrayInputStream(compressed, offset, length);
         InputStream stream = new RLEDecompressingInputStream(instream);
index 4a9b0db4f5c361c77bbf059ce619c74c5730dff6..29d91df7f40b87d503dada82230cc61fde9bd8f4 100644 (file)
@@ -179,7 +179,7 @@ public class ShortField
      */
 
     public void readFromStream(final InputStream stream)
-        throws IOException, BufferUnderrunException
+        throws IOException
     {
         _value = LittleEndian.readShort(stream);
     }
index cb465b241cf999d815bbeeebcc18d3faa9cebf49..afec8225d479568c3654f58a3859a6873ddd9e23 100644 (file)
@@ -283,7 +283,7 @@ public class StringUtil {
        /**
         * Checks to see if a given String needs to be represented as Unicode
         *
-        * @param value
+        * @param value The string to look at.
         * @return true if string needs Unicode to be represented.
         */
        public static boolean isUnicodeString(final String value) {
index a13882f56da0f4fe02a8eb59d9c8414f62ce8a13..e665ba63245cb47cc4f5084f5e258b72f00bfdac 100644 (file)
@@ -87,10 +87,7 @@ public class SystemOutLogger extends POILogger
             currentLevel = POILogger.DEBUG;
         }
 
-        if (level >= currentLevel) {
-            return true;
-        }
-        return false;
+        return level >= currentLevel;
     }
 
 
index 1e9ae9cdbbe6131681d296d734e713940f066762..d7752e766f497e19b5a9eaeafa7979bbc2f09d88 100644 (file)
@@ -34,5 +34,5 @@ public interface TempFileCreationStrategy {
      * 
      * @throws IOException If no temporary file could be created.
      */
-    public File createTempFile(String prefix, String suffix) throws IOException;
+    File createTempFile(String prefix, String suffix) throws IOException;
 }
index 6649c1f8607087cb9697097911def75087bb511f..4ee12cb9c5b15b9edd2a36cd0c75cbc29cfea639 100644 (file)
@@ -75,23 +75,22 @@ public class Units {
     /**\r
      * Converts a value of type FixedPoint to a floating point\r
      *\r
-     * @param fixedPoint\r
+     * @param fixedPoint value in fixed point notation\r
      * @return floating point (double)\r
      * \r
      * @see <a href="http://msdn.microsoft.com/en-us/library/dd910765(v=office.12).aspx">[MS-OSHARED] - 2.2.1.6 FixedPoint</a>\r
      */\r
     public static double fixedPointToDouble(int fixedPoint) {\r
         int i = (fixedPoint >> 16);\r
-        int f = (fixedPoint >> 0) & 0xFFFF;\r
-        double floatPoint = (i + f/65536d);\r
-        return floatPoint;\r
+        int f = fixedPoint & 0xFFFF;\r
+        return (i + f/65536d);\r
     }\r
     \r
     /**\r
      * Converts a value of type floating point to a FixedPoint\r
      *\r
-     * @param floatPoint\r
-     * @return fixedPoint\r
+     * @param floatPoint value in floating point notation\r
+     * @return fixedPoint value in fixed points notation\r
      * \r
      * @see <a href="http://msdn.microsoft.com/en-us/library/dd910765(v=office.12).aspx">[MS-OSHARED] - 2.2.1.6 FixedPoint</a>\r
      */\r
@@ -100,8 +99,7 @@ public class Units {
         double integralPart = floatPoint - fractionalPart;\r
         int i = (int)Math.floor(integralPart);\r
         int f = (int)Math.rint(fractionalPart*65536d);\r
-        int fixedPoint = (i << 16) | (f & 0xFFFF);\r
-        return fixedPoint;\r
+        return (i << 16) | (f & 0xFFFF);\r
     }\r
 \r
     public static double masterToPoints(int masterDPI) {\r
index 22d27208be067341c458452c4965039045caa996..8797475461e0839179cc0227a398eca1bda22dce 100644 (file)
@@ -22,7 +22,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
 
 /**
  * Helper methods for working with javax.xml classes.
- * @see org.apache.poi.util.SAXHelper
  */
 public final class XMLHelper
 {