Java Code Examples for org.apache.velocity.context.InternalContextAdapter#containsKey()
The following examples show how to use
org.apache.velocity.context.InternalContextAdapter#containsKey() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GetPackage.java From CodeGen with MIT License | 5 votes |
@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { String clazz = (String) node.jjtGetChild(0).value(context); if (context.containsKey(clazz)) { String packagePath = context.get(clazz).toString(); packagePath = new StringBuilder("").append(packagePath).toString(); writer.write(packagePath); return true; } return false; }
Example 2
Source File: ImportPackage.java From CodeGen with MIT License | 5 votes |
@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { String clazz = (String) node.jjtGetChild(0).value(context); if (context.containsKey(clazz)) { String packagePath = context.get(clazz).toString(); packagePath = new StringBuilder("import ").append(packagePath).append(";\n").toString(); writer.write(packagePath); return true; } return false; }
Example 3
Source File: ASTReference.java From velocity-engine with Apache License 2.0 | 5 votes |
/** * @param context * @return The evaluated value of the variable. * @throws MethodInvocationException */ public Object getRootVariableValue(InternalContextAdapter context) { Object obj = null; try { obj = context.get(rootString); } catch(RuntimeException e) { log.error("Exception calling reference ${} at {}", rootString, StringUtils.formatFileString(uberInfo)); throw e; } if (obj == null && strictRef && astAlternateValue == null) { if (!context.containsKey(rootString)) { log.error("Variable ${} has not been set at {}", rootString, StringUtils.formatFileString(uberInfo)); throw new MethodInvocationException("Variable $" + rootString + " has not been set", null, rsvc.getLogContext().getStackTrace(), identifier, uberInfo.getTemplateName(), uberInfo.getLine(), uberInfo.getColumn()); } } return obj; }