/** * Construct a new URLResourceSource from a specific URL and type. * * @param sourceUrl * The url to load the resource from. Must not be null. * @param type * our type. Usually a file extension such as .png. Required for generic loading when multiple resource * handlers could be used. */ public URLResourceSource(final URL sourceUrl, final String type) { assert (sourceUrl != null) : "sourceUrl must not be null"; setURL(sourceUrl); _type = type; }
/** * Construct a new URLResourceSource from a specific URL and type. * * @param sourceUrl * The url to load the resource from. Must not be null. * @param type * our type. Usually a file extension such as .png. Required for generic loading when multiple resource * handlers could be used. */ public URLResourceSource(final URL sourceUrl, final String type) { assert (sourceUrl != null) : "sourceUrl must not be null"; setURL(sourceUrl); _type = type; }
/** * Construct a new URLResourceSource from a specific URL. * * @param sourceUrl * The url to load the resource from. Must not be null. If the URL has a valid URL filename (see * {@link URL#getFile()}) and an extension (eg. http://url/myFile.png) then the extension (.png in this * case) is used as the type. */ public URLResourceSource(final URL sourceUrl) { assert (sourceUrl != null) : "sourceUrl must not be null"; setURL(sourceUrl); // add type, if present final String fileName = _url.getFile(); if (fileName != null) { final int dot = fileName.lastIndexOf('.'); if (dot >= 0) { _type = fileName.substring(dot); } else { _type = UNKNOWN_TYPE; } } }
/** * Construct a new URLResourceSource from a specific URL. * * @param sourceUrl * The url to load the resource from. Must not be null. If the URL has a valid URL filename (see * {@link URL#getFile()}) and an extension (eg. http://url/myFile.png) then the extension (.png in this * case) is used as the type. */ public URLResourceSource(final URL sourceUrl) { assert (sourceUrl != null) : "sourceUrl must not be null"; setURL(sourceUrl); // add type, if present final String fileName = _url.getFile(); if (fileName != null) { final int dot = fileName.lastIndexOf('.'); if (dot >= 0) { _type = fileName.substring(dot); } else { _type = UNKNOWN_TYPE; } } }
public void read(final InputCapsule capsule) throws IOException { final String protocol = capsule.readString("protocol", null); final String host = capsule.readString("host", null); final String file = capsule.readString("file", null); if (file != null) { // see if we would like to divert this to a new location. final ResourceSource src = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_TEXTURE, URLDecoder.decode(file, "UTF-8")); if (src instanceof URLResourceSource) { setURL(((URLResourceSource) src)._url); _type = ((URLResourceSource) src)._type; return; } } if (protocol != null && host != null && file != null) { setURL(new URL(protocol, host, file)); } _type = capsule.readString("type", null); }
public void read(final InputCapsule capsule) throws IOException { final String protocol = capsule.readString("protocol", null); final String host = capsule.readString("host", null); final String file = capsule.readString("file", null); if (file != null) { // see if we would like to divert this to a new location. final ResourceSource src = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_TEXTURE, URLDecoder.decode(file, "UTF-8")); if (src instanceof URLResourceSource) { setURL(((URLResourceSource) src)._url); _type = ((URLResourceSource) src)._type; return; } } if (protocol != null && host != null && file != null) { setURL(new URL(protocol, host, file)); } _type = capsule.readString("type", null); }