private void maybeIndexResource ( String relPath , URL delegate ) { if ( ! index . containsKey ( relPath ) ) { index . put ( relPath , delegate ) ; if ( relPath . endsWith ( File . separator ) ) { maybeIndexResource ( relPath . substring ( 0 , relPath . length ( ) - File . separator . length ( ) ) , delegate ) ; } } }
Callers may request the directory itself as a resource and may do so with or without trailing slashes . We do this in a while - loop in case the classpath element has multiple superfluous trailing slashes .