Java Doc for RecordingOutputStream.java in  » Web-Crawler » heritrix » org » archive » io » 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 » Web Crawler » heritrix » org.archive.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.io.OutputStream
      org.archive.io.RecordingOutputStream

RecordingOutputStream
public class RecordingOutputStream extends OutputStream (Code)
An output stream that records all writes to wrapped output stream. A RecordingOutputStream can be wrapped around any other OutputStream to record all bytes written to it. You can then request a ReplayInputStream to read those bytes.

The RecordingOutputStream uses an in-memory buffer and backing disk file to allow it to record streams of arbitrary length limited only by available disk space.

As long as the stream recorded is smaller than the in-memory buffer, no disk access will occur.

Recorded content can be recovered as a ReplayInputStream (via getReplayInputStream() or, for only the content after the content-begin-mark is set, getContentReplayInputStream() ) or as a ReplayCharSequence (via getReplayCharSequence()).

This class is also used as a straight output stream by RecordingInputStream to which it records all reads. RecordingInputStream is exploiting the file backed buffer facility of this class passing null for the stream to wrap. TODO: Make a FileBackedOutputStream class that is subclassed by RecordingInputStream.
author:
   gojomo



Field Summary
final protected static  longMAX_HEADER_MATERIAL
     Maximum amount of header material to accept without the content body beginning -- if more, throw a RecorderTooMuchHeaderException.
protected  byte[]bufStreamBuf
    
protected static  Loggerlogger
    
protected  longmaxLength
    
protected  longmaxRateBytesPerMs
    
protected  longstartTime
    
protected  longtimeoutMs
    

Constructor Summary
public  RecordingOutputStream(int bufferSize, String backingFilename)
     Create a new RecordingOutputStream.

Method Summary
protected  voidcheckLimits()
     Check any enforced limits.
public  voidclose()
    
protected synchronized  voidcloseDiskStream()
    
public  voidcloseRecorder()
    
public  voidflush()
    
public  longgetContentBegin()
    
public  ReplayInputStreamgetContentReplayInputStream()
    
public  byte[]getDigestValue()
     Return the digest value for any recorded, digested data.
public  longgetRemainingLength()
    
public  ReplayCharSequencegetReplayCharSequence()
    
public  ReplayCharSequencegetReplayCharSequence(String characterEncoding)
    
public  ReplayCharSequencegetReplayCharSequence(String characterEncoding, long startOffset)
    
Parameters:
  characterEncoding - Encoding of recorded stream.
public  ReplayInputStreamgetReplayInputStream()
    
public  ReplayInputStreamgetReplayInputStream(long skip)
    
public  longgetResponseContentLength()
    
public  longgetSize()
    
public  booleanisOpen()
    
public  voidmark()
     When used alongside a mark-supporting RecordingInputStream, remember a position reachable by a future reset().
public  voidmarkContentBegin()
     Remember the current position as the start of the "response body".
public  voidopen()
     Wrap the given stream, both recording and passing along any data written to this RecordingOutputStream.
public  voidopen(OutputStream wrappedStream)
     Wrap the given stream, both recording and passing along any data written to this RecordingOutputStream.
Parameters:
  wrappedStream - Stream to wrap.
public  voidreset()
     When used alongside a mark-supporting RecordingInputStream, reset the position to that saved by previous mark().
public  voidresetLimits()
    
public  voidsetDigest(String algorithm)
     Sets a digest function which may be applied to recorded data.
public  voidsetDigest(MessageDigest md)
     Sets a digest function which may be applied to recorded data.
public  voidsetLimits(long length, long milliseconds, long rateKBps)
     Set limits on length, time, and rate to enforce.
public  voidsetSha1Digest()
     Convenience method for setting SHA1 digest.
public  voidstartDigest()
     Starts digesting recorded data, if a MessageDigest has been set.
public  voidwrite(int b)
    
public  voidwrite(byte[] b, int off, int len)
    

Field Detail
MAX_HEADER_MATERIAL
final protected static long MAX_HEADER_MATERIAL(Code)
Maximum amount of header material to accept without the content body beginning -- if more, throw a RecorderTooMuchHeaderException. TODO: make configurable? make smaller?



bufStreamBuf
protected byte[] bufStreamBuf(Code)
Reusable buffer for FastBufferedOutputStream



logger
protected static Logger logger(Code)



maxLength
protected long maxLength(Code)
maximum length of material to record before throwing exception



maxRateBytesPerMs
protected long maxRateBytesPerMs(Code)
maximum rate to record (adds delays to hit target rate)



startTime
protected long startTime(Code)
time recording begins for timeout, rate calculations



timeoutMs
protected long timeoutMs(Code)
maximum time to record before throwing exception




