|
|||||||||||
| 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 java.util.List<java.lang.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 java.util.Map<java.lang.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 java.lang.String |
PROTECT_PREFIX
A prefix for the keys of protected properties. |
static java.lang.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 | |
|---|---|
java.lang.String |
getProperty(java.lang.String key)
Return the property value as plain text. |
java.lang.String |
getProperty(java.lang.String key,
Log log)
Return the property value as plain text. |
boolean |
isModified()
Determine whether the contents of this file has been modified, e.g. |
boolean |
isPropertyEncrypted(java.lang.String key)
|
boolean |
isPropertyProtected(java.lang.String key)
|
java.util.Iterator<java.lang.String> |
keys()
|
void |
removeProperty(java.lang.String key)
Remove a property from this properties file. |
void |
setProperty(java.lang.String key,
java.lang.String value)
Set a property. |
void |
setPropertyEncrypted(java.lang.String key,
boolean encrypt)
Change the encrypted status of a property's value. |
void |
setPropertyProtected(java.lang.String key,
boolean protect)
Change the protected status of a property. |
abstract void |
store(java.lang.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 java.lang.String PROTECT_PREFIX
public static final java.lang.String PROTECT_VAL_PREFIX
protected java.util.List<java.lang.StringBuilder> lines
protected java.util.Map<java.lang.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 final ResourceHash resHash
| Constructor Detail |
|---|
public BasePropertiesFile()
public BasePropertiesFile(Crypto propertyCrypto)
propertyCrypto - object used to encrypt/decrypt values of protected properties| Method Detail |
|---|
public java.util.Iterator<java.lang.String> keys()
public java.lang.String getProperty(java.lang.String key)
throws java.lang.Exception
key - the property key
java.lang.Exception - decryption error
public void setProperty(java.lang.String key,
java.lang.String value)
throws java.lang.Exception
key - a property key; can be marked as protectedvalue - a property value; can be encrypted
java.lang.Exception - encryption error (if setting a non-encrypted value to an
encrypted property)public void removeProperty(java.lang.String key)
key - property keypublic boolean isPropertyProtected(java.lang.String key)
key - a property key
public boolean isPropertyEncrypted(java.lang.String key)
key - a property key
public void setPropertyProtected(java.lang.String key,
boolean protect)
throws java.lang.Exception
key - a property keyprotect - whether the property will be protected
java.lang.Exception - decryption error
public void setPropertyEncrypted(java.lang.String key,
boolean encrypt)
throws java.lang.Exception
key - a property keyencrypt - whether the property value will be encrypted
java.lang.Exception - encryption/decryption errorpublic boolean isModified()
public abstract void store(java.lang.String path)
throws java.lang.Exception
path - a file, whether the contents will be saved
java.lang.Exception - error while writing the file
public java.lang.String getProperty(java.lang.String key,
Log log)
throws java.lang.Exception
key - log -
java.lang.Exception
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||