Package com.google.gson.stream

Examples of com.google.gson.stream.JsonToken


    gson = Serializer.createGSon(refLoader);
  }

  public IEvent deserialize() throws IOException {
    JsonToken peek = input.peek();
    if (peek == JsonToken.END_ARRAY)
      return null;

    input.beginArray();
    EventType type = EventType.valueOf(input.nextString());
View Full Code Here


  }

  public static int startJson(final JsonReader reader) throws EntityProviderException {
    // The enclosing "d" and "results" are optional - so we cannot check for the presence
    // but we have to read over them in case they are present.
    JsonToken token;
    try {
      token = reader.peek();
      int openJsonObjects = 0;
      if (JsonToken.BEGIN_OBJECT == token) {
        reader.beginObject();
View Full Code Here

  private Object readSimpleProperty(final JsonReader reader, final EntityPropertyInfo entityPropertyInfo,
      final Object typeMapping) throws EdmException, EntityProviderException, IOException {
    final EdmSimpleType type = (EdmSimpleType) entityPropertyInfo.getType();
    Object value = null;
    final JsonToken tokenType = reader.peek();
    if (tokenType == JsonToken.NULL) {
      reader.nextNull();
    } else {
      switch (EdmSimpleTypeKind.valueOf(type.getName())) {
      case Boolean:
View Full Code Here

   * @param knownRecords Set of record name already encountered during the reading.
   * @return A {@link Schema} reflecting the json.
   * @throws java.io.IOException Any error during reading.
   */
  private Schema read(JsonReader reader, Set<String> knownRecords) throws IOException {
    JsonToken token = reader.peek();
    switch (token) {
      case NULL:
        return null;
      case STRING: {
        // Simple type or know record type
View Full Code Here

    DcatParser.ListenerInternal listener = new DcatParser.ListenerInternal() {
      private void parse(final ListenerInternal listener) throws DcatParseException, IOException {
          if (!jsonReader.hasNext()) {
            throw new DcatParseException("No more data available.");
          }
          JsonToken token = jsonReader.peek();
          if (token != JsonToken.BEGIN_ARRAY) {
            throw new DcatParseException("No array found.");
          }

          parseRecords(listener);
View Full Code Here

  void parse(final ListenerInternal listener) throws DcatParseException, IOException {
      if (!jsonReader.hasNext()) {
        throw new DcatParseException("No more data available.");
      }

      JsonToken token = jsonReader.peek();
      if (token != JsonToken.BEGIN_ARRAY) {
        throw new DcatParseException("No array found.");
      }
      jsonReader.beginArray();
View Full Code Here

   * @throws DcatParseException if parsing DCAT fails
   */
  void parseRecords(ListenerInternal listener) throws DcatParseException, IOException {

      while (jsonReader.hasNext()) {
        JsonToken token = jsonReader.peek();
        switch (token) {
          case BEGIN_OBJECT:
            jsonReader.beginObject();
            if (!parseRecord(listener)) {
              return;
View Full Code Here

  }

  private boolean parseRecord(ListenerInternal listener) throws DcatParseException, IOException {
    JsonRecord record = new JsonRecord();
    while (jsonReader.hasNext()) {
      JsonToken token = jsonReader.peek();
      switch (token) {
        case NAME:
          parseAttribute(record);
          break;
        default:
View Full Code Here

  }

  private void parseAttribute(JsonRecord record) throws DcatParseException, IOException {
    String attrName = jsonReader.nextName();
    while (jsonReader.hasNext()) {
      JsonToken token = jsonReader.peek();
      switch (token) {
        case STRING:
          record.put(attrName, new JsonAttribute(jsonReader.nextString()));
          return;
        case NUMBER:
View Full Code Here

  }
 
  private void parseKeywords(List<JsonAttribute> keywords) throws DcatParseException, IOException {

    while (jsonReader.hasNext()) {
      JsonToken token = jsonReader.peek();
      switch (token) {
        case END_ARRAY:
          jsonReader.endArray();
          break;
        case STRING:
View Full Code Here

TOP

Related Classes of com.google.gson.stream.JsonToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.