|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.util.PropertiesFile
public class PropertiesFile
In-memory representation of a TDI properties file. It may contain comments and empty lines as well as property definitions. It may also contain references to other properties files.
A property in a TDI properties file can be protected or non-protected. Protected properties normally have their keys prefixed with PropertiesFile.PROTECT_PREFIX. Protected properties may have their values encrypted. If a property value is encrypted, it will be prefixed with PropertiesFile.PROTECT_VAL_PREFIX. If a property's value is encrypted, the property is considered protected no matter if it is actually marked as protected.
Field Summary | |
---|---|
static java.lang.String |
INCLUDE_DIRECTIVE
Include directive "!include <other-file/url>" |
static java.lang.String |
MERGE_DIRECTIVE
Merge directive - "!merge <other-file/url>". |
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. |
Constructor Summary | |
---|---|
PropertiesFile(Crypto propertyCrypto)
Create an empty object. |
|
PropertiesFile(Crypto propertyCrypto,
java.lang.String path,
boolean resolveReferences)
Load a properties file in memory. |
|
PropertiesFile(Crypto propertyCrypto,
java.lang.String path,
boolean resolveReferences,
Crypto fileCrypto,
java.lang.String prefixToSkip)
Load a properties file in memory. |
|
PropertiesFile(java.lang.String path,
boolean resolveReferences)
Load a properties file in memory. |
Method Summary | |
---|---|
java.lang.String |
getProperty(java.lang.String key)
Return the property value as plaintext. |
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. |
void |
store(java.lang.String path,
java.lang.String header,
Crypto fileCrypto)
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 INCLUDE_DIRECTIVE
Include directive "!include <other-file/url>"
Include one properties file into another properties file. Properties defined in the main properties file before the include directive can be potentially overridden by properties from the included file. Properties defined in the main properties file after the include directive can potentially override properties from the included file.
public static final java.lang.String MERGE_DIRECTIVE
Merge directive - "!merge <other-file/url>".
Merge the contents of one properties file into another properties file. Properties defined in the main properties file before the merge directive will not be overwritten by the properties from the merged file. Properties defined in the main properties file after the merge directive can potentially override properties from the merged file.
public static final java.lang.String PROTECT_PREFIX
public static final java.lang.String PROTECT_VAL_PREFIX
Constructor Detail |
---|
public PropertiesFile(Crypto propertyCrypto)
propertyCrypto
- object used to encrypt/decrypt values of protected propertiespublic PropertiesFile(java.lang.String path, boolean resolveReferences) throws java.lang.Exception
path
- properties file to loadresolveReferences
- whether to load the properties files that the specified file
references
java.lang.Exception
- error while reading the properties filepublic PropertiesFile(Crypto propertyCrypto, java.lang.String path, boolean resolveReferences) throws java.lang.Exception
propertyCrypto
- object used to encrypt/decrypt values of protected propertiespath
- properties file to loadresolveReferences
- whether to load the properties files that the specified file
references
java.lang.Exception
- error while reading the properties filepublic PropertiesFile(Crypto propertyCrypto, java.lang.String path, boolean resolveReferences, Crypto fileCrypto, java.lang.String prefixToSkip) throws java.lang.Exception
propertyCrypto
- object used to encrypt/decrypt values of protected propertiespath
- properties file to loadresolveReferences
- whether to load the properties files that the specified file
referencesfileCrypto
- object used to decrypt the file; pass null if the properties
file is not encrypted as a wholeprefixToSkip
- prefix that matches lines from the properties file, which will
be skipped during processing; pass null to read all lines
java.lang.Exception
- error while reading the properties file, or error while
decrypting itMethod Detail |
---|
public java.util.Iterator<java.lang.String> keys()
public void store(java.lang.String path, java.lang.String header, Crypto fileCrypto) throws java.lang.Exception
path
- a file, whether the contents will be savedheader
- an optional header, that will be put as the first line in the
properties file; must be a single comment linefileCrypto
- object used to encrypt the file as a whole; if null the file
will not be encrypted as a whole
java.lang.Exception
- error while writing the file or error while encrypting the
filepublic java.lang.String getProperty(java.lang.String key) throws java.lang.Exception
key
- the property key
java.lang.Exception
- decryption errorpublic 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 errorpublic 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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |