本文整理匯總了Java中java.net.InetAddress.hashCode方法的典型用法代碼示例。如果您正苦於以下問題:Java InetAddress.hashCode方法的具體用法?Java InetAddress.hashCode怎麽用?Java InetAddress.hashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.net.InetAddress
的用法示例。
在下文中一共展示了InetAddress.hashCode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hashCode
import java.net.InetAddress; //導入方法依賴的package包/類
/** Compute the hash code for this URLName. */
@Override
public int hashCode() {
if (this.hashCode != 0) {
return this.hashCode;
}
if (this.protocol != null) {
this.hashCode += this.protocol.hashCode();
}
final InetAddress addr = getHostAddress();
if (addr != null) {
this.hashCode += addr.hashCode();
}
else if (this.host != null) {
this.hashCode += this.host.toLowerCase(Locale.ENGLISH).hashCode();
}
if (this.username != null) {
this.hashCode += this.username.hashCode();
}
if (this.file != null) {
this.hashCode += this.file.hashCode();
}
this.hashCode += this.port;
return this.hashCode;
}
示例2: doNameQuery
import java.net.InetAddress; //導入方法依賴的package包/類
static NbtAddress doNameQuery( Name name, InetAddress svr )
throws UnknownHostException {
NbtAddress addr;
if( name.hexCode == 0x1d && svr == null ) {
svr = CLIENT.baddr; // bit of a hack but saves a lookup
}
name.srcHashCode = svr != null ? svr.hashCode() : 0;
addr = getCachedAddress( name );
if( addr == null ) {
/* This is almost exactly like InetAddress.java. See the
* comments there for a description of how the LOOKUP_TABLE prevents
* redundant queries from going out on the wire.
*/
if(( addr = (NbtAddress)checkLookupTable( name )) == null ) {
try {
addr = CLIENT.getByName( name, svr );
} catch( UnknownHostException uhe ) {
addr = UNKNOWN_ADDRESS;
} finally {
cacheAddress( name, addr );
updateLookupTable( name );
}
}
}
if( addr == UNKNOWN_ADDRESS ) {
throw new UnknownHostException( name.toString() );
}
return addr;
}
示例3: isWINS
import java.net.InetAddress; //導入方法依賴的package包/類
public static boolean isWINS( InetAddress svr ) {
for( int i = 0; svr != null && i < NBNS.length; i++ ) {
if( svr.hashCode() == NBNS[i].hashCode() ) {
return true;
}
}
return false;
}