本文整理汇总了Java中org.apache.http.conn.util.InetAddressUtilsHC4类的典型用法代码示例。如果您正苦于以下问题:Java InetAddressUtilsHC4类的具体用法?Java InetAddressUtilsHC4怎么用?Java InetAddressUtilsHC4使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InetAddressUtilsHC4类属于org.apache.http.conn.util包,在下文中一共展示了InetAddressUtilsHC4类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: normaliseIPv6Address
import org.apache.http.conn.util.InetAddressUtilsHC4; //导入依赖的package包/类
private String normaliseIPv6Address(final String hostname) {
if (hostname == null || !InetAddressUtilsHC4.isIPv6Address(hostname)) {
return hostname;
}
try {
final InetAddress inetAddress = InetAddress.getByName(hostname);
return inetAddress.getHostAddress();
} catch (final UnknownHostException uhe) { // Should not happen, because we check for IPv6 address above
Log.e(TAG, "Unexpected error converting "+hostname, uhe);
return hostname;
}
}
示例2: buildString
import org.apache.http.conn.util.InetAddressUtilsHC4; //导入依赖的package包/类
private String buildString() {
final StringBuilder sb = new StringBuilder();
if (this.scheme != null) {
sb.append(this.scheme).append(':');
}
if (this.encodedSchemeSpecificPart != null) {
sb.append(this.encodedSchemeSpecificPart);
} else {
if (this.encodedAuthority != null) {
sb.append("//").append(this.encodedAuthority);
} else if (this.host != null) {
sb.append("//");
if (this.encodedUserInfo != null) {
sb.append(this.encodedUserInfo).append("@");
} else if (this.userInfo != null) {
sb.append(encodeUserInfo(this.userInfo)).append("@");
}
if (InetAddressUtilsHC4.isIPv6Address(this.host)) {
sb.append("[").append(this.host).append("]");
} else {
sb.append(this.host);
}
if (this.port >= 0) {
sb.append(":").append(this.port);
}
}
if (this.encodedPath != null) {
sb.append(normalizePath(this.encodedPath));
} else if (this.path != null) {
sb.append(encodePath(normalizePath(this.path)));
}
if (this.encodedQuery != null) {
sb.append("?").append(this.encodedQuery);
} else if (this.queryParams != null) {
sb.append("?").append(encodeUrlForm(this.queryParams));
} else if (this.query != null) {
sb.append("?").append(encodeUric(this.query));
}
}
if (this.encodedFragment != null) {
sb.append("#").append(this.encodedFragment);
} else if (this.fragment != null) {
sb.append("#").append(encodeUric(this.fragment));
}
return sb.toString();
}
示例3: isIPAddress
import org.apache.http.conn.util.InetAddressUtilsHC4; //导入依赖的package包/类
private static boolean isIPAddress(final String hostname) {
return hostname != null &&
(InetAddressUtilsHC4.isIPv4Address(hostname) ||
InetAddressUtilsHC4.isIPv6Address(hostname));
}