/// <summary> /// Check if this key locator has the same values as the given key locator. /// </summary> /// /// <param name="other">The other key locator to check.</param> /// <returns>true if the key locators are equal, otherwise false.</returns> public bool equals(KeyLocator other) { if (type_ != other.type_) { return(false); } if (type_ == net.named_data.jndn.KeyLocatorType.KEYNAME) { if (!getKeyName().equals(other.getKeyName())) { return(false); } } else if (type_ == net.named_data.jndn.KeyLocatorType.KEY_LOCATOR_DIGEST) { if (!getKeyData().equals(other.getKeyData())) { return(false); } } return(true); }
/// <summary> /// Check if this key locator has the same values as the given key locator. /// </summary> /// /// <param name="other">The other key locator to check.</param> /// <returns>true if the key locators are equal, otherwise false.</returns> public bool equals(KeyLocator other) { if (type_ != other.type_) return false; if (type_ == net.named_data.jndn.KeyLocatorType.KEYNAME) { if (!getKeyName().equals(other.getKeyName())) return false; } else if (type_ == net.named_data.jndn.KeyLocatorType.KEY_LOCATOR_DIGEST) { if (!getKeyData().equals(other.getKeyData())) return false; } return true; }
private static void encodeKeyLocator(int type, KeyLocator keyLocator, TlvEncoder encoder) { int saveLength = encoder.getLength(); // Encode backwards. if (keyLocator.getType() != net.named_data.jndn.KeyLocatorType.NONE) { if (keyLocator.getType() == net.named_data.jndn.KeyLocatorType.KEYNAME) encodeName(keyLocator.getKeyName(), new int[1], new int[1], encoder); else if (keyLocator.getType() == net.named_data.jndn.KeyLocatorType.KEY_LOCATOR_DIGEST && keyLocator.getKeyData().size() > 0) encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.KeyLocatorDigest, keyLocator .getKeyData().buf()); else throw new Exception("Unrecognized KeyLocatorType " + keyLocator.getType()); } encoder.writeTypeAndLength(type, encoder.getLength() - saveLength); }