Top Description Inners Fields Constructors Methods
org.hsqldb.persist

public Class HsqlProperties

extends Object
Class Inheritance
Known Direct Subclasses
org.hsqldb.server.ServerProperties, org.hsqldb.persist.HsqlDatabaseProperties
Imports
java.io.FileNotFoundException, .InputStream, .OutputStream, java.util.Collections, .Enumeration, .List, .Properties, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.lib.ArrayUtil, .FileAccess, .FileUtil, org.hsqldb.map.ValuePool

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

Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
1.7.0
Version
2.7.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
public static final int
protected int[]
protected String[]
protected FileAccess
protected String
protected String
public static final int
protected Properties

Constructor Summary

AccessConstructor and Description
public
public
public
HsqlProperties(String fileName, String fileExtension)

public
HsqlProperties(String fileName, FileAccess accessor, boolean b)

public

Method Summary

Modifier and TypeMethod and Description
protected void
addError(int code, String key)

Adds the error code and the key to the list of errors.

public void
public void
public static HsqlProperties
argArrayToProps(String[] arg, String type)

Creates and populates an HsqlProperties Object from the arguments array of a Main method.

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".

public String[]
public int
getIntegerProperty(String key, int defaultValue)

public static int
getIntegerProperty(Properties props, String key, int defaultValue)

public Properties
public String
public String
getProperty(String key, String defaultValue)

public boolean
public boolean
public boolean
isPropertyTrue(String key, boolean defaultValue)

public boolean
load()

public static HsqlProperties.PropertyMeta
newMeta(String name, int type, long defaultVal)

public static HsqlProperties.PropertyMeta
newMeta(String name, int type, String defaultValue)

public static HsqlProperties.PropertyMeta
newMeta(String name, int type, String defaultValue, String[] options)

public static HsqlProperties.PropertyMeta
newMeta(String name, int type, boolean defaultValue)

public static HsqlProperties.PropertyMeta
newMeta(String name, int type, int defaultValue, int[] values)

public static HsqlProperties.PropertyMeta
newMeta(String name, int type, int defaultValue, int rangeLow, int rangeHigh)

public boolean
public Enumeration<E>
public void
public void
save()

Saves the properties.

public void
save(String fileString)

Saves the properties

public void
public String
setProperty(String key, int value)

public String
setProperty(String key, boolean value)

public String
public String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
public static String
validateProperty(String key, String value, HsqlProperties.PropertyMeta meta)

Performs any range checking for property and return an error message

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ANY_ERRORback to summary
public static final int ANY_ERROR
errorCodesback to summary
protected int[] errorCodes
errorKeysback to summary
protected String[] errorKeys
faback to summary
protected FileAccess fa
fileExtensionback to summary
protected String fileExtension
fileNameback to summary
protected String fileName
NO_VALUE_FOR_KEYback to summary
public static final int NO_VALUE_FOR_KEY
stringPropsback to summary
protected Properties stringProps

Constructor Detail

HsqlPropertiesback to summary
public HsqlProperties()
HsqlPropertiesback to summary
public HsqlProperties(String fileName)
HsqlPropertiesback to summary
public HsqlProperties(String fileName, String fileExtension)
HsqlPropertiesback to summary
public HsqlProperties(String fileName, FileAccess accessor, boolean b)
HsqlPropertiesback to summary
public HsqlProperties(Properties props)

Method Detail

addErrorback to summary
protected void addError(int code, String key)

Adds the error code and the key to the list of errors. This list is populated during construction or addition of elements and is used outside this class to act upon the errors.

addPropertiesback to summary
public void addProperties(Properties props)
addPropertiesback to summary
public void addProperties(HsqlProperties props)
argArrayToPropsback to summary
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.

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

delimitedArgPairsToPropsback to summary
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.

getErrorKeysback to summary
public String[] getErrorKeys()
getIntegerPropertyback to summary
public int getIntegerProperty(String key, int defaultValue)
getIntegerPropertyback to summary
public static int getIntegerProperty(Properties props, String key, int defaultValue)
getPropertiesback to summary
public Properties getProperties()
getPropertyback to summary
public String getProperty(String key)
getPropertyback to summary
public String getProperty(String key, String defaultValue)
isEmptyback to summary
public boolean isEmpty()
isPropertyTrueback to summary
public boolean isPropertyTrue(String key)
isPropertyTrueback to summary
public boolean isPropertyTrue(String key, boolean defaultValue)
loadback to summary
public boolean load() throws Exception
newMetaback to summary
public static HsqlProperties.PropertyMeta newMeta(String name, int type, long defaultVal)
newMetaback to summary
public static HsqlProperties.PropertyMeta newMeta(String name, int type, String defaultValue)
newMetaback to summary
public static HsqlProperties.PropertyMeta newMeta(String name, int type, String defaultValue, String[] options)
newMetaback to summary
public static HsqlProperties.PropertyMeta newMeta(String name, int type, boolean defaultValue)
newMetaback to summary
public static HsqlProperties.PropertyMeta newMeta(String name, int type, int defaultValue, int[] values)
newMetaback to summary
public static HsqlProperties.PropertyMeta newMeta(String name, int type, int defaultValue, int rangeLow, int rangeHigh)
propertiesFileExistsback to summary
public boolean propertiesFileExists()
propertyNamesback to summary
public Enumeration<E> propertyNames()
removePropertyback to summary
public void removeProperty(String key)
saveback to summary
public void save() throws Exception

Saves the properties.

saveback to summary
public void save(String fileString) throws Exception

Saves the properties

setFileNameback to summary
public void setFileName(String name)
setPropertyback to summary
public String setProperty(String key, int value)
setPropertyback to summary
public String setProperty(String key, boolean value)
setPropertyback to summary
public String setProperty(String key, String value)
setPropertyIfNotExistsback to summary
public String setPropertyIfNotExists(String key, String value)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

validateback to summary
public void validate()
validatePropertyback to summary
public static String validateProperty(String key, String value, HsqlProperties.PropertyMeta meta)

Performs any range checking for property and return an error message

org.hsqldb.persist back to summary

public Class HsqlProperties.PropertyMeta

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public String
public Object
public boolean
public String
public String[]
public int
public int
public int
public int[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

propClassback to summary
public String propClass
propDefaultValueback to summary
public Object propDefaultValue
propIsRangeback to summary
public boolean propIsRange
propNameback to summary
public String propName
propOptionsback to summary
public String[] propOptions
propRangeHighback to summary
public int propRangeHigh
propRangeLowback to summary
public int propRangeLow
propTypeback to summary
public int propType
propValuesback to summary
public int[] propValues

Constructor Detail

PropertyMetaback to summary
public PropertyMeta()