public final class ResourceHelper extends Object
Modifier and Type | Method and Description |
---|---|
static String |
appendParameters(String uri,
Map<String,Object> parameters)
Appends the parameters to the given uri
|
static Set<Path> |
findInFileSystem(Path root,
String pattern)
Find resources from the file system using Ant-style path patterns.
|
static String |
getScheme(String uri)
Gets the scheme from the URI (e.g.
|
static boolean |
hasScheme(String uri)
Determines whether the URI has a scheme (e.g.
|
static boolean |
isClasspathUri(String uri)
Is the given uri a classpath uri?
|
static boolean |
isHttpUri(String uri)
Is the given uri a http uri?
|
static InputStream |
resolveMandatoryResourceAsInputStream(org.apache.camel.CamelContext camelContext,
String uri)
Resolves the mandatory resource.
|
static URL |
resolveMandatoryResourceAsUrl(org.apache.camel.spi.ClassResolver classResolver,
String uri)
Resolves the mandatory resource.
|
static InputStream |
resolveResourceAsInputStream(org.apache.camel.spi.ClassResolver classResolver,
String uri)
Resolves the resource.
|
static URL |
resolveResourceAsUrl(org.apache.camel.spi.ClassResolver classResolver,
String uri)
Resolves the resource.
|
public static boolean hasScheme(String uri)
uri
- the URIpublic static String getScheme(String uri)
uri
- the uripublic static InputStream resolveMandatoryResourceAsInputStream(org.apache.camel.CamelContext camelContext, String uri) throws IOException
Registry
Registry
and call the methodURLStreamHandler
registered for the resolveMandatoryResourceAsUrl(org.apache.camel.spi.ClassResolver, String)
camelContext
- the Camel Contexturi
- URI of the resourceInputStream
. Remember to close this stream after usage.IOException
- is thrown if the resource file could not be found or loaded as InputStream
public static InputStream resolveResourceAsInputStream(org.apache.camel.spi.ClassResolver classResolver, String uri) throws IOException
resolveMandatoryResourceAsUrl(org.apache.camel.spi.ClassResolver, String)
classResolver
- the class resolver to load the resource from the classpathuri
- URI of the resourceInputStream
. Remember to close this stream after usage. Or
null if not found.IOException
- is thrown if error loading the resourcepublic static URL resolveMandatoryResourceAsUrl(org.apache.camel.spi.ClassResolver classResolver, String uri) throws FileNotFoundException, MalformedURLException
classResolver
- the class resolver to load the resource from the classpathuri
- uri of the resourceURL
.FileNotFoundException
- is thrown if the resource file could not be foundMalformedURLException
- if the URI is malformedpublic static URL resolveResourceAsUrl(org.apache.camel.spi.ClassResolver classResolver, String uri) throws MalformedURLException
classResolver
- the class resolver to load the resource from the classpathuri
- uri of the resourceURL
. Or null if not found.MalformedURLException
- if the URI is malformedpublic static boolean isClasspathUri(String uri)
uri
- the uripublic static boolean isHttpUri(String uri)
uri
- the uripublic static String appendParameters(String uri, Map<String,Object> parameters) throws URISyntaxException
uri
- the uriparameters
- the additional parameters (will clear the map)URISyntaxException
- is thrown if the uri is invalidpublic static Set<Path> findInFileSystem(Path root, String pattern) throws Exception
root
- the starting filepattern
- the Ant patternException
Apache Camel