|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.util.BasePropertiesFile
public abstract class BasePropertiesFile
In-memory representation of a properties file. It may contain comments and empty lines as well as property definitions. When writing the order of the properties and the user comments are kept.
A property in a properties file can be protected or non-protected. Protected properties normally have their keys prefixed with BasePropertiesFiles.PROTECT_PREFIX. Protected properties may have their values encrypted. If a property value is encrypted, it will be prefixed with BasePropertiesFiles.PROTECT_VAL_PREFIX. If a property's value is encrypted, the property is considered protected no matter if it is actually marked as protected.
PropertiesFile
Nested Class Summary | |
---|---|
protected static class |
BasePropertiesFile.Property
A property from a properties file. |
Field Summary | |
---|---|
protected List<StringBuilder> |
lines
All lines of the properties file - including comments, empty lines, include directives and property definitions. |
protected boolean |
modified
Whether any of the lines in this properties file has been modified. |
protected Map<String,BasePropertiesFile.Property> |
properties
The property definitions of the properties file the mapping is: property key -> BasePropertiesFile.Property object. |
protected Crypto |
propertyCrypto
Object to encrypt/decrypt the values of protected properties. |
static String |
PROTECT_PREFIX
A prefix for the keys of protected properties. |
static String |
PROTECT_VAL_PREFIX
A prefix for encrypted property values. |
protected static ResourceHash |
resHash
|
Constructor Summary | |
---|---|
BasePropertiesFile()
Create an empty object. |
|
BasePropertiesFile(Crypto propertyCrypto)
Create an empty object with crypto module. |
Method Summary | |
---|---|
String |
getProperty(String key)
Return the property value as plain text. |
boolean |
isModified()
Determine whether the contents of this file has been modified, e.g. |
boolean |
isPropertyEncrypted(String key)
|
boolean |
isPropertyProtected(String key)
|
Iterator<String> |
keys()
|
void |
removeProperty(String key)
Remove a property from this properties file. |
void |
setProperty(String key,
String value)
Set a property. |
void |
setPropertyEncrypted(String key,
boolean encrypt)
Change the encrypted status of a property's value. |
void |
setPropertyProtected(String key,
boolean protect)
Change the protected status of a property. |
abstract void |
store(String path)
Write the contents of this properties file to disk. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROTECT_PREFIX
public static final String PROTECT_VAL_PREFIX
protected List<StringBuilder> lines
protected Map<String,BasePropertiesFile.Property> properties
The property definitions of the properties file the mapping is: property key -> BasePropertiesFile.Property object. The key is not marked with a protect prefix.
Only the last encountered definition of a property is kept. If for example a properties file contains two equal properties, then the definition from the last property will be kept.
protected boolean modified
protected Crypto propertyCrypto
protected static ResourceHash resHash
Constructor Detail |
---|
public BasePropertiesFile()
public BasePropertiesFile(Crypto propertyCrypto)
propertyCrypto
- object used to encrypt/decrypt values of protected propertiesMethod Detail |
---|
public Iterator<String> keys()
public String getProperty(String key) throws Exception
key
- the property key
Exception
- decryption errorpublic void setProperty(String key, String value) throws Exception
key
- a property key; can be marked as protectedvalue
- a property value; can be encrypted
Exception
- encryption error (if setting a non-encrypted value to an
encrypted property)public void removeProperty(String key)
key
- property keypublic boolean isPropertyProtected(String key)
key
- a property key
public boolean isPropertyEncrypted(String key)
key
- a property key
public void setPropertyProtected(String key, boolean protect) throws Exception
key
- a property keyprotect
- whether the property will be protected
Exception
- decryption errorpublic void setPropertyEncrypted(String key, boolean encrypt) throws Exception
key
- a property keyencrypt
- whether the property value will be encrypted
Exception
- encryption/decryption errorpublic boolean isModified()
public abstract void store(String path) throws Exception
path
- a file, whether the contents will be saved
Exception
- error while writing the file
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |