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


Java Resource.getLastModified方法代码示例

本文整理汇总了Java中org.apache.tools.ant.types.Resource.getLastModified方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getLastModified方法的具体用法?Java Resource.getLastModified怎么用?Java Resource.getLastModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tools.ant.types.Resource的用法示例。


在下文中一共展示了Resource.getLastModified方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: touch

import org.apache.tools.ant.types.Resource; //导入方法依赖的package包/类
private void touch(Resource r, long defaultTimestamp) {
    if (fileNameMapper == null) {
        FileProvider fp = r.as(FileProvider.class);
        if (fp != null) {
            // use this to create file and deal with non-writable files
            touch(fp.getFile(), defaultTimestamp);
        } else {
            r.as(Touchable.class).touch(defaultTimestamp);
        }
    } else {
        String[] mapped = fileNameMapper.mapFileName(r.getName());
        if (mapped != null && mapped.length > 0) {
            long modTime = defaultTimestamp;
            if (millis < 0 && r.isExists()) {
                modTime = r.getLastModified();
            }
            for (int i = 0; i < mapped.length; i++) {
                touch(getProject().resolveFile(mapped[i]), modTime);
            }
        }
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:23,代码来源:Touch.java

示例2: execute

import org.apache.tools.ant.types.Resource; //导入方法依赖的package包/类
/**
 * validate, then hand off to the subclass
 * @throws BuildException on error
 */
@Override
public void execute() throws BuildException {
    validate();

    Resource s = getSrcResource();
    if (!s.isExists()) {
        log("Nothing to do: " + s.toString()
            + " doesn't exist.");
    } else if (zipFile.lastModified() < s.getLastModified()) {
        log("Building: " + zipFile.getAbsolutePath());
        pack();
    } else {
        log("Nothing to do: " + zipFile.getAbsolutePath()
            + " is up to date.");
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:21,代码来源:Pack.java

示例3: process

import org.apache.tools.ant.types.Resource; //导入方法依赖的package包/类
/**
 * Process the input file to the output file with the given stylesheet.
 *
 * @param inFile the input file to process.
 * @param outFile the destination file.
 * @param stylesheet the stylesheet to use.
 * @exception BuildException if the processing fails.
 */
private void process(final File inFile, final File outFile, final Resource stylesheet) throws BuildException {
    try {
        final long styleSheetLastModified = stylesheet.getLastModified();
        log("In file " + inFile + " time: " + inFile.lastModified(), Project.MSG_DEBUG);
        log("Out file " + outFile + " time: " + outFile.lastModified(), Project.MSG_DEBUG);
        log("Style file " + xslFile + " time: " + styleSheetLastModified, Project.MSG_DEBUG);
        if (force || inFile.lastModified() >= outFile.lastModified()
                || styleSheetLastModified >= outFile.lastModified()) {
            ensureDirectoryFor(outFile);
            log("Processing " + inFile + " to " + outFile, Project.MSG_INFO);
            configureLiaison(stylesheet);
            setLiaisonDynamicFileParameters(liaison, inFile);
            liaison.transform(inFile, outFile);
        } else {
            log("Skipping input file " + inFile + " because it is older than output file "
                    + outFile + " and so is the stylesheet " + stylesheet, Project.MSG_DEBUG);
        }
    } catch (final Exception ex) {
        log("Failed to process " + inFile, Project.MSG_INFO);
        if (outFile != null) {
            outFile.delete();
        }
        handleTransformationError(ex);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:34,代码来源:XSLTProcess.java

示例4: setStylesheet

import org.apache.tools.ant.types.Resource; //导入方法依赖的package包/类
/**
 * Set the stylesheet file.
 * @param stylesheet a {@link org.apache.tools.ant.types.Resource} value
 * @throws Exception on error
 */
public void setStylesheet(final Resource stylesheet) throws Exception {
    if (this.stylesheet != null) {
        // resetting the stylesheet - reset transformer
        transformer = null;

        // do we need to reset templates as well
        if (!this.stylesheet.equals(stylesheet)
            || (stylesheet.getLastModified() != templatesModTime)) {
            templates = null;
        }
    }
    this.stylesheet = stylesheet;
}
 
开发者ID:apache,项目名称:ant,代码行数:19,代码来源:TraXLiaison.java

示例5: uptodate

import org.apache.tools.ant.types.Resource; //导入方法依赖的package包/类
private boolean uptodate(ResourceCollection src, ResourceCollection target) {
    org.apache.tools.ant.types.resources.selectors.Date datesel
        = new org.apache.tools.ant.types.resources.selectors.Date();
    datesel.setMillis(System.currentTimeMillis());
    datesel.setWhen(TimeComparison.AFTER);
    // don't whine because a file has changed during the last
    // second (or whathever our current granularity may be)
    datesel.setGranularity(0);
    logFuture(targets, datesel);

    NonExistent missingTargets = new NonExistent(targets);
    int neTargets = missingTargets.size();
    if (neTargets > 0) {
        log(neTargets + " nonexistent targets", Project.MSG_VERBOSE);
        logMissing(missingTargets, "target");
        return false;
    }
    Resource oldestTarget = getOldest(targets);
    logWithModificationTime(oldestTarget, "oldest target file");

    logFuture(sources, datesel);

    NonExistent missingSources = new NonExistent(sources);
    int neSources = missingSources.size();
    if (neSources > 0) {
        log(neSources + " nonexistent sources", Project.MSG_VERBOSE);
        logMissing(missingSources, "source");
        return false;
    }
    Resource newestSource = getNewest(sources);
    logWithModificationTime(newestSource, "newest source");
    return oldestTarget.getLastModified() >= newestSource.getLastModified();
}
 
开发者ID:apache,项目名称:ant,代码行数:34,代码来源:DependSet.java

示例6: isOutOfDate

import org.apache.tools.ant.types.Resource; //导入方法依赖的package包/类
/**
 * Returns dependency information on these two resources. If src has been
 * modified later than target, it returns true. If target doesn't exist,
 * it likewise returns true. Otherwise, target is newer than src and
 * is not out of date, thus the method returns false. It also returns
 * false if the src file doesn't even exist, since how could the
 * target then be out of date.
 *
 * @param src the original resource
 * @param target the resource being compared against
 * @param granularity the long amount in seconds of slack we will give in
 *        determining out of dateness
 * @return whether the target is out of date
 */
public static boolean isOutOfDate(Resource src, Resource target, long granularity) {
    long sourceLastModified = src.getLastModified();
    long targetLastModified = target.getLastModified();
    return src.isExists()
            && (sourceLastModified == Resource.UNKNOWN_DATETIME
                    || targetLastModified == Resource.UNKNOWN_DATETIME
                            || (sourceLastModified - granularity) > targetLastModified);
}
 
开发者ID:apache,项目名称:ant,代码行数:23,代码来源:SelectorUtils.java


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