private Predicate pSimpleSetPredicate(HashMap<String, String> attrs) { expect('>'); IsIn in = IsIn.make(attrs.get("field"), BooleanOperators.valueOf(attrs.get("booleanOperator"))); in._values = skipWS().expect('<').pArray(); skipWS().expect("</SimpleSetPredicate>"); return in; }
// Any number of attributes, or '/' or '>' public HashMap<String, String> attrs() { HashMap<String, String> attrs = null; while (true) { int b = skipWS().peek(); if (b == '/' || b == '>') return attrs; if (attrs == null) attrs = new HashMap(); String attr = token(); String val = skipWS().expect('=').str(); attrs.put(attr, val); } }
// Read a single field name & type, plus any enum/factor/level info private PMMLParser pDataField() { HashMap<String, String> attrs = expect("DataField").attrs(); String name = attrs.get("name"); _types.put(name, DataTypes.parse(attrs.get("dataType"))); if (peek() == '/') return expect("/>"); expect('>'); ArrayList<String> str = new ArrayList(); while (skipWS().expect('<').peek() != '/') str.add(pDataFieldValue()); String[] ss = str.toArray(new String[0]); Arrays.sort(ss, null); _enums.put(name, ss); return expect("/DataField>"); }
private String[] pArray() { HashMap<String, String> attrs = expect("Array").attrs(); expect('>'); int len = Integer.parseInt(attrs.get("n")); assert attrs.get("type").equals("string"); String[] ss = new String[len]; for (int i = 0; i < len; i++) { int b = skipWS().peek(); // Allow both quoted and unquoted tokens ss[i] = (b == '&' || b == '"') ? str() : token(); } skipWS().expect("</Array>"); return ss; }
private Predicate pCompoundPredicate(HashMap<String, String> attrs) { expect(">"); CompoundPredicate cp = CompoundPredicate.make(BooleanOperators.valueOf(attrs.get("booleanOperator"))); cp._l = skipWS().expect('<').pPredicate(); cp._r = skipWS().expect('<').pPredicate(); skipWS().expect("</CompoundPredicate>"); return cp; }
public static String getString(HashMap<String, Comparable> row, String s) { return getString(row.get(s)); }
public static double getBoolean(HashMap<String, Comparable> row, String s) { return getBoolean(row.get(s)); }
// Happy Helper Methods for the generated code public static double getNumber(HashMap<String, Comparable> row, String s) { return getNumber(row.get(s)); }
private Predicate pSimplePredicate(HashMap<String, String> attrs) { expect("/>"); return Comparison.makeSimple( attrs.get("field"), Operators.valueOf(attrs.get("operator")), attrs.get("value")); }