public class PropertyUtil extends Object
| Constructor and Description |
|---|
PropertyUtil() |
| Modifier and Type | Method and Description |
|---|---|
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 string.
|
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> |
parseQuery(String queryString)
Get properties from a URI Query String obtained by calling the getRawQuery method
on a given URI or from some other source.
|
static Map<String,String> |
parseQuery(URI uri)
Get properties from the Query portion of the given URI.
|
static URI |
replaceQuery(URI originalURI,
Map<String,String> properties)
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> properties) throws URISyntaxException
originalURI - The URI whose current parameters are removed and replaced with the given remainder value.properties - The URI properties 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> parseQuery(URI uri) throws Exception
uri - the URI whose Query string should be parsed.Map of properties from the parsed string.Exception - if an error occurs while parsing the query options.public static Map<String,String> parseQuery(String queryString) throws Exception
queryString - the query string obtained from called getRawQuery on a given URI.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 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–2019 The Apache Software Foundation. All rights reserved.