public static String fileToString(File f) throws FileNotFoundException, IOException { return streamToString(new FileInputStream(f)); }
public static String bytesToString(byte[] bs) throws IOException { return streamToString(new ByteArrayInputStream(bs)); }
public PackageGenerator(OutputStream stream, InputStream template) throws JsonSyntaxException, IOException { super(); this.stream = stream; JsonParser parser = new com.google.gson.JsonParser(); object = parser.parse(TextFile.streamToString(template)).getAsJsonObject(); }
public PackageGenerator(OutputStream stream, InputStream template) throws JsonSyntaxException, IOException { super(); this.stream = stream; JsonParser parser = new com.google.gson.JsonParser(); object = parser.parse(TextFile.streamToString(template)).getAsJsonObject(); }
private JsonObject loadJson(InputStream input) throws JsonSyntaxException, IOException { return JsonTrackingParser.parse(TextFile.streamToString(input), null); // return parser.parse(TextFile.streamToString(input)).getAsJsonObject(); }
private String cachedFetch(String id, String source) throws IOException { String tmpDir = System.getProperty("java.io.tmpdir"); String local = Utilities.path(tmpDir, id); File f = new File(local); if (f.exists()) return TextFile.fileToString(f); URL url = new URL(source); URLConnection c = url.openConnection(); String result = TextFile.streamToString(c.getInputStream()); TextFile.stringToFile(result, f); return result; }
public static String fileToString(String src) throws FileNotFoundException, IOException { return streamToString(new FileInputStream(new CSFile(src))); }
public static Package parseJson(InputStream source) throws EGraphQLException, IOException, EGraphEngine { JsonObject json = (JsonObject) new com.google.gson.JsonParser().parse(TextFile.streamToString(source)); Parser self = new Parser(); self.reader = new StringReader(json.get("query").getAsString()); self.next(); Package result = new Package(self.parseDocument()); result.setOperationName(json.get("operationName").getAsString()); if (json.has("variables")) { JsonObject vl = json.getAsJsonObject("variables"); for (Entry<String, JsonElement> n : vl.entrySet()) result.getVariables().add(new Argument(n.getKey(), n.getValue())); } return result; }
@Override public Element parse(InputStream stream) throws Exception { // if we're parsing at this point, then we're going to use the custom parser map = new HashMap<JsonElement, LocationData>(); String source = TextFile.streamToString(stream); if (policy == ValidationPolicy.EVERYTHING) { JsonObject obj = null; try { obj = JsonTrackingParser.parse(source, map); } catch (Exception e) { logError(-1, -1, "(document)", IssueType.INVALID, "Error parsing JSON: "+e.getMessage(), IssueSeverity.FATAL); return null; } assert (map.containsKey(obj)); return parse(obj); } else { JsonObject obj = (JsonObject) new com.google.gson.JsonParser().parse(source); assert (map.containsKey(obj)); return parse(obj); } }
@Override public Element parse(InputStream input) throws IOException, FHIRException { Turtle src = new Turtle(); if (policy == ValidationPolicy.EVERYTHING) { try { src.parse(TextFile.streamToString(input)); } catch (Exception e) { logError(-1, -1, "(document)", IssueType.INVALID, "Error parsing Turtle: "+e.getMessage(), IssueSeverity.FATAL); return null; } return parse(src); } else { src.parse(TextFile.streamToString(input)); return parse(src); } }
@Override public Element parse(InputStream stream) throws IOException, FHIRException { // if we're parsing at this point, then we're going to use the custom parser map = new HashMap<JsonElement, LocationData>(); String source = TextFile.streamToString(stream); if (policy == ValidationPolicy.EVERYTHING) { JsonObject obj = null; try { obj = JsonTrackingParser.parse(source, map); } catch (Exception e) { logError(-1, -1, "(document)", IssueType.INVALID, "Error parsing JSON: "+e.getMessage(), IssueSeverity.FATAL); return null; } assert (map.containsKey(obj)); return parse(obj); } else { JsonObject obj = JsonTrackingParser.parse(source, null); // (JsonObject) new com.google.gson.JsonParser().parse(source); // assert (map.containsKey(obj)); return parse(obj); } }
public static String fileToString(File f) throws FileNotFoundException, IOException { return streamToString(new FileInputStream(f)); }
public static String bytesToString(byte[] bs) throws IOException { return streamToString(new ByteArrayInputStream(bs)); }
public PackageGenerator(OutputStream stream, InputStream template) throws JsonSyntaxException, IOException { super(); this.stream = stream; JsonParser parser = new com.google.gson.JsonParser(); object = parser.parse(TextFile.streamToString(template)).getAsJsonObject(); }
public PackageGenerator(OutputStream stream, InputStream template) throws JsonSyntaxException, IOException { super(); this.stream = stream; JsonParser parser = new com.google.gson.JsonParser(); object = parser.parse(TextFile.streamToString(template)).getAsJsonObject(); }
private JsonObject loadJson(InputStream input) throws JsonSyntaxException, IOException { return parser.parse(TextFile.streamToString(input)).getAsJsonObject(); }
private JsonObject loadJson(InputStream input) throws JsonSyntaxException, IOException { return JsonTrackingParser.parse(TextFile.streamToString(input), null); // return parser.parse(TextFile.streamToString(input)).getAsJsonObject(); }
private String cachedFetch(String id, String source) throws IOException { String tmpDir = System.getProperty("java.io.tmpdir"); String local = Utilities.path(tmpDir, id); File f = new File(local); if (f.exists()) return TextFile.fileToString(f); URL url = new URL(source); URLConnection c = url.openConnection(); String result = TextFile.streamToString(c.getInputStream()); TextFile.stringToFile(result, f); return result; }
public static String fileToString(String src) throws FileNotFoundException, IOException { return streamToString(new FileInputStream(new CSFile(src))); }
public static Package parseJson(InputStream source) throws EGraphQLException, IOException, EGraphEngine { JsonObject json = (JsonObject) new com.google.gson.JsonParser().parse(TextFile.streamToString(source)); Parser self = new Parser(); self.reader = new StringReader(json.get("query").getAsString()); self.next(); Package result = new Package(self.parseDocument()); result.setOperationName(json.get("operationName").getAsString()); if (json.has("variables")) { JsonObject vl = json.getAsJsonObject("variables"); for (Entry<String, JsonElement> n : vl.entrySet()) result.getVariables().add(new Argument(n.getKey(), n.getValue())); } return result; }