public JsonRepresentation getRepresentation(final String pathTemplate, final Object... args) { final String pathStr = String.format(pathTemplate, args); final JsonNode node = getNode(pathStr); if (representsNull(node)) { return null; } return new JsonRepresentation(node); }
private JsonRepresentation getArrayEnsured(final String path, final JsonNode node) { if (representsNull(node)) { return null; } return new JsonRepresentation(node).ensureArray(); }
private boolean isDecimal(final JsonNode node) { return !representsNull(node) && node.isValueNode() && node.isDouble(); }
private boolean isLong(final JsonNode node) { return !representsNull(node) && node.isValueNode() && node.isLong(); }
private JsonRepresentation getArray(final String path, final JsonNode node) { if (representsNull(node)) { return null; } if (!isArray(node)) { throw new IllegalArgumentException(formatExMsg(path, "is not an array")); } return new JsonRepresentation(node); }
private Float getFloat(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a float"); if (!node.isNumber()) { throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue().floatValue(); }
private Byte getByte(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "an byte"); if (!node.isNumber()) { // there is no node.isByte() throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue().byteValue(); }
private Short getShort(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "an short"); if (!node.isNumber()) { // there is no node.isShort() throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue().shortValue(); }
private JsonRepresentation getMap(final String path, final JsonNode node) { if (representsNull(node)) { return null; } if (isArray(node) || node.isValueNode()) { throw new IllegalArgumentException(formatExMsg(path, "is not a map")); } return new JsonRepresentation(node); }
private Number getNumber(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a number"); if (!node.isNumber()) { throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue(); }
private Integer getInt(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "an int"); if (!node.isInt()) { throw new IllegalArgumentException(formatExMsg(path, "is not an int")); } return node.getIntValue(); }
private String getString(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a string"); if (!node.isTextual()) { throw new IllegalArgumentException(formatExMsg(path, "is not a string")); } return node.getTextValue(); }
private java.util.Date getDateTime(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a date-time"); if (!node.isTextual()) { throw new IllegalArgumentException(formatExMsg(path, "is not a date-time")); } final String textValue = node.getTextValue(); return new java.util.Date(yyyyMMddTHHmmssZ.parseMillis(textValue)); }
private java.util.Date getDate(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a date"); if (!node.isTextual()) { throw new IllegalArgumentException(formatExMsg(path, "is not a date")); } final String textValue = node.getTextValue(); return new java.util.Date(yyyyMMdd.parseMillis(textValue)); }
private Double getDouble(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a double"); if (!node.isDouble()) { throw new IllegalArgumentException(formatExMsg(path, "is not a double")); } return node.getDoubleValue(); }
private Boolean getBoolean(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a boolean"); if (!node.isBoolean()) { throw new IllegalArgumentException(formatExMsg(path, "is not a boolean")); } return node.getBooleanValue(); }
private java.util.Date getTime(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a time"); if (!node.isTextual()) { throw new IllegalArgumentException(formatExMsg(path, "is not a time")); } final String textValue = node.getTextValue(); final LocalTime localTime = _HHmmss.parseLocalTime(textValue + "Z"); return new java.util.Date(localTime.getMillisOfDay()); }
public boolean isLink(final JsonNode node) { if (representsNull(node) || isArray(node) || node.isValueNode()) { return false; } final LinkRepresentation link = new LinkRepresentation(node); if (link.getHref() == null) { return false; } return true; }
private Long getLong(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a long"); if(node.isInt()) { return Long.valueOf(node.getIntValue()); } if(node.isLong()) { return node.getLongValue(); } throw new IllegalArgumentException(formatExMsg(path, "is not a long")); }
private boolean isBigDecimal(final JsonNode node) { return !representsNull(node) && node.isValueNode() && (node.isBigDecimal() || node.isDouble() || node.isLong() || node.isInt() || node.isBigInteger() || node.isTextual() && parseableAsBigDecimal(node.getTextValue())); }