Class AbstractViewWriter
- java.lang.Object
-
- org.soulwing.prospecto.runtime.text.AbstractViewWriter
-
- All Implemented Interfaces:
ViewWriter
- Direct Known Subclasses:
JsonPViewWriter
public abstract class AbstractViewWriter extends Object implements ViewWriter
An object that produces a representation of a view on a specified target.This class is designed to allow a callback-driven interpretation of a view's event stream.
A writer is not thread safe.
- Author:
- Carl Harris
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.soulwing.prospecto.api.ViewWriter
ViewWriter.Target
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractViewWriter(View view, Options options)
Constructs a new writer.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
afterViewEvents()
Notifies the recipient that the view's event stream has ended.protected void
beforeViewEvents()
Notifies the recipient that the view's event stream will start.Options
getOptions()
protected View
getView()
Gets the source view for this writer.protected abstract void
onBeginArray(View.Event event)
Notifies the recipient that the nextevent
is of typeView.Event.Type.BEGIN_ARRAY
.protected abstract void
onBeginObject(View.Event event)
Notifies the recipient that the nextevent
is of typeView.Event.Type.BEGIN_OBJECT
.protected abstract void
onDiscriminator(View.Event event)
Notifies the recipient that the nextevent
is of typeView.Event.Type.DISCRIMINATOR
.protected abstract void
onEndArray(View.Event event)
Notifies the recipient that the nextevent
is of typeView.Event.Type.END_ARRAY
.protected abstract void
onEndObject(View.Event event)
Notifies the recipient that the nextevent
is of typeView.Event.Type.END_OBJECT
.protected abstract void
onMeta(View.Event event)
Notifies the recipient that the nextevent
is of typeView.Event.Type.META
.protected abstract void
onValue(View.Event event)
Notifies the recipient that the nextevent
is of typeView.Event.Type.VALUE
.void
writeView()
Writes the view to the target output stream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.soulwing.prospecto.api.ViewWriter
writeView
-
-
-
-
Method Detail
-
getOptions
public Options getOptions()
-
writeView
public final void writeView() throws ViewException
Writes the view to the target output stream.The underlying output stream is not closed by this method.
- Specified by:
writeView
in interfaceViewWriter
- Throws:
ViewException
- if an error occurs in writing the view.IllegalStateException
- if this method has already been invoked on this writer instance
-
beforeViewEvents
protected void beforeViewEvents() throws Exception
Notifies the recipient that the view's event stream will start.- Throws:
Exception
-
afterViewEvents
protected void afterViewEvents() throws Exception
Notifies the recipient that the view's event stream has ended.- Throws:
Exception
-
onBeginObject
protected abstract void onBeginObject(View.Event event) throws Exception
Notifies the recipient that the nextevent
is of typeView.Event.Type.BEGIN_OBJECT
.- Parameters:
event
- the subject event- Throws:
Exception
-
onEndObject
protected abstract void onEndObject(View.Event event) throws Exception
Notifies the recipient that the nextevent
is of typeView.Event.Type.END_OBJECT
.- Parameters:
event
- the subject event- Throws:
Exception
-
onBeginArray
protected abstract void onBeginArray(View.Event event) throws Exception
Notifies the recipient that the nextevent
is of typeView.Event.Type.BEGIN_ARRAY
.- Parameters:
event
- the subject event- Throws:
Exception
-
onEndArray
protected abstract void onEndArray(View.Event event) throws Exception
Notifies the recipient that the nextevent
is of typeView.Event.Type.END_ARRAY
.- Parameters:
event
- the subject event- Throws:
Exception
-
onValue
protected abstract void onValue(View.Event event) throws Exception
Notifies the recipient that the nextevent
is of typeView.Event.Type.VALUE
.- Parameters:
event
- the subject event- Throws:
Exception
-
onMeta
protected abstract void onMeta(View.Event event) throws Exception
Notifies the recipient that the nextevent
is of typeView.Event.Type.META
.- Parameters:
event
- the subject event- Throws:
Exception
-
onDiscriminator
protected abstract void onDiscriminator(View.Event event) throws Exception
Notifies the recipient that the nextevent
is of typeView.Event.Type.DISCRIMINATOR
.- Parameters:
event
- the subject event- Throws:
Exception
-
getView
protected final View getView()
Gets the source view for this writer.- Returns:
- source view
-
-