Java Doc for ISRandomAccessIO.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » jj2000 » j2k » util » 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 » 6.0 JDK Modules » Java Advanced Imaging » jj2000.j2k.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   jj2000.j2k.util.ISRandomAccessIO

ISRandomAccessIO
public class ISRandomAccessIO implements RandomAccessIO(Code)
This class implements a wrapper to turn an InputStream into a RandomAccessIO. To provide random access the input data from the InputStream is cached in an in-memory buffer. The in-memory buffer size can be limited to a specified size. The data is read into the cache on a as needed basis, blocking only when necessary.

The cache grows automatically as necessary. However, if the data length is known prior to the creation of a ISRandomAccessIO object, it is best to specify that as the initial in-memory buffer size. That will minimize data copying and multiple allocation.

Multi-byte data is read in big-endian order. The in-memory buffer storage is released when 'close()' is called. This class can only be used for data input, not output. The wrapped InputStream is closed when all the input data is cached or when 'close()' is called.

If an out of memory condition is encountered when growing the in-memory buffer an IOException is thrown instead of an OutOfMemoryError. The exception message is "Out of memory to cache input data".

This class is intended for use as a "quick and dirty" way to give network connectivity to RandomAccessIO based classes. It is not intended as an efficient means of implementing network connectivity. Doing such requires reimplementing the RandomAccessIO based classes to directly use network connections.

This class does not use temporary files as buffers, because that would preclude the use in unsigned applets.




Constructor Summary
public  ISRandomAccessIO(InputStream is, int size, int inc, int maxsize)
     Creates a new RandomAccessIO wrapper for the given InputStream 'is'.
public  ISRandomAccessIO(InputStream is)
     Creates a new RandomAccessIO wrapper for the given InputStream 'is'.

Method Summary
public  voidclose()
     Closes this object for reading as well as the wrapped InputStream, if not already closed.
public  voidflush()
     Does nothing since this class does not implement data output.
public  intgetByteOrdering()
     Returns the endianess (i.e., byte ordering) of multi-byte I/O operations.
public  intgetPos()
     Returns the current position in the stream, which is the position from where the next byte of data would be read.
public  intlength()
     Returns the length of the stream.
public  intread()
     Reads a byte of data from the stream.
public  bytereadByte()
     Reads a signed byte (8 bit) from the input.
public  doublereadDouble()
     Reads an IEEE double precision (i.e., 64 bit) floating-point number from the input.
public  floatreadFloat()
     Reads an IEEE single precision (i.e., 32 bit) floating-point number from the input.
public  voidreadFully(byte b, int off, int n)
     Reads 'len' bytes of data from this file into an array of bytes.
public  intreadInt()
     Reads a signed int (32 bit) from the input.
public  longreadLong()
     Reads a signed long (64 bit) from the input.
public  shortreadShort()
     Reads a signed short (16 bit) from the input.
public  intreadUnsignedByte()
     Reads an unsigned byte (8 bit) from the input.
public  longreadUnsignedInt()
     Reads a unsigned int (32 bit) from the input.
public  intreadUnsignedShort()
     Reads an unsigned short (16 bit) from the input.
public  voidseek(int off)
     Moves the current position for the next read operation to offset.
public  intskipBytes(int n)
     Skips 'n' bytes from the input.
public  voidwrite(int b)
     Throws an IOException since this class does not implement data output.
public  voidwriteByte(int v)
     Throws an IOException since this class does not implement data output.
public  voidwriteDouble(double v)
     Throws an IOException since this class does not implement data output.
public  voidwriteFloat(float v)
     Throws an IOException since this class does not implement data output.
public  voidwriteInt(int v)
     Throws an IOException since this class does not implement data output.
public  voidwriteLong(long v)
     Throws an IOException since this class does not implement data output.
public  voidwriteShort(int v)
     Throws an IOException since this class does not implement data output.


Constructor Detail
ISRandomAccessIO
public ISRandomAccessIO(InputStream is, int size, int inc, int maxsize)(Code)
Creates a new RandomAccessIO wrapper for the given InputStream 'is'. The internal cache buffer will have size 'size' and will increment by 'inc' each time it is needed. The maximum buffer size is limited to 'maxsize'.
Parameters:
  is - The input from where to get the data.
Parameters:
  size - The initial size for the cache buffer, in bytes.
Parameters:
  inc - The size increment for the cache buffer, in bytes.
Parameters:
  maxsize - The maximum size for the cache buffer, in bytes.



ISRandomAccessIO
public ISRandomAccessIO(InputStream is)(Code)
Creates a new RandomAccessIO wrapper for the given InputStream 'is'. The internal cache buffer size and increment is to to 256 kB. The maximum buffer size is set to Integer.MAX_VALUE (2 GB).
Parameters:
  is - The input from where to get the data.




