Java Doc for RewindableInputStream.java in  » GIS » GeoServer » org » geoserver » ows » 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 » GIS » GeoServer » org.geoserver.ows.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.io.InputStream
      org.geoserver.ows.util.RewindableInputStream

RewindableInputStream
public class RewindableInputStream extends InputStream (Code)


Field Summary
final public static  intDEFAULT_XMLDECL_BUFFER_SIZE
    
protected  byte[]fData
     Internal buffer of bytes already read from source input stream.
protected  intfEndOffset
     Position where the end of underlying stream was encountered.
protected  InputStreamfInputStream
     Source input stream we are wrapping with rewindable one.
protected  intfLength
     Number of read bytes currently stored in fData buffer.
protected  intfMark
     Offset of the "marked" position in the stream relative to its beginning.
protected  booleanfMayReadChunks
    
protected  intfOffset
    
protected  intfStartOffset
     Position in the stream that to which stream pointer can be reset with rewind method invocation.

Constructor Summary
public  RewindableInputStream(InputStream is)
     Creates new RewindableInputStream object with internal buffer of default size and default value of chunked reading flag (which is _currently_ true).
public  RewindableInputStream(InputStream is, boolean chunkedMode)
     Creates new RewindableInputStream with internal buffer of specified size and no chunk reading beyound the buffer limits allowed.
public  RewindableInputStream(InputStream is, boolean chunkedMode, int initialSize)
     Primary constructor that allows to specify all parameters exlicitly affecting class work (initial size of the internal buffer and chunk read mode).
Parameters:
  is - InputStream that needs some reset/rewind functionality.
Parameters:
  chunkedMode - Initial value of fMayReadChunks flag which determineswhether multiple bytes can be read from the underlying stream insingle reading operation or not.

Method Summary
public  intavailable()
     Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
public  voidclose()
     Closes underlying byte stream.
public  voiddisableChunkedMode()
     More conscious alias for setChunkedMode(false).
public  voidenableChunkedMode()
     More conscious alias for setChunkedMode(true).
public  voidmark(int howMuch)
     Sets a mark to the current position in the stream.
public  booleanmarkSupported()
     Tells that this stream supports mark/reset capability.
public  intread()
     Reads next byte from this stream.
public  intread(byte[] b, int off, int len)
     Reads up to len bytes of data from the input stream into an array of bytes.
public  voidreset()
     Returns stream pointer to the position previously remembered using mark method (or to beginning of the stream, if there were no mark method calls).
public  voidrewind()
     Quickly reset stream pointer to the beginning of the stream or to position which offset was specified during the last setStartOffset call.
public  voidsetChunkedMode(boolean chunkedMode)
     Allows to change the behavior of the stream regarding chunked reading at runtime.
public  voidsetStartOffset(int offset)
     Sets the position somewhere in the stream to which the stream pointer will be reset after rewind invocation.
public  longskip(long n)
     Skips over and discards n bytes of data from this input stream.

Field Detail
DEFAULT_XMLDECL_BUFFER_SIZE
final public static int DEFAULT_XMLDECL_BUFFER_SIZE(Code)
Default buffer size before we've finished with the XMLDecl: I think the name should be left unchanged to give a hint for possible use of this class :)



fData
protected byte[] fData(Code)
Internal buffer of bytes already read from source input stream. Allows to access the same byte more than once.



fEndOffset
protected int fEndOffset(Code)
Position where the end of underlying stream was encountered. Potentially in RewindableInputStream instance stream's "end" could be reached more than once, so it is a good thing to know where original stream ended to avoid IOExceptions.



fInputStream
protected InputStream fInputStream(Code)
Source input stream we are wrapping with rewindable one.



fLength
protected int fLength(Code)
Number of read bytes currently stored in fData buffer. Size of the buffer itself can be greater than this value, obviously.



fMark
protected int fMark(Code)
Offset of the "marked" position in the stream relative to its beginning.



fMayReadChunks
protected boolean fMayReadChunks(Code)
Tells whether read(byte[], int, int) method is allowed to read multiple bytes beyond the internal buffer (true) or not (true is the default)



fOffset
protected int fOffset(Code)
Offset of the next byte to be read from the stream relative to the beginning of the stream (and fData array as well)



fStartOffset
protected int fStartOffset(Code)
Position in the stream that to which stream pointer can be reset with rewind method invocation.




Constructor Detail
RewindableInputStream
public RewindableInputStream(InputStream is)(Code)
Creates new RewindableInputStream object with internal buffer of default size and default value of chunked reading flag (which is _currently_ true).
Parameters:
  is - InputStream that needs basic reset/rewind functionality.



RewindableInputStream
public RewindableInputStream(InputStream is, boolean chunkedMode)(Code)
Creates new RewindableInputStream with internal buffer of specified size and no chunk reading beyound the buffer limits allowed.
Parameters:
  is - InputStream that needs some reset/rewind functionality.
Parameters:
  chunkedMode - See the RewindableInputStream(InputStream,boolean, int) constructor description.



RewindableInputStream
public RewindableInputStream(InputStream is, boolean chunkedMode, int initialSize)(Code)
Primary constructor that allows to specify all parameters exlicitly affecting class work (initial size of the internal buffer and chunk read mode).
Parameters:
  is - InputStream that needs some reset/rewind functionality.
Parameters:
  chunkedMode - Initial value of fMayReadChunks flag which determineswhether multiple bytes can be read from the underlying stream insingle reading operation or not. This value can be changed usingsetChunkedMode (or its aliases). For specificpurpose of inferring encoding/charset of XML document typicalusage policy is to disable chunked reads while obtaining XMLdeclaration and then enable it to speed up reading the rest ofdocument.
Parameters:
  initialSize - Initial size of the internal buffer array.




Method Detail
available
public int available() throws IOException(Code)
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. For RewindableInputStream this can be:
  • Number of unread bytes in the fData buffer, i.e. those between current position (fOffset) and total bytes quantity in the buffer (fLength).
  • Result of underlying InputStream's available call if there are no unread bytes in the buffer.
  • -1 if end of stream is reached.
the number of bytes that can be read from this input streamwithout blocking.
throws:
  IOException - when an I/O error occurs.



close
public void close() throws IOException(Code)
Closes underlying byte stream.
throws:
  IOException - if an I/O error occurs.



disableChunkedMode
public void disableChunkedMode()(Code)
More conscious alias for setChunkedMode(false). While last method is a general purpose mutator, code may look a bit more clear if you use specialized methods to enable/disable chunk read mode.



enableChunkedMode
public void enableChunkedMode()(Code)
More conscious alias for setChunkedMode(true). While last method is a general purpose mutator, code may look a bit more clear if you use specialized methods to enable/disable chunk read mode.



mark
public void mark(int howMuch)(Code)
Sets a mark to the current position in the stream.
Parameters:
  howMuch - Not used in this implementation I guess.



markSupported
public boolean markSupported()(Code)
Tells that this stream supports mark/reset capability. This one definitely supports it :) true if this stream instance supports the markand reset methods; false otherwise.



read
public int read() throws IOException(Code)
Reads next byte from this stream. This byte is either being read from underlying InputStream or taken from the internal buffer in case it was already read at some point before. Next byte of data or -1 if end of stream is reached.
throws:
  IOException - in case of any I/O errors.



read
public int read(byte[] b, int off, int len) throws IOException(Code)
Reads up to len bytes of data from the input stream into an array of bytes. In its current implementation it cannot return more bytes than left in the buffer if in "non-chunked" mode (fMayReadChunks == false). After reaching the end of the buffer, each invocation of this method will read exactly 1 byte then. In "chunked" mode this method may return more than 1 byte, but it doesn't buffer the result.

From the other hand, for the task of reading xml declaration, such behavior may be desirable, as we probably don't need reset/rewind functionality after we finished with charset deduction. It is good idea to call enableChunkedMode after that, in order to improve perfomance and lessen memoery consumption when reading the rest of the data. Total number of bytes actually read or -1 if endof stream has been reached.
throws:
  IOException - when an I/O error occurs while reading data
throws:
  IndexOutOfBoundsException - in case of invalid off,len and b.length combination




reset
public void reset()(Code)
Returns stream pointer to the position previously remembered using mark method (or to beginning of the stream, if there were no mark method calls).



rewind
public void rewind()(Code)
Quickly reset stream pointer to the beginning of the stream or to position which offset was specified during the last setStartOffset call.



setChunkedMode
public void setChunkedMode(boolean chunkedMode)(Code)
Allows to change the behavior of the stream regarding chunked reading at runtime. If you allowed chunked reading and then read some data from the stream, you better forget about resetting or rewinding it after that.
Parameters:
  chunkedMode - New value for fMayReadChunks.



setStartOffset
public void setStartOffset(int offset)(Code)
Sets the position somewhere in the stream to which the stream pointer will be reset after rewind invocation. By default this position is the beginning of the stream.
Parameters:
  offset - New value for "fStartOffset".



skip
public long skip(long n) throws IOException(Code)
Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.
Parameters:
  n - Number of bytes to be skipped. Number of bytes actually skipped.
throws:
  IOException - if an I/O error occurs.



Methods inherited from java.io.InputStream
public int available() throws IOException(Code)(Java Doc)
public void close() throws IOException(Code)(Java Doc)
public synchronized void mark(int readlimit)(Code)(Java Doc)
public boolean markSupported()(Code)(Java Doc)
abstract public int read() throws IOException(Code)(Java Doc)
public int read(byte b) throws IOException(Code)(Java Doc)
public int read(byte b, int off, int len) throws IOException(Code)(Java Doc)
public synchronized void reset() throws IOException(Code)(Java Doc)
public long skip(long n) throws IOException(Code)(Java Doc)

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.