当前位置: 首页>>代码示例>>Java>>正文


Java Union类代码示例

本文整理汇总了Java中org.apache.tools.ant.types.resources.Union的典型用法代码示例。如果您正苦于以下问题:Java Union类的具体用法?Java Union怎么用?Java Union使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Union类属于org.apache.tools.ant.types.resources包,在下文中一共展示了Union类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectOutOfDateResources

import org.apache.tools.ant.types.resources.Union; //导入依赖的package包/类
private Resource[] selectOutOfDateResources(final Resource[] initial,
                                            final FileNameMapper mapper) {
    final Resource[] rs = selectFileResources(initial);
    Resource[] result =
        ResourceUtils.selectOutOfDateSources(this, rs, mapper,
                                             getZipScanner(),
                                             ZIP_FILE_TIMESTAMP_GRANULARITY);
    if (!doFilesonly) {
        final Union u = new Union();
        u.addAll(Arrays.asList(selectDirectoryResources(initial)));
        final ResourceCollection rc =
            ResourceUtils.selectSources(this, u, mapper,
                                        getZipScanner(),
                                        MISSING_DIR_PROVIDER);
        if (!rc.isEmpty()) {
            final List<Resource> newer = new ArrayList<>();
            newer.addAll(Arrays.asList(((Union) rc).listResources()));
            newer.addAll(Arrays.asList(result));
            result = newer.toArray(result);
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:ant,代码行数:24,代码来源:Zip.java

示例2: clone

import org.apache.tools.ant.types.resources.Union; //导入依赖的package包/类
/**
 * Clone this Path.
 * @return Path with shallowly cloned Resource children.
 */
@Override
public Object clone() {
    try {
        Path result = (Path) super.clone();
        result.union = union == null ? union : (Union) union.clone();
        return result;
    } catch (CloneNotSupportedException e) {
        throw new BuildException(e);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:15,代码来源:Path.java

示例3: add

import org.apache.tools.ant.types.resources.Union; //导入依赖的package包/类
/**
 * Add a resource collection.
 * @param rc the resource collection to add.
 */
public void add(ResourceCollection rc) {
    if (rc == null) {
        return;
    }
    resources = resources == null ? new Union() : resources;
    resources.add(rc);
}
 
开发者ID:apache,项目名称:ant,代码行数:12,代码来源:ResourcesMatch.java

示例4: execute

import org.apache.tools.ant.types.resources.Union; //导入依赖的package包/类
@Override
public void execute() {
    if (file == null && resources.isEmpty()) {
        throw new BuildException(
            "import requires file attribute or at least one nested resource");
    }
    if (getOwningTarget() == null
        || !getOwningTarget().getName().isEmpty()) {
        throw new BuildException("import only allowed as a top-level task");
    }

    ProjectHelper helper = getProject().
                getReference(ProjectHelper.PROJECTHELPER_REFERENCE);

    if (helper == null) {
        // this happens if the projecthelper was not registered with the project.
        throw new BuildException("import requires support in ProjectHelper");
    }

    if (helper.getImportStack().isEmpty()) {
        // this happens if ant is used with a project
        // helper that doesn't set the import.
        throw new BuildException("import requires support in ProjectHelper");
    }

    if (getLocation() == null || getLocation().getFileName() == null) {
        throw new BuildException("Unable to get location of import task");
    }

    Union resourcesToImport = new Union(getProject(), resources);
    Resource fromFileAttribute = getFileAttributeResource();
    if (fromFileAttribute != null) {
        resources.add(fromFileAttribute);
    }
    for (Resource r : resourcesToImport) {
        importResource(helper, r);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:39,代码来源:ImportTask.java

示例5: selectSources

import org.apache.tools.ant.types.resources.Union; //导入依赖的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;
}
 
开发者ID:apache,项目名称:ant,代码行数:74,代码来源:ResourceUtils.java

示例6: execute

import org.apache.tools.ant.types.resources.Union; //导入依赖的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;
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:81,代码来源:PathConvert.java

示例7: FileUnion

import org.apache.tools.ant.types.resources.Union; //导入依赖的package包/类
FileUnion() {
    u = new Union();
    super.add(u);
    super.add(Type.FILE);
}
 
开发者ID:apache,项目名称:ant,代码行数:6,代码来源:Checksum.java

示例8: createSources

import org.apache.tools.ant.types.resources.Union; //导入依赖的package包/类
/**
 * Create a nested sources element.
 * @return a Union instance.
 */
public synchronized Union createSources() {
    sources = (sources == null) ? new Union() : sources;
    return sources;
}
 
开发者ID:apache,项目名称:ant,代码行数:9,代码来源:DependSet.java

示例9: selectOutOfDateSources

import org.apache.tools.ant.types.resources.Union; //导入依赖的package包/类
/**
 * Tells which source files should be reprocessed based on the
 * last modification date of target files.
 * @param logTo where to send (more or less) interesting output.
 * @param source array of resources bearing relative path and last
 * modification date.
 * @param mapper filename mapper indicating how to find the target
 * files.
 * @param targets object able to map as a resource a relative path
 * at <b>destination</b>.
 * @param granularity The number of milliseconds leeway to give
 * before deciding a target is out of date.
 * @return array containing the source files which need to be
 * copied or processed, because the targets are out of date or do
 * not exist.
 * @since Ant 1.6.2
 */
public static Resource[] selectOutOfDateSources(final ProjectComponent logTo,
                                                final Resource[] source,
                                                final FileNameMapper mapper,
                                                final ResourceFactory targets,
                                                final long granularity) {
    final Union u = new Union();
    u.addAll(Arrays.asList(source));
    final ResourceCollection rc
        = selectOutOfDateSources(logTo, u, mapper, targets, granularity);
    return rc.size() == 0 ? new Resource[0] : ((Union) rc).listResources();
}
 
开发者ID:apache,项目名称:ant,代码行数:29,代码来源:ResourceUtils.java

示例10: createSrcResources

import org.apache.tools.ant.types.resources.Union; //导入依赖的package包/类
/**
 * Nested resource collections as sources.
 * @return the source resources to configure.
 * @since Ant 1.7
 */
public Union createSrcResources() {
	return sourceResources;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:9,代码来源:WebUpToDate.java

示例11: createSrcResources

import org.apache.tools.ant.types.resources.Union; //导入依赖的package包/类
/**
 * Nested resource collections as sources.
 * @return the source resources to configure.
 * @since Ant 1.7
 */
public Union createSrcResources() {
    return sourceResources;
}
 
开发者ID:apache,项目名称:ant,代码行数:9,代码来源:UpToDate.java

示例12: add

import org.apache.tools.ant.types.resources.Union; //导入依赖的package包/类
/**
 * Add a collection of resources to touch.
 * @param rc the collection to add.
 * @since Ant 1.7
 */
public synchronized void add(ResourceCollection rc) {
    resources = resources == null ? new Union() : resources;
    resources.add(rc);
}
 
开发者ID:apache,项目名称:ant,代码行数:10,代码来源:Touch.java


注:本文中的org.apache.tools.ant.types.resources.Union类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。