Here you can find the source of equals(final ByteBuffer keyValue, final int offset, final int keyLen, final byte[] otherKey)
Parameter | Description |
---|---|
keyValue | the key value |
offset | the offset |
keyLen | the key len |
otherKey | the other key |
public static boolean equals(final ByteBuffer keyValue, final int offset, final int keyLen, final byte[] otherKey)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Vladimir Rodionov. All Rights Reserved * * This code is released under the GNU Affero General Public License. * * See: http://www.fsf.org/licensing/licenses/agpl-3.0.html * * VLADIMIR RODIONOV MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * NON-INFRINGEMENT. Vladimir Rodionov SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR * ITS DERIVATIVES.//from www . j av a 2s . c o m * * Author: Vladimir Rodionov * *******************************************************************************/ import java.nio.ByteBuffer; public class Main { /** * Equals. * * @param s the s * @param key the key * @return true, if successful */ public final static boolean equals(final byte[] s, final byte[] key) { if (key.length != s.length) return false; for (int i = 0; i < s.length; i++) { if (s[i] != key[i]) { System.out.println("Failed at " + i + " of " + s.length); return false; } } return true; } /** * Equals. * * @param keyValue the key value * @param offset the offset * @param keyLen the key len * @param otherKey the other key * @return true, if successful */ public static boolean equals(final ByteBuffer keyValue, final int offset, final int keyLen, final byte[] otherKey) { for (int i = offset; i < offset + keyLen; i++) { if (keyValue.get(i) != otherKey[i - offset]) return false; } return true; } }