public class Locator
extends java.lang.Object
Locator
which refers to a
URI
.Modifier and Type | Class and Description |
---|---|
private static class |
Locator.LocatorConnection
Holds connection and response code returned from getConnection()
|
Modifier and Type | Field and Description |
---|---|
private LocatorCache.CacheReference |
cacheEntry |
private boolean |
canBlock |
private static long |
CONNECTION_RETRY_INTERVAL
The number of milliseconds between attempts to open a URL connection.
|
private static int |
CONNECTION_TIMEOUT
Timeout in milliseconds to wait for connection (5 min).
|
private java.util.Map<java.lang.String,java.lang.Object> |
connectionProperties
Properties to be associated with the connection made to the URI.
|
protected long |
contentLength
A hint for the internal player.
|
protected java.lang.String |
contentType
The content type of the media content.
|
static java.lang.String |
DEFAULT_CONTENT_TYPE
The content type used if no more specific one may be derived.
|
private boolean |
isIpod
iOS only: determines if the given URL points to the iPod library
|
private static int |
MAX_CONNECTION_ATTEMPTS
The number of times to attempt to open a URL connection to test the URI.
|
private java.lang.Object |
propertyLock
Mutex for connectionProperties;
|
private java.lang.String |
protocol |
private java.util.concurrent.CountDownLatch |
readySignal |
private java.lang.String |
scheme |
protected java.net.URI |
uri
The URI source.
|
private java.lang.String |
uriString |
Constructor and Description |
---|
Locator(java.net.URI uri)
Constructs an object representing a media source.
|
Modifier and Type | Method and Description |
---|---|
void |
cacheMedia()
Tell this Locator to preload the media into memory, if it hasn't been
already.
|
boolean |
canBlock() |
(package private) static void |
closeConnection(java.net.URLConnection connection) |
ConnectionHolder |
createConnectionHolder() |
private Locator.LocatorConnection |
getConnection(java.net.URI uri,
java.lang.String requestMethod) |
long |
getContentLength()
Retrieves the media size.
|
private static long |
getContentLengthLong(java.net.URLConnection connection) |
java.lang.String |
getContentType()
Retrieves the content type describing the media content or
"application/octet-stream" if no more specific content type
may be detected. |
private java.lang.String |
getContentTypeFromFileSignature(java.net.URI uri) |
private java.io.InputStream |
getInputStream(java.net.URI uri) |
java.lang.String |
getProtocol()
Retrieves the protocol of the media URL
|
java.lang.String |
getStringLocation() |
java.net.URI |
getURI()
Retrieves the associated
URI . |
void |
init() |
void |
setConnectionProperty(java.lang.String property,
java.lang.Object value)
Sets a property to be used by the connection to the media specified by
the URI.
|
java.lang.String |
toString()
Retrieves a string representation of the
Locator |
void |
waitForReadySignal()
Blocks until locator is ready (connection is established or failed).
|
public static final java.lang.String DEFAULT_CONTENT_TYPE
private static final int MAX_CONNECTION_ATTEMPTS
private static final long CONNECTION_RETRY_INTERVAL
private static final int CONNECTION_TIMEOUT
protected java.lang.String contentType
protected long contentLength
protected java.net.URI uri
private java.util.Map<java.lang.String,java.lang.Object> connectionProperties
private final java.lang.Object propertyLock
private java.lang.String uriString
private java.lang.String scheme
private java.lang.String protocol
private LocatorCache.CacheReference cacheEntry
private boolean canBlock
private java.util.concurrent.CountDownLatch readySignal
private boolean isIpod
public Locator(java.net.URI uri) throws java.net.URISyntaxException
uri
- The URI source.java.lang.NullPointerException
- if
uri
is
null
.java.lang.IllegalArgumentException
- if the URI's scheme is
null
.java.net.URISyntaxException
- if the supplied URI requires some further
manipulation in order to be used and this procedure fails to produce a
usable URI.java.lang.IllegalArgumentException
- if the URI is a Jar URL as described in
https://docs.oracle.com/javase/8/docs/api/java/net/JarURLConnection.html
,
and the scheme of the URL after removing the leading four characters is
null
.java.lang.UnsupportedOperationException
- if the URI's protocol is
unsupported.private Locator.LocatorConnection getConnection(java.net.URI uri, java.lang.String requestMethod) throws java.net.MalformedURLException, java.io.IOException
java.net.MalformedURLException
java.io.IOException
private static long getContentLengthLong(java.net.URLConnection connection)
private java.io.InputStream getInputStream(java.net.URI uri) throws java.net.MalformedURLException, java.io.IOException
java.net.MalformedURLException
java.io.IOException
public void cacheMedia()
public boolean canBlock()
public void init() throws java.net.URISyntaxException, java.io.IOException, java.io.FileNotFoundException
java.net.URISyntaxException
java.io.IOException
java.io.FileNotFoundException
public java.lang.String getContentType()
"application/octet-stream"
if no more specific content type
may be detected.public java.lang.String getProtocol()
public long getContentLength()
public void waitForReadySignal()
public java.net.URI getURI()
URI
.public java.lang.String toString()
Locator
toString
in class java.lang.Object
LocatorURI
as a
String
.public java.lang.String getStringLocation()
public void setConnectionProperty(java.lang.String property, java.lang.Object value)
createConnectionHolder()
or it will have no effect.property
- The name of the property.value
- The value of the property.public ConnectionHolder createConnectionHolder() throws java.io.IOException
java.io.IOException
private java.lang.String getContentTypeFromFileSignature(java.net.URI uri) throws java.net.MalformedURLException, java.io.IOException
java.net.MalformedURLException
java.io.IOException
static void closeConnection(java.net.URLConnection connection)