本文整理匯總了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);
}
示例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);
}