|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.net.URLConnection
A class to represent an active connection to an object represented by a URL. It is an abstract class that must be subclassed to implement a connection.
Field Summary | |
protected boolean |
allowUserInteraction
|
protected boolean |
connected
|
protected boolean |
doInput
|
protected boolean |
doOutput
|
protected long |
ifModifiedSince
|
protected URL |
url
|
protected boolean |
useCaches
|
Constructor Summary | |
protected |
URLConnection(URL url)
Constructs a URL connection to the specified URL. |
Method Summary | |
abstract void |
connect()
URLConnection objects go through two phases: first they are created, then they are connected. |
boolean |
getAllowUserInteraction()
|
Object |
getContent()
Gets the object referred to by this URL. |
String |
getContentEncoding()
Gets the content encoding. |
int |
getContentLength()
Gets the content length. |
String |
getContentType()
Gets the content type. |
long |
getDate()
Gets the sending date of the object. |
static boolean |
getDefaultAllowUserInteraction()
|
static String |
getDefaultRequestProperty(String key)
|
boolean |
getDefaultUseCaches()
Sets/gets the default value of the UseCaches flag. |
boolean |
getDoInput()
|
boolean |
getDoOutput()
|
long |
getExpiration()
Gets the expriation date of the object. |
String |
getHeaderField(int n)
Returns the value for the nth header field. |
String |
getHeaderField(String name)
Gets a header field by name. |
long |
getHeaderFieldDate(String name,
long Default)
Gets a header field by name. |
int |
getHeaderFieldInt(String name,
int Default)
Gets a header field by name. |
String |
getHeaderFieldKey(int n)
Returns the key for the nth header field. |
long |
getIfModifiedSince()
|
InputStream |
getInputStream()
Calls this routine to get an InputStream that reads from the object. |
long |
getLastModified()
Gets the last modified date of the object. |
OutputStream |
getOutputStream()
Calls this routine to get an OutputStream that writes to the object. |
String |
getRequestProperty(String key)
|
URL |
getURL()
Gets the URL for this connection. |
boolean |
getUseCaches()
|
protected static String |
guessContentTypeFromName(String fname)
A useful utility routine that tries to guess the content-type of an object based upon its extension. |
protected static String |
guessContentTypeFromStream(InputStream is)
This method is used to check for files that have some type that can be determined by inspection. |
void |
setAllowUserInteraction(boolean allowuserinteraction)
Some URL connections occasionally need to to interactions with the user. |
static void |
setContentHandlerFactory(ContentHandlerFactory fac)
Sets the ContentHandler factory. |
static void |
setDefaultAllowUserInteraction(boolean defaultallowuserinteraction)
Sets/gets the default value of the allowUserInteraction flag. |
static void |
setDefaultRequestProperty(String key,
String value)
Sets/gets the default value of a general request property. |
void |
setDefaultUseCaches(boolean defaultusecaches)
|
void |
setDoInput(boolean doinput)
A URL connection can be used for input and/or output. |
void |
setDoOutput(boolean dooutput)
A URL connection can be used for input and/or output. |
void |
setIfModifiedSince(long ifmodifiedsince)
Some protocols support skipping fetching unless the object is newer than some amount of time. |
void |
setRequestProperty(String key,
String value)
Sets/gets a general request property. |
void |
setUseCaches(boolean usecaches)
Some protocols do caching of documents. |
String |
toString()
Returns the String representation of the URL connection. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected URL url
protected boolean doInput
protected boolean doOutput
protected boolean allowUserInteraction
protected boolean useCaches
protected long ifModifiedSince
protected boolean connected
Constructor Detail |
protected URLConnection(URL url)
url
- the specified URLMethod Detail |
public abstract void connect() throws IOException
IOException
public URL getURL()
public int getContentLength()
public String getContentType()
public String getContentEncoding()
public long getExpiration()
public long getDate()
public long getLastModified()
public String getHeaderField(String name)
name
- the name of the header fieldpublic int getHeaderFieldInt(String name, int Default)
name
- the name of the header fieldDefault
- the value to return if the field is missing
or malformed.public long getHeaderFieldDate(String name, long Default)
name
- the name of the header fieldDefault
- the value to return if the field is missing
or malformed.public String getHeaderFieldKey(int n)
public String getHeaderField(int n)
public Object getContent() throws IOException
UnknownServiceException
- If the protocol does not
support content.
IOException
public InputStream getInputStream() throws IOException
UnknownServiceException
- If the protocol does not
support input.
IOException
public OutputStream getOutputStream() throws IOException
UnknownServiceException
- If the protocol does not
support output.
IOException
public String toString()
toString
in class Object
public void setDoInput(boolean doinput)
public boolean getDoInput()
public void setDoOutput(boolean dooutput)
public boolean getDoOutput()
public void setAllowUserInteraction(boolean allowuserinteraction)
public boolean getAllowUserInteraction()
public static void setDefaultAllowUserInteraction(boolean defaultallowuserinteraction)
public static boolean getDefaultAllowUserInteraction()
public void setUseCaches(boolean usecaches)
public boolean getUseCaches()
public void setIfModifiedSince(long ifmodifiedsince)
public long getIfModifiedSince()
public boolean getDefaultUseCaches()
public void setDefaultUseCaches(boolean defaultusecaches)
public void setRequestProperty(String key, String value)
key
- The keyword by which the request is known (eg "accept")value
- The value associated with it.public String getRequestProperty(String key)
public static void setDefaultRequestProperty(String key, String value)
key
- The keyword by which the request is known (eg "accept")value
- The value associated with it.public static String getDefaultRequestProperty(String key)
public static void setContentHandlerFactory(ContentHandlerFactory fac)
fac
- the desired factory
Error
- If the factory has already been defined.protected static String guessContentTypeFromName(String fname)
protected static String guessContentTypeFromStream(InputStream is) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |