Package gaiasky.util.properties
Class CommentedProperties
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Object,
Object>
The CommentedProperties class is an extension of java.util.Properties
to allow retention of comment lines and blank (whitespace only) lines
in the properties file.
Written for Java version 1.4
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionUse a Vector to keep a copy of lines containing a key, i.e.Use a Vector to keep a copy of lines that are a comment or 'blank'Fields inherited from class java.util.Properties
defaults
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a Property to the end of the CommentedProperties.void
Add a comment or blank line or comment to the end of the CommentedProperties.clone()
void
load
(InputStream inStream) Load properties from the specified InputStream.void
load
(InputStreamReader isr) Load properties from the specified InputStreamReader.void
store
(OutputStream out, String header) void
store
(OutputStream out, String header, String encoding) Write the properties to the specified OutputStream.void
Methods inherited from class java.util.Properties
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Field Details
-
lineData
Use a Vector to keep a copy of lines that are a comment or 'blank' -
keyData
Use a Vector to keep a copy of lines containing a key, i.e. they are a property.
-
-
Constructor Details
-
CommentedProperties
public CommentedProperties()
-
-
Method Details
-
load
Load properties from the specified InputStreamReader. Overload the load method in Properties so we can keep comment and blank lines.- Parameters:
isr
- The InputStreamReader to read.- Throws:
IOException
-
load
Load properties from the specified InputStream. Overload the load method in Properties so we can keep comment and blank lines.- Overrides:
load
in classProperties
- Parameters:
inStream
- The InputStream to read.- Throws:
IOException
-
store
- Overrides:
store
in classProperties
- Throws:
IOException
-
store
public void store(OutputStream out, String header, String encoding, Map<String, String> missing) throws IOException- Throws:
IOException
-
store
Write the properties to the specified OutputStream.Overloads the store method in Properties so we can put back comment and blank lines.
- Parameters:
out
- The OutputStream to write to.header
- Ignored, here for compatibility w/ Properties.encoding
- The encoding of the file- Throws:
IOException
- If the creation of the writer fails.
-
add
Add a Property to the end of the CommentedProperties.- Parameters:
keyString
- The Property key.value
- The value of this Property.
-
addLine
Add a comment or blank line or comment to the end of the CommentedProperties.- Parameters:
line
- The string to add to the end, make sure this is a comment or a 'whitespace' line.
-
clone
- Overrides:
clone
in classProperties
-