@@ -42,7 +42,7 @@ of this software and associated documentation files (the "Software"), to deal
4242 * @version 2016-08-10
4343 */
4444@ SuppressWarnings ("boxing" )
45- public class XML {
45+ public class XML {
4646
4747 /** The Character '&'. */
4848 public static final Character AMP = '&' ;
@@ -78,6 +78,11 @@ public class XML {
7878
7979 public static final String TYPE_ATTR = "xsi:type" ;
8080
81+ /** [Milestone 5]
82+ * Need to define some global function variables that can be accessed by run function.
83+ */
84+ //public static Function command, errorHandle;
85+
8186 /**
8287 * Creates an iterator for navigating Code Points in a string instead of
8388 * characters. Once Java7 support is dropped, this can be replaced with
@@ -1072,6 +1077,45 @@ public static Stream<String> toStream(JSONObject obj)
10721077 return (listOfTags ).stream ();
10731078 }
10741079
1080+ public static void toJSONObject (Reader r , Function <JSONObject , Object > command , boolean diff )
1081+ {
1082+ //Reader r, Function commander, Function errorHandler
1083+ //Take the inputs and store them in global variables for later use in run function
1084+ //command = commander;
1085+ //errorHandle = errorHandler;
1086+ String outstr = "outside the thread rj" ;
1087+ JSONObject myJSON = toJSONObject (r );
1088+
1089+ Runnable runnable = () -> {
1090+ System .out .println ("Inside : " + outstr );
1091+ System .out .println (myJSON .toString ());
1092+ command .apply (myJSON );
1093+ };
1094+
1095+ System .out .println ("Creating Thread..." );
1096+ Thread thread = new Thread (runnable );
1097+
1098+ System .out .println ("Starting Thread..." );
1099+ thread .start ();
1100+
1101+
1102+ //(new Thread(new XML())).start();
1103+ }
1104+
1105+ /*public void run() {
1106+ System.out.println("Hello from a thread!");
1107+ try
1108+ {
1109+ //Convert reader to JSON Object and send off.i
1110+ command.apply();
1111+
1112+ } catch (Exception e)
1113+ {
1114+ System.out.println();
1115+ }
1116+ }*/
1117+
1118+
10751119 /**
10761120 * Convert a JSONObject into a well-formed, element-normal XML string.
10771121 *
0 commit comments