private static String handleCommandResult(CommandResult object) { StringBuilder sb = new StringBuilder(); sb.append(" Status : " + object.getStatus()).append(NEW_LINE); try { sb.append(" Raw JSON : " + object.getContent().toIndentedString(5)); sb.append(NEW_LINE); } catch (GfJsonException e) { sb.append(" Error getting raw JSON : " + e.getMessage()); logError(" Error getting raw JSON : ", e); } return sb.toString(); }
public GfJsonObject put(String key, Map<?, ?> value) throws GfJsonException { try { jsonObject.put(key, value); } catch (JSONException e) { throw new GfJsonException(e.getMessage()); } return this; }
public GfJsonArray getHeaders() { try { return this.contentObject.names(); } catch (GfJsonException e) { e.printStackTrace(); } return null; }
public static byte[] toByteArray(GfJsonArray jsonArray) throws GfJsonException { byte[] byteArray = null; if (jsonArray != null) { int length = jsonArray.size(); byteArray = new byte[length]; for (int i = 0; i < length; i++) { try { byteArray[i] = Byte.valueOf(String.valueOf(jsonArray.get(i))); } catch (NumberFormatException e) { throw e; } catch (GfJsonException e) { throw new GfJsonException(e.getMessage()); } } } return byteArray ; }
jsonBean = new GfJsonObject(); try { jsonBean.put("msg", e.getMessage()); } catch (GfJsonException e1) { jsonBean = new GfJsonObject(str); } catch (GfJsonException e) { e.printStackTrace(); jsonBean = new GfJsonObject(); try { jsonBean.put("msg", e.getMessage()); } catch (GfJsonException e1) { } catch (GfJsonException e) { logger.warning(e); return DataCommandResult.createSelectResult(queryString, null, queryVerboseMsg, e, e.getMessage(), false); }finally{ if(queryObserver!=null){
public static byte[] toByteArray(GfJsonArray jsonArray) throws GfJsonException { byte[] byteArray = null; if (jsonArray != null) { int length = jsonArray.size(); byteArray = new byte[length]; for (int i = 0; i < length; i++) { try { byteArray[i] = Byte.valueOf(String.valueOf(jsonArray.get(i))); } catch (NumberFormatException e) { throw e; } catch (GfJsonException e) { throw new GfJsonException(e.getMessage()); } } } return byteArray ; }
public ObjectResultData<T> addObject(T infoBean) { try { contentObject.accumulateAsJSONObject(OBJECTS_ACCESSOR, infoBean); } catch (GfJsonException e) { throw new ResultDataException(e.getMessage()); } return this; }
public GfJsonObject put(String key, Map<?, ?> value) throws GfJsonException { try { jsonObject.put(key, value); } catch (JSONException e) { throw new GfJsonException(e.getMessage()); } return this; }
public GfJsonArray getHeaders() { try { return this.contentObject.names(); } catch (GfJsonException e) { e.printStackTrace(); } return null; }
public SectionResultData setFooter(String footerText) { try { sectionGfJsonObject.put(RESULT_FOOTER, footerText); } catch (GfJsonException e) { throw new ResultDataException(e.getMessage()); } return this; }
/** * * @param source * @throws GfJsonException If there is a syntax error. */ public GfJsonArray(String source) throws GfJsonException { try { this.jsonArray = new JSONArray(source); } catch (JSONException e) { throw new GfJsonException(e.getMessage()); } }
public boolean hasIncomingFiles() { GfJsonArray fileDataArray = null; try { GfJsonObject content = getContent(); if (content != null) { fileDataArray = content.getJSONArray(CompositeResultData.BYTE_DATA_ACCESSOR); } } catch (GfJsonException e) { e.printStackTrace(); } return fileDataArray != null; }
public TabularResultData accumulate(String accumulateFor, Object value) { try { contentObject.accumulate(accumulateFor, value); } catch (GfJsonException e) { throw new ResultDataException(e.getMessage()); } return this; }
/** * * @param source * @throws GfJsonException If there is a syntax error. */ public GfJsonArray(String source) throws GfJsonException { try { this.jsonArray = new JSONArray(source); } catch (JSONException e) { throw new GfJsonException(e.getMessage()); } }
public boolean hasIncomingFiles() { GfJsonArray fileDataArray = null; try { GfJsonObject content = getContent(); if (content != null) { fileDataArray = content.getJSONArray(CompositeResultData.BYTE_DATA_ACCESSOR); } } catch (GfJsonException e) { e.printStackTrace(); } return fileDataArray != null; }
public CompositeResultData addSeparator(char buildSeparatorFrom) { try { contentObject.put(SEPARATOR, buildSeparatorFrom); } catch (GfJsonException e) { throw new ResultDataException(e.getMessage()); } return this; }
/** * * @param indentFactor * @return this GfJsonObject * @throws GfJsonException * If the object contains an invalid number. */ public String toIndentedString(int indentFactor) throws GfJsonException { try { return jsonObject.toString(indentFactor); } catch (JSONException e) { throw new GfJsonException(e.getMessage()); } }
private static String objectToJsonNestedChkCDep(Object object, int length, boolean checkCyclicDep) { GfJsonObject jsonObject = new GfJsonObject(object,checkCyclicDep); Iterator<String> iterator = jsonObject.keys(); while(iterator.hasNext()){ String key = iterator.next(); Object value = jsonObject.get(key); if(value!=null && !isPrimitiveOrWrapper(value.getClass())){ GfJsonObject jsonified = new GfJsonObject(value); String stringified = jsonified.toString(); try{ if(stringified.length()>length){ jsonObject.put(key,jsonified.getType()); }else{ jsonObject.put(key, stringified); } }catch (GfJsonException e) { e.printStackTrace(); } } } return jsonObject.toString(); }
public SectionResultData setHeader(String headerText) { try { sectionGfJsonObject.put(RESULT_HEADER, headerText); } catch (GfJsonException e) { throw new ResultDataException(e.getMessage()); } return this; }
/** * * @param indentFactor * @return this GfJsonArray * @throws GfJsonException * If the object contains an invalid number. */ public String toIndentedString(int indentFactor) throws GfJsonException { try { return jsonArray.toString(indentFactor); } catch (JSONException e) { throw new GfJsonException(e.getMessage()); } }