activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r915018 [3/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
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.cpp?rev=915018&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.cpp Mon Feb 22 19:02:35 2010
@@ -0,0 +1,164 @@
+/*
+ * 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 "FilterOutputStream.h"
+
+#include <decaf/io/OutputStream.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+
+using namespace decaf;
+using namespace decaf::io;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+FilterOutputStream::FilterOutputStream( OutputStream* outputStream, bool own ){
+    this->outputStream = outputStream;
+    this->own = own;
+    this->closed = false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+FilterOutputStream::~FilterOutputStream() {
+    try {
+        this->close();
+
+        if( own ) {
+            delete outputStream;
+        }
+        outputStream = NULL;
+    }
+    DECAF_CATCH_NOTHROW( IOException )
+    DECAF_CATCHALL_NOTHROW( )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void FilterOutputStream::doWriteByte( unsigned char c ) throw ( decaf::io::IOException ) {
+    try {
+
+        if( isClosed()  ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "FilterOutputStream::write - Stream is closed" );
+        }
+
+        this->outputStream->write( c );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void FilterOutputStream::doWriteArray( const unsigned char* buffer, std::size_t size )
+    throw ( decaf::io::IOException ) {
+
+    try {
+
+        if( isClosed() ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "FilterOutputStream::write - Stream is closed" );
+        }
+
+        for( std::size_t ix = 0; ix < size; ++ix ) {
+            this->outputStream->write( buffer[ix] );
+        }
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void FilterOutputStream::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 ) {
+
+    try {
+
+        if( isClosed() ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "FilterOutputStream::write - Stream is closed" );
+        }
+
+        if( buffer == NULL ) {
+            throw decaf::lang::exceptions::NullPointerException(
+                __FILE__, __LINE__,
+                "FilterOutputStream::write - Buffer passed is Null.");
+        }
+
+        if( ( offset + length ) > size ) {
+            throw decaf::lang::exceptions::IndexOutOfBoundsException(
+                __FILE__, __LINE__,
+                "FilterOutputStream::write - given offset + length is greater than buffer size.");
+        }
+
+        for( std::size_t ix = offset; ix < offset + length; ++ix ) {
+            this->outputStream->write( buffer[ix] );
+        }
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void FilterOutputStream::flush() throw ( decaf::io::IOException ) {
+    try {
+
+        if( isClosed() ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "FilterOutputStream::flush - Stream is closed" );
+        }
+
+        this->outputStream->flush();
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void FilterOutputStream::close() throw ( decaf::io::IOException ) {
+    try {
+        if( !this->closed && this->outputStream != NULL ) {
+            this->outputStream->flush();
+            this->outputStream->close();
+        }
+        this->closed = true;
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string FilterOutputStream::toString() const {
+
+    if( this->outputStream != NULL ) {
+        return this->outputStream->toString();
+    }
+
+    return typeid( this ).name();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool FilterOutputStream::isClosed() const {
+    return this->closed || this->outputStream == NULL;
+}

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

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.h Mon Feb 22 19:02:35 2010
@@ -20,8 +20,8 @@
 
 #include <decaf/io/OutputStream.h>
 #include <decaf/io/IOException.h>
-#include <decaf/util/concurrent/Mutex.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
 
 namespace decaf{
 namespace io{
@@ -52,9 +52,6 @@
         // The output Stream to wrap
         OutputStream* outputStream;
 
-        // Synchronization object.
-        util::concurrent::Mutex mutex;
-
         // Indicates if we own the wrapped stream
         bool own;
 
@@ -69,220 +66,53 @@
          * @param own If true, this object will control the lifetime of the
          * output stream that it encapsulates.
          */
-        FilterOutputStream( OutputStream* outputStream, bool own = false ){
-            this->outputStream = outputStream;
-            this->own = own;
-            this->closed = false;
-        }
-
-        virtual ~FilterOutputStream() {
-            try {
-                this->close();
-
-                if( own ) {
-                    delete outputStream;
-                }
-                outputStream = NULL;
-            }
-            DECAF_CATCH_NOTHROW( IOException )
-            DECAF_CATCHALL_NOTHROW( )
-        }
+        FilterOutputStream( OutputStream* outputStream, bool own = false );
 
-        /**
-         * Writes a single byte to the output stream.  The write method of
-         * FilterOutputStream calls the write method of its underlying output
-         * stream, that is, it performs out.write(b).
-         * @param c the byte.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual void write( unsigned char c ) throw ( IOException ) {
-            try {
-
-                if( isClosed() ) {
-                    throw IOException(
-                        __FILE__, __LINE__,
-                        "FilterOutputStream::write - Stream is closed" );
-                }
-
-                outputStream->write( c );
-            }
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
+        virtual ~FilterOutputStream();
 
         /**
-         * Writes an array of bytes to the output stream.
-         * @param buffer The bytes to write.
-         * @throws IOException thrown if an error occurs.
+         * {@inheritDoc}
+         *
+         * The flush method of FilterOutputStream calls the flush method of its
+         * underlying output stream.
          */
-        virtual void write( const std::vector<unsigned char>& buffer )
-            throw ( IOException ) {
-
-            try {
-
-                if( isClosed() ) {
-                    throw IOException(
-                        __FILE__, __LINE__,
-                        "FilterOutputStream::write - Stream is closed" );
-                }
-
-                for( std::size_t ix = 0; ix < buffer.size(); ++ix ) {
-                    outputStream->write( buffer[ix] );
-                }
-            }
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
+        virtual void flush() throw ( decaf::io::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.
+         * {@inheritDoc}
          *
-         * @throws IOException if an I/O error occurs.
-         * @throws NullPointerException thrown if buffer is Null.
-         * @throws IndexOutOfBoundsException if the offset + length > size.
+         * The close method of FilterOutputStream calls its flush method, and then
+         * calls the close method of its underlying output stream.
          */
-        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 ) {
-
-            try {
-
-                if( isClosed() ) {
-                    throw IOException(
-                        __FILE__, __LINE__,
-                        "FilterOutputStream::write - Stream is closed" );
-                }
-
-                if( buffer == NULL ) {
-                    throw decaf::lang::exceptions::NullPointerException(
-                        __FILE__, __LINE__,
-                        "FilterOutputStream::write - Buffer passed is Null.");
-                }
-
-                if( ( offset + length ) > size ) {
-                    throw decaf::lang::exceptions::IndexOutOfBoundsException(
-                        __FILE__, __LINE__,
-                        "FilterOutputStream::write - given offset + length is greater than buffer size.");
-                }
-
-                for( std::size_t ix = 0; ix < length; ++ix ) {
-                    outputStream->write( buffer[offset + ix] );
-                }
-            }
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
+        virtual void close() throw ( decaf::io::IOException );
 
         /**
-         * Flushes any pending writes in this output stream.
-         * The flush method of FilterOutputStream calls the flush method
-         * of its underlying output stream
-         * @throws IOException
+         * {@inheritDoc}
+         *
+         * The toString method of FilterOutputStream calls the toString method of its
+         * underlying output stream.
          */
-        virtual void flush() throw ( IOException ) {
-            try {
+        virtual std::string toString() const;
 
-                if( isClosed() ) {
-                    throw IOException(
-                        __FILE__, __LINE__,
-                        "FilterOutputStream::flush - Stream is closed" );
-                }
-
-                outputStream->flush();
-            }
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
-
-        /**
-         * Close the Stream.  The close method of FilterOutputStream calls its
-         * flush method, and then calls the close method of its underlying output
-         * stream, it then destroys the output stream if it is the owner.
-         * @throws Exception
-         */
-        virtual void close() throw ( io::IOException ) {
-            try {
-                if( !closed && outputStream != NULL ) {
-                    outputStream->flush();
-                    outputStream->close();
-                }
-                this->closed = true;
-            }
-            DECAF_CATCH_RETHROW( IOException )
-            DECAF_CATCHALL_THROW( IOException )
-        }
-
-    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 ) {
+    protected:
 
-            mutex.notify();
-        }
+        virtual void doWriteByte( unsigned char value ) throw ( decaf::io::IOException );
 
-        virtual void notifyAll() throw( decaf::lang::exceptions::RuntimeException,
-                                        decaf::lang::exceptions::IllegalMonitorStateException ) {
+        virtual void doWriteArray( const unsigned char* buffer, std::size_t size )
+            throw( decaf::io::IOException );
 
-            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 );
 
     protected:
 
         /**
          * @returns true if this stream has been closed.
          */
-        virtual bool isClosed() const {
-            return this->closed || this->outputStream == NULL;
-        }
+        virtual bool isClosed() const;
 
     };
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStream.cpp?rev=915018&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStream.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStream.cpp Mon Feb 22 19:02:35 2010
@@ -0,0 +1,199 @@
+/*
+ * 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 "InputStream.h"
+
+#include <typeinfo>
+
+#include <decaf/lang/exceptions/NullPointerException.h>
+
+using namespace decaf;
+using namespace decaf::io;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+InputStream::InputStream() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+InputStream::~InputStream() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void InputStream::close() throw( decaf::io::IOException ) {
+    // Nothing to do by default.
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void InputStream::mark( int readLimit DECAF_UNUSED ) {
+    // Nothing to do by default.
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string InputStream::toString() const {
+    return typeid( this ).name();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void InputStream::reset() throw ( decaf::io::IOException ) {
+    throw IOException(
+        __FILE__, __LINE__,
+        "Base InputStream class does not support Reset." );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int InputStream::read() throw ( decaf::io::IOException ) {
+    try{
+        return this->doReadByte();
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int InputStream::read( unsigned char* buffer, std::size_t size )
+    throw ( decaf::io::IOException,
+            decaf::lang::exceptions::NullPointerException ) {
+
+    try{
+        return this->doReadArray( buffer, size );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int InputStream::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{
+        return this->doReadArrayBounded( buffer, size, offset, length );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t InputStream::skip( std::size_t num )
+    throw ( decaf::io::IOException,
+            decaf::lang::exceptions::UnsupportedOperationException ) {
+
+    try{
+
+        if( num <= 0 ) {
+            return 0;
+        }
+
+        std::size_t skipped = 0;
+
+        // Lets not try and buffer every byte since it could be as large as
+        // whatever size_t is on this platform, read the data in reasonable
+        // chunks until finished.
+        std::size_t toRead = num < 4096 ? num : 4096;
+        std::vector<unsigned char> buffer( toRead );
+
+        while( skipped < num ) {
+
+            int read = doReadArrayBounded( &buffer[0], buffer.size(), 0, toRead );
+
+            // Is it EOF?
+            if( read == -1 ) {
+                return skipped;
+            }
+
+            skipped += read;
+
+            if( (std::size_t)read < toRead ) {
+                return skipped;
+            }
+            if( num - skipped < toRead ) {
+                toRead = num - skipped;
+            }
+        }
+        return skipped;
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( UnsupportedOperationException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int InputStream::doReadArray( unsigned char* buffer, std::size_t size )
+    throw ( decaf::io::IOException,
+            decaf::lang::exceptions::NullPointerException ) {
+
+    try{
+        return this->doReadArrayBounded( buffer, size, 0, size );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int InputStream::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( length == 0 ) {
+            return 0;
+        }
+
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__, "Buffer passed was NULL" );
+        }
+
+        if( length > ( size - offset ) ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "Offset + Length given exceeds Buffer size." );
+        }
+
+        for( std::size_t i = 0; i < length; i++ ) {
+
+            int c;
+            try {
+                if( ( c = doReadByte() ) == -1 ) {
+                    return i == 0 ? -1 : i;
+                }
+            } catch( IOException& e ) {
+                if( i != 0 ) {
+                    return i;
+                }
+                throw e;
+            }
+            buffer[offset + i] = (unsigned char)c;
+        }
+
+        return length;
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCHALL_THROW( IOException )
+}

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

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStream.h Mon Feb 22 19:02:35 2010
@@ -21,6 +21,7 @@
 #include <decaf/io/IOException.h>
 #include <decaf/io/Closeable.h>
 #include <decaf/util/concurrent/Synchronizable.h>
+#include <decaf/util/concurrent/Mutex.h>
 #include <decaf/lang/exceptions/UnsupportedOperationException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
@@ -36,10 +37,25 @@
      * @since 1.0
      */
     class DECAF_API InputStream : public Closeable,
-                                  public util::concurrent::Synchronizable {
+                                  virtual public util::concurrent::Synchronizable {
+    private:
+
+        // Synchronization object.
+        util::concurrent::Mutex mutex;
+
     public:
 
-        virtual ~InputStream(){}
+        InputStream();
+
+        virtual ~InputStream();
+
+        /**
+         * Closes the InputStream freeing any resources that might have been aquired
+         * during the lifetime of this stream.
+         *
+         * The default implementation of this method does nothing.
+         */
+        virtual void close() throw( decaf::io::IOException );
 
         /**
          * Marks the current position in the stream A subsequent call to the
@@ -52,10 +68,12 @@
          *
          * Calling mark on a closed stream instance should have no effect.
          *
+         * The default implementation of this method does nothing.
+         *
          * @param readLimit
          *      The max bytes read before marked position is invalid.
          */
-        virtual void mark( int readLimit ) = 0;
+        virtual void mark( int readLimit );
 
         /**
          * Repositions this stream to the position at the time the mark method was
@@ -80,18 +98,24 @@
          *     it was created. The bytes that will be supplied to subsequent callers
          *     of the read method depend on the particular type of the input stream.
          *
+         * The default implementation of this method throws an IOException.
+         *
          * @throws IOException if an I/O error occurs.
          */
-        virtual void reset() throw ( decaf::io::IOException ) = 0;
+        virtual void reset() throw ( decaf::io::IOException );
 
         /**
          * Determines if this input stream supports the mark and reset methods.
          * Whether or not mark and reset are supported is an invariant property of
          * a particular input stream instance.
          *
+         * The default implementation of this method returns false.
+         *
          * @returns true if this stream instance supports marks
          */
-        virtual bool markSupported() const = 0;
+        virtual bool markSupported() const {
+            return false;
+        }
 
         /**
          * Indicates the number of bytes available.  The default implementation of this
@@ -100,11 +124,15 @@
          * return a value of one indicating that there is some data avaiable.  The caller
          * should view the result of this method as an absolute.
          *
+         * The default implementation of this method returns zero.
+         *
          * @return the number of bytes available on this input stream.
          *
          * @throws IOException if an I/O error occurs.
          */
-        virtual std::size_t available() const throw ( decaf::io::IOException ) = 0;
+        virtual std::size_t available() const throw ( decaf::io::IOException ) {
+            return 0;
+        }
 
         /**
          * Reads a single byte from the buffer.  The value byte is returned as an int in the
@@ -112,31 +140,76 @@
          * 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.
          *
+         * The default implementation of this method calls the internal virtual method doReadByte
+         * which is a pure virtual method and must be overridden by all subclasses.
+         *
          * @return The next byte or -1 if the end of stream is reached.
+         *
          * @throws IOException if an I/O error occurs.
          */
-        virtual int read() throw ( decaf::io::IOException ) = 0;
+        virtual int read() throw ( decaf::io::IOException );
+
+        /**
+         * Reads up to size bytes of data from the input stream into an array of bytes. An
+         * attempt is made to read as many as size bytes, but a smaller number may be read.
+         * 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.
+         *
+         * If size 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 b.
+         *
+         * This method called the protected virtual method doReadArray which by default is the
+         * same as calling read( buffer, size, 0, size ).  Subclasses can customize the behavior
+         * of this method by overriding the doReadArray method to provide a better performing
+         * read operation.
+         *
+         * @param buffer
+         *      The target buffer to write the read in data to.
+         * @param size
+         *      The size in bytes of the target 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.
+         */
+        virtual int read( unsigned char* buffer, std::size_t size )
+            throw ( decaf::io::IOException,
+                    decaf::lang::exceptions::NullPointerException );
 
         /**
          * Reads up to length bytes of data from the 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.
+         * attempt is made to read as many as length bytes, but a smaller number may be read.
          * 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.
          *
-         * If len is zero, then no bytes are read and 0 is returned; otherwise, there is an
+         * If length 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 b.
          *
          * The first byte read is stored into element b[off], the next one into b[off+1], and
-         * so on. The number of bytes read is, at most, equal to len. Let k be the number of
+         * so on. The number of bytes read is, at most, equal to length. Let k be the number of
          * bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1],
-         * leaving elements b[off+k] through b[off+len-1] unaffected.
+         * leaving elements b[offset+k] through b[offset+length-1] unaffected.
          *
-         * In every case, elements b[0] through b[off] and elements b[off+len] through b[b.length-1]
-         * are unaffected.
+         * In every case, elements b[0] through b[offset] and elements b[offset+length] through
+         * b[b.length-1] are unaffected.
+         *
+         * This method called the protected virtual method doReadArrayBounded which simply
+         * calls the method doReadByte() repeatedly. If the first such call results in an IOException,
+         * that exception is returned. If any subsequent call to doReadByte() results in a IOException,
+         * the exception is caught and treated as if it were end of file; the bytes read up to that
+         * point are stored into the buffer and the number of bytes read before the exception occurred
+         * is returned. The default implementation of this method blocks until the requested amount of
+         * input data has been read, end of file is detected, or an exception is thrown. Subclasses
+         * are encouraged to provide a more efficient implementation of this method.
          *
          * @param buffer
          *      The target buffer to write the read in data to.
@@ -157,7 +230,7 @@
                           std::size_t offset, std::size_t length )
             throw ( decaf::io::IOException,
                     decaf::lang::exceptions::IndexOutOfBoundsException,
-                    decaf::lang::exceptions::NullPointerException ) = 0;
+                    decaf::lang::exceptions::NullPointerException );
 
         /**
          * Skips over and discards n bytes of data from this input stream. The skip
@@ -167,7 +240,7 @@
          * only one possibility. The actual number of bytes skipped is returned.
          *
          * The skip method of InputStream creates a byte array and then repeatedly
-         * reads into it until n bytes have been read or the end of the stream has
+         * reads into it until num bytes have been read or the end of the stream has
          * been reached. Subclasses are encouraged to provide a more efficient
          * implementation of this method.
          *
@@ -182,7 +255,80 @@
          */
         virtual std::size_t skip( std::size_t num )
             throw ( decaf::io::IOException,
-                    decaf::lang::exceptions::UnsupportedOperationException ) = 0;
+                    decaf::lang::exceptions::UnsupportedOperationException );
+
+        /**
+         * Output a String representation of this object.
+         *
+         * The default version of this method just prints the Class Name.
+         *
+         * @return a string representation of the object.
+         */
+        virtual std::string toString() const;
+
+    protected:  // Virtual doRead methods that can be overridden to customize subclasses.
+
+        virtual int doReadByte() throw( decaf::io::IOException ) = 0;
+
+        virtual int doReadArray( unsigned char* buffer, std::size_t size )
+            throw ( decaf::io::IOException,
+                    decaf::lang::exceptions::NullPointerException );
+
+        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 );
+
+    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 void notifyAll() throw( decaf::lang::exceptions::RuntimeException,
+                                        decaf::lang::exceptions::IllegalMonitorStateException ) {
+
+            mutex.notifyAll();
+        }
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStreamReader.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStreamReader.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStreamReader.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStreamReader.cpp Mon Feb 22 19:02:35 2010
@@ -84,8 +84,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int InputStreamReader::doReadArraySizeOffsetLength(
-    char* buffer, std::size_t size, std::size_t offset, std::size_t length )
+int InputStreamReader::doReadArrayBounded( 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/InputStreamReader.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStreamReader.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStreamReader.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/InputStreamReader.h Mon Feb 22 19:02:35 2010
@@ -73,8 +73,8 @@
 
     protected:
 
-        virtual int doReadArraySizeOffsetLength( char* buffer, std::size_t size,
-                                                 std::size_t offset, std::size_t length )
+        virtual int doReadArrayBounded( 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 );

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStream.cpp?rev=915018&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStream.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStream.cpp Mon Feb 22 19:02:35 2010
@@ -0,0 +1,124 @@
+/*
+ * 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 "OutputStream.h"
+
+#include <typeinfo>
+
+#include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+
+using namespace decaf;
+using namespace decaf::io;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+OutputStream::~OutputStream() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OutputStream::close() throw( decaf::io::IOException ) {
+    // Nothing to do by default.
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OutputStream::flush() throw( decaf::io::IOException ) {
+    // Nothing to do by default.
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string OutputStream::toString() const {
+    return typeid( this ).name();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OutputStream::write( unsigned char c ) throw ( decaf::io::IOException ) {
+
+    try{
+        this->doWriteByte( c );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OutputStream::write( const unsigned char* buffer, std::size_t size )
+    throw ( decaf::io::IOException ) {
+
+    try{
+        this->doWriteArray( buffer, size );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OutputStream::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 ) {
+
+    try{
+        this->doWriteArrayBounded( buffer, size, offset, length );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OutputStream::doWriteArray( const unsigned char* buffer, std::size_t size )
+    throw ( decaf::io::IOException ) {
+
+    try{
+        this->doWriteArrayBounded( buffer, size, 0, size );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OutputStream::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 ) {
+
+    try{
+
+        if( buffer == NULL ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "Buffer pointer passed was NULL." );
+        }
+
+        if( offset > size || length > size - offset ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "Offset + Length greater than buffer size." );
+        }
+
+        for( std::size_t i = offset; i < offset + length; i++ ) {
+            this->doWriteByte( buffer[i] );
+        }
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCHALL_THROW( IOException )
+}

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

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStream.h Mon Feb 22 19:02:35 2010
@@ -22,6 +22,7 @@
 #include <decaf/io/Flushable.h>
 #include <decaf/io/IOException.h>
 #include <decaf/util/concurrent/Synchronizable.h>
+#include <decaf/util/concurrent/Mutex.h>
 #include <decaf/util/Config.h>
 
 #include <decaf/lang/exceptions/NullPointerException.h>
@@ -39,37 +40,71 @@
                                    public Flushable,
                                    public util::concurrent::Synchronizable
     {
+    private:
+
+        // Synchronization object.
+        util::concurrent::Mutex mutex;
+
     public:
 
-        virtual ~OutputStream() {}
+        virtual ~OutputStream();
+
+        /**
+         * {@inheritDoc}
+         *
+         * The default implementation of this method does nothing.
+         */
+        virtual void close() throw( decaf::io::IOException );
+
+        /**
+         * {@inheritDoc}
+         *
+         * The default implementation of this method does nothing.
+         */
+        virtual void flush() throw( decaf::io::IOException );
 
         /**
          * Writes a single byte to the output stream.
          *
+         * The default implementation of this method calls the pure virtual method
+         * doWriteByte which must be implemented by any subclass of the OutputStream.
+         *
          * @param c
          *      The byte to write to the sink.
          *
          * @throws IOException if an I/O error occurs.
          */
-        virtual void write( unsigned char c ) throw ( IOException ) = 0;
+        virtual void write( unsigned char c ) throw ( decaf::io::IOException );
 
         /**
          * Writes an array of bytes to the output stream.  The entire contents of
          * the given vector are written to the output stream.
          *
+         * The default implementation of this method simply calls the doWriteArray which
+         * writes the contents of the array using the doWriteByte method repeatedly.  It is
+         * recommended that a subclass override doWriteArray to provide more performant
+         * means of writing the array.
+         *
          * @param buffer
          *      The vector of bytes to write.
+         * @param size
+         *      The size of the buffer passed.
          *
          * @throws IOException if an I/O error occurs.
          */
-        virtual void write( const std::vector<unsigned char>& buffer )
-            throw ( IOException ) = 0;
+        virtual void write( const unsigned char* buffer, std::size_t size )
+            throw ( decaf::io::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.
          *
+         * The default implementation of this method simply calls the doWriteArrayBounded method
+         * which writes the contents of the array using the doWriteByte method repeatedly.  It is
+         * recommended that a subclass override doWriteArrayBounded to provide more performant
+         * means of writing the array.
+         *
          * @param buffer
          *      The array of bytes to write.
          * @param size
@@ -87,7 +122,80 @@
                             std::size_t offset, std::size_t length )
             throw ( decaf::io::IOException,
                     decaf::lang::exceptions::NullPointerException,
-                    decaf::lang::exceptions::IndexOutOfBoundsException ) = 0;
+                    decaf::lang::exceptions::IndexOutOfBoundsException );
+
+        /**
+         * Output a String representation of this object.
+         *
+         * The default version of this method just prints the Class Name.
+         *
+         * @return a string representation of the object.
+         */
+        virtual std::string toString() const;
+
+    protected:
+
+        virtual void doWriteByte( unsigned char value )
+            throw( decaf::io::IOException ) = 0;
+
+        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 );
+
+    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 void notifyAll() throw( decaf::lang::exceptions::RuntimeException,
+                                        decaf::lang::exceptions::IllegalMonitorStateException ) {
+
+            mutex.notifyAll();
+        }
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStreamWriter.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStreamWriter.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStreamWriter.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStreamWriter.cpp Mon Feb 22 19:02:35 2010
@@ -80,8 +80,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void OutputStreamWriter::doWriteArraySizeOffsetLength( const char* buffer, std::size_t size,
-                                                       std::size_t offset, std::size_t length )
+void OutputStreamWriter::doWriteArrayBounded( const 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/OutputStreamWriter.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStreamWriter.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStreamWriter.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/OutputStreamWriter.h Mon Feb 22 19:02:35 2010
@@ -68,8 +68,8 @@
 
     protected:
 
-        virtual void doWriteArraySizeOffsetLength( const char* buffer, std::size_t size,
-                                                   std::size_t offset, std::size_t length )
+        virtual void doWriteArrayBounded( const 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/Reader.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Reader.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Reader.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Reader.cpp Mon Feb 22 19:02:35 2010
@@ -72,8 +72,7 @@
 
         while( skipped < count ) {
 
-            int read = this->doReadArraySizeOffsetLength(
-                            &charsSkipped[0], charsSkipped.size(), 0, toRead );
+            int read = this->doReadArrayBounded( &charsSkipped[0], charsSkipped.size(), 0, toRead );
 
             if( read == -1 ) {
                 return skipped;
@@ -112,7 +111,7 @@
           decaf::lang::exceptions::NullPointerException ) {
 
     try{
-        return this->doReadArraySize( buffer, length );
+        return this->doReadArray( buffer, length );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
@@ -125,7 +124,7 @@
            decaf::lang::exceptions::NullPointerException ) {
 
     try{
-        return this->doReadArraySizeOffsetLength( buffer, size, offset, length );
+        return this->doReadArrayBounded( buffer, size, offset, length );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
@@ -167,14 +166,14 @@
             return -1;
         }
 
-        return this->doReadArraySizeOffsetLength( &buffer[0], buffer.size(), 0, buffer.size() );
+        return this->doReadArrayBounded( &buffer[0], buffer.size(), 0, buffer.size() );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int Reader::doReadArraySize( char* buffer, std::size_t length )
+int Reader::doReadArray( char* buffer, std::size_t length )
     throw( decaf::io::IOException,
            decaf::lang::exceptions::NullPointerException ) {
 
@@ -184,7 +183,7 @@
             return 0;
         }
 
-        return this->doReadArraySizeOffsetLength( buffer, length, 0, length );
+        return this->doReadArrayBounded( buffer, length, 0, length );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
@@ -197,7 +196,7 @@
 
         char buffer;
 
-        if( this->doReadArraySizeOffsetLength( &buffer, 1, 0, 1 ) == -1 ) {
+        if( this->doReadArrayBounded( &buffer, 1, 0, 1 ) == -1 ) {
             return -1;
         }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Reader.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Reader.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Reader.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Reader.h Mon Feb 22 19:02:35 2010
@@ -115,7 +115,7 @@
          *
          * @throws IOException thrown if an I/O error occurs.
          */
-        int read( std::vector<char>& buffer ) throw( decaf::io::IOException );
+        virtual int read( std::vector<char>& buffer ) throw( decaf::io::IOException );
 
         /**
          * Reads characters into an array, the method will attempt to read as much data as the size
@@ -132,7 +132,7 @@
          * @throws IOException thrown if an I/O error occurs.
          * @throws NullPointerException if buffer is NULL.
          */
-        int read( char* buffer, std::size_t length )
+        virtual int read( char* buffer, std::size_t length )
            throw( decaf::io::IOException,
                   decaf::lang::exceptions::NullPointerException );
 
@@ -155,7 +155,7 @@
          * @throws NullPointerException if buffer is NULL.
          * @throws IndexOutOfBoundsException if the offset + length is greater than the array size.
          */
-        int read( char* buffer, std::size_t size, std::size_t offset, std::size_t length )
+        virtual int read( 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 );
@@ -172,9 +172,9 @@
          *
          * @throws IOException thrown if an I/O error occurs.
          */
-        int read() throw( decaf::io::IOException );
+        virtual int read() throw( decaf::io::IOException );
 
-        int read( decaf::nio::CharBuffer* charBuffer )
+        virtual int read( decaf::nio::CharBuffer* charBuffer )
                  throw( decaf::io::IOException,
                         decaf::lang::exceptions::NullPointerException,
                         decaf::nio::ReadOnlyBufferException );
@@ -188,8 +188,8 @@
          * All subclasses must override this method to provide the basic Reader
          * functionality.
          */
-        virtual int doReadArraySizeOffsetLength( char* buffer, std::size_t size,
-                                                 std::size_t offset, std::size_t length )
+        virtual int doReadArrayBounded( 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 ) = 0;
@@ -207,7 +207,7 @@
          * Override this method to customize the functionality of the method
          * read( char* buffer, std::size_t length ).
          */
-        virtual int doReadArraySize( char* buffer, std::size_t length )
+        virtual int doReadArray( char* buffer, std::size_t length )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::NullPointerException );
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.cpp Mon Feb 22 19:02:35 2010
@@ -53,7 +53,7 @@
            decaf::lang::exceptions::NullPointerException ) {
 
     try {
-        this->doWriteArraySize( buffer, size );
+        this->doWriteArray( buffer, size );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCH_RETHROW( NullPointerException )
@@ -67,7 +67,7 @@
            decaf::lang::exceptions::IndexOutOfBoundsException ) {
 
     try {
-        this->doWriteArraySizeOffsetLength( buffer, size, offset, length );
+        this->doWriteArrayBounded( buffer, size, offset, length );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCH_RETHROW( NullPointerException )
@@ -96,7 +96,7 @@
                 __FILE__, __LINE__, "Given Offset + Length value greater than the String length." );
         }
 
-        this->doWriteStringOffsetLength( str.c_str(), offset, length );
+        this->doWriteStringBounded( str.c_str(), offset, length );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
@@ -141,7 +141,7 @@
 void Writer::doWriteChar( char v ) throw( decaf::io::IOException ) {
 
     try {
-        this->doWriteArraySizeOffsetLength( (const char*)&v, 1, 0, 1 );
+        this->doWriteArrayBounded( (const char*)&v, 1, 0, 1 );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
@@ -152,19 +152,19 @@
     throw( decaf::io::IOException ) {
 
     try {
-        this->doWriteArraySizeOffsetLength( &buffer[0], buffer.size(), 0, buffer.size() );
+        this->doWriteArrayBounded( &buffer[0], buffer.size(), 0, buffer.size() );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Writer::doWriteArraySize( const char* buffer, std::size_t size )
+void Writer::doWriteArray( const char* buffer, std::size_t size )
     throw( decaf::io::IOException,
            decaf::lang::exceptions::NullPointerException ) {
 
     try {
-        this->doWriteArraySizeOffsetLength( buffer, size, 0, size );
+        this->doWriteArrayBounded( buffer, size, 0, size );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCH_RETHROW( NullPointerException )
@@ -175,19 +175,19 @@
 void Writer::doWriteString( const std::string& str ) throw( decaf::io::IOException ) {
 
     try {
-        this->doWriteArraySizeOffsetLength( str.c_str(), str.length(), 0, str.length() );
+        this->doWriteArrayBounded( str.c_str(), str.length(), 0, str.length() );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Writer::doWriteStringOffsetLength( const std::string& str, std::size_t offset, std::size_t length )
+void Writer::doWriteStringBounded( const std::string& str, std::size_t offset, std::size_t length )
     throw( decaf::io::IOException,
            decaf::lang::exceptions::IndexOutOfBoundsException ) {
 
     try {
-        this->doWriteArraySizeOffsetLength( str.c_str(), str.length(), offset, length );
+        this->doWriteArrayBounded( str.c_str(), str.length(), offset, length );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCH_RETHROW( IndexOutOfBoundsException )

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.h Mon Feb 22 19:02:35 2010
@@ -53,7 +53,7 @@
          *
          * @throws IOException thrown if an error occurs.
          */
-        void write( char v ) throw( decaf::io::IOException );
+        virtual void write( char v ) throw( decaf::io::IOException );
 
         /**
          * Writes an array of Chars
@@ -63,7 +63,7 @@
          *
          * @throws IOException thrown if an error occurs.
          */
-        void write( const std::vector<char>& buffer )
+        virtual void write( const std::vector<char>& buffer )
             throw( decaf::io::IOException );
 
         /**
@@ -77,7 +77,7 @@
          * @throws IOException if an I/O error occurs.
          * @throws NullPointerException if buffer is NULL.
          */
-        void write( const char* buffer, std::size_t size )
+        virtual void write( const char* buffer, std::size_t size )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::NullPointerException );
 
@@ -97,7 +97,7 @@
          * @throws NullPointerException if buffer is NULL.
          * @throws IndexOutOfBoundsException if offset + length > size of the buffer.
          */
-        void write( const char* buffer, std::size_t size, std::size_t offset, std::size_t length )
+        virtual void write( const 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 );
@@ -110,7 +110,7 @@
          *
          * @throws IOException thrown if an error occurs.
          */
-        void write( const std::string& str ) throw( decaf::io::IOException );
+        virtual void write( const std::string& str ) throw( decaf::io::IOException );
 
         /**
          * Writes a string
@@ -125,16 +125,16 @@
          * @throws IOException thrown if an error occurs.
          * @throws IndexOutOfBoundsException if offset+length is greater than the string length.
          */
-        void write( const std::string& str, std::size_t offset, std::size_t length )
+        virtual void write( const std::string& str, std::size_t offset, std::size_t length )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::IndexOutOfBoundsException );
 
-        decaf::lang::Appendable& append( char value ) throw( decaf::io::IOException );
+        virtual decaf::lang::Appendable& append( char value ) throw( decaf::io::IOException );
 
-        decaf::lang::Appendable& append( const decaf::lang::CharSequence* csq )
+        virtual decaf::lang::Appendable& append( const decaf::lang::CharSequence* csq )
             throw ( decaf::io::IOException );
 
-        decaf::lang::Appendable& append( const decaf::lang::CharSequence* csq,
+        virtual decaf::lang::Appendable& append( const decaf::lang::CharSequence* csq,
                                                  std::size_t start, std::size_t end )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::IndexOutOfBoundsException );
@@ -148,8 +148,8 @@
          * All subclasses must override this method to provide the basic Writer
          * functionality.
          */
-        virtual void doWriteArraySizeOffsetLength( const char* buffer, std::size_t size,
-                                                   std::size_t offset, std::size_t length )
+        virtual void doWriteArrayBounded( const 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 ) = 0;
@@ -161,13 +161,13 @@
         virtual void doWriteVector( const std::vector<char>& buffer )
             throw( decaf::io::IOException );
 
-        virtual void doWriteArraySize( const char* buffer, std::size_t size )
+        virtual void doWriteArray( const char* buffer, std::size_t size )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::NullPointerException );
 
         virtual void doWriteString( const std::string& str ) throw( decaf::io::IOException );
 
-        virtual void doWriteStringOffsetLength( const std::string& str, std::size_t offset, std::size_t length )
+        virtual void doWriteStringBounded( const std::string& str, std::size_t offset, std::size_t length )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::IndexOutOfBoundsException );
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.cpp Mon Feb 22 19:02:35 2010
@@ -72,7 +72,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void System::arraycopy( unsigned char* src, std::size_t srcPos,
+void System::arraycopy( const unsigned char* src, std::size_t srcPos,
                         unsigned char* dest, std::size_t destPos, std::size_t length )
     throw( decaf::lang::exceptions::NullPointerException ){
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.h Mon Feb 22 19:02:35 2010
@@ -43,8 +43,21 @@
          * Copies the number of elements specified by length from the source array starting at
          * the given source offset specified by srcPos to the dest array starting at the given
          * destination offset given by destPos.
+         *
+         * @param src
+         *      The source array to copy from.
+         * @param srcPos
+         *      The position in the array to start copying from.
+         * @param dest
+         *      The destination array to copy to.
+         * @param destPos
+         *      The position in the destination array to start writing at.
+         * @param length
+         *      The number of elements to copy from src to dest.
+         *
+         * @throws NullPointerException if src or dest are NULL.
          */
-        static void arraycopy( unsigned char* src, std::size_t srcPos,
+        static void arraycopy( const unsigned char* src, std::size_t srcPos,
                                unsigned char* dest, std::size_t destPos, std::size_t length )
             throw( decaf::lang::exceptions::NullPointerException );
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.cpp Mon Feb 22 19:02:35 2010
@@ -56,7 +56,7 @@
 using namespace std;
 
 ////////////////////////////////////////////////////////////////////////////////
-SocketInputStream::SocketInputStream( net::Socket::SocketHandle socket ) {
+SocketInputStream::SocketInputStream( net::Socket::SocketHandle socket ) : InputStream() {
     this->socket = socket;
     this->closed = false;
 }
@@ -136,7 +136,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int SocketInputStream::read() throw ( IOException ){
+int SocketInputStream::doReadByte() throw ( IOException ){
 
     // Check for a closed call from socket class, if closed then this read fails.
     if( closed ){
@@ -160,7 +160,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int SocketInputStream::read( unsigned char* buffer, std::size_t size, std::size_t offset, std::size_t length )
+int SocketInputStream::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 ) {
@@ -172,6 +173,10 @@
             "decaf::io::SocketInputStream::read - The Stream has been closed" );
     }
 
+    if( length == 0 ) {
+        return 0;
+    }
+
     if( buffer == NULL ) {
         throw NullPointerException(
             __FILE__, __LINE__,
@@ -224,4 +229,3 @@
         __FILE__, __LINE__,
         "SocketInputStream::skip() method is not supported");
 }
-

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h Mon Feb 22 19:02:35 2010
@@ -20,7 +20,6 @@
 
 #include <decaf/io/InputStream.h>
 #include <decaf/net/Socket.h>
-#include <decaf/util/concurrent/Mutex.h>
 #include <decaf/lang/Exception.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
 
@@ -28,15 +27,15 @@
 namespace net{
 
     /**
-     * Input stream for performing reads on a socket.  This
-     * class will only work properly for blocking sockets.
+     * Input stream for performing reads on a socket.  This class will only
+     * work properly for blocking sockets.
+     *
+     * @since 1.0
      */
     class DECAF_API SocketInputStream : public io::InputStream {
     private:
 
-        // The socket handle.
         Socket::SocketHandle socket;
-        util::concurrent::Mutex mutex;
         bool closed;
 
     public:
@@ -47,9 +46,6 @@
          */
         SocketInputStream( Socket::SocketHandle socket );
 
-        /**
-         * Destructor.
-         */
         virtual ~SocketInputStream();
 
         /**
@@ -61,30 +57,6 @@
         virtual std::size_t available() const throw ( io::IOException );
 
         /**
-         * Reads a single byte from the buffer.  If no data
-         * is available, blocks until their is.
-         * @return The next byte.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual int read() throw ( io::IOException );
-
-        /**
-         * Reads an array of bytes from the buffer.  If the desired amount
-         * of data is not currently available, this operation
-         * will block until the appropriate amount of data is available.
-         * @param buffer (out) the target buffer
-         * @param offset the position in the buffer to start from.
-         * @param bufferSize the size of the output buffer.
-         * @return the number of bytes read. or -1 if EOF
-         * @throws IOException f 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 );
-
-        /**
          * Close - does nothing.  It is the responsibility of the owner
          * of the socket object to close it.
          * @throws IOException
@@ -99,106 +71,15 @@
             throw ( io::IOException,
                     lang::exceptions::UnsupportedOperationException );
 
-        /**
-         * Marks the current position in the stream A subsequent call to the
-         * reset method repositions this stream at the last marked position so
-         * that subsequent reads re-read the same bytes.
-         *
-         * If a stream instance reports that marks are supported then the stream
-         * will ensure that the same bytes can be read again after the reset method
-         * 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 ) {}
-
-        /**
-         * Repositions this stream to the position at the time the mark method was
-         * last called on this input stream.
-         *
-         * If the method markSupported returns true, then:
-         *   * If the method mark has not been called since the stream was created,
-         *     or the number of bytes read from the stream since mark was last called
-         * 	   is larger than the argument to mark at that last call, then an
-         *     IOException might be thrown.
-         *   * If such an IOException is not thrown, then the stream is reset to a
-         *     state such that all the bytes read since the most recent call to mark
-         *     (or since the start of the file, if mark has not been called) will be
-         *     resupplied to subsequent callers of the read method, followed by any
-         *     bytes that otherwise would have been the next input data as of the
-         *     time of the call to reset.
-         * If the method markSupported returns false, then:
-         *   * The call to reset may throw an IOException.
-         *   * If an IOException is not thrown, then the stream is reset to a fixed
-         *     state that depends on the particular type of the input stream and how
-         *     it was created. The bytes that will be supplied to subsequent callers
-         *     of the read method depend on the particular type of the input stream.
-         * @throws IOException
-         */
-        virtual void reset() throw ( io::IOException ) {
-            throw io::IOException(
-                __FILE__, __LINE__,
-                "SocketInputStream::reset - Mark is not supported" );
-        }
-
-        /**
-         * Determines if this input stream supports the mark and reset methods.
-         * Whether or not mark and reset are supported is an invariant property of
-         * a particular input stream instance.
-         * @returns true if this stream instance supports marks
-         */
-        virtual bool markSupported() const {
-            return false;
-        }
-
-    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();
-        }
+    protected:
 
-        virtual void wait( long long millisecs )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
+        virtual int doReadByte() throw ( io::IOException );
 
-            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 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/net/SocketOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.cpp Mon Feb 22 19:02:35 2010
@@ -24,6 +24,7 @@
 using namespace decaf::net;
 using namespace decaf::io;
 using namespace decaf::util;
+using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 using namespace std;
 
@@ -35,7 +36,11 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 SocketOutputStream::~SocketOutputStream() {
-    close();
+    try{
+        this->close();
+    }
+    DECAF_CATCH_NOTHROW( Exception )
+    DECAF_CATCHALL_NOTHROW()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -44,29 +49,20 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void SocketOutputStream::write( unsigned char c ) throw ( IOException ) {
-    write( &c, 1, 0, 1 );
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void SocketOutputStream::write( const std::vector<unsigned char>& buffer )
-    throw ( IOException ) {
+void SocketOutputStream::doWriteByte( unsigned char c ) throw ( IOException ) {
 
     try{
 
-        if( buffer.empty() ) {
-            return;
-        }
-
-        this->write( &buffer[0], buffer.size(), 0, buffer.size() );
+        // Treat the single byte case the same as an array.
+        this->doWriteArrayBounded( &c, 1, 0, 1 );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void SocketOutputStream::write( const unsigned char* buffer, std::size_t size,
-                                std::size_t offset, std::size_t length )
+void SocketOutputStream::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/net/SocketOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h Mon Feb 22 19:02:35 2010
@@ -20,135 +20,45 @@
 
 #include <decaf/io/OutputStream.h>
 #include <decaf/net/Socket.h>
-#include <decaf/util/concurrent/Mutex.h>
 
 namespace decaf{
 namespace net{
 
     /**
-     * Output stream for performing write operations
-     * on a socket.
+     * Output stream for performing write operations on a socket.
+     *
+     * @since 1.0
      */
     class DECAF_API SocketOutputStream : public io::OutputStream {
     private:
 
         // The socket.
         Socket::SocketHandle socket;
-        util::concurrent::Mutex mutex;
         bool closed;
 
     public:
 
         /**
-         * Constructor.
+         * Create a new instance of a Socket OutputStream class.
+         *
          * @param socket the socket handle.
          */
         SocketOutputStream( Socket::SocketHandle socket );
 
         virtual ~SocketOutputStream();
 
-        /**
-         * 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 ( io::IOException );
+        virtual void close() 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 ( io::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 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 );
 
-        /**
-         * Flush - does nothing.
-         * @throws IOException
-         */
-        virtual void flush() throw ( io::IOException ){};
-
-        /**
-         * Close - does nothing.  It is the responsibility of the owner
-         * of the socket object to close it.
-         * @throws IOException
-         */
-        virtual void close() throw( decaf::io::IOException );
-
-    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();
-        }
-
-        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 void notifyAll() throw( decaf::lang::exceptions::RuntimeException,
-                                        decaf::lang::exceptions::IllegalMonitorStateException ) {
-
-            mutex.notifyAll();
-        }
-
     };
 
 }}



Mime
View raw message