Class HsqlProperties
- java.lang.Object
-
- org.hsqldb.persist.HsqlProperties
-
- Direct Known Subclasses:
- HsqlDatabaseProperties, ServerProperties
public class HsqlProperties extends java.lang.ObjectWrapper for java.util.Properties to limit values to Specific types and allow saving and loading.- Since:
- 1.7.0
-
-
Field Summary
Fields Modifier and Type Field and Description static intANY_ERRORstatic intindexClassstatic intindexDefaultValuestatic intindexIsRangestatic intindexLimitstatic intindexNamestatic intindexRangeHighstatic intindexRangeLowstatic intindexTypestatic intindexValuesstatic intNO_VALUE_FOR_KEY
-
Constructor Summary
Constructors Constructor and Description HsqlProperties()HsqlProperties(HashMap meta, java.lang.String fileName, FileAccess accessor, boolean b)HsqlProperties(java.util.Properties props)HsqlProperties(java.lang.String fileName)HsqlProperties(java.lang.String fileName, java.lang.String fileExtension)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddProperties(HsqlProperties props)voidaddProperties(java.util.Properties props)static HsqlPropertiesargArrayToProps(java.lang.String[] arg, java.lang.String type)Creates and populates an HsqlProperties Object from the arguments array of a Main method.static HsqlPropertiesdelimitedArgPairsToProps(java.lang.String s, java.lang.String pairsep, java.lang.String dlimiter, java.lang.String type)Creates and populates a new HsqlProperties Object using a string such as "key1=value1;key2=value2".java.lang.String[]getErrorKeys()static intgetIntegerProperty(java.util.Properties props, java.lang.String key, int defaultValue)intgetIntegerProperty(java.lang.String key, int defaultValue)static java.lang.Object[]getMeta(java.lang.String name, int type, boolean defaultValue)static java.lang.Object[]getMeta(java.lang.String name, int type, int defaultValue, int[] values)static java.lang.Object[]getMeta(java.lang.String name, int type, int defaultValue, int rangeLow, int rangeHigh)static java.lang.Object[]getMeta(java.lang.String name, int type, java.lang.String defaultValue)java.util.PropertiesgetProperties()java.lang.StringgetProperty(java.lang.String key)java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)booleanisEmpty()booleanisPropertyTrue(java.lang.String key)booleanisPropertyTrue(java.lang.String key, boolean defaultValue)booleanload()booleanpropertiesFileExists()java.util.EnumerationpropertyNames()voidremoveProperty(java.lang.String key)voidsave()Saves the properties.voidsave(java.lang.String fileString)Saves the properties using JDK2 method if present, otherwise JDK1.voidsetFileName(java.lang.String name)java.lang.StringsetProperty(java.lang.String key, boolean value)java.lang.StringsetProperty(java.lang.String key, int value)java.lang.StringsetProperty(java.lang.String key, java.lang.String value)java.lang.StringsetPropertyIfNotExists(java.lang.String key, java.lang.String value)java.lang.StringtoString()voidvalidate()booleanvalidateProperty(java.lang.String name, int number)static java.lang.StringvalidateProperty(java.lang.String key, java.lang.String value, java.lang.Object[] meta)Perfoms any range checking for property and return an error message
-
-
-
Field Detail
-
ANY_ERROR
public static final int ANY_ERROR
- See Also:
- Constant Field Values
-
NO_VALUE_FOR_KEY
public static final int NO_VALUE_FOR_KEY
- See Also:
- Constant Field Values
-
indexName
public static final int indexName
- See Also:
- Constant Field Values
-
indexType
public static final int indexType
- See Also:
- Constant Field Values
-
indexClass
public static final int indexClass
- See Also:
- Constant Field Values
-
indexIsRange
public static final int indexIsRange
- See Also:
- Constant Field Values
-
indexDefaultValue
public static final int indexDefaultValue
- See Also:
- Constant Field Values
-
indexRangeLow
public static final int indexRangeLow
- See Also:
- Constant Field Values
-
indexRangeHigh
public static final int indexRangeHigh
- See Also:
- Constant Field Values
-
indexValues
public static final int indexValues
- See Also:
- Constant Field Values
-
indexLimit
public static final int indexLimit
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HsqlProperties
public HsqlProperties()
-
HsqlProperties
public HsqlProperties(java.lang.String fileName)
-
HsqlProperties
public HsqlProperties(java.lang.String fileName, java.lang.String fileExtension)
-
HsqlProperties
public HsqlProperties(HashMap meta, java.lang.String fileName, FileAccess accessor, boolean b)
-
HsqlProperties
public HsqlProperties(java.util.Properties props)
-
-
Method Detail
-
setFileName
public void setFileName(java.lang.String name)
-
setProperty
public java.lang.String setProperty(java.lang.String key, int value)
-
setProperty
public java.lang.String setProperty(java.lang.String key, boolean value)
-
setProperty
public java.lang.String setProperty(java.lang.String key, java.lang.String value)
-
setPropertyIfNotExists
public java.lang.String setPropertyIfNotExists(java.lang.String key, java.lang.String value)
-
getProperties
public java.util.Properties getProperties()
-
getProperty
public java.lang.String getProperty(java.lang.String key)
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
-
getIntegerProperty
public int getIntegerProperty(java.lang.String key, int defaultValue)
-
getIntegerProperty
public static int getIntegerProperty(java.util.Properties props, java.lang.String key, int defaultValue)
-
isPropertyTrue
public boolean isPropertyTrue(java.lang.String key)
-
isPropertyTrue
public boolean isPropertyTrue(java.lang.String key, boolean defaultValue)
-
removeProperty
public void removeProperty(java.lang.String key)
-
addProperties
public void addProperties(java.util.Properties props)
-
addProperties
public void addProperties(HsqlProperties props)
-
propertiesFileExists
public boolean propertiesFileExists()
-
load
public boolean load() throws java.lang.Exception- Throws:
java.lang.Exception
-
save
public void save() throws java.lang.ExceptionSaves the properties.- Throws:
java.lang.Exception
-
save
public void save(java.lang.String fileString) throws java.lang.ExceptionSaves the properties using JDK2 method if present, otherwise JDK1.- Throws:
java.lang.Exception
-
argArrayToProps
public static HsqlProperties argArrayToProps(java.lang.String[] arg, java.lang.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.
-
delimitedArgPairsToProps
public static HsqlProperties delimitedArgPairsToProps(java.lang.String s, java.lang.String pairsep, java.lang.String dlimiter, java.lang.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 java.util.Enumeration propertyNames()
-
isEmpty
public boolean isEmpty()
-
getErrorKeys
public java.lang.String[] getErrorKeys()
-
validate
public void validate()
-
getMeta
public static java.lang.Object[] getMeta(java.lang.String name, int type, java.lang.String defaultValue)
-
getMeta
public static java.lang.Object[] getMeta(java.lang.String name, int type, boolean defaultValue)
-
getMeta
public static java.lang.Object[] getMeta(java.lang.String name, int type, int defaultValue, int[] values)
-
getMeta
public static java.lang.Object[] getMeta(java.lang.String name, int type, int defaultValue, int rangeLow, int rangeHigh)
-
validateProperty
public static java.lang.String validateProperty(java.lang.String key, java.lang.String value, java.lang.Object[] meta)Perfoms any range checking for property and return an error message
-
validateProperty
public boolean validateProperty(java.lang.String name, int number)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG