/** * Fulfill the ResourceCollection contract. * @return an Iterator of Resources. */ @Override public final synchronized Iterator<Resource> iterator() { if (isReference()) { return getCheckedRef().iterator(); } dieOnCircularReference(); return w.iterator(); }
@Override protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { if (isChecked()) { return; } // takes care of Selectors super.dieOnCircularReference(stk, p); if (!isReference()) { pushAndInvokeCircularReferenceCheck(w, stk, p); setChecked(true); } }
/** * Fulfill the ResourceCollection contract. * @return whether this is a filesystem-only resource collection. */ @Override public synchronized boolean isFilesystemOnly() { if (isReference()) { return getCheckedRef().isFilesystemOnly(); } dieOnCircularReference(); return w.isFilesystemOnly(); }
/** * Fulfill the ResourceCollection contract. * @return number of elements as int. */ @Override public synchronized int size() { if (isReference()) { return getCheckedRef().size(); } dieOnCircularReference(); return w.size(); }
ResourceCollectionFlags rcFlags = getFlags(target); Restrict res = new Restrict(); res.setProject(getProject()); res.add(target); or.add(name); res.add(not); for (Iterator rs = res.iterator(); rs.hasNext(); ) { Resource r = (Resource) rs.next(); String name = r.getName();
/** * Format this Restrict collection as a String. * @return the String value of this collection. */ @Override public synchronized String toString() { if (isReference()) { return getCheckedRef().toString(); } dieOnCircularReference(); return w.toString(); }
/** * Add the ResourceCollection. * @param c the ResourceCollection to add. */ public synchronized void add(ResourceCollection c) { if (isReference()) { throw noChildrenAllowed(); } if (c == null) { return; } w.add(c); setChecked(false); }
/** * Restrict the nested ResourceCollection based on the nested selectors. */ @Override protected boolean filterResource(Resource r) { return getResourceSelectors().stream().anyMatch(rsel -> !rsel.isSelected(r)); } };
/** * Log which Resources (if any) have been modified in the future. * @param logTo the ProjectComponent to do the logging. * @param rc the collection of Resources to check. * @param granularity the timestamp granularity to use. * @since Ant 1.7 */ private static void logFuture(final ProjectComponent logTo, final ResourceCollection rc, final long granularity) { final long now = System.currentTimeMillis() + granularity; final Date sel = new Date(); sel.setMillis(now); sel.setWhen(TimeComparison.AFTER); final Restrict future = new Restrict(); future.add(sel); future.add(rc); for (final Resource r : future) { logTo.log("Warning: " + r.getName() + " modified in the future.", Project.MSG_WARN); } }
/** * Get the resources to concatenate. */ private ResourceCollection getResources() { if (rc == null) { return new StringResource(getProject(), textBuffer.toString()); } if (dest != null) { Intersect checkDestNotInSources = new Intersect(); checkDestNotInSources.setProject(getProject()); checkDestNotInSources.add(rc); checkDestNotInSources.add(dest); if (checkDestNotInSources.size() > 0) { throw new BuildException( "Destination resource %s was specified as an input resource.", dest); } } Restrict noexistRc = new Restrict(); noexistRc.add(NOT_EXISTS); noexistRc.add(rc); for (Resource r : noexistRc) { log(r + " does not exist.", Project.MSG_ERR); } Restrict result = new Restrict(); result.add(EXISTS); result.add(rc); return result; }
/** * Adds a collection of filesystem resources to copy. * @param rc a resource collection * @since Ant 1.7 */ public void add(ResourceCollection rc) { if (rc instanceof FileSet && rc.isFilesystemOnly()) { // receives special treatment in copy that this task relies on myCopy.add(rc); } else { if (resources == null) { Restrict r = new Restrict(); r.add(new Exists()); resources = new Resources(); r.add(resources); myCopy.add(r); } resources.add(rc); } }