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

org.immutables.gson.stream.XmlParserReader Maven / Gradle / Ivy

Go to download

Gson integration for Immutables. Also includes optional integration with Jackson to speed-up streaming parsing of Gson, while using all of gson binding infrastructure.

There is a newer version: 2.10.1
Show newest version
package org.immutables.gson.stream;

import com.fasterxml.jackson.core.JsonParser;
import com.google.gson.stream.JsonReader;

import javax.annotation.concurrent.NotThreadSafe;
import java.io.IOException;

/**
 *  {@link JsonReader} implementation backed by Jackson's {@link JsonParser}.
 *  This version assumes the token producer only supports strings, therefore will
 *  work with the XML and properties formats.
 */
@NotThreadSafe
public class XmlParserReader extends JsonParserReader {
  public XmlParserReader(JsonParser parser) {
    super(parser);
  }

  @Override
  public boolean nextBoolean() throws IOException {
    return Boolean.parseBoolean(nextString());
  }

  @Override
  public double nextDouble() throws IOException {
    return Double.parseDouble(nextString());
  }

  @Override
  public long nextLong() throws IOException {
    return Long.parseLong(nextString());
  }

  @Override
  public int nextInt() throws IOException {
    return Integer.parseInt(nextString());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy