- root = (JSONObject) parser.parse(result.getResult());
- if (result.getResultCode() >= 200 && result.getResultCode() <= 299) {
- JSONArray hitArray = (JSONArray) root.get("suggest-vnf");
- JSONObject hitdata = (JSONObject) hitArray.get(0);
- JSONArray optionsArray = (JSONArray) hitdata.get("options");
- SuggestHits suggestHits = new SuggestHits();
- suggestHits.setTotalHits(String.valueOf(optionsArray.size()));
-
- ArrayList<SuggestHit> suggestHitArray = new ArrayList<SuggestHit>();
-
- for (int i = 0; i < optionsArray.size(); i++) {
- JSONObject hit = (JSONObject) optionsArray.get(i);
-
- SuggestHit suggestHit = new SuggestHit();
- suggestHit.setScore((hit.get("score") != null) ? hit.get("score").toString() : "");
- suggestHit.setText((hit.get("text") != null) ? hit.get("text").toString() : "");
- Document doc = new Document();
- if (hit.get("_version") != null) {
- doc.setEtag((hit.get("_version") != null) ? hit.get("_version").toString() : "");
+ root = (JSONObject) parser.parse ( result.getResult () );
+ if (result.getResultCode () >= 200 && result.getResultCode () <= 299) {
+ JSONArray hitArray = (JSONArray) root.get ( "suggest-vnf" );
+ JSONObject hitdata = (JSONObject) hitArray.get ( 0 );
+ JSONArray optionsArray = (JSONArray) hitdata.get ( "options" );
+ SuggestHits suggestHits = new SuggestHits ();
+ suggestHits.setTotalHits ( String.valueOf ( optionsArray.size () ) );
+
+ ArrayList<SuggestHit> suggestHitArray = new ArrayList<SuggestHit> ();
+
+ for (int i = 0; i < optionsArray.size (); i++) {
+ JSONObject hit = (JSONObject) optionsArray.get ( i );
+
+ SuggestHit suggestHit = new SuggestHit ();
+ suggestHit.setScore ( (hit.get ( "score" ) != null) ? hit.get ( "score" ).toString () : "" );
+ suggestHit.setText ( (hit.get ( "text" ) != null) ? hit.get ( "text" ).toString () : "" );
+ Document doc = new Document ();
+ if (hit.get ( "_version" ) != null) {
+ doc.setEtag ( (hit.get ( "_version" ) != null) ? hit.get ( "_version" ).toString () : "" );