public class PropertiesConfigurationFile extends AbstractConfigurationFile
setCharsetName. If a value of null is used for
the charset name, the platform default will be used. Otherwise, the
charset name specified will be used.Properties| Modifier and Type | Field and Description |
|---|---|
static String |
ISO_8859_1 |
| Constructor and Description |
|---|
PropertiesConfigurationFile()
Constructor for PropertiesConfigurationFile with encoding Unicode turned
off and allowing multiple values per key turned off
|
| Modifier and Type | Method and Description |
|---|---|
void |
addComment(String comment)
Adds a comment
|
void |
addComment(String commentStartToken,
String comment)
Adds a comment
|
void |
addCommentStartToken(String commentStartToken)
Adds a comment start token
|
void |
addProperty(PropertyEntry property)
Adds a property to the list.
|
void |
addProperty(String key,
String value)
Adds a property to the list.
|
boolean |
allowsEntryType(AbstractEntry entry)
Determines if an entry type is allowed in this configuration File
|
void |
commentProperty(String commentStartToken,
PropertyEntry property) |
void |
commentProperty(String commentStartToken,
String key) |
void |
deleteProperty(PropertyEntry property)
Deletes a property entry
|
void |
deleteProperty(String key)
Deletes all the property values associated with this key
|
boolean |
getAllowMultipleValuesPerKey()
Gets whether to allow multiple values per key
|
String |
getCharsetName()
Gets the charset name
The PropertiesConfigurationFile by default uses ISO-8859-1 encoding to
match the convention for Java property files.
|
List<String> |
getCommentStartTokens()
Gets the comment start tokens
|
boolean |
getEncodeUnicode()
Gets whether to encode Unicode or not
|
String |
getKeyValueSeparators()
Gets the possible key value separator characters
|
List<String> |
getProperties(String key)
Gets all the property values for a given key
|
String |
getProperty(String key)
Gets a property value
|
PropertyEntry |
getPropertyEntry(String key,
String value) |
String |
getStrictKeyValueSeparators()
Gets the strict key value separator characters
|
boolean |
getUseKeySeparatorSpacing()
Gets whether to use key separator spacing or not
|
boolean |
getUseSeparatorValueSpacing()
Gets whether to use separator value spacing or not
|
String |
getWhitespaceCharacters()
Gets the whitespace characters
|
void |
parse(File file)
Parses a File
|
void |
parse(InputStream inputStream)
Parses an input stream
|
void |
removeComment(String comment)
Removes a comment
|
void |
removeCommentStartToken(String commentStartToken)
Removes a comment start token
|
void |
save(File file)
Writes the current configuration to a File
|
void |
setAllowMultipleValuesPerKey(boolean allowMultipleValuesPerKey)
Sets whether a key can have multiple values or not
|
void |
setCharsetName(String charsetName)
Sets the charset name
The PropertiesConfigurationFile by default uses ISO-8859-1 encoding to
match the convention for Java property files.
|
void |
setCommentStartTokens(List<String> commentStartTokens)
Sets the comment start tokens
|
void |
setEncodeUnicode(boolean encodeUnicode)
Sets whether to encode Unicode or not
|
void |
setKeyValueSeparators(String keyValueSeparators)
Sets the possible key value separator characters
|
void |
setProperties(Properties properties)
Sets property values
|
void |
setProperty(PropertyEntry property)
Sets a property value
|
void |
setProperty(String key,
String value)
Sets a property value
|
void |
setStrictKeyValueSeparators(String strictKeyValueSeparators)
Sets the strict key value separator characters
|
void |
setUseKeySeparatorSpacing(boolean useKeySeparatorSpacing)
Sets whether to use key separator spacing or not
|
void |
setUseSeparatorValueSpacing(boolean useSeparatorValueSpacing)
Sets whether to use separator value spacing or not
|
void |
setWhitespaceCharacters(String whitespaceCharacters)
Sets the whitespace characters
|
Properties |
toProperties()
Converts this to a Properties object
|
addEntry, addEntry, equals, getConfigurationFileListIterator, getEntries, getEntry, hashCode, indexOfEntry, iterator, removeEntry, toStringpublic static final String ISO_8859_1
public PropertiesConfigurationFile()
public boolean allowsEntryType(AbstractEntry entry)
entry - entry to examinepublic void parse(File file) throws FileNotFoundException, IOException, ParseException
parse in class AbstractConfigurationFilefile - File to parseFileNotFoundException - if the File is not foundIOException - for all other I/O errorsParseException - for any parsing errorspublic void parse(InputStream inputStream) throws IOException, ParseException
inputStream - input stream to parseIOException - for all other I/O errorsParseException - for any parsing errorspublic void save(File file) throws FileNotFoundException, IOException
save in class AbstractConfigurationFilefile - File to write toFileNotFoundException - if the File is not foundIOException - for all other I/O errorspublic void addComment(String comment)
comment - comment to addpublic void addComment(String commentStartToken, String comment)
commentStartToken - comment start tokencomment - comment to addpublic void removeComment(String comment)
comment - comment to removepublic List<String> getProperties(String key)
key - property key to look uppublic String getProperty(String key)
key - property key to look uppublic PropertyEntry getPropertyEntry(String key, String value)
public void addProperty(String key, String value)
key - property key to addvalue - property value to addpublic void addProperty(PropertyEntry property)
property - PropertyEntry to addpublic void setProperty(String key, String value)
key - property key to setvalue - property value to setpublic void setProperty(PropertyEntry property)
property - PropertyEntry to setpublic void setProperties(Properties properties)
properties - Properties to setpublic void deleteProperty(PropertyEntry property)
property - Property to delete
/**
Deletes a property entryproperty - PropertyEntry to deletepublic void deleteProperty(String key)
key - property key to deletepublic Properties toProperties()
public String getCharsetName()
setCharsetName. If a value of null is used for
the charset name, the platform default will be used. Otherwise, the
charset name specified will be used.public void setCharsetName(String charsetName)
setCharsetName. If a value of null is used for
the charset name, the platform default will be used. Otherwise, the
charset name specified will be used.charsetName - charset namepublic boolean getEncodeUnicode()
public void setEncodeUnicode(boolean encodeUnicode)
encodeUnicode - whether to encode Unicode or notpublic boolean getAllowMultipleValuesPerKey()
public void setAllowMultipleValuesPerKey(boolean allowMultipleValuesPerKey)
allowMultipleValuesPerKey - whether a key can have multiple valuespublic String getWhitespaceCharacters()
public void setWhitespaceCharacters(String whitespaceCharacters)
whitespaceCharacters - whitespace characterspublic List<String> getCommentStartTokens()
public void setCommentStartTokens(List<String> commentStartTokens)
commentStartTokens - comment start tokenspublic void addCommentStartToken(String commentStartToken)
commentStartToken - comment start token to addpublic void removeCommentStartToken(String commentStartToken)
commentStartToken - comment start token to removepublic String getStrictKeyValueSeparators()
public void setStrictKeyValueSeparators(String strictKeyValueSeparators)
strictKeyValueSeparators - strict key value separator characterspublic String getKeyValueSeparators()
public void setKeyValueSeparators(String keyValueSeparators)
keyValueSeparators - possible key value separator characterspublic boolean getUseKeySeparatorSpacing()
public void setUseKeySeparatorSpacing(boolean useKeySeparatorSpacing)
useKeySeparatorSpacing - whether to use key separator spacing or notpublic boolean getUseSeparatorValueSpacing()
public void setUseSeparatorValueSpacing(boolean useSeparatorValueSpacing)
useSeparatorValueSpacing - whether to use separator value spacing
or notpublic void commentProperty(String commentStartToken, PropertyEntry property)
? Copyright 2013 BMC Software, Inc.