Package org.apache.qpid.jms.util
Class PropertyUtil
java.lang.Object
org.apache.qpid.jms.util.PropertyUtil
Utilities for properties
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateQueryString(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 URIeraseQuery(URI uri) Creates a URI with the given query, removing an previous query value from the given URI.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.getProperties(Object object) Get properties from an object using reflection.static ObjectgetProperty(Object object, String name) Find a specific property getter in a given object based on a property name.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.parseQuery(URI uri) Get properties from the Query portion of the given URI.static URIreplaceQuery(URI uri, String query) Creates a URI with the given query, removing an previous query value from the given URI.static URIreplaceQuery(URI originalURI, Map<String, String> properties) Creates a URI from the original URI and the given parameters.setProperties(Object target, Map<String, String> properties) Set properties on an object using the provided map.setProperties(Object target, Properties properties) Set properties on an object using the provided Properties object.static booleansetProperty(Object target, String name, Object value) Set a property named property on a given Object.static StringstripBefore(String value, char c) Return a String up to and including characterstatic StringstripPrefix(String value, String prefix) Return a String minus the given prefix.static StringReturn a portion of a String value by looking beyond the given character.
-
Constructor Details
-
PropertyUtil
public PropertyUtil()
-
-
Method Details
-
replaceQuery
public static URI replaceQuery(URI originalURI, Map<String, String> properties) throws URISyntaxExceptionCreates a URI from the original URI and the given parameters. The string values in the Map will be URL Encoded by this method which means that if an already encoded value is passed it will be double encoded resulting in corrupt values in the newly created URI.- Parameters:
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.- Returns:
- a new URI that matches the original one but has its query options replaced with the given ones.
- Throws:
URISyntaxException- if the given URI is invalid.
-
replaceQuery
Creates a URI with the given query, removing an previous query value from the given URI.- Parameters:
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.- Returns:
- a new URI that is a combination of the original URI and the given query string.
- Throws:
URISyntaxException- if the given URI is invalid.
-
eraseQuery
Creates a URI with the given query, removing an previous query value from the given URI.- Parameters:
uri- The source URI whose existing query is replaced with the newly supplied one.- Returns:
- a new URI that is a combination of the original URI and the given query string.
- Throws:
URISyntaxException- if the given URI is invalid.
-
createQueryString
public static String createQueryString(Map<String, ? extends Object> options) throws URISyntaxExceptionGiven a key / value mapping, create and return a URI formatted query string that is valid and can be appended to a URI string. The values in the given Map are URL Encoded during construction of the query string, if the original values were previously encoded this can result in double encoding.- Parameters:
options- The Mapping that will create the new Query string.- Returns:
- a URI formatted query string.
- Throws:
URISyntaxException- if the given URI is invalid.
-
parseQuery
Get properties from the Query portion of the given URI.- Parameters:
uri- the URI whose Query string should be parsed.- Returns:
Mapof properties from the parsed string.- Throws:
Exception- if an error occurs while parsing the query options.
-
parseQuery
Get properties from a URI Query String obtained by calling the getRawQuery method on a given URI or from some other source.- Parameters:
queryString- the query string obtained from called getRawQuery on a given URI.- Returns:
Mapof properties from the parsed string.- Throws:
Exception- if an error occurs while parsing the query options.
-
filterProperties
public 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.- Parameters:
properties- The map of properties to filter.optionPrefix- The prefix value to use when filtering.- Returns:
- a filter map with only values that match the given prefix.
-
setProperties
Set properties on an object using the provided map. The return value indicates if all properties from the given map were set on the target object.- Parameters:
target- the object whose properties are to be set from the map options.properties- the properties that should be applied to the given object.- Returns:
- true if all values in the properties map were applied to the target object.
-
setProperties
Set properties on an object using the provided Properties object. The return value indicates if all properties from the given map were set on the target object.- Parameters:
target- the object whose properties are to be set from the map options.properties- the properties that should be applied to the given object.- Returns:
- an unmodifiable map with any values that could not be applied to the target.
-
getProperties
Get properties from an object using reflection. If the passed object is null an emptyMapis returned.- Parameters:
object- the Object whose properties are to be extracted.- Returns:
Mapof properties extracted from the given object.- Throws:
Exception- if an error occurs while examining the object's properties.
-
getProperty
Find a specific property getter in a given object based on a property name.- Parameters:
object- the object to search.name- the property name to search for.- Returns:
- the result of invoking the specific property get method.
- Throws:
Exception- if an error occurs while searching the object's bean info.
-
setProperty
Set a property named property on a given Object.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.
- Parameters:
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.- Returns:
- true if the property was able to be set on the target object.
-
stripPrefix
Return a String minus the given prefix. If the string does not start with the given prefix the original string value is returned.- Parameters:
value- The String whose prefix is to be removed.prefix- The prefix string to remove from the target string.- Returns:
- stripped version of the original input string.
-
stripUpto
Return a portion of a String value by looking beyond the given character.- Parameters:
value- The string value to splitc- The character that marks the split point.- Returns:
- the sub-string value starting beyond the given character.
-
stripBefore
Return a String up to and including character- Parameters:
value- The string value to splitc- The character that marks the start of split point.- Returns:
- the sub-string value starting from the given character.
-