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_LONGARRAYBUFFER_H_ 00019 #define _DECAF_INTERNAL_NIO_LONGARRAYBUFFER_H_ 00020 00021 #include <decaf/nio/LongBuffer.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 LongArrayBuffer : public decaf::nio::LongBuffer { 00038 private: 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 LongArrayBuffer( int size, bool readOnly = false ); 00067 00086 LongArrayBuffer( long long* array, int size, int offset, int length, bool readOnly = false ); 00087 00105 LongArrayBuffer( const decaf::lang::Pointer<ByteArrayAdapter>& array, int offset, int length, 00106 bool readOnly = false ); 00107 00116 LongArrayBuffer( const LongArrayBuffer& other ); 00117 00118 virtual ~LongArrayBuffer(); 00119 00120 public: 00121 00125 virtual long long* array(); 00126 00130 virtual int arrayOffset(); 00131 00135 virtual LongBuffer* asReadOnlyBuffer() const; 00136 00140 virtual LongBuffer& compact(); 00141 00145 virtual LongBuffer* duplicate(); 00146 00150 virtual long long get(); 00151 00155 virtual long long 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 LongBuffer& put( long long value ); 00173 00177 virtual LongBuffer& put( int index, long long value ); 00178 00182 virtual LongBuffer* slice() const; 00183 00184 protected: 00185 00192 virtual void setReadOnly( bool value ) { 00193 this->readOnly = value; 00194 } 00195 00196 }; 00197 00198 }}} 00199 00200 #endif /*_DECAF_INTERNAL_NIO_LONGARRAYBUFFER_H_*/
1.6.1