connectionUtils/src/main/java/com/ge/research/semtk/sparqlX/SparqlEndpointInterface.java
protected JSONObject parseResponse(SparqlResultTypes resultType, String responseTxt) throws Exception {
		
		Object responseObj = null;
		
		if(responseTxt == null || responseTxt.trim().isEmpty()) {
			// empty
			return this.handleEmptyResponse(resultType); 
		}
		
		// check for RDF first, return { "rdf": "<rdf ....    >" } 
		
		if (resultType==SparqlResultTypes.RDF) {
			String beginning = responseTxt.length() > 100 ? responseTxt.substring(0,100) : responseTxt;
			beginning = beginning.trim();
			if (!beginning.trim().contains("<rdf")) {
				throw new Exception("non-rdf response, starting with: " + beginning);
			}
			JSONObject res = new JSONObject();
			res.put(SparqlResultTypes.RDF.toString(), responseTxt);
			return res;
		}
		
		// it now must be JSON.  Start by parsing.
		try {
			responseObj = new JSONParser().parse(responseTxt);
		} catch(Exception e) {
			
			// non-JSON
			return this.handleNonJSONResponse(responseTxt, resultType);
		}

		if (responseObj == null) {
			// empty JSON
			return this.handleNonJSONResponse(responseTxt, resultType);

		} else {
			// Normal path: get results
			return this.getResultsFromResponse(responseObj, resultType);
		}
	}
/**
	 * Parse the response to JSON and send  for results parsing
	 * @param resultType
	 * @param responseTxt
	 * @return
	 * @throws Exception
	 */
Parse the response to JSON and send  for results parsing
@param resultType
@param responseTxt
@return
@throws Exception
Parse the response to JSON and send for results parsing @param resultType @param responseTxt @return @throws Exception
protected JSONObject parseResponse(SparqlResultTypes resultType, String responseTxt) throws Exception {
		Object responseObj = null;
		if(responseTxt == null || responseTxt.trim().isEmpty()) {
			return this.handleEmptyResponse(resultType); 
		}
		if (resultType==SparqlResultTypes.RDF) {
			String beginning = responseTxt.length() > 100 ? responseTxt.substring(0,100) : responseTxt;
			beginning = beginning.trim();
			if (!beginning.trim().contains("<rdf")) {
				throw new Exception("non-rdf response, starting with: " + beginning);
			}
			JSONObject res = new JSONObject();
			res.put(SparqlResultTypes.RDF.toString(), responseTxt);
			return res;
		}
		try {
			responseObj = new JSONParser().parse(responseTxt);
		} catch(Exception e) {
			return this.handleNonJSONResponse(responseTxt, resultType);
		}
		if (responseObj == null) {
			 JSON
			return this.handleNonJSONResponse(responseTxt, resultType);
		} else {
			return this.getResultsFromResponse(responseObj, resultType);
		}
	}
protected JSONObject parseResponse ( SparqlResultTypes resultType , String responseTxt ) throws Exception { Object responseObj = null ; if ( responseTxt == null || responseTxt . trim ( ) . isEmpty ( ) ) { return this . handleEmptyResponse ( resultType ) ; } if ( resultType == SparqlResultTypes . RDF ) { String beginning = responseTxt . length ( ) > 100 ? responseTxt . substring ( 0 , 100 ) : responseTxt ; beginning = beginning . trim ( ) ; if ( ! beginning . trim ( ) . contains ( "<rdf" ) ) { throw new Exception ( "non-rdf response, starting with: " + beginning ) ; } JSONObject res = new JSONObject ( ) ; res . put ( SparqlResultTypes . RDF . toString ( ) , responseTxt ) ; return res ; } try { responseObj = new JSONParser ( ) . parse ( responseTxt ) ; } catch ( Exception e ) { return this . handleNonJSONResponse ( responseTxt , resultType ) ; } if ( responseObj == null ) { return this . handleNonJSONResponse ( responseTxt , resultType ) ; } else { return this . getResultsFromResponse ( responseObj , resultType ) ; } }
Parse the response to JSON and send  for results parsing
 @param resultType
 @param responseTxt
 @return
 @throws Exception
Parse the response to JSON and send for results parsing @param resultType @param responseTxt @return @throws Exception
// empty // check for RDF first, return { "rdf": "<rdf ....    >" }  // it now must be JSON.  Start by parsing. // non-JSON // empty JSON // Normal path: get results