com.ibm.awb.misc
Class Resource

java.lang.Object
  |
  +--com.ibm.awb.misc.Resource

public class Resource
extends java.lang.Object

The Resource class

Version:
1.00 96/11/15
Author:
Danny B. Lange, Mitsuru Oshima

Method Summary
 void appendResource(java.lang.String key, java.lang.String value)
          Appends a value to a resource.
static Resource createResource(java.lang.String name, java.util.Properties defaults)
          Creates named resources with default Proeprties object.
static Resource createResource(java.lang.String name, java.lang.String file, java.util.Properties defaults)
          Creates named resources with file and default Proeprties object.
 boolean getBoolean(java.lang.String key, boolean defaultValue)
           
 java.awt.Color getColor(java.lang.String key, java.awt.Color defaultColor)
           
 java.awt.Font getFont(java.lang.String key, java.awt.Font defaultFont)
           
 int getInteger(java.lang.String key, int defaultValue)
           
 java.lang.String[] getPersistentResourcesStartsWith(java.lang.String startsWith)
          Get the resources starting with the key
static Resource getResourceFor(java.lang.String name)
          Get the resource object by name.
 java.lang.String getString(java.lang.String key)
           
 java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
           
 java.lang.String[] getStringArray(java.lang.String key, java.lang.String sep)
           
 java.net.URL getURL(java.lang.String key, java.net.URL defaultValue)
           
 void importOptionProperties(java.lang.String startsWith)
          Imports all properties start with "key" into this resource.
 void list(java.io.PrintStream out)
           
 boolean load(java.net.URL loadFrom)
          Loads the properties from the file
 void mergeResource(java.lang.String key, java.lang.String value)
          Merge a value to a resource.
 void removeOptionResource(java.lang.String key)
           
 void removePersistentResourcesStartsWith(java.lang.String startsWith)
           
 void removeResource(java.lang.String key)
           
 boolean save(java.lang.String header)
          Saves the properties into the default file.
 boolean save(java.net.URL saveTo, java.lang.String header)
          Saves the properties into the file with given header.
 void setDefaultResource(java.lang.String key, java.lang.String value)
          Sets default property.
 void setDefaultResources(java.lang.String[][] key_value_pairs)
          Sets default properties.
 void setOptionResource(java.lang.String key, java.lang.String value)
          Sets an option property.
 void setResource(java.lang.String key, java.lang.String value)
          Sets a property.
static java.lang.String toString(java.awt.Color color)
          Convenient function to convert Color object to string representation.
static java.lang.String toString(java.awt.Font font)
          Convenient function to convert Font object to string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

appendResource

public void appendResource(java.lang.String key,
                           java.lang.String value)
Appends a value to a resource.
Parameters:
key - the key
value - the value to be append at the end of the original value

createResource

public static Resource createResource(java.lang.String name,
                                      java.lang.String file,
                                      java.util.Properties defaults)
                               throws java.net.MalformedURLException
Creates named resources with file and default Proeprties object.
See Also:
getResourceFor

createResource

public static Resource createResource(java.lang.String name,
                                      java.util.Properties defaults)
Creates named resources with default Proeprties object.
See Also:
getResourceFor

getBoolean

public boolean getBoolean(java.lang.String key,
                          boolean defaultValue)

getColor

public java.awt.Color getColor(java.lang.String key,
                               java.awt.Color defaultColor)

getFont

public java.awt.Font getFont(java.lang.String key,
                             java.awt.Font defaultFont)

getInteger

public int getInteger(java.lang.String key,
                      int defaultValue)

getPersistentResourcesStartsWith

public java.lang.String[] getPersistentResourcesStartsWith(java.lang.String startsWith)
Get the resources starting with the key
Parameters:
key - the key to search

getResourceFor

public static Resource getResourceFor(java.lang.String name)
Get the resource object by name.

getString

public java.lang.String getString(java.lang.String key)

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String defaultValue)

getStringArray

public java.lang.String[] getStringArray(java.lang.String key,
                                         java.lang.String sep)

getURL

public java.net.URL getURL(java.lang.String key,
                           java.net.URL defaultValue)

importOptionProperties

public void importOptionProperties(java.lang.String startsWith)
Imports all properties start with "key" into this resource. All imported properties are removed from "from" object.

list

public void list(java.io.PrintStream out)

load

public boolean load(java.net.URL loadFrom)
Loads the properties from the file

mergeResource

public void mergeResource(java.lang.String key,
                          java.lang.String value)
Merge a value to a resource. If the same value exists in the original value, it is just ignored.
Parameters:
key - the key
value - the value to be merged.

removeOptionResource

public void removeOptionResource(java.lang.String key)

removePersistentResourcesStartsWith

public void removePersistentResourcesStartsWith(java.lang.String startsWith)

removeResource

public void removeResource(java.lang.String key)

save

public boolean save(java.lang.String header)
Saves the properties into the default file.
Parameters:
header - header string

save

public boolean save(java.net.URL saveTo,
                    java.lang.String header)
Saves the properties into the file with given header.
Parameters:
saveTo - the URL pointing to the file location
header - string to be saved at the top of file

setDefaultResource

public void setDefaultResource(java.lang.String key,
                               java.lang.String value)
Sets default property. Default properties have last priority and are not persistent.
Parameters:
key - the key
value - the value to be stored as a default

setDefaultResources

public void setDefaultResources(java.lang.String[][] key_value_pairs)
Sets default properties. Default properties have last priority and are not persistent.
Parameters:
key - the key
value - the value to be stored as a default

setOptionResource

public void setOptionResource(java.lang.String key,
                              java.lang.String value)
Sets an option property. Option properties have first priority and are not persistent. These will not be saved in the file.
Parameters:
key - the key
value - the value to be stored as a option resource

setResource

public void setResource(java.lang.String key,
                        java.lang.String value)
Sets a property. Option properties are persistent and will be saved in the strage.
Parameters:
key - the key
value - the value to be stored

toString

public static java.lang.String toString(java.awt.Color color)
Convenient function to convert Color object to string representation.

toString

public static java.lang.String toString(java.awt.Font font)
Convenient function to convert Font object to string representation.