com.bbn.openmap.util
Class PropUtils

java.lang.Object
  extended by com.bbn.openmap.util.PropUtils

public class PropUtils
extends java.lang.Object


Field Summary
static java.lang.String DUMMY_MARKER_NAME
          A string used in marker names for property editors, when a custom editor used by an Inspector can set several top-level properties.
static java.lang.String keyValueSeparators
          Borrowed from Properties.java
static java.util.logging.Logger logger
           
static java.lang.String propertySeparators
          As defined in the OGC Web Mapping Test bed.
static java.lang.String strictKeyValueSeparators
          Borrowed from Properties.java
static java.lang.String whiteSpaceChars
          Borrowed from Properties.java
 
Constructor Summary
PropUtils()
           
 
Method Summary
static boolean booleanFromProperties(java.util.Properties p, java.lang.String propName, boolean defaultValue)
          Gets an boolean out of a properties object.
static char charFromProperties(java.util.Properties p, java.lang.String propName, char defaultValue)
          Return the first letter of the property specified by propName.
static void copyProperties(java.util.Properties from, java.util.Properties to)
          Copy the contents from one properties object to another.
static java.lang.String decodeDummyMarkerFromPropertyInfo(java.lang.String possibleDummyMarker)
          Should be used inside a PropertyConsumerPropertyEditor.setProperties(String, Properties) method to set the real property prefix.
static double doubleFromProperties(java.util.Properties p, java.lang.String propName, double defaultValue)
          Gets a double out of a properties object.
static float floatFromProperties(java.util.Properties p, java.lang.String propName, float defaultValue)
          Gets an float out of a properties object.
static java.lang.String getDummyMarkerForPropertyInfo(java.lang.String realComponentPropertyPrefix, java.lang.String anyDesiredScoper)
          Should be called by a PropertyConsumer in the getPropertiesInfo(Properties) method to create a property marker name for a custom PropertyEditor that will modify several top-level properties, i.e.
static java.lang.String[] getPropertiesAsStringArray(java.util.Properties props)
          Converts a properties object to an array of Strings.
static java.lang.String getProperty(java.awt.Color color)
          Returns a string representing a color, properly buffered for zeros for different alpha values.
static java.net.URL getResourceOrFileOrURL(java.lang.Class<? extends java.lang.Object> askingClass, java.lang.String name)
          Returns a URL that names either a resource, a local file, or an internet URL.
static java.net.URL getResourceOrFileOrURL(java.lang.Object askingClass, java.lang.String name)
          Returns a URL that names either a resource, a local file, or an internet URL.
static java.net.URL getResourceOrFileOrURL(java.lang.String name)
          Returns a URL that names either a resource, a local file, or an internet URL.
static java.lang.String getScopedPropertyPrefix(PropertyConsumer pc)
          It seems like every PropertyConsumer wrestles with having a prefix or not.
static java.lang.String getScopedPropertyPrefix(java.lang.String pre)
          Given the string, check if it's null.
static java.lang.String[] initPathsFromProperties(java.util.Properties p, java.lang.String propName)
          Takes a string of `;' separated paths and returns an array of parsed strings.
static java.lang.String[] initPathsFromProperties(java.util.Properties p, java.lang.String propName, java.lang.String[] defaultPaths)
          Takes a string of `;' separated paths and returns an array of parsed strings.
static int intFromProperties(java.util.Properties p, java.lang.String propName, int defaultValue)
          Gets an integer out of a properties object.
static boolean loadProperties(java.util.Properties properties, java.io.InputStream propsIn)
          Loads properties from a java resource.
static boolean loadProperties(java.util.Properties props, java.lang.String dir, java.lang.String file)
          Load the named file from the named directory into the given Properties instance.
static long longFromProperties(java.util.Properties p, java.lang.String propName, long defaultValue)
          Gets a long out of a properties object.
static java.lang.Object objectFromProperties(java.util.Properties p, java.lang.String propName)
          Creates an object out of a property name.
static java.util.List<?> objectsFromProperties(java.util.Properties p, java.lang.String markerListProperty, java.lang.String definingProperty)
          Get a List of Objects defined by marker names listed in a property.
static java.util.List<?> objectsFromScopedProperties(java.util.Properties p, java.lang.String markerListProperty, java.lang.String definingProperty, java.lang.String parentMarker)
          Get a List of Objects defined by marker names listed in a property, when this list property has been scoped by a parent object definition.
static java.awt.Color parseColor(java.lang.String colorString)
          Convert a string representing a 24/32bit hex color value into a Color value.
static java.awt.Color parseColor(java.lang.String colorString, boolean forceAlpha)
          Convert a string representing a 24/32bit hex color value into a Color value.
static java.awt.Paint parseColorFromProperties(java.util.Properties p, java.lang.String propName, java.awt.Paint dfault)
          Take a string from a properties file, representing the 24bit RGB or 32bit ARGB hex values for a color, and convert it to a java.awt.Color.
static java.awt.Color parseColorFromProperties(java.util.Properties p, java.lang.String propName, java.lang.String dfault)
          Take a string from a properties file, representing the 24bit RGB or 32bit ARGB hex values for a color, and convert it to a java.awt.Color.
static java.awt.Color parseColorFromProperties(java.util.Properties p, java.lang.String propName, java.lang.String dfault, boolean forceAlpha)
          Take a string from a properties file, representing the 24bit RGB or 32bit ARGB hex values for a color, and convert it to a java.awt.Color.
static java.util.Vector<java.lang.String> parseMarkers(java.lang.String markerList, java.lang.String delim)
          Parse a list of marker names from a space separated list within a String.
static java.util.Properties parsePropertyList(java.lang.String list)
          Take a property list, defined in a single string, and return a Properties object.
static java.util.Properties parsePropertyList(java.lang.String list, java.lang.String propertySeparators, java.lang.String keyValueSeparators)
          Take a property list, defined in a single string, and return a Properties object.
static java.util.Vector<java.lang.String> parseSpacedMarkers(java.lang.String markerList)
          Parse a list of marker names from a space separated list within a String.
static java.util.Properties promptUserForProperties()
          A function that brings up a file chooser window in order to have the user look for a valid Java properties file.
static void putDataPrefixToLayerList(Layer layer, java.util.Properties props, java.lang.String layerListProperty)
          If the layer has a dataPathPrefix attribute set, that attribute value can be used as a common path to prepend to any layer's data path.
static void putDataPrefixToLayerList(java.lang.String dataPrefix, java.util.Properties props, java.lang.String layerListProperty)
          If the layer has a dataPathPrefix attribute set, that attribute value can be used as a common path to prepend to any layer's data path.
static
<T> void
putIfNotDefault(java.util.Properties props, java.lang.String propertyName, T value)
          Add the object property value to properties if it's not null or empty, which assumes it should be set to the default value.
static
<T> void
putIfNotDefault(java.util.Properties props, java.lang.String propertyName, T value, T def)
          Add the object property value to properties if it's not null or default value.
static java.util.Properties setI18NPropertyInfo(I18n i18n, java.util.Properties info, java.lang.Class<? extends java.lang.Object> classToSetFor, java.lang.String propertyName, java.lang.String label, java.lang.String tooltip, java.lang.String editor)
          Simple space saving implementation of common I18n Property Info setting.
static java.lang.String[] stringArrayFromProperties(java.util.Properties p, java.lang.String propName, java.lang.String tok)
          Takes a string of representing token separated properties and returns an array of parsed strings.
static java.lang.String unnull(java.lang.Object prop)
          It kills Properties to have null values set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static java.util.logging.Logger logger

DUMMY_MARKER_NAME

public static final java.lang.String DUMMY_MARKER_NAME
A string used in marker names for property editors, when a custom editor used by an Inspector can set several top-level properties.

See Also:
Constant Field Values

keyValueSeparators

public static final java.lang.String keyValueSeparators
Borrowed from Properties.java

See Also:
Constant Field Values

strictKeyValueSeparators

public static final java.lang.String strictKeyValueSeparators
Borrowed from Properties.java

See Also:
Constant Field Values

whiteSpaceChars

public static final java.lang.String whiteSpaceChars
Borrowed from Properties.java

See Also:
Constant Field Values

propertySeparators

public static final java.lang.String propertySeparators
As defined in the OGC Web Mapping Test bed.

See Also:
Constant Field Values
Constructor Detail

PropUtils

public PropUtils()
Method Detail

parseSpacedMarkers

public static java.util.Vector<java.lang.String> parseSpacedMarkers(java.lang.String markerList)
Parse a list of marker names from a space separated list within a String.

Parameters:
markerList - a string containing a space delimited list of marker names.
Returns:
Vector of marker names.

parseMarkers

public static java.util.Vector<java.lang.String> parseMarkers(java.lang.String markerList,
                                                              java.lang.String delim)
Parse a list of marker names from a space separated list within a String.

Parameters:
markerList - a string containing a list of things to be parsed.
delim - the list of tokens to look for which separate the list elements.
Returns:
Vector of marker names.

parsePropertyList

public static java.util.Properties parsePropertyList(java.lang.String list)
                                              throws PropertyStringFormatException
Take a property list, defined in a single string, and return a Properties object. The properties, as key-value pairs, are separated by another type of symbol. In this method, the key-values are assumed to be separated from other key-value pairs by PropUtils.propertySeparators String characters, and each key is separated from its value by any character in the PropUtils.keyValueSeparators list.

Parameters:
list - the properties list string.
Returns:
Properties object containing keys and values.
Throws:
PropertyStringFormatException - if a key doesn't have a value.

parsePropertyList

public static java.util.Properties parsePropertyList(java.lang.String list,
                                                     java.lang.String propertySeparators,
                                                     java.lang.String keyValueSeparators)
                                              throws PropertyStringFormatException
Take a property list, defined in a single string, and return a Properties object. The properties, as key-value pairs, are separated by another type of symbol.

Parameters:
list - the properties list string.
propertySeparators - the key-values are assumed to be separated from other key-value pairs by any character in this String.
keyValueSeparators - each key is separated from its value by any character in this String.
Returns:
Properties object containing keys and values.
Throws:
PropertyStringFormatException - if a key doesn't have a value.

copyProperties

public static void copyProperties(java.util.Properties from,
                                  java.util.Properties to)
Copy the contents from one properties object to another.

Parameters:
from - the source Properties object.
to - the destination Properties object.

loadProperties

public static boolean loadProperties(java.util.Properties props,
                                     java.lang.String dir,
                                     java.lang.String file)
Load the named file from the named directory into the given Properties instance. If the file is not found a warning is issued. If an IOException occurs, a fatal error is printed.

Parameters:
props - the instance to receive the loaded properties
dir - the directory where the properties file resides
file - the name of the file
Returns:
true if the properties file exists and was loaded.

loadProperties

public static boolean loadProperties(java.util.Properties properties,
                                     java.io.InputStream propsIn)
Loads properties from a java resource. This will load the named resource identifier into the given properties instance.

Parameters:
properties - the Properties instance to receive the properties.
propsIn - an InputStream to read properties from
Returns:
true if the properties file exists and was loaded.

promptUserForProperties

public static java.util.Properties promptUserForProperties()
A function that brings up a file chooser window in order to have the user look for a valid Java properties file.

Returns:
properties object with selected file contents.

getScopedPropertyPrefix

public static java.lang.String getScopedPropertyPrefix(PropertyConsumer pc)
It seems like every PropertyConsumer wrestles with having a prefix or not. This method lets you just get the prefix with a period on the end (for scoping purposes), or just returns an empty String. Either way, you get a String you can slap on the beginning of your defined property names to get a valid property based on what the prefix is.

Parameters:
pc - the PropertyConsumer to fetch from
Returns:
an empty string if no prefix, or the prefix with a period at the end

getScopedPropertyPrefix

public static java.lang.String getScopedPropertyPrefix(java.lang.String pre)
Given the string, check if it's null. If it isn't, check to see if it ends with a period, and do nothing if it does. If it doesn't end in a period, add one, and then return that. The returned string should be good for prepending to other properties.

Parameters:
pre - the string to check
Returns:
an empty string or one that ends with a period

getDummyMarkerForPropertyInfo

public static java.lang.String getDummyMarkerForPropertyInfo(java.lang.String realComponentPropertyPrefix,
                                                             java.lang.String anyDesiredScoper)
Should be called by a PropertyConsumer in the getPropertiesInfo(Properties) method to create a property marker name for a custom PropertyEditor that will modify several top-level properties, i.e. the com.bbn.openmap.omGraphics.DrawingAttributesPropertyEditor.

Parameters:
realComponentPropertyPrefix - the top-level prefix that the PropertyConsumer being set with the properties has. Can be null.
anyDesiredScoper - an additional scoping mechanism if there are more than one custom editors being used for a given getPropertyInfo call.
Returns:
The string that is used for a marker for a custom editor.

decodeDummyMarkerFromPropertyInfo

public static java.lang.String decodeDummyMarkerFromPropertyInfo(java.lang.String possibleDummyMarker)
Should be used inside a PropertyConsumerPropertyEditor.setProperties(String, Properties) method to set the real property prefix. The PropertyConsumer that the Inspector is looking at should use the getDummyMarker() call to create the marker for the getPropertyInfor(Properties) call.

Parameters:
possibleDummyMarker - string to check for DUMMY_MARKER_NAME, indicating that's a dummy
Returns:
the encoded 'real' property prefix for the PropertyConsumer embedded in the dummy marker, or the possibleDummyMarker if it's not a dummy marker.

unnull

public static java.lang.String unnull(java.lang.Object prop)
It kills Properties to have null values set. You can wrap a property value in this in PropertyConsumer.getProperties() to not worry about it.

Parameters:
prop - property value to be set in properties after this call
Returns:
empty string if prop equals null, else returns what was passed in

initPathsFromProperties

public static java.lang.String[] initPathsFromProperties(java.util.Properties p,
                                                         java.lang.String propName)
Takes a string of `;' separated paths and returns an array of parsed strings. NOTE: this method currently doesn't support appropriate quoting of the `;' character, although it probably should...

Parameters:
p - properties
propName - the name of the property
Returns:
Array of strings representing paths.

initPathsFromProperties

public static java.lang.String[] initPathsFromProperties(java.util.Properties p,
                                                         java.lang.String propName,
                                                         java.lang.String[] defaultPaths)
Takes a string of `;' separated paths and returns an array of parsed strings. NOTE: this method currently doesn't support appropriate quoting of the `;' character, although it probably should...

Parameters:
p - properties
propName - the name of the property
defaultPaths - the value of the paths to set if the property doesn't exist, or if is doesn't contain anything.
Returns:
Array of strings representing paths.

charFromProperties

public static char charFromProperties(java.util.Properties p,
                                      java.lang.String propName,
                                      char defaultValue)
Return the first letter of the property specified by propName. If that value is null or has length of zero, the default char is returned.

Parameters:
p - properties to load from
propName - property name
defaultValue - default to use if property isn't found
Returns:
first char from property, or default.

intFromProperties

public static int intFromProperties(java.util.Properties p,
                                    java.lang.String propName,
                                    int defaultValue)
Gets an integer out of a properties object. Returns the default value if something goes wrong.

Parameters:
p - properties
propName - name of the property associated with the wanted value.
defaultValue - what to return if the property name doesn't exist, or if the value isn't a numerical value.
Returns:
integer value associated with the property.

floatFromProperties

public static float floatFromProperties(java.util.Properties p,
                                        java.lang.String propName,
                                        float defaultValue)
Gets an float out of a properties object. Returns the default value if something goes wrong.

Parameters:
p - properties
propName - name of the property associated with the wanted value.
defaultValue - what to return if the property name doesn't exist, or if the value isn't a numerical value.
Returns:
float value associated with the property.

booleanFromProperties

public static boolean booleanFromProperties(java.util.Properties p,
                                            java.lang.String propName,
                                            boolean defaultValue)
Gets an boolean out of a properties object. Returns the default value if something goes wrong.

Parameters:
p - properties
propName - name of the property associated with the wanted value.
defaultValue - what to return if the property name doesn't exist, or if the value isn't a numerical value.
Returns:
boolean value associated with the property.

objectFromProperties

public static java.lang.Object objectFromProperties(java.util.Properties p,
                                                    java.lang.String propName)
Creates an object out of a property name. If anything fails, return null.

Parameters:
p - properties
propName - name of class to instantiate.
Returns:
null on failure, otherwise, a default constructed instance of the class named in the property.

stringArrayFromProperties

public static java.lang.String[] stringArrayFromProperties(java.util.Properties p,
                                                           java.lang.String propName,
                                                           java.lang.String tok)
Takes a string of representing token separated properties and returns an array of parsed strings. NOTE: this method currently doesn't support appropriate quoting of the token, although it probably should...

Parameters:
p - properties
propName - the name of the property
tok - the characters separating the strings.
Returns:
Array of strings between the tokens.

doubleFromProperties

public static double doubleFromProperties(java.util.Properties p,
                                          java.lang.String propName,
                                          double defaultValue)
Gets a double out of a properties object. Returns the default value if something goes wrong.

Parameters:
p - properties
propName - name of the property associated with the wanted value.
defaultValue - what to return if the property name doesn't exist, or if the value isn't a numerical value.
Returns:
double value associated with the property.

longFromProperties

public static long longFromProperties(java.util.Properties p,
                                      java.lang.String propName,
                                      long defaultValue)
Gets a long out of a properties object. Returns the default value if something goes wrong.

Parameters:
p - properties
propName - name of the property associated with the wanted value.
defaultValue - what to return if the property name doesn't exist, or if the value isn't a numerical value.
Returns:
long value associated with the property.

parseColorFromProperties

public static java.awt.Color parseColorFromProperties(java.util.Properties p,
                                                      java.lang.String propName,
                                                      java.lang.String dfault)
                                               throws java.lang.NumberFormatException
Take a string from a properties file, representing the 24bit RGB or 32bit ARGB hex values for a color, and convert it to a java.awt.Color.

Parameters:
p - properties
propName - the name of the property
dfault - color to use if the property value doesn't work
Returns:
java.awt.Color
Throws:
java.lang.NumberFormatException - if the specified string cannot be interpreted as a hexidecimal integer
See Also:
ColorFactory.parseColorFromProperties(Properties, String, String, boolean)

parseColorFromProperties

public static java.awt.Color parseColorFromProperties(java.util.Properties p,
                                                      java.lang.String propName,
                                                      java.lang.String dfault,
                                                      boolean forceAlpha)
                                               throws java.lang.NumberFormatException
Take a string from a properties file, representing the 24bit RGB or 32bit ARGB hex values for a color, and convert it to a java.awt.Color.

Parameters:
p - properties
propName - the name of the property
dfault - color to use if the property value doesn't work
forceAlpha - force using alpha value
Returns:
java.awt.Color
Throws:
java.lang.NumberFormatException - if the specified string cannot be interpreted as a hexidecimal integer
See Also:
ColorFactory.parseColorFromProperties(Properties, String, String, boolean)

parseColorFromProperties

public static java.awt.Paint parseColorFromProperties(java.util.Properties p,
                                                      java.lang.String propName,
                                                      java.awt.Paint dfault)
Take a string from a properties file, representing the 24bit RGB or 32bit ARGB hex values for a color, and convert it to a java.awt.Color.

Parameters:
p - properties
propName - the name of the property
dfault - color to use if the property value doesn't work
Returns:
java.awt.Color
See Also:
ColorFactory.parseColorFromProperties(Properties, String, String, boolean)

parseColor

public static java.awt.Color parseColor(java.lang.String colorString,
                                        boolean forceAlpha)
                                 throws java.lang.NumberFormatException
Convert a string representing a 24/32bit hex color value into a Color value. NOTE:

Parameters:
colorString - the 24/32bit hex string value (ARGB)
forceAlpha - force using alpha value
Returns:
java.awt.Color (24bit RGB on JDK 1.1, 24/32bit ARGB on JDK1.2)
Throws:
java.lang.NumberFormatException - if the specified string cannot be interpreted as a hexidecimal integer
See Also:
ColorFactory.parseColor(String, boolean)

parseColor

public static java.awt.Color parseColor(java.lang.String colorString)
                                 throws java.lang.NumberFormatException
Convert a string representing a 24/32bit hex color value into a Color value. NOTE:

Parameters:
colorString - the 24/32bit hex string value (ARGB)
Returns:
java.awt.Color (24bit RGB on JDK 1.1, 24/32bit ARGB on JDK1.2)
Throws:
java.lang.NumberFormatException - if the specified string cannot be interpreted as a hexidecimal integer
See Also:
ColorFactory.parseColor(String, boolean)

getProperty

public static java.lang.String getProperty(java.awt.Color color)
Returns a string representing a color, properly buffered for zeros for different alpha values.

Parameters:
color - the source Color
Returns:
string for color with alpha values.

getPropertiesAsStringArray

public static java.lang.String[] getPropertiesAsStringArray(java.util.Properties props)
Converts a properties object to an array of Strings. The resulting array will consist of alternating key-value strings.

Parameters:
props - the properties object to convert.
Returns:
an array of Strings representing key-value pairs.

getResourceOrFileOrURL

public static java.net.URL getResourceOrFileOrURL(java.lang.String name)
                                           throws java.net.MalformedURLException
Returns a URL that names either a resource, a local file, or an internet URL. Resources are checked for in the general classpath.

Parameters:
name - name of the resource, file or URL.
Returns:
URL
Throws:
java.net.MalformedURLException - if there's a problem finding the thingy

getResourceOrFileOrURL

public static java.net.URL getResourceOrFileOrURL(java.lang.Object askingClass,
                                                  java.lang.String name)
                                           throws java.net.MalformedURLException
Returns a URL that names either a resource, a local file, or an internet URL.

Parameters:
askingClass - the object asking for the URL.
name - name of the resource, file or URL.
Returns:
URL
Throws:
java.net.MalformedURLException - if there's a problem finding the thingy

getResourceOrFileOrURL

public static java.net.URL getResourceOrFileOrURL(java.lang.Class<? extends java.lang.Object> askingClass,
                                                  java.lang.String name)
                                           throws java.net.MalformedURLException
Returns a URL that names either a resource, a local file, or an internet URL.

Parameters:
askingClass - the class asking for the URL. Can be null.
name - name of the resource, file or URL.
Returns:
URL
Throws:
java.net.MalformedURLException - if there's a problem finding the thingy

setI18NPropertyInfo

public static java.util.Properties setI18NPropertyInfo(I18n i18n,
                                                       java.util.Properties info,
                                                       java.lang.Class<? extends java.lang.Object> classToSetFor,
                                                       java.lang.String propertyName,
                                                       java.lang.String label,
                                                       java.lang.String tooltip,
                                                       java.lang.String editor)
Simple space saving implementation of common I18n Property Info setting.

Parameters:
i18n - i18n object to use to search for internationalized strings.
info - the properties class being used to set information into.
classToSetFor - class to use for i18n search.
propertyName - property to set for.
label - label to use for GUI (can be null if N/A).
tooltip - tooltip to use for GUI (can be null if N/A).
editor - editor class string to use for GUI (can be null if N/A).
Returns:
Properties object passed in, or new one if null Properties passed in.

putDataPrefixToLayerList

public static void putDataPrefixToLayerList(Layer layer,
                                            java.util.Properties props,
                                            java.lang.String layerListProperty)
If the layer has a dataPathPrefix attribute set, that attribute value can be used as a common path to prepend to any layer's data path. This allows you to set a relative path to files in the layer's properties, and then prepend the absolute path later at runtime.

The dataPathPrefix can be set in the properties for a layer, where it is pushed to the layer's attributes in Layer.setProperties(). This method is intended for layers that have sub-layers, so the parent layer can set that dataPathPrefix property on it's children automatically.

Parameters:
layer - the parent layer to retrieve the attribute from
props - the properties that define the children, and also passed to them for configuration
layerListProperty - the property for the parent that lists the marker names for the children

putDataPrefixToLayerList

public static void putDataPrefixToLayerList(java.lang.String dataPrefix,
                                            java.util.Properties props,
                                            java.lang.String layerListProperty)
If the layer has a dataPathPrefix attribute set, that attribute value can be used as a common path to prepend to any layer's data path. This allows you to set a relative path to files in the layer's properties, and then prepend the absolute path later at runtime.

The dataPathPrefix can be set in the properties for a layer, where it is pushed to the layer's attributes in Layer.setProperties(). This method is intended for layers that have sub-layers, so the parent layer can set that dataPathPrefix property on it's children automatically.

Parameters:
dataPrefix - the dataPathPrefix retrieved from the parent attributes
props - the properties that define the children, and also passed to them for configuration
layerListProperty - the property for the parent that lists the marker names for the children

objectsFromProperties

public static java.util.List<?> objectsFromProperties(java.util.Properties p,
                                                      java.lang.String markerListProperty,
                                                      java.lang.String definingProperty)
Get a List of Objects defined by marker names listed in a property. If the objects are PropertyConsumers, they will be given the properties and their scoped property prefix so they can configure themselves.
 
 listProperty=markername1 markername2 markername3
 markername1.definingProperty=classname1
 markername2.definingProperty=classname2
 markername3.definingProperty=classname3
 
 

Parameters:
p - Properties object containing all properties
markerListProperty - listProperty in example above
definingProperty - definingProperty in example above, scoped property when combined with marker name to define the class that should be created for an object.
Returns:
List of objects created from properties

objectsFromScopedProperties

public static java.util.List<?> objectsFromScopedProperties(java.util.Properties p,
                                                            java.lang.String markerListProperty,
                                                            java.lang.String definingProperty,
                                                            java.lang.String parentMarker)
Get a List of Objects defined by marker names listed in a property, when this list property has been scoped by a parent object definition. If the objects are PropertyConsumers, they will be given the properties and their scoped property prefix so they can configure themselves.
 
 parentMarker.listProperty=markername1 markername2 markername3
 parentMarker.markername1.definingProperty=classname1
 parentMarker.markername2.definingProperty=classname2
 parentMarker.markername3.definingProperty=classname3
 
 

Parameters:
p - Properties object containing all properties
markerListProperty - listProperty in example above
definingProperty - definingProperty in example above, scoped property when combined with marker name to define the class that should be created for an object.
parentMarker - the string that should be used as the prefix for the defining property
Returns:
List of objects created from properties, where properties are scoped for each object.

putIfNotDefault

public static <T> void putIfNotDefault(java.util.Properties props,
                                       java.lang.String propertyName,
                                       T value)
Add the object property value to properties if it's not null or empty, which assumes it should be set to the default value.

Type Parameters:
T - class for property
Parameters:
props - Properties to write to
propertyName - the scoped property to enter value under
value - the object to get property from - toString() will be called if not null.

putIfNotDefault

public static <T> void putIfNotDefault(java.util.Properties props,
                                       java.lang.String propertyName,
                                       T value,
                                       T def)
Add the object property value to properties if it's not null or default value.

Type Parameters:
T - matching class types for the property
Parameters:
props - Properties to write to
propertyName - the scoped property to enter value under
value - the object to get property from - toString() will be called if not null.
def - the default value of the property. If not null and value not null, toString().equals() will be used to determine equality. If not equal, then value will be set in props.


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details