@@ -48,88 +48,58 @@ public class SqlToJsonParser {
4848// System.out.println(e.getMessage());
4949// }
5050// }
51-
52- /**
53- * used for java code
54- *
55- * @param sql raw sql query encoded with base 64
56- * @return parsed json string
57- * return null if exception was caught
58- */
59- public String parse (String sql ) {
60- return parse (sql , true );
61- }
62-
6351 /**
6452 * used for java code
6553 *
6654 * @param sql raw sql query
67- * @param isEncoded64 true if encoded with base 64
6855 * @return parsed json string
6956 * return null if exception was caught
7057 */
71- public String parse (String sql , boolean isEncoded64 ) {
72- if (isEncoded64 )
73- sql = decode64 (sql );
74-
58+ public String parse (String sql ) {
7559 try {
7660 return new Parser ().parse (sql ).toString (4 );
7761 } catch (Exception e ) {
7862 return null ;
7963 }
8064 }
8165
82- private String encode64 (String raw ) {
83- byte [] bytes = raw .getBytes (StandardCharsets .UTF_8 );
84- Base64 .Encoder encoder = Base64 .getEncoder ();
85- byte [] encodedBytes = encoder .encode (bytes );
86- return encoder .encodeToString (encodedBytes );
87- }
88-
89- private String decode64 (String encoded64 ) {
90- byte [] encodedBytes = encoded64 .getBytes ();
91- Base64 .Decoder decoder = Base64 .getDecoder ();
92- byte [] decodedBytes = decoder .decode (encodedBytes );
93- return new String (decodedBytes , StandardCharsets .UTF_8 );
94- }
95-
96- /**
97- * read sql from com.inzapp.SqlToJsonParser.config.Config.INPUT_FILE_NAME
98- * used for executable jar
99- *
100- * @param fileName main methods first args, user specified input file name
101- * @return sql from file
102- * return null if not exist file
103- */
104- private String readSqlFromFile (String fileName ) {
105- try {
106- BufferedReader br = new BufferedReader (new FileReader (fileName ));
107- StringBuilder sb = new StringBuilder ();
108- while (true ) {
109- String line = br .readLine ();
110- if (line == null )
111- break ;
112- sb .append (line .trim ()).append ("\n " );
113- }
114- return sb .toString ();
115- } catch (Exception e ) {
116- return null ;
117- }
118- }
119-
120- /**
121- * save json string as specified file name
122- *
123- * @param jsonString org.json.JSONObject().toString()
124- * parsed json object
125- * @param fileName main methods second args, user specified output file name
126- */
127- private void saveFile (String jsonString , String fileName ) {
128- try {
129- FileOutputStream fos = new FileOutputStream (fileName );
130- fos .write (jsonString .getBytes ());
131- } catch (Exception e ) {
132- e .printStackTrace ();
133- }
134- }
66+ // /**
67+ // * read sql from com.inzapp.SqlToJsonParser.config.Config.INPUT_FILE_NAME
68+ // * used for executable jar
69+ // *
70+ // * @param fileName main methods first args, user specified input file name
71+ // * @return sql from file
72+ // * return null if not exist file
73+ // */
74+ // private String readSqlFromFile(String fileName) {
75+ // try {
76+ // BufferedReader br = new BufferedReader(new FileReader(fileName));
77+ // StringBuilder sb = new StringBuilder();
78+ // while (true) {
79+ // String line = br.readLine();
80+ // if (line == null)
81+ // break;
82+ // sb.append(line.trim()).append("\n");
83+ // }
84+ // return sb.toString();
85+ // } catch (Exception e) {
86+ // return null;
87+ // }
88+ // }
89+ //
90+ // /**
91+ // * save json string as specified file name
92+ // *
93+ // * @param jsonString org.json.JSONObject().toString()
94+ // * parsed json object
95+ // * @param fileName main methods second args, user specified output file name
96+ // */
97+ // private void saveFile(String jsonString, String fileName) {
98+ // try {
99+ // FileOutputStream fos = new FileOutputStream(fileName);
100+ // fos.write(jsonString.getBytes());
101+ // } catch (Exception e) {
102+ // e.printStackTrace();
103+ // }
104+ // }
135105}
0 commit comments