Last active
August 29, 2015 14:14
-
-
Save swapnil-kotwal-sp/8bec8b6c73283f048be5 to your computer and use it in GitHub Desktop.
Code Snippets for conditions check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ((parserFailureConditions != null) | |
&& (parserFailureConditions.length != 0)) { | |
numberOfParserFailureConditions = getNumberOfFailureConditions(parserFailureConditions[0]); | |
} | |
/* | |
* As the the passed array holds JSON String at first location, | |
* this method initialize the 'number_failureConditions' based on no. of JSON elements. | |
*/ | |
public int getNumberOfFailureConditions(String condition) { | |
int number_failureConditions = 0; | |
if ((condition != null) && (condition.startsWith("["))) { | |
try { | |
JSONArray temp_object_array = new JSONArray(condition); | |
for (int i = 0; i < temp_object_array.length(); i++) { | |
number_failureConditions++; | |
} | |
} catch (JSONException ex) { | |
System.out.println("Could not create JSONArray"); | |
} | |
} else if ((condition != null) && (condition.startsWith("{"))) { | |
for (@SuppressWarnings("unused") | |
String retval : condition.split("}")) { | |
if (number_failureConditions < 50) { | |
number_failureConditions++; | |
} | |
} | |
} else { | |
if (condition != null) { | |
System.out.println("Invalid condition"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment