Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.util
Class PropUtils

    java.lang.Object
      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 Properites.java
`static java.lang.String` | `propertySeparators` As defined in the OGC Web Mapping Testbed.
`static java.lang.String` | `strictKeyValueSeparators` Borrowed from Properites.java
`static java.lang.String` | `whiteSpaceChars` Borrowed from Properites.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 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 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.awt.Color` | `parseColor(java.lang.String colorString)` 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.util.Vector` | `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` | `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 java.util.Properties` | `setI18NPropertyInfo(I18n i18n, java.util.Properties info, java.lang.Class 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.String 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

### 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 Properites.java

  See Also:
    Constant Field Values

### strictKeyValueSeparators

    public static final java.lang.String strictKeyValueSeparators

  Borrowed from Properites.java

  See Also:
    Constant Field Values

### whiteSpaceChars

    public static final java.lang.String whiteSpaceChars

  Borrowed from Properites.java

  See Also:
    Constant Field Values

### propertySeparators

    public static final java.lang.String propertySeparators

  As defined in the OGC Web Mapping Testbed.

  See Also:
    Constant Field Values

Constructor Detail

### PropUtils

    public PropUtils()

Method Detail

### parseSpacedMarkers

    public static java.util.Vector 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 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 space delimited list of marker names.
    `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 propery names to get a valid property based on what the prefix is.

### getScopedPropertyPrefix

    public static java.lang.String getScopedPropertyPrefix(java.lang.String pre)

  Given the string, check if it's null. If it is, return an empty string. 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.

### 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` -
  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.String 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. Returns "" if prop == 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.

### 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.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)
                                     throws java.lang.NumberFormatException

  Convert a string representing a 24/32bit hex color value into a Color value. NOTE:
  - Only 24bit (RGB) java.awt.Color is supported on the JDK 1.1 platform.
  - Both 24/32bit (ARGB) java.awt.Color is supported on the Java 2 platform.

  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` -
  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`

### 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`

### getResourceOrFileOrURL

    public static java.net.URL getResourceOrFileOrURL(java.lang.Class 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`

### setI18NPropertyInfo

    public static java.util.Properties setI18NPropertyInfo(I18n i18n,
                                                           java.util.Properties info,
                                                           java.lang.Class 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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