use of org.apache.tools.ant.util.ConcatResourceInputStream in project ant by apache.
the class Tokens method getCollection.
/**
* Sort the contained elements.
* @return a Collection of Resources.
*/
protected synchronized Collection<Resource> getCollection() {
ResourceCollection rc = getResourceCollection();
if (rc.isEmpty()) {
return Collections.emptySet();
}
if (tokenizer == null) {
tokenizer = new LineTokenizer();
}
try (ConcatResourceInputStream cat = new ConcatResourceInputStream(rc);
InputStreamReader rdr = new InputStreamReader(cat, encoding == null ? Charset.defaultCharset() : Charset.forName(encoding))) {
cat.setManagingComponent(this);
List<Resource> result = new ArrayList<>();
for (String s = tokenizer.getToken(rdr); s != null; s = tokenizer.getToken(rdr)) {
// do not send the Project to the constructor of StringResource, since
// the semantics of that constructor clearly state that property value
// replacement takes place on the passed string value. We don't want
// that to happen.
final StringResource resource = new StringResource(s);
resource.setProject(getProject());
result.add(resource);
}
return result;
} catch (IOException e) {
throw new BuildException("Error reading tokens", e);
}
}
Aggregations