當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。