Java 类org.apache.velocity.runtime.parser.node.SimpleNode 实例源码

项目:java-framework-with-springmvc-mybatis-proxool    文件:TestDirective.java   
@Override
public boolean render(InternalContextAdapter context, Writer writer,
        Node node) throws IOException, ResourceNotFoundException,
        ParseErrorException, MethodInvocationException 
{
    int argsNum = node.jjtGetNumChildren();
    for(int step = 0 ; step < argsNum; step++)
    {
        SimpleNode simpleNode = (SimpleNode) node.jjtGetChild(step);

        Object argObject = simpleNode.value(context);

        //传入参数
        if(argObject instanceof String)
        {
            System.out.println((String)argObject);
            writer.write((String)argObject);
            writer.flush();
        }
    }
    return true;
}
项目:motech    文件:VelocityTemplateParser.java   
public String mergeTemplateIntoString(String templateFilename, Map<String, Object> params)
        throws VelocityTemplateParsingException {
    try (InputStream is = settingsFacade.getRawConfig(templateFilename)) {
        StringReader reader = new StringReader(IOUtils.toString(is));
        SimpleNode node = rs.parse(reader, templateFilename);

        Template template = new Template();
        template.setRuntimeServices(rs);
        template.setData(node);
        template.initDocument();

        StringWriter writer = new StringWriter();
        template.merge(new VelocityContext(params), writer);
        return writer.toString();
    } catch (ParseException|IOException e) {
        throw new VelocityTemplateParsingException("Couldn't merge template into string", e);
    }
}
项目:connector-certification-tools    文件:DirectoryStructureRule.java   
private void initTemplate(@NonNull final String verifyExpression) throws ParseException {

        // Init pattern ...
        final RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();

        final StringReader reader = new StringReader(verifyExpression);
        SimpleNode node = runtimeServices.parse(reader, this.getDocumentation().getId());

        final Template template = new Template();
        template.setRuntimeServices(runtimeServices);
        template.setData(node);
        template.initDocument();
        this.template = template;

        // Parse expression looking for variable ...
        final Pattern pattern = Pattern.compile(VELOCITY_VARIABLE);
        final Matcher matcher = pattern.matcher(verifyExpression);

        while (matcher.find()) {
            final String key = matcher.group(1);
            final ClassProperty property = ClassProperty.to(key);
            this.templateProperties.add(property);
        }

    }
项目:pippo    文件:VelocityTemplateEngine.java   
@Override
public void renderString(String templateContent, Map<String, Object> model, Writer writer) {
    // create the velocity context
    VelocityContext context = createVelocityContext(model);

    // merge the template
    try {
        RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
        StringReader reader = new StringReader(templateContent);
        SimpleNode node = runtimeServices.parse(reader, "StringTemplate");
        Template template = new Template();
        template.setRuntimeServices(runtimeServices);
        template.setData(node);
        template.initDocument();
        template.merge(context, writer);
    } catch (Exception e) {
        throw new PippoRuntimeException(e);
    }
}
项目:iotplatform    文件:VelocityUtils.java   
public static Template create(String source, String templateName) throws ParseException {
  RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
  StringReader reader = new StringReader(source);
  SimpleNode node = runtimeServices.parse(reader, templateName);
  Template template = new Template();
  template.setRuntimeServices(runtimeServices);
  template.setData(node);
  template.initDocument();
  return template;
}
项目:MybatisCode    文件:VelocitySqlSource.java   
public VelocitySqlSource(Configuration configuration, String scriptText) {
  this.configuration = configuration;
  try {
    RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
    StringReader reader = new StringReader(scriptText);
    SimpleNode node = runtimeServices.parse(reader, "Template name");
    script = new Template();
    script.setRuntimeServices(runtimeServices);
    script.setData(node);
    script.initDocument();
  } catch (Exception ex) {
    throw new BuilderException("Error parsing velocity script", ex);
  }
}
项目:Gargoyle    文件:MailUtil.java   
/**
 * @작성자 : KYJ
 * @작성일 : 2017. 10. 14.
 * @param url
 * @return
 * @throws Exception
 */
