|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.streamhtmlparser.util.CharacterRecorder
public class CharacterRecorder
Records (stores) characters supplied one at a time conditional on whether recording is currently enabled.
When maybeRecord(char)
is called, it will add the
supplied character to the recording buffer but only if
recording is in progress. This is useful in our
com.google.security.streamhtmlparser.HtmlParser
as the caller logic to enable/disable recording is decoupled from the logic
of recording.
This is a specialized class - of no use to external code -
which aims to be 100% compatible with the corresponding logic
in the C-version of the HtmlParser, specifically in
statemachine.c
. In particular:
startRecording()
and stopRecording()
methods
may be called repeatedly without interleaving since the C version is
not guaranteed to interleave them.
RECORDING_BUFFER_SIZE
. Once the size is
reached, no further characters are recorded regardless of whether
recording is currently enabled.
Field Summary | |
---|---|
static int |
RECORDING_BUFFER_SIZE
How many characters can be recorded before stopping to accept new ones. |
Constructor Summary | |
---|---|
CharacterRecorder()
Constructs an empty character recorder of fixed size currently not recording. |
|
CharacterRecorder(CharacterRecorder aCharacterRecorder)
Constructs a character recorder of fixed size that is a copy of the one provided. |
Method Summary | |
---|---|
void |
clear()
Empties the underlying storage but does not change the recording state [i.e whether we are recording or not incoming characters]. |
String |
getContent()
Returns the characters recorded in a String form. |
boolean |
isRecording()
Returns whether or not we are currently recording incoming characters. |
void |
maybeRecord(char input)
Records the input if recording is currently on and we
have space available in the buffer. |
void |
reset()
Empties the underlying storage and resets the recording indicator to indicate we are not recording currently. |
void |
startRecording()
Enables recording for incoming characters. |
void |
stopRecording()
Disables recording further characters. |
String |
toString()
Returns the full state of the object in a human readable form. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int RECORDING_BUFFER_SIZE
Constructor Detail |
---|
public CharacterRecorder()
RECORDING_BUFFER_SIZE
for the size.
public CharacterRecorder(CharacterRecorder aCharacterRecorder)
aCharacterRecorder
- the CharacterRecorder
to copyMethod Detail |
---|
public void startRecording()
public void stopRecording()
public void maybeRecord(char input)
input
if recording is currently on and we
have space available in the buffer. If recording is not
currently on, this method will not perform any action.
input
- the character to recordpublic void clear()
public void reset()
public String getContent()
String
form. This
method has no side-effects, the characters remain stored as is.
String
formpublic boolean isRecording()
true
if we are recording, false
otherwisepublic String toString()
String
is not specified and is
subject to change.
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |