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

net.intelie.liverig.witsml.query.AbstractQuery20 Maven / Gradle / Ivy

The newest version!
package net.intelie.liverig.witsml.query;

import com.google.common.base.Strings;
import net.intelie.liverig.metadata.Metadata;
import net.intelie.liverig.parser.MultiMapEventBuilder;
import net.intelie.liverig.parser.ParseException;
import net.intelie.liverig.parser.Parser;
import net.intelie.liverig.parser.ParserFactory;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.IOException;
import java.io.StringReader;

abstract class AbstractQuery20 extends AbstractQuery {


    static void writeRootElement(XMLStreamWriter writer, String localName) throws XMLStreamException {
    }

    @Override
    public String options() {
        return "";
    }

    protected static Parser getParser(String indexType) throws ParseException {
        Metadata metadata = new Metadata();
        metadata.source_protocol_name = "witsml";
        metadata.requested_index_type = indexType;
        return ParserFactory.getParser(metadata);
    }

    protected static void parse(String xml, MultiMapEventBuilder.EventOutput eventOutput, String indexType) throws ParseException {
        if (Strings.isNullOrEmpty(xml))
            throw new ParseEmptyException("Empty response to WITSML query");

        try {
            Parser parser = getParser(indexType);
            parser.setVerbose(true);
            parser.parse(new StringReader(xml), new MultiMapEventBuilder(eventOutput));
        } catch (IOException e) {
            throw new ParseException(e);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy