本文整理汇总了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;
}