|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectoranjestad.commons.io.AbstractResource
oranjestad.commons.io.URLResource
public class URLResource
Resource over a URL object. URL's are typically
used as read only references, but URLs can supported write semantics. This
resource will attempt to support writes if the underlying protocol supports
them.
URLResource resource = new URLResource( new URL("..."));
This resource supports ant style property expansion. An ant
property reference ${property name} will be expanded before
converting strings to URLs.
| Constructor Summary | |
|---|---|
protected |
URLResource()
Internal constructor used by subclasses. |
|
URLResource(java.lang.String urlString)
Creates a URL resource based on the supplied URL string. |
|
URLResource(java.net.URL theURL)
Creates a URL resource over the supplied URL. |
| Method Summary | |
|---|---|
boolean |
canReopen()
Flag that lets you check if this resource supports reopening of the InputStream. |
boolean |
equals(java.lang.Object o)
|
boolean |
exists()
Attempts to open a connection to the URL, if the connection is succesful then the resource is considered to exist. |
java.io.InputStream |
getInputStream()
An open input stream at the beginning of the resource. |
java.io.OutputStream |
getOutputStream()
Attempts to obtain an output stream to the resource identified by the URL. |
int |
hashCode()
|
boolean |
isReadOnly()
Flag that lets you check if this resource supports writes. |
void |
setReadOnly(boolean flag)
Sets the read only flag. |
java.lang.String |
toString()
|
| Methods inherited from class oranjestad.commons.io.AbstractResource |
|---|
expand |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public URLResource(java.net.URL theURL)
theURL - The URL to read/write from.
public URLResource(java.lang.String urlString)
throws java.net.MalformedURLException
urlString - The URL string (can include ant style properties).
java.net.MalformedURLException - If the string specifies an unknown protocolprotected URLResource()
| Method Detail |
|---|
public void setReadOnly(boolean flag)
Sets the read only flag. This flag in no way alters the underlying URL object but instead instructs this resource to not attempt ever write to this URL.
When true, this flag delegates to the actual URL protocol,
which itself may not support writes.
flag - Whether or not to attempt writes (true no writes,
false will attempt writes).
public java.io.InputStream getInputStream()
throws java.io.IOException
ResourceAn open input stream at the beginning of the resource. If the resource
doesn not support reopening, this method might
throw an IllegalStateException. Otherwise subsequent calls
to this method return a new input stream set to the beginning of the
data stream.
java.io.IOException - If an I/O related error occurs.
public java.io.OutputStream getOutputStream()
throws java.io.IOException,
java.lang.IllegalStateException
java.io.IOException - If an I/O related error occurs.
java.lang.IllegalStateExceptionpublic boolean isReadOnly()
ResourceFlag that lets you check if this resource supports writes.
true if this resource is configured
to be read only, or if the underlying protocol indicates it is not read only.public boolean canReopen()
ResourceFlag that lets you check if this resource supports reopening of the
InputStream. Some resources can only be read
once.
truepublic boolean exists()
true if the associated url can be connected
to, otherwise false.public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - The object to compare against.
true if o is a URLResource over an equal
URL object, otherwise false.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||