public abstract class AbstractParser<T> extends Object implements Parser<T>
Parser
. This simply handles progress updating, validator setting and
listener registration.
Note that this implementation will cascade any registered listeners to the validator as well. This means that
listeners registered to the parser will also report on validation errors, removing the requirement to separately
handle parse and validation errors.Modifier and Type | Class and Description |
---|---|
protected class |
AbstractParser.DefaultHandlerListener |
DEFAULT_ENCODING
Modifier | Constructor and Description |
---|---|
protected |
AbstractParser() |
Modifier and Type | Method and Description |
---|---|
void |
addErrorItemListener(ErrorItemListener listener)
Register an
ErrorItemListener with this parser. |
void |
addProgressListener(ProgressListener listener)
Register a
ProgressListener with this parser. |
protected void |
fireErrorItemEvent(org.mged.magetab.error.ErrorItem errorItem)
Fires an error item notification on any
ErrorItemListener s currently configured to listen to this
parser. |
protected void |
fireParseEvent(ProgressEvent event) |
protected void |
fireParsingCompletedEvent(ProgressEvent event) |
protected void |
fireParsingFailedEvent(ProgressEvent event) |
protected void |
fireParsingStartedEvent(ProgressEvent event) |
String |
getEncoding()
Gets current encoding for the parser.
|
Set<ErrorItemListener> |
getErrorItemListeners()
Get the collection of
ErrorItemListener s registered to this
parser |
org.slf4j.Logger |
getLog() |
Collection<ProgressListener> |
getProgressListeners()
Get the collection of
ProgressListener s that are currently registered to this parser. |
boolean |
isStrippingEscaping() |
void |
removeErrorItemListener(ErrorItemListener listener)
Deregister an
ErrorItemListener with this parser. |
void |
removeProgressListener(ProgressListener listener)
Deregister a
ProgressListener from this parser. |
void |
setEncoding(String encoding)
Sets an alternative encoding for the parser.
|
void |
setStripEscaping(boolean stripEscaping) |
public String getEncoding()
Parser
getEncoding
in interface Parser<T>
public void setEncoding(String encoding)
Parser
setEncoding
in interface Parser<T>
encoding
- input encoding of the streampublic org.slf4j.Logger getLog()
public boolean isStrippingEscaping()
public void setStripEscaping(boolean stripEscaping)
public void addErrorItemListener(ErrorItemListener listener)
Parser
ErrorItemListener
with this parser. Whenever an error is encountered when parsing from the a
parserSource, this listener should be notified.addErrorItemListener
in interface Parser<T>
listener
- the listener to registerpublic void removeErrorItemListener(ErrorItemListener listener)
Parser
ErrorItemListener
with this parser. This listener will no longer be notified when error
items are generated.removeErrorItemListener
in interface Parser<T>
listener
- the listener to registerpublic Set<ErrorItemListener> getErrorItemListeners()
Parser
ErrorItemListener
s registered to this
parsergetErrorItemListeners
in interface Parser<T>
public void addProgressListener(ProgressListener listener)
Parser
ProgressListener
with this parser. Whenever the parser has more progress to report, this
listener will be notified.addProgressListener
in interface Parser<T>
listener
- the listener to registerpublic void removeProgressListener(ProgressListener listener)
Parser
ProgressListener
from this parser. Progress events will no longer be reported through this
parserremoveProgressListener
in interface Parser<T>
listener
- a listener to monitor progress of the parsing operationpublic Collection<ProgressListener> getProgressListeners()
Parser
ProgressListener
s that are currently registered to this parser.getProgressListeners
in interface Parser<T>
protected void fireErrorItemEvent(org.mged.magetab.error.ErrorItem errorItem)
ErrorItemListener
s currently configured to listen to this
parser.errorItem
- the error item that encapsulates the errorprotected void fireParsingStartedEvent(ProgressEvent event)
protected void fireParsingCompletedEvent(ProgressEvent event)
protected void fireParsingFailedEvent(ProgressEvent event)
protected void fireParseEvent(ProgressEvent event)
Copyright © 2014. All rights reserved.