use of org.apache.tools.ant.filters.util.ChainReaderHelper in project ant by apache.
the class FilterMapper method mapFileName.
/**
* Return the result of the filters on the sourcefilename.
* @param sourceFileName the filename to map
* @return a one-element array of converted filenames, or null if
* the filterchain returns an empty string.
*/
@Override
public String[] mapFileName(String sourceFileName) {
if (sourceFileName == null) {
return null;
}
try {
Reader stringReader = new StringReader(sourceFileName);
ChainReaderHelper helper = new ChainReaderHelper();
helper.setBufferSize(BUFFER_SIZE);
helper.setPrimaryReader(stringReader);
helper.setProject(getProject());
Vector<FilterChain> filterChains = new Vector<>();
filterChains.add(this);
helper.setFilterChains(filterChains);
String result = FileUtils.safeReadFully(helper.getAssembledReader());
if (result.isEmpty()) {
return null;
}
return new String[] { result };
} catch (BuildException ex) {
throw ex;
} catch (Exception ex) {
throw new BuildException(ex);
}
}
use of org.apache.tools.ant.filters.util.ChainReaderHelper in project ant by apache.
the class ResourceList method open.
private Reader open(Resource r) throws IOException {
ChainReaderHelper crh = new ChainReaderHelper();
crh.setPrimaryReader(new InputStreamReader(new BufferedInputStream(r.getInputStream()), encoding == null ? Charset.defaultCharset() : Charset.forName(encoding)));
crh.setFilterChains(filterChains);
crh.setProject(getProject());
return crh.getAssembledReader();
}
Aggregations