public abstract class ArcWriter extends java.lang.Object implements java.io.Closeable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
bExceptionOnContentLengthMismatch
Configuration for throwing exception on content-length mismatch.
|
Diagnostics<Diagnosis> |
diagnostics
Writer level errors and warnings or when writing byte headers.
|
protected ArcFieldParsers |
fieldParsers
ARC field parser used.
|
protected ArcHeader |
header |
protected java.lang.Long |
headerContentLength
Content-Length from the ARC header.
|
protected java.io.OutputStream |
out
Outputstream used to write ARC records.
|
protected long |
payloadWrittenTotal
Total bytes written for current record payload.
|
protected static int |
S_HEADER_WRITTEN
State after header has been written.
|
protected static int |
S_INIT
State after writer has been constructed and before records have been written.
|
protected static int |
S_PAYLOAD_WRITTEN
State after payload has been written.
|
protected static int |
S_RECORD_CLOSED
State after record has been closed.
|
protected int |
state
Current state of writer.
|
protected byte[] |
stream_copy_buffer
Buffer used by streamPayload() to copy from one stream to another.
|
| Constructor and Description |
|---|
ArcWriter() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
close()
Close ARC writer and free its resources.
|
protected void |
closeRecord_impl()
Closes the ARC record by writing one newline and comparing the amount of
payload data streamed with the content-length supplied with the header.
|
abstract void |
closeRecord()
Close the ARC record in an implementation specific way.
|
boolean |
exceptionOnContentLengthMismatch()
Does this writer throw an exception if the content-length does not match
the payload amount written.
|
protected void |
init()
Method used to initialize a readers internal state.
|
abstract boolean |
isCompressed()
Is this writer producing compressed output.
|
void |
setExceptionOnContentLengthMismatch(boolean enabled)
Tell the writer what to do in case of mismatch between content-length
and amount payload written.
|
long |
streamPayload(java.io.InputStream in)
Stream the content of an input stream to the payload content.
|
protected byte[] |
writeHeader_impl(ArcRecordBase record)
Write an ARC header to the ARC output stream.
|
abstract byte[] |
writeHeader(ArcRecordBase record)
Write a ARC header to the ARC output stream.
|
long |
writePayload(byte[] b)
Append the content of a byte array to the payload content.
|
long |
writePayload(byte[] b,
int offset,
int len)
Append the partial content of a byte array to the payload content.
|
void |
writeRawHeader(byte[] header_bytes,
java.lang.Long contentLength)
Write a raw ARC header to the ARC output stream.
|
protected static final int S_INIT
protected static final int S_HEADER_WRITTEN
protected static final int S_PAYLOAD_WRITTEN
protected static final int S_RECORD_CLOSED
protected ArcFieldParsers fieldParsers
protected byte[] stream_copy_buffer
protected boolean bExceptionOnContentLengthMismatch
public final Diagnostics<Diagnosis> diagnostics
protected int state
protected java.io.OutputStream out
protected java.lang.Long headerContentLength
protected long payloadWrittenTotal
public ArcWriter()
protected void init()
public abstract boolean isCompressed()
public boolean exceptionOnContentLengthMismatch()
public void setExceptionOnContentLengthMismatch(boolean enabled)
enabled - boolean indicating exception throwing on/offpublic abstract void close() throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException - if an I/O exception occurs while closing the writerpublic abstract void closeRecord() throws java.io.IOException
java.io.IOException - if an I/O exception occurs while closing the recordprotected void closeRecord_impl() throws java.io.IOException
java.io.IOException - if an I/O exception occurs while closing the recordpublic void writeRawHeader(byte[] header_bytes, java.lang.Long contentLength) throws java.io.IOException
header_bytes - raw ARC record to outputcontentLength - the expected content-length to be written and validated
The contentLength is synonymous to the Archive-Length.java.io.IOException - if an exception occurs while writing header datapublic abstract byte[] writeHeader(ArcRecordBase record) throws java.io.IOException
record - ARC record to outputjava.io.IOException - if an I/O exception occurs while writing header dataprotected byte[] writeHeader_impl(ArcRecordBase record) throws java.io.IOException
record - ARC record to outputjava.io.IOException - if an I/O exception occurs while writing header datapublic long streamPayload(java.io.InputStream in) throws java.io.IOException
in - input stream containing payload datajava.io.IOException - if an I/O exception occurs while writing payload datapublic long writePayload(byte[] b) throws java.io.IOException
b - byte array with data to be writtenjava.io.IOException - if an I/O exception occurs while writing payload datapublic long writePayload(byte[] b, int offset, int len) throws java.io.IOException
b - byte array with partial data to be writtenoffset - offset to data to be writtenlen - length of data to be writtenjava.io.IOException - if an I/O exception occurs while writing payload dataCopyright © 2011–2022. All rights reserved.