Package org.apache.camel.catalog.impl
Class URISupport
- java.lang.Object
-
- org.apache.camel.catalog.impl.URISupport
-
public final class URISupport extends Object
Copied from org.apache.camel.util.URISupport
-
-
Field Summary
Fields Modifier and Type Field Description static char[]
RAW_TOKEN_END
static String
RAW_TOKEN_PREFIX
static char[]
RAW_TOKEN_START
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
createQueryString(Map<String,String> options, String ampersand, boolean encode)
Assembles a query from the given map.static Map<String,Object>
extractProperties(Map<String,Object> properties, String optionPrefix)
static boolean
isEmpty(Object value)
Tests whether the value is null or an empty string.static boolean
isNotEmpty(Object value)
Tests whether the value is not null or an empty string.static boolean
isRaw(int index, List<Pair<Integer>> pairs)
static URI
normalizeUri(String uri)
Normalizes the URI so unsafe characters is encodedstatic Map<String,Object>
parseParameters(URI uri)
Parses the query parameters of the uri (eg the query part).static Map<String,Object>
parseQuery(String uri)
Parses the query part of the uri (eg the parameters).static Map<String,Object>
parseQuery(String uri, boolean useRaw)
Parses the query part of the uri (eg the parameters).static List<Pair<Integer>>
scanRaw(String str)
static String
stripPrefix(String value, String prefix)
Strips the prefix from the value.static String
stripQuery(String uri)
Strips the query parameters from the uri
-
-
-
Field Detail
-
RAW_TOKEN_PREFIX
public static final String RAW_TOKEN_PREFIX
- See Also:
- Constant Field Values
-
RAW_TOKEN_START
public static final char[] RAW_TOKEN_START
-
RAW_TOKEN_END
public static final char[] RAW_TOKEN_END
-
-
Method Detail
-
normalizeUri
public static URI normalizeUri(String uri) throws URISyntaxException
Normalizes the URI so unsafe characters is encoded- Parameters:
uri
- the input uri- Returns:
- as URI instance
- Throws:
URISyntaxException
- is thrown if syntax error in the input uri
-
extractProperties
public static Map<String,Object> extractProperties(Map<String,Object> properties, String optionPrefix)
-
stripQuery
public static String stripQuery(String uri)
Strips the query parameters from the uri- Parameters:
uri
- the uri- Returns:
- the uri without the query parameter
-
parseParameters
public static Map<String,Object> parseParameters(URI uri) throws URISyntaxException
Parses the query parameters of the uri (eg the query part).- Parameters:
uri
- the uri- Returns:
- the parameters, or an empty map if no parameters (eg never null)
- Throws:
URISyntaxException
- is thrown if uri has invalid syntax.
-
stripPrefix
public static String stripPrefix(String value, String prefix)
Strips the prefix from the value. Returns the value as-is if not starting with the prefix.- Parameters:
value
- the valueprefix
- the prefix to remove from value- Returns:
- the value without the prefix
-
parseQuery
public static Map<String,Object> parseQuery(String uri) throws URISyntaxException
Parses the query part of the uri (eg the parameters). The URI parameters will by default be URI encoded. However you can define a parameter values with the syntax: key=RAW(value) which tells Camel to not encode the value, and use the value as is (eg key=value) and the value has not been encoded.- Parameters:
uri
- the uri- Returns:
- the parameters, or an empty map if no parameters (eg never null)
- Throws:
URISyntaxException
- is thrown if uri has invalid syntax.- See Also:
RAW_TOKEN_START
,RAW_TOKEN_END
-
parseQuery
public static Map<String,Object> parseQuery(String uri, boolean useRaw) throws URISyntaxException
Parses the query part of the uri (eg the parameters). The URI parameters will by default be URI encoded. However you can define a parameter values with the syntax: key=RAW(value) which tells Camel to not encode the value, and use the value as is (eg key=value) and the value has not been encoded.- Parameters:
uri
- the uriuseRaw
- whether to force using raw values- Returns:
- the parameters, or an empty map if no parameters (eg never null)
- Throws:
URISyntaxException
- is thrown if uri has invalid syntax.- See Also:
RAW_TOKEN_START
,RAW_TOKEN_END
-
createQueryString
public static String createQueryString(Map<String,String> options, String ampersand, boolean encode) throws URISyntaxException
Assembles a query from the given map.- Parameters:
options
- the map with the options (eg key/value pairs)ampersand
- to use & for Java code, and & for XML- Returns:
- a query string with key1=value&key2=value2&..., or an empty string if there is no options.
- Throws:
URISyntaxException
- is thrown if uri has invalid syntax.
-
isEmpty
public static boolean isEmpty(Object value)
Tests whether the value is null or an empty string.- Parameters:
value
- the value, if its a String it will be tested for text length as well- Returns:
- true if empty
-
isNotEmpty
public static boolean isNotEmpty(Object value)
Tests whether the value is not null or an empty string.- Parameters:
value
- the value, if its a String it will be tested for text length as well- Returns:
- true if not empty
-
-