T
- the type of the target@ParametersAreNonnullByDefault public abstract class AbstractWriter<T> extends Object implements Writer
Writer
that acts as an accumulator of multi-value features in order to notify them once. This
allow to use batch methods in a DataMapper
, and ensure the call order
when writing in a file.Modifier and Type | Field and Description |
---|---|
protected T |
target
The target where to write data.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractWriter(T target)
Constructs a new
AbstractWriter with the given target . |
Modifier and Type | Method and Description |
---|---|
void |
onAttribute(ProxyAttribute attribute)
Handles an attribute in the current element.
|
abstract void |
onAttribute(ProxyAttribute attribute,
List<Object> values)
Handles an attribute in the current element.
|
void |
onEndElement()
Handles the end of the current element.
|
void |
onReference(ProxyReference reference)
Handles a reference from the current element to another.
|
abstract void |
onReference(ProxyReference reference,
List<Id> values)
Handles a reference in the current element.
|
void |
onStartElement(ProxyElement element)
Handles the start of an element.
|
protected boolean |
requireEndBeforeFlush()
Returns
true if this writer requires the end of the current element before flushing all features,
otherwise, all features will be flushed as soon as another feature is intercepted. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onComplete, onInitialize
protected AbstractWriter(T target)
AbstractWriter
with the given target
.target
- the target where to write data@OverridingMethodsMustInvokeSuper public void onStartElement(ProxyElement element) throws IOException
Handler
onStartElement
in interface Handler
element
- the element of the new elementIOException
Handler.onEndElement()
,
Notifier.notifyStartElement(ProxyElement)
public final void onAttribute(ProxyAttribute attribute) throws IOException
Handler
onAttribute
in interface Handler
attribute
- the new attributeIOException
Handler.onStartElement(ProxyElement)
,
Notifier.notifyAttribute(ProxyAttribute)
public final void onReference(ProxyReference reference) throws IOException
Handler
onReference
in interface Handler
reference
- the new referenceIOException
Handler.onStartElement(ProxyElement)
,
Notifier.notifyReference(ProxyReference)
@OverridingMethodsMustInvokeSuper public void onEndElement() throws IOException
Handler
onEndElement
in interface Handler
IOException
Handler.onStartElement(ProxyElement)
,
Notifier.notifyEndElement()
public abstract void onAttribute(ProxyAttribute attribute, List<Object> values) throws IOException
attribute
- the new attribute, without its valuevalues
- the ordered values of the attribute; when the attribute
is single-valued, this parameter
is a Collections.singletonList(Object)
IOException
public abstract void onReference(ProxyReference reference, List<Id> values) throws IOException
reference
- the new reference, without its valuevalues
- the ordered values of the reference; when the reference
is single-valued, this parameter
is a Collections.singletonList(Object)
IOException
protected boolean requireEndBeforeFlush()
true
if this writer requires the end of the current element before flushing all features,
otherwise, all features will be flushed as soon as another feature is intercepted. This is typically used when
writing a structured file with streams.true
if this writer requires the end of the current element before flushing all featuresCopyright © 2013–2019 Atlanmod. All rights reserved.