| java.lang.Object org.xins.common.collections.PropertyReaderUtils
PropertyReaderUtils | final public class PropertyReaderUtils (Code) | | Utility functions for dealing with PropertyReader objects.
version: $Revision: 1.59 $ $Date: 2007/09/13 11:31:30 $ author: Ernst de Haan since: XINS 1.0.0 See Also: PropertyReader |
Method Summary | |
public static PropertyReader | createPropertyReader(InputStream in) Constructs a PropertyReader from the specified input
stream.
The parsing done is similar to the parsing done by the
Properties.load(InputStream) method. | final public static boolean | equals(PropertyReader pr, Object toCompare) Compares a PropertyReader instance with another object for
equality. | public static boolean | getBooleanProperty(PropertyReader properties, String propertyName, boolean fallbackDefault) Gets the property with the specified name and converts it to a
boolean . | public static int | getIntProperty(PropertyReader properties, String propertyName) Gets the property with the specified name and converts it to an
int . | public static String | getRequiredProperty(PropertyReader properties, String name) Retrieves the specified property and throws a
MissingRequiredPropertyException if it is not set. | public String | getWithDefault(PropertyReader properties, String key, String fallbackValue) Retrieves a property with the specified name, falling back to a default
value if the property is not set. | final public static int | hashCode(PropertyReader pr) Computes a hash code value for the specified PropertyReader
object. | public static void | serialize(PropertyReader properties, FastStringBuffer buffer, String valueIfEmpty) Serializes the specified PropertyReader to a
FastStringBuffer . | public static String | toString(PropertyReader properties) Returns the String representation of the specified PropertyReader .
For each entry, both the key and the value are encoded using the URL
encoding (see
URLEncoding ).
The key and value are separated by a literal equals sign
('=' ). | public static String | toString(PropertyReader properties, String valueIfEmpty) Serializes the specified PropertyReader to a
String . | public static String | toString(PropertyReader properties, String valueIfEmpty, String prefixIfNotEmpty, String suffix) Returns the String representation for the specified
PropertyReader .
Parameters: properties - the PropertyReader to construct a String for, or null . Parameters: valueIfEmpty - the value to return if the specified set of properties is eithernull or empty, can be null . Parameters: prefixIfNotEmpty - the prefix to add to the value if the PropertyReader is not empty, can be null . Parameters: suffix - the suffix to add to the value, can be null . | public static String | toString(PropertyReader properties, String valueIfEmpty, String prefixIfNotEmpty, String suffix, int maxValueLength) Returns the String representation for the specified
PropertyReader .
Parameters: properties - the PropertyReader to construct a String for, or null . Parameters: valueIfEmpty - the value to return if the specified set of properties is eithernull or empty, can be null . Parameters: prefixIfNotEmpty - the prefix to add to the value if the PropertyReader is not empty, can be null . Parameters: suffix - the suffix to add to the value, can be null . |
EMPTY_PROPERTY_READER | final public static PropertyReader EMPTY_PROPERTY_READER(Code) | | An empty and unmodifiable PropertyReader instance. This
field is not null .
since: XINS 1.1.0 |
equals | final public static boolean equals(PropertyReader pr, Object toCompare)(Code) | | Compares a PropertyReader instance with another object for
equality.
Parameters: pr - the PropertyReader , can be null . Parameters: toCompare - the object to compare the PropertyReader with,can be null .true if the objects are considered to be equal,false if they are considered different. since: XINS 2.1 |
getBooleanProperty | public static boolean getBooleanProperty(PropertyReader properties, String propertyName, boolean fallbackDefault) throws IllegalArgumentException, InvalidPropertyValueException(Code) | | Gets the property with the specified name and converts it to a
boolean .
Parameters: properties - the set of properties to read from, cannot be null . Parameters: propertyName - the name of the property to read, cannot be null . Parameters: fallbackDefault - the fallback default value, returned if the value of the property iseither null or "" (an empty string).the value of the property. throws: IllegalArgumentException - if properties == null || propertyName == null . throws: InvalidPropertyValueException - if the value of the property is neither null nor"" (an empty string), nor "true" nor"false" . |
getWithDefault | public String getWithDefault(PropertyReader properties, String key, String fallbackValue) throws IllegalArgumentException(Code) | | Retrieves a property with the specified name, falling back to a default
value if the property is not set.
Parameters: properties - the set of properties to retrieve a property from,cannot be null . Parameters: key - the property key, cannot be null . Parameters: fallbackValue - the fallback default value, returned in case the property is not set in properties , cannot be null .the value of the property or the fallback value. throws: IllegalArgumentException - if properties == null || key == null || fallbackValue == null . since: XINS 2.1 |
hashCode | final public static int hashCode(PropertyReader pr) throws NullPointerException(Code) | | Computes a hash code value for the specified PropertyReader
object.
Parameters: pr - the PropertyReader instance to compute a hash code valuefor, cannot be null .the hash code value. throws: NullPointerException - if pr == null . since: XINS 2.1 |
serialize | public static void serialize(PropertyReader properties, FastStringBuffer buffer, String valueIfEmpty) throws IllegalArgumentException(Code) | | Serializes the specified PropertyReader to a
FastStringBuffer . For each entry, both the key and the
value are encoded using the URL encoding (see
URLEncoding ).
The key and value are separated by a literal equals sign
('=' ). The entries are separated using
an ampersand ('&' ).
If the value for an entry is either null or an empty
string ("" ), then nothing is added to the buffer for that
entry.
Parameters: properties - the PropertyReader to serialize, can be null . Parameters: buffer - the buffer to write the serialized data to, cannot benull . Parameters: valueIfEmpty - the string to append to the buffer in caseproperties == null || properties.size() == 0 ; if thisargument is null , however, then nothing will be appendedin the mentioned case. throws: IllegalArgumentException - if properties == null || buffer == null .PropertyReaderUtils.toString(PropertyReader,String) |
toString | public static String toString(PropertyReader properties)(Code) | | Returns the String representation of the specified PropertyReader .
For each entry, both the key and the value are encoded using the URL
encoding (see
URLEncoding ).
The key and value are separated by a literal equals sign
('=' ). The entries are separated using an ampersand
('&' ).
If the value for an entry is either null or an empty
string ("" ), then nothing is added to the String for that
entry.
Parameters: properties - the PropertyReader to serialize, cannot be null .the String representation of the specified PropertyReader . since: XINS 2.0. |
toString | public static String toString(PropertyReader properties, String valueIfEmpty)(Code) | | Serializes the specified PropertyReader to a
String . For each entry, both the key and the
value are encoded using the URL encoding (see
URLEncoding ).
The key and value are separated by a literal equals sign
('=' ). The entries are separated using
an ampersand ('&' ).
If the value for an entry is either null or an empty
string ("" ), then nothing is added to the String for that
entry.
Parameters: properties - the PropertyReader to serialize, can be null . Parameters: valueIfEmpty - the string to append to the buffer in caseproperties == null || properties.size() == 0 .the String representation of the PropertyReader or the valueIfEmpty, never null .If all parameters are null then an empty String is returned. |
toString | public static String toString(PropertyReader properties, String valueIfEmpty, String prefixIfNotEmpty, String suffix)(Code) | | Returns the String representation for the specified
PropertyReader .
Parameters: properties - the PropertyReader to construct a String for, or null . Parameters: valueIfEmpty - the value to return if the specified set of properties is eithernull or empty, can be null . Parameters: prefixIfNotEmpty - the prefix to add to the value if the PropertyReader is not empty, can be null . Parameters: suffix - the suffix to add to the value, can be null . The suffixwill be added even if the PropertyReaderis empty.the String representation of the PropertyReader with the different artifacts, never null .If all parameters are null then an empty String is returned. since: XINS 2.0 |
toString | public static String toString(PropertyReader properties, String valueIfEmpty, String prefixIfNotEmpty, String suffix, int maxValueLength)(Code) | | Returns the String representation for the specified
PropertyReader .
Parameters: properties - the PropertyReader to construct a String for, or null . Parameters: valueIfEmpty - the value to return if the specified set of properties is eithernull or empty, can be null . Parameters: prefixIfNotEmpty - the prefix to add to the value if the PropertyReader is not empty, can be null . Parameters: suffix - the suffix to add to the value, can be null . The suffixwill be added even if the PropertyReaderis empty. Parameters: maxValueLength - the maximum of characters to set for the value, if the value is longerthan this limit '...' will be added after the limit.If the value is -1, no limit will be set.the String representation of the PropertyReader with the different artifacts, never null .If all parameters are null then an empty String is returned. since: XINS 2.0 |
|
|