Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. if ((parserFailureConditions != null)
  2. && (parserFailureConditions.length != 0)) {
  3. numberOfParserFailureConditions = getNumberOfFailureConditions(parserFailureConditions[0]);
  4. }
  5.  
  6. /*
  7. * As the the passed array holds JSON String at first location,
  8. * this method initialize the 'number_failureConditions' based on no. of JSON elements.
  9. */
  10. public int getNumberOfFailureConditions(String condition) {
  11. int number_failureConditions = 0;
  12. if ((condition != null) && (condition.startsWith("["))) {
  13. try {
  14. JSONArray temp_object_array = new JSONArray(condition);
  15. for (int i = 0; i < temp_object_array.length(); i++) {
  16. number_failureConditions++;
  17. }
  18. } catch (JSONException ex) {
  19. System.out.println("Could not create JSONArray");
  20. }
  21. } else if ((condition != null) && (condition.startsWith("{"))) {
  22. for (@SuppressWarnings("unused")
  23. String retval : condition.split("}")) {
  24. if (number_failureConditions < 50) {
  25. number_failureConditions++;
  26. }
  27. }
  28. } else {
  29. if (condition != null) {
  30. System.out.println("Invalid condition");
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement