|
Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client 11g Release 1 (11.1.1) E17503-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoracle.adfnmc.java.net.URLConnection
public abstract class URLConnection
The URLConnection class is responsible for establishing a connection to an URL for a given protocol. The correct
URLConnection subclass to call is determined by URLStreamHandler.openConnection()
.
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)
Creates a URLConnection pointing to the resource specified by the url |
Method Summary | |
---|---|
void |
addRequestProperty(java.lang.String field,
java.lang.String newValue)
Adds the given request property. |
abstract void |
connect()
Establishes the connection to the resource specified by this URL with this method , along
with other options that can only be set before this connection is made. |
boolean |
getAllowUserInteraction()
Answers the value of allowUserInteraction which indicates if this connection allows user interaction |
int |
getConnectTimeout()
Returns a timeout of connection by milliseconds |
java.lang.Object |
getContent()
Answers the object pointed to by this URL . |
java.lang.Object |
getContent(java.lang.Class[] types)
Answers the object pointed to by this URL . |
java.lang.String |
getContentEncoding()
Answers the Content encoding type of the response body, null if no such field is found in the header response. |
int |
getContentLength()
Answers the length of the content or body in the response header in bytes. |
java.lang.String |
getContentType()
Answers the type of the content. |
long |
getDate()
Answers the date in milliseconds since epoch when this response header was created, or 0 if the field Date is not found in the header. |
static boolean |
getDefaultAllowUserInteraction()
Answers whether this connection allow user interaction by default. |
static java.lang.String |
getDefaultRequestProperty(java.lang.String field)
Deprecated. Use getRequestProperty(). |
boolean |
getDefaultUseCaches()
Answers whether this connection use caches by default. |
boolean |
getDoInput()
Answers whether this connection supports input. |
boolean |
getDoOutput()
Answers whether this connection supports output. |
long |
getExpiration()
Answers the date in milliseconds since epoch when this response header expires or 0 if the field Expires is not found in the header. |
static FileNameMap |
getFileNameMap()
Answers the MIME table of this URL connection. |
java.lang.String |
getHeaderField(int pos)
Answers the value of the field at position pos |
java.lang.String |
getHeaderField(java.lang.String key)
Answers the value of the field corresponding to the key Answers null if there is no such
field. |
long |
getHeaderFieldDate(java.lang.String field,
long defaultValue)
Answers the date value in the form of milliseconds since epoch corresponding to the field field . |
int |
getHeaderFieldInt(java.lang.String field,
int defaultValue)
Answers the integer value of the specified field. |
java.lang.String |
getHeaderFieldKey(int posn)
Answers the name of the field at position specified by posn , null if there are fewer than
posn fields. |
Map |
getHeaderFields()
Provides an unmodifiable map of the connection header values. |
long |
getIfModifiedSince()
Answers the value of ifModifiedSince of this connection in milliseconds since epoch |
java.io.InputStream |
getInputStream()
Creates an InputStream for reading from this URL Connection. |
long |
getLastModified()
Answers the value of the field Last-Modified in the response header, 0 if no such field exists |
java.io.OutputStream |
getOutputStream()
Creates an OutputStream for writing to this URL Connection. |
oracle.adfnmc.java.security.Permission |
getPermission()
Answers the permissions necessary to make the connection. |
int |
getReadTimeout()
Returns a timeout of reading by milliseconds |
Map |
getRequestProperties()
Provides an unmodifiable map of the request properties. |
java.lang.String |
getRequestProperty(java.lang.String field)
Answers the value corresponding to the field in the request Header, null if no such field exists. |
URL |
getURL()
Answers the URL of this connection |
boolean |
getUseCaches()
Answers whether this connection uses caches |
static java.lang.String |
guessContentTypeFromName(java.lang.String url)
Determines the MIME type of the file specified by the string URL, using the filename extension. |
static java.lang.String |
guessContentTypeFromStream(java.io.InputStream is)
Examines the bytes of the input stream and returns the MIME type, null if no content type can be deduced. |
void |
setAllowUserInteraction(boolean newValue)
Sets the flag indicating whether this connection allows user interaction This can only be called prior to connection establishment. |
void |
setConnectTimeout(int timeout)
Sets a timeout for connection to perform non-block. |
static void |
setContentHandlerFactory(ContentHandlerFactory contentFactory)
Sets the current content handler factory to be contentFactory . |
static void |
setDefaultAllowUserInteraction(boolean allows)
Set whether user interaction is allowed by default. |
static void |
setDefaultRequestProperty(java.lang.String field,
java.lang.String value)
Deprecated. Use getRequestProperty(). |
void |
setDefaultUseCaches(boolean newValue)
Set whether caches are used by default. |
void |
setDoInput(boolean newValue)
Sets whether this URLConnection allows input. |
void |
setDoOutput(boolean newValue)
Sets whether this URLConnection allows output. |
static void |
setFileNameMap(FileNameMap map)
With permission from the security manager, this method sets the map to be the MIME Table of this URL
connection. |
void |
setIfModifiedSince(long newValue)
Sets the header field ifModifiedSince . |
void |
setReadTimeout(int timeout)
Sets a timeout for reading to perform non-block. |
void |
setRequestProperty(java.lang.String field,
java.lang.String newValue)
Sets the value of the request header field field to newValue Only the current URL
Connection is affected. |
void |
setUseCaches(boolean newValue)
Sets the flag indicating if this connection uses caches. |
java.lang.String |
toString()
Answers the name of the class of the URLConnection |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected URL url
protected long ifModifiedSince
protected boolean useCaches
protected boolean connected
protected boolean doOutput
protected boolean doInput
protected boolean allowUserInteraction
Constructor Detail |
---|
protected URLConnection(URL url)
url
Method Detail |
---|
public abstract void connect() throws java.io.IOException
URL
with this method
, along
with other options that can only be set before this connection is made.
java.io.IOException
- If an error occurs while connectingIOException
,
URLStreamHandler
public boolean getAllowUserInteraction()
allowUserInteraction
which indicates if this connection allows user interaction
getDefaultRequestProperty(java.lang.String)
,
setDefaultRequestProperty(java.lang.String, java.lang.String)
,
allowUserInteraction
public java.lang.Object getContent() throws java.io.IOException
URL
. It first attempts to get the content type from
getContentType()
, which looks for the response header field "Content-Type". If none is found, it will
guess the content type from the filename extension. If that fails, it will guess by inspecting the stream.
java.io.IOException
- if an IO error occurredContentHandler
,
ContentHandlerFactory
,
IOException
,
setContentHandlerFactory(oracle.adfnmc.java.net.ContentHandlerFactory)
public java.lang.Object getContent(java.lang.Class[] types) throws java.io.IOException
URL
. It first attempts to get the content type from
getContentType()
, which looks for the response header field "Content-Type". If none is found, it will
guess the content type from the filename extension. If that fails, it will guess by inspecting the stream.
types
- The list of acceptable content types
java.io.IOException
- If an error occurred obtaining the content.public java.lang.String getContentEncoding()
getContentType()
public int getContentLength()
Content-Length
cannot be found in the response header.
getContentType()
public java.lang.String getContentType()
null
if there's no such field.
guessContentTypeFromName(java.lang.String)
,
guessContentTypeFromStream(java.io.InputStream)
public long getDate()
Date
is not found in the header.
getExpiration()
,
getLastModified()
,
Date
public static boolean getDefaultAllowUserInteraction()
defaultAllowUserInteraction
getAllowUserInteraction()
,
setDefaultAllowUserInteraction(boolean)
,
setAllowUserInteraction(boolean)
,
allowUserInteraction
public static java.lang.String getDefaultRequestProperty(java.lang.String field)
field
, null if there's no such field.
field
- the field to get the request property for
public boolean getDefaultUseCaches()
getUseCaches()
,
setDefaultUseCaches(boolean)
,
setUseCaches(boolean)
,
useCaches
public boolean getDoInput()
setDoInput(boolean)
,
doInput
public boolean getDoOutput()
setDoOutput(boolean)
,
doOutput
public long getExpiration()
Expires
is not found in the header.
getHeaderField(int)
,
getHeaderField(String)
,
getHeaderFieldDate(String, long)
,
getHeaderFieldInt(String, int)
,
getHeaderFieldKey(int)
public static FileNameMap getFileNameMap()
public java.lang.String getHeaderField(int pos)
pos.
Answers null
if there are fewer than pos
fields in the response header.
- Parameters:
pos
- the position of the field
- Returns:
- The value of the field
- See Also:
getHeaderFieldDate(java.lang.String, long)
,
getHeaderFieldInt(java.lang.String, int)
,
getHeaderFieldKey(int)
public Map getHeaderFields()
public Map getRequestProperties()
public void addRequestProperty(java.lang.String field, java.lang.String newValue)
field
- the request property field namenewValue
- the property value
java.lang.IllegalStateException
- - if connection already established
java.lang.NullPointerException
- - if field is nullpublic java.lang.String getHeaderField(java.lang.String key)
key
Answers null
if there is no such
field.
key
- the name of the header field
getHeaderFieldDate(java.lang.String, long)
,
getHeaderFieldInt(java.lang.String, int)
,
getHeaderFieldKey(int)
public long getHeaderFieldDate(java.lang.String field, long defaultValue)
field
.
Answers defaultValue
if no such field can be found in the response header.
field
- the field in questiondefaultValue
- the default value if no field is found or the value is invalid
ifModifiedSince
,
setIfModifiedSince(long)
public int getHeaderFieldInt(java.lang.String field, int defaultValue)
defaultValue
if no such field
exists.
field
- the field to returndefaultValue
- to be returned if field>
does not exist
public java.lang.String getHeaderFieldKey(int posn)
posn
, null if there are fewer than
posn
fields.
posn
- the position to look for; the first field being 0
getHeaderFieldDate(java.lang.String, long)
,
getHeaderFieldInt(java.lang.String, int)
,
getHeaderField(int)
,
getHeaderField(String)
,
getHeaderFieldDate(String, long)
,
getHeaderFieldInt(String, int)
,
getHeaderFieldKey(int)
public long getIfModifiedSince()
ifModifiedSince
of this connection in milliseconds since epoch
ifModifiedSince
,
setIfModifiedSince(long)
public java.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
- If an InputStream could not be createdgetContent()
,
getContent(Class[])
,
getOutputStream()
,
InputStream
,
IOException
public long getLastModified()
Last-Modified
in the response header, 0 if no such field exists
Date
,
getDate()
,
getExpiration()
public java.io.OutputStream getOutputStream() throws java.io.IOException
java.io.IOException
- If an OutputStream could not be createdgetContent()
,
getContent(Class[])
,
getInputStream()
,
IOException
public oracle.adfnmc.java.security.Permission getPermission() throws java.io.IOException
By default, this methods returns AllPermission
. Subclasses should override this and return the
appropriate permission object.
java.io.IOException
- if an IO exception occurs during the creation of the permission object.public java.lang.String getRequestProperty(java.lang.String field)
field
- the field to get the property for
java.lang.IllegalStateException
- - if connection already establishedgetDefaultRequestProperty(java.lang.String)
,
setDefaultRequestProperty(java.lang.String, java.lang.String)
,
setRequestProperty(java.lang.String, java.lang.String)
public URL getURL()
URL
of this connection
URL
,
URLConnection(URL)
public boolean getUseCaches()
public static java.lang.String guessContentTypeFromName(java.lang.String url)
string
URL, using the filename extension. Any
fragment identifier is removed before processing.
url
- the MIME type of the file.
FileNameMap
,
FileNameMap.getContentTypeFor(String)
,
getContentType()
,
guessContentTypeFromStream(java.io.InputStream)
public static java.lang.String guessContentTypeFromStream(java.io.InputStream is) throws java.io.IOException
is
- the input stream for the URL
java.io.IOException
- If an IO error occurspublic void setAllowUserInteraction(boolean newValue)
newValue
- the value of the flag to be set
java.lang.IllegalStateException
- if this method attempts to change the flag after a connection has been establishedpublic static void setContentHandlerFactory(ContentHandlerFactory contentFactory)
contentFactory
. It can only do so with the permission
of the security manager. The ContentFactory can only be specified once during the lifetime of an application.
contentFactory
- the factory
java.lang.Error
- if a ContentFactory has been created before SecurityException if the security manager does not allow this
actionContentHandler
,
ContentHandlerFactory
,
SecurityException
,
java.lang.SecurityManager#checkSetFactory()
public static void setDefaultAllowUserInteraction(boolean allows)
allows
- allow user interactionpublic static void setDefaultRequestProperty(java.lang.String field, java.lang.String value)
field
in the default request header with the value value
field
- the request header field to be setvalue
- the new valuepublic void setDefaultUseCaches(boolean newValue)
newValue
- the value of the flag to be setgetDefaultUseCaches()
,
getUseCaches()
,
setUseCaches(boolean)
,
useCaches
public void setDoInput(boolean newValue)
newValue
- boolean
IllegalAccessError
- Exception thrown when this method attempts to change the value after connecteddoInput
,
getDoInput()
,
setDoInput(boolean)
,
java.lang.IllegalAccessError
public void setDoOutput(boolean newValue)
newValue
- boolean
IllegalAccessError
- Exception thrown when this method attempts to change the value after connecteddoOutput
,
getDoOutput()
,
setDoOutput(boolean)
,
java.lang.IllegalAccessError
public static void setFileNameMap(FileNameMap map)
map
to be the MIME Table of this URL
connection.
map
- the MIME table to be set.public void setIfModifiedSince(long newValue)
ifModifiedSince
.
newValue
- number of milliseconds since epoch
java.lang.IllegalStateException
- if already connected.public void setRequestProperty(java.lang.String field, java.lang.String newValue)
field
to newValue
Only the current URL
Connection is affected. It can only be called before the connection is made
field
- the fieldnewValue
- the field's new value
java.lang.IllegalStateException
- - if connection already established
java.lang.NullPointerException
- - if field is nullgetDefaultRequestProperty(java.lang.String)
,
setDefaultRequestProperty(java.lang.String, java.lang.String)
,
getRequestProperty(java.lang.String)
public void setUseCaches(boolean newValue)
newValue
- the value of the flag to be set
java.lang.IllegalStateException
- Exception thrown when this method attempts to change the value after connectedgetDefaultUseCaches()
,
setDefaultUseCaches(boolean)
,
getUseCaches()
,
useCaches
public void setConnectTimeout(int timeout)
timeout
- timeout for connection in milliseconds.
java.lang.IllegalArgumentException
- if timeout is less than zero.public int getConnectTimeout()
public void setReadTimeout(int timeout)
timeout
- timeout for reading in milliseconds.
java.lang.IllegalArgumentException
- if timeout is less than zero.public int getReadTimeout()
public java.lang.String toString()
URLConnection
toString
in class java.lang.Object
URLConnection
getURL()
,
URLConnection(URL)
|
Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client 11g Release 1 (11.1.1) E17503-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |