當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonToken.END_ARRAY屬性代碼示例

本文整理匯總了Java中com.google.gson.stream.JsonToken.END_ARRAY屬性的典型用法代碼示例。如果您正苦於以下問題:Java JsonToken.END_ARRAY屬性的具體用法?Java JsonToken.END_ARRAY怎麽用?Java JsonToken.END_ARRAY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.google.gson.stream.JsonToken的用法示例。


在下文中一共展示了JsonToken.END_ARRAY屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: peek

@Override
public JsonToken peek() throws IOException {
  JsonToken token = null;

  if (state() == State.INITIAL || state() == State.SCOPE_DOCUMENT) {
    advance();
    token = toGsonToken(delegate.getCurrentBsonType());
  } else if (state() == State.TYPE) {
    advance();
    token = toGsonToken(delegate.getCurrentBsonType());
  } else if (state() == State.NAME) {
    token = JsonToken.NAME;
  } else if (state() == State.END_OF_DOCUMENT) {
    token = JsonToken.END_OBJECT;
  } else if (state() == State.END_OF_ARRAY) {
    token = JsonToken.END_ARRAY;
  } else if (state() == State.DONE) {
    token = JsonToken.END_DOCUMENT;
  } else if (state() == State.VALUE) {
    token = toGsonToken(delegate.getCurrentBsonType());
  }

  if (token == null) {
    throw new IllegalStateException("Shouldn't get here (null token). Last state is " + state() + " currentType:" +
            delegate.getCurrentBsonType());
  }

  return token;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:29,代碼來源:BsonReader.java

示例2: toGsonToken

private static JsonToken toGsonToken(com.fasterxml.jackson.core.JsonToken token) {
  switch (token) {
  case START_ARRAY:
    return JsonToken.BEGIN_ARRAY;
  case END_ARRAY:
    return JsonToken.END_ARRAY;
  case START_OBJECT:
    return JsonToken.BEGIN_OBJECT;
  case END_OBJECT:
    return JsonToken.END_OBJECT;
  case FIELD_NAME:
    return JsonToken.NAME;
  case VALUE_FALSE:
    return JsonToken.BOOLEAN;
  case VALUE_TRUE:
    return JsonToken.BOOLEAN;
  case VALUE_NULL:
    return JsonToken.NULL;
  case VALUE_NUMBER_INT:
    return JsonToken.NUMBER;
  case VALUE_NUMBER_FLOAT:
    return JsonToken.NUMBER;
  case VALUE_STRING:
  case VALUE_EMBEDDED_OBJECT:
    return JsonToken.STRING;
  default: // Not semantically equivalent
    return JsonToken.NULL;
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:29,代碼來源:JsonParserReader.java

示例3: read

@Override
public SemanticVersion read(JsonReader in) throws IOException {
    in.beginArray();
    int major = in.nextInt();
    int minor = in.nextInt();
    int patch = in.peek() == JsonToken.END_ARRAY ? 0 : in.nextInt();
    in.endArray();
    return new SemanticVersion(major, minor, patch);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:9,代碼來源:SemanticVersionTypeAdapter.java

示例4: read

public BitSet read(JsonReader in) throws IOException {
  if (in.peek() == JsonToken.NULL) {
    in.nextNull();
    return null;
  }

  BitSet bitset = new BitSet();
  in.beginArray();
  int i = 0;
  JsonToken tokenType = in.peek();
  while (tokenType != JsonToken.END_ARRAY) {
    boolean set;
    switch (tokenType) {
    case NUMBER:
      set = in.nextInt() != 0;
      break;
    case BOOLEAN:
      set = in.nextBoolean();
      break;
    case STRING:
      String stringValue = in.nextString();
      try {
        set = Integer.parseInt(stringValue) != 0;
      } catch (NumberFormatException e) {
        throw new JsonSyntaxException(
            "Error: Expecting: bitset number value (1, 0), Found: " + stringValue);
      }
      break;
    default:
      throw new JsonSyntaxException("Invalid bitset value type: " + tokenType);
    }
    if (set) {
      bitset.set(i);
    }
    ++i;
    tokenType = in.peek();
  }
  in.endArray();
  return bitset;
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:40,代碼來源:TypeAdapters.java

示例5: hasNext

public boolean hasNext() throws IOException {
    JsonToken token = peek();
    return (token == JsonToken.END_OBJECT || token == JsonToken.END_ARRAY) ? false : true;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:4,代碼來源:JsonTreeReader.java

示例6: peek

public JsonToken peek() throws IOException {
    if (this.stack.isEmpty()) {
        return JsonToken.END_DOCUMENT;
    }
    Iterator<?> o = peekStack();
    if (o instanceof Iterator) {
        boolean isObject = this.stack.get(this.stack.size() - 2) instanceof JsonObject;
        Iterator<?> iterator = o;
        if (!iterator.hasNext()) {
            return isObject ? JsonToken.END_OBJECT : JsonToken.END_ARRAY;
        } else {
            if (isObject) {
                return JsonToken.NAME;
            }
            this.stack.add(iterator.next());
            return peek();
        }
    } else if (o instanceof JsonObject) {
        return JsonToken.BEGIN_OBJECT;
    } else {
        if (o instanceof JsonArray) {
            return JsonToken.BEGIN_ARRAY;
        }
        if (o instanceof JsonPrimitive) {
            JsonPrimitive primitive = (JsonPrimitive) o;
            if (primitive.isString()) {
                return JsonToken.STRING;
            }
            if (primitive.isBoolean()) {
                return JsonToken.BOOLEAN;
            }
            if (primitive.isNumber()) {
                return JsonToken.NUMBER;
            }
            throw new AssertionError();
        } else if (o instanceof JsonNull) {
            return JsonToken.NULL;
        } else {
            if (o == SENTINEL_CLOSED) {
                throw new IllegalStateException("JsonReader is closed");
            }
            throw new AssertionError();
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:45,代碼來源:JsonTreeReader.java

示例7: read

public BitSet read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    BitSet bitset = new BitSet();
    in.beginArray();
    int i = 0;
    JsonToken tokenType = in.peek();
    while (tokenType != JsonToken.END_ARRAY) {
        boolean set;
        switch (tokenType) {
            case NUMBER:
                if (in.nextInt() == 0) {
                    set = false;
                    break;
                }
                set = true;
                break;
            case BOOLEAN:
                set = in.nextBoolean();
                break;
            case STRING:
                String stringValue = in.nextString();
                try {
                    set = Integer.parseInt(stringValue) != 0;
                    break;
                } catch (NumberFormatException e) {
                    throw new JsonSyntaxException("Error: Expecting: bitset number value (1, 0), Found: " + stringValue);
                }
            default:
                throw new JsonSyntaxException("Invalid bitset value type: " + tokenType);
        }
        if (set) {
            bitset.set(i);
        }
        i++;
        tokenType = in.peek();
    }
    in.endArray();
    return bitset;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:42,代碼來源:TypeAdapters.java

示例8: hasNext

@Override public boolean hasNext() throws IOException {
  JsonToken token = peek();
  return token != JsonToken.END_OBJECT && token != JsonToken.END_ARRAY;
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:4,代碼來源:JsonTreeReader.java

示例9: peek

@Override public JsonToken peek() throws IOException {
  if (stack.isEmpty()) {
    return JsonToken.END_DOCUMENT;
  }

  Object o = peekStack();
  if (o instanceof Iterator) {
    boolean isObject = stack.get(stack.size() - 2) instanceof JsonObject;
    Iterator<?> iterator = (Iterator<?>) o;
    if (iterator.hasNext()) {
      if (isObject) {
        return JsonToken.NAME;
      } else {
        stack.add(iterator.next());
        return peek();
      }
    } else {
      return isObject ? JsonToken.END_OBJECT : JsonToken.END_ARRAY;
    }
  } else if (o instanceof JsonObject) {
    return JsonToken.BEGIN_OBJECT;
  } else if (o instanceof JsonArray) {
    return JsonToken.BEGIN_ARRAY;
  } else if (o instanceof JsonPrimitive) {
    JsonPrimitive primitive = (JsonPrimitive) o;
    if (primitive.isString()) {
      return JsonToken.STRING;
    } else if (primitive.isBoolean()) {
      return JsonToken.BOOLEAN;
    } else if (primitive.isNumber()) {
      return JsonToken.NUMBER;
    } else {
      throw new AssertionError();
    }
  } else if (o instanceof JsonNull) {
    return JsonToken.NULL;
  } else if (o == SENTINEL_CLOSED) {
    throw new IllegalStateException("JsonReader is closed");
  } else {
    throw new AssertionError();
  }
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:42,代碼來源:JsonTreeReader.java

示例10: read

public BitSet read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    BitSet bitset = new BitSet();
    in.beginArray();
    int i = 0;
    JsonToken tokenType = in.peek();
    while (tokenType != JsonToken.END_ARRAY) {
        boolean set;
        switch (tokenType) {
            case NUMBER:
                if (in.nextInt() == 0) {
                    set = false;
                    break;
                }
                set = true;
                break;
            case BOOLEAN:
                set = in.nextBoolean();
                break;
            case STRING:
                String stringValue = in.nextString();
                try {
                    set = Integer.parseInt(stringValue) != 0;
                    break;
                } catch (NumberFormatException e) {
                    throw new JsonSyntaxException("Error: Expecting: bitset number value " +
                            "(1, 0), Found: " + stringValue);
                }
            default:
                throw new JsonSyntaxException("Invalid bitset value type: " + tokenType);
        }
        if (set) {
            bitset.set(i);
        }
        i++;
        tokenType = in.peek();
    }
    in.endArray();
    return bitset;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:43,代碼來源:TypeAdapters.java

示例11: readMessage

public static <T> int readMessage(JsonReader reader,String tableName,Class<T> clazz,long last_sync_ts) throws IOException, JSONException,Exception {    
String n = null;
int i=0;

 		while (reader.hasNext()) {
 			JsonToken peek=reader.peek();

 			String v = null;
 			if (peek==JsonToken.BEGIN_OBJECT) {
 				reader.beginObject();
 			} else if (peek==JsonToken.NAME) {
 				n=reader.nextName();
 			} else if (peek==JsonToken.BEGIN_ARRAY) {   				
 				if (n.equals(tableName)) {
 					i=readJsnArr(reader,tableName,clazz);
 					
 				} else {
 					if (n.equals("params")) {
 						reader.beginArray();
 						if (reader.hasNext()) {
 						reader.beginObject();
 						if (reader.hasNext()) {
  						n=reader.nextName();
  						v=reader.nextString();
 						}
 						reader.endObject();
 						}
 						reader.endArray();
 					} else {
 						reader.skipValue();
 					}
 				}
 			} else if (peek==JsonToken.END_OBJECT) {
 				reader.endObject();
 			} else if (peek==JsonToken.END_ARRAY) {
 				reader.endArray();
 			} else if (peek==JsonToken.STRING) {
              reader.skipValue();
          } else {
              reader.skipValue();
          }
 		}
 		return i;      
  }
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:44,代碼來源:FlowzrSyncEngine.java


注:本文中的com.google.gson.stream.JsonToken.END_ARRAY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。