activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r652104 [8/29] - in /activemq/activemq-cpp/trunk: ./ m4/ src/examples/ src/examples/consumers/ src/main/ src/main/decaf/ src/main/decaf/internal/ src/main/decaf/internal/net/ src/main/decaf/internal/nio/ src/main/decaf/internal/util/ src/ma...
Date Tue, 29 Apr 2008 20:52:37 GMT
Added: activemq/activemq-cpp/trunk/src/main/decaf/io/StandardErrorOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/io/StandardErrorOutputStream.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/io/StandardErrorOutputStream.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/io/StandardErrorOutputStream.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,176 @@
+/*
+ * 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.
+ */
+#ifndef _DECAF_IO_STANDARDERROROUTPUTSTREAM_H_
+#define _DECAF_IO_STANDARDERROROUTPUTSTREAM_H_
+
+#include <decaf/io/OutputStream.h>
+#include <decaf/util/concurrent/Mutex.h>
+
+#include <iostream>
+
+namespace decaf{
+namespace io{
+
+    class DECAF_API StandardErrorOutputStream : public OutputStream {
+    private:
+
+        /**
+         * Synchronization object.
+         */
+        util::concurrent::Mutex mutex;
+
+    public:
+
+        /**
+         * Default Constructor
+         */
+        StandardErrorOutputStream(void) {}
+
+        virtual ~StandardErrorOutputStream(void) {}
+
+        /**
+         * 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 ) {
+           std::cerr << c;
+        }
+
+        /**
+         * 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 ) {
+
+            if( buffer.empty() ){
+                return;
+            }
+
+            this->write( &buffer[0], 0, buffer.size() );
+        }
+
+        /**
+         * Writes an array of bytes to the output stream.
+         * @param buffer The array of bytes to write.
+         * @param offset, the position to start writing in buffer.
+         * @param len The number of bytes from the buffer to be written.
+         * @throws IOException thrown if an error occurs.
+         * @throws NullPointerException if buffer is null.
+         */
+        virtual void write( const unsigned char* buffer,
+                            std::size_t offset,
+                            std::size_t len )
+            throw ( IOException, lang::exceptions::NullPointerException ) {
+
+            if( buffer == NULL ) {
+                throw lang::exceptions::NullPointerException(
+                    __FILE__, __LINE__,
+                    "StandardErrorOutputStream::write - Passed buffer is null." );
+            }
+
+            for( int i = 0; i < len; ++i ) {
+                std::cerr << buffer[i+offset];
+            }
+        }
+
+        /**
+         * Invokes flush on the target output stream.
+         * throws IOException if an error occurs
+         */
+        virtual void flush() throw ( IOException ){
+            std::cerr.flush();
+        }
+
+        /**
+         * Invokes close on the target output stream.
+         * throws CMSException if an error occurs
+         */
+        void close() throw( lang::Exception ){
+            std::cerr.flush();
+        }
+
+    public:
+
+        /**
+         * Waits on a signal from this object, which is generated
+         * by a call to Notify.  Must have this object locked before
+         * calling.
+         * @throws Exception
+         */
+        virtual void lock() throw( Exception ){
+            mutex.lock();
+        }
+
+        /**
+         * Unlocks the object.
+         * @throws Exception
+         */
+        virtual void unlock() throw( lang::Exception ){
+            mutex.unlock();
+        }
+
+        /**
+         * Waits on a signal from this object, which is generated
+         * by a call to Notify.  Must have this object locked before
+         * calling.
+         * @throws Exception
+         */
+        virtual void wait() throw( lang::Exception ){
+            mutex.wait();
+        }
+
+        /**
+         * Waits on a signal from this object, which is generated
+         * by a call to Notify.  Must have this object locked before
+         * calling.  This wait will timeout after the specified time
+         * interval.
+         * @param time in millisecsonds to wait, or WAIT_INIFINITE
+         * @throws Exception
+         */
+        virtual void wait( unsigned long millisecs ) throw( lang::Exception ){
+            mutex.wait( millisecs );
+        }
+
+        /**
+         * Signals a waiter on this object that it can now wake
+         * up and continue.  Must have this object locked before
+         * calling.
+         * @throws Exception
+         */
+        virtual void notify() throw( lang::Exception ){
+            mutex.notify();
+        }
+
+        /**
+         * Signals the waiters on this object that it can now wake
+         * up and continue.  Must have this object locked before
+         * calling.
+         * @throws Exception
+         */
+        virtual void notifyAll() throw( lang::Exception ){
+            mutex.notifyAll();
+        }
+
+    };
+
+}
+
+#endif /*_DECAF_IO_STANDARDERROROUTPUTSTREAM_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/io/Writer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/io/Writer.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/io/Writer.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/io/Writer.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+#ifndef _DECAF_IO_WRITER_H
+#define _DECAF_IO_WRITER_H
+
+#include <string>
+#include <decaf/io/IOException.h>
+#include <decaf/io/OutputStream.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+
+namespace decaf{
+namespace io{
+
+    /*
+     * Writer interface for an object that wraps around an output
+     * stream
+     */
+    class DECAF_API Writer {
+    public:
+
+        virtual ~Writer(){};
+
+        /**
+         * Sets the target output stream.
+         * @param Outputstream to use
+         */
+        virtual void setOutputStream( OutputStream* os ) = 0;
+
+        /**
+         * Gets the target output stream.
+         * @returns the output stream currently being used
+         */
+        virtual OutputStream* getOutputStream() = 0;
+
+        /**
+         * Writes a byte array to the output stream.
+         * @param buffer a byte array
+         * @param count the number of bytes in the array to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const unsigned char* buffer,
+                            std::size_t count )
+            throw( IOException, lang::exceptions::NullPointerException ) = 0;
+
+         /**
+          * Writes a byte to the output stream.
+          * @param v The value to be written.
+          * @throws IOException thrown if an error occurs.
+          */
+         virtual void writeByte( unsigned char v ) throw( IOException ) = 0;
+    };
+
+}}
+
+#endif /*_DECAF_IO_WRITER_H*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Appendable.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Appendable.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Appendable.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Appendable.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+#ifndef _DECAF_LANG_APPENDABLE_H_
+#define _DECAF_LANG_APPENDABLE_H_
+
+#include <decaf/lang/Exception.h>
+#include <decaf/util/Config.h>
+
+namespace decaf{
+namespace lang{
+
+    class CharSequence;
+
+    class DECAF_API Appendable {
+    public:
+
+        virtual ~Appendable() {}
+
+        /**
+         * Appends the specified character to this Appendable.
+         * @param value - The character to append
+         * @returns a Reference to this Appendable
+         * @throws Exception if an error occurs.
+         */
+        virtual Appendable& append( char value ) throw( decaf::lang::Exception ) = 0;
+
+        /**
+         * Appends the specified character sequence to this Appendable.
+         * @param csq - The character sequence from which a subsequence will be appended.
+         * If csq is NULL, then characters will be appended as if csq contained the
+         * string "null".
+         * @returns a Reference to this Appendable
+         * @throws Exception if an error occurs.
+         */
+        virtual Appendable& append( const CharSequence* csq )
+            throw ( decaf::lang::Exception ) = 0;
+
+        /**
+         * Appends a subsequence of the specified character sequence to this Appendable.
+         * @param csq - The character sequence from which a subsequence will be appended.
+         * If csq is NULL, then characters will be appended as if csq contained the
+         * string "null".
+         * @param start - The index of the first character in the subsequence
+         * @param end - The index of the character following the last character in the subsequence
+         * @returns a Reference to this Appendable
+         * @throws Exception if an error occurs.
+         * @throws IndexOutOfBoundsException start is greater than end, or end is
+         * greater than csq.length()
+         */
+        virtual Appendable& append( const CharSequence* csq,
+                                    std::size_t start, std::size_t end )
+            throw( decaf::lang::Exception ) = 0;
+
+    };
+
+}}
+
+#endif /*_DECAF_LANG_APPENDABLE_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Boolean.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Boolean.cpp?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Boolean.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Boolean.cpp Tue Apr 29 13:52:30 2008
@@ -0,0 +1,107 @@
+/*
+ * 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 "Boolean.h"
+#include <sstream>
+
+using namespace decaf;
+using namespace decaf::lang;
+
+////////////////////////////////////////////////////////////////////////////////
+const Boolean Boolean::_FALSE( false );
+const Boolean Boolean::_TRUE( true );
+
+////////////////////////////////////////////////////////////////////////////////
+Boolean::Boolean( bool value ) {
+    this->value = value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Boolean::Boolean( const std::string& value ) {
+    this->value = parseBoolean( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Boolean::compareTo( const Boolean& b ) const {
+    if( this->value == b.value ) {
+        return 0;
+    } else if( this->value && !b.value ) {
+        return 1;
+    } else {
+        return -1;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Boolean::operator==( const Boolean& b ) const {
+    return this->value == b.value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Boolean::operator<( const Boolean& b ) const {
+    return this->value < b.value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Boolean::compareTo( const bool& b ) const {
+    if( this->value == b ) {
+        return 0;
+    } else if( this->value && !b ) {
+        return 1;
+    } else {
+        return -1;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Boolean::operator==( const bool& b ) const {
+    return this->value == b;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Boolean::operator<( const bool& b ) const {
+    return this->value < b;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Boolean::toString() const {
+    return this->value ? "true" : "false";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Boolean Boolean::valueOf( const std::string& value ) {
+    return Boolean( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Boolean Boolean::valueOf( bool value ) {
+    return Boolean( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Boolean::parseBoolean( const std::string& value ) {
+    bool ret = 0;
+    std::istringstream istream( value );
+    istream.clear();
+    istream >> std::boolalpha >> ret;
+    return ret;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Boolean::toString( bool value ) {
+    return value ? "true" : "false";
+}

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Boolean.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Boolean.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Boolean.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Boolean.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,167 @@
+/*
+ * 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.
+ */
+
+#ifndef _DECAF_LANG_BOOLEAN_H_
+#define _DECAF_LANG_BOOLEAN_H_
+
+#include <string>
+#include <decaf/lang/Comparable.h>
+#include <decaf/util/Config.h>
+
+namespace decaf{
+namespace lang{
+
+    class DECAF_API Boolean : public Comparable<Boolean>,
+                              public Comparable<bool> {
+    private:
+
+        // This objects boolean value
+        bool value;
+
+    public:
+
+        /**
+         * The Class object representing the primitive false boolean.
+         */
+        static const Boolean _FALSE;
+
+        /**
+         * The Class object representing the primitive type boolean.
+         */
+        static const Boolean _TRUE;
+
+    public:
+
+        /**
+         * @param value - primitive boolean to wrap.
+         */
+        Boolean( bool value );
+
+        /**
+         * @param value - String value to convert to a boolean.
+         */
+        Boolean( const std::string& value );
+
+        virtual ~Boolean() {}
+
+        /**
+         * @returns the primitive boolean value of this object
+         */
+        bool booleanValue() const {
+            return value;
+        }
+
+        /**
+         * @returns the string representation of this Booleans value.
+         */
+        std::string toString() const;
+
+        /**
+         * Compares this Boolean instance with another.
+         * @param b - the Boolean instance to be compared
+         * @return zero if this object represents the same boolean value as the
+         * argument; a positive value if this object represents true and the
+         * argument represents false; and a negative value if this object
+         * represents false and the argument represents true
+         */
+        virtual int compareTo( const Boolean& b ) const;
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const Boolean& value ) const;
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const Boolean& value ) const;
+
+        /**
+         * @returns true if the two Boolean Objects have the same value.
+         */
+        bool equals( const Boolean& b ) const {
+            return this->value == b.value;
+        }
+
+        /**
+         * Compares this Boolean instance with another.
+         * @param b - the Boolean instance to be compared
+         * @return zero if this object represents the same boolean value as the
+         * argument; a positive value if this object represents true and the
+         * argument represents false; and a negative value if this object
+         * represents false and the argument represents true
+         */
+        virtual int compareTo( const bool& b ) const;
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const bool& value ) const;
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const bool& value ) const;
+
+        /**
+         * @returns true if the two Boolean Objects have the same value.
+         */
+        bool equals( const bool& b ) const {
+            return this->value == b;
+        }
+
+    public:  // Statics
+
+        /**
+         * @returns a Boolean instance of the primitive boolean value
+         */
+        static Boolean valueOf( bool value );
+
+        /**
+         * @returns a Boolean instance of the string value
+         */
+        static Boolean valueOf( const std::string& value );
+
+        /**
+         * Parses the String passed and extracts an bool.
+         * @param String to parse
+         * @return bool value
+         */
+        static bool parseBoolean( const std::string& value );
+
+        /**
+         * Converts the bool to a String representation
+         * @param bool to convert
+         * @return string representation
+         */
+        static std::string toString( bool value );
+
+    };
+
+}}
+
+#endif /*_DECAF_LANG_BOOLEAN_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Byte.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Byte.cpp?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Byte.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Byte.cpp Tue Apr 29 13:52:30 2008
@@ -0,0 +1,95 @@
+/*
+ * 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 "Byte.h"
+#include <decaf/lang/Integer.h>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+Byte::Byte( unsigned char value ) {
+    this->value = value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Byte::Byte( const std::string& value ) throw( exceptions::NumberFormatException ) {
+    this->value = parseByte( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Byte::toString() const {
+    return string( 1, this->value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Byte::toString( unsigned char value ) {
+    return Integer::toString( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char Byte::parseByte( const std::string& s, int radix )
+    throw ( exceptions::NumberFormatException ) {
+
+    int intValue = Integer::parseInt( s, radix );
+    unsigned char result = (unsigned char)intValue;
+    if( result != intValue ) {
+        throw NumberFormatException(
+            __FILE__, __LINE__,
+            "Byte::parseByte - Not a valid unsigned char encoded string.");
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char Byte::parseByte( const std::string& s )
+    throw ( exceptions::NumberFormatException ) {
+
+    return parseByte( s, 10 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Byte Byte::decode( const std::string& value )
+    throw ( exceptions::NumberFormatException ) {
+
+    int intValue = Integer::decode( value ).intValue();
+    unsigned char result = (unsigned char)intValue;
+    if( result != intValue ) {
+        throw NumberFormatException(
+            __FILE__, __LINE__,
+            "Byte::decode - Not a valid unsigned char encoded string.");
+    }
+
+    return Byte( result );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Byte Byte::valueOf( const std::string& value )
+    throw ( exceptions::NumberFormatException ) {
+
+    return Byte( parseByte( value, 10 ) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Byte Byte::valueOf( const std::string& value, int radix )
+    throw ( exceptions::NumberFormatException ) {
+
+    return Byte( parseByte( value, radix ) );
+}

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Byte.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Byte.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Byte.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Byte.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,301 @@
+/*
+ * 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.
+ */
+
+#ifndef _DECAF_LANG_BYTE_H_
+#define _DECAF_LANG_BYTE_H_
+
+#include <decaf/util/Config.h>
+#include <decaf/lang/Number.h>
+#include <decaf/lang/Comparable.h>
+#include <decaf/lang/exceptions/NumberFormatException.h>
+#include <string>
+
+namespace decaf{
+namespace lang{
+
+    class DECAF_API Byte : public Number,
+                           public Comparable<Byte>,
+                           public Comparable<unsigned char> {
+    private:
+
+        unsigned char value;
+
+    public:
+
+        /** The minimum value that a unsigned char can take on. */
+        static const unsigned char MIN_VALUE = 0x7F;
+
+        /** The maximum value that a unsigned char can take on. */
+        static const unsigned char MAX_VALUE = 0x80;
+
+        /** The size of the primitive charactor in bits. */
+        static const int SIZE = 8;
+
+    public:
+
+        /**
+         * @param value - the primitive value to wrap
+         */
+        Byte( unsigned char value );
+
+        /**
+         * @param value - the string to convert to an unsigned char
+         * @throws NumberFormatException
+         */
+        Byte( const std::string& value ) throw( exceptions::NumberFormatException );
+
+        virtual ~Byte() {}
+
+        /**
+         * Compares this Byte instance with another.
+         * @param c - the Byte instance to be compared
+         * @return zero if this object represents the same char value as the
+         * argument; a positive value if this object represents a value greater
+         * than the passed in value, and -1 if this object repesents a value
+         * less than the passed in value.
+         */
+        virtual int compareTo( const Byte& c ) const {
+            return this->value < c.value ? -1 : (this->value > c.value) ? 1 : 0;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const Byte& c ) const {
+            return this->value == c.value;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const Byte& c ) const {
+            return this->value < c.value;
+        }
+
+        /**
+         * Compares this Byte instance with a char type.
+         * @param c - the char instance to be compared
+         * @return zero if this object represents the same char value as the
+         * argument; a positive value if this object represents a value greater
+         * than the passed in value, and -1 if this object repesents a value
+         * less than the passed in value.
+         */
+        virtual int compareTo( const unsigned char& c ) const {
+            return this->value < c ? -1 : (this->value > c) ? 1 : 0;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const unsigned char& c ) const {
+            return this->value == c;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const unsigned char& c ) const {
+            return this->value < c;
+        }
+
+        /**
+         * @returns true if the two Byte Objects have the same value.
+         */
+        bool equals( const Byte& c ) const {
+            return this->value == c.value;
+        }
+
+        /**
+         * @returns true if the two Bytes have the same value.
+         */
+        bool equals( const unsigned char& c ) const {
+            return this->value == c;
+        }
+
+        /**
+         * @returns this Byte Object as a String Representation
+         */
+        std::string toString() const;
+
+        /**
+         * Answers the double value which the receiver represents
+         * @return double the value of the receiver.
+         */
+        virtual double doubleValue() const {
+            return (double)this->value;
+        }
+
+        /**
+         * Answers the float value which the receiver represents
+         * @return float the value of the receiver.
+         */
+        virtual float floatValue() const {
+            return (float)this->value;
+        }
+
+        /**
+         * Answers the byte value which the receiver represents
+         * @return byte the value of the receiver.
+         */
+        virtual unsigned char byteValue() const {
+            return this->value;
+        }
+
+        /**
+         * Answers the short value which the receiver represents
+         * @return short the value of the receiver.
+         */
+        virtual short shortValue() const {
+            return (short)this->value;
+        }
+
+        /**
+         * Answers the int value which the receiver represents
+         * @return int the value of the receiver.
+         */
+        virtual int intValue() const {
+            return (int)this->value;
+        }
+
+        /**
+         * Answers the long value which the receiver represents
+         * @return long long the value of the receiver.
+         */
+        virtual long long longValue() const {
+            return (long long)this->value;
+        }
+
+    public:    // statics
+
+        /**
+         * @returns a string representing the primitive value as Base 10
+         */
+        static std::string toString( unsigned char value );
+
+        /**
+         * Decodes a String into a Byte. Accepts decimal, hexadecimal, and octal
+         * numbers given by the following grammar:
+         *
+         * The sequence of characters following an (optional) negative sign and/or
+         * radix specifier ("0x", "0X", "#", or leading zero) is parsed as by the
+         * Byte::parseByte method with the indicated radix (10, 16, or 8). This
+         * sequence of characters must represent a positive value or a
+         * NumberFormatException will be thrown. The result is negated if first
+         * character of the specified String is the minus sign. No whitespace
+         * characters are permitted in the string.
+         * @param value - The string to decode
+         * @returns a Byte object containing the decoded value
+         * @throws NumberFomatException if the string is not formatted correctly.
+         */
+        static Byte decode( const std::string& value )
+            throw ( exceptions::NumberFormatException );
+
+        /**
+         * Parses the string argument as a signed unsigned char in the radix specified by
+         * the second argument. The characters in the string must all be digits,
+         * of the specified radix (as determined by whether
+         * Character.digit(char, int) returns a nonnegative value) except that the
+         * first character may be an ASCII minus sign '-'  ('\u002D') to indicate
+         * a negative value. The resulting byte value is returned.
+         *
+         * An exception of type NumberFormatException is thrown if any of the
+         * following situations occurs:
+         *  * The first argument is null or is a string of length zero.
+         *  * The radix is either smaller than Character.MIN_RADIX or larger than
+         *    Character::MAX_RADIX.
+         *  * Any character of the string is not a digit of the specified radix,
+         *    except that the first character may be a minus sign '-' provided
+         *    that the string is longer than length 1.
+         *  * The value represented by the string is not a value of type unsigned char.
+         *
+         * @param s - the String containing the unsigned char to be parsed
+         * @param radix - the radix to be used while parsing s
+         * @return the unsigned char represented by the string argument in the
+         * 	       specified radix.
+         * @throws NumberFormatException - If String does not contain a parsable
+         *         unsigned char.
+         */
+        static unsigned char parseByte( const std::string& s, int radix )
+            throw ( exceptions::NumberFormatException );
+
+        /**
+         * Parses the string argument as a signed decimal unsigned char. The
+         * characters in the string must all be decimal digits, except that the
+         * first character may be an ASCII minus sign '-' ('\u002D') to indicate a
+         * negative value. The resulting unsigned char value is returned, exactly as
+         * if the argument and the radix 10 were given as arguments to the
+         * parseByte( const std::string, int ) method.
+         * @param s - String to convert to a unsigned char
+         * @returns the converted unsigned char value
+         * @throws NumberFormatException if the string is not a unsigned char.
+         */
+        static unsigned char parseByte( const std::string& s )
+            throw ( exceptions::NumberFormatException );
+
+        /**
+         * Returns a Character instance representing the specified char value.
+         * @param value - the primitive char to wrap.
+         * @returns a new Charactor instance that wraps this value.
+         */
+        static Byte valueOf( unsigned char value ) {
+            return Byte( value );
+        }
+
+        /**
+         * Returns a Byte object holding the value given by the specified std::string.
+         * The argument is interpreted as representing a signed decimal unsigned char,
+         * exactly as if the argument were given to the parseByte( std::string )
+         * method. The result is a Byte object that represents the unsigned char value
+         * specified by the string.
+         * @param value - std::string to parse as base 10
+         * @return new Byte Object wrapping the primitive
+         * @throws NumberFormatException if the string is not a decimal unsigned char.
+         */
+        static Byte valueOf( const std::string& value )
+            throw ( exceptions::NumberFormatException );
+
+        /**
+         * Returns a Byte object holding the value extracted from the specified
+         * std::string when parsed with the radix given by the second argument.
+         * The first argument is interpreted as representing a signed unsigned char
+         * in the radix specified by the second argument, exactly as if the argument
+         * were given to the parseByte( std::string, int ) method. The result is a
+         * Byte object that represents the unsigned char value specified by the
+         * string.
+         * @param value - std::string to parse as base ( radix )
+         * @param radix - base of the string to parse.
+         * @return new Byte Object wrapping the primitive
+         * @throws NumberFormatException if the string is not a valid unsigned char.
+         */
+        static Byte valueOf( const std::string& value, int radix )
+            throw ( exceptions::NumberFormatException );
+
+    };
+
+}}
+
+#endif /*_DECAF_LANG_BYTE_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/CharSequence.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/CharSequence.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/CharSequence.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/CharSequence.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+#ifndef _DECAF_LANG_CHARSEQUENCE_H_
+#define _DECAF_LANG_CHARSEQUENCE_H_
+
+#include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
+#include <decaf/util/Config.h>
+
+namespace decaf{
+namespace lang{
+
+    /**
+     * A CharSequence is a readable sequence of char values. This interface provides
+     * uniform, read-only access to many different kinds of char sequences.
+     *
+     * This interface does not define that a CharSequence should implement comparable,
+     * it is therefore up to the dervied classes that implement this interface to define
+     * equality, which implies that comparison of two CharSequences does not have a
+     * contract on equality.
+     */
+    class DECAF_API CharSequence {
+    public:
+
+        virtual ~CharSequence() {}
+
+        /**
+         * @returns the length of the underlying character sequence.
+         */
+        virtual std::size_t length() const = 0;
+
+        /**
+         * Returns the Char at the specified index so long as the index is not
+         * greater than the length of the sequence.
+         * @param index - position to return the char at.
+         * @returns the char at the given position
+         * @throws IndexOutOfBoundsException if index is > than length()
+         */
+        virtual char charAt( std::size_t index ) const
+            throw( lang::exceptions::IndexOutOfBoundsException ) = 0;
+
+        /**
+         * Returns a new CharSequence that is a subsequence of this sequence. The
+         * subsequence starts with the char value at the specified index and ends with
+         * the char value at index end - 1. The length (in chars) of the returned
+         * sequence is end - start, so if start == end then an empty sequence is returned.
+         * @param start - the start index, inclusive
+         * @param end - the end index, exclusive
+         * @returns a new CharSequence
+         * @throws IndexOutOfBoundsException if start or end > length()
+         */
+        virtual CharSequence* subSequence( std::size_t start, std::size_t end ) const
+            throw( lang::exceptions::IndexOutOfBoundsException ) = 0;
+
+        /**
+         * @returns the string representation of this CharSequence
+         */
+        virtual std::string toString() const = 0;
+
+    };
+
+}}
+
+#endif /*_DECAF_LANG_CHARSEQUENCE_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Character.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Character.cpp?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Character.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Character.cpp Tue Apr 29 13:52:30 2008
@@ -0,0 +1,48 @@
+/*
+ * 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 <decaf/lang/Character.h>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::lang;
+
+////////////////////////////////////////////////////////////////////////////////
+Character::Character( char value ) {
+    this->value = value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Character::toString() const {
+    return string( 1, this->value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Character::digit( char c, int radix ) {
+    if( radix >= MIN_RADIX && radix <= MAX_RADIX ) {
+        int result = -1;
+        if( '0' <= c && c <= '9' ) {
+            result = c - '0';
+        } else if( 'a' <= c && c <= 'z' ) {
+            result = c - ('a' - 10);
+        } else if( 'A' <= c && c <= 'Z' ) {
+            result = c - ('A' - 10);
+        }
+        return result < radix ? result : -1;
+    }
+    return -1;
+}

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Character.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Character.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Character.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Character.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,298 @@
+/*
+ * 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.
+ */
+
+#ifndef _DECAF_LANG_CHARACTER_H_
+#define _DECAF_LANG_CHARACTER_H_
+
+#include <decaf/util/Config.h>
+#include <decaf/lang/Number.h>
+#include <decaf/lang/Comparable.h>
+#include <string>
+
+namespace decaf{
+namespace lang{
+
+    class DECAF_API Character : public Number,
+                                public Comparable<Character>,
+                                public Comparable<char> {
+    private:
+
+        // The primitive Char value
+        char value;
+
+    public:
+
+        /** The minimum radix available for conversion to and from strings. */
+        static const int MIN_RADIX = 2;
+
+        /** The maximum radix available for conversion to and from strings. */
+        static const int MAX_RADIX = 36;
+
+        /** The minimum value that a signed char can take on. */
+        static const char MIN_VALUE = (char)0x7F;
+
+        /** The maximum value that a signed char can take on. */
+        static const char MAX_VALUE = (char)0x80;
+
+        /** The size of the primitive charactor in bits. */
+        static const int SIZE = 8;
+
+    public:
+
+        /**
+         * @param value - char to wrap.
+         */
+        Character( char value );
+
+        /**
+         * Compares this Character instance with another.
+         * @param c - the Character instance to be compared
+         * @return zero if this object represents the same char value as the
+         * argument; a positive value if this object represents a value greater
+         * than the passed in value, and -1 if this object repesents a value
+         * less than the passed in value.
+         */
+        virtual int compareTo( const Character& c ) const {
+            return this->value < c.value ? -1 : (this->value > c.value) ? 1 : 0;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const Character& c ) const {
+            return this->value == c.value;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const Character& c ) const {
+            return this->value < c.value;
+        }
+
+        /**
+         * Compares this Character instance with a char type.
+         * @param c - the char instance to be compared
+         * @return zero if this object represents the same char value as the
+         * argument; a positive value if this object represents a value greater
+         * than the passed in value, and -1 if this object repesents a value
+         * less than the passed in value.
+         */
+        virtual int compareTo( const char& c ) const {
+            return this->value < c ? -1 : (this->value > c) ? 1 : 0;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const char& c ) const {
+            return this->value == c;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const char& c ) const {
+            return this->value < c;
+        }
+
+        /**
+         * @returns true if the two Character Objects have the same value.
+         */
+        bool equals( const Character& c ) const {
+            return this->value == c.value;
+        }
+
+        /**
+         * @returns true if the two Characters have the same value.
+         */
+        bool equals( const char& c ) const {
+            return this->value == c;
+        }
+
+        /**
+         * @returns this Character Object as a String Representation
+         */
+        std::string toString() const;
+
+        /**
+         * Answers the double value which the receiver represents
+         * @return double the value of the receiver.
+         */
+        virtual double doubleValue() const {
+            return (double)this->value;
+        }
+
+        /**
+         * Answers the float value which the receiver represents
+         * @return float the value of the receiver.
+         */
+        virtual float floatValue() const {
+            return (float)this->value;
+        }
+
+        /**
+         * Answers the byte value which the receiver represents
+         * @return int the value of the receiver.
+         */
+        virtual unsigned char byteValue() const {
+            return (unsigned char)this->value;
+        }
+
+        /**
+         * Answers the short value which the receiver represents
+         * @return int the value of the receiver.
+         */
+        virtual short shortValue() const {
+            return (short)this->value;
+        }
+
+        /**
+         * Answers the int value which the receiver represents
+         * @return int the value of the receiver.
+         */
+        virtual int intValue() const {
+            return (int)this->value;
+        }
+
+        /**
+         * Answers the long value which the receiver represents
+         * @return long the value of the receiver.
+         */
+        virtual long long longValue() const {
+            return (long long)this->value;
+        }
+
+    public:    // statics
+
+        /**
+         * Returns a Character instance representing the specified char value.
+         * @param value - the primitive char to wrap.
+         * @returns a new Charactor instance that wraps this value.
+         */
+        static Character valueOf( char value ) {
+            return Character( value );
+        }
+
+        /**
+         * Indicates whether or not the given character is considered
+         * whitespace.
+         */
+        static bool isWhitespace( char c ){
+            switch ( c )
+            {
+                case '\n':
+                case '\t':
+                case '\r':
+                case '\f':
+                case ' ':
+                    return true;
+            }
+
+            return false;
+        }
+
+        /**
+         * Indicates whether or not the given character is
+         * a digit.
+         */
+        static bool isDigit( char c ){
+            return c >= '0' && c <= '9';
+        }
+
+        /**
+         * Indicates whether or not the given character is
+         * a lower case character.
+         */
+        static bool isLowerCase( char c ){
+            return c >= 'a' && c <= 'z';
+        }
+
+        /**
+         * Indicates whether or not the given character is
+         * a upper case character.
+         */
+        static bool isUpperCase( char c ){
+            return c >= 'A' && c <= 'Z';
+        }
+
+        /**
+         * Indicates whether or not the given character is
+         * a letter.
+         */
+        static bool isLetter( char c ){
+            return isUpperCase(c) || isLowerCase(c);
+        }
+
+        /**
+         * Indicates whether or not the given character is
+         * either a letter or a digit.
+         */
+        static bool isLetterOrDigit( char c ){
+            return isLetter(c) || isDigit(c);
+        }
+
+        /**
+         * Answers whether the character is an ISO control character, which
+         * is a char that lays in the range of 0 to 1f and 7f to 9f
+         * @param c - the character, including supplementary characters
+         * @return true if the char is an ISO control character
+         */
+        static bool isISOControl( char c ) {
+            return ( c >= 0 && c <= 0x1f ) ||
+                   ( (unsigned char)c >= 0x7f && (unsigned char)c <= 0x9f );
+        }
+
+        /**
+         * Returns the numeric value of the character ch in the specified radix.
+         *
+         * If the radix is not in the range MIN_RADIX <= radix <= MAX_RADIX or if
+         * the value of ch is not a valid digit in the specified radix, -1 is
+         * returned. A character is a valid digit if at least one of the following
+         * is true:
+         *
+         *    * The method isDigit is true of the character and the single-character
+         *      decomposition is less than the specified radix. In this case the
+         *      decimal digit value is returned.
+         *    * The character is one of the uppercase Latin letters 'A' through 'Z'
+         *      and its code is less than radix + 'A' - 10. In this case,
+         *      ch - 'A' + 10 is returned.
+         *    * The character is one of the lowercase Latin letters 'a' through 'z'
+         *      and its code is less than radix + 'a' - 10. In this case,
+         *      ch - 'a' + 10 is returned.
+         *
+         * @param c - the char to be converted
+         * @param radix - the radix of the number
+         * @returns the numeric value of the number represented in the given radix
+         */
+        static int digit( char c, int radix );
+
+    };
+
+}}
+
+#endif /*_DECAF_LANG_CHARACTER_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Comparable.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Comparable.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Comparable.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Comparable.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+#ifndef _DECAF_LANG_COMPARABLE_H_
+#define _DECAF_LANG_COMPARABLE_H_
+
+#include <decaf/util/Config.h>
+
+namespace decaf{
+namespace lang{
+
+    /**
+     * This interface imposes a total ordering on the objects of each class that
+     * implements it. This ordering is referred to as the class's natural
+     * ordering, and the class's compareTo method is referred to as its natural
+     * comparison method.
+     */
+    template< typename T >
+    class DECAF_API Comparable{
+    public:
+
+        virtual ~Comparable() {}
+
+        /**
+         * Compares this object with the specified object for order. Returns a
+         * negative integer, zero, or a positive integer as this object is less
+         * than, equal to, or greater than the specified object.
+         *
+         * In the foregoing description, the notation sgn(expression) designates
+         * the mathematical signum function, which is defined to return one of
+         * -1, 0, or 1 according to whether the value of expression  is negative,
+         * zero or positive. The implementor must ensure sgn(x.compareTo(y)) ==
+         * -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y)
+         * must throw an exception iff y.compareTo(x) throws an exception.)
+         *
+         * The implementor must also ensure that the relation is transitive:
+         * (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.
+         *
+         * Finally, the implementer must ensure that x.compareTo(y)==0 implies
+         * that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.
+         *
+         * It is strongly recommended, but not strictly required that
+         * (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class
+         * that implements the Comparable interface and violates this condition
+         * should clearly indicate this fact. The recommended language is
+         * "Note: this class has a natural ordering that is inconsistent with
+         * equals."
+         * @param value - the Object to be compared.
+         * @returns a negative integer, zero, or a positive integer as this
+         * object is less than, equal to, or greater than the specified object.
+         */
+        virtual int compareTo( const T& value ) const = 0;
+
+        /**
+         * @return true if this value is considered equal to the passed value.
+         */
+        virtual bool equals( const T& value ) const = 0;
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const T& value ) const = 0;
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const T& value ) const = 0;
+
+    };
+
+}}
+
+#endif /*_DECAF_LANG_COMPARABLE_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Double.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Double.cpp?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Double.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Double.cpp Tue Apr 29 13:52:30 2008
@@ -0,0 +1,245 @@
+/*
+ * 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 "Double.h"
+#include <decaf/lang/Long.h>
+#include <limits>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+const double Double::MAX_VALUE = 1.7976931348623157e+308;
+const double Double::MIN_VALUE = 5e-324;
+const double Double::NaN = std::numeric_limits<double>::quiet_NaN();
+const double Double::POSITIVE_INFINITY = std::numeric_limits<double>::infinity();
+const double Double::NEGATIVE_INFINITY = -std::numeric_limits<double>::infinity();
+
+////////////////////////////////////////////////////////////////////////////////
+Double::Double( double value ) {
+    this->value = value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Double::Double( const std::string& value ) throw( exceptions::NumberFormatException ) {
+    this->value = Double::parseDouble( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Double::compareTo( const Double& d ) const {
+    return Double::compare( this->value, d.value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Double::compareTo( const double& d ) const {
+    return Double::compare( this->value, d );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Double::toString() const {
+    return Double::toString( this->value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Double::isInfinite() const {
+    return Double::isInfinite( this->value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Double::isNaN() const {
+    return Double::isNaN( this->value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Double::compare( double d1, double d2 ) {
+
+    long long l1, l2 = 0;
+    long long NaNbits = Double::doubleToLongBits( Double::NaN );
+
+    if( ( l1 = Double::doubleToLongBits( d1 ) ) == NaNbits ) {
+        if( Double::doubleToLongBits( d2 ) == NaNbits ) {
+            return 0;
+        }
+        return 1;
+    }
+
+    if( ( l2 = Double::doubleToLongBits( d2 ) ) == NaNbits ) {
+        return -1;
+    }
+
+    if( d1 == d2 ) {
+        if( l1 == l2 ) {
+            return 0;
+        }
+
+        // check for -0
+        return l1 > l2 ? 1 : -1;
+    }
+
+    return d1 > d2 ? 1 : -1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Double::doubleToLongBits( double value ) {
+
+    long long longValue = 0;
+    memcpy( &longValue, &value, sizeof( double ) );
+
+    if( ( longValue & DOUBLE_EXPONENT_MASK ) == DOUBLE_EXPONENT_MASK ) {
+        if( longValue & DOUBLE_MANTISSA_MASK ) {
+            return DOUBLE_NAN_BITS;
+        }
+    }
+
+    return longValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Double::doubleToRawLongBits( double value ) {
+
+    long long longValue = 0;
+    memcpy( &longValue, &value, sizeof( double ) );
+    return longValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Double::isInfinite( double value ) {
+    return ( value == POSITIVE_INFINITY ) || ( value == NEGATIVE_INFINITY );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Double::isNaN( double value ) {
+    return value != value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Double::longBitsToDouble( long long bits ) {
+    double result = 0;
+    memcpy( &result, &bits, sizeof( long long ) );
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Double::parseDouble( DECAF_UNUSED const std::string value )
+    throw ( exceptions::NumberFormatException ) {
+
+    return 0; // TODO
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Double::toHexString( double value ) {
+    /*
+     * Reference: http://en.wikipedia.org/wiki/IEEE_754
+     */
+    if( value != value ) {
+        return "NaN";
+    }
+    if( value == POSITIVE_INFINITY ) {
+        return "Infinity";
+    }
+    if( value == NEGATIVE_INFINITY ) {
+        return "-Infinity";
+    }
+
+    unsigned long long bitValue = Double::doubleToLongBits( value );
+
+    bool negative = ( bitValue & 0x8000000000000000LL ) != 0;
+    // mask exponent bits and shift down
+    unsigned long long exponent = ( bitValue & 0x7FF0000000000000LL ) >> 52;
+    // mask significand bits and shift up
+    unsigned long long significand = bitValue & 0x000FFFFFFFFFFFFFLL;
+
+    if( exponent == 0 && significand == 0 ) {
+        return ( negative ? "-0x0.0p0" : "0x0.0p0" );
+    }
+
+    // Start with sign and hex indicator
+    std::string hexString( negative ? "-0x" : "0x" );
+
+    if( exponent == 0 ) {
+        // denormal (subnormal) value
+        hexString.append("0.");
+        // significand is 52-bits, so there can be 13 hex digits
+        unsigned int fractionDigits = 13;
+        // remove trailing hex zeros, so Integer.toHexString() won't print
+        // them
+        while( ( significand != 0 ) && ( ( significand & 0xF ) == 0 ) ) {
+            significand >>= 4;
+            fractionDigits--;
+        }
+        // this assumes Integer.toHexString() returns lowercase characters
+        std::string hexSignificand = Long::toHexString( significand );
+
+        // if there are digits left, then insert some '0' chars first
+        if( significand != 0 && fractionDigits > hexSignificand.length() ) {
+            int digitDiff = fractionDigits - hexSignificand.length();
+            while( digitDiff-- != 0 ) {
+                hexString.append( "0" );
+            }
+        }
+
+        hexString.append( hexSignificand );
+        hexString.append( "p-1022" );
+    } else {
+        // normal value
+        hexString.append( "1." );
+        // significand is 52-bits, so there can be 13 hex digits
+        unsigned int fractionDigits = 13;
+        // remove trailing hex zeros, so Integer.toHexString() won't print
+        // them
+        while( (significand != 0 ) && ( ( significand & 0xF ) == 0 ) ) {
+            significand >>= 4;
+            fractionDigits--;
+        }
+        // this assumes Integer.toHexString() returns lowercase characters
+        std::string hexSignificand = Long::toHexString( significand );
+
+        // if there are digits left, then insert some '0' chars first
+        if( significand != 0 && fractionDigits > hexSignificand.length() ) {
+            int digitDiff = fractionDigits - hexSignificand.length();
+            while( digitDiff-- != 0 ) {
+                hexString.append( "0" );
+            }
+        }
+
+        hexString.append( hexSignificand );
+        hexString.append( "p" );
+        // remove exponent's 'bias' and convert to a string
+        hexString.append( Long::toString( exponent - 1023 ) );
+    }
+
+    return hexString;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Double::toString( DECAF_UNUSED double value ) {
+    return ""; //TODO
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Double Double::valueOf( double value ) {
+    return Double( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Double Double::valueOf( const std::string& value )
+    throw ( exceptions::NumberFormatException ) {
+
+    return valueOf( parseDouble( value ) );
+}

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Double.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Double.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Double.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Double.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,412 @@
+/*
+ * 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.
+ */
+
+#ifndef _DECAF_LANG_DOUBLE_H_
+#define _DECAF_LANG_DOUBLE_H_
+
+#include <decaf/util/Config.h>
+#include <decaf/lang/Comparable.h>
+#include <decaf/lang/Number.h>
+#include <decaf/lang/exceptions/NumberFormatException.h>
+#include <string>
+
+namespace decaf{
+namespace lang{
+
+    class DECAF_API Double : public Number,
+                             public Comparable<Double>,
+                             public Comparable<double> {
+    private:
+
+        double value;
+
+    public:
+
+        /** The size in bits of the primitive int type */
+        static const int SIZE = 64;
+
+        /** The maximum value that the primitive type can hold */
+        static const double MAX_VALUE;
+
+        /** The minimum value that the primitive type can hold */
+        static const double MIN_VALUE;
+
+        /** Constant for the Not a Number Value */
+        static const double NaN;
+
+        /** Constant for Positive Infinity */
+        static const double POSITIVE_INFINITY;
+
+        /** Constant for Negative Infinitiy */
+        static const double NEGATIVE_INFINITY;
+
+    public:
+
+        /**
+         * @param value - the primitve type to wrap
+         */
+        Double( double value );
+
+        /**
+         * @param value - the string to convert to a primitve type to wrap
+         */
+        Double( const std::string& value ) throw( exceptions::NumberFormatException );
+
+        virtual ~Double() {}
+
+        /**
+         * Compares this Double instance with another.
+         * @param d - the Double instance to be compared
+         * @return zero if this object represents the same integer value as the
+         * argument; a positive value if this object represents a value greater
+         * than the passed in value, and -1 if this object repesents a value
+         * less than the passed in value.
+         */
+        virtual int compareTo( const Double& d ) const;
+
+        /**
+         * @param d - the Double object to compare against.
+         * @returns true if the two Double Objects have the same value.
+         */
+        bool equals( const Double& d ) const {
+            return this->value == d.value;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param d - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const Double& d ) const {
+            return this->value == d.value;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param d - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const Double& d ) const {
+            return this->value < d.value;
+        }
+
+        /**
+         * Compares this Double instance with another.
+         * @param d - the Double instance to be compared
+         * @return zero if this object represents the same integer value as the
+         * argument; a positive value if this object represents a value greater
+         * than the passed in value, and -1 if this object repesents a value
+         * less than the passed in value.
+         */
+        virtual int compareTo( const double& d ) const;
+
+        /**
+         * @param d - the Double object to compare against.
+         * @returns true if the two Double Objects have the same value.
+         */
+        bool equals( const double& d ) const {
+            return this->value == d;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param d - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const double& d ) const {
+            return this->value == d;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param d - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const double& d ) const {
+            return this->value < d;
+        }
+
+        /**
+         * @returns this Double Object as a String Representation
+         */
+        std::string toString() const;
+
+        /**
+         * Answers the double value which the receiver represents
+         * @return double the value of the receiver.
+         */
+        virtual double doubleValue() const {
+            return this->value;
+        }
+
+        /**
+         * Answers the float value which the receiver represents
+         * @return float the value of the receiver.
+         */
+        virtual float floatValue() const {
+            return (float)this->value;
+        }
+
+        /**
+         * Answers the byte value which the receiver represents
+         * @return byte the value of the receiver.
+         */
+        virtual unsigned char byteValue() const {
+            return (unsigned char)this->value;
+        }
+
+        /**
+         * Answers the short value which the receiver represents
+         * @return short the value of the receiver.
+         */
+        virtual short shortValue() const {
+            return (short)this->value;
+        }
+
+        /**
+         * Answers the int value which the receiver represents
+         * @return int the value of the receiver.
+         */
+        virtual int intValue() const {
+            return (int)this->value;
+        }
+
+        /**
+         * Answers the long value which the receiver represents
+         * @return long the value of the receiver.
+         */
+        virtual long long longValue() const {
+            return (long long)this->value;
+        }
+
+        /**
+         * @returns true if the double is equal to positive infinity.
+         */
+        bool isInfinite() const;
+
+        /**
+         * @returns true if the double is equal to NaN.
+         */
+        bool isNaN() const;
+
+    public:  // Statics
+
+        /**
+         * Compares the two specified double values. The sign of the integer value
+         * returned is the same as that of the integer that would be returned by the
+         * call:
+         *        new Double(d1).compareTo(new Double(d2))
+         * @param d1 - the first double to compare
+         * @param d2 - the second double to compare
+         * @returns the value 0 if d1 is numerically equal to d2; a value less than
+         * 0 if d1 is numerically less than d2; and a value greater than 0  if d1 is
+         * numerically greater than d2.
+         */
+        static int compare( double d1, double d2 );
+
+        /**
+         * Returns a representation of the specified floating-point value according
+         * to the IEEE 754 floating-point "double format" bit layout.
+         *
+         * Bit 63 (the bit that is selected by the mask 0x8000000000000000L)
+         * represents the sign of the floating-point number. Bits 62-52 (the bits
+         * that are selected by the mask 0x7ff0000000000000L) represent the exponent.
+         * Bits 51-0 (the bits that are selected by the mask 0x000fffffffffffffL)
+         * represent the significand (sometimes called the mantissa) of the
+         * floating-point number.
+         *
+         * If the argument is positive infinity, the result is 0x7ff0000000000000L.
+         * If the argument is negative infinity, the result is 0xfff0000000000000L.
+         * If the argument is NaN, the result is 0x7ff8000000000000L.
+         *
+         * In all cases, the result is a long integer that, when given to the
+         * longBitsToDouble(long) method, will produce a floating-point value the
+         * same as the argument to doubleToLongBits (except all NaN values are
+         * collapsed to a single "canonical" NaN value).
+         * @param value - double to be converted
+         * @returns the long long bits that make up the double
+         */
+        static long long doubleToLongBits( double value );
+
+        /**
+         * Returns a representation of the specified floating-point value according
+         * to the IEEE 754 floating-point "double format" bit layout, preserving
+         * Not-a-Number (NaN) values.
+         *
+         * Bit 63 (the bit that is selected by the mask 0x8000000000000000LL)
+         * represents the sign of the floating-point number. Bits 62-52 (the bits
+         * that are selected by the mask 0x7ff0000000000000L) represent the exponent.
+         * Bits 51-0 (the bits that are selected by the mask 0x000fffffffffffffL)
+         * represent the significand (sometimes called the mantissa) of the
+         * floating-point number.
+         *
+         * If the argument is positive infinity, the result is 0x7ff0000000000000LL.
+         * If the argument is negative infinity, the result is 0xfff0000000000000LL.
+         * If the argument is NaN, the result is the long integer representing the
+         * actual NaN value. Unlike the doubleToLongBits method, doubleToRawLongBits
+         * does not collapse all the bit patterns encoding a NaN to a single
+         * "canonical" NaN value.
+         *
+         * In all cases, the result is a long integer that, when given to the
+         * longBitsToDouble(long) method, will produce a floating-point value the
+         * same as the argument to doubleToRawLongBits.
+         * @param value - double to be converted
+         * @returns the long long bits that make up the double
+         */
+        static long long doubleToRawLongBits( double value );
+
+        /**
+         * @param value - The double to check.
+         * @returns true if the double is equal to infinity.
+         */
+        static bool isInfinite( double value );
+
+        /**
+         * @param value - The double to check.
+         * @returns true if the double is equal to NaN.
+         */
+        static bool isNaN( double value );
+
+        /**
+         * Returns the double value corresponding to a given bit representation.
+         * The argument is considered to be a representation of a floating-point
+         * value according to the IEEE 754 floating-point "double format" bit layout.
+         *
+         * If the argument is 0x7ff0000000000000L, the result is positive infinity.
+         * If the argument is 0xfff0000000000000L, the result is negative infinity.
+         * If the argument is any value in the range 0x7ff0000000000001L through
+         * 0x7fffffffffffffffL or in the range 0xfff0000000000001L through
+         * 0xffffffffffffffffL, the result is a NaN. No IEEE 754 floating-point
+         * operation provided by C++ can distinguish between two NaN values of the
+         * same type with different bit patterns. Distinct values of NaN are only
+         * distinguishable by use of the Double.doubleToRawLongBits method.
+         * @param bits - the long long bits to convert to double
+         * @return the double converted from the bits
+         */
+        static double longBitsToDouble( long long bits );
+
+        /**
+         * Returns a new double initialized to the value represented by the
+         * specified string, as performed by the valueOf method of class Double.
+         * @param value - The string to parse to an double
+         * @returns a double parsed from the passed string
+         * @throws NumberFormatException
+         */
+        static double parseDouble( const std::string value )
+            throw ( exceptions::NumberFormatException );
+
+        /**
+         * Returns a hexadecimal string representation of the double argument. All
+         * characters mentioned below are ASCII characters.
+         *
+         *  * If the argument is NaN, the result is the string "NaN".
+         *  * Otherwise, the result is a string that represents the sign and magnitude
+         *    (absolute value) of the argument. If the sign is negative, the first
+         *    character of the result is '-'; if the sign is positive, no sign
+         *    character appears in the result. As for the magnitude m:
+         *      o If m is infinity, it is represented by the string "Infinity"; thus,
+         *        positive infinity produces the result "Infinity" and negative
+         *        infinity produces the result "-Infinity".
+         *      o If m is zero, it is represented by the string "0x0.0p0"; thus,
+         *        negative zero produces the result "-0x0.0p0" and positive zero
+         *        produces the result "0x0.0p0".
+         *      o If m is a double value with a normalized representation, substrings
+         *        are used to represent the significand and exponent fields. The
+         *        significand is represented by the characters "0x1." followed by a
+         *        lowercase hexadecimal representation of the rest of the
+         *        significand as a fraction. Trailing zeros in the hexadecimal
+         *        representation are removed unless all the digits are zero, in which
+         *        case a single zero is used. Next, the exponent is represented by
+         *        "p" followed by a decimal string of the unbiased exponent as if
+         *        produced by a call to Integer.toString on the exponent value.
+         *      o If m is a double value with a subnormal representation, the
+         *        significand is represented by the characters "0x0." followed by a
+         *        hexadecimal representation of the rest of the significand as a
+         *        fraction. Trailing zeros in the hexadecimal representation are
+         *        removed. Next, the exponent is represented by "p-126". Note that
+         *        there must be at least one nonzero digit in a subnormal significand.
+         *
+         * @param value - The double to convert to a string
+         * @returns the Hex formatted double string.
+         */
+        static std::string toHexString( double value );
+
+        /**
+         * Returns a string representation of the double argument. All characters
+         * mentioned below are ASCII characters.
+         *
+         * If the argument is NaN, the result is the string "NaN".
+         * Otherwise, the result is a string that represents the sign and magnitude
+         * (absolute value) of the argument. If the sign is negative, the first
+         * character of the result is '-'; if the sign is positive, no
+         * sign character appears in the result. As for the magnitude m:
+         *  o If m is infinity, it is represented by the characters "Infinity"; thus,
+         *    positive infinity produces the result "Infinity" and negative infinity
+         *    produces the result "-Infinity".
+         *  o If m is zero, it is represented by the characters "0.0"; thus, negative
+         *    zero produces the result "-0.0" and positive zero produces the result
+         *    "0.0".
+         *  o If m is greater than or equal to 10-3 but less than 107, then it is
+         *    represented as the integer part of m, in decimal form with no leading
+         *    zeroes, followed by '.', followed by one or more decimal digits
+         *    representing the fractional part of m.
+         *  o If m is less than 10-3 or greater than or equal to 107, then it is
+         *    represented in so-called "computerized scientific notation." Let n be
+         *    the unique integer such that 10n <= m < 10n+1; then let a be the
+         *    mathematically exact quotient of m and 10n so that 1 <= a < 10.
+         *    The magnitude is then represented as the integer part of a, as a
+         *    single decimal digit, followed by '.', followed by decimal digits
+         *    representing the fractional part of a, followed by the letter 'E',
+         *    followed by a representation of n as a decimal integer, as produced
+         *    by the method Integer.toString(int).
+         * @param value - The double to convert to a string
+         * @returns the formatted double string.
+         */
+        static std::string toString( double value );
+
+        /**
+         * Returns a Double instance representing the specified double value.
+         * @param value - double to wrap
+         * @returns new Double instance wrapping the primitive value
+         */
+        static Double valueOf( double value );
+
+        /**
+         * Returns a Double instance that wraps a primtive double which is parsed
+         * from the string value passed.
+         * @param value - the string to parse
+         * @returns a new Double instance wrapping the double parsed from value
+         * @throws NumberFormatException on error.
+         */
+        static Double valueOf( const std::string& value )
+            throw ( exceptions::NumberFormatException );
+
+    private:
+
+        static const long long DOUBLE_SIGN_MASK = 0x8000000000000000LL;
+        static const long long DOUBLE_EXPONENT_MASK = 0x7FF0000000000000LL;
+        static const long long DOUBLE_MANTISSA_MASK = 0x000FFFFFFFFFFFFFLL;
+        static const long long DOUBLE_NAN_BITS =
+            DOUBLE_EXPONENT_MASK | 0x0008000000000000LL;
+
+    };
+
+}}
+
+#endif /*_DECAF_LANG_DOUBLE_H_*/



Mime
View raw message