29import java.io.FileNotFoundException;
 
   30import java.io.IOException;
 
   31import java.net.MalformedURLException;
 
   32import java.net.URISyntaxException;
 
   34import java.net.URLConnection;
 
   35import java.net.URLStreamHandler;
 
   37import org.jau.io.IOUtil;
 
   38import org.jau.lang.ExceptionUtils;
 
   39import org.jau.sys.AndroidVersion;
 
   88    public static URL 
createURL(
final String path, 
final ClassLoader cl) 
throws MalformedURLException {
 
 
  104    public static URL 
createURL(
final String path) 
throws MalformedURLException {
 
 
  170    public URLConnection 
resolve(
final String path) 
throws IOException {
 
 
  174    public static URLConnection 
resolve(String path, 
final ClassLoader cl) 
throws IOException {
 
  176        URLConnection conn = 
null;
 
  180            System.err.println(
"AssetURLContext.resolve: <"+path+
">");
 
  184        } 
catch (
final URISyntaxException uriEx) {
 
  185            throw new IOException(uriEx);
 
  192            type = 
null != conn ? 1 : -1;
 
  193        } 
catch(
final MalformedURLException e1) { 
if(DEBUG) { System.err.println(
"FAIL(1): "+e1.getMessage()); } }
 
  195        if(
null == conn && 
null != cl) {
 
  198            while(cpath.startsWith(
"/")) {
 
  199                cpath = cpath.substring(1);
 
  204            url = cl.getResource(cpath);
 
  206            type = 
null != conn ? 2 : -1;
 
  212                final File file = 
new File(path);
 
  216                    type = 
null != conn ? 3 : -1;
 
  218            } 
catch (
final Throwable e) { 
if(DEBUG) { System.err.println(
"FAIL(3): "+e.getMessage()); } }
 
  222            System.err.println(
"AssetURLContext.resolve: type "+type+
": url <"+url+
">, conn <"+conn+
">, connURL <"+(
null!=conn?conn.getURL():
null)+
">");
 
  225            throw new FileNotFoundException(
"Could not look-up: "+path+
" as URL, w/ ClassLoader or as File");
 
 
  230    private static URLConnection open(
final URL url) {
 
  235            final URLConnection c = url.openConnection();
 
  238        } 
catch (
final IOException ioe) { 
if(DEBUG) { System.err.println(
"FAIL(2): "+ioe.getMessage()); } }
 
  253    public static URLConnection 
getResource(
final String resourcePath, 
final ClassLoader cl) {
 
  254        if(
null == resourcePath) {
 
  258            System.err.println(
"AssetURLContext: locating <"+resourcePath+
">, has cl: "+(
null!=cl));
 
  263            } 
catch (
final IOException ioe) {
 
  272            } 
catch (
final IOException ioe) {
 
 
 
static final boolean DEBUG
static String cleanPathString(String path)
static void dumpThrowable(final String additionalDescr, final Throwable t)
Dumps a Throwable to System.err in a decorating message including the current thread name,...
See PiggybackURLConnection for description and examples.
static URL createURL(final String path)
Create an asset URL, suitable only with the registered asset URLStreamHandler.
static final String asset_protocol_prefix
The asset URL protocol prefix asset:
URLConnection resolve(final String path)
Resolving path to a URL sub protocol and return it's open URLConnection.
static boolean registerHandler(final ClassLoader cl)
Registers the generic URLStreamHandlerFactory via GenericURLStreamHandlerFactory#register() and if su...
String getImplementedProtocol()
Returns the specific protocol, constant for this implementation.
static final String assets_folder
The optional asset folder name with ending slash assets/.
static URLConnection getResource(final String resourcePath, final ClassLoader cl)
Locating a resource using the ClassLoader's facilities.
abstract ClassLoader getClassLoader()
Returns an asset aware ClassLoader.
static AssetURLStreamHandler createHandler(final ClassLoader cl)
static URLStreamHandler getRegisteredHandler()
Returns the asset handler previously set via registerHandler(ClassLoader), or null if none was set.
static URLConnection resolve(String path, final ClassLoader cl)
static final String asset_protocol
The asset URL protocol name asset
static URL createURL(final String path, final ClassLoader cl)
Create an asset URL, suitable even w/o the registered asset URLStreamHandler.
static AssetURLContext create(final ClassLoader cl)
URLStreamHandler to handle the asset protocol.
static synchronized GenericURLStreamHandlerFactory register()
Returns the singleton instance of the registered GenericURLStreamHandlerFactory or null if registrati...
synchronized final URLStreamHandler setHandler(final String protocol, final URLStreamHandler handler)
Sets the handler for protocol.
synchronized final URLStreamHandler getHandler(final String protocol)
Returns the protocol handler previously set via setHandler(String, URLStreamHandler),...
This class implements an immutable Uri as defined by RFC 2396.
final java.net.URL toURL()
Returns a new URL instance using the encoded input string, new URL(uri.input), i.e.
static Uri valueOf(final File file)
Creates a new Uri instance using the given File instance.
static final boolean isAvailable
See PiggybackURLConnection for description and examples.