
public class HumbleIO extends Object implements IURLProtocolHandlerFactory
IURLProtocolHandler objects.
Most of the time, Container hides this away from you, but in case you're interested, here's the underlying class doing the IO magic.
To use for reading (assuming an InputStream object called inputStream):Container container = Container.make(); container.open(inputStream, null);
or for writing:
Container container = Container.make(); container.open(outputStream, null);
Really. That's it.
All streams that are mapped in this factory share the same name space, even
if registered under different protocols. So, if "exampleone" and "exampletwo"
were both registered as protocols for this factory, then
"exampleone:filename" is the same as "exampletwo:filename" and will map to
the same input and output streams. In reality, they are all mapped to the
DEFAULT_PROTOCOL protocol.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_PROTOCOL
The default protocol string that this factory uses (
"humble").
|
| Modifier and Type | Method and Description |
|---|---|
static String |
generateUniqueName(Object src)
Generates a unique name suitable for using in the map methods for the URL
parameter.
|
static String |
generateUniqueName(Object src,
String extension)
Generates a unique name suitable for using in the map methods for the URL
parameter.
|
static HumbleIO |
getFactory()
Get the singleton factory object for this class.
|
IURLProtocolHandler |
getHandler(String protocol,
String url,
int flags)
Called by FFMPEG in order to get a handler to use for a given file.
|
static String |
map(ByteChannel channel)
Maps a
ByteChannel to a URL for use by Humble. |
static String |
map(DataInput input)
Maps a
DataInput object to a URL for use by Humble. |
static String |
map(DataOutput output)
Maps a
DataOutput object to a URL for use by Humble. |
static String |
map(InputStream in)
Maps an
InputStream to a URL for use by Humble. |
static String |
map(IURLProtocolHandler handler)
Maps a
IURLProtocolHandler to a url that Humble can open. |
static String |
map(OutputStream out)
Maps an
OutputStream to a URL for use by Humble. |
static String |
map(RandomAccessFile file)
Maps a
RandomAccessFile object to a URL for use by Humble. |
static String |
map(ReadableByteChannel channel)
Maps a
ReadableByteChannel to a URL for use by Humble. |
static String |
map(String url,
ByteChannel channel)
Maps a
ByteChannel to a URL for use by Humble. |
static String |
map(String url,
DataInput input)
Maps a
DataInput object to a URL for use by Humble. |
static String |
map(String url,
DataInput in,
DataOutput out,
boolean unmapOnOpen,
boolean closeOnClose)
Maps a
DataInput or DataOutput object to a URL for use by
Humble. |
static String |
map(String url,
DataOutput output)
Maps a
DataOutput object to a URL for use by Humble. |
static String |
map(String url,
InputStream in)
Maps an
InputStream to a URL for use by Humble. |
static String |
map(String url,
InputStream in,
OutputStream out,
boolean unmapOnOpen,
boolean closeOnClose)
Maps an
InputStream or OutputStream to a URL for use by
Humble. |
static String |
map(String url,
IURLProtocolHandler handler)
Maps a
IURLProtocolHandler to a url that Humble can open. |
static String |
map(String url,
IURLProtocolHandler handler,
boolean unmapUrlOnOpen)
Maps a
IURLProtocolHandler to a url that Humble can open. |
static String |
map(String url,
OutputStream out)
Maps an
OutputStream to a URL for use by Humble. |
static String |
map(String url,
RandomAccessFile file)
Maps a
RandomAccessFile object to a URL for use by Humble. |
static String |
map(String url,
ReadableByteChannel channel)
Maps a
ReadableByteChannel to a URL for use by Humble. |
static String |
map(String url,
ReadableByteChannel in,
WritableByteChannel out,
boolean unmapOnOpen,
boolean closeOnClose)
Maps an
ReadableByteChannel or WritableByteChannel to a URL
for use by Humble. |
static String |
map(String url,
WritableByteChannel channel)
Maps a
WritableByteChannel to a URL for use by Humble. |
static String |
map(WritableByteChannel channel)
Maps a
WritableByteChannel to a URL for use by Humble. |
IURLProtocolHandler |
mapIO(String url,
IURLProtocolHandler handler,
boolean unmapUrlOnOpen)
Maps the given url or file name to the given
IURLProtocolHandler or
so that Humble calls to open the URL it will call back to the handler. |
static IURLProtocolHandler |
unmap(String url)
Undoes a URL to
InputStream or OutputStream mapping. |
IURLProtocolHandler |
unmapIO(String url)
Unmaps a registration between a URL and the underlying i/o objects.
|
public static final String DEFAULT_PROTOCOL
public static HumbleIO getFactory()
public static String generateUniqueName(Object src)
src - The object you want to generate a unique name for, or null if
you don't have one.public static String generateUniqueName(Object src, String extension)
src - The object you want to generate a unique name for, or null if
you don't have one.extension - an option extension to append to the generated URL.public static String map(IURLProtocolHandler handler)
IURLProtocolHandler to a url that Humble can open.
unmap(String) will be called automatically after this URL is
opened.handler - the handlerContainer's open
methods.public static String map(String url, IURLProtocolHandler handler)
IURLProtocolHandler to a url that Humble can open.
unmap(String) will be called automatically after this URL is
opened.url - the unique string to use for the mapping.handler - the handlerContainer's open
methods.public static String map(String url, DataInput input)
DataInput object to a URL for use by Humble.public static String map(DataOutput output)
DataOutput object to a URL for use by Humble.output - the DataOutputContainer's open methods.public static String map(String url, DataOutput output)
DataOutput object to a URL for use by Humble.url - the URL to use.output - the DataOutputContainer's open methods.public static String map(RandomAccessFile file)
RandomAccessFile object to a URL for use by Humble.file - the RandomAccessFileContainer's open methods.public static String map(String url, RandomAccessFile file)
RandomAccessFile object to a URL for use by Humble.url - the URL to use.file - the RandomAccessFileContainer's open methods.public static String map(ReadableByteChannel channel)
ReadableByteChannel to a URL for use by Humble.channel - the ReadableByteChannelContainer's open methods.public static String map(String url, ReadableByteChannel channel)
ReadableByteChannel to a URL for use by Humble.url - the URL to use.channel - the ReadableByteChannelContainer's open methods.public static String map(WritableByteChannel channel)
WritableByteChannel to a URL for use by Humble.channel - the WritableByteChannelContainer's open methods.public static String map(String url, WritableByteChannel channel)
WritableByteChannel to a URL for use by Humble.url - the URL to use.channel - the WritableByteChannelContainer's open methods.public static String map(ByteChannel channel)
ByteChannel to a URL for use by Humble.channel - the ByteChannelContainer's open methods.public static String map(String url, ByteChannel channel)
ByteChannel to a URL for use by Humble.url - the URL to use.channel - the ByteChannelContainer's open methods.public static String map(InputStream in)
InputStream to a URL for use by Humble.in - the streamContainer's
open method, and will result in IO being performed on the passed in
streams.public static String map(String url, InputStream in)
InputStream to a URL for use by Humble.url - the URL to use.in - the streamContainer's
open method, and will result in IO being performed on the passed in
streams.public static String map(OutputStream out)
OutputStream to a URL for use by Humble.out - the streamContainer's
open method, and will result in IO being performed on the passed in
streams.public static String map(String url, OutputStream out)
OutputStream to a URL for use by Humble.url - the URL to use.out - the streamContainer's
open method, and will result in IO being performed on the passed in
streams.public static String map(String url, DataInput in, DataOutput out, boolean unmapOnOpen, boolean closeOnClose)
DataInput or DataOutput object to a URL for use by
Humble.url - the urlin - the input to useout - the output to useunmapOnOpen - should we remove the mapping as soon as the resulting
handler is opened?closeOnClose - should we call Closeable.close() on the
underlying input or output objects when
IURLProtocolHandler.close() is called (if supported by the
underlying object)?Container's
open method, and will result in IO being performed on the passed in
streams.public static String map(String url, ReadableByteChannel in, WritableByteChannel out, boolean unmapOnOpen, boolean closeOnClose)
ReadableByteChannel or WritableByteChannel to a URL
for use by Humble.url - the urlin - the input to useout - the output to useunmapOnOpen - should we remove the mapping as soon as the resulting
handler is opened?closeOnClose - should we call Closeable.close() on the
underlying input or output objects when
IURLProtocolHandler.close() is called (if supported by the
underlying object)?Container's
open method, and will result in IO being performed on the passed in
streams.public static String map(String url, InputStream in, OutputStream out, boolean unmapOnOpen, boolean closeOnClose)
InputStream or OutputStream to a URL for use by
Humble.url - the urlin - the input to useout - the output to useunmapOnOpen - should we remove the mapping as soon as the resulting
handler is opened?closeOnClose - should we call Closeable.close() on the
underlying input or output objects when
IURLProtocolHandler.close() is called?Container's
open method, and will result in IO being performed on the passed in
streams.public static String map(String url, IURLProtocolHandler handler, boolean unmapUrlOnOpen)
IURLProtocolHandler to a url that Humble can open.url - the unique string to use for the mapping.handler - the handlerunmapUrlOnOpen - if true, when Humble opens the
IURLProtocolHandler, unmap(String) will be called
automatically.Container's open
methods.public static IURLProtocolHandler unmap(String url)
public IURLProtocolHandler mapIO(String url, IURLProtocolHandler handler, boolean unmapUrlOnOpen)
IURLProtocolHandler or
so that Humble calls to open the URL it will call back to the handler.
If you set unmapOnOpen to false, or you never actually open this mapping,
then you must ensure that you call unmapIO(String) at some point
in time to remove the mapping, or we will hold onto references to the
handler you passed in.
url - A file or URL. If a URL, the protocol will be stripped off and
replaced with DEFAULT_PROTOCOL when registering.handler - An IURLProtocolHandler for the urlunmapUrlOnOpen - If true, the handler will unmap itself after an
Container opens the registered URL. If true, you do not
need to call unmapIO(String) for this url.IllegalArgumentException - if url is null or zero lengthIllegalArgumentException - if handler is nullpublic IURLProtocolHandler unmapIO(String url)
If URL contains a protocol it is ignored when trying to find the matching IO stream.
url - The stream name to unmapIURLProtocolHandler that had been registered for that
url, or null if none.public IURLProtocolHandler getHandler(String protocol, String url, int flags)
getHandler in interface IURLProtocolHandlerFactoryprotocol - The protocol without a ':'. For example, "file", "http", or "yourcustomprotocol"url - The URL that FFMPEG is trying to open.flags - The flags that FFMPEG will pass to IURLProtocolHandler.open(String, int)IURLProtocolHandler to use, or null. If null, a file not found error will be passed back
to FFMPEG.Copyright © 2018 Humble Software. All rights reserved.