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

org.codehaus.stax2.io.Stax2StringSource Maven / Gradle / Ivy

Go to download

Stax2 API is an extension to basic Stax 1.0 API that adds significant new functionality, such as full-featured bi-direction validation interface and high-performance Typed Access API.

There is a newer version: 4.2.2
Show newest version
package org.codehaus.stax2.io;

import java.io.*;

/**
 * Simple implementation of {@link Stax2BlockSource} that encapsulates
 * a simple {@link String}.
 */
public class Stax2StringSource
    extends Stax2BlockSource
{
    final String mText;

    public Stax2StringSource(String text) {
        mText = text;
    }

    /*
    /////////////////////////////////////////
    // Implementation of the Public API
    /////////////////////////////////////////
     */

    @Override
    public Reader constructReader() throws IOException
    {
        return new StringReader(mText);
    }

    @Override
    public InputStream constructInputStream() throws IOException
    {
        /* No obvious/easy way; if caller really wants an InputStream, it
         * can get a Reader, add an encoders, and so on.
         */
        return null;
    }

    /*
    /////////////////////////////////////////
    // Additional API for this source
    /////////////////////////////////////////
     */

    public String getText() {
        return mText;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy