All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.jackson.jr.ob.comp.ComposerBase Maven / Gradle / Ivy

Go to download

"Uber" jar that contains all Jackson jr components as well as underlying Jackson core Streaming, in a single jar.

The newest version!
package com.fasterxml.jackson.jr.ob.comp;

import java.io.Flushable;
import java.io.IOException;
import java.util.Collection;

import com.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(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy