private String consumeName() throws EGraphQLException, IOException { if (lexType != LexType.gqlltName) throw new EGraphQLException("Found \""+token.toString()+"\" expecting a name"); String result = token.toString(); next(); return result; }
private void consumePunctuation(String punc) throws EGraphQLException, IOException { if (lexType != LexType.gqlltPunctuation) throw new EGraphQLException("Found \""+token.toString()+"\" expecting \""+punc+"\""); if (!token.toString().equals(punc)) throw new EGraphQLException("Found \""+token.toString()+"\" expecting \""+punc+"\""); next(); }
private void consumeName(String name) throws EGraphQLException, IOException{ if (lexType != LexType.gqlltName) throw new EGraphQLException("Found \""+token.toString()+"\" expecting a name"); if (!token.toString().equals(name)) throw new EGraphQLException("Found \""+token.toString()+"\" expecting \""+name+"\""); next(); }
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; }
public static Package parse(String source) throws IOException, EGraphQLException, EGraphEngine { Parser self = new Parser(); self.reader = new StringReader(source); self.next(); Document doc = self.parseDocument(); return new Package(doc); }
public static Package parse(InputStream source) throws IOException, EGraphQLException, EGraphEngine { Parser self = new Parser(); self.reader = new InputStreamReader(source); self.next(); Document doc = self.parseDocument(); return new Package(doc); }
private Value parseValue() throws EGraphQLException, IOException { Value result = null; switch (lexType) { case gqlltNull: throw new EGraphQLException("Attempt to read a value after reading off the } of the GraphQL statement"); case gqlltName: result = new NameValue(token.toString()); break; case gqlltPunctuation: if (hasPunctuation("$")) { consumePunctuation("$"); result = new VariableValue(token.toString()); } else if (hasPunctuation("{")) { consumePunctuation("{"); ObjectValue obj = new ObjectValue(); while (!hasPunctuation("}")) obj.getFields().add(parseArgument()); result = obj; } else throw new EGraphQLException("Attempt to read a value at \""+token.toString()+"\""); break; case gqlltString: result = new StringValue(token.toString()); break; case gqlltNumber: result = new NumberValue(token.toString()); break; } next(); return result; }
private String consumeName() throws EGraphQLException, IOException { if (lexType != LexType.gqlltName) throw new EGraphQLException("Found \""+token.toString()+"\" expecting a name"); String result = token.toString(); next(); return result; }
private void consumePunctuation(String punc) throws EGraphQLException, IOException { if (lexType != LexType.gqlltPunctuation) throw new EGraphQLException("Found \""+token.toString()+"\" expecting \""+punc+"\""); if (!token.toString().equals(punc)) throw new EGraphQLException("Found \""+token.toString()+"\" expecting \""+punc+"\""); next(); }
private void consumeName(String name) throws EGraphQLException, IOException{ if (lexType != LexType.gqlltName) throw new EGraphQLException("Found \""+token.toString()+"\" expecting a name"); if (!token.toString().equals(name)) throw new EGraphQLException("Found \""+token.toString()+"\" expecting \""+name+"\""); next(); }
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; }
public static Package parse(String source) throws IOException, EGraphQLException, EGraphEngine { Parser self = new Parser(); self.reader = new StringReader(source); self.next(); Document doc = self.parseDocument(); return new Package(doc); }
public static Package parse(InputStream source) throws IOException, EGraphQLException, EGraphEngine { Parser self = new Parser(); self.reader = new InputStreamReader(source); self.next(); Document doc = self.parseDocument(); return new Package(doc); }
private Value parseValue() throws EGraphQLException, IOException { Value result = null; switch (lexType) { case gqlltNull: throw new EGraphQLException("Attempt to read a value after reading off the } of the GraphQL statement"); case gqlltName: result = new NameValue(token.toString()); break; case gqlltPunctuation: if (hasPunctuation("$")) { consumePunctuation("$"); result = new VariableValue(token.toString()); } else if (hasPunctuation("{")) { consumePunctuation("{"); ObjectValue obj = new ObjectValue(); while (!hasPunctuation("}")) obj.getFields().add(parseArgument()); result = obj; } else throw new EGraphQLException("Attempt to read a value at \""+token.toString()+"\""); break; case gqlltString: result = new StringValue(token.toString()); break; case gqlltNumber: result = new NumberValue(token.toString()); break; } next(); return result; }