public void enroll ( Template template ) throws GrFingerJavaException { try { //Inserts the template on the database enrollStmt.setBinaryStream(1,new ByteArrayInputStream(template.getData()), template.getData().length); enrollStmt.executeUpdate(); //Picks the ID generated for it. ResultSet rs = insertedIdStmt.executeQuery(); rs.next(); System.out.println("Fingerprint enrolled with id = "+Integer.toString(rs.getInt(1))); System.out.println("Fingerprint enrolled"); } catch (SQLException e) { System.out.println("Error enrolling template"); } }
VelocityEngine ve = new VelocityEngine(); Properties props = new Properties(); props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); props.put("resource.loader", "class"); ve.init(props); Template t = ve.getTemplate("templates/my-template.vm"); final List<String> keys = new ArrayList<String>(); SimpleNode sn = (SimpleNode)t.getData(); BaseVisitor myVisitor = new BaseVisitor(){ @Override public Object visit(ASTReference node, Object data){ String key = node.literal(); keys.add(key); return super.visit(node, data); } }; sn.jjtAccept(myVisitor, new Object()); for (String key : keys) { System.out.println(key); }
/** * Determines whether a directive with an specified name is present on a template instance. * * @param directiveName The name of the directive to look for. * @param template The template where we will search for the directive. * @return true, if the directive has been defined on the template; otherwise, false. */ public static boolean isPresent(final String directiveName, final Template template) { final SimpleNode dataAsSimpleNode = (SimpleNode) template.getData(); final DirectiveDetectionVisitor isDirectivePresentVisitor = new DirectiveDetectionVisitor(directiveName); dataAsSimpleNode.jjtAccept(isDirectivePresentVisitor, new Object()); return isDirectivePresentVisitor.isPresent(); }
public VelocityTemplateParser(String templateString) throws ParseErrorException { VelocityEngine engine = new VelocityEngine(); engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.Log4JLogChute"); engine.setProperty("runtime.log.logsystem.log4j.logger", LOG.getName()); engine.setProperty(Velocity.RESOURCE_LOADER, "string"); engine.addProperty("string.resource.loader.class", StringResourceLoader.class.getName()); engine.addProperty("string.resource.loader.repository.static", "false"); engine.addProperty("runtime.references.strict", "true"); engine.init(); StringResourceRepository resourceRepository = (StringResourceRepository) engine.getApplicationAttribute(StringResourceLoader.REPOSITORY_NAME_DEFAULT); resourceRepository.putStringResource(TEMPLATE_NAME, templateString); template = engine.getTemplate(TEMPLATE_NAME); ASTprocess data = (ASTprocess) template.getData(); visitor = new ParserNodeVisitor(); data.jjtAccept(visitor, null); }
final RequireChecker requireChecker = new RequireChecker(); requireChecker.visit( (ASTprocess) this.presentationTemplate.getData(), this.inputDepths); (ASTprocess) this.presentationTemplate.getData(), this.outputDepths); (ASTprocess) this.presentationTemplate.getData(), this.configBean); this.configurePortsFromTemplate();
ASTprocess data = (ASTprocess) velocityTemplate.getData(); ReferenceContext referenceContext = new ReferenceContext(); data.jjtAccept(referenceContext,null);
context.pushCurrentTemplateName(arg); ((SimpleNode) t.getData()).render(context, writer);
((SimpleNode) t.getData()).render( context, writer );
context.pushCurrentTemplateName(arg); ((SimpleNode) t.getData()).render(context, writer);
((SimpleNode)t.getData()).render(context, writer);