|
CheatSheet
Guide for the impatient.
Things You Should Know
If you're looking for syntax examples: SyntaxExamples Zipscript UsagesEvaluating config entries as booleansthe default boolean evaluation resource loader assumes the expression is passed to the getEvaluator method String expression = "foo != null && bar > 10"; // get the expression to evaluate
Map context = new HashMap();
// add business data to the context
try {
Evaluator e = ZipEngine.createInstance().getEvaluator(expression);
boolean val = e.booleanValue(context);
}
catch (ParseException e) {
// the expression was invalid
}Retrieving runtime objects using config entriesthe default object evaluation resource loader assumes the expression is passed to the getEvaluator method String expression = "{foo, bar, baz}"; // get the expression to evaluate - example represents a list
Map context = new HashMap();
// add business data to the context
try {
Evaluator e = ZipEngine.createInstance().getEvaluator(expression);
Object obj = e.objectValue(context);
// in this example obj will be a java.util.List
}
catch (ParseException e) {
// the expression was invalid
}Merging templates with runtime datathe default template resource loader will retrieve the template resource from the classpath String templateName = ...
Map context = new HashMap();
// add business data to the context
try {
Template t = ZipEngine.createInstance().getTemplate(templateName);
// there are other merging options as well
String result = t.merge(context);
}
catch (ParseException e) {
// the expression was invalid
}Now What?There are many other features and functionality not listed here. To learn more, why not check out the UserGuide and DevelopersGuide. |
Sign in to add a comment