Package com.google.gwt.thirdparty.json

Examples of com.google.gwt.thirdparty.json.JSONObject


public class JsonLogRecordServerUtil {

  public static LogRecord logRecordFromJson(String jsonString)
      throws InvalidJsonLogRecordFormatException {
    try {
      JSONObject lro = new JSONObject(jsonString);
      String level = lro.getString("level");
      String loggerName = lro.getString("loggerName");
      String msg = lro.getString("msg");
      long timestamp = Long.parseLong(lro.getString("timestamp"));
      Throwable thrown = JsonLogRecordThrowable.fromJsonString(lro.getString("thrown"));
      LogRecord lr = new LogRecord(Level.parse(level), msg);
      lr.setLoggerName(loggerName);
      lr.setThrown(thrown);
      lr.setMillis(timestamp);
      return lr;
View Full Code Here


    private static Throwable fromJsonString(String jsonString) throws JSONException {
      if (jsonString.equals("{}")) {
        return null;
      }
      return new JsonLogRecordThrowable(new JSONObject(jsonString));
    }
View Full Code Here

      }
      return stackTrace;
    }

    private StackTraceElement stackTraceElementFromJson(String jsonString) throws JSONException {
      JSONObject ste = new JSONObject(jsonString);
      String className = ste.getString("className");
      String fileName = ste.getString("fileName");
      String methodName = ste.getString("methodName");
      int lineNumber = Integer.parseInt(ste.getString("lineNumber"));
      return new StackTraceElement(className, methodName, fileName, lineNumber);
    }
View Full Code Here

* Uses the org.json packages to slice and dice request payloads.
*/
public class JsonSplittable implements Splittable, HasSplittable {

  public static JsonSplittable create() {
    return new JsonSplittable(new JSONObject());
  }
View Full Code Here

  public static Splittable create(String payload) {
    try {
      switch (payload.charAt(0)) {
        case '{':
          return new JsonSplittable(new JSONObject(payload));
        case '[':
          return new JsonSplittable(new JSONArray(payload));
        case '"':
          return new JsonSplittable(new JSONArray("[" + payload + "]").getString(0));
        case '-':
View Full Code Here

  private void checkEntities(File sizeMap, File dependency,
      Map<String, SimpleSymbolData> symbolTable, File entitiesFile)
      throws Exception {
    Map<String, ClassDescriptor> clsMap =
          EntityDescriptorJsonTranslator.readJson(new JSONObject(stringContent(entitiesFile)))
              .getAllClassesByName();
    SAXParser parser = SAXParserFactory.newInstance().newSAXParser();

    parser.reset();
    parser.parse(new GZIPInputStream(new FileInputStream(sizeMap)), checkStories(clsMap));
View Full Code Here

    };
  }

  private void checkSplitPloints(File origSplitPoints, File fragmentsFile)
      throws Exception {
    JSONObject jsPoints = new JSONObject(stringContent(fragmentsFile));
    final JSONArray initSeq = (JSONArray) jsPoints.opt(EntityRecorder.INITIAL_SEQUENCE);
    if (initSeq != null) {
      // Considering stable order on "initial sequence". May be this is too strict, in that case,
      // we need to store the elements in a list and provide a search method
      JSONArray fragments = (JSONArray) jsPoints.get(EntityRecorder.FRAGMENTS);
      final Map<Integer, JSONObject> fragmentById = Maps.newHashMap();
      for (int i = 0; i < fragments.length(); i++) {
        JSONObject spoint = fragments.getJSONObject(i);
        fragmentById.put(spoint.getInt(EntityRecorder.FRAGMENT_ID), spoint);
      }
      SAXParserFactory.newInstance().newSAXParser().parse(
          new GZIPInputStream(new FileInputStream(origSplitPoints)),
          new DefaultHandler() {
            int isIdx = 0;
View Full Code Here

    toReturn.add(artifact);
    return named;
  }

  private void recordFragments(JProgram jprogram) throws IOException, JSONException {
    JSONObject jsonPoints = new JSONObject();
    // adding runAsyncs, if any
    FragmentPartitioningResult partitionResult = jprogram.getFragmentPartitioningResult();
    // a FragmentPartitioningResult' instance exist if and only if there are runAyncs nodes
    if (partitionResult != null) {
      Map<Integer, Set<String>> runAsyncPerFragment = Maps.newHashMap();
      for (JRunAsync runAsync : jprogram.getRunAsyncs()) {
        int fragmentId = partitionResult.getFragmentForRunAsync(runAsync.getRunAsyncId());
        Set<String> runAsyncNames = runAsyncPerFragment.get(fragmentId);
        if (runAsyncNames == null) {
          runAsyncNames = Sets.newHashSet();
        }
        runAsyncNames.add(runAsync.getName());
        runAsyncPerFragment.put(fragmentId, runAsyncNames);
      }
      for (Integer idx : runAsyncPerFragment.keySet()) {
        sizeMetrics[idx].put(FRAGMENT_POINTS, runAsyncPerFragment.get(idx));
      }
      // initial fragment sequence points
      JSONArray initialSequence = new JSONArray();
      for (int fragId : jprogram.getInitialFragmentIdSequence()) {
        initialSequence.put(partitionResult.getFragmentForRunAsync(fragId));
      }
      jsonPoints.put(INITIAL_SEQUENCE, initialSequence);
    }

    jsonPoints.put(FRAGMENTS, this.sizeMetrics);
    addArtifactFromJson(jsonPoints, FRAGMENTS + permutationId + ".json");
  }
View Full Code Here

  public static final String METHODS           = "methods";
  public static final String CLASSES           = "classes";
  public static final String PACKAGES          = "packages";

  private static JSONObject writeJsonFromEntity(EntityDescriptor entity) throws JSONException {
    JSONObject json = new JSONObject();
    JSONArray fragments = new JSONArray();
    for (EntityDescriptor.Fragment frg : entity.getFragments()) {
      JSONObject frag = new JSONObject();
      frag.put(EntityRecorder.FRAGMENT_ID, frg.getId());
      frag.put(EntityRecorder.FRAGMENT_SIZE, frg.getSize());

      fragments.put(frag);
    }
    json.put(EntityRecorder.FRAGMENTS, fragments);
    json.put(ENTITY_JS, new JSONArray(entity.getObfuscatedNames()));
View Full Code Here

    json.put(ENTITY_JS, new JSONArray(entity.getObfuscatedNames()));
    return json;
  }

  private static JSONObject writeJsonFromMember(MemberDescriptor entity) throws JSONException {
    JSONObject json = writeJsonFromEntity(entity);
    json.put(ENTITY_NAME, entity.getJsniSignature());
    return json;
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.thirdparty.json.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.