public String processText(InputStream in) throws IOException { String text = IOUtils.toString(in, UTF_8); return processText(text); }
public void processText(InputStream is, OutputStreamWriter os) throws IOException { String text = IOUtils.toString(is, UTF_8); text = processText(text); os.write(text); }
public String expandQueryVariables(String query, Map<String, Object> params) { if (params != null && params.size() > 0) { TextTemplate tmpl = new TextTemplate(); for (String key : params.keySet()) { Object val = params.get(key); if (val == null) { continue; } else if (val instanceof Calendar) { tmpl.setVariable(key, Long.toString(((Calendar) val).getTime().getTime())); } else if (val instanceof Date) { tmpl.setVariable(key, Long.toString(((Date) val).getTime())); } else { tmpl.setVariable(key, val.toString()); } } query = tmpl.processText(query); } return query; }
try (InputStream is = new FileInputStream(in); OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(out), "UTF-8")) { processText(is, os);
ttProps.put(PARAM_DB_PWD, dbPassword); TextTemplate tt = new TextTemplate(ttProps); String url = tt.processText(connectionUrl); Properties conProps = new Properties(); conProps.put("user", dbUser);
/** * Read the classpath parameter from the template and expand parameters with their value. It allow classpath of the * form ${nuxeo.home}/nxserver/bundles/... * * @param template The name of the template */ // VisibleForTesting String getClasspathForTemplate(String template) { String classPath = configurationGenerator.getUserConfig().getProperty(template + PARAM_CHECK_CLASSPATH_SUFFIX); TextTemplate templateParser = new TextTemplate(configurationGenerator.getUserConfig()); return templateParser.processText(classPath); }
ttProps.put(PARAM_DB_PWD, dbPassword); TextTemplate tt = new TextTemplate(ttProps); String url = tt.processText(connectionUrl); Properties conProps = new Properties(); conProps.put("user", dbUser);