本文整理汇总了Java中org.apache.tools.ant.types.resources.Resources类的典型用法代码示例。如果您正苦于以下问题:Java Resources类的具体用法?Java Resources怎么用?Java Resources使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resources类属于org.apache.tools.ant.types.resources包,在下文中一共展示了Resources类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectClassesJarsAndResources
import org.apache.tools.ant.types.resources.Resources; //导入依赖的package包/类
/** Also modifies resourceReferences collection */
@SuppressWarnings("unchecked")
private List<String> collectClassesJarsAndResources() {
Resources filesToProcess = new Resources();
List<String> result = new ArrayList<String> (filesToProcess.size());
filesToProcess.setProject(getProject());
if (filesets == null)
throw new BuildException("Specify files to process using nested <fileset> element");
for (FileSet fileset : filesets) {
filesToProcess.add(fileset);
}
Iterator<org.apache.tools.ant.types.Resource> iter = (Iterator<org.apache.tools.ant.types.Resource>) filesToProcess.iterator();
while (iter.hasNext()) {
appendClassOrJarOrResource(result, (FileResource) iter.next());
}
return result;
}
示例2: add
import org.apache.tools.ant.types.resources.Resources; //导入依赖的package包/类
/**
* Add a ResourceCollection.
* @param c the <code>ResourceCollection</code> to add.
* @since Ant 1.7
*/
public synchronized void add(ResourceCollection c) {
if (c == null) {
return;
}
resources = (resources == null) ? new Resources() : resources;
resources.add(c);
}
示例3: addConfiguredStyle
import org.apache.tools.ant.types.resources.Resources; //导入依赖的package包/类
/**
* Add a nested <style> element.
* @param rc the configured Resources object represented as <style>.
* @since Ant 1.7
*/
public void addConfiguredStyle(final Resources rc) {
if (rc.size() != 1) {
handleError(
"The style element must be specified with exactly one nested resource.");
} else {
setXslResource(rc.iterator().next());
}
}
示例4: selectSources
import org.apache.tools.ant.types.resources.Resources; //导入依赖的package包/类
/**
* Tells which sources should be reprocessed because the given
* selector selects at least one target.
*
* @param logTo where to send (more or less) interesting output.
* @param source ResourceCollection.
* @param mapper filename mapper indicating how to find the target Resources.
* @param targets object able to map a relative path as a Resource.
* @param selector returns a selector that is applied to target
* files. If it selects at least one target the source will be
* added to the returned collection.
* @return ResourceCollection.
* @since Ant 1.8.0
*/
public static ResourceCollection selectSources(final ProjectComponent logTo,
ResourceCollection source,
final FileNameMapper mapper,
final ResourceFactory targets,
final ResourceSelectorProvider selector) {
if (source.isEmpty()) {
logTo.log("No sources found.", Project.MSG_VERBOSE);
return Resources.NONE;
}
source = Union.getInstance(source);
final Union result = new Union();
for (final Resource sr : source) {
String srName = sr.getName();
srName = srName == null
? srName : srName.replace('/', File.separatorChar);
String[] targetnames = null;
try {
targetnames = mapper.mapFileName(srName);
} catch (final Exception e) {
logTo.log("Caught " + e + " mapping resource " + sr,
Project.MSG_VERBOSE);
}
if (targetnames == null || targetnames.length == 0) {
logTo.log(sr + " skipped - don\'t know how to handle it",
Project.MSG_VERBOSE);
continue;
}
for (int i = 0; i < targetnames.length; i++) {
if (targetnames[i] == null) {
targetnames[i] = "(no name)";
}
}
final Union targetColl = new Union();
for (int i = 0; i < targetnames.length; i++) {
targetColl.add(targets.getResource(
targetnames[i].replace(File.separatorChar, '/')));
}
//find the out-of-date targets:
final Restrict r = new Restrict();
r.add(selector.getTargetSelectorForSource(sr));
r.add(targetColl);
if (r.size() > 0) {
result.add(sr);
final Resource t = r.iterator().next();
logTo.log(sr.getName() + " added as " + t.getName()
+ (t.isExists() ? " is outdated." : " doesn\'t exist."),
Project.MSG_VERBOSE);
continue;
}
//log uptodateness of all targets:
logTo.log(sr.getName()
+ " omitted as " + targetColl.toString()
+ (targetColl.size() == 1 ? " is" : " are ")
+ " up to date.", Project.MSG_VERBOSE);
}
return result;
}
示例5: add
import org.apache.tools.ant.types.resources.Resources; //导入依赖的package包/类
public synchronized void add(ResourceCollection c) {
if (c == null) {
return;
}
resources = (resources == null) ? new Resources() : resources;
resources.add(c);
}
示例6: execute
import org.apache.tools.ant.types.resources.Resources; //导入依赖的package包/类
/**
* Do the execution.
* @throws BuildException if something is invalid.
*/
@Override
public void execute() throws BuildException {
Resources savedPath = path;
String savedPathSep = pathSep; // may be altered in validateSetup
String savedDirSep = dirSep; // may be altered in validateSetup
try {
// If we are a reference, create a Path from the reference
if (isReference()) {
Object o = refid.getReferencedObject(getProject());
if (!(o instanceof ResourceCollection)) {
throw new BuildException(
"refid '%s' does not refer to a resource collection.",
refid.getRefId());
}
getPath().add((ResourceCollection) o);
}
validateSetup(); // validate our setup
// Currently, we deal with only two path formats: Unix and Windows
// And Unix is everything that is not Windows
// (with the exception for NetWare and OS/2 below)
// for NetWare and OS/2, piggy-back on Windows, since here and
// in the apply code, the same assumptions can be made as with
// windows - that \\ is an OK separator, and do comparisons
// case-insensitive.
String fromDirSep = onWindows ? "\\" : "/";
StringBuilder rslt = new StringBuilder();
ResourceCollection resources = isPreserveDuplicates() ? (ResourceCollection) path : new Union(path);
List<String> ret = new ArrayList<>();
FileNameMapper mapperImpl = mapper == null ? new IdentityMapper() : mapper.getImplementation();
for (Resource r : resources) {
String[] mapped = mapperImpl.mapFileName(String.valueOf(r));
for (int m = 0; mapped != null && m < mapped.length; ++m) {
ret.add(mapped[m]);
}
}
boolean first = true;
for (String string : ret) {
String elem = mapElement(string); // Apply the path prefix map
// Now convert the path and file separator characters from the
// current os to the target os.
if (!first) {
rslt.append(pathSep);
}
first = false;
StringTokenizer stDirectory = new StringTokenizer(elem, fromDirSep, true);
while (stDirectory.hasMoreTokens()) {
String token = stDirectory.nextToken();
rslt.append(fromDirSep.equals(token) ? dirSep : token);
}
}
// Place the result into the specified property,
// unless setonempty == false
if (setonempty || rslt.length() > 0) {
String value = rslt.toString();
if (property == null) {
log(value);
} else {
log("Set property " + property + " = " + value, Project.MSG_VERBOSE);
getProject().setNewProperty(property, value);
}
}
} finally {
path = savedPath;
dirSep = savedDirSep;
pathSep = savedPathSep;
}
}
示例7: iterator
import org.apache.tools.ant.types.resources.Resources; //导入依赖的package包/类
@Override
public Iterator<Resource> iterator() {
return basedirExists() ? fs.iterator() : Resources.EMPTY_ITERATOR;
}