public class GenericReplayCharSequence extends java.lang.Object implements ReplayCharSequence
InMemoryReplayCharSequence.
Call close() on this class when done to clean up resources.
| Modifier and Type | Field and Description |
|---|---|
protected java.nio.charset.Charset |
charset |
protected java.nio.charset.CharacterCodingException |
codingException |
protected long |
decodingExceptions
counter of decoding exceptions for report at end
|
protected int |
length
Total length of character stream to replay minus the HTTP headers
if present.
|
protected static java.util.logging.Logger |
logger |
static java.nio.charset.Charset |
WRITE_ENCODING
Name of the encoding we use writing out concatenated decoded prefix
buffer and decoded backing file.
|
FALLBACK_CHARSET| Constructor and Description |
|---|
GenericReplayCharSequence(java.io.InputStream contentReplayInputStream,
int prefixMax,
java.lang.String backingFilename,
java.nio.charset.Charset charset)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
char |
charAt(int index)
Get character at passed absolute position.
|
void |
close()
Call this method when done so implementation has chance to clean up
resources.
|
protected void |
decode(java.io.InputStream inStream,
int prefixMax,
java.lang.String backingFilename,
java.nio.charset.Charset charset)
Converts the first
Integer.MAX_VALUE characters from the
file backingFilename from encoding encoding to
encoding WRITE_ENCODING and saves as
this.decodedFile, which is named backingFilename
+ "." + WRITE_ENCODING. |
protected void |
finalize() |
java.nio.charset.Charset |
getCharset()
Return the effective Charset used to create this CharSequence from
(raw byte) source material.
|
java.nio.charset.CharacterCodingException |
getCodingException()
Return the first coding-exception encountered, if the count > 0.
|
long |
getDecodeExceptionCount()
Report count of decoder errors silently eaten during ReplayCharSequence
use.
|
boolean |
isOpen() |
int |
length() |
java.lang.CharSequence |
subSequence(int start,
int end) |
java.lang.String |
substring(int offset,
int len)
Deprecated.
please use subSequence() and then toString() directly
|
java.lang.String |
toString() |
protected static java.util.logging.Logger logger
public static final java.nio.charset.Charset WRITE_ENCODING
This define is also used as suffix for the file that holds the decodings. The name of the file that holds the decoding is the name of the backing file w/ this encoding for a suffix.
See Encoding.
protected int length
Integer.MAX_VALUE (i.e. 2gb),
only the first Integer.MAX_VALUE characters are available through this API.
We're overriding java.lang.CharSequence so that we can use
java.util.regex directly on the data, and the CharSequence
API uses int for the length and index.protected long decodingExceptions
protected java.nio.charset.CharacterCodingException codingException
protected java.nio.charset.Charset charset
public GenericReplayCharSequence(java.io.InputStream contentReplayInputStream,
int prefixMax,
java.lang.String backingFilename,
java.nio.charset.Charset charset)
throws java.io.IOException
contentReplayInputStream - inputStream of contentcharset - Encoding to use reading the passed prefix
buffer and backing file. Must not be null.backingFilename - Path to backing file with content in excess of
whats in buffer.java.io.IOExceptionprotected void decode(java.io.InputStream inStream,
int prefixMax,
java.lang.String backingFilename,
java.nio.charset.Charset charset)
throws java.io.IOException
Integer.MAX_VALUE characters from the
file backingFilename from encoding encoding to
encoding WRITE_ENCODING and saves as
this.decodedFile, which is named backingFilename
+ "." + WRITE_ENCODING.java.io.IOExceptionpublic char charAt(int index)
charAt in interface java.lang.CharSequenceindex - Index into contentindex.public java.lang.CharSequence subSequence(int start,
int end)
subSequence in interface java.lang.CharSequencepublic boolean isOpen()
isOpen in interface ReplayCharSequenceReplayCharSequence.close() has been calledpublic void close()
throws java.io.IOException
ReplayCharSequenceclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface ReplayCharSequencejava.io.IOException - Problem cleaning up file system resources.protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic java.lang.String substring(int offset,
int len)
public java.lang.String toString()
toString in interface java.lang.CharSequencetoString in class java.lang.Objectpublic int length()
length in interface java.lang.CharSequencepublic long getDecodeExceptionCount()
ReplayCharSequencegetDecodeExceptionCount in interface ReplayCharSequencepublic java.nio.charset.CharacterCodingException getCodingException()
ReplayCharSequencegetCodingException in interface ReplayCharSequencepublic java.nio.charset.Charset getCharset()
ReplayCharSequencegetCharset in interface ReplayCharSequenceCopyright © 2019 The International Internet Preservation Consortium. All Rights Reserved.