public class PropertyUtil extends Object
Constructor and Description |
---|
PropertyUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
addPropertiesToURI(String uri,
Map<String,String> properties)
Append the given properties to the query portion of the given URI.
|
static String |
addPropertiesToURI(URI uri,
Map<String,String> properties)
Enumerate the properties of the target object and add them as additional entries
to the query string of the given URI.
|
static String |
addPropertiesToURIFromBean(String uri,
Object bean)
Enumerate the properties of the target object and add them as additional entries
to the query string of the given string URI.
|
static String |
createQueryString(Map<String,? extends Object> options)
Given a key / value mapping, create and return a URI formatted query string that is valid
and can be appended to a URI.
|
static URI |
eraseQuery(URI uri)
Creates a URI with the given query, removing an previous query value from the given URI.
|
static Map<String,String> |
filterProperties(Map<String,String> properties,
String optionPrefix)
Given a map of properties, filter out only those prefixed with the given value, the
values filtered are returned in a new Map instance.
|
static Map<String,String> |
getProperties(Object object)
Get properties from an object using reflection.
|
static Object |
getProperty(Object object,
String name)
Find a specific property getter in a given object based on a property name.
|
static Map<String,String> |
parseParameters(String uri)
Parse properties from a named resource -eg.
|
static Map<String,String> |
parseParameters(URI uri)
Get properties from a URI and return them in a new
Map<String, String> instance. |
static Map<String,String> |
parseQuery(String queryString)
Get properties from a URI query string.
|
static URI |
replaceQuery(URI originalURI,
Map<String,String> params)
Creates a URI from the original URI and the given parameters.
|
static URI |
replaceQuery(URI uri,
String query)
Creates a URI with the given query, removing an previous query value from the given URI.
|
static Map<String,String> |
setProperties(Object target,
Map<String,String> properties)
Set properties on an object using the provided map.
|
static Map<String,Object> |
setProperties(Object target,
Properties properties)
Set properties on an object using the provided Properties object.
|
static boolean |
setProperty(Object target,
String name,
Object value)
Set a property named property on a given Object.
|
static String |
stripBefore(String value,
char c)
Return a String up to and including character
|
static String |
stripPrefix(String value,
String prefix)
Return a String minus the given prefix.
|
static String |
stripUpto(String value,
char c)
Return a portion of a String value by looking beyond the given
character.
|
public static URI replaceQuery(URI originalURI, Map<String,String> params) throws URISyntaxException
originalURI
- The URI whose current parameters are removed and replaced with the given remainder value.params
- The URI params that should be used to replace the current ones in the target.URISyntaxException
- if the given URI is invalid.public static URI replaceQuery(URI uri, String query) throws URISyntaxException
uri
- The source URI whose existing query is replaced with the newly supplied one.query
- The new URI query string that should be appended to the given URI.URISyntaxException
- if the given URI is invalid.public static URI eraseQuery(URI uri) throws URISyntaxException
uri
- The source URI whose existing query is replaced with the newly supplied one.URISyntaxException
- if the given URI is invalid.public static String createQueryString(Map<String,? extends Object> options) throws URISyntaxException
options
- The Mapping that will create the new Query string.URISyntaxException
- if the given URI is invalid.public static Map<String,String> parseParameters(URI uri) throws Exception
Map<String, String>
instance.
If the URI is null or the query string of the URI is null an empty Map is returned.uri
- the URI whose parameters are to be parsed.Map
of propertiesException
- if an error occurs while parsing the query options.public static Map<String,String> parseParameters(String uri) throws Exception
uri
- the URI whose parameters are to be parsed.Map
of propertiesException
- if an error occurs while parsing the query options.public static Map<String,String> parseQuery(String queryString) throws Exception
queryString
- the string value returned from a call to the URI class getQuery method.Map
of properties from the parsed string.Exception
- if an error occurs while parsing the query options.public static Map<String,String> filterProperties(Map<String,String> properties, String optionPrefix)
properties
- The map of properties to filter.optionPrefix
- The prefix value to use when filtering.public static String addPropertiesToURIFromBean(String uri, Object bean) throws Exception
uri
- The string URI value to append the object properties to.bean
- The Object whose properties will be added to the target URI.Exception
- if an error occurs while enumerating the bean properties.public static String addPropertiesToURI(URI uri, Map<String,String> properties) throws Exception
uri
- The URI value to append the object properties to.properties
- The Object whose properties will be added to the target URI.Exception
- if an error occurs while enumerating the bean properties.public static String addPropertiesToURI(String uri, Map<String,String> properties) throws Exception
uri
- The string URI value to append the object properties to.properties
- The properties that will be added to the target URI.Exception
- if an error occurs while building the new URI string.public static Map<String,String> setProperties(Object target, Map<String,String> properties)
target
- the object whose properties are to be set from the map options.properties
- the properties that should be applied to the given object.public static Map<String,Object> setProperties(Object target, Properties properties)
target
- the object whose properties are to be set from the map options.properties
- the properties that should be applied to the given object.public static Map<String,String> getProperties(Object object) throws Exception
Map
is returned.object
- the Object whose properties are to be extracted.Map
of properties extracted from the given object.Exception
- if an error occurs while examining the object's properties.public static Object getProperty(Object object, String name) throws Exception
object
- the object to search.name
- the property name to search for.Exception
- if an error occurs while searching the object's bean info.public static boolean setProperty(Object target, String name, Object value)
The object is searched for an set method that would match the given named property and if one is found. If necessary an attempt will be made to convert the new value to an acceptable type.
target
- The object whose property is to be set.name
- The name of the property to set.value
- The new value to set for the named property.public static String stripPrefix(String value, String prefix)
value
- The String whose prefix is to be removed.prefix
- The prefix string to remove from the target string.public static String stripUpto(String value, char c)
value
- The string value to splitc
- The character that marks the split point.Copyright © 2013–2016 The Apache Software Foundation. All rights reserved.