|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jguiraffe.locators.AbstractLocator
net.sf.jguiraffe.locators.AbstractStreamLocator
public abstract class AbstractStreamLocator
An abstract base class for Locator implementations that mainly
operate on streams.
The Locator interface requires that the getURL()
method has to be implemented in a meaningful way. However, there are some use
cases where data is available only as a stream (e.g. in some binary form),
and it is not obvious how a URL can be constructed to point to this data.
This class is designed to support such use cases.
The basic idea is that this class provides a specialized implementation of
the abstract java.net.URLStreamHandler class. This
implementation can create java.net.URLConnection objects whose
getInputStream() method returns the input stream provided by the
concrete Locator implementation.
Concrete subclasses have to implement the getInputStream()
method to return the stream they point to. They also have to provide an
implementation of the createURL() method. This method is passed
a URLStreamHandler object as described above. An implementation
of createURL() can create a URL with an arbitrary protocol and
other components as it sees fit. As long as the URLStreamHandler
is used when creating the URL it is guaranteed that calls to
openConnection() or openStream() on the URL object
return the stream of the Locator.
| Constructor Summary | |
|---|---|
protected |
AbstractStreamLocator()
Creates a new instance of AbstractStreamLocator. |
| Method Summary | |
|---|---|
protected abstract java.net.URL |
createURL(java.net.URLStreamHandler streamHandler)
Creates the URL managed by this locator. |
java.net.URL |
getURL()
Returns the URL managed by this locator. |
| Methods inherited from class net.sf.jguiraffe.locators.AbstractLocator |
|---|
getFile, getInputStream |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractStreamLocator()
AbstractStreamLocator.
| Method Detail |
|---|
public java.net.URL getURL()
URL managed by this locator. On first access
this implementation delegates to createURL() for creating
the URL. Then the URL is cached and directly returned on subsequent
requests. Note that a non-blocking algorithm is used for lazily creating
the URL. So on concurrent access it may happen that
createURL() is invoked multiple times. However, it is
guaranteed that this method always returns the same URL.
URL managed by this locator
protected abstract java.net.URL createURL(java.net.URLStreamHandler streamHandler)
throws java.net.MalformedURLException
getURL() to initialize the URL. An implementation is free to
create whatever URL it likes, but it should use the specified
URLStreamHandler. This handler ensures that reading from the
URL is delegated to the stream managed by this locator.
streamHandler - the stream handler to use when creating the URL
getURL()
java.net.MalformedURLException - if the URL cannot be created
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||