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

com.rt.storage.api.client.util.ObjectParser Maven / Gradle / Ivy

package com.rt.storage.api.client.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.lang.reflect.Type;
import java.nio.charset.Charset;

/**
 * Parses a data source into the specified data type.
 *
 * 

Implementations should normally be thread-safe. * * @author Yaniv Inbar * @since 1.10 */ public interface ObjectParser { /** * Parses the given input stream into a new instance of the the given data class of key/value * pairs and closes the input stream. * * @param in input stream which contains the data to parse * @param charset charset which should be used to decode the input stream or {@code null} if * unknown * @param dataClass class into which the data is parsed */ T parseAndClose(InputStream in, Charset charset, Class dataClass) throws IOException; /** * Parses the given input stream into a new instance of the the given data type of key/value pairs * and closes the input stream. * * @param in input stream which contains the data to parse * @param charset charset which should be used to decode the input stream or {@code null} if * unknown * @param dataType type into which the data is parsed */ Object parseAndClose(InputStream in, Charset charset, Type dataType) throws IOException; /** * Parses the given reader into a new instance of the the given data class of key/value pairs and * closes the reader. * * @param reader reader which contains the text data to parse * @param dataClass class into which the data is parsed */ T parseAndClose(Reader reader, Class dataClass) throws IOException; /** * Parses the given reader into a new instance of the the given data type of key/value pairs and * closes the reader. * * @param reader reader which contains the text data to parse * @param dataType type into which the data is parsed */ Object parseAndClose(Reader reader, Type dataType) throws IOException; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy