|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.net.URLStreamHandler
public abstract class URLStreamHandler
抽象类 URLStreamHandler 是所有流协议处理程序的通用超类。流协议处理程序知道如何为特定的协议类型,如 http、ftp 或 gopher 进行连接。
在大多数情况下,URLStreamHandler 子类的实例都不是由应用程序直接创建的。而是在构造 URL 过程中第一次遇到协议名称时,自动加载适当的流协议处理程序。
URL.URL(java.lang.String, java.lang.String, int, java.lang.String)| 构造方法摘要 | |
|---|---|
URLStreamHandler()
|
|
| 方法摘要 | |
|---|---|
protected boolean |
equals(URL u1,
URL u2)
提供默认的 equals 计算。 |
protected int |
getDefaultPort()
返回由该处理程序解析的 URL 的默认端口。 |
protected InetAddress |
getHostAddress(URL u)
获得主机的 IP 地址。 |
protected int |
hashCode(URL u)
提供默认的哈希计算。 |
protected boolean |
hostsEqual(URL u1,
URL u2)
比较两个 URL 的主机组件。 |
protected abstract URLConnection |
openConnection(URL u)
打开一个到 URL 参数引用的对象的连接。 |
protected URLConnection |
openConnection(URL u,
Proxy p)
与 openConnection(URL) 相同,不同点在于:通过指定的代理进行连接;不支持代理方式的协议处理程序将忽略该代理参数并进行正常的连接。 |
protected void |
parseURL(URL u,
String spec,
int start,
int limit)
将 URL 的字符表示形式解析为 URL 对象。 |
protected boolean |
sameFile(URL u1,
URL u2)
比较两个 url 以确定它们是否引用相同的文件(即具有相同的协议、主机、端口和路径)。 |
protected void |
setURL(URL u,
String protocol,
String host,
int port,
String file,
String ref)
已过时。 使用 setURL(URL, String, String, int, String, String, String, String); |
protected void |
setURL(URL u,
String protocol,
String host,
int port,
String authority,
String userInfo,
String path,
String query,
String ref)
将 URL 参数的字段设置为指示的值。 |
protected String |
toExternalForm(URL u)
将特定协议的 URL 转换为 String。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public URLStreamHandler()
| 方法详细信息 |
|---|
protected abstract URLConnection openConnection(URL u) throws IOException
URL 参数引用的对象的连接。此方法应该由子类重写。
如果对应处理程序的协议(例如,HTTP 或 JAR)存在属于以下包或其子包之一的公共、专用 URLConnection 子类:java.lang、java.io、java.util、java.net,返回的连接将为该子类的类型。例如,对于 HTTP,将返回 HttpURLConnection,对于 JAR,将返回 JarURLConnection。
u - 所连接的 URL。
URL 的 URLConnection 对象。
IOException - 如果打开连接时发生 I/O 错误。protected URLConnection openConnection(URL u, Proxy p) throws IOException
u - 所连接的 URL。p - 进行连接所通过的代理。如果希望使用直接连接,则应指定 Proxy.NO_PROXY。
URL 的 URLConnection 对象。
IOException - 如果打开连接时发生 I/O 错误。
IllegalArgumentException - 如果 u 或 p 为 null,或者 p 包含错误的类型。
UnsupportedOperationException - 如果实现该协议的子类不支持该方法。protected void parseURL(URL u, String spec, int start, int limit)
URL 的字符表示形式解析为 URL 对象。
如果有任何继承的上下文,则已将其复制到 URL 参数中。
URLStreamHandler 的 parseURL 方法按照 http 规范解析该字符串表示形式。多数 URL 协议家族的解析都很相似。具有不同语法的协议的流协议处理程序必须重写该例程。
u - 用于接收解析规范的结果的 URL。spec - 代表必须解析的 URL 的 String。start - 解析开始处的字符索引。其只传递 ':'(如果有一个),用来指定确定的协议名称。limit - 停止解析的字符位置。这是字符串的结束或 "#" 字符位置(如果有)。井号之后的所有信息都指示一个定位点。protected int getDefaultPort()
URL 的默认端口。protected boolean equals(URL u1, URL u2)
u1 - URL 对象u2 - URL 对象
protected int hashCode(URL u)
u - URL 对象
protected boolean sameFile(URL u1, URL u2)
u1 - URL 对象u2 - URL 对象
protected InetAddress getHostAddress(URL u)
u - URL 对象
InetAddress。protected boolean hostsEqual(URL u1, URL u2)
u1 - 要比较的第一个主机的 URLu2 - 要比较的第二个主机的 URL
protected String toExternalForm(URL u)
URL 转换为 String。
u - URL
URL 参数的字符串表示形式。protected void setURL(URL u, String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref)
URL 参数的字段设置为指示的值。只有从 URLStreamHandler 派生的类才能够在 URL 上调用 set 方法。
u - 要修改的 URL。protocol - 协议名称。host - 对应 URL 的远程主机值。port - 远程机器上的端口。authority - URL 的授权部分。userInfo - URL 的 userInfo 部分。path - URL 的 path 部分。query - URL 的 query 部分。ref - 引用。
SecurityException - 如果该 URL 的协议处理程序与这一个不同URL.set(java.lang.String, java.lang.String, int, java.lang.String, java.lang.String)@Deprecated protected void setURL(URL u, String protocol, String host, int port, String file, String ref)
URL 参数的字段设置为指示的值。只有从 URLStreamHandler 派生的类才能够在 URL 上调用 set 方法。
u - 要修改的 URL。protocol - 协议名称。从 1.2 开始,忽略了该值。host - 对应 URL 的远程主机值。port - 远程机器上的端口。file - 文件。ref - 引用。
SecurityException - 如果该 URL 的协议处理程序与这一个不同
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。