Package com.massivecraft.mcore.xlib.gson

Examples of com.massivecraft.mcore.xlib.gson.JsonElement


  {
    JsonArray in = inElement.getAsJsonArray();
    BasicDBList out = new BasicDBList();
    for (int i = 0; i < in.size(); i++)
    {
      JsonElement element = in.get(i);
      if (element.isJsonArray())
      {
        out.add(gson2MongoArray(element));
      }
      else if (element.isJsonObject())
      {
        out.add(gson2MongoObject(element));
      }
      else
      {
View Full Code Here


   * @since 1.3
   */
  public JsonElement parse(Reader json) throws JsonIOException, JsonSyntaxException {
    try {
      JsonReader jsonReader = new JsonReader(json);
      JsonElement element = parse(jsonReader);
      if (!element.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) {
        throw new JsonSyntaxException("Did not consume the entire document.");
      }
      return element;
    } catch (MalformedJsonException e) {
      throw new JsonSyntaxException(e);
View Full Code Here

    this.clearSynclog(id);
   
    E entity = this.id2entity.get(id);
    if (entity == null) return;
   
    JsonElement raw = this.getGson().toJsonTree(entity, this.getEntityClass());
    this.lastRaw.put(id, raw);
   
    if (this.isDefault(entity))
    {
      this.db.getDriver().delete(this, id);
View Full Code Here

    this.clearIdentifiedChanges(id);
   
    Entry<JsonElement, Long> entry = this.getDriver().load(this, id);
    if (entry == null) return;
   
    JsonElement raw = entry.getKey();
    if (raw == null) return;
   
    Long mtime = entry.getValue();
    if (mtime == null) return;
   
View Full Code Here

    return ModificationState.NONE;
  }
 
  protected boolean examineHasLocalAlter(String id, E entity)
  {
    JsonElement lastRaw = this.lastRaw.get(id);
    JsonElement currentRaw = this.getGson().toJsonTree(entity, this.getEntityClass());
   
    return !MStore.equal(lastRaw, currentRaw);
  }
View Full Code Here

    if (raw == null) return null;
   
    Long mtime = ((Number)raw.removeField(MTIME_FIELD)).longValue();
    raw.removeField(ID_FIELD);
   
    JsonElement element = GsonMongoConverter.mongo2GsonObject(raw);
   
    return new SimpleEntry<JsonElement, Long>(element, mtime);
  }
View Full Code Here

    Long mtime = file.lastModified();
    if (mtime == 0) return null;
    String content = DiscUtil.readCatch(file);
    if (content == null) return null;
    if (content.length() == 0) return null;
    JsonElement raw = new JsonParser().parse(content);
    return new SimpleEntry<JsonElement, Long>(raw, mtime);
  }
View Full Code Here

    rename(jsonObject, "permOverrides", "perms");
  }
 
  public void rename(final JsonObject jsonObject, final String from, final String to)
  {
    JsonElement element = jsonObject.remove(from);
    if (element != null) jsonObject.add(to, element);
  }
View Full Code Here

    // The return value is this object:
    JsonObject jsonInventory = new JsonObject();
   
    // These variables are used in loops and repetitive logic.
    ItemStack itemStack = null;
    JsonElement jsonItemStack = null;
   
    // Every inventory has a content part.
    ItemStack[] itemStacks = src.getContents();
   
    if (src instanceof PlayerInventory)
View Full Code Here

    // The return value
    Inventory ret = null;
   
    // These variables are used in loops and repetitive logic.
    ItemStack itemStack = null;
    JsonElement jsonItemStack = null;
   
    // There must be a size entry!
    if ( ! jsonInventory.has(SIZE)) return null;
   
    JsonPrimitive jsonSize = jsonInventory.get(SIZE).getAsJsonPrimitive();
View Full Code Here

TOP

Related Classes of com.massivecraft.mcore.xlib.gson.JsonElement

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.