|
activemq-cpp-3.3.0
|
00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _DECAF_INTERNAL_NIO_CHARARRAYBUFFER_H_ 00019 #define _DECAF_INTERNAL_NIO_CHARARRAYBUFFER_H_ 00020 00021 #include <decaf/nio/CharBuffer.h> 00022 #include <decaf/lang/exceptions/NullPointerException.h> 00023 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h> 00024 #include <decaf/nio/BufferUnderflowException.h> 00025 #include <decaf/nio/BufferOverflowException.h> 00026 #include <decaf/nio/ReadOnlyBufferException.h> 00027 #include <decaf/internal/util/ByteArrayAdapter.h> 00028 00029 #include <decaf/lang/Pointer.h> 00030 00031 namespace decaf{ 00032 namespace internal{ 00033 namespace nio{ 00034 00035 using decaf::internal::util::ByteArrayAdapter; 00036 00037 class DECAF_API CharArrayBuffer : public decaf::nio::CharBuffer { 00038 protected: 00039 00040 // The reference array object that backs this buffer. 00041 decaf::lang::Pointer<ByteArrayAdapter> _array; 00042 00043 // Offset into the array that we are to start from 00044 int offset; 00045 00046 // The length of the sub-array, or limit 00047 int length; 00048 00049 // Read / Write flag 00050 bool readOnly; 00051 00052 public: 00053 00066 CharArrayBuffer( int size, bool readOnly = false ); 00067 00086 CharArrayBuffer( char* array, int size, int offset, int length, bool readOnly = false ); 00087 00105 CharArrayBuffer( const decaf::lang::Pointer<ByteArrayAdapter>& array, 00106 int offset, int length, bool readOnly = false ); 00107 00116 CharArrayBuffer( const CharArrayBuffer& other ); 00117 00118 virtual ~CharArrayBuffer(); 00119 00120 public: // Overrides 00121 00125 virtual char* array(); 00126 00130 virtual int arrayOffset(); 00131 00135 virtual CharBuffer* asReadOnlyBuffer() const; 00136 00140 virtual CharBuffer& compact(); 00141 00145 virtual CharBuffer* duplicate(); 00146 00150 virtual char get(); 00151 00155 virtual char get( int index ) const; 00156 00160 virtual bool hasArray() const { return true; } 00161 00165 virtual bool isReadOnly() const { 00166 return this->readOnly; 00167 } 00168 00172 virtual CharBuffer& put( char value ); 00173 00177 virtual CharBuffer& put( int index, char value ); 00178 00182 virtual CharBuffer* slice() const; 00183 00187 virtual lang::CharSequence* subSequence( int start, int end ) const; 00188 00189 protected: 00190 00197 virtual void setReadOnly( bool value ) { 00198 this->readOnly = value; 00199 } 00200 00201 }; 00202 00203 }}} 00204 00205 #endif /*_DECAF_INTERNAL_NIO_CHARARRAYBUFFER_H_*/