org.hsqldb
Class HsqlProperties

java.lang.Object
  extended byorg.hsqldb.HsqlProperties

public class HsqlProperties
extends Object

Wrapper for java.util.Properties to limit values to Specific types and allow saving and loading.

Is public because it is used in the org.hsqldb.test package.

Since:
1.7.0
Version:
1.7.2
Author:
fredt@users

Field Summary
protected  int[] errorCodes
           
protected  String[] errorKeys
           
protected  String fileName
           
static int NO_VALUE_FOR_KEY
           
protected  boolean resource
           
protected  Properties stringProps
           
 
Constructor Summary
HsqlProperties()
           
HsqlProperties(Properties props)
           
HsqlProperties(String name)
           
HsqlProperties(String name, boolean b)
           
 
Method Summary
 void addProperties(HsqlProperties props)
           
 void addProperties(Properties props)
           
static HsqlProperties argArrayToProps(String[] arg, String type)
          Creates and populates an HsqlProperties Object from the arguments array of a Main method.
 boolean checkFileExists()
           
static boolean checkFileExists(String fileName, boolean resource, Class cla)
           
static HsqlProperties delimitedArgPairsToProps(String s, String pairsep, String dlimiter, String type)
          Creates and populates a new HsqlProperties Object using a string such as "key1=value1;key2=value2" The string that represents the = sign above is specified as pairsep and the one that represents the semicolon is specified as delimiter, allowing any string to be used for either.
 int getIntegerProperty(String key, int defaultValue)
           
 int getIntegerProperty(String key, int defaultValue, int minimum, int maximum)
           
 Properties getProperties()
           
 String getProperty(String key)
           
 String getProperty(String key, String defaultValue)
           
 boolean isEmpty()
           
 boolean isPropertyTrue(String key)
           
 boolean isPropertyTrue(String key, boolean defaultValue)
           
 boolean load()
           
static void main(String[] argv)
           
 Enumeration propertyNames()
           
 void removeProperty(String key)
           
 void save()
          Saves the properties using JDK2 method if present, otherwise JDK1.
 void setFileName(String name)
           
 String setProperty(String key, boolean value)
           
 String setProperty(String key, int value)
           
 String setProperty(String key, String value)
           
 String setPropertyIfNotExists(String key, String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_VALUE_FOR_KEY

public static int NO_VALUE_FOR_KEY

fileName

protected String fileName

stringProps

protected Properties stringProps

errorCodes

protected int[] errorCodes

errorKeys

protected String[] errorKeys

resource

protected boolean resource
Constructor Detail

HsqlProperties

public HsqlProperties()

HsqlProperties

public HsqlProperties(String name)

HsqlProperties

public HsqlProperties(String name,
                      boolean b)

HsqlProperties

public HsqlProperties(Properties props)
Method Detail

setFileName

public void setFileName(String name)

setProperty

public String setProperty(String key,
                          int value)

setProperty

public String setProperty(String key,
                          boolean value)

setProperty

public String setProperty(String key,
                          String value)

setPropertyIfNotExists

public String setPropertyIfNotExists(String key,
                                     String value)

getProperties

public Properties getProperties()

getProperty

public String getProperty(String key)

getProperty

public String getProperty(String key,
                          String defaultValue)

getIntegerProperty

public int getIntegerProperty(String key,
                              int defaultValue)

getIntegerProperty

public int getIntegerProperty(String key,
                              int defaultValue,
                              int minimum,
                              int maximum)

isPropertyTrue

public boolean isPropertyTrue(String key)

isPropertyTrue

public boolean isPropertyTrue(String key,
                              boolean defaultValue)

removeProperty

public void removeProperty(String key)

addProperties

public void addProperties(Properties props)

addProperties

public void addProperties(HsqlProperties props)

checkFileExists

public boolean checkFileExists()
                        throws IOException
Throws:
IOException

checkFileExists

public static boolean checkFileExists(String fileName,
                                      boolean resource,
                                      Class cla)
                               throws IOException
Throws:
IOException

load

public boolean load()
             throws Exception
Throws:
Exception

save

public void save()
          throws Exception
Saves the properties using JDK2 method if present, otherwise JDK1.

Throws:
Exception

argArrayToProps

public static HsqlProperties argArrayToProps(String[] arg,
                                             String type)
Creates and populates an HsqlProperties Object from the arguments array of a Main method. Properties are in the form of "-key value" pairs. Each key is prefixed with the type argument and a dot before being inserted into the properties Object.

"-?" is treated as a key with no value and not inserted.


delimitedArgPairsToProps

public static HsqlProperties delimitedArgPairsToProps(String s,
                                                      String pairsep,
                                                      String dlimiter,
                                                      String type)
Creates and populates a new HsqlProperties Object using a string such as "key1=value1;key2=value2"

The string that represents the = sign above is specified as pairsep and the one that represents the semicolon is specified as delimiter, allowing any string to be used for either.

Leading / trailing spaces around the keys and values are discarded.

The string is parsed by (1) subdividing into segments by delimiter (2) subdividing each segment in two by finding the first instance of the pairsep (3) trimming each pair of segments from step 2 and inserting into the properties object.

Each key is prefixed with the type argument and a dot before being inserted.

Any key without a value is added to the list of errors.


propertyNames

public Enumeration propertyNames()

isEmpty

public boolean isEmpty()

main

public static void main(String[] argv)


Copyright © 2001 - 2004 HSQL Development Group. All Rights Reserved.