Constructor Detail
RecordingOutputStream
public RecordingOutputStream(int bufferSize, String backingFilename)(Code)
Create a new RecordingOutputStream.
Parameters:
  bufferSize - Buffer size to use.
Parameters:
  backingFilename - Name of backing file to use.




Method Detail
checkLimits
protected void checkLimits() throws RecorderIOException(Code)
Check any enforced limits.



close
public void close() throws IOException(Code)



closeDiskStream
protected synchronized void closeDiskStream() throws IOException(Code)



closeRecorder
public void closeRecorder() throws IOException(Code)



flush
public void flush() throws IOException(Code)



getContentBegin
public long getContentBegin()(Code)
Return stored content-begin-mark (which is also end-of-headers)



getContentReplayInputStream
public ReplayInputStream getContentReplayInputStream() throws IOException(Code)
Return a replay stream, cued up to begining of content
throws:
  IOException - An RIS.



getDigestValue
public byte[] getDigestValue()(Code)
Return the digest value for any recorded, digested data. Call only after all data has been recorded; otherwise, the running digest state is ruined. the digest final value



getRemainingLength
public long getRemainingLength()(Code)
Return number of bytes that could be recorded without hitting length limit long byte count



getReplayCharSequence
public ReplayCharSequence getReplayCharSequence() throws IOException(Code)



getReplayCharSequence
public ReplayCharSequence getReplayCharSequence(String characterEncoding) throws IOException(Code)



getReplayCharSequence
public ReplayCharSequence getReplayCharSequence(String characterEncoding, long startOffset) throws IOException(Code)

Parameters:
  characterEncoding - Encoding of recorded stream. A ReplayCharSequence Will return null if an IOException. Callclose on returned RCS when done.
throws:
  IOException -



getReplayInputStream
public ReplayInputStream getReplayInputStream() throws IOException(Code)



getReplayInputStream
public ReplayInputStream getReplayInputStream(long skip) throws IOException(Code)



getResponseContentLength
public long getResponseContentLength()(Code)



getSize
public long getSize()(Code)



isOpen
public boolean isOpen()(Code)
True if this ROS is open.



mark
public void mark()(Code)
When used alongside a mark-supporting RecordingInputStream, remember a position reachable by a future reset().



markContentBegin
public void markContentBegin()(Code)
Remember the current position as the start of the "response body". Useful when recording HTTP traffic as a way to start replays after the headers.



open
public void open() throws IOException(Code)
Wrap the given stream, both recording and passing along any data written to this RecordingOutputStream.
throws:
  IOException - If failed creation of backing file.



open
public void open(OutputStream wrappedStream) throws IOException(Code)
Wrap the given stream, both recording and passing along any data written to this RecordingOutputStream.
Parameters:
  wrappedStream - Stream to wrap. May be null for case where wewant to write to a file backed stream only.
throws:
  IOException - If failed creation of backing file.



reset
public void reset()(Code)
When used alongside a mark-supporting RecordingInputStream, reset the position to that saved by previous mark(). Until the position again reached "new" material, none of the bytes pushed to this stream will be digested or recorded.



resetLimits
public void resetLimits()(Code)
Reset limits to effectively-unlimited defaults



setDigest
public void setDigest(String algorithm)(Code)
Sets a digest function which may be applied to recorded data. The difference between calling this method and RecordingOutputStream.setDigest(MessageDigest) is that this method tries to reuse MethodDigest instance if already allocated and of appropriate algorithm.
Parameters:
  algorithm - Message digest algorithm to use.
See Also:   RecordingOutputStream.setDigest(MessageDigest)



setDigest
public void setDigest(MessageDigest md)(Code)
Sets a digest function which may be applied to recorded data. As usually only a subset of the recorded data should be fed to the digest, you must also call startDigest() to begin digesting.
Parameters:
  md - Message digest function to use.



setLimits
public void setLimits(long length, long milliseconds, long rateKBps)(Code)
Set limits on length, time, and rate to enforce.
Parameters:
  length -
Parameters:
  milliseconds -
Parameters:
  rateKBps -



setSha1Digest
public void setSha1Digest()(Code)
Convenience method for setting SHA1 digest.
See Also:   RecordingOutputStream.setDigest(String)



startDigest
public void startDigest()(Code)
Starts digesting recorded data, if a MessageDigest has been set.



write
public void write(int b) throws IOException(Code)



write
public void write(byte[] b, int off, int len) throws IOException(Code)



Methods inherited from java.io.OutputStream
public void close() throws IOException(Code)(Java Doc)
public void flush() throws IOException(Code)(Java Doc)
abstract public void write(int b) throws IOException(Code)(Java Doc)
public void write(byte b) throws IOException(Code)(Java Doc)
public void write(byte b, int off, int len) 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.