當前位置: 首頁>>代碼示例>>Java>>正文


Java Enumeration.hashCode方法代碼示例

本文整理匯總了Java中java.util.Enumeration.hashCode方法的典型用法代碼示例。如果您正苦於以下問題:Java Enumeration.hashCode方法的具體用法?Java Enumeration.hashCode怎麽用?Java Enumeration.hashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Enumeration的用法示例。


在下文中一共展示了Enumeration.hashCode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setControllerTLV

import java.util.Enumeration; //導入方法依賴的package包/類
protected void setControllerTLV() {
	// Setting the controllerTLVValue based on current nano time,
	// controller's IP address, and the network interface object hash
	// the corresponding IP address.

	final int prime = 7867;

	byte[] controllerTLVValue = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; // 8
	// byte
	// value.
	ByteBuffer bb = ByteBuffer.allocate(10);

	long result = System.nanoTime();
	try{
		// Use some data specific to the machine this controller is
		// running on. In this case: the list of network interfaces
		Enumeration<NetworkInterface> ifaces =
				NetworkInterface.getNetworkInterfaces();
		if (ifaces != null) {
			result = result * prime + ifaces.hashCode();
		}
	} catch (SocketException e) {
		log.warn("Could not get list of interfaces of local machine to " +
				"encode in TLV: {}", e.toString());
	}
	// set the first 4 bits to 0.
	result = result & (0x0fffffffffffffffL);

	bb.putLong(result);

	bb.rewind();
	bb.get(controllerTLVValue, 0, 8);

	this.controllerTLV = new LLDPTLV().setType((byte) 0x0c)
			.setLength((short) controllerTLVValue.length)
			.setValue(controllerTLVValue);
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:38,代碼來源:LinkDiscoveryManager.java

示例2: setControllerTLV

import java.util.Enumeration; //導入方法依賴的package包/類
@LogMessageDoc(level="WARN",
		message="Could not get list of interfaces of local machine to " +
				"encode in TLV: {detail-msg}",
				explanation="Outgoing LLDP packets encode a unique hash to " +
						"identify the local machine. The list of network " +
						"interfaces is used as input and the controller failed " +
						"to query this list",
						recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
protected void setControllerTLV() {
	// Setting the controllerTLVValue based on current nano time,
	// controller's IP address, and the network interface object hash
	// the corresponding IP address.

	final int prime = 7867;

	byte[] controllerTLVValue = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; // 8
	// byte
	// value.
	ByteBuffer bb = ByteBuffer.allocate(10);

	long result = System.nanoTime();
	try{
		// Use some data specific to the machine this controller is
		// running on. In this case: the list of network interfaces
		Enumeration<NetworkInterface> ifaces =
				NetworkInterface.getNetworkInterfaces();
		if (ifaces != null) {
			result = result * prime + ifaces.hashCode();
		}
	} catch (SocketException e) {
		log.warn("Could not get list of interfaces of local machine to " +
				"encode in TLV: {}", e.toString());
	}
	// set the first 4 bits to 0.
	result = result & (0x0fffffffffffffffL);

	bb.putLong(result);

	bb.rewind();
	bb.get(controllerTLVValue, 0, 8);

	this.controllerTLV = new LLDPTLV().setType((byte) 0x0c)
			.setLength((short) controllerTLVValue.length)
			.setValue(controllerTLVValue);
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:46,代碼來源:LinkDiscoveryManager.java


注:本文中的java.util.Enumeration.hashCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。