@Test public void testVariable () throws IOException { final HashMap<String,String> varMap = new HashMap<String, String> (); varMap.put ("PATH", "/c/d:/e/f"); ExpressionHandler varHandler = new ExpressionHandler () { @Override public String eval (String name) throws IOException { return varMap.get (name); } }; String str = "abcd ${1} ${2+2} ${PATH} ${SHELL} {{abc}} {{}} {{d}} {{def}}"; String value; value = ExpressionParser.getString (str, varHandler); Assert.assertEquals ("abcd /c/d:/e/f {{abc}} {{}} {{d}} {{def}}", value); }
public static String getString (String str, ExpressionHandler varHandler) throws IOException { ExpressionParser parser = new ExpressionParser (varHandler); parser.setInput (new StringReader (str)); if (parser.yyLex () != 0) throw new IOException ("parsing error."); return parser.toString (); }
ExpressionParser extends GeneratedExpressionParser { public static String getString (String str, ExpressionHandler varHandler) throws IOException { ExpressionParser parser = new ExpressionParser (varHandler); parser.setInput (new StringReader (str)); if (parser.yyLex () != 0) throw new IOException ("parsing error."); return parser.toString (); } }
ExpressionParser extends GeneratedExpressionParser { public static String getString (String str, ExpressionHandler varHandler) throws IOException { ExpressionParser parser = new ExpressionParser (varHandler); parser.setInput (new StringReader (str)); if (parser.yyLex () != 0) throw new IOException ("parsing error."); return parser.toString (); } private  ExpressionParser(ExpressionHandler varHandler); }
ExpressionParser extends GeneratedExpressionParser { public static String getString (String str, ExpressionHandler varHandler) throws IOException { ExpressionParser parser = new ExpressionParser (varHandler); parser.setInput (new StringReader (str)); if (parser.yyLex () != 0) throw new IOException ("parsing error."); return parser.toString (); } private  ExpressionParser(ExpressionHandler varHandler); @Override String toString(); static String getString(String str, ExpressionHandler varHandler); }
ExpressionParser extends GeneratedExpressionParser { public static String getString (String str, ExpressionHandler varHandler) throws IOException { ExpressionParser parser = new ExpressionParser (varHandler); parser.setInput (new StringReader (str)); if (parser.yyLex () != 0) throw new IOException ("parsing error."); return parser.toString (); } private  ExpressionParser(ExpressionHandler varHandler); @Override String toString(); static String getString(String str, ExpressionHandler varHandler);  }