Method Detail
close
public void close() throws IOException(Code)
Closes this object for reading as well as the wrapped InputStream, if not already closed. The memory used by the cache is released.
exception:
  IOException - If an I/O error occurs while closing theunderlying InputStream.



flush
public void flush()(Code)
Does nothing since this class does not implement data output.



getByteOrdering
public int getByteOrdering()(Code)
Returns the endianess (i.e., byte ordering) of multi-byte I/O operations. Always EndianType.BIG_ENDIAN since this class implements only big-endian. Always EndianType.BIG_ENDIAN.
See Also:   EndianType



getPos
public int getPos() throws IOException(Code)
Returns the current position in the stream, which is the position from where the next byte of data would be read. The first byte in the stream is in position 0.
exception:
  IOException - If an I/O error occurred.



length
public int length() throws IOException(Code)
Returns the length of the stream. This will cause all the data to be read. This method will block until all the data is read, which can be lengthy across the network. The length of the stream, in bytes.
exception:
  IOException - If an I/O error ocurred.



read
public int read() throws IOException(Code)
Reads a byte of data from the stream. The byte read, as an int in the range [0-255].
exception:
  EOFException - If the end-of file was reached.
exception:
  IOException - If an I/O error ocurred.



readByte
public byte readByte() throws IOException(Code)
Reads a signed byte (8 bit) from the input. The next byte-aligned signed byte (8 bit) from theinput.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



readDouble
public double readDouble() throws IOException(Code)
Reads an IEEE double precision (i.e., 64 bit) floating-point number from the input. The next byte-aligned IEEE double (64 bit) from the input.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



readFloat
public float readFloat() throws IOException(Code)
Reads an IEEE single precision (i.e., 32 bit) floating-point number from the input. The next byte-aligned IEEE float (32 bit) from the input.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



readFully
public void readFully(byte b, int off, int n) throws IOException(Code)
Reads 'len' bytes of data from this file into an array of bytes. This method reads repeatedly from the stream until all the bytes are read. This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.
Parameters:
  b - The buffer into which the data is to be read. It must be longenough.
Parameters:
  off - The index in 'b' where to place the first byte read.
Parameters:
  len - The number of bytes to read.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



readInt
public int readInt() throws IOException(Code)
Reads a signed int (32 bit) from the input. The next byte-aligned signed int (32 bit) from theinput.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



readLong
public long readLong() throws IOException(Code)
Reads a signed long (64 bit) from the input. The next byte-aligned signed long (64 bit) from theinput.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



readShort
public short readShort() throws IOException(Code)
Reads a signed short (16 bit) from the input. The next byte-aligned signed short (16 bit) from theinput.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



readUnsignedByte
public int readUnsignedByte() throws IOException(Code)
Reads an unsigned byte (8 bit) from the input. The next byte-aligned unsigned byte (8 bit) from theinput.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



readUnsignedInt
public long readUnsignedInt() throws IOException(Code)
Reads a unsigned int (32 bit) from the input. The next byte-aligned unsigned int (32 bit) from theinput.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



readUnsignedShort
public int readUnsignedShort() throws IOException(Code)
Reads an unsigned short (16 bit) from the input. The next byte-aligned unsigned short (16 bit) from theinput.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



seek
public void seek(int off) throws IOException(Code)
Moves the current position for the next read operation to offset. The offset is measured from the beginning of the stream. If the offset is set beyond the currently cached data, the missing data will be read only when a read operation is performed. Setting the offset beyond the end of the data will cause an EOFException only if the data length is currently known, otherwise an IOException will occur when a read operation is attempted at that position.
Parameters:
  off - The offset where to move to.
exception:
  EOFException - If seeking beyond EOF and the data length isknown.
exception:
  IOException - If an I/O error ocurred.



skipBytes
public int skipBytes(int n) throws IOException(Code)
Skips 'n' bytes from the input.
Parameters:
  n - The number of bytes to skip Always n.
exception:
  EOFException - If the end-of file was reached beforeall the bytes could be skipped.
exception:
  IOException - If an I/O error ocurred.



write
public void write(int b) throws IOException(Code)
Throws an IOException since this class does not implement data output.



writeByte
public void writeByte(int v) throws IOException(Code)
Throws an IOException since this class does not implement data output.



writeDouble
public void writeDouble(double v) throws IOException(Code)
Throws an IOException since this class does not implement data output.



writeFloat
public void writeFloat(float v) throws IOException(Code)
Throws an IOException since this class does not implement data output.



writeInt
public void writeInt(int v) throws IOException(Code)
Throws an IOException since this class does not implement data output.



writeLong
public void writeLong(long v) throws IOException(Code)
Throws an IOException since this class does not implement data output.



writeShort
public void writeShort(int v) throws IOException(Code)
Throws an IOException since this class does not implement data output.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) 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.