@Override public void setFromJSON(String json) throws JsonException { id = SerializationUtils.fromJson(json); }
@Override public String toJson() { return SerializationUtils.toJson(documentMap); }
/** * Functionally the same as calling SerializationUtils.toObject(<pre>json</pre>).getClass() */ public static Class<?> getResultingClass(String json) { try { return toObject(json).getClass(); } catch (JsonException e) { return null; } }
/** * Method for verifying what class the passed Object will get if serialized and then deserialized via this class. */ public static Class<?> getResultingClass(Object o) { return getResultingClass(toJson(o)); }
@Override public String toJSON() { return SerializationUtils.toJson(id); }
public static AbstractProcessStage fromJsonString(String json) throws JsonException, ClassNotFoundException, InstantiationException, IllegalAccessException, InitFailedException, RequiredArgumentMissingException { Map<String, Object> properties = SerializationUtils.fromJson(json); return fromMap(properties); }
public static LocalDocumentID getDocumentID(String json) throws JsonException { return new LocalDocumentID(SerializationUtils.toObject(json)); }
@Override public String toJSON() { return SerializationUtils.toJson(id); }
@Override public void setFromJSON(String json) throws JsonException { id = toObjectId(SerializationUtils.fromJson(json)); }
@Override public DocumentID<MongoType> toDocumentIdFromJson(String json) { try { return toDocumentId(SerializationUtils.toObject(json)); } catch (JsonException e) { logger.error("Error deserializing json", e); return null; } }
@Override public String toString() { return SerializationUtils.toJson(this); }
public static MongoDocumentID getDocumentID(String json) throws JsonException { return getDocumentID(SerializationUtils.fromJson(json)); }
@SuppressWarnings("unchecked") public static List<String> getStages(String host, int port, String group) throws IOException { HttpConnection connection = new HttpConnection(host, port); HttpResponse response = connection.get("/"+GET_STAGES_URL+"?"+GROUP_PARAM+"="+group); if(response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { logger.error("Unable to get list stages in the group"); return new ArrayList<String>(); } try { return (List<String>) SerializationUtils.toObject(EntityUtils.toString(response.getEntity())); } catch (JsonException e) { logger.error("Unable to deserialize list of stages", e); return new ArrayList<String>(); } } }
public static ObjectId getObjectId(String json) throws JsonException { return toObjectId(SerializationUtils.fromJson(json)); }
/** * Method for Deserializing any Json message into a Map. * Should the Json message not be a map, it will be wrapped in a map, corresponding to * the JSON: <code>{ "" : <original_json> }</code> */ @SuppressWarnings("unchecked") public static Map<String, Object> fromJson(String json) throws JsonException { try { Object o = toObject(json); if(o instanceof Map) { return (Map<String, Object>) o; } else { HashMap<String, Object> x = new HashMap<String, Object>(); x.put("", o); return x; } } catch(JsonParseException e) { throw new JsonException(e); } }
@Override public String toString() { return SerializationUtils.toJson(stageGroups.values()); }
private static Map<String, Object> readPropertiesFile(String filename) { String json = ""; try { json = readFileAsString(filename); } catch (IOException e) { System.err.println("Property file " + filename + " could not be read"); System.exit(-1); } try { return SerializationUtils.fromJson(json); } catch (JsonException e) { System.err.println("Property file " + filename + " is not well formed json"); System.exit(-1); } return null; }
@SuppressWarnings("unchecked") public List<String> getFileNames(DocumentID<?> docid) { try { HttpResponse response = core.get(fileUrl + "&" + HttpEndpointConstants.DOCID_PARAM + "=" + URLEncoder.encode(docid.toJSON(), "UTF-8")); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { try { return (List<String>) SerializationUtils.toObject(EntityUtils.toString(response.getEntity())); } catch (JsonException e) { throw new IOException(e); } } else { logUnexpected("getFileNames()", response); return null; } } catch (IOException e) { throw new RuntimeException(e); } }
public String toJson() { Map<String, Object> x = new HashMap<String, Object>(); x.put("equals", equals); x.put("notEquals", notEquals); x.put("exists", exists); x.put("touched", touched); if(action!=null) { x.put("action", action.toString()); } return SerializationUtils.toJson(x); }