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


Java Element.equals方法代码示例

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


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

示例1: doVerifyFileMd5

import com.allanbank.mongodb.bson.Element; //导入方法依赖的package包/类
/**
 * Verifies the MD5 result for the filemd5 command.
 *
 * @param faults
 *            The faults for to update if the verify fails.
 * @param fileDoc
 *            The document representing the file.
 * @param cmdResult
 *            The document returned from the 'filemd5' command.
 * @return True if the file was successful.
 */
protected boolean doVerifyFileMd5(final Map<Object, List<String>> faults,
        final Document fileDoc, final Document cmdResult) {
    boolean ok = false;
    final Element idElement = fileDoc.get(ID_FIELD);

    final Element md5 = fileDoc.get(MD5_FIELD);
    final Element commandMd5 = cmdResult.findFirst(MD5_FIELD);

    ok = (md5 != null) && md5.equals(commandMd5);
    if (!ok) {
        doAddFault(faults, idElement,
                "MD5 sums do not match. File document contains '" + md5
                        + "' and the filemd5 command produced '"
                        + commandMd5 + "'.");
    }

    return ok;
}
 
开发者ID:allanbank,项目名称:mongodb-async-driver,代码行数:30,代码来源:GridFs.java

示例2: doValidate

import com.allanbank.mongodb.bson.Element; //导入方法依赖的package包/类
/**
 * Validates the file from the GridFS collections using the {@code filemd5}
 * command.
 * <p>
 * <b>Note:</b> Due to a limitation in the MongoDB server this method will
 * always return <code>false</code> when used with a sharded cluster when
 * the shard key for the chunks collection is not one of
 * <code>{files_id:1}</code> or <code>{files_id:1, n:1}</code>. See <a
 * href="https://jira.mongodb.org/browse/SERVER-9888">SERVER-9888</a>.
 * </p>
 *
 * @param fileDoc
 *            The document for the file to delete.
 * @return True if a file was deleted, false otherwise.
 *
 * @see <a
 *      href="https://jira.mongodb.org/browse/SERVER-9888">SERVER-9888</a>
 */
protected boolean doValidate(final Document fileDoc) {
    final Element id = fileDoc.get(ID_FIELD);
    final Element md5 = fileDoc.get(MD5_FIELD);

    final DocumentBuilder commandDoc = BuilderFactory.start();
    commandDoc.add(id.withName("filemd5"));
    commandDoc.add("root", myRootName);
    final Document result = myDatabase.runCommand(commandDoc.build());

    return (md5 != null) && md5.equals(result.findFirst(MD5_FIELD));
}
 
开发者ID:allanbank,项目名称:mongodb-async-driver,代码行数:30,代码来源:GridFs.java

示例3: fuzzyEquals

import com.allanbank.mongodb.bson.Element; //导入方法依赖的package包/类
/**
 * Compares if the two elements are equals allowing numeric values type to
 * not be a strict match but when casted as a long those values must still
 * compare equal.
 *
 * @param lhs
 *            The first element to compare. May not be <code>null</code>.
 * @param rhs
 *            The second element to compare. May be <code>null</code>.
 * @return True if the two elements compare equal ignore two
 *         {@link NumericElement}s' specific type.
 */
private boolean fuzzyEquals(final Element lhs, final Element rhs) {
    // Be fuzzy on the integer/long/double.
    if ((rhs instanceof NumericElement) && (lhs instanceof NumericElement)) {
        final long tagValue = ((NumericElement) rhs).getLongValue();
        final long tagMatchingValue = ((NumericElement) lhs).getLongValue();
        return (tagValue == tagMatchingValue);
    }

    // Otherwise exact match.
    return lhs.equals(rhs);
}
 
开发者ID:allanbank,项目名称:mongodb-async-driver,代码行数:24,代码来源:ReadPreference.java


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