本文整理汇总了Java中com.sun.jndi.toolkit.url.UrlUtil类的典型用法代码示例。如果您正苦于以下问题:Java UrlUtil类的具体用法?Java UrlUtil怎么用?Java UrlUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UrlUtil类属于com.sun.jndi.toolkit.url包,在下文中一共展示了UrlUtil类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DnsUrl
import com.sun.jndi.toolkit.url.UrlUtil; //导入依赖的package包/类
public DnsUrl(String url) throws MalformedURLException {
super(url);
if (!scheme.equals("dns")) {
throw new MalformedURLException(
url + " is not a valid DNS pseudo-URL");
}
domain = path.startsWith("/")
? path.substring(1)
: path;
domain = domain.equals("")
? "."
: UrlUtil.decode(domain);
// Debug
// System.out.println("host=" + host + " port=" + port +
// " domain=" + domain);
}
示例2: constructProviderUrl
import com.sun.jndi.toolkit.url.UrlUtil; //导入依赖的package包/类
private static String constructProviderUrl(String domain,
String[] servers) {
String path = "";
if (!domain.equals(".")) {
try {
path = "/" + UrlUtil.encode(domain, "ISO-8859-1");
} catch (java.io.UnsupportedEncodingException e) {
// assert false : "ISO-Latin-1 charset unavailable";
}
}
StringBuffer buf = new StringBuffer();
for (int i = 0; i < servers.length; i++) {
if (i > 0) {
buf.append(' ');
}
buf.append("dns://").append(servers[i]).append(path);
}
return buf.toString();
}
示例3: toUrlString
import com.sun.jndi.toolkit.url.UrlUtil; //导入依赖的package包/类
static String toUrlString(String host, int port, String dn, boolean useSsl)
{
try {
String h = (host != null) ? host : "";
if ((h.indexOf(':') != -1) && (h.charAt(0) != '[')) {
h = "[" + h + "]"; // IPv6 literal
}
String p = (port != -1) ? (":" + port) : "";
String d = (dn != null) ? ("/" + UrlUtil.encode(dn, "UTF8")) : "";
return useSsl ? "ldaps://" + h + p + d : "ldap://" + h + p + d;
} catch (UnsupportedEncodingException e) {
// UTF8 should always be supported
throw new IllegalStateException("UTF-8 encoding unavailable");
}
}
示例4: constructProviderUrl
import com.sun.jndi.toolkit.url.UrlUtil; //导入依赖的package包/类
private static String constructProviderUrl(String domain,
String[] servers) {
String path = "";
if (!domain.equals(".")) {
try {
path = "/" + UrlUtil.encode(domain, "ISO-8859-1");
} catch (java.io.UnsupportedEncodingException e) {
// assert false : "ISO-Latin-1 charset unavailable";
}
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < servers.length; i++) {
if (i > 0) {
sb.append(' ');
}
sb.append("dns://").append(servers[i]).append(path);
}
return sb.toString();
}
示例5: showDocument
import com.sun.jndi.toolkit.url.UrlUtil; //导入依赖的package包/类
@Override
public void showDocument(URL url, String target) {
// If it is a javascript document, eval on current page.
if ("javascript".equals(url.getProtocol())) {
// Snip protocol off string
String evalString = url.toString().substring("javascript:".length());
eval(getWindow(), evalString);
return;
}
try {
Long reference = getRequestIdentifier();
write("reference " + reference + " LoadURL " + UrlUtil.encode(url.toString(), "UTF-8") + " " + target);
} catch (IOException exception) {
// Deliberately ignore IOException. showDocument may be
// called from threads other than the main thread after
// streamhandler.pluginOutputStream has been closed.
}
}
示例6: put
import com.sun.jndi.toolkit.url.UrlUtil; //导入依赖的package包/类
@Override
public void put(URI uri,
Map<String, List<String>> responseHeaders) throws IOException {
super.put(uri, responseHeaders);
for (Map.Entry<String, List<String>> headerEntry : responseHeaders.entrySet()) {
String type = headerEntry.getKey();
if ("Set-Cookie".equalsIgnoreCase(type) || "Set-Cookie2".equalsIgnoreCase(type)) {
List<String> cookies = headerEntry.getValue();
for (String cookie : cookies) {
streamHandler.write("plugin PluginSetCookie reference -1 " + UrlUtil.encode(uri.toString(), "UTF-8") + " " + cookie);
}
}
}
}