*/
public void readFromStream(final InputStream stream)
- throws IOException, BufferUnderrunException
+ throws IOException
{
// TODO - are these ~Field used / necessary
int ib = stream.read();
}
public void close() {
- // Does nothing and ignores you
- return;
+ // Does nothing and ignores closing the wrapped stream
}
}
* of the array's valid index range
*/
- public void readFromBytes(byte [] data)
+ void readFromBytes(byte [] data)
throws ArrayIndexOutOfBoundsException;
/**
* 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
* of the array's valid index range
*/
- public void writeToBytes(byte [] data)
+ void writeToBytes(byte [] data)
throws ArrayIndexOutOfBoundsException;
/**
* @return the value as a String
*/
- public String toString();
+ String toString();
} // end public interface FixedField
*/
public void readFromStream(final InputStream stream)
- throws IOException, BufferUnderrunException
+ throws IOException
{
_value = LittleEndian.readInt(stream);
}
* @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
-
import java.io.IOException;
import java.io.InputStream;
-import org.apache.poi.util.LittleEndian.BufferUnderrunException;
-
/**
* Wraps an {@link InputStream} providing {@link LittleEndianInput}<p/>
*
* 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() {
*/
public void readFromStream(final InputStream stream)
- throws IOException, BufferUnderrunException
+ throws IOException
{
_value = LittleEndian.readLong(stream);
}
* @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
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
// 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")
/**
* 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 {
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);
*/
public void readFromStream(final InputStream stream)
- throws IOException, BufferUnderrunException
+ throws IOException
{
_value = LittleEndian.readShort(stream);
}
/**
* 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) {
currentLevel = POILogger.DEBUG;
}
- if (level >= currentLevel) {
- return true;
- }
- return false;
+ return level >= currentLevel;
}
*
* @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;
}
/**\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
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
/**
* Helper methods for working with javax.xml classes.
- * @see org.apache.poi.util.SAXHelper
*/
public final class XMLHelper
{