Source Code Cross Referenced for DirectByteBuffers.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) 


01:        /* Licensed to the Apache Software Foundation (ASF) under one or more
02:         * contributor license agreements.  See the NOTICE file distributed with
03:         * this work for additional information regarding copyright ownership.
04:         * The ASF licenses this file to You under the Apache License, Version 2.0
05:         * (the "License"); you may not use this file except in compliance with
06:         * the License.  You may obtain a copy of the License at
07:         * 
08:         *     http://www.apache.org/licenses/LICENSE-2.0
09:         * 
10:         * Unless required by applicable law or agreed to in writing, software
11:         * distributed under the License is distributed on an "AS IS" BASIS,
12:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13:         * See the License for the specific language governing permissions and
14:         * limitations under the License.
15:         */
16:
17:        package java.nio;
18:
19:        import org.apache.harmony.luni.platform.PlatformAddress;
20:
21:        /**
22:         * Helper class for operations on direct ByteBuffer
23:         * 
24:         * @see java.nio.ByteBuffer
25:         */
26:        class DirectByteBuffers {
27:
28:            /**
29:             * Explicitly frees the memory used by the given direct byte buffer.
30:             * <p>
31:             * If the memory is known to already have been freed then this is a no-op.
32:             * Once the memory has been freed then operations requiring access to the
33:             * memory will throw an <code>IllegalStateException</code>.
34:             * </p>
35:             * <p>
36:             * Note this is is possible that the memory is freed by code that reaches
37:             * into the address and explicitly frees it 'beneith' us -- this is bad
38:             * form.
39:             * </p>
40:             * 
41:             * @param directBuffer
42:             *            the direct byte buffer memory to free
43:             * @throws IllegalArgumentException
44:             *             if the buffer is <code>null</code> or is not a
45:             *             <em>direct</em> byte buffer.
46:             */
47:            public static void free(ByteBuffer directBuffer) {
48:                if ((directBuffer == null) || (!directBuffer.isDirect())) {
49:                    throw new IllegalArgumentException();
50:                }
51:                DirectByteBuffer buf = (DirectByteBuffer) directBuffer;
52:                buf.free();
53:            }
54:
55:            /**
56:             * Answers the platform address of the start of this buffer instance.
57:             * <em>You must not attempt to free the returned address!!</em> It may not
58:             * be an address that was explicitly malloc'ed (i.e. if this buffer is the
59:             * result of a split); and it may be memory shared by multiple buffers.
60:             * <p>
61:             * If you can guarantee that you want to free the underlying memory call the
62:             * #free() method on this instance -- generally applications will rely on
63:             * the garbage collector to autofree this memory.
64:             * </p>
65:             * 
66:             * @param directBuffer
67:             *            the direct byte buffer
68:             * @return the effective address of the start of the buffer.
69:             * @throws IllegalStateException
70:             *             if this buffer address is known to have been freed
71:             *             previously.
72:             */
73:            public static PlatformAddress getEffectiveAddress(
74:                    ByteBuffer directBuffer) {
75:                return toDirectBuffer(directBuffer).getEffectiveAddress();
76:            }
77:
78:            private static DirectByteBuffer toDirectBuffer(
79:                    ByteBuffer directBuffer) {
80:                if ((directBuffer == null) || (!directBuffer.isDirect())) {
81:                    throw new IllegalArgumentException();
82:                }
83:                return (DirectByteBuffer) directBuffer;
84:            }
85:
86:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.