public StringBuilder makeStr(StringBuilder sb, String jname, String rel) { sb.append("("); _l.toJavaStr(sb, jname); sb.append(" ").append(rel).append(" "); _r.toJavaStr(sb, jname); sb.append(")"); return sb; }
// Read from stream a "string". Skips the trailing close-quote private String str() { int q = skipWS().qget(); if (q != '"' && q != '\'') throw new ParseException("Expected one of ' or \" but found '" + (char) q + "'"); StringBuilder sb = new StringBuilder(); int b = get(); while (b != q) { sb.append((char) b); b = qget(); } return sb.toString(); }
// Read from stream a valid PMML token public String token() { int b = get(); if (!Character.isJavaIdentifierStart(b)) throw new ParseException("Expected token start but found '" + (char) b + "'"); StringBuilder sb = new StringBuilder(); sb.append((char) b); b = get(); while (Character.isJavaIdentifierPart(b) || b == ':') { sb.append((char) b); b = get(); } push(b); return sb.toString(); }
public PMMLParser barf(char tok, char c) { StringBuilder sb = new StringBuilder(); sb.append("Expected '").append(tok).append("' but found '").append(c).append("'"); int line = 0; for (int i = 0; i < 512; i++) { try { c = (char) get(); } catch (ParseException ioe) { break; } sb.append(c); if (c == '\n' && line++ > 2) break; } throw new ParseException(sb.toString()); }
@Override public StringBuilder toJavaStr(StringBuilder sb, String jname) { return sb.append("true"); }
@Override public StringBuilder toJavaStr(StringBuilder sb, String jname) { sb.append("!("); super.toJavaStr(sb, jname); return sb.append(")"); }
@Override public StringBuilder toJavaStr(StringBuilder sb, String jname) { for (String s : _values) sb.append("\"").append(s).append("\".equals(").append(jname).append(") || "); return sb.append("false"); }
@Override public StringBuilder toJavaStr(StringBuilder sb, String jname) { return sb.append("\"").append(_str).append("\".equals(").append(jname).append(")"); }
@Override public StringBuilder toJavaBool(StringBuilder sb, String jname) { return sb.append(jname).append("==").append(_bool); }
@Override public StringBuilder toJavaNum(StringBuilder sb, String jname) { return sb.append(jname).append("==").append(_num); }
@Override public StringBuilder toJavaStr(StringBuilder sb, String jname) { return sb.append(jname).append("==null"); }
@Override public StringBuilder toJavaBool(StringBuilder sb, String jname) { return sb.append("Double.isNaN(" + jname + ")"); }