Package org.json.simple

Examples of org.json.simple.JSONObject


    throws IOException, HadoopException {
    path.makeAbsolute();
    MDC.put("op", "DELETE");
    AUDIT_LOG.info("[{}] recursive [{}]", path, recursive);
    FSDelete command = new FSDelete(path.value(), recursive.value());
    JSONObject json = fsExecute(user, doAs.value(), command);
    return Response.ok(json).type(MediaType.APPLICATION_JSON).build();
  }
View Full Code Here


        response = Response.ok().type(MediaType.APPLICATION_JSON).build();
        break;
      }
      case RENAME: {
        FSRename command = new FSRename(path.value(), toPath.value());
        JSONObject json = fsExecute(user, doAs.value(), command);
        AUDIT_LOG.info("[{}] to [{}]", path, toPath);
        response = Response.ok(json).type(MediaType.APPLICATION_JSON).build();
        break;
      }
      case SETOWNER: {
        FSSetOwner command = new FSSetOwner(path.value(), owner.value(), group.value());
        fsExecute(user, doAs.value(), command);
        AUDIT_LOG.info("[{}] to (O/G)[{}]", path, owner.value() + ":" + group.value());
        response = Response.ok().build();
        break;
      }
      case SETPERMISSION: {
        FSSetPermission command = new FSSetPermission(path.value(), permission.value());
        fsExecute(user, doAs.value(), command);
        AUDIT_LOG.info("[{}] to [{}]", path, permission.value());
        response = Response.ok().build();
        break;
      }
      case SETREPLICATION: {
        FSSetReplication command = new FSSetReplication(path.value(), replication.value());
        JSONObject json = fsExecute(user, doAs.value(), command);
        AUDIT_LOG.info("[{}] to [{}]", path, replication.value());
        response = Response.ok(json).build();
        break;
      }
      case SETTIMES: {
View Full Code Here

        response = Response.created(uri).type(MediaType.APPLICATION_JSON).build();
        break;
      }
      case MKDIRS: {
        FSMkdirs command = new FSMkdirs(path.value(), permission.value());
        JSONObject json = fsExecute(user, doAs.value(), command);
        AUDIT_LOG.info("[{}] permission [{}]", path, permission.value());
        response = Response.ok(json).type(MediaType.APPLICATION_JSON).build();
        break;
      }
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    private JSONObject getJSON() {
      long[] values = getValues();
      JSONObject json = new JSONObject();
      json.put("lastTotal", values[0]);
      json.put("lastOwn", values[1]);
      json.put("avgTotal", values[2]);
      json.put("avgOwn", values[3]);
      return json;
    }
View Full Code Here

      this.var = var;
    }

    @SuppressWarnings("unchecked")
    private JSONObject getJSON() {
      JSONObject json = new JSONObject();
      json.put("value", var.getValue());
      return json;
    }
View Full Code Here

      return ((double) sum.get()) / ((full) ? values.length : ((last == 0) ? 1 : last));
    }

    @SuppressWarnings("unchecked")
    private JSONObject getJSON() {
      JSONObject json = new JSONObject();
      json.put("sampler", getRate());
      json.put("size", (full) ? values.length : last);
      return json;
    }
View Full Code Here

    JSONMapProvider p = new JSONMapProvider();
    Assert.assertTrue(p.isWriteable(Map.class, null, null, null));
    Assert.assertFalse(p.isWriteable(XTest.class, null, null, null));
    Assert.assertEquals(p.getSize(null, null, null, null, null), -1);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    JSONObject json = new JSONObject();
    json.put("a", "A");
    p.writeTo(json, JSONObject.class, null, null, null, null, baos);
    baos.close();
    Assert.assertEquals(new String(baos.toByteArray()).trim(), "{\"a\":\"A\"}");
  }
View Full Code Here

    JSONProvider p = new JSONProvider();
    Assert.assertTrue(p.isWriteable(JSONObject.class, null, null, null));
    Assert.assertFalse(p.isWriteable(XTest.class, null, null, null));
    Assert.assertEquals(p.getSize(null, null, null, null, null), -1);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    JSONObject json = new JSONObject();
    json.put("a", "A");
    p.writeTo(json, JSONObject.class, null, null, null, null, baos);
    baos.close();
    Assert.assertEquals(new String(baos.toByteArray()).trim(), "{\"a\":\"A\"}");
  }
View Full Code Here

    Assert.assertEquals(values[InstrumentationService.Timer.LAST_TOTAL], totalDelta, 20);
    Assert.assertEquals(values[InstrumentationService.Timer.LAST_OWN], ownDelta, 20);
    Assert.assertEquals(values[InstrumentationService.Timer.AVG_TOTAL], avgTotal, 20);
    Assert.assertEquals(values[InstrumentationService.Timer.AVG_OWN], avgOwn, 20);

    JSONObject json = (JSONObject) new JSONParser().parse(timer.toJSONString());
    Assert.assertEquals(json.size(), 4);
    Assert.assertEquals(json.get("lastTotal"), values[InstrumentationService.Timer.LAST_TOTAL]);
    Assert.assertEquals(json.get("lastOwn"), values[InstrumentationService.Timer.LAST_OWN]);
    Assert.assertEquals(json.get("avgTotal"), values[InstrumentationService.Timer.AVG_TOTAL]);
    Assert.assertEquals(json.get("avgOwn"), values[InstrumentationService.Timer.AVG_OWN]);

    StringWriter writer = new StringWriter();
    timer.writeJSONString(writer);
    writer.close();
    json = (JSONObject) new JSONParser().parse(writer.toString());
    Assert.assertEquals(json.size(), 4);
    Assert.assertEquals(json.get("lastTotal"), values[InstrumentationService.Timer.LAST_TOTAL]);
    Assert.assertEquals(json.get("lastOwn"), values[InstrumentationService.Timer.LAST_OWN]);
    Assert.assertEquals(json.get("avgTotal"), values[InstrumentationService.Timer.AVG_TOTAL]);
    Assert.assertEquals(json.get("avgOwn"), values[InstrumentationService.Timer.AVG_OWN]);
  }
View Full Code Here

    Assert.assertEquals(sampler.getRate(), (0d + 1 + 2 + 3) / 4, 0.0001);
    value[0] = 4;
    sampler.sample();
    Assert.assertEquals(sampler.getRate(), (4d + 1 + 2 + 3) / 4, 0.0001);

    JSONObject json = (JSONObject) new JSONParser().parse(sampler.toJSONString());
    Assert.assertEquals(json.size(), 2);
    Assert.assertEquals(json.get("sampler"), sampler.getRate());
    Assert.assertEquals(json.get("size"), 4L);

    StringWriter writer = new StringWriter();
    sampler.writeJSONString(writer);
    writer.close();
    json = (JSONObject) new JSONParser().parse(writer.toString());
    Assert.assertEquals(json.size(), 2);
    Assert.assertEquals(json.get("sampler"), sampler.getRate());
    Assert.assertEquals(json.get("size"), 4L);
  }
View Full Code Here

TOP

Related Classes of org.json.simple.JSONObject

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.