本文整理了Java中org.apache.tomcat.util.net.URL
类的一些代码示例,展示了URL
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URL
类的具体详情如下:
包路径:org.apache.tomcat.util.net.URL
类名称:URL
[英]URL is designed to provide public APIs for parsing and synthesizing Uniform Resource Locators as similar as possible to the APIs of java.net.URL
, but without the ability to open a stream or connection. One of the consequences of this is that you can construct URLs for protocols for which a URLStreamHandler is not available (such as an "https" URL when JSSE is not installed).
WARNING - This class assumes that the string representation of a URL conforms to the spec
argument as described in RFC 2396 "Uniform Resource Identifiers: Generic Syntax":
<scheme>//<authority><path>?<query>#<fragment>
FIXME - This class really ought to end up in a Commons package someplace.
[中]URL旨在为解析和合成统一资源定位器提供公共API,尽可能类似于java.net.URL
的API,但不能打开流或连接。这样做的后果之一是,您可以为URLStreamHandler不可用的协议构造URL(例如未安装JSSE时的“https”URL)。
警告-此类假定URL的字符串表示形式符合RFC 2396“统一资源标识符:通用语法”中描述的spec
参数:
<scheme>//<authority><path>?<query>#<fragment>
修正我——这门课真的应该在某个地方的公共包中结束。
代码示例来源:origin: org.jboss.web/jbossweb
/**
* Compare two URLs, excluding the "ref" fields. Returns <code>true</code>
* if this <code>URL</code> and the <code>other</code> argument both refer
* to the same resource. The two <code>URLs</code> might not both contain
* the same anchor.
*/
public boolean sameFile(URL other) {
if (!compare(protocol, other.getProtocol()))
return (false);
if (!compare(host, other.getHost()))
return (false);
if (port != other.getPort())
return (false);
if (!compare(file, other.getFile()))
return (false);
return (true);
}
代码示例来源:origin: org.osivia.portal.core/osivia-portal-jbossas-jbossweb-lib
/* */ private boolean hasScheme(String uri)
/* */ {
/* 1533 */ int len = uri.length();
/* 1534 */ for (int i = 0; i < len; i++) {
/* 1535 */ char c = uri.charAt(i);
/* 1536 */ if (c == ':')
/* 1537 */ return i > 0;
/* 1538 */ if (!URL.isSchemeChar(c)) {
/* 1539 */ return false;
/* */ }
/* */ }
/* 1542 */ return false;
/* */ }
/* */
代码示例来源:origin: codefollower/Tomcat-Research
/**
* Compare two URLs for equality. The result is <code>true</code> if and
* only if the argument is not null, and is a <code>URL</code> object
* that represents the same <code>URL</code> as this object. Two
* <code>URLs</code> are equal if they have the same protocol and
* reference the same host, the same port number on the host,
* and the same file and anchor on the host.
*
* @param obj The URL to compare against
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof URL))
return (false);
URL other = (URL) obj;
if (!sameFile(other))
return (false);
return (compare(ref, other.getRef()));
}
代码示例来源:origin: org.apache.coyote.springsource/com.springsource.org.apache.coyote.springsource
} else if( c == '#' ) {
aRef = true;
} else if( !isSchemeChar((char)c) ) {
break;
newProtocol.equalsIgnoreCase(context.getProtocol()))) {
if ((context.getPath() != null) &&
(context.getPath().startsWith("/")))
newProtocol = null;
if (newProtocol == null) {
protocol = context.getProtocol();
authority = context.getAuthority();
userInfo = context.getUserInfo();
host = context.getHost();
port = context.getPort();
file = context.getFile();
int question = file.lastIndexOf("?");
if (question < 0)
parse(spec, start, limit);
if (context != null)
normalize();
代码示例来源:origin: tomcat/catalina
url = new URL(location);
} catch (MalformedURLException e) {
return (false);
if (!hreq.getScheme().equalsIgnoreCase(url.getProtocol()))
return (false);
if (!hreq.getServerName().equalsIgnoreCase(url.getHost()))
return (false);
int serverPort = hreq.getServerPort();
serverPort = 80;
int urlPort = url.getPort();
if (urlPort == -1) {
if ("https".equals(url.getProtocol()))
urlPort = 443;
else
String file = url.getFile();
if ((file == null) || !file.startsWith(contextPath))
return (false);
代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7
} else if( c == '#' ) {
aRef = true;
} else if( !isSchemeChar((char)c) ) {
break;
newProtocol.equalsIgnoreCase(context.getProtocol()))) {
if ((context.getPath() != null) &&
(context.getPath().startsWith("/")))
newProtocol = null;
if (newProtocol == null) {
protocol = context.getProtocol();
authority = context.getAuthority();
userInfo = context.getUserInfo();
host = context.getHost();
port = context.getPort();
file = context.getFile();
int question = file.lastIndexOf("?");
if (question < 0)
parse(spec, start, limit);
if (context != null)
normalize();
代码示例来源:origin: jboss.web/jbossweb
url = new URL(location);
} catch (MalformedURLException e) {
return (false);
if (!hreq.getScheme().equalsIgnoreCase(url.getProtocol()))
return (false);
if (!hreq.getServerName().equalsIgnoreCase(url.getHost()))
return (false);
int serverPort = hreq.getServerPort();
serverPort = 80;
int urlPort = url.getPort();
if (urlPort == -1) {
if ("https".equals(url.getProtocol()))
urlPort = 443;
else
String file = url.getFile();
if ((file == null) || !file.startsWith(contextPath))
return (false);
代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina
} else if( c == '#' ) {
aRef = true;
} else if( !isSchemeChar((char)c) ) {
break;
newProtocol.equalsIgnoreCase(context.getProtocol()))) {
if ((context.getPath() != null) &&
(context.getPath().startsWith("/")))
newProtocol = null;
if (newProtocol == null) {
protocol = context.getProtocol();
authority = context.getAuthority();
userInfo = context.getUserInfo();
host = context.getHost();
port = context.getPort();
file = context.getFile();
int question = file.lastIndexOf("?");
if (question < 0)
parse(spec, start, limit);
if (context != null)
normalize();
代码示例来源:origin: org.osivia.portal.core/osivia-portal-jbossas-jbossweb-lib
/* 1406 */ url = new URL(location);
/* */ } catch (MalformedURLException e) {
/* 1408 */ return false;
/* 1412 */ if (!hreq.getScheme().equalsIgnoreCase(url.getProtocol()))
/* 1413 */ return false;
/* 1414 */ if (!hreq.getServerName().equalsIgnoreCase(url.getHost()))
/* 1415 */ return false;
/* 1416 */ int serverPort = hreq.getServerPort();
/* 1421 */ serverPort = 80;
/* 1423 */ int urlPort = url.getPort();
/* 1424 */ if (urlPort == -1) {
/* 1425 */ if ("https".equals(url.getProtocol()))
/* 1426 */ urlPort = 443;
/* */ else
/* 1435 */ String file = url.getFile();
/* 1436 */ if ((file == null) || (!file.startsWith(contextPath)))
/* 1437 */ return false;
代码示例来源:origin: jboss.web/jbossweb
/**
* Compare two URLs, excluding the "ref" fields. Returns <code>true</code>
* if this <code>URL</code> and the <code>other</code> argument both refer
* to the same resource. The two <code>URLs</code> might not both contain
* the same anchor.
*/
public boolean sameFile(URL other) {
if (!compare(protocol, other.getProtocol()))
return (false);
if (!compare(host, other.getHost()))
return (false);
if (port != other.getPort())
return (false);
if (!compare(file, other.getFile()))
return (false);
return (true);
}
代码示例来源:origin: org.apache.coyote.springsource/com.springsource.org.apache.coyote.springsource
/**
* Compare two URLs for equality. The result is <code>true</code> if and
* only if the argument is not null, and is a <code>URL</code> object
* that represents the same <code>URL</code> as this object. Two
* <code>URLs</code> are equal if they have the same protocol and
* reference the same host, the same port number on the host,
* and the same file and anchor on the host.
*
* @param obj The URL to compare against
*/
public boolean equals(Object obj) {
if (obj == null)
return (false);
if (!(obj instanceof URL))
return (false);
URL other = (URL) obj;
if (!sameFile(other))
return (false);
return (compare(ref, other.getRef()));
}
代码示例来源:origin: org.jboss.web/jbossweb
/**
* Determine if a URI string has a <code>scheme</code> component.
*/
private boolean hasScheme(String uri) {
int len = uri.length();
for(int i=0; i < len ; i++) {
char c = uri.charAt(i);
if(c == ':') {
return i > 0;
} else if(!URL.isSchemeChar(c)) {
return false;
}
}
return false;
}
代码示例来源:origin: org.apache.coyote/com.springsource.org.apache.coyote
} else if( c == '#' ) {
aRef = true;
} else if( !isSchemeChar((char)c) ) {
break;
newProtocol.equalsIgnoreCase(context.getProtocol()))) {
if ((context.getPath() != null) &&
(context.getPath().startsWith("/")))
newProtocol = null;
if (newProtocol == null) {
protocol = context.getProtocol();
authority = context.getAuthority();
userInfo = context.getUserInfo();
host = context.getHost();
port = context.getPort();
file = context.getFile();
int question = file.lastIndexOf("?");
if (question < 0)
parse(spec, start, limit);
if (context != null)
normalize();
代码示例来源:origin: org.jboss.web/jbossweb
url = new URL(location);
} catch (MalformedURLException e) {
return (false);
if (!hreq.getScheme().equalsIgnoreCase(url.getProtocol()))
return (false);
if (!hreq.getServerName().equalsIgnoreCase(url.getHost()))
return (false);
int serverPort = hreq.getServerPort();
serverPort = 80;
int urlPort = url.getPort();
if (urlPort == -1) {
if ("https".equals(url.getProtocol()))
urlPort = 443;
else
return (false);
String file = url.getFile();
if (file == null)
return (false);
代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7
/**
* Compare two URLs, excluding the "ref" fields. Returns <code>true</code>
* if this <code>URL</code> and the <code>other</code> argument both refer
* to the same resource. The two <code>URLs</code> might not both contain
* the same anchor.
*/
public boolean sameFile(URL other) {
if (!compare(protocol, other.getProtocol()))
return (false);
if (!compare(host, other.getHost()))
return (false);
if (port != other.getPort())
return (false);
if (!compare(file, other.getFile()))
return (false);
return (true);
}
代码示例来源:origin: org.apache.coyote/com.springsource.org.apache.coyote
/**
* Compare two URLs for equality. The result is <code>true</code> if and
* only if the argument is not null, and is a <code>URL</code> object
* that represents the same <code>URL</code> as this object. Two
* <code>URLs</code> are equal if they have the same protocol and
* reference the same host, the same port number on the host,
* and the same file and anchor on the host.
*
* @param obj The URL to compare against
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof URL))
return (false);
URL other = (URL) obj;
if (!sameFile(other))
return (false);
return (compare(ref, other.getRef()));
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
/**
* Determine if a URI string has a <code>scheme</code> component.
*/
private boolean hasScheme(String uri) {
int len = uri.length();
for(int i=0; i < len ; i++) {
char c = uri.charAt(i);
if(c == ':') {
return i > 0;
} else if(!URL.isSchemeChar(c)) {
return false;
}
}
return false;
}
代码示例来源:origin: codefollower/Tomcat-Research
} else if( c == '#' ) {
aRef = true;
} else if( !isSchemeChar((char)c) ) {
break;
newProtocol.equalsIgnoreCase(context.getProtocol()))) {
if ((context.getPath() != null) &&
(context.getPath().startsWith("/")))
newProtocol = null;
if (newProtocol == null) {
protocol = context.getProtocol();
authority = context.getAuthority();
userInfo = context.getUserInfo();
host = context.getHost();
port = context.getPort();
file = context.getFile();
int question = file.lastIndexOf("?");
if (question < 0)
parse(spec, start, limit);
if (context != null)
normalize();
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
url = new URL(location);
} catch (MalformedURLException e) {
return (false);
if (!hreq.getScheme().equalsIgnoreCase(url.getProtocol()))
return (false);
if (!hreq.getServerName().equalsIgnoreCase(url.getHost()))
return (false);
int serverPort = hreq.getServerPort();
serverPort = 80;
int urlPort = url.getPort();
if (urlPort == -1) {
if ("https".equals(url.getProtocol()))
urlPort = 443;
else
String file = url.getFile();
if ((file == null) || !file.startsWith(contextPath))
return (false);
代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina
/**
* Compare two URLs, excluding the "ref" fields. Returns <code>true</code>
* if this <code>URL</code> and the <code>other</code> argument both refer
* to the same resource. The two <code>URLs</code> might not both contain
* the same anchor.
*/
public boolean sameFile(URL other) {
if (!compare(protocol, other.getProtocol()))
return (false);
if (!compare(host, other.getHost()))
return (false);
if (port != other.getPort())
return (false);
if (!compare(file, other.getFile()))
return (false);
return (true);
}
内容来源于网络,如有侵权,请联系作者删除!