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


Java Resource.equals方法代码示例

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


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

示例1: compareContent

import org.apache.tools.ant.types.Resource; //导入方法依赖的package包/类
/**
 * Compare the content of two Resources. A nonexistent Resource's
 * content is "less than" that of an existing Resource; a directory-type
 * Resource's content is "less than" that of a file-type Resource.
 * @param r1 the Resource whose content is to be compared.
 * @param r2 the other Resource whose content is to be compared.
 * @param text true if the content is to be treated as text and
 *        differences in kind of line break are to be ignored.
 * @return a negative integer, zero, or a positive integer as the first
 *         argument is less than, equal to, or greater than the second.
 * @throws IOException if the Resources cannot be read.
 * @since Ant 1.7
 */
public static int compareContent(final Resource r1, final Resource r2, final boolean text) throws IOException {
    if (r1.equals(r2)) {
        return 0;
    }
    final boolean e1 = r1.isExists();
    final boolean e2 = r2.isExists();
    if (!(e1 || e2)) {
        return 0;
    }
    if (e1 != e2) {
        return e1 ? 1 : -1;
    }
    final boolean d1 = r1.isDirectory();
    final boolean d2 = r2.isDirectory();
    if (d1 && d2) {
        return 0;
    }
    if (d1 || d2) {
        return d1 ? -1 : 1;
    }
    return text ? textCompare(r1, r2) : binaryCompare(r1, r2);
}
 
开发者ID:apache,项目名称:ant,代码行数:36,代码来源:ResourceUtils.java

示例2: contentEquals

import org.apache.tools.ant.types.Resource; //导入方法依赖的package包/类
/**
 * Compares the contents of two Resources.
 *
 * @param r1 the Resource whose content is to be compared.
 * @param r2 the other Resource whose content is to be compared.
 * @param text true if the content is to be treated as text and
 *        differences in kind of line break are to be ignored.
 *
 * @return true if the content of the Resources is the same.
 *
 * @throws IOException if the Resources cannot be read.
 * @since Ant 1.7
 */
public static boolean contentEquals(final Resource r1, final Resource r2, final boolean text) throws IOException {
    if (r1.isExists() != r2.isExists()) {
        return false;
    }
    if (!r1.isExists()) {
        // two not existing files are equal
        return true;
    }
    // should the following two be switched?  If r1 and r2 refer to the same file,
    // isn't their content equal regardless of whether that file is a directory?
    if (r1.isDirectory() || r2.isDirectory()) {
        // don't want to compare directory contents for now
        return false;
    }
    if (r1.equals(r2)) {
        return true;
    }
    if (!text) {
        final long s1 = r1.getSize();
        final long s2 = r2.getSize();
        if (s1 != Resource.UNKNOWN_SIZE && s2 != Resource.UNKNOWN_SIZE
                && s1 != s2) {
            return false;
        }
    }
    return compareContent(r1, r2, text) == 0;
}
 
开发者ID:apache,项目名称:ant,代码行数:41,代码来源:ResourceUtils.java


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