/** * {@inheritDoc} */ @Override public Enumeration<URL> getResources(final String name) throws IOException { // Let's find us all resources. @SuppressWarnings("unchecked") final Enumeration<URL>[] resources = (Enumeration<URL>[]) new Enumeration<?>[2]; // Instead of returning our parent's resources first, // we'll return our own resources first. resources[0] = findResources(name); resources[1] = this.parent.getResources(name); // TODO: Replace by our own implementation. It's simple! // First return all elements from the enumeration at index 0, // then all elements from the enumeration at index 1, // etc.. Or generalize to take an enumeration of enumerations // and flatten them? return new CompoundEnumeration<>(resources); }
public Enumeration<URL> findResources(final String name) throws IOException { final long started = myDebugTime ? System.nanoTime() : 0; try { final Enumeration[] resources = new Enumeration[myParents.length + 1]; resources[0] = super.findResources(name); for (int idx = 0; idx < myParents.length; idx++) { resources[idx + 1] = fetchResources(myParents[idx], name); } return new CompoundEnumeration<URL>(resources); } finally { long doneFor = myDebugTime ? System.nanoTime() - started:0; if (doneFor > NS_THRESHOLD) { System.out.println((doneFor / 1000000) + " ms for " + (myPluginId != null?myPluginId.getIdString():null)+ ", find resources:"+name); } } }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override protected Enumeration<URL> findResources(String name) throws IOException { Enumeration tmp[] = new Enumeration[delegates.length]; for (int i = 0; i < tmp.length; i++) tmp[i] = delegates[i].getResources(name); return new CompoundEnumeration(tmp); }
@Override public Enumeration<URL> findResources(final String name) throws IOException { final Enumeration[] resources = new Enumeration[myParents.length + 1]; resources[0] = super.findResources(name); for (int idx = 0; idx < myParents.length; idx++) { resources[idx + 1] = fetchResources(myParents[idx], name); } return new CompoundEnumeration<URL>(resources); }
@SuppressWarnings({"unchecked","rawtypes"}) public Enumeration<URL> getResources(String name) throws IOException { Enumeration<URL>[] resEnum = new Enumeration[2]; if(parent == null) { resEnum[0] = getSystemClassLoader().getResourcesURL(name); } else{ resEnum[0] = parent.getResources(name); } resEnum[1] = findResources(name); return new CompoundEnumeration<URL>(resEnum); }
public Enumeration<URL> getResources(String name) throws IOException { Enumeration<URL>[] tmp = (Enumeration<URL>[]) new Enumeration<?>[2]; tmp[0] = super.getResources(name); tmp[1] = defaultClassLoader.getResources(name); return new CompoundEnumeration<>(tmp); }
/** * Finds all the resources with the given name. A resource is some data * (images, audio, text, etc) that can be accessed by class code in a way * that is independent of the location of the code. * * <p>The name of a resource is a <tt>/</tt>-separated path name that * identifies the resource. * * <p> The search order is described in the documentation for {@link * #getResource(String)}. </p> * * @apiNote When overriding this method it is recommended that an * implementation ensures that any delegation is consistent with the {@link * #getResource(java.lang.String) getResource(String)} method. This should * ensure that the first element returned by the Enumeration's * {@code nextElement} method is the same resource that the * {@code getResource(String)} method would return. * * @param name * The resource name * * @return An enumeration of {@link java.net.URL <tt>URL</tt>} objects for * the resource. If no resources could be found, the enumeration * will be empty. Resources that the class loader doesn't have * access to will not be in the enumeration. * * @throws IOException * If I/O errors occur * * @see #findResources(String) * * @since 1.2 */ public Enumeration<URL> getResources(String name) throws IOException { @SuppressWarnings("unchecked") Enumeration<URL>[] tmp = (Enumeration<URL>[]) new Enumeration<?>[2]; if (parent != null) { tmp[0] = parent.getResources(name); } else { tmp[0] = getBootstrapResources(name); } tmp[1] = findResources(name); return new CompoundEnumeration<>(tmp); }
/** * Finds all the resources with the given name. A resource is some data * (images, audio, text, etc) that can be accessed by class code in a way * that is independent of the location of the code.<p> * * The name of a resource is a "/"-separated path name that identifies the * resource.<p> * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name resource name * @return an enumeration of URL to the resource. If no resources could * be found, the enumeration will be empty. Resources that the * doesn't have access to will not be in the enumeration. * @throws IOException if I/O errors occur * @since 1.2 * @see #getResource * @see #findResources */ public final Enumeration getResources(String name) throws IOException { Enumeration[] tmp = new Enumeration[2]; if (parent != null) { tmp[0] = parent.getResources(name); } else { tmp[0] = getBootstrapResources(name); } tmp[1] = findResources(name); return new CompoundEnumeration(tmp); }
/** * Finds all the resources with the given name. A resource is some data * (images, audio, text, etc) that can be accessed by class code in a way * that is independent of the location of the code. * * <p>The name of a resource is a <tt>/</tt>-separated path name that * identifies the resource. * * <p> The search order is described in the documentation for {@link * #getResource(String)}. </p> * * @param name * The resource name * * @return An enumeration of {@link java.net.URL <tt>URL</tt>} objects for * the resource. If no resources could be found, the enumeration * will be empty. Resources that the class loader doesn't have * access to will not be in the enumeration. * * @throws IOException * If I/O errors occur * * @see #findResources(String) * * @since 1.2 */ public Enumeration<URL> getResources(String name) throws IOException { Enumeration[] tmp = new Enumeration[2]; if (parent != null) { tmp[0] = parent.getResources(name); } else { tmp[0] = getBootstrapResources(name); } tmp[1] = findResources(name); return new CompoundEnumeration(tmp); }
/** * Finds all the resources with the given name. A resource is some data * (images, audio, text, etc) that can be accessed by class code in a way * that is independent of the location of the code. * * <p>The name of a resource is a <tt>/</tt>-separated path name that * identifies the resource. * * <p> The search order is described in the documentation for {@link * #getResource(String)}. </p> * * @param name * The resource name * * @return An enumeration of {@link java.net.URL <tt>URL</tt>} objects for * the resource. If no resources could be found, the enumeration * will be empty. Resources that the class loader doesn't have * access to will not be in the enumeration. * * @throws IOException * If I/O errors occur * * @see #findResources(String) * * @since 1.2 */ public Enumeration<URL> getResources(String name) throws IOException { Enumeration[] tmp = new Enumeration[2]; if (parent != null) { tmp[0] = parent.getResources(name); } else { tmp[0] = getBootstrapResources(name); } tmp[1] = findResources(name); return new CompoundEnumeration<>(tmp); }
/** * Returns an Enumeration of URLs representing all the resources with * the given name. Class loader implementations should override this * method to specify where to load resources from. * * @param name the resource name * @return an Enumeration of URLs for the resources * @throws IOException if I/O errors occur * @since 1.2 */ protected Enumeration findResources(String name) throws IOException { return new CompoundEnumeration(new Enumeration[0]); }
/** * Returns an enumeration of {@link java.net.URL <tt>URL</tt>} objects * representing all the resources with the given name. Class loader * implementations should override this method to specify where to load * resources from. </p> * * @param name * The resource name * * @return An enumeration of {@link java.net.URL <tt>URL</tt>} objects for * the resources * * @throws IOException * If I/O errors occur * * @since 1.2 */ protected Enumeration<URL> findResources(String name) throws IOException { return new CompoundEnumeration(new Enumeration[0]); }