public static Template createTemplate(InputStream is) throws Exception {
    String readFileToString = ValueUtil.toString(is);
    RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
    StringReader reader = new StringReader(readFileToString);
    SimpleNode node = runtimeServices.parse(reader, "URLTemplate");
    Template template = new Template();
    template.setRuntimeServices(runtimeServices);
    template.setData(node);
    template.initDocument();
    return template;
}
项目:mybatis    文件:VelocitySqlSource.java   
public VelocitySqlSource(Configuration configuration, String scriptText) {
  this.configuration = configuration;
  try {
    RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
    StringReader reader = new StringReader(scriptText);
    SimpleNode node = runtimeServices.parse(reader, "Template name");
    script = new Template();
    script.setRuntimeServices(runtimeServices);
    script.setData(node);
    script.initDocument();
  } catch (Exception ex) {
    throw new BuilderException("Error parsing velocity script", ex);
  }
}
项目:thingsboard    文件:VelocityUtils.java   
public static Template create(String source, String templateName) throws ParseException {
    RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
    StringReader reader = new StringReader(source);
    SimpleNode node = runtimeServices.parse(reader, templateName);
    Template template = new Template();
    template.setRuntimeServices(runtimeServices);
    template.setData(node);
    template.initDocument();
    return template;
}
项目:RetroFacebook    文件:TemplateVars.java   
/**
 * Returns the result of substituting the variables defined by the fields of this class
 * (a concrete subclass of TemplateVars) into the template returned by {@link #parsedTemplate()}.
 */
String toText() {
  VelocityContext velocityContext = toVelocityContext();
  StringWriter writer = new StringWriter();
  SimpleNode parsedTemplate = parsedTemplate();
  boolean rendered = velocityRuntimeInstance.render(
      velocityContext, writer, parsedTemplate.getTemplateName(), parsedTemplate);
  if (!rendered) {
    // I don't know when this happens. Usually you get an exception during rendering.
    throw new IllegalArgumentException("Template rendering failed");
  }
  return writer.toString();
}
项目:RetroFacebook    文件:TemplateVars.java   
static SimpleNode parsedTemplateForResource(String templateStr, String resourceName) {
  try {
    return velocityRuntimeInstance.parse(templateStr, resourceName);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:RetroFacebook    文件:TemplateVarsTest.java   
static SimpleNode parsedTemplateForString(String string) {
  try {
    Reader reader = new StringReader(string);
    return RuntimeSingleton.parse(reader, string);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:RetroFacebook    文件:TemplateVars.java   
/**
 * Returns the result of substituting the variables defined by the fields of this class
 * (a concrete subclass of TemplateVars) into the template returned by {@link #parsedTemplate()}.
 */
String toText() {
  VelocityContext velocityContext = toVelocityContext();
  StringWriter writer = new StringWriter();
  SimpleNode parsedTemplate = parsedTemplate();
  boolean rendered = velocityRuntimeInstance.render(
      velocityContext, writer, parsedTemplate.getTemplateName(), parsedTemplate);
  if (!rendered) {
    // I don't know when this happens. Usually you get an exception during rendering.
    throw new IllegalArgumentException("Template rendering failed");
  }
  return writer.toString();
}
项目:RetroFacebook    文件:TemplateVars.java   
static SimpleNode parsedTemplateForResource(String templateStr, String resourceName) {
  try {
    return velocityRuntimeInstance.parse(templateStr, resourceName);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:RetroFacebook    文件:TemplateVarsTest.java   
static SimpleNode parsedTemplateForString(String string) {
  try {
    Reader reader = new StringReader(string);
    return RuntimeSingleton.parse(reader, string);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:mybaties    文件:VelocitySqlSource.java   
public VelocitySqlSource(Configuration configuration, String scriptText) {
  this.configuration = configuration;
  try {
    RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
    StringReader reader = new StringReader(scriptText);
    SimpleNode node = runtimeServices.parse(reader, "Template name");
    script = new Template();
    script.setRuntimeServices(runtimeServices);
    script.setData(node);
    script.initDocument();
  } catch (Exception ex) {
    throw new BuilderException("Error parsing velocity script", ex);
  }
}
项目:AutoCursor    文件:TemplateVars.java   
/**
 * Returns the result of substituting the variables defined by the fields of this class
 * (a concrete subclass of TemplateVars) into the template returned by {@link #parsedTemplate()}.
 */
String toText() {
  VelocityContext velocityContext = toVelocityContext();
  StringWriter writer = new StringWriter();
  SimpleNode parsedTemplate = parsedTemplate();
  boolean rendered = velocityRuntimeInstance.render(
      velocityContext, writer, parsedTemplate.getTemplateName(), parsedTemplate);
  if (!rendered) {
    // I don't know when this happens. Usually you get an exception during rendering.
    throw new IllegalArgumentException("Template rendering failed");
  }
  return writer.toString();
}
项目:AutoCursor    文件:TemplateVars.java   
static SimpleNode parsedTemplateForResource(String templateStr, String resourceName) {
  try {
    return velocityRuntimeInstance.parse(templateStr, resourceName);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:AutoCursor    文件:TemplateVarsTest.java   
static SimpleNode parsedTemplateForString(String string) {
  try {
    Reader reader = new StringReader(string);
    return RuntimeSingleton.parse(reader, string);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:play    文件:VelocitySqlSource.java   
public VelocitySqlSource(Configuration configuration, String scriptText) {
  this.configuration = configuration;
  try {
    RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
    StringReader reader = new StringReader(scriptText);
    SimpleNode node = runtimeServices.parse(reader, "Template name");
    script = new Template();
    script.setRuntimeServices(runtimeServices);
    script.setData(node);
    script.initDocument();
  } catch (Exception ex) {
    throw new BuilderException("Error parsing velocity script", ex);
  }
}
项目:retrofit2.bak    文件:TemplateVars.java   
/**
 * Returns the result of substituting the variables defined by the fields of this class
 * (a concrete subclass of TemplateVars) into the template returned by {@link #parsedTemplate()}.
 */
String toText() {
  VelocityContext velocityContext = toVelocityContext();
  StringWriter writer = new StringWriter();
  SimpleNode parsedTemplate = parsedTemplate();
  boolean rendered = velocityRuntimeInstance.render(
      velocityContext, writer, parsedTemplate.getTemplateName(), parsedTemplate);
  if (!rendered) {
    // I don't know when this happens. Usually you get an exception during rendering.
    throw new IllegalArgumentException("Template rendering failed");
  }
  return writer.toString();
}
项目:retrofit2.bak    文件:TemplateVars.java   
static SimpleNode parsedTemplateForResource(String templateStr, String resourceName) {
  try {
    return velocityRuntimeInstance.parse(templateStr, resourceName);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:retrofit2.bak    文件:TemplateVarsTest.java   
static SimpleNode parsedTemplateForString(String string) {
  try {
    Reader reader = new StringReader(string);
    return RuntimeSingleton.parse(reader, string);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:SimpleWeibo    文件:TemplateVars.java   
/**
 * Returns the result of substituting the variables defined by the fields of this class
 * (a concrete subclass of TemplateVars) into the template returned by {@link #parsedTemplate()}.
 */
String toText() {
  VelocityContext velocityContext = toVelocityContext();
  StringWriter writer = new StringWriter();
  SimpleNode parsedTemplate = parsedTemplate();
  boolean rendered = velocityRuntimeInstance.render(
      velocityContext, writer, parsedTemplate.getTemplateName(), parsedTemplate);
  if (!rendered) {
    // I don't know when this happens. Usually you get an exception during rendering.
    throw new IllegalArgumentException("Template rendering failed");
  }
  return writer.toString();
}
项目:SimpleWeibo    文件:TemplateVars.java   
static SimpleNode parsedTemplateForResource(String templateStr, String resourceName) {
  try {
    return velocityRuntimeInstance.parse(templateStr, resourceName);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:SimpleWeibo    文件:TemplateVarsTest.java   
static SimpleNode parsedTemplateForString(String string) {
  try {
    Reader reader = new StringReader(string);
    return RuntimeSingleton.parse(reader, string);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:AutoJson    文件:TemplateVars.java   
/**
 * Returns the result of substituting the variables defined by the fields of this class
 * (a concrete subclass of TemplateVars) into the template returned by {@link #parsedTemplate()}.
 */
String toText() {
  VelocityContext velocityContext = toVelocityContext();
  StringWriter writer = new StringWriter();
  SimpleNode parsedTemplate = parsedTemplate();
  boolean rendered = velocityRuntimeInstance.render(
      velocityContext, writer, parsedTemplate.getTemplateName(), parsedTemplate);
  if (!rendered) {
    // I don't know when this happens. Usually you get an exception during rendering.
    throw new IllegalArgumentException("Template rendering failed");
  }
  return writer.toString();
}
项目:AutoJson    文件:TemplateVars.java   
static SimpleNode parsedTemplateForResource(String templateStr, String resourceName) {
  try {
    return velocityRuntimeInstance.parse(templateStr, resourceName);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:AutoJson    文件:TemplateVarsTest.java   
static SimpleNode parsedTemplateForString(String string) {
  try {
    Reader reader = new StringReader(string);
    return RuntimeSingleton.parse(reader, string);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
项目:velocity-scripting    文件:VelocityFacade.java   
public static Object compile(String script, String name) {
  try {
    StringReader reader = new StringReader(script);
    Template template = new Template();
    SimpleNode node = engine.parse(reader, template);
    template.setRuntimeServices(engine);
    template.setData(node);
    template.setName(name);
    template.initDocument();
    return template;
  } catch (Exception ex) {
    throw new BuilderException("Error parsing velocity script '" + name + "'", ex);
  }
}
项目:mybatis-3    文件:VelocitySqlSource.java   
public VelocitySqlSource(Configuration configuration, String scriptText) {
  this.configuration = configuration;
  try {
    RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
    StringReader reader = new StringReader(scriptText);
    SimpleNode node = runtimeServices.parse(reader, "Template name");
    script = new Template();
    script.setRuntimeServices(runtimeServices);
    script.setData(node);
    script.initDocument();
  } catch (Exception ex) {
    throw new BuilderException("Error parsing velocity script", ex);
  }
}
项目:RetroFacebook    文件:RetroFacebookTemplateVars.java   
@Override
SimpleNode parsedTemplate() {
  return TEMPLATE;
}
项目:RetroFacebook    文件:GwtSerialization.java   
@Override
SimpleNode parsedTemplate() {
  return TEMPLATE;
}
项目:RetroFacebook    文件:TemplateVarsTest.java   
@Override SimpleNode parsedTemplate() {
  return parsedTemplateForString("integer=$integer string=$string list=$list");
}
项目:RetroFacebook    文件:TemplateVarsTest.java   
@Override SimpleNode parsedTemplate() {
  throw new UnsupportedOperationException();
}
项目:RetroFacebook    文件:TemplateVarsTest.java   
@Override SimpleNode parsedTemplate() {
  throw new UnsupportedOperationException();
}
项目:RetroFacebook    文件:TemplateVarsTest.java   
@Override SimpleNode parsedTemplate() {
  throw new UnsupportedOperationException();
}
项目:RetroFacebook    文件:RetroFacebookTemplateVars.java   
@Override
SimpleNode parsedTemplate() {
  return TEMPLATE;
}
项目:RetroFacebook    文件:GwtSerialization.java   
@Override
SimpleNode parsedTemplate() {
  return TEMPLATE;
}
项目:RetroFacebook    文件:TemplateVarsTest.java   
@Override SimpleNode parsedTemplate() {
  return parsedTemplateForString("integer=$integer string=$string list=$list");
}