Package adams.core
Class Properties
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable<Object,Object>
-
- java.util.Properties
-
- adams.core.Properties
-
- All Implemented Interfaces:
CloneHandler<Properties>,Mergeable<Properties>,Serializable,Cloneable,Comparable<Properties>,Map<Object,Object>
public class Properties extends Properties implements Comparable<Properties>, Mergeable<Properties>, CloneHandler<Properties>
Enhanced java.util.Properties class.Date types are stores as follows:
- time:
FORMAT_TIME - date:
FORMAT_DATE - date/time:
FORMAT_DATETIME
Colors are stored as hex string, i.e., "#RRGGBB" with all three values as hex values. The following string representations of colors are supported as well (case-insensitive):
- black
- blue
- cyan
- darkgray
- darkgrey
- gray
- grey
- green
- lightgray
- lightgrey
- magenta
- orange
- pink
- red
- white
- yellow
Theread(String)andread(String, List)methods also look for platform-specific properties files using platform-specific extensions:EXT_LINUX,EXT_ANDROID,EXT_MAC,EXT_WINDOWS.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOMMENTthe comment.static StringEXT_ANDROIDthe android extension (incl dot).static StringEXT_DEFAULTthe default extension (incl dot).static StringEXT_LINUXthe linux extension (incl dot).static StringEXT_MACthe mac extension (incl dot).static StringEXT_WINDOWSthe windows extension (incl dot).static StringFORMAT_DATEthe date format.static StringFORMAT_DATETIMEthe date/time format.static StringFORMAT_TIMEthe time format.-
Fields inherited from class java.util.Properties
defaults
-
-
Constructor Summary
Constructors Constructor Description Properties()default constructor.Properties(Properties defaults)Creates an empty property list with the specified defaults.Properties(Properties defaults)Creates an empty property list with the specified defaults.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Properties props)Adds the key-value pairs stored in the specified properties to itself.voidadd(Properties props, String prefix)Adds the key-value pairs stored in the specified properties to itself.Propertiescollapse()Collapses all the inherited and current properties into a single Properties object and returns it.protected StringcollapsePlaceHolders(String s)Collapses the paths to placeholders in the string.intcompareTo(Properties o)Compares this object with the specified object for order.booleanequals(Object obj)Indicates whether some other object is "equal to" this one.protected StringexpandPlaceHolders(String s)Expands the placeholders in the string.protected StringfixDir(String dir)Ensures that the directory ends with a separator, e.g. "/".static PropertiesfromComment(String comments)Re-generates a properties object that was commented out.BooleangetBoolean(String key)Returns the boolean value associated with the key, or null if not found or not parseable.BooleangetBoolean(String key, Boolean defValue)Returns the boolean value associated with the key, or the default value if not found or not parseable.PropertiesgetClone()Returns a clone of the object.ColorgetColor(String key)Returns the color associated with the string.ColorgetColor(String key, Color defValue)Returns the color associated with the string.DategetDate(String key)Returns the date value associated with the key, or null if not found or not parseable.DategetDate(String key, Date defValue)Returns the date value associated with the key, or the default value if not found or not parseable.DateTimegetDateTime(String key)Returns the date/time value associated with the key, or null if not found or not parseable.DateTimegetDateTime(String key, DateTime defValue)Returns the date/time value associated with the key, or the default value if not found or not parseable.DoublegetDouble(String key)Returns the double value associated with the key, or null if not found or not parseable.DoublegetDouble(String key, Double defValue)Returns the double value associated with the key, or the default value if not found or not parseable.FontgetFont(String key)Returns the font associated with the string.FontgetFont(String key, Font defValue)Returns the font associated with the string.IntegergetInteger(String key)Returns the integer value associated with the key, or null if not found or not parseable.IntegergetInteger(String key, Integer defValue)Returns the integer value associated with the key, or the default value if not found or not parseable.LonggetLong(String key)Returns the long value associated with the key, or null if not found or not parseable.LonggetLong(String key, Long defValue)Returns the long value associated with the key, or the default value if not found or not parseable.<T> TgetObject(String key, Class<T> cls)Returns the object stored as commandline.<T> TgetObject(String key, Class<T> cls, T defValue)Returns the object stored as commandline.BasePasswordgetPassword(String key)Returns the password associated with the string.BasePasswordgetPassword(String key, BasePassword defValue)Returns the password associated with the string.StringgetPath(String key)Returns the path value associated with the key, or null if not found.StringgetPath(String key, String defValue)Returns the path value associated with the key, or the default value if not found.static StringgetPlatformDependentExtension()Determines the platform-specific extension.TimegetTime(String key)Returns the time value associated with the key, or null if not found or not parseable.TimegetTime(String key, Time defValue)Returns the time value associated with the key, or the default value if not found or not parseable.booleanhasKey(String key)Checks whether the given property exists.protected voidinitialize()Initializes member variables.Set<String>keySetAll()Returns a set of all the keys.Set<String>keySetAll(BaseRegExp regexp)Returns a set of all the keys that match the specified regular expression.Set<String>keySetAll(String prefix)Returns a set of all the keys that have the specified prefix.booleanload(String filename)Loads the properties from the given file - not to be confused withread(String).static booleanloadFromResource(Properties props, String resourceName)Loads the properties with the given name as a classpath resource.protected static PropertiesloadURLs(Properties parent, String path)Loads the properties from URLs associated with the path.static voidmain(String[] args)Only for testing.voidmergeWith(Properties other)Merges its own data with the one provided by the specified object.protected static booleanpropertiesExist(String path)Checks whether the properties file exists.Enumeration<String>propertyNames(String regExp)Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list, as long as the key matches the provided prefix.static Propertiesread(String name)Reads properties that inherit from several locations.static Propertiesread(String name, List<String> dirs)Reads properties that inherit from several locations.voidremoveKey(String key)Removes the entry with the specified key, if available.voidremoveKeyRecursive(String key)Removes the entry with the specified key, if available.voidremoveKeys(String regexp)Removes the entries that match the regular expression.voidremoveKeysRecursive(String regexp)Removes the entries that match the specified regular expression.voidremoveWithPrefix(String prefix)Removes all properties that share this prefix.voidremoveWithSuffix(String suffix)Removes all properties that share this suffix.booleansave(String filename)Saves the properties to the given file (unsorted).booleansave(String filename, boolean sorted)Saves the properties to the given file.booleansave(String filename, String comment)Saves the properties to the given file (unsorted).booleansave(String filename, String comment, boolean sorted)Saves the properties to the given file.voidsetBoolean(String key, Boolean value)Sets the boolean value.voidsetColor(String key, Color value)Stores the color as hex string under the specified property key.voidsetDate(String key, Date value)Sets the date value.voidsetDateTime(String key, DateTime value)Sets the date/time value.voidsetDefaults(Properties value)Sets the default properties.voidsetDouble(String key, Double value)Sets the double value.voidsetFont(String key, Font value)Stores the font under the specified property key.voidsetInteger(String key, Integer value)Sets the integer value.voidsetLong(String key, Long value)Sets the long value.voidsetObject(String key, Object obj)Stores the object as commandline.voidsetPassword(String key, BasePassword value)Stores the password as 64-bit encoded string under the specified property key.voidsetPath(String key, String value)Sets the path value.voidsetTime(String key, Time value)Sets the time value.Propertiessubset(BaseRegExp regexp)Returns a subset of all the keys that match the given regular expression.Propertiessubset(String prefix)Returns a subset of all the keys that match the given prefix.StringtoComment()Outputs the properties as they would be written to a file (unsorted).StringtoComment(boolean sorted)Outputs the properties as they would be written to a file.StringtoString()Outputs the properties as they would be written to a file (unsorted).StringtoString(boolean sorted)Outputs the properties as they would be written to a file.StringtoString(String comment)Outputs the properties as they would be written to a file (unsorted).StringtoString(String comment, boolean sorted)Outputs the properties as they would be written to a file.StringtoStringSimple()Outputs a single line representation of the full properties stored in the Properties object (and its defaults).-
Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, values
-
-
-
-
Field Detail
-
COMMENT
public static final String COMMENT
the comment.- See Also:
- Constant Field Values
-
FORMAT_TIME
public static final String FORMAT_TIME
the time format.- See Also:
- Constant Field Values
-
FORMAT_DATE
public static final String FORMAT_DATE
the date format.- See Also:
- Constant Field Values
-
FORMAT_DATETIME
public static final String FORMAT_DATETIME
the date/time format.- See Also:
- Constant Field Values
-
EXT_DEFAULT
public static final String EXT_DEFAULT
the default extension (incl dot).- See Also:
- Constant Field Values
-
EXT_LINUX
public static final String EXT_LINUX
the linux extension (incl dot).- See Also:
- Constant Field Values
-
EXT_ANDROID
public static final String EXT_ANDROID
the android extension (incl dot).- See Also:
- Constant Field Values
-
EXT_MAC
public static final String EXT_MAC
the mac extension (incl dot).- See Also:
- Constant Field Values
-
EXT_WINDOWS
public static final String EXT_WINDOWS
the windows extension (incl dot).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Properties
public Properties()
default constructor.
-
Properties
public Properties(Properties defaults)
Creates an empty property list with the specified defaults.- Parameters:
defaults- the default properties
-
Properties
public Properties(Properties defaults)
Creates an empty property list with the specified defaults.- Parameters:
defaults- the default properties
-
-
Method Detail
-
initialize
protected void initialize()
Initializes member variables.
-
setDefaults
public void setDefaults(Properties value)
Sets the default properties.- Parameters:
value- the default properties
-
getClone
public Properties getClone()
Returns a clone of the object.- Specified by:
getClonein interfaceCloneHandler<Properties>- Returns:
- the clone
-
read
public static Properties read(String name) throws Exception
Reads properties that inherit from several locations. Properties are first defined in the system resource location (i.e. in the CLASSPATH). These default properties must exist. Not to be confused withload(String). Also looks for environment variables with a semi-colon separated list of key=value pairs to override the values loaded from the .props file(s). E.g., for "adams/core/io/FileUtils.props" the environment variables "adams_core_io_FileUtils" or "ADAMS_CORE_IO_FILEUTILS" can be used.- Parameters:
name- the location of the resource that should be loaded. e.g.: "adams/gui/Something.props".- Returns:
- the Properties
- Throws:
Exception- if no default properties are defined, or if an error occurs reading the properties files.- See Also:
load(String)
-
getPlatformDependentExtension
public static String getPlatformDependentExtension()
Determines the platform-specific extension.- Returns:
- the extension (incl dot), null if failed to determine
-
loadURLs
protected static Properties loadURLs(Properties parent, String path)
Loads the properties from URLs associated with the path.- Parameters:
parent- the parent Properties object, null if first callpath- the path of the properties to load- Returns:
- the properties
-
propertiesExist
protected static boolean propertiesExist(String path)
Checks whether the properties file exists.- Parameters:
path- the file name- Returns:
- true if it exists
-
read
public static Properties read(String name, List<String> dirs) throws Exception
Reads properties that inherit from several locations. Properties are first defined in the system resource location (i.e. in the CLASSPATH). These default properties must exist. Not to be confused withload(String). Also looks for environment variables with a semi-colon separated list of key=value pairs to override the values loaded from the .props file(s). E.g., for "adams/core/io/FileUtils.props" the environment variables "adams_core_io_FileUtils" or "ADAMS_CORE_IO_FILEUTILS" can be used.- Parameters:
name- the location of the resource that should be loaded. e.g.: "adams/gui/Something.props".dirs- the directories to search for this properties file.- Returns:
- the Properties
- Throws:
Exception- if no default properties are defined, or if an error occurs reading the properties files.- See Also:
load(String)
-
expandPlaceHolders
protected String expandPlaceHolders(String s)
Expands the placeholders in the string. Supported placeholders:%t - the temp directory %h - the user's home directory (also $HOME and %USERHOME%) %p - the project's home directory (if such is available) %c - the current directory %% - gets replaced by a single percentage sign
- Parameters:
s- the string to process- Returns:
- the processed string
-
fixDir
protected String fixDir(String dir)
Ensures that the directory ends with a separator, e.g. "/".- Parameters:
dir- the directory to fix- Returns:
- the fixed directory
-
collapsePlaceHolders
protected String collapsePlaceHolders(String s)
Collapses the paths to placeholders in the string. Supported placeholders (from highest precedence to lowest):%c - the current directory %p - the project's home directory (if such is available) %h - the user's home directory %t - the temp directory
- Parameters:
s- the string to process- Returns:
- the processed string
-
keySetAll
public Set<String> keySetAll()
Returns a set of all the keys.- Returns:
- a set over all the keys
-
keySetAll
public Set<String> keySetAll(String prefix)
Returns a set of all the keys that have the specified prefix.- Parameters:
prefix- the prefix that the keys must have- Returns:
- a set over all the keys
-
keySetAll
public Set<String> keySetAll(BaseRegExp regexp)
Returns a set of all the keys that match the specified regular expression.- Parameters:
regexp- the expression to match the keys against- Returns:
- a set over all the keys
-
propertyNames
public Enumeration<String> propertyNames(String regExp)
Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list, as long as the key matches the provided prefix.- Parameters:
regExp- the regular expression that the property keys must match- Returns:
- an enumeration of all the keys in this property list, including the keys in the default property list, that match the prefix.
-
load
public boolean load(String filename)
Loads the properties from the given file - not to be confused withread(String).- Parameters:
filename- the file to load the properties from- Returns:
- true if successfully loaded
- See Also:
read(String)
-
save
public boolean save(String filename)
Saves the properties to the given file (unsorted).- Parameters:
filename- the file to save the properties to- Returns:
- true if successfully written
-
save
public boolean save(String filename, boolean sorted)
Saves the properties to the given file.- Parameters:
filename- the file to save the properties tosorted- whether to sort the content- Returns:
- true if successfully written
-
save
public boolean save(String filename, String comment)
Saves the properties to the given file (unsorted).- Parameters:
filename- the file to save the properties tocomment- the comment to use, can be null- Returns:
- true if successfully written
-
save
public boolean save(String filename, String comment, boolean sorted)
Saves the properties to the given file.- Parameters:
filename- the file to save the properties tocomment- the comment to use, can be nullsorted- whether to sort the content- Returns:
- true if successfully written
-
toStringSimple
public String toStringSimple()
Outputs a single line representation of the full properties stored in the Properties object (and its defaults).- Returns:
- the single-line representation
-
toString
public String toString()
Outputs the properties as they would be written to a file (unsorted).- Overrides:
toStringin classProperties- Returns:
- the generated output or null in case of an error
-
toString
public String toString(String comment)
Outputs the properties as they would be written to a file (unsorted).- Parameters:
comment- the comment to output- Returns:
- the generated output or null in case of an error
-
toString
public String toString(boolean sorted)
Outputs the properties as they would be written to a file.- Parameters:
sorted- whether to store the output- Returns:
- the generated output or null in case of an error
-
toString
public String toString(String comment, boolean sorted)
Outputs the properties as they would be written to a file.- Parameters:
comment- the comment to outputsorted- whether to store the output- Returns:
- the generated output or null in case of an error
-
toComment
public String toComment()
Outputs the properties as they would be written to a file (unsorted). In addition, all lines will be output as comment:# key1=value1 # key2=value2 # ...
- Returns:
- the generated output or null in case of an error
- See Also:
COMMENT
-
toComment
public String toComment(boolean sorted)
Outputs the properties as they would be written to a file. In addition, all lines will be output as comment:# key1=value1 # key2=value2 # ...
- Parameters:
sorted- whether to sort the output- Returns:
- the generated output or null in case of an error
- See Also:
COMMENT
-
add
public void add(Properties props)
Adds the key-value pairs stored in the specified properties to itself. The property names are not prefixed. Already existing properties will be overwritten.- Parameters:
props- the properties to add
-
add
public void add(Properties props, String prefix)
Adds the key-value pairs stored in the specified properties to itself. Already existing properties will be overwritten.- Parameters:
props- the properties to addprefix- the prefix for the property names, use null to ignore
-
subset
public Properties subset(String prefix)
Returns a subset of all the keys that match the given prefix.- Parameters:
prefix- the prefix for the property names- Returns:
- the subset
-
subset
public Properties subset(BaseRegExp regexp)
Returns a subset of all the keys that match the given regular expression.- Parameters:
regexp- the regular expression- Returns:
- the subset
-
removeKey
public void removeKey(String key)
Removes the entry with the specified key, if available.- Parameters:
key- the key to remove
-
removeKeyRecursive
public void removeKeyRecursive(String key)
Removes the entry with the specified key, if available. Processes the defaults recursively.- Parameters:
key- the key to remove
-
removeKeys
public void removeKeys(String regexp)
Removes the entries that match the regular expression.- Parameters:
regexp- the regular expression that the keys must match
-
removeKeysRecursive
public void removeKeysRecursive(String regexp)
Removes the entries that match the specified regular expression. Processes the defaults recursively.- Parameters:
regexp- the regular expression that the keys must match
-
hasKey
public boolean hasKey(String key)
Checks whether the given property exists.- Parameters:
key- the property to check- Returns:
- true if the property exists
-
setInteger
public void setInteger(String key, Integer value)
Sets the integer value.- Parameters:
key- the property to store the value undervalue- the value to store
-
getInteger
public Integer getInteger(String key)
Returns the integer value associated with the key, or null if not found or not parseable.- Parameters:
key- the property to look for- Returns:
- the value for the key
-
getInteger
public Integer getInteger(String key, Integer defValue)
Returns the integer value associated with the key, or the default value if not found or not parseable.- Parameters:
key- the property to look fordefValue- the default value in case key is not found or value cannot be parsed- Returns:
- the value for the key
-
setLong
public void setLong(String key, Long value)
Sets the long value.- Parameters:
key- the property to store the value undervalue- the value to store
-
getLong
public Long getLong(String key)
Returns the long value associated with the key, or null if not found or not parseable.- Parameters:
key- the property to look for- Returns:
- the value for the key
-
getLong
public Long getLong(String key, Long defValue)
Returns the long value associated with the key, or the default value if not found or not parseable.- Parameters:
key- the property to look fordefValue- the default value in case key is not found or value cannot be parsed- Returns:
- the value for the key
-
setDouble
public void setDouble(String key, Double value)
Sets the double value.- Parameters:
key- the property to store the value undervalue- the value to store
-
getDouble
public Double getDouble(String key)
Returns the double value associated with the key, or null if not found or not parseable.- Parameters:
key- the property to look for- Returns:
- the value for the key
-
getDouble
public Double getDouble(String key, Double defValue)
Returns the double value associated with the key, or the default value if not found or not parseable.- Parameters:
key- the property to look fordefValue- the default value in case key is not found or value cannot be parsed- Returns:
- the value for the key
-
setBoolean
public void setBoolean(String key, Boolean value)
Sets the boolean value.- Parameters:
key- the property to store the value undervalue- the value to store
-
getBoolean
public Boolean getBoolean(String key)
Returns the boolean value associated with the key, or null if not found or not parseable.- Parameters:
key- the property to look for- Returns:
- the value for the key
-
getBoolean
public Boolean getBoolean(String key, Boolean defValue)
Returns the boolean value associated with the key, or the default value if not found or not parseable.- Parameters:
key- the property to look fordefValue- the default value in case key is not found or value cannot be parsed- Returns:
- the value for the key
-
setTime
public void setTime(String key, Time value)
Sets the time value.- Parameters:
key- the property to store the value undervalue- the value to store
-
getTime
public Time getTime(String key)
Returns the time value associated with the key, or null if not found or not parseable.- Parameters:
key- the property to look for- Returns:
- the value for the key
-
getTime
public Time getTime(String key, Time defValue)
Returns the time value associated with the key, or the default value if not found or not parseable.- Parameters:
key- the property to look fordefValue- the default value in case key is not found or value cannot be parsed- Returns:
- the value for the key
-
setDate
public void setDate(String key, Date value)
Sets the date value.- Parameters:
key- the property to store the value undervalue- the value to store
-
getDate
public Date getDate(String key)
Returns the date value associated with the key, or null if not found or not parseable.- Parameters:
key- the property to look for- Returns:
- the value for the key
-
getDate
public Date getDate(String key, Date defValue)
Returns the date value associated with the key, or the default value if not found or not parseable.- Parameters:
key- the property to look fordefValue- the default value in case key is not found or value cannot be parsed- Returns:
- the value for the key
-
setDateTime
public void setDateTime(String key, DateTime value)
Sets the date/time value.- Parameters:
key- the property to store the value undervalue- the value to store
-
getDateTime
public DateTime getDateTime(String key)
Returns the date/time value associated with the key, or null if not found or not parseable.- Parameters:
key- the property to look for- Returns:
- the value for the key
-
getDateTime
public DateTime getDateTime(String key, DateTime defValue)
Returns the date/time value associated with the key, or the default value if not found or not parseable.- Parameters:
key- the property to look fordefValue- the default value in case key is not found or value cannot be parsed- Returns:
- the value for the key
-
setPath
public void setPath(String key, String value)
Sets the path value.- Parameters:
key- the property to store the value undervalue- the value to store- See Also:
collapsePlaceHolders(String)
-
getPath
public String getPath(String key)
Returns the path value associated with the key, or null if not found.- Parameters:
key- the property to look for- Returns:
- the value for the key
- See Also:
expandPlaceHolders(String)
-
getPath
public String getPath(String key, String defValue)
Returns the path value associated with the key, or the default value if not found.- Parameters:
key- the property to look fordefValue- the default value in case key is not found- Returns:
- the value for the key
- See Also:
expandPlaceHolders(String)
-
getColor
public Color getColor(String key)
Returns the color associated with the string.- Parameters:
key- the property to look for- Returns:
- the value or null if not found
-
getColor
public Color getColor(String key, Color defValue)
Returns the color associated with the string.- Parameters:
key- the property to look fordefValue- the default value- Returns:
- the value or defValue if not found
-
setColor
public void setColor(String key, Color value)
Stores the color as hex string under the specified property key.- Parameters:
key- the property to store the color undervalue- the color to store
-
getPassword
public BasePassword getPassword(String key)
Returns the password associated with the string.- Parameters:
key- the property to look for- Returns:
- the value or null if not found
-
getPassword
public BasePassword getPassword(String key, BasePassword defValue)
Returns the password associated with the string.- Parameters:
key- the property to look fordefValue- the default value- Returns:
- the value or defValue if not found
-
setPassword
public void setPassword(String key, BasePassword value)
Stores the password as 64-bit encoded string under the specified property key.- Parameters:
key- the property to store the password undervalue- the password to store
-
getFont
public Font getFont(String key)
Returns the font associated with the string.- Parameters:
key- the property to look for- Returns:
- the value or null if not found
-
getFont
public Font getFont(String key, Font defValue)
Returns the font associated with the string.- Parameters:
key- the property to look fordefValue- the default value- Returns:
- the value or defValue if not found
-
setFont
public void setFont(String key, Font value)
Stores the font under the specified property key.- Parameters:
key- the property to store the font undervalue- the font to store
-
setObject
public void setObject(String key, Object obj)
Stores the object as commandline.- Parameters:
key- the key to store the object underobj- the object to store
-
getObject
public <T> T getObject(String key, Class<T> cls)
Returns the object stored as commandline.- Type Parameters:
T- the type of the object- Parameters:
key- the key with the commandlinecls- the type of the object- Returns:
- the object, null if failed to instantiate
-
getObject
public <T> T getObject(String key, Class<T> cls, T defValue)
Returns the object stored as commandline.- Type Parameters:
T- the type of the object- Parameters:
key- the key with the commandlinecls- the type of the objectdefValue- the default value- Returns:
- the object, null if failed to instantiate
-
mergeWith
public void mergeWith(Properties other)
Merges its own data with the one provided by the specified object.- Specified by:
mergeWithin interfaceMergeable<Properties>- Parameters:
other- the object to merge with
-
removeWithPrefix
public void removeWithPrefix(String prefix)
Removes all properties that share this prefix.- Parameters:
prefix- the prefix to look for
-
removeWithSuffix
public void removeWithSuffix(String suffix)
Removes all properties that share this suffix.- Parameters:
suffix- the suffix to look for
-
collapse
public Properties collapse()
Collapses all the inherited and current properties into a single Properties object and returns it.- Returns:
- the collapsed version of this Properties object
-
compareTo
public int compareTo(Properties o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
compareToin interfaceComparable<Properties>- Parameters:
o- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
-
fromComment
public static Properties fromComment(String comments)
Re-generates a properties object that was commented out.- Parameters:
comments- the commented out properties content- Returns:
- the properties object, or null in case of an error
- See Also:
toComment()
-
loadFromResource
public static boolean loadFromResource(Properties props, String resourceName)
Loads the properties with the given name as a classpath resource.- Parameters:
resourceName- the name of the props file on the classpath- Returns:
- true if successful
-
-