activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r915018 [2/4] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/ main/activemq/commands/ main/activemq/io/ main/activemq/wireformat/openwire/marshal/ main/activemq/wireformat/openwire/utils/ main/decaf/internal/io/ main/decaf/io/ mai...
Date Mon, 22 Feb 2010 19:02:36 GMT
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedInputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedInputStream.h Mon Feb 22 19:02:35 2010
@@ -18,12 +18,15 @@
 #ifndef _DECAF_IO_BUFFEREDINPUTSTREAM_H_
 #define _DECAF_IO_BUFFEREDINPUTSTREAM_H_
 
+#include <decaf/util/Config.h>
 #include <decaf/io/FilterInputStream.h>
 #include <decaf/lang/exceptions/IllegalArgumentException.h>
 
 namespace decaf{
 namespace io{
 
+    class StreamBuffer;
+
     /**
      * A wrapper around another input stream that performs
      * a buffered read, where it reads more data than it needs
@@ -33,56 +36,33 @@
     class DECAF_API BufferedInputStream : public FilterInputStream {
     private:
 
-        /**
-         * The internal buffer.
-         */
-        unsigned char* buffer;
-
-        /**
-         * The buffer size.
-         */
-        std::size_t bufferSize;
-
-        /**
-         * The current head of the buffer.
-         */
-        std::size_t head;
-
-        /**
-         * The current tail of the buffer.
-         */
-        std::size_t tail;
-
-        /**
-         * The current limit, which when passed, invalidates the current mark.
-         */
-        int markLimit;
-
-        /**
-         * The currently marked position. -1 indicates no mark has been set or the
-         * mark has been invalidated.
-         */
-        int markpos;
+        StreamBuffer* buffer;
 
     public:
 
         /**
          * Constructor
-         * @param stream The target input stream.
-         * @param own indicates if we own the stream object, defaults to false
+         *
+         * @param stream
+         *      The target input stream to buffer.
+         * @param own
+         *      Indicates if we own the stream object, defaults to false.
          */
         BufferedInputStream( InputStream* stream, bool own = false );
 
         /**
          * Constructor
-         * @param stream the target input stream
-         * @param bufferSize the size for the internal buffer.
-         * @param own indicates if we own the stream object, defaults to false.
+         *
+         * @param stream
+         *      The target input stream to buffer.
+         * @param bufferSize
+         *      The size in bytes to allocate for the internal buffer.
+         * @param own
+         *      Indicates if we own the stream object, defaults to false.
+         *
          * @throws IllegalArgumentException is the size is zero.
          */
-        BufferedInputStream( InputStream* stream,
-                             std::size_t bufferSize,
-                             bool own = false )
+        BufferedInputStream( InputStream* stream, std::size_t bufferSize, bool own = false )
             throw ( lang::exceptions::IllegalArgumentException );
 
         virtual ~BufferedInputStream();
@@ -93,45 +73,14 @@
          * in the buffer and the data available on the target
          * input stream.
          */
-        virtual std::size_t available() const throw ( IOException ) {
-            if( buffer == NULL || this->isClosed() ) {
-                throw IOException(
-                    __FILE__, __LINE__,
-                    "BufferedInputStream::available - Buffer was closed");
-            }
-            return ( tail - head ) + inputStream->available();
-        }
+        virtual std::size_t available() const throw ( decaf::io::IOException );
 
         /**
          * Close this BufferedInputStream. This implementation closes the target
          * stream and releases any resources associated with it.
          * @throws IOException If an error occurs attempting to close this stream.
          */
-        virtual void close() throw( IOException );
-
-        /**
-         * Reads a single byte from the buffer.  Blocks until
-         * the data is available.
-         * @return The next byte.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual int read() throw ( IOException );
-
-        /**
-         * Reads an array of bytes from the buffer.  Blocks
-         * until the requested number of bytes are available.
-         * @param buffer (out) the target buffer.
-         * @param offset the position in the buffer to start reading from.
-         * @param bufferSize the size of the output buffer.
-         * @return The number of bytes read or -1 if EOF
-         * @throws IOException thrown if an error occurs.
-         * @throws NullPointerException if buffer is NULL
-         */
-        virtual int read( unsigned char* buffer, std::size_t size,
-                          std::size_t offset, std::size_t length )
-            throw ( decaf::io::IOException,
-                    decaf::lang::exceptions::IndexOutOfBoundsException,
-                    decaf::lang::exceptions::NullPointerException );
+        virtual void close() throw( decaf::io::IOException );
 
         /**
          * Skips over and discards n bytes of data from this input stream. The
@@ -150,7 +99,8 @@
          * @throws IOException if an error occurs
          */
         virtual std::size_t skip( std::size_t num )
-            throw ( io::IOException, lang::exceptions::UnsupportedOperationException );
+            throw ( decaf::io::IOException,
+                    decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Marks the current position in the stream A subsequent call to the
@@ -164,10 +114,7 @@
          * @param readLimit
          *      max bytes read before marked position is invalid.
          */
-        virtual void mark( int readLimit ) {
-            this->markLimit = readLimit;
-            this->markpos = (int)head;
-        }
+        virtual void mark( int readLimit );
 
         /**
          * Repositions this stream to the position at the time the mark method was
@@ -192,11 +139,7 @@
          *     of the read method depend on the particular type of the input stream.
          * @throws IOException
          */
-        virtual void reset() throw ( IOException ) {
-            throw IOException(
-                __FILE__, __LINE__,
-                "BufferedInputStream::reset - mark no yet supported." );
-        }
+        virtual void reset() throw ( decaf::io::IOException );
 
         /**
          * Determines if this input stream supports the mark and reset methods.
@@ -204,63 +147,21 @@
          * a particular input stream instance.
          * @returns true if this stream instance supports marks
          */
-        virtual bool markSupported() const{ return false; }
-
-    private:
-
-        /**
-         * Initializes the internal structures.
-         * @param bufferSize
-         *      size of buffer to allocate
-         */
-        void init( std::size_t bufferSize );
-
-        /**
-         * Populates the buffer with as much data as possible
-         * from the target input stream.
-         * @returns total bytes read, or -1 if EOF.
-         * @throws IOException
-         */
-        int bufferData() throw ( IOException );
+        virtual bool markSupported() const{ return true; }
 
-        /**
-         * Returns the number of bytes that are currently unused
-         * in the buffer.
-         */
-        std::size_t getUnusedBytes() const{
-            return bufferSize - tail;
-        }
+    protected:
 
-        /**
-         * Returns the current tail position of the buffer.
-         */
-        unsigned char* getTail() {
-            return buffer + tail;
-        }
+        virtual int doReadByte() throw ( decaf::io::IOException );
 
-        /**
-         * Initializes the head and tail indices to the beginning
-         * of the buffer.
-         */
-        void clear(){
-            head = tail = 0;
-        }
+        virtual int doReadArrayBounded( unsigned char* buffer, std::size_t size,
+                                        std::size_t offset, std::size_t length )
+            throw ( decaf::io::IOException,
+                    decaf::lang::exceptions::IndexOutOfBoundsException,
+                    decaf::lang::exceptions::NullPointerException );
 
-        /**
-         * Indicates whether or not the buffer is empty.
-         */
-        bool isEmpty() const{
-            return head == tail;
-        }
+    private:
 
-        /**
-         * Clears the buffer if there is no data remaining.
-         */
-        void normalizeBuffer(){
-            if( isEmpty() ){
-                clear();
-            }
-        }
+        int bufferData( InputStream* stream ) throw ( decaf::io::IOException );
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedOutputStream.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedOutputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedOutputStream.cpp Mon Feb 22 19:02:35 2010
@@ -16,14 +16,9 @@
  */
 
 #include "BufferedOutputStream.h"
-#include <algorithm>
 
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
+#include <decaf/lang/System.h>
+#include <decaf/lang/Math.h>
 
 using namespace std;
 using namespace decaf;
@@ -34,17 +29,14 @@
 ////////////////////////////////////////////////////////////////////////////////
 BufferedOutputStream::BufferedOutputStream( OutputStream* stream, bool own )
 : FilterOutputStream( stream, own ) {
+
     // Default to 1k buffer.
-    init( 1024 );
+    init( 8192 );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-BufferedOutputStream::BufferedOutputStream( OutputStream* stream,
-    std::size_t bufSize,
-    bool own )
-        throw ( lang::exceptions::IllegalArgumentException )
-
-: FilterOutputStream( stream, own ) {
+BufferedOutputStream::BufferedOutputStream( OutputStream* stream, std::size_t bufSize, bool own )
+ : FilterOutputStream( stream, own ) {
 
     try {
         this->init( bufSize );
@@ -71,12 +63,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 void BufferedOutputStream::init( std::size_t bufSize ) {
 
-    if( bufSize <= 0 ) {
-        throw new IllegalArgumentException(
-            __FILE__, __LINE__,
-            "BufferedOutputStream::init - Size must be greater than zero");
-    }
-
     this->bufferSize = bufSize;
 
     buffer = new unsigned char[bufSize];
@@ -84,29 +70,22 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void BufferedOutputStream::close() throw( io::IOException ){
-
-    // let parent close the inputStream
-    FilterOutputStream::close();
-}
-
-////////////////////////////////////////////////////////////////////////////////
 void BufferedOutputStream::emptyBuffer() throw ( IOException ){
 
-    if( outputStream == NULL ) {
+    if( this->outputStream == NULL ) {
         throw IOException(
             __FILE__, __LINE__,
             "BufferedOutputStream::emptyBuffer - OutputStream is closed" );
     }
 
-    if( head != tail ){
-        outputStream->write( buffer+head, tail-head, 0, tail-head );
+    if( this->head != this->tail ){
+        this->outputStream->write( this->buffer + this->head, this->tail -this->head );
     }
-    head = tail = 0;
+    this->head = this->tail = 0;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void BufferedOutputStream::flush() throw ( IOException ){
+void BufferedOutputStream::flush() throw ( decaf::io::IOException ) {
 
     try {
 
@@ -127,7 +106,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void BufferedOutputStream::write( const unsigned char c ) throw ( IOException ){
+void BufferedOutputStream::doWriteByte( const unsigned char c )
+    throw ( decaf::io::IOException ) {
 
     try{
 
@@ -148,12 +128,12 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void BufferedOutputStream::write( const std::vector<unsigned char>& buffer )
-    throw ( IOException ) {
+void BufferedOutputStream::doWriteArray( const unsigned char* buffer, std::size_t size )
+    throw ( decaf::io::IOException ) {
 
     try{
 
-        if( buffer.empty() ) {
+        if( size == 0 ) {
             return;
         }
 
@@ -163,15 +143,15 @@
                 "BufferedOutputStream::write - Stream is clsoed" );
         }
 
-        this->write( &buffer[0], buffer.size(), 0, buffer.size() );
+        this->doWriteArrayBounded( buffer, size, 0, size );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void BufferedOutputStream::write( const unsigned char* buffer, std::size_t size,
-                                  std::size_t offset, std::size_t length )
+void BufferedOutputStream::doWriteArrayBounded( const unsigned char* buffer, std::size_t size,
+                                                std::size_t offset, std::size_t length )
     throw ( decaf::io::IOException,
             decaf::lang::exceptions::NullPointerException,
             decaf::lang::exceptions::IndexOutOfBoundsException ) {
@@ -208,10 +188,13 @@
             }
 
             // Get the number of bytes left to write.
-            std::size_t bytesToWrite = min( (int)bufferSize-tail, length-pos );
+            std::size_t bytesToWrite = Math::min( (long long)( bufferSize - tail ),
+                                                  (long long)( length - pos ) );
 
             // Copy the data.
-            memcpy( this->buffer+tail, buffer+offset+pos, bytesToWrite );
+            //memcpy( this->buffer+tail, buffer+offset+pos, bytesToWrite );
+
+            System::arraycopy( buffer, offset + pos, this->buffer, this->tail, bytesToWrite );
 
             // Increase the tail position.
             tail += bytesToWrite;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedOutputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BufferedOutputStream.h Mon Feb 22 19:02:35 2010
@@ -28,8 +28,7 @@
      * Wrapper around another output stream that buffers
      * output before writing to the target output stream.
      */
-    class DECAF_API BufferedOutputStream : public FilterOutputStream
-    {
+    class DECAF_API BufferedOutputStream : public FilterOutputStream {
     private:
 
         /**
@@ -74,65 +73,30 @@
          * @param own
          *      Indicates if this class owns the stream pointer.
          */
-        BufferedOutputStream( OutputStream* stream,
-                              std::size_t bufferSize,
-                              bool own = false )
-            throw ( lang::exceptions::IllegalArgumentException );
+        BufferedOutputStream( OutputStream* stream, std::size_t bufferSize, bool own = false );
 
         virtual ~BufferedOutputStream();
 
         /**
-         * Writes a single byte to the output stream.
-         * @param c the byte.
+         * Invokes flush on the target output stream.
          * @throws IOException thrown if an error occurs.
          */
-        virtual void write( unsigned char c ) throw ( IOException );
+        virtual void flush() throw ( decaf::io::IOException );
 
-        /**
-         * Writes an array of bytes to the output stream.
-         * @param buffer The bytes to write.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual void write( const std::vector<unsigned char>& buffer )
-            throw ( IOException );
+    protected:
 
-        /**
-         * Writes an array of bytes to the output stream in order starting at buffer[offset]
-         * and proceeding until the number of bytes specified by the length argument are
-         * written or an error occurs.
-         *
-         * @param buffer
-         *      The array of bytes to write.
-         * @param size
-         *      The size of the buffer array passed.
-         * @param offset
-         *      The position to start writing in buffer.
-         * @param length
-         *      The number of bytes from the buffer to be written.
-         *
-         * @throws IOException if an I/O error occurs.
-         * @throws NullPointerException thrown if buffer is Null.
-         * @throws IndexOutOfBoundsException if the offset + length > size.
-         */
-        virtual void write( const unsigned char* buffer, std::size_t size,
-                            std::size_t offset, std::size_t length )
+        virtual void doWriteByte( unsigned char c ) throw ( decaf::io::IOException );
+
+        virtual void doWriteArray( const unsigned char* buffer, std::size_t size )
+            throw ( decaf::io::IOException );
+
+        virtual void doWriteArrayBounded( const unsigned char* buffer, std::size_t size,
+                                          std::size_t offset, std::size_t length )
             throw ( decaf::io::IOException,
                     decaf::lang::exceptions::NullPointerException,
                     decaf::lang::exceptions::IndexOutOfBoundsException );
 
-        /**
-         * Invokes flush on the target output stream.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual void flush() throw ( IOException );
-
-        /**
-         * Invokes close on the target output stream.
-         * @throws IOException thrown if an error occurs.
-         */
-        void close() throw( io::IOException );
-
-   private:
+    private:
 
         /**
          * Initializes the internal structures.
@@ -144,7 +108,7 @@
         /**
          * Writes the contents of the buffer to the output stream.
          */
-        void emptyBuffer() throw ( IOException );
+        void emptyBuffer() throw ( decaf::io::IOException );
 
    };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.cpp Mon Feb 22 19:02:35 2010
@@ -79,6 +79,26 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+std::size_t ByteArrayInputStream::available() const throw ( IOException ) {
+
+    if( activeBuffer == NULL ){
+        throw IOException(
+            __FILE__, __LINE__,
+            "buffer has not been initialized");
+    }
+
+    return std::distance( pos, activeBuffer->end() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteArrayInputStream::mark( int readLimit DECAF_UNUSED ) {
+
+    // the reset point is now the marked position until a new byte buffer
+    // is set on this stream.
+    this->markpos = pos;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void ByteArrayInputStream::reset() throw ( IOException ){
 
     try{
@@ -96,7 +116,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int ByteArrayInputStream::read() throw ( IOException ){
+int ByteArrayInputStream::doReadByte() throw ( IOException ){
 
     try{
 
@@ -117,14 +137,15 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int ByteArrayInputStream::read( unsigned char* buffer, std::size_t size, std::size_t offset, std::size_t length )
+int ByteArrayInputStream::doReadArrayBounded( unsigned char* buffer, std::size_t size,
+                                              std::size_t offset, std::size_t length )
     throw ( decaf::io::IOException,
             decaf::lang::exceptions::IndexOutOfBoundsException,
             decaf::lang::exceptions::NullPointerException ) {
 
     try{
 
-        if( size == 0 || length == 0 ) {
+        if( length == 0 ) {
             return 0;
         }
 
@@ -166,6 +187,7 @@
         return (int)ix;
     }
     DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCHALL_THROW( IOException )
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h Mon Feb 22 19:02:35 2010
@@ -52,11 +52,6 @@
         std::vector<unsigned char>::const_iterator pos;
 
         /**
-         * Synchronization object.
-         */
-        util::concurrent::Mutex mutex;
-
-        /**
          * The currently marked position or begin() of activeBuffer.
          */
         std::vector<unsigned char>::const_iterator markpos;
@@ -106,45 +101,10 @@
                                    std::size_t bufferSize );
 
         /**
-         * Indcates the number of bytes avaialable.
+         * Indicates the number of bytes available.
          * @return The number of bytes until the end of the internal buffer.
          */
-        virtual std::size_t available() const throw ( IOException ) {
-            if( activeBuffer == NULL ){
-                throw IOException(
-                    __FILE__, __LINE__,
-                    "buffer has not been initialized");
-            }
-
-            return std::distance( pos, activeBuffer->end() );
-        }
-
-        /**
-         * Reads a single byte from the buffer.
-         * @return The next byte.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual int read() throw ( IOException );
-
-        /**
-         * Reads an array of bytes from the buffer.
-         * @param buffer (out) the target buffer.
-         * @param offset the position in the buffer to start reading from.
-         * @param bufferSize the size of the output buffer.
-         * @return The number of bytes read.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual int read( unsigned char* buffer, std::size_t size,
-                          std::size_t offset, std::size_t length )
-            throw ( decaf::io::IOException,
-                    decaf::lang::exceptions::IndexOutOfBoundsException,
-                    decaf::lang::exceptions::NullPointerException );
-
-        /**
-         * Closes the target input stream.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual void close() throw( io::IOException ){ /* do nothing */ }
+        virtual std::size_t available() const throw ( IOException );
 
         /**
          * Skips over and discards n bytes of data from this input stream. The
@@ -175,11 +135,7 @@
          * is called so long the readLimit is not reached.
          * @param readLimit - max bytes read before marked position is invalid.
          */
-        virtual void mark( int readLimit DECAF_UNUSED ) {
-            // the reset point is now the marked position until a new byte buffer
-            // is set on this stream.
-            this->markpos = pos;
-        }
+        virtual void mark( int readLimit );
 
         /**
          * Resets the read index to the beginning of the byte array, unless mark
@@ -198,53 +154,13 @@
 
     protected:
 
-        virtual void lock() throw( decaf::lang::exceptions::RuntimeException ) {
-            mutex.lock();
-        }
-
-        virtual bool tryLock() throw( decaf::lang::exceptions::RuntimeException ) {
-            return mutex.tryLock();
-        }
-
-        virtual void unlock() throw( decaf::lang::exceptions::RuntimeException ) {
-            mutex.unlock();
-        }
-
-        virtual void wait() throw( decaf::lang::exceptions::RuntimeException,
-                                   decaf::lang::exceptions::IllegalMonitorStateException,
-                                   decaf::lang::exceptions::InterruptedException ) {
-
-            mutex.wait();
-        }
-
-        virtual void wait( long long millisecs )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
-
-            mutex.wait( millisecs );
-        }
-
-        virtual void wait( long long millisecs, int nanos )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalArgumentException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
+        virtual int doReadByte() throw ( IOException );
 
-            mutex.wait( millisecs, nanos );
-        }
-
-        virtual void notify() throw( decaf::lang::exceptions::RuntimeException,
-                                     decaf::lang::exceptions::IllegalMonitorStateException ) {
-
-            mutex.notify();
-        }
-
-        virtual void notifyAll() throw( decaf::lang::exceptions::RuntimeException,
-                                        decaf::lang::exceptions::IllegalMonitorStateException ) {
-
-            mutex.notifyAll();
-        }
+        virtual int doReadArrayBounded( unsigned char* buffer, std::size_t size,
+                                        std::size_t offset, std::size_t length )
+            throw ( decaf::io::IOException,
+                    decaf::lang::exceptions::IndexOutOfBoundsException,
+                    decaf::lang::exceptions::NullPointerException );
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.cpp Mon Feb 22 19:02:35 2010
@@ -24,11 +24,15 @@
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-ByteArrayOutputStream::ByteArrayOutputStream() {
+ByteArrayOutputStream::ByteArrayOutputStream() : OutputStream() {
     activeBuffer = &defaultBuffer;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+ByteArrayOutputStream::~ByteArrayOutputStream() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
 ByteArrayOutputStream::ByteArrayOutputStream( vector<unsigned char>& buffer) {
     setBuffer( buffer );
 }
@@ -39,41 +43,48 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ByteArrayOutputStream::reset() throw ( IOException ) {
-    // Empty the contents of the buffer to the output stream.
-    activeBuffer->clear();
+const unsigned char* ByteArrayOutputStream::toByteArray() const {
+    if( activeBuffer == NULL || activeBuffer->size() == 0 ){
+        return NULL;
+    }
+
+    return &(*activeBuffer)[0];
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ByteArrayOutputStream::write( unsigned char c )
-    throw ( IOException ) {
-
-    try{
-        activeBuffer->push_back( c );
+const std::vector<unsigned char> ByteArrayOutputStream::toByteArrayRef() const {
+    if( activeBuffer == NULL ){
+        return defaultBuffer;
     }
-    DECAF_CATCH_RETHROW( IOException )
-    DECAF_CATCHALL_THROW( IOException )
+
+    return *activeBuffer;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ByteArrayOutputStream::write( const std::vector<unsigned char>& buffer )
-    throw ( IOException ) {
+std::size_t ByteArrayOutputStream::size() const {
+    return activeBuffer->size();
+}
 
-    try{
+////////////////////////////////////////////////////////////////////////////////
+void ByteArrayOutputStream::reset() throw ( IOException ) {
+    // Empty the contents of the buffer to the output stream.
+    activeBuffer->clear();
+}
 
-        if( buffer.empty() ) {
-            return;
-        }
+////////////////////////////////////////////////////////////////////////////////
+void ByteArrayOutputStream::doWriteByte( unsigned char c )
+    throw ( IOException ) {
 
-        this->write( &buffer[0], buffer.size(), 0, buffer.size() );
+    try{
+        activeBuffer->push_back( c );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ByteArrayOutputStream::write( const unsigned char* buffer, std::size_t size,
-                                   std::size_t offset, std::size_t length )
+void ByteArrayOutputStream::doWriteArrayBounded( const unsigned char* buffer, std::size_t size,
+                                                 std::size_t offset, std::size_t length )
     throw ( decaf::io::IOException,
             decaf::lang::exceptions::NullPointerException,
             decaf::lang::exceptions::IndexOutOfBoundsException ) {
@@ -127,7 +138,7 @@
                 "ByteArrayOutputStream::writeTo - Passed stream pointer is null" );
         }
 
-        out->write( this->toByteArray(), this->size(), 0, this->size() );
+        out->write( this->toByteArray(), this->size() );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCH_RETHROW( NullPointerException )

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h Mon Feb 22 19:02:35 2010
@@ -19,7 +19,6 @@
 #define _DECAF_IO_BYTEARRAYOUTPUTSTREAM_H_
 
 #include <decaf/io/OutputStream.h>
-#include <decaf/util/concurrent/Mutex.h>
 #include <vector>
 
 namespace decaf{
@@ -38,11 +37,6 @@
          */
         std::vector<unsigned char>* activeBuffer;
 
-        /**
-         * Synchronization object.
-         */
-        util::concurrent::Mutex mutex;
-
     public:
 
         /**
@@ -56,7 +50,7 @@
          */
         ByteArrayOutputStream( std::vector<unsigned char>& buffer );
 
-        virtual ~ByteArrayOutputStream() {};
+        virtual ~ByteArrayOutputStream();
 
         /**
          * Sets the internal buffer.  This input stream will wrap around
@@ -71,79 +65,19 @@
          * Get a snapshot of the data
          * @return pointer to the data
          */
-        virtual const unsigned char* toByteArray() const {
-            if( activeBuffer == NULL || activeBuffer->size() == 0 ){
-                return NULL;
-            }
-
-            return &(*activeBuffer)[0];
-        }
+        virtual const unsigned char* toByteArray() const;
 
         /**
          * Get a snapshot of the data
          * @return reference to the underlying data as a const std::vector<unsigned char>&
          */
-        virtual const std::vector<unsigned char> toByteArrayRef() const {
-            if( activeBuffer == NULL ){
-                return defaultBuffer;
-            }
-
-            return *activeBuffer;
-        }
+        virtual const std::vector<unsigned char> toByteArrayRef() const;
 
         /**
          * Get the Size of the Internal Buffer
          * @return size of the internal buffer
          */
-        virtual std::size_t size() const {
-            return activeBuffer->size();
-        }
-
-        /**
-         * Writes a single byte to the output stream.
-         * @param c the byte.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual void write( unsigned char c )
-           throw ( IOException );
-
-        /**
-         * Writes an array of bytes to the output stream.
-         * @param buffer The bytes to write.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual void write( const std::vector<unsigned char>& buffer )
-            throw ( IOException );
-
-        /**
-         * Writes an array of bytes to the output stream in order starting at buffer[offset]
-         * and proceeding until the number of bytes specified by the length argument are
-         * written or an error occurs.
-         *
-         * @param buffer
-         *      The array of bytes to write.
-         * @param size
-         *      The size of the buffer array passed.
-         * @param offset
-         *      The position to start writing in buffer.
-         * @param length
-         *      The number of bytes from the buffer to be written.
-         *
-         * @throws IOException if an I/O error occurs.
-         * @throws NullPointerException thrown if buffer is Null.
-         * @throws IndexOutOfBoundsException if the offset + length > size.
-         */
-        virtual void write( const unsigned char* buffer, std::size_t size,
-                            std::size_t offset, std::size_t length )
-            throw ( decaf::io::IOException,
-                    decaf::lang::exceptions::NullPointerException,
-                    decaf::lang::exceptions::IndexOutOfBoundsException );
-
-        /**
-         * Invokes flush on the target output stream, has no affect.
-         * @throws IOException
-         */
-        virtual void flush() throw ( IOException ){ /* do nothing */ }
+        virtual std::size_t size() const;
 
         /**
          * Clear current Stream contents
@@ -152,16 +86,10 @@
         virtual void reset() throw ( IOException );
 
         /**
-         * Invokes close on the target output stream.
-         * @throws IOException
-         */
-        void close() throw( io::IOException ){ /* do nothing */ }
-
-        /**
          * Converts the bytes in the buffer into a standard C++ string
          * @returns a string containing the bytes in the buffer
          */
-        std::string toString() const;
+        virtual std::string toString() const;
 
         /**
          * Writes the complete contents of this byte array output stream to the
@@ -169,57 +97,18 @@
          * stream's write method using out.write( buf, 0, count ).
          */
         void writeTo( OutputStream* out ) const
-            throw ( IOException, lang::exceptions::NullPointerException );
-
-    public:
-
-        virtual void lock() throw( decaf::lang::exceptions::RuntimeException ) {
-            mutex.lock();
-        }
-
-        virtual bool tryLock() throw( decaf::lang::exceptions::RuntimeException ) {
-            return mutex.tryLock();
-        }
-
-        virtual void unlock() throw( decaf::lang::exceptions::RuntimeException ) {
-            mutex.unlock();
-        }
-
-        virtual void wait() throw( decaf::lang::exceptions::RuntimeException,
-                                   decaf::lang::exceptions::IllegalMonitorStateException,
-                                   decaf::lang::exceptions::InterruptedException ) {
-
-            mutex.wait();
-        }
+            throw ( decaf::io::IOException, decaf::lang::exceptions::NullPointerException );
 
-        virtual void wait( long long millisecs )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
+    protected:
 
-            mutex.wait( millisecs );
-        }
+        virtual void doWriteByte( unsigned char value )
+           throw ( decaf::io::IOException );
 
-        virtual void wait( long long millisecs, int nanos )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalArgumentException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
-
-            mutex.wait( millisecs, nanos );
-        }
-
-        virtual void notify() throw( decaf::lang::exceptions::RuntimeException,
-                                     decaf::lang::exceptions::IllegalMonitorStateException ) {
-
-            mutex.notify();
-        }
-
-        virtual void notifyAll() throw( decaf::lang::exceptions::RuntimeException,
-                                        decaf::lang::exceptions::IllegalMonitorStateException ) {
-
-            mutex.notifyAll();
-        }
+        virtual void doWriteArrayBounded( const unsigned char* buffer, std::size_t size,
+                                          std::size_t offset, std::size_t length )
+            throw ( decaf::io::IOException,
+                    decaf::lang::exceptions::NullPointerException,
+                    decaf::lang::exceptions::IndexOutOfBoundsException );
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInput.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInput.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInput.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInput.h Mon Feb 22 19:02:35 2010
@@ -256,27 +256,31 @@
         /**
          * Reads some bytes from an input stream and stores them into the
          * buffer array buffer. The number of bytes read is equal to the length
-         * of buffer.<p>
+         * of buffer.
+         *
          * This method blocks until one of the following conditions occurs:
-         *    * buffer.size() bytes of input data are available, in which case
+         *    * buffer's size bytes of input data are available, in which case
          *      a normal return is made.
          *    * End of file is detected, in which case an EOFException is
          *      thrown.
          *    * An I/O error occurs, in which case an IOException other than
          *      EOFException is thrown.
-         * <p>
-         * If buffer.size() is zero, then no bytes are read. Otherwise, the
+         *
+         * If buffer size is zero, then no bytes are read. Otherwise, the
          * first byte read is stored into element b[0], the next one into
          * buffer[1], and so on. If an exception is thrown from this method,
          * then it may be that some but not all bytes of buffer have been
          * updated with data from the input stream.
          *
-         * @param buffer - vector of char that is read to its size().
+         * @param buffer
+         *      The byte array to insert read data into.
+         * @param size
+         *      The size in bytes of the given byte buffer.
          *
          * @throws IOException if an I/O Error occurs.
          * @throws EOFException if the end of input is reached.
          */
-        virtual void readFully( std::vector<unsigned char>& buffer )
+        virtual void readFully( unsigned char* buffer, std::size_t size )
             throw( decaf::io::IOException, decaf::io::EOFException ) = 0;
 
         /**

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInputStream.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInputStream.cpp Mon Feb 22 19:02:35 2010
@@ -39,52 +39,6 @@
 DataInputStream::~DataInputStream() {}
 
 ////////////////////////////////////////////////////////////////////////////////
-int DataInputStream::read( std::vector<unsigned char>& buffer ) throw ( io::IOException ) {
-
-    try {
-        return this->read( &buffer[0], buffer.size(), 0, buffer.size() );
-    }
-    DECAF_CATCH_RETHROW( IOException )
-    DECAF_CATCHALL_THROW( IOException )
-}
-
-////////////////////////////////////////////////////////////////////////////////
-int DataInputStream::read( unsigned char* buffer, std::size_t size, std::size_t offset, std::size_t length )
-    throw ( IOException, NullPointerException, IndexOutOfBoundsException ) {
-
-    try {
-
-        if( length == 0 ) {
-            return 0;
-        }
-
-        if( buffer == NULL ) {
-            throw NullPointerException(
-                __FILE__, __LINE__,
-                "DataInputStream::read - Buffer is null" );
-        }
-
-        if( inputStream == NULL ) {
-            throw NullPointerException(
-                __FILE__, __LINE__,
-                "DataInputStream::readFully - Base input stream is null" );
-        }
-
-        if( length > size - offset ) {
-            throw IndexOutOfBoundsException(
-                __FILE__, __LINE__,
-                "Given size{%d} - offset{%d} is less than length{%d}.", size, offset, length );
-        }
-
-        return inputStream->read( buffer, size, offset, length );
-    }
-    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
-    DECAF_CATCH_RETHROW( NullPointerException )
-    DECAF_CATCH_RETHROW( IOException )
-    DECAF_CATCHALL_THROW( IOException )
-}
-
-////////////////////////////////////////////////////////////////////////////////
 bool DataInputStream::readBoolean() throw( IOException, EOFException ) {
 
     try {
@@ -262,7 +216,7 @@
             }
 
             // Resize to hold more if we exceed current size
-            if( ++pos > size ) {
+            if( ++pos >= size ) {
                 buffer.resize( (size *= 2) );
             }
         }
@@ -294,7 +248,7 @@
         std::vector<unsigned char> buffer( utfLength );
         std::vector<unsigned char> result( utfLength );
 
-        this->readFully( &buffer[0], 0, utfLength );
+        this->readFully( &buffer[0], utfLength );
 
         std::size_t count = 0;
         std::size_t index = 0;
@@ -371,14 +325,14 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void DataInputStream::readFully( std::vector< unsigned char >& buffer )
-    throw ( io::IOException, io::EOFException ) {
+void DataInputStream::readFully( unsigned char* buffer, std::size_t size )
+    throw ( decaf::io::IOException, decaf::io::EOFException ) {
 
     try {
-        if( buffer.empty() ) {
+        if( size == 0 ) {
             return;
         }
-        this->readFully( &buffer[0], 0, buffer.size() );
+        this->readFully( buffer, size, 0, size );
     }
     DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
@@ -386,12 +340,56 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void DataInputStream::readFully( unsigned char* buffer,
-                                 std::size_t offset,
-                                 std::size_t length )
-    throw ( io::IOException,
-            io::EOFException,
-            lang::exceptions::NullPointerException )
+std::string DataInputStream::readLine() throw( decaf::io::IOException ) {
+    try{
+
+        throw IOException( __FILE__, __LINE__, "Not Yet Implemented." );
+        // TODO - Once PushBackInputStream is done.
+//        std::string line;
+//        bool foundTerminator = false;
+//
+//        while( true ) {
+//
+//            int nextByte = inputStream->read();
+//            switch( nextByte ) {
+//                case -1:
+//                    if( line.length() == 0 && !foundTerminator ) {
+//                        return "";
+//                    }
+//                    return line;
+//                case (unsigned char)'\r':
+//                    if( foundTerminator ) {
+//                        ( (PushbackInputStream)in ).unread( nextByte );
+//                        return line.toString();
+//                    }
+//                    foundTerminator = true;
+//                    /* Have to be able to peek ahead one byte */
+//                    if(!(in.getClass() == PushbackInputStream.class))  {
+//                        in = new PushbackInputStream( in );
+//                    }
+//                    break;
+//                case (byte)'\n':
+//                    return line.toString();
+//                default:
+//                    if( foundTerminator ) {
+//                        ( (PushbackInputStream)in ).unread( nextByte );
+//                        return line.toString();
+//                    }
+//                    line.append( (char)nextByte );
+//            }
+//        }
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataInputStream::readFully( unsigned char* buffer, std::size_t size,
+                                 std::size_t offset, std::size_t length )
+    throw ( decaf::io::IOException,
+            decaf::io::EOFException,
+            decaf::lang::exceptions::IndexOutOfBoundsException,
+            decaf::lang::exceptions::NullPointerException )
 {
     try {
 
@@ -411,6 +409,11 @@
                 "DataInputStream::readFully - Base input stream is null" );
         }
 
+        if( offset + length > size ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "Offset + Length is greater than the size of the Buffer." );
+        }
+
         std::size_t n = 0;
         while( n < length ) {
             int count = inputStream->read( buffer, length, offset + n, length - n );
@@ -429,8 +432,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t DataInputStream::skip( std::size_t num )
-    throw( io::IOException, lang::exceptions::UnsupportedOperationException ) {
+std::size_t DataInputStream::skipBytes( std::size_t num )
+    throw( decaf::io::IOException ) {
 
     try {
 
@@ -450,7 +453,6 @@
 
         return total;
     }
-    DECAF_CATCH_RETHROW( UnsupportedOperationException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/DataInputStream.h Mon Feb 22 19:02:35 2010
@@ -63,174 +63,100 @@
 
         virtual ~DataInputStream();
 
-        virtual int read() throw ( IOException ) {
-            return FilterInputStream::read();
-        }
-
-        /**
-         * Reads some number of bytes from the contained input stream and
-         * stores them into the buffer array b. The number of bytes actually
-         * read is returned as an integer. This method blocks until input
-         * data is available, end of file is detected, or an exception is
-         * thrown.
-         * <p>
-         * If the length of buffer is zero, then no bytes are read and 0 is
-         * returned; otherwise, there is an attempt to read at least one
-         * byte. If no byte is available because the stream is at end of
-         * file, the value -1 is returned; otherwise, at least one byte is
-         * read and stored into buffer.
-         * <p>
-         * The first byte read is stored into element buffer[0], the next one
-         * into buffer[1], and so on. The number of bytes read is, at most,
-         * equal to the length of buffer. Let k be the number of bytes actually
-         * read; these bytes will be stored in elements b[0] through b[k-1],
-         * leaving elements buffer[k] through buffer[buffer.length-1]
-         * unaffected.
-         * <p>
-         * If the first byte cannot be read for any reason other than end
-         * of file, then an IOException is thrown. In particular, an
-         * IOException is thrown if the input stream has been closed.
-         * <p>
-         * The read( buffer ) method has the same effect as:
-         *      read( buffer, 0, b.length )
-         * @param buffer - byte array to insert read data into
-         * @returns the total number of bytes read, or -1 if there is no
-         *          more data because the stream is EOF.
-         * @throws IOException
-         */
-        virtual int read( std::vector< unsigned char >& buffer )
-            throw ( io::IOException );
-
-        /**
-         * Reads up to len bytes of data from the contained input stream
-         * into an array of bytes. An attempt is made to read as many as
-         * len bytes, but a smaller number may be read, possibly zero. The
-         * number of bytes actually read is returned as an integer.
-         * <p>
-         * This method blocks until input data is available, end of file is
-         * detected, or an exception is thrown.
-         * <p>
-         * If buffer is null, a NullPointerException is thrown.
-         * <p>
-         * If off is negative, or len is negative then an
-         * IndexOutOfBoundsException is thrown, if off + len is greater that
-         * the allocated length of the array, an IOException will result
-         * depending on the platform and compiler settings.
-         * <p>
-         * If len is zero, then no bytes are read and 0 is returned;
-         * otherwise, there is an attempt to read at least one byte. If no
-         * byte is available because the stream is at end of file, the
-         * value -1 is returned; otherwise, at least one byte is read and
-         * stored into buffer.
-         * <p>
-         * The first byte read is stored into element b[off], the next one
-         * into buffer[off+1], and so on. The number of bytes read is, at most,
-         * equal to len. Let k be the number of bytes actually read; these
-         * bytes will be stored in elements buffer[off] through buffer[off+k-1],
-         * leaving elements buffer[off+k] through buffer[off+len-1] unaffected.
-         * <p>
-         * In every case, elements buffer[0] through buffer[off] and elements
-         * buffer[off+len] through buffer[buffer.length-1] are unaffected.
-         * <p>
-         * If the first byte cannot be read for any reason other than end of
-         * file, then an IOException is thrown. In particular, an IOException
-         * is thrown if the input stream has been closed.
-         *
-         * @param buffer
-         *      The target buffer to write the read in data to.
-         * @param size
-         *      The size in bytes of the target buffer.
-         * @param offset
-         *      The position in the buffer to start inserting the read in data.
-         * @param length
-         *      The maximum number of bytes that should be read into buffer.
-         *
-         * @return The number of bytes read or -1 if EOF is detected
-         *
-         * @throws IOException if an I/O error occurs.
-         * @throws NullPointerException if buffer passed is NULL.
-         * @throws IndexOutOfBoundsException if length > size - offset.
-         */
-        virtual int read( unsigned char* buffer, std::size_t size,
-                          std::size_t offset, std::size_t length )
-            throw ( decaf::io::IOException,
-                    decaf::lang::exceptions::IndexOutOfBoundsException,
-                    decaf::lang::exceptions::NullPointerException );
+    public:  // DataInput
 
         /**
-         * Reads one input byte and returns true if that byte is nonzero,
-         * false if that byte is zero.
-         * @returns the boolean value read.
-         * @throws IOException
-         * @throws EOFException
+         * Reads in one byte and returns true if that byte is nonzero, false if that
+         * byte is zero.
+         *
+         * @returns the boolean value of the read in byte (0=false, 1=true).
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
         virtual bool readBoolean()
-            throw( io::IOException, io::EOFException );
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
          * Reads and returns one input byte. The byte is treated as a
          * signed value in the range -128 through 127, inclusive.
+         *
          * @returns the 8-bit value read.
-         * @throws IOException
-         * @throws EOFException
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
         virtual char readByte()
-            throw ( io::IOException, io::EOFException );
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
          * Reads one input byte, zero-extends it to type int, and returns
          * the result, which is therefore in the range 0  through 255.
-         * @returns the 8 bit unsigned value read
-         * @throws IOException
-         * @throws EOFException
+         *
+         * @returns the 8 bit unsigned value read.
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
         virtual unsigned char readUnsignedByte()
-            throw ( io::IOException, io::EOFException );
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
          * Reads an input char and returns the char value. A ascii char
          * is made up of one bytes.  This returns the same result as
          * <code>readByte</code>
-         * @returns the 8 bit char read
-         * @throws IOException
-         * @throws EOFException
+         *
+         * @returns the 8 bit char read.
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
-        virtual char readChar() throw ( io::IOException, io::EOFException );
+        virtual char readChar()
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
          * Reads eight input bytes and returns a double value. It does this
          * by first constructing a long long  value in exactly the manner of
          * the readlong  method, then converting this long  value to a double
-         * in exactly the manner of the method Double.longBitsToDouble.
-         * @returns the double value read
-         * @throws IOException
-         * @throws EOFException
+         * in exactly the manner of the method Double::longBitsToDouble.
+         *
+         * @returns the double value read.
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
         virtual double readDouble()
-            throw ( io::IOException, io::EOFException );
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
          * Reads four input bytes and returns a float value. It does this
          * by first constructing an int  value in exactly the manner of the
          * readInt  method, then converting this int  value to a float in
-         * exactly the manner of the method Float.intBitsToFloat.
-         * @returns the float value read
-         * @throws IOException
-         * @throws EOFException
+         * exactly the manner of the method Float::intBitsToFloat.
+         *
+         * @returns the float value read.
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
-        virtual float readFloat() throw ( io::IOException, io::EOFException );
+        virtual float readFloat()
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
          * Reads four input bytes and returns an int value. Let a  be the
          * first byte read, b be the second byte, c be the third byte, and
-         * d be the fourth byte. The value returned is: <p>
+         * d be the fourth byte. The value returned is:
+         *
          *  (((a & 0xff) << 24) | ((b & 0xff) << 16) |
          *   ((c & 0xff) << 8) | (d & 0xff))
-         * @returns the int value read
-         * @throws IOException
-         * @throws EOFException
+         *
+         * @returns the int value read.
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
-        virtual int readInt() throw ( io::IOException, io::EOFException );
+        virtual int readInt()
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
          * Reads eight input bytes and returns a long value. Let a  be the
@@ -238,6 +164,7 @@
          * be the fourth byte, e be the fifth byte, f  be the sixth byte,
          * g be the seventh byte, and h be the eighth byte. The value
          * returned is:
+         *
          *  (((long)(a & 0xff) << 56) |
          *   ((long)(b & 0xff) << 48) |
          *   ((long)(c & 0xff) << 40) |
@@ -246,44 +173,77 @@
          *   ((long)(f & 0xff) << 16) |
          *   ((long)(g & 0xff) <<  8) |
          *   ((long)(h & 0xff)))
-         * @returns the 64 bit long long read
-         * @throws IOException
-         * @throws EOFException
+         *
+         * @returns the 64 bit long long read.
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
         virtual long long readLong()
-            throw ( io::IOException, io::EOFException );
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
          * Reads two input bytes and returns a short value. Let a  be the
          * first byte read and b  be the second byte. The value returned is:
+         *
          *   (short)((a << 8) | (b & 0xff))
-         * @returns the 16 bit short value read
-         * @throws IOException
-         * @throws EOFException
+         *
+         * @returns the 16 bit short value read.
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
-        virtual short readShort() throw ( io::IOException, io::EOFException );
+        virtual short readShort()
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
          * Reads two input bytes and returns an int value in the range 0
          * through 65535. Let a  be the first byte read and b  be the
          * second byte. The value returned is:
+         *
          *   (((a & 0xff) << 8) | (b & 0xff))
-         * @returns the 16 bit unsigned short read
-         * @throws IOException
-         * @throws EOFException
+         *
+         * @returns the 16 bit unsigned short read.
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
         virtual unsigned short readUnsignedShort()
-            throw ( io::IOException, io::EOFException );
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
-         * Reads an null terminated ASCII string to the stream and returns the
+         * Reads an NULL terminated ASCII string to the stream and returns the
          * string to the caller.
+         *
          * @returns string object containing the string read.
-         * @throws IOException
-         * @throws EOFException
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
         virtual std::string readString()
-            throw ( io::IOException, io::EOFException );
+            throw( decaf::io::IOException, decaf::io::EOFException );
+
+        /**
+         * Reads the next line of text from the input stream. It reads successive bytes, converting
+         * each byte to an ASCII char separately, until it encounters a line terminator or end of
+         * file; the characters read are then returned as a standard String. Note that because this
+         * method processes bytes, it does not support input of the full Unicode character set.
+         *
+         * If end of file is encountered before even one byte can be read, then an empty string is
+         * returned. Otherwise, each byte that is read is converted to type char.  If the character
+         * '\n' is encountered, it is discarded and reading ceases. If the character '\r' is
+         * encountered, it is discarded and, if the following byte converts to the character '\n',
+         * then that is discarded also; reading then ceases. If end of file is encountered before
+         * either of the characters '\n' and '\r' is encountered, reading ceases. Once reading has
+         * ceased, a String is returned that contains all the characters read and not discarded,
+         * taken in order.
+         *
+         * @return the next line of text read from the input stream or empty string if at EOF.
+         *
+         * @throws IOException if an I/O Error occurs.
+         */
+        virtual std::string readLine()
+            throw( decaf::io::IOException );
 
         /**
          * Reads a modified UTF-8 encoded string in ASCII format and returns it,
@@ -296,40 +256,48 @@
          *
          * @returns The decoded string read from stream.
          *
-         * @throws IOException
-         * @throws EOFException
-         * @throws UTFDataFormatException
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
+         * @throws UTFDataFormatException if the bytes are not valid modified UTF-8 values.
          */
         virtual std::string readUTF()
-            throw ( io::IOException, io::EOFException, io::UTFDataFormatException );
+            throw( decaf::io::IOException,
+                   decaf::io::EOFException,
+                   decaf::io::UTFDataFormatException );
 
         /**
          * Reads some bytes from an input stream and stores them into the
          * buffer array buffer. The number of bytes read is equal to the length
-         * of buffer.<p>
+         * of buffer.
+         *
          * This method blocks until one of the following conditions occurs:
-         *    * buffer.size() bytes of input data are available, in which case
+         *    * buffer's size bytes of input data are available, in which case
          *      a normal return is made.
          *    * End of file is detected, in which case an EOFException is
          *      thrown.
          *    * An I/O error occurs, in which case an IOException other than
          *      EOFException is thrown.
-         * <p>
-         * If buffer.size() is zero, then no bytes are read. Otherwise, the
+         *
+         * If buffer size is zero, then no bytes are read. Otherwise, the
          * first byte read is stored into element b[0], the next one into
          * buffer[1], and so on. If an exception is thrown from this method,
          * then it may be that some but not all bytes of buffer have been
          * updated with data from the input stream.
-         * @param buffer - vector of char that is read to its size()
-         * @throws IOException
-         * @throws EOFException
+         *
+         * @param buffer
+         *      The byte array to insert read data into.
+         * @param size
+         *      The size in bytes of the given byte buffer.
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
          */
-        virtual void readFully( std::vector< unsigned char >& buffer )
-            throw ( io::IOException, io::EOFException );
+        virtual void readFully( unsigned char* buffer, std::size_t size )
+            throw( decaf::io::IOException, decaf::io::EOFException );
 
         /**
          * Reads length bytes from an input stream.
-         * <p>
+         *
          * This method blocks until one of the following conditions occurs:
          *    * length bytes of input data are available, in which case a
          *      normal return is made.
@@ -337,42 +305,50 @@
          *      thrown.
          *    * An I/O error occurs, in which case an IOException other
          *      than EOFException is thrown.
-         * <p>
-         * If buffer is null, a NullPointerException is thrown. If offset is
-         * negative, or len is negative, or offset+length is greater than the
-         * length of the array buffer, then an IndexOutOfBoundsException is
-         * thrown. If len is zero, then no bytes are read. Otherwise, the
-         * first byte read is stored into element buffer[off], the next one into
-         * buffer[offset+1], and so on. The number of bytes read is, at most,
-         * equal to len.
-         * @param buffer - byte array to insert read data into
-         * @param offset - location in buffer to start writing
-         * @param length - number of bytes to read
-         * @throws IOException
-         * @throws EOFException
-         * @throws NullPointerException if the buffer is null
-         */
-        virtual void readFully( unsigned char* buffer,
-                                std::size_t offset,
-                                std::size_t length )
-            throw ( io::IOException,
-                    io::EOFException,
-                    lang::exceptions::NullPointerException );
-
-        /**
-         * Makes an attempt to skip over n bytes of data from the input
-         * stream, discarding the skipped bytes. However, it may skip over
-         * some smaller number of bytes, possibly zero. This may result from
-         * any of a number of conditions; reaching end of file before n
-         * bytes have been skipped is only one possibility. This method
-         * never throws an EOFException. The actual number of bytes skipped
-         * is returned.
-         * @param num - number of bytes to skip
-         * @return the total number of bytes skipped
-         */
-        virtual std::size_t skip( std::size_t num )
-            throw( io::IOException,
-                   lang::exceptions::UnsupportedOperationException );
+         *
+         * If buffer is NULL, a NullPointerException is thrown. If offset+length
+         * is greater than the length of the array buffer, then an IndexOutOfBoundsException
+         * is thrown. If length is zero, then no bytes are read. Otherwise, the first
+         * byte read is stored into element buffer[off], the next one into buffer[offset+1],
+         * and so on. The number of bytes read is, at most, equal to length.
+         *
+         * @param buffer
+         *      The byte array to insert read data into.
+         * @param size
+         *      The size in bytes of the given byte buffer.
+         * @param offset
+         *      The location in buffer to start writing.
+         * @param length
+         *      The number of bytes to read from the buffer.
+         *
+         * @throws IOException if an I/O Error occurs.
+         * @throws EOFException if the end of input is reached.
+         * @throws NullPointerException if the buffer is NULL.
+         * @throws IndexOutOfBoundsException if the offset + length > size.
+         */
+        virtual void readFully( unsigned char* buffer, std::size_t size,
+                                std::size_t offset, std::size_t length )
+            throw ( decaf::io::IOException,
+                    decaf::io::EOFException,
+                    decaf::lang::exceptions::NullPointerException,
+                    decaf::lang::exceptions::IndexOutOfBoundsException );
+
+        /**
+         * Makes an attempt to skip over n bytes of data from the input stream,
+         * discarding the skipped bytes. However, it may skip over some smaller
+         * number of bytes, possibly zero. This may result from any of a number
+         * of conditions; reaching end of file before n bytes have been skipped
+         * is only one possibility. This method never throws an EOFException.
+         * The actual number of bytes skipped is returned.
+         *
+         * @param num
+         *      The number of bytes to skip over.
+         *
+         * @return the total number of bytes skipped.
+         *
+         * @throws IOException if an I/O Error occurs.
+         */
+        virtual std::size_t skipBytes( std::size_t num ) throw( io::IOException );
 
     private:
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.cpp?rev=915018&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.cpp Mon Feb 22 19:02:35 2010
@@ -0,0 +1,183 @@
+/*
+ * 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.
+ */
+
+#include "FilterInputStream.h"
+
+#include <decaf/io/InputStream.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+
+using namespace decaf;
+using namespace decaf::io;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+FilterInputStream::FilterInputStream( InputStream* inputStream, bool own ) {
+    this->inputStream = inputStream;
+    this->own = own;
+    this->closed = false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+FilterInputStream::~FilterInputStream() {
+
+    try {
+        this->close();
+
+        if( own ) {
+            delete inputStream;
+        }
+        inputStream = NULL;
+    }
+    DECAF_CATCH_NOTHROW( IOException )
+    DECAF_CATCHALL_NOTHROW( )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t FilterInputStream::available() const throw ( IOException ) {
+
+    try {
+
+        if( isClosed() ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "FilterInputStream::available - Stream is closed" );
+        }
+
+        return inputStream->available();
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void FilterInputStream::close() throw ( io::IOException ) {
+
+    try {
+        if( !closed && inputStream != NULL ) {
+            inputStream->close();
+        }
+        this->closed = true;
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void FilterInputStream::mark( int readLimit ) {
+    try {
+
+        if( !isClosed() ) {
+            inputStream->mark( readLimit );
+        }
+    }
+    DECAF_CATCHALL_NOTHROW()
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void FilterInputStream::reset() throw ( IOException ) {
+
+    try {
+
+        if( isClosed() ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "FilterInputStream::skip - Stream is closed" );
+        }
+
+        return inputStream->reset();
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool FilterInputStream::markSupported() const {
+
+    try {
+        if( !isClosed() ) {
+            return inputStream->markSupported();
+        }
+    }
+    DECAF_CATCHALL_NOTHROW()
+    return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t FilterInputStream::skip( std::size_t num )
+    throw ( decaf::io::IOException,
+            decaf::lang::exceptions::UnsupportedOperationException ) {
+
+    try {
+
+        if( isClosed() ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "FilterInputStream::skip - Stream is closed" );
+        }
+
+        return inputStream->skip( num );
+    }
+    DECAF_CATCH_RETHROW( UnsupportedOperationException )
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int FilterInputStream::doReadByte() throw ( IOException ) {
+
+    try {
+
+        if( isClosed() ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "FilterInputStream::read - Stream is closed" );
+        }
+
+        return inputStream->read();
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int FilterInputStream::doReadArrayBounded( unsigned char* buffer, std::size_t size,
+                                           std::size_t offset, std::size_t length )
+    throw ( decaf::io::IOException,
+            decaf::lang::exceptions::IndexOutOfBoundsException,
+            decaf::lang::exceptions::NullPointerException ) {
+
+    try {
+
+        if( isClosed() ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "FilterInputStream::read - Stream is closed" );
+        }
+
+        return inputStream->read( buffer, size, offset, length );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool FilterInputStream::isClosed() const {
+    return this->closed;
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.h Mon Feb 22 19:02:35 2010
@@ -20,7 +20,6 @@
 
 #include <decaf/io/InputStream.h>
 #include <decaf/io/IOException.h>
-#include <decaf/util/concurrent/Mutex.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
 
@@ -42,9 +41,6 @@
         // The input stream to wrap
         InputStream* inputStream;
 
-        // Synchronization object.
-        util::concurrent::Mutex mutex;
-
         // Indicates if we own the wrapped stream
         bool own;
 
@@ -55,27 +51,15 @@
 
         /**
          * Constructor to create a wrapped InputStream
-         * @param inputStream the stream to wrap and filter
-         * @param own indicates if we own the stream object, defaults to false
+         *
+         * @param inputStream
+         *      The stream to wrap and filter.
+         * @param own
+         *      Indicates if we own the stream object, defaults to false.
          */
-        FilterInputStream( InputStream* inputStream, bool own = false ) {
-            this->inputStream = inputStream;
-            this->own = own;
-            this->closed = false;
-        }
-
-        virtual ~FilterInputStream() {
-            try {
-                this->close();
-
-                if( own ) {
-                    delete inputStream;
-                }
-                inputStream = NULL;
-            }
-            DECAF_CATCH_NOTHROW( IOException )
-            DECAF_CATCHALL_NOTHROW( )
-        }
+        FilterInputStream( InputStream* inputStream, bool own = false );
+
+        virtual ~FilterInputStream();
 
         /**
          * Returns the number of bytes that can be read from this input stream
@@ -83,93 +67,15 @@
          * returns the result.
          * @return the number of bytes available without blocking.
          */
-        virtual std::size_t available() const throw ( IOException ) {
-            try {
-
-                if( isClosed() ) {
-                    throw IOException(
-                        __FILE__, __LINE__,
-                        "FilterInputStream::available - Stream is closed" );
-                }
-
-                return inputStream->available();
-            }
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
-
-        /**
-         * Reads the next byte of data from this input stream. The value byte
-         * is returned as an unsigned char in the range 0 to 255. If no byte is
-         * available because the end of the stream has been reached, the value
-         * -1 is returned. This method blocks until input data is available,
-         * the end of the stream is detected, or an exception is thrown.
-         * This method simply performs in.read() and returns the result.
-         * @return The next byte.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual int read() throw ( IOException ) {
-            try {
-
-                if( isClosed() ) {
-                    throw IOException(
-                        __FILE__, __LINE__,
-                        "FilterInputStream::read - Stream is closed" );
-                }
-
-                return inputStream->read();
-            }
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
-
-        /**
-         * Reads up to len bytes of data from this input stream into an array
-         * of bytes. This method blocks until some input is available.
-         * This method simply performs in.read(b, len) and returns the result.
-         * @param buffer (out) the target buffer.
-         * @param offset the position to start reading in the passed buffer.
-         * @param bufferSize the size of the output buffer.
-         * @return The number of bytes read or -1 if EOF is detected
-         * @throws IOException thrown if an error occurs.
-         * @throws NullPointerException
-         */
-        virtual int read( unsigned char* buffer, std::size_t size,
-                          std::size_t offset, std::size_t length )
-            throw ( decaf::io::IOException,
-                    decaf::lang::exceptions::IndexOutOfBoundsException,
-                    decaf::lang::exceptions::NullPointerException ) {
-
-            try {
-
-                if( isClosed() ) {
-                    throw IOException(
-                        __FILE__, __LINE__,
-                        "FilterInputStream::read - Stream is closed" );
-                }
-
-                return inputStream->read( buffer, size, offset, length );
-            }
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCH_RETHROW( lang::exceptions::NullPointerException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
+        virtual std::size_t available() const throw ( decaf::io::IOException );
 
         /**
          * Close the Stream, the FilterOutputStream simply calls the close
          * method of the underlying stream
-         * @throws Exception
+         *
+         * @throws IOException if an I/O error occurs
          */
-        virtual void close() throw ( io::IOException ) {
-            try {
-                if( !closed && inputStream != NULL ) {
-                    inputStream->close();
-                }
-                this->closed = true;
-            }
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
+        virtual void close() throw ( decaf::io::IOException );
 
         /**
          * Skips over and discards n bytes of data from this input stream. The
@@ -185,23 +91,11 @@
          * provide a more efficient implementation of this method.
          * @param num - the number of bytes to skip
          * @returns total butes skipped
-         * @throws IOException if an error occurs
+         * @throws IOException if an I/O error occurs
          */
-        virtual std::size_t skip( std::size_t num ) throw ( io::IOException, lang::exceptions::UnsupportedOperationException ) {
-            try {
-
-                if( isClosed() ) {
-                    throw IOException(
-                        __FILE__, __LINE__,
-                        "FilterInputStream::skip - Stream is closed" );
-                }
-
-                return inputStream->skip( num );
-            }
-            DECAF_CATCH_RETHROW( lang::exceptions::UnsupportedOperationException )
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
+        virtual std::size_t skip( std::size_t num )
+            throw ( decaf::io::IOException,
+                    decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Marks the current position in the stream A subsequent call to the
@@ -215,15 +109,7 @@
          * @param readLimit
          *      The max bytes read before marked position is invalid.
          */
-        virtual void mark( int readLimit ) {
-            try {
-
-                if( !isClosed() ) {
-                    inputStream->mark( readLimit );
-                }
-            }
-            DECAF_CATCHALL_NOTHROW()
-        }
+        virtual void mark( int readLimit );
 
         /**
          * Repositions this stream to the position at the time the mark method was
@@ -248,20 +134,7 @@
          *     of the read method depend on the particular type of the input stream.
          * @throws IOException
          */
-        virtual void reset() throw ( IOException ) {
-            try {
-
-                if( isClosed() ) {
-                    throw IOException(
-                        __FILE__, __LINE__,
-                        "FilterInputStream::skip - Stream is closed" );
-                }
-
-                return inputStream->reset();
-            }
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
+        virtual void reset() throw ( decaf::io::IOException );
 
         /**
          * Determines if this input stream supports the mark and reset methods.
@@ -269,74 +142,22 @@
          * a particular input stream instance.
          * @returns true if this stream instance supports marks
          */
-        virtual bool markSupported() const {
-            try {
-                if( !isClosed() ) {
-                    return inputStream->markSupported();
-                }
-            }
-            DECAF_CATCHALL_NOTHROW()
-            return false;
-        }
-
-    public:  // Synchronizable
-
-        virtual void lock() throw( decaf::lang::exceptions::RuntimeException ) {
-            mutex.lock();
-        }
-
-        virtual bool tryLock() throw( decaf::lang::exceptions::RuntimeException ) {
-            return mutex.tryLock();
-        }
-
-        virtual void unlock() throw( decaf::lang::exceptions::RuntimeException ) {
-            mutex.unlock();
-        }
-
-        virtual void wait() throw( decaf::lang::exceptions::RuntimeException,
-                                   decaf::lang::exceptions::IllegalMonitorStateException,
-                                   decaf::lang::exceptions::InterruptedException ) {
-
-            mutex.wait();
-        }
-
-        virtual void wait( long long millisecs )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
-
-            mutex.wait( millisecs );
-        }
-
-        virtual void wait( long long millisecs, int nanos )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalArgumentException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
-
-            mutex.wait( millisecs, nanos );
-        }
-
-        virtual void notify() throw( decaf::lang::exceptions::RuntimeException,
-                                     decaf::lang::exceptions::IllegalMonitorStateException ) {
-
-            mutex.notify();
-        }
+        virtual bool markSupported() const;
 
-        virtual void notifyAll() throw( decaf::lang::exceptions::RuntimeException,
-                                        decaf::lang::exceptions::IllegalMonitorStateException ) {
+    protected:
 
-            mutex.notifyAll();
-        }
+        virtual int doReadByte() throw ( decaf::io::IOException );
 
-    protected:
+        virtual int doReadArrayBounded( unsigned char* buffer, std::size_t size,
+                                        std::size_t offset, std::size_t length )
+            throw ( decaf::io::IOException,
+                    decaf::lang::exceptions::IndexOutOfBoundsException,
+                    decaf::lang::exceptions::NullPointerException );
 
         /**
          * @returns true if this stream has been closed.
          */
-        virtual bool isClosed() const {
-            return this->closed || inputStream == NULL;
-        }
+        virtual bool isClosed() const;
 
     };
 



Mime
View raw message