com.signalfx.shaded.fasterxml.jackson.jr.ob.comp.ComposerBase Maven / Gradle / Ivy
Show all versions of signalfx-codahale Show documentation
package com.signalfx.shaded.fasterxml.jackson.jr.ob.comp;
import java.io.Flushable;
import java.io.IOException;
import java.util.Collection;
import com.signalfx.shaded.fasterxml.jackson.core.JsonGenerator;
/**
* Base class for all composer implementations.
*/
public abstract class ComposerBase
implements Flushable
{
protected ComposerBase _child;
protected boolean _open = true;
protected ComposerBase() { }
/*
/**********************************************************************
/* Abstract methods sub-classes have to implement
/**********************************************************************
*/
protected abstract ComposerBase _start() throws IOException;
protected abstract Object _finish() throws IOException;
/**
* Helper method used to "peel away" bogus exception declaration
*/
protected Object _safeFinish() {
try {
return _finish();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
protected final void _childClosed() {
_child = null;
}
/*
/**********************************************************************
/* Helper methods for sub-classes
/**********************************************************************
*/
protected IllegalStateException _illegalCall() {
return new IllegalStateException("This code path should never be executed");
}
protected ArrayComposer
_startArray(P parent, JsonGenerator g)
throws IOException
{
ArrayComposer
child = new ArrayComposer
(parent, g);
_child = child;
return child._start();
}
protected
ObjectComposer
_startObject(P parent, JsonGenerator g)
throws IOException
{
ObjectComposer
child = new ObjectComposer
(parent, g);
_child = child;
return child._start();
}
protected
CollectionComposer
_startCollection(P parent)
{
CollectionComposer
child = new CollectionComposer
>(parent);
_child = child;
return child._start();
}
protected
MapComposer
_startMap(P parent)
{
MapComposer
child = new MapComposer
(parent);
_child = child;
return child._start();
}
}