Top Description Inners Fields Constructors Methods
com.sun.media.jfxmedia.locator

public Class Locator

extends Object
Class Inheritance
Imports
com.sun.javafx.PlatformUtil, com.sun.media.jfxmedia.MediaException, .MediaManager, com.sun.media.jfxmedia.logging.Logger, com.sun.media.jfxmediaimpl.MediaUtils, java.io.FileNotFoundException, .IOException, .InputStream, java.lang.reflect.InvocationTargetException, .Method, java.net.HttpURLConnection, .JarURLConnection, .MalformedURLException, .URI, .URISyntaxException, .URL, .URLConnection, java.nio.ByteBuffer, java.util.Map, .TreeMap, java.util.concurrent.CountDownLatch

A Locator which refers to a URI.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Locator.LocatorConnection

Holds connection and response code returned from getConnection()

Field Summary

Modifier and TypeField and Description
private LocatorCache.CacheReference
private boolean
private static final long
CONNECTION_RETRY_INTERVAL

The number of milliseconds between attempts to open a URL connection.

private static final int
CONNECTION_TIMEOUT

Timeout in milliseconds to wait for connection (5 min).

private Map<String, Object>
connectionProperties

Properties to be associated with the connection made to the URI.

protected long
contentLength

A hint for the internal player.

protected String
contentType

The content type of the media content.

public static final 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 final int
MAX_CONNECTION_ATTEMPTS

The number of times to attempt to open a URL connection to test the URI.

private final Object
propertyLock

Mutex for connectionProperties;

private String
private CountDownLatch
private String
protected URI
uri

The URI source.

private String

Constructor Summary

AccessConstructor and Description
public
Locator(URI
The URI source.
uri
)

Constructs an object representing a media source.

Method Summary

Modifier and TypeMethod and Description
public void
cacheMedia()

Tell this Locator to preload the media into memory, if it hasn't been already.

public boolean
pack-priv static void
public ConnectionHolder
public ConnectionHolder
private Locator.LocatorConnection
getConnection(URI uri, String requestMethod)

public long

Returns:

size of the media file in bytes. -1 indicates unknown, which may happen with network streams.
getContentLength
()

Retrieves the media size.

private static long
public String
getContentType()

Retrieves the content type describing the media content or "application/octet-stream" if no more specific content type may be detected.

private String
private InputStream
public String
getProtocol()

Retrieves the protocol of the media URL

public String
public URI

Returns:

The URI source.
getURI
()

Retrieves the associated URI.

public void
init()

public void
setConnectionProperty(String
The name of the property.
property
,
Object
The value of the property.
value
)

Sets a property to be used by the connection to the media specified by the URI.

public String

Returns:

The LocatorURI as a String.
toString
()

Overrides java.lang.Object.toString.

Retrieves a string representation of the Locator

public void
waitForReadySignal()

Blocks until locator is ready (connection is established or failed).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cacheEntryback to summary
private LocatorCache.CacheReference cacheEntry
canBlockback to summary
private boolean canBlock
CONNECTION_RETRY_INTERVALback to summary
private static final long CONNECTION_RETRY_INTERVAL

The number of milliseconds between attempts to open a URL connection.

CONNECTION_TIMEOUTback to summary
private static final int CONNECTION_TIMEOUT

Timeout in milliseconds to wait for connection (5 min).

connectionPropertiesback to summary
private Map<String, Object> connectionProperties

Properties to be associated with the connection made to the URI. The significance of the properties depends on the URI protocol and type of media source.

contentLengthback to summary
protected long contentLength

A hint for the internal player.

contentTypeback to summary
protected String contentType

The content type of the media content.

DEFAULT_CONTENT_TYPEback to summary
public static final String DEFAULT_CONTENT_TYPE

The content type used if no more specific one may be derived.

isIpodback to summary
private boolean isIpod

iOS only: determines if the given URL points to the iPod library

MAX_CONNECTION_ATTEMPTSback to summary
private static final int MAX_CONNECTION_ATTEMPTS

The number of times to attempt to open a URL connection to test the URI.

propertyLockback to summary
private final Object propertyLock

Mutex for connectionProperties;

protocolback to summary
private String protocol
readySignalback to summary
private CountDownLatch readySignal
schemeback to summary
private String scheme
uriback to summary
protected URI uri

The URI source.

uriStringback to summary
private String uriString

Constructor Detail

Locatorback to summary
public Locator(URI uri) throws URISyntaxException

Constructs an object representing a media source.

Parameters
uri:URI

The URI source.

Exceptions
URISyntaxException:
if the supplied URI requires some further manipulation in order to be used and this procedure fails to produce a usable URI.
NullPointerException:
if uri is null.
IllegalArgumentException:
UnsupportedOperationException:
if the URI's protocol is unsupported.

Method Detail

cacheMediaback to summary
public void cacheMedia()

Tell this Locator to preload the media into memory, if it hasn't been already.

canBlockback to summary
public boolean canBlock()
closeConnectionback to summary
pack-priv static void closeConnection(URLConnection connection)
createConnectionHolderback to summary
public ConnectionHolder createConnectionHolder() throws IOException
getAudioStreamConnectionHolderback to summary
public ConnectionHolder getAudioStreamConnectionHolder(ConnectionHolder connectionHolder) throws IOException
getConnectionback to summary
private Locator.LocatorConnection getConnection(URI uri, String requestMethod) throws MalformedURLException, IOException
getContentLengthback to summary
public long getContentLength()

Retrieves the media size.

Returns:long

size of the media file in bytes. -1 indicates unknown, which may happen with network streams.

getContentLengthLongback to summary
private static long getContentLengthLong(URLConnection connection)
getContentTypeback to summary
public String getContentType()

Retrieves the content type describing the media content or "application/octet-stream" if no more specific content type may be detected.

getContentTypeFromFileSignatureback to summary
private String getContentTypeFromFileSignature(URI uri) throws MalformedURLException, IOException
getInputStreamback to summary
private InputStream getInputStream(URI uri) throws MalformedURLException, IOException
getProtocolback to summary
public String getProtocol()

Retrieves the protocol of the media URL

getStringLocationback to summary
public String getStringLocation()
getURIback to summary
public URI getURI()

Retrieves the associated URI.

Returns:URI

The URI source.

initback to summary
public void init() throws URISyntaxException, IOException, FileNotFoundException
setConnectionPropertyback to summary
public void setConnectionProperty(String property, Object value)

Sets a property to be used by the connection to the media specified by the URI. The meaning of the property is a function of the URI protocol and type of media source. This method should be invoked before calling createConnectionHolder() or it will have no effect.

Parameters
property:String

The name of the property.

value:Object

The value of the property.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Retrieves a string representation of the Locator

Returns:String

The LocatorURI as a String.

Annotations
@Override
waitForReadySignalback to summary
public void waitForReadySignal()

Blocks until locator is ready (connection is established or failed).

com.sun.media.jfxmedia.locator back to summary

private Class Locator.LocatorConnection

extends Object
Class Inheritance

Holds connection and response code returned from getConnection()

Field Summary

Modifier and TypeField and Description
public HttpURLConnection
public int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionback to summary
public HttpURLConnection connection
responseCodeback to summary
public int responseCode

Constructor Detail

LocatorConnectionback to summary
private LocatorConnection()