jeremias 2003/07/27 10:15:07
Modified: io/src/java/org/apache/commons/io/input
SwappedDataInputStream.java
Log:
Correct license
Javadocs
Use ProxyInputStream as base class to reduce code.
Revision Changes Path
1.3 +51 -83
jakarta-commons-sandbox/io/src/java/org/apache/commons/io/input/SwappedDataInputStream.java
Index: SwappedDataInputStream.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/input/SwappedDataInputStream.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SwappedDataInputStream.java 25 Jul 2003 07:51:26 -0000 1.2
+++ SwappedDataInputStream.java 27 Jul 2003 17:15:06 -0000 1.3
@@ -1,9 +1,7 @@
-package org.apache.commons.io.input;
-
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -18,21 +16,21 @@
* the documentation and/or other materials provided with the
* distribution.
*
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
- * written permission, please contact [EMAIL PROTECTED]
- *
- * 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
- * prior written permission of the Apache Software Foundation.
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -53,6 +51,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+package org.apache.commons.io.input;
import java.io.DataInput;
import java.io.EOFException;
@@ -64,57 +63,67 @@
/**
* DataInput for systems relying on little endian data formats.
*
+ * <p><b>Origin of code: </b>Avalon Excalibur (IO)</p>
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @version CVS $Revision$ $Date$
- * @since 4.0
*/
-public class SwappedDataInputStream
+public class SwappedDataInputStream extends ProxyInputStream
implements DataInput
{
- //The underlying input stream
- private InputStream m_input;
+ /**
+ * Constructs a SwappedDataInputStream.
+ * @param input InputStream to read from
+ */
public SwappedDataInputStream( final InputStream input )
{
- m_input = input;
+ super( input );
}
+ /** @see java.io.DataInput#readBoolean() */
public boolean readBoolean()
throws IOException, EOFException
{
return ( 0 == readByte() );
}
+ /** @see java.io.DataInput#readByte() */
public byte readByte()
throws IOException, EOFException
{
- return (byte)m_input.read();
+ return (byte)in.read();
}
+ /** @see java.io.DataInput#readChar() */
public char readChar()
throws IOException, EOFException
{
return (char)readShort();
}
+ /** @see java.io.DataInput#readDouble() */
public double readDouble()
throws IOException, EOFException
{
- return EndianUtils.readSwappedDouble( m_input );
+ return EndianUtils.readSwappedDouble( in );
}
+ /** @see java.io.DataInput#readFloat() */
public float readFloat()
throws IOException, EOFException
{
- return EndianUtils.readSwappedFloat( m_input );
+ return EndianUtils.readSwappedFloat( in );
}
+ /** @see java.io.DataInput#readFully(byte[]) */
public void readFully( final byte[] data )
throws IOException, EOFException
{
readFully( data, 0, data.length );
}
+ /** @see java.io.DataInput#readFully(byte[], int, int) */
public void readFully( final byte[] data, final int offset, final int length )
throws IOException, EOFException
{
@@ -134,103 +143,62 @@
}
}
+ /** @see java.io.DataInput#readInt() */
public int readInt()
throws IOException, EOFException
{
- return EndianUtils.readSwappedInteger( m_input );
+ return EndianUtils.readSwappedInteger( in );
}
+ /** @see java.io.DataInput#readLine() */
public String readLine()
throws IOException, EOFException
{
- throw new IOException( "Operation not supported" );
+ throw new UnsupportedOperationException(
+ "Operation not supported: readLine()" );
}
+ /** @see java.io.DataInput#readLong() */
public long readLong()
throws IOException, EOFException
{
- return EndianUtils.readSwappedLong( m_input );
+ return EndianUtils.readSwappedLong( in );
}
+ /** @see java.io.DataInput#readShort() */
public short readShort()
throws IOException, EOFException
{
- return EndianUtils.readSwappedShort( m_input );
+ return EndianUtils.readSwappedShort( in );
}
+ /** @see java.io.DataInput#readUnsignedByte() */
public int readUnsignedByte()
throws IOException, EOFException
{
- return m_input.read();
+ return in.read();
}
+ /** @see java.io.DataInput#readUnsignedShort() */
public int readUnsignedShort()
throws IOException, EOFException
{
- return EndianUtils.readSwappedUnsignedShort( m_input );
+ return EndianUtils.readSwappedUnsignedShort( in );
}
+ /** @see java.io.DataInput#readUTF() */
public String readUTF()
throws IOException, EOFException
{
- throw new IOException( "Operation not supported" );
+ throw new UnsupportedOperationException(
+ "Operation not supported: readUTF()" );
}
+ /** @see java.io.DataInput#skipBytes(int) */
public int skipBytes( final int count )
throws IOException, EOFException
{
- return (int)m_input.skip( count );
- }
-
- public int available()
- throws IOException, EOFException
- {
- return m_input.available();
- }
-
- public void close()
- throws IOException, EOFException
- {
- m_input.close();
- }
-
- public int read()
- throws IOException, EOFException
- {
- return m_input.read();
- }
-
- public int read( final byte[] data )
- throws IOException, EOFException
- {
- return read( data, 0, data.length );
- }
-
- public int read( final byte[] data, final int offset, final int length )
- throws IOException, EOFException
- {
- return m_input.read( data, offset, length );
- }
-
- public long skip( final long count )
- throws IOException, EOFException
- {
- return m_input.skip( count );
+ return (int)in.skip( count );
}
- public void mark( final int readLimit )
- {
- m_input.mark( readLimit );
- }
-
- public boolean markSupported()
- {
- return m_input.markSupported();
- }
-
- public void reset()
- throws IOException
- {
- m_input.reset();
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]