public JSONObject getJsonConfig ( Path name ) throws IOException , JSONException { String pathString = name . toUri ( ) . getPath ( ) ; String xml = new Path ( pathString ) . getName ( ) ; File jsonFile = new File ( pathString . replace ( xml , MATERIALIZEDJSON ) ) . getAbsoluteFile ( ) ; if ( jsonFile . exists ( ) ) { InputStream in = new BufferedInputStream ( new FileInputStream ( jsonFile ) ) ; if ( in != null ) { JSONObject json = instantiateJsonObject ( in ) ; // Try to load the xml entity inside the json blob. if ( json . has ( xmlToThrift ( xml ) ) ) { return json . getJSONObject ( xmlToThrift ( xml ) ) ; } } } return null ; }
Given a xml config file specified by a path return the corresponding json object if it exists .