|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bbn.openmap.util.PropUtils
public class PropUtils
| 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
|
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
|
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 |
|---|
public static java.util.logging.Logger logger
public static final java.lang.String DUMMY_MARKER_NAME
public static final java.lang.String keyValueSeparators
public static final java.lang.String strictKeyValueSeparators
public static final java.lang.String whiteSpaceChars
public static final java.lang.String propertySeparators
| Constructor Detail |
|---|
public PropUtils()
| Method Detail |
|---|
public static java.util.Vector<java.lang.String> parseSpacedMarkers(java.lang.String markerList)
markerList - a string containing a space delimited list of marker
names.
public static java.util.Vector<java.lang.String> parseMarkers(java.lang.String markerList,
java.lang.String delim)
markerList - a string containing a list of things to be parsed.delim - the list of tokens to look for which separate the list
elements.
public static java.util.Properties parsePropertyList(java.lang.String list)
throws PropertyStringFormatException
list - the properties list string.
PropertyStringFormatException - if a key doesn't have a value.
public static java.util.Properties parsePropertyList(java.lang.String list,
java.lang.String propertySeparators,
java.lang.String keyValueSeparators)
throws PropertyStringFormatException
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.
PropertyStringFormatException - if a key doesn't have a value.
public static void copyProperties(java.util.Properties from,
java.util.Properties to)
from - the source Properties object.to - the destination Properties object.
public static boolean loadProperties(java.util.Properties props,
java.lang.String dir,
java.lang.String file)
Properties instance. If the file is not found a warning is
issued. If an IOException occurs, a fatal error is printed.
props - the instance to receive the loaded propertiesdir - the directory where the properties file residesfile - the name of the file
public static boolean loadProperties(java.util.Properties properties,
java.io.InputStream propsIn)
properties - the Properties instance to receive the properties.propsIn - an InputStream to read properties from
public static java.util.Properties promptUserForProperties()
public static java.lang.String getScopedPropertyPrefix(PropertyConsumer pc)
pc - the PropertyConsumer to fetch from
public static java.lang.String getScopedPropertyPrefix(java.lang.String pre)
pre - the string to check
public static java.lang.String getDummyMarkerForPropertyInfo(java.lang.String realComponentPropertyPrefix,
java.lang.String anyDesiredScoper)
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.
public static java.lang.String decodeDummyMarkerFromPropertyInfo(java.lang.String possibleDummyMarker)
possibleDummyMarker - string to check for DUMMY_MARKER_NAME,
indicating that's a dummy
public static java.lang.String unnull(java.lang.Object prop)
prop - property value to be set in properties after this call
public static java.lang.String[] initPathsFromProperties(java.util.Properties p,
java.lang.String propName)
p - propertiespropName - the name of the property
public static java.lang.String[] initPathsFromProperties(java.util.Properties p,
java.lang.String propName,
java.lang.String[] defaultPaths)
p - propertiespropName - the name of the propertydefaultPaths - the value of the paths to set if the property doesn't
exist, or if is doesn't contain anything.
public static char charFromProperties(java.util.Properties p,
java.lang.String propName,
char defaultValue)
p - properties to load frompropName - property namedefaultValue - default to use if property isn't found
public static int intFromProperties(java.util.Properties p,
java.lang.String propName,
int defaultValue)
p - propertiespropName - 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.
public static float floatFromProperties(java.util.Properties p,
java.lang.String propName,
float defaultValue)
p - propertiespropName - 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.
public static boolean booleanFromProperties(java.util.Properties p,
java.lang.String propName,
boolean defaultValue)
p - propertiespropName - 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.
public static java.lang.Object objectFromProperties(java.util.Properties p,
java.lang.String propName)
p - propertiespropName - name of class to instantiate.
public static java.lang.String[] stringArrayFromProperties(java.util.Properties p,
java.lang.String propName,
java.lang.String tok)
p - propertiespropName - the name of the propertytok - the characters separating the strings.
public static double doubleFromProperties(java.util.Properties p,
java.lang.String propName,
double defaultValue)
p - propertiespropName - 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.
public static long longFromProperties(java.util.Properties p,
java.lang.String propName,
long defaultValue)
p - propertiespropName - 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.
public static java.awt.Color parseColorFromProperties(java.util.Properties p,
java.lang.String propName,
java.lang.String dfault)
throws java.lang.NumberFormatException
p - propertiespropName - the name of the propertydfault - color to use if the property value doesn't work
java.lang.NumberFormatException - if the specified string cannot be
interpreted as a hexidecimal integerColorFactory.parseColorFromProperties(Properties, String, String,
boolean)
public static java.awt.Color parseColorFromProperties(java.util.Properties p,
java.lang.String propName,
java.lang.String dfault,
boolean forceAlpha)
throws java.lang.NumberFormatException
p - propertiespropName - the name of the propertydfault - color to use if the property value doesn't workforceAlpha - force using alpha value
java.lang.NumberFormatException - if the specified string cannot be
interpreted as a hexidecimal integerColorFactory.parseColorFromProperties(Properties, String, String,
boolean)
public static java.awt.Paint parseColorFromProperties(java.util.Properties p,
java.lang.String propName,
java.awt.Paint dfault)
p - propertiespropName - the name of the propertydfault - color to use if the property value doesn't work
ColorFactory.parseColorFromProperties(Properties, String, String,
boolean)
public static java.awt.Color parseColor(java.lang.String colorString,
boolean forceAlpha)
throws java.lang.NumberFormatException
colorString - the 24/32bit hex string value (ARGB)forceAlpha - force using alpha value
java.lang.NumberFormatException - if the specified string cannot be
interpreted as a hexidecimal integerColorFactory.parseColor(String, boolean)
public static java.awt.Color parseColor(java.lang.String colorString)
throws java.lang.NumberFormatException
colorString - the 24/32bit hex string value (ARGB)
java.lang.NumberFormatException - if the specified string cannot be
interpreted as a hexidecimal integerColorFactory.parseColor(String, boolean)public static java.lang.String getProperty(java.awt.Color color)
color - the source Color
public static java.lang.String[] getPropertiesAsStringArray(java.util.Properties props)
props - the properties object to convert.
public static java.net.URL getResourceOrFileOrURL(java.lang.String name)
throws java.net.MalformedURLException
name - name of the resource, file or URL.
java.net.MalformedURLException - if there's a problem finding the
thingy
public static java.net.URL getResourceOrFileOrURL(java.lang.Object askingClass,
java.lang.String name)
throws java.net.MalformedURLException
askingClass - the object asking for the URL.name - name of the resource, file or URL.
java.net.MalformedURLException - if there's a problem finding the
thingy
public static java.net.URL getResourceOrFileOrURL(java.lang.Class<? extends java.lang.Object> askingClass,
java.lang.String name)
throws java.net.MalformedURLException
askingClass - the class asking for the URL. Can be null.name - name of the resource, file or URL.
java.net.MalformedURLException - if there's a problem finding the
thingy
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)
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).
public static void putDataPrefixToLayerList(Layer layer,
java.util.Properties props,
java.lang.String layerListProperty)
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.
layer - the parent layer to retrieve the attribute fromprops - the properties that define the children, and also passed to
them for configurationlayerListProperty - the property for the parent that lists the
marker names for the children
public static void putDataPrefixToLayerList(java.lang.String dataPrefix,
java.util.Properties props,
java.lang.String layerListProperty)
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.
dataPrefix - the dataPathPrefix retrieved from the parent attributesprops - the properties that define the children, and also passed to
them for configurationlayerListProperty - the property for the parent that lists the
marker names for the children
public static java.util.List<?> objectsFromProperties(java.util.Properties p,
java.lang.String markerListProperty,
java.lang.String definingProperty)
listProperty=markername1 markername2 markername3 markername1.definingProperty=classname1 markername2.definingProperty=classname2 markername3.definingProperty=classname3
p - Properties object containing all propertiesmarkerListProperty - listProperty in example abovedefiningProperty - definingProperty in example above, scoped
property when combined with marker name to define the class that
should be created for an object.
public static java.util.List<?> objectsFromScopedProperties(java.util.Properties p,
java.lang.String markerListProperty,
java.lang.String definingProperty,
java.lang.String parentMarker)
parentMarker.listProperty=markername1 markername2 markername3 parentMarker.markername1.definingProperty=classname1 parentMarker.markername2.definingProperty=classname2 parentMarker.markername3.definingProperty=classname3
p - Properties object containing all propertiesmarkerListProperty - listProperty in example abovedefiningProperty - 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
public static <T> void putIfNotDefault(java.util.Properties props,
java.lang.String propertyName,
T value)
T - class for propertyprops - Properties to write topropertyName - the scoped property to enter value undervalue - the object to get property from - toString() will be called
if not null.
public static <T> void putIfNotDefault(java.util.Properties props,
java.lang.String propertyName,
T value,
T def)
T - matching class types for the propertyprops - Properties to write topropertyName - the scoped property to enter value undervalue - 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||