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 org.apache.camel.spi.Resource |
fromBytes(String location,
byte[] content)
Create a
Resource from bytes. |
static org.apache.camel.spi.Resource |
fromString(String location,
String content)
Create a
Resource from a String . |
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.CamelContext camelContext,
String uri)
Resolves the mandatory resource.
|
static InputStream |
resolveResourceAsInputStream(org.apache.camel.CamelContext camelContext,
String uri)
Resolves the resource.
|
static URL |
resolveResourceAsUrl(org.apache.camel.CamelContext camelContext,
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.CamelContext camelContext, String uri) throws IOException
#resolveMandatoryResourceAsUrl(org.apache.camel.spi.ClassResolver, String)
camelContext
- the camel contexturi
- 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.CamelContext camelContext, String uri) throws FileNotFoundException, MalformedURLException
camelContext
- the camel contexturi
- 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.CamelContext camelContext, String uri) throws MalformedURLException
camelContext
- the camel contexturi
- 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
public static org.apache.camel.spi.Resource fromBytes(String location, byte[] content)
Resource
from bytes.location
- a virtual locationcontent
- the resource contentpublic static org.apache.camel.spi.Resource fromString(String location, String content)
Resource
from a String
.
The implementation delegates to fromBytes(String, byte[])
by encoding the string as bytes with
String.getBytes(Charset)
and StandardCharsets.UTF_8
as charset.location
- a virtual locationcontent
- the resource contentString
Apache Camel