Source Code Cross Referenced for MappedByteBufferAdapter.java in  » Apache-Harmony-Java-SE » java-package » java » nio » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.nio 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package java.nio;
019:
020:        import org.apache.harmony.luni.platform.PlatformAddress;
021:        import org.apache.harmony.nio.internal.DirectBuffer;
022:
023:        final class MappedByteBufferAdapter extends MappedByteBuffer implements 
024:                DirectBuffer {
025:
026:            private static final int CHAR_SIZE = 2;
027:
028:            private static final int SHORT_SIZE = 2;
029:
030:            private static final int INTEGER_SIZE = 4;
031:
032:            private static final int LONG_SIZE = 8;
033:
034:            private static final int FLOAT_SIZE = 4;
035:
036:            private static final int DOUBLE_SIZE = 8;
037:
038:            public MappedByteBufferAdapter(ByteBuffer buffer) {
039:                super (buffer);
040:            }
041:
042:            public MappedByteBufferAdapter(PlatformAddress addr, int capa,
043:                    int offset, int mode) {
044:                super (addr, capa, offset, mode);
045:            }
046:
047:            @Override
048:            public CharBuffer asCharBuffer() {
049:                return this .wrapped.asCharBuffer();
050:            }
051:
052:            @Override
053:            public DoubleBuffer asDoubleBuffer() {
054:                return this .wrapped.asDoubleBuffer();
055:            }
056:
057:            @Override
058:            public FloatBuffer asFloatBuffer() {
059:                return this .wrapped.asFloatBuffer();
060:            }
061:
062:            @Override
063:            public IntBuffer asIntBuffer() {
064:                return this .wrapped.asIntBuffer();
065:            }
066:
067:            @Override
068:            public LongBuffer asLongBuffer() {
069:                return this .wrapped.asLongBuffer();
070:            }
071:
072:            @Override
073:            public ByteBuffer asReadOnlyBuffer() {
074:                MappedByteBufferAdapter buf = new MappedByteBufferAdapter(
075:                        this .wrapped.asReadOnlyBuffer());
076:                buf.limit = this .limit;
077:                buf.position = this .position;
078:                buf.mark = this .mark;
079:                return buf;
080:            }
081:
082:            @Override
083:            public ShortBuffer asShortBuffer() {
084:                return this .wrapped.asShortBuffer();
085:            }
086:
087:            @Override
088:            public ByteBuffer compact() {
089:                if (this .wrapped.isReadOnly()) {
090:                    throw new ReadOnlyBufferException();
091:                }
092:                this .wrapped.limit(this .limit);
093:                this .wrapped.position(this .position);
094:                this .wrapped.compact();
095:                this .wrapped.clear();
096:                this .position = this .limit - this .position;
097:                this .limit = this .capacity;
098:                this .mark = UNSET_MARK;
099:                return this ;
100:            }
101:
102:            @Override
103:            public ByteBuffer duplicate() {
104:                MappedByteBufferAdapter buf = new MappedByteBufferAdapter(
105:                        this .wrapped.duplicate());
106:                buf.limit = this .limit;
107:                buf.position = this .position;
108:                buf.mark = this .mark;
109:                return buf;
110:            }
111:
112:            @Override
113:            public byte get() {
114:                byte result = this .wrapped.get();
115:                this .position++;
116:                return result;
117:            }
118:
119:            @Override
120:            public byte get(int index) {
121:                return this .wrapped.get(index);
122:            }
123:
124:            @Override
125:            public char getChar() {
126:                char result = this .wrapped.getChar();
127:                this .position += CHAR_SIZE;
128:                return result;
129:            }
130:
131:            @Override
132:            public char getChar(int index) {
133:                return this .wrapped.getChar(index);
134:            }
135:
136:            @Override
137:            public double getDouble() {
138:                double result = this .wrapped.getDouble();
139:                this .position += DOUBLE_SIZE;
140:                return result;
141:            }
142:
143:            @Override
144:            public double getDouble(int index) {
145:                return this .wrapped.getDouble(index);
146:            }
147:
148:            public PlatformAddress getEffectiveAddress() {
149:                return ((DirectBuffer) this .wrapped).getEffectiveAddress();
150:            }
151:
152:            @Override
153:            public float getFloat() {
154:                float result = this .wrapped.getFloat();
155:                this .position += FLOAT_SIZE;
156:                return result;
157:            }
158:
159:            @Override
160:            public float getFloat(int index) {
161:                return this .wrapped.getFloat(index);
162:            }
163:
164:            @Override
165:            public int getInt() {
166:                int result = this .wrapped.getInt();
167:                this .position += INTEGER_SIZE;
168:                return result;
169:            }
170:
171:            @Override
172:            public int getInt(int index) {
173:                return this .wrapped.getInt(index);
174:            }
175:
176:            @Override
177:            public long getLong() {
178:                long result = this .wrapped.getLong();
179:                this .position += LONG_SIZE;
180:                return result;
181:            }
182:
183:            @Override
184:            public long getLong(int index) {
185:                return this .wrapped.getLong(index);
186:            }
187:
188:            @Override
189:            public short getShort() {
190:                short result = this .wrapped.getShort();
191:                this .position += SHORT_SIZE;
192:                return result;
193:            }
194:
195:            @Override
196:            public short getShort(int index) {
197:                return this .wrapped.getShort(index);
198:            }
199:
200:            @Override
201:            public boolean isDirect() {
202:                return true;
203:            }
204:
205:            @Override
206:            public boolean isReadOnly() {
207:                return this .wrapped.isReadOnly();
208:            }
209:
210:            @Override
211:            ByteBuffer orderImpl(ByteOrder byteOrder) {
212:                super .orderImpl(byteOrder);
213:                return this .wrapped.order(byteOrder);
214:            }
215:
216:            @Override
217:            public ByteBuffer put(byte b) {
218:                this .wrapped.put(b);
219:                this .position++;
220:                return this ;
221:            }
222:
223:            @Override
224:            public ByteBuffer put(byte[] src, int off, int len) {
225:                this .wrapped.position(this .position);
226:                this .wrapped.put(src, off, len);
227:                this .position += len;
228:                return this ;
229:            }
230:
231:            @Override
232:            public ByteBuffer put(int index, byte b) {
233:                this .wrapped.put(index, b);
234:                return this ;
235:            }
236:
237:            @Override
238:            public ByteBuffer putChar(char value) {
239:                this .wrapped.putChar(value);
240:                this .position += CHAR_SIZE;
241:                return this ;
242:            }
243:
244:            @Override
245:            public ByteBuffer putChar(int index, char value) {
246:                this .wrapped.putChar(index, value);
247:                return this ;
248:            }
249:
250:            @Override
251:            public ByteBuffer putDouble(double value) {
252:                this .wrapped.putDouble(value);
253:                this .position += DOUBLE_SIZE;
254:                return this ;
255:            }
256:
257:            @Override
258:            public ByteBuffer putDouble(int index, double value) {
259:                this .wrapped.putDouble(index, value);
260:                return this ;
261:            }
262:
263:            @Override
264:            public ByteBuffer putFloat(float value) {
265:                this .wrapped.putFloat(value);
266:                this .position += FLOAT_SIZE;
267:                return this ;
268:            }
269:
270:            @Override
271:            public ByteBuffer putFloat(int index, float value) {
272:                this .wrapped.putFloat(index, value);
273:                return this ;
274:            }
275:
276:            @Override
277:            public ByteBuffer putInt(int index, int value) {
278:                this .wrapped.putInt(index, value);
279:                return this ;
280:            }
281:
282:            @Override
283:            public ByteBuffer putInt(int value) {
284:                this .wrapped.putInt(value);
285:                this .position += INTEGER_SIZE;
286:                return this ;
287:            }
288:
289:            @Override
290:            public ByteBuffer putLong(int index, long value) {
291:                this .wrapped.putLong(index, value);
292:                return this ;
293:            }
294:
295:            @Override
296:            public ByteBuffer putLong(long value) {
297:                this .wrapped.putLong(value);
298:                this .position += LONG_SIZE;
299:                return this ;
300:            }
301:
302:            @Override
303:            public ByteBuffer putShort(int index, short value) {
304:                this .wrapped.putShort(index, value);
305:                return this ;
306:            }
307:
308:            @Override
309:            public ByteBuffer putShort(short value) {
310:                this .wrapped.putShort(value);
311:                this .position += SHORT_SIZE;
312:                return this ;
313:            }
314:
315:            @Override
316:            public ByteBuffer slice() {
317:                this .wrapped.limit(this .limit);
318:                this .wrapped.position(this .position);
319:                MappedByteBufferAdapter result = new MappedByteBufferAdapter(
320:                        this .wrapped.slice());
321:                this .wrapped.clear();
322:                return result;
323:            }
324:
325:            @Override
326:            byte[] protectedArray() {
327:                return this .wrapped.protectedArray();
328:            }
329:
330:            @Override
331:            int protectedArrayOffset() {
332:                return this .wrapped.protectedArrayOffset();
333:            }
334:
335:            @Override
336:            boolean protectedHasArray() {
337:                return this .wrapped.protectedHasArray();
338:            }
339:
340:            public PlatformAddress getBaseAddress() {
341:                return this .wrapped.getBaseAddress();
342:            }
343:
344:            public boolean isAddressValid() {
345:                return this .wrapped.isAddressValid();
346:            }
347:
348:            public void addressValidityCheck() {
349:                this .wrapped.addressValidityCheck();
350:            }
351:
352:            public void free() {
353:                this .wrapped.free();
354:            }
355:
356:            public int getByteCapacity() {
357:                return wrapped.getByteCapacity();
358:            }
359:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.