List of usage examples for org.apache.commons.lang.text StrSubstitutor setVariablePrefix
public StrSubstitutor setVariablePrefix(String prefix)
From source file:ddf.test.itests.common.Library.java
/** * Variables to be replaced in a resource file should be in the format: $variableName$ * The variable to replace in the file should also also match the parameter names of the method calling getFileContent. * * @param filePath//from w w w . j a v a 2s .com * @param params * @return */ public static String getFileContent(String filePath, ImmutableMap<String, String> params) { StrSubstitutor strSubstitutor = new StrSubstitutor(params); strSubstitutor.setVariablePrefix(VARIABLE_DELIMETER); strSubstitutor.setVariableSuffix(VARIABLE_DELIMETER); String fileContent = null; try { fileContent = org.apache.commons.io.IOUtils.toString(Library.class.getResourceAsStream(filePath), "UTF-8"); } catch (IOException e) { throw new RuntimeException("Failed to read filepath: " + filePath); } return strSubstitutor.replace(fileContent); }
From source file:ddf.test.itests.catalog.TestSpatial.java
private String getPagingMaxRecordsQuery(int maxRecords) { String rawCswQuery = savedCswQueries.get("CswPagingTestLikeQuery"); StrSubstitutor strSubstitutor = new StrSubstitutor(ImmutableMap.of("maxRecords", "" + maxRecords)); strSubstitutor.setVariablePrefix(RESOURCE_VARIABLE_DELIMETER); strSubstitutor.setVariableSuffix(RESOURCE_VARIABLE_DELIMETER); return strSubstitutor.replace(rawCswQuery); }
From source file:ddf.test.itests.catalog.TestSpatial.java
private String substitutePagingParams(String rawCswRecord, int testNum, String identifier) { StrSubstitutor strSubstitutor = new StrSubstitutor( ImmutableMap.of("identifier", identifier, "testNum", "" + testNum)); strSubstitutor.setVariablePrefix(RESOURCE_VARIABLE_DELIMETER); strSubstitutor.setVariableSuffix(RESOURCE_VARIABLE_DELIMETER); return strSubstitutor.replace(rawCswRecord); }
From source file:org.codice.ddf.itests.common.AbstractIntegrationTest.java
/** * Variables to be replaced in a resource file should be in the format: $variableName$ The * variable to replace in the file should also also match the parameter names of the method * calling getFileContent.// w w w . ja v a 2s .co m * * @param filePath * @param params * @param classRelativeToResource * @return */ @SuppressWarnings({ "squid:S00112" /* A generic RuntimeException is perfectly reasonable in this case. */ }) public static String getFileContent(String filePath, ImmutableMap<String, String> params, Class classRelativeToResource) { StrSubstitutor strSubstitutor = new StrSubstitutor(params); strSubstitutor.setVariablePrefix(RESOURCE_VARIABLE_DELIMETER); strSubstitutor.setVariableSuffix(RESOURCE_VARIABLE_DELIMETER); String fileContent; try { fileContent = IOUtils.toString(classRelativeToResource.getClassLoader().getResourceAsStream(filePath), "UTF-8"); } catch (IOException e) { throw new RuntimeException("Failed to read filepath: " + filePath); } return strSubstitutor.replace(fileContent); }