Java Doc for Buffer.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 Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.nio.Buffer

All known Subclasses:   java.nio.LongBuffer,  java.nio.FloatBuffer,  java.nio.IntBuffer,  java.nio.CharBuffer,  java.nio.DoubleBuffer,  java.nio.ByteBuffer,  java.nio.ShortBuffer,
Buffer
abstract public class Buffer (Code)
A buffer is a list of elements of a specific primitive type.

A buffer can be described by following properties:

  • Capacity, is the number of elements a buffer can hold. Capacity is no less than zero and never changes.
  • Position, is a cursor of this buffer. Elements are read or write at the position if you do not specify an index explicitly. Position is no less than zero and no greater than the limit.
  • Limit controls the scope of accessible elements. You can only read or write elements from index zero to limit - 1. Accessing elements out of the scope will cause exception. Limit is no less than zero and no greater than capacity.
  • Mark, is used to remember the current position, so that you can reset the position later. Mark is no less than zero and no greater than position.
  • A buffer can be readonly or read-write. Trying to modify the elements of a readonly buffer will cause ReadOnlyBufferException, while changing the position, limit and mark of a readonly buffer is OK.
  • A buffer can be direct or indirect. A direct buffer will try its best to take advantage of native memory APIs and it may not stay in java heap, thus not affected by GC.

Buffers are not thread-safe. If concurrent access to a buffer instance is required, then the callers are responsible to take care of the synchronization issues.



Field Summary
final static  intUNSET_MARK
     UNSET_MARK means the mark has not been set.
final  intcapacity
     The capacity of this buffer, which never change.
 intlimit
     limit - 1 is the last element that can be read or write.
 intmark
     Mark is the position will be set when reset() is called. Mark is not set by default.
 intposition
     The current position of this buffer.

Constructor Summary
 Buffer(int capacity)
     Construct a buffer with the specified capacity.

Method Summary
final public  intcapacity()
     Returns the capacity of this buffer.
final public  Bufferclear()
     Clears this buffer.
final public  Bufferflip()
     Flips this buffer.
final public  booleanhasRemaining()
     Returns true if there are remaining element(s) in this buffer.
abstract public  booleanisReadOnly()
     Returns whether this buffer is readonly or not.
final public  intlimit()
     Returns the limit of this buffer.
final public  Bufferlimit(int newLimit)
     Sets the limit of this buffer.

If the current position in the buffer is in excess of newLimit then, on returning from this call, it will have been adjusted to be equivalent to newLimit.

final public  Buffermark()
     Mark the current position, so that the position may return to this point later by calling reset().
final public  intposition()
     Returns the position of this buffer.
final public  Bufferposition(int newPosition)
     Sets the position of this buffer.
final public  intremaining()
     Returns the number of remaining elements in this buffer.
final public  Bufferreset()
     Reset the position of this buffer to the mark.
final public  Bufferrewind()
     Rewinds this buffer.

Field Detail
UNSET_MARK
final static int UNSET_MARK(Code)
UNSET_MARK means the mark has not been set.



capacity
final int capacity(Code)
The capacity of this buffer, which never change.



limit
int limit(Code)
limit - 1 is the last element that can be read or write. Limit must be no less than zero and no greater than capacity.



mark
int mark(Code)
Mark is the position will be set when reset() is called. Mark is not set by default. Mark is always no less than zero and no greater than position.



position
int position(Code)
The current position of this buffer. Position is always no less than zero and no greater than limit.




Constructor Detail
Buffer
Buffer(int capacity)(Code)
Construct a buffer with the specified capacity.
Parameters:
  capacity - The capacity of this buffer




Method Detail
capacity
final public int capacity()(Code)
Returns the capacity of this buffer. The number of elements that are contained in this buffer.



clear
final public Buffer clear()(Code)
Clears this buffer.

While the content of this buffer is not changed the following internal changes take place : the current position is reset back to the start of the buffer, the value of the buffer limit is made equal to the capacity and mark is unset.

This buffer



flip
final public Buffer flip()(Code)
Flips this buffer.

The limit is set to the current position, then the position is set to zero, and the mark is cleared.

The content of this buffer is not changed.

This buffer



hasRemaining
final public boolean hasRemaining()(Code)
Returns true if there are remaining element(s) in this buffer.

Or more precisely, returns position < limit.

True if there are remaining element(s) in this buffer.



isReadOnly
abstract public boolean isReadOnly()(Code)
Returns whether this buffer is readonly or not. Whether this buffer is readonly or not.



limit
final public int limit()(Code)
Returns the limit of this buffer. The limit of this buffer.



limit
final public Buffer limit(int newLimit)(Code)
Sets the limit of this buffer.

If the current position in the buffer is in excess of newLimit then, on returning from this call, it will have been adjusted to be equivalent to newLimit. If the mark is set and is greater than the new limit, then it is cleared.


Parameters:
  newLimit - The new limit, must be no less than zero and no greater thancapacity This buffer
exception:
  IllegalArgumentException - If newLimit is invalid.



mark
final public Buffer mark()(Code)
Mark the current position, so that the position may return to this point later by calling reset(). This buffer



position
final public int position()(Code)
Returns the position of this buffer. The value of this buffer's current position.



position
final public Buffer position(int newPosition)(Code)
Sets the position of this buffer.

If the mark is set and is greater than the new position, then it is cleared.


Parameters:
  newPosition - The new position, must be no less than zero and no greaterthan limit This buffer
exception:
  IllegalArgumentException - If newPosition is invalid



remaining
final public int remaining()(Code)
Returns the number of remaining elements in this buffer.

Or more precisely, returns limit - position.

The number of remaining elements in this buffer.



reset
final public Buffer reset()(Code)
Reset the position of this buffer to the mark. This buffer
exception:
  InvalidMarkException - If the mark is not set



rewind
final public Buffer rewind()(Code)
Rewinds this buffer.

The position is set to zero, and the mark is cleared.

The content of this buffer is not changed.

This buffer



Methods inherited from java.lang.Object
protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object object)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final public Class<? extends Object> getClass()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
final public void notify()(Code)(Java Doc)
final public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final public void wait(long millis, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait(long millis) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.