Java Code Examples for org.codehaus.jettison.json.JSONArray#getInt()

The following examples show how to use org.codehaus.jettison.json.JSONArray#getInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GPOType.java    From attic-apex-malhar with Apache License 2.0 6 votes vote down vote up
@Override
public void setFieldFromJSON(GPOMutable gpo, String field, JSONArray jo, int index)
{
  int val;

  try {
    val = jo.getInt(index);
  } catch (JSONException ex) {
    throw new IllegalArgumentException("The key " + field + " does not have a valid byte value.", ex);
  }

  if (val < (int)Byte.MIN_VALUE) {
    throw new IllegalArgumentException("The key " + field + " has a value " + val
        + " which is too small to fit into a byte.");
  }

  if (val > (int)Byte.MAX_VALUE) {
    throw new IllegalArgumentException("The key " + field + " has a value " + val
        + " which is too larg to fit into a byte.");
  }

  gpo.setField(field, (byte)val);
}
 
Example 2
Source File: GPOType.java    From attic-apex-malhar with Apache License 2.0 6 votes vote down vote up
@Override
public void setFieldFromJSON(GPOMutable gpo, String field, JSONArray jo, int index)
{
  int val;

  try {
    val = jo.getInt(index);
  } catch (JSONException ex) {
    throw new IllegalArgumentException("The key " + field + " does not have a valid short value.", ex);
  }

  if (val < (int)Short.MIN_VALUE) {
    throw new IllegalArgumentException("The key " + field + " has a value " + val
        + " which is too small to fit into a short.");
  }

  if (val > (int)Short.MAX_VALUE) {
    throw new IllegalArgumentException("The key " + field + " has a value " + val
        + " which is too large to fit into a short.");
  }

  gpo.setField(field, (short)val);
}
 
Example 3
Source File: GraphBackedDiscoveryServiceTest.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Override
public void validateResult(String dslQuery, JSONArray foundRows) throws JSONException {
    assertEquals(foundRows.length(), expectedCounts.size());
    for (int i = 0; i < foundRows.length(); i++) {

        JSONArray row = foundRows.getJSONArray(i);
        assertEquals(row.length(), 1);
        int foundCount = row.getInt(countColumn);
      //  assertTrue(expectedCounts.contains(foundCount));
    }
}
 
Example 4
Source File: GPOType.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
@Override
public void setFieldFromJSON(GPOMutable gpo, String field, JSONArray jo, int index)
{
  int val;

  try {
    val = jo.getInt(index);
  } catch (JSONException ex) {
    throw new IllegalArgumentException("The key " + field + " does not have a valid int value.", ex);
  }

  gpo.setField(field, val);
}