com.ibm.di.util
Class PropertiesFile

java.lang.Object
  extended by com.ibm.di.util.BasePropertiesFile
      extended by com.ibm.di.util.PropertiesFile

public class PropertiesFile
extends BasePropertiesFile

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. The properties file could also be encrypted.

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.

Since:
7.0
See Also:
BasePropertiesFile

Nested Class Summary
 
Nested classes/interfaces inherited from class com.ibm.di.util.BasePropertiesFile
BasePropertiesFile.Property
 
Field Summary
static String INCLUDE_DIRECTIVE
           Include directive "!include <other-file/url>"
static String MERGE_DIRECTIVE
           Merge directive - "!merge <other-file/url>".
 
Fields inherited from class com.ibm.di.util.BasePropertiesFile
lines, modified, properties, propertyCrypto, PROTECT_PREFIX, PROTECT_VAL_PREFIX, resHash
 
Constructor Summary
PropertiesFile(Crypto propertyCrypto)
          Create an empty object.
PropertiesFile(Crypto propertyCrypto, String path, boolean resolveReferences)
          Load a properties file in memory.
PropertiesFile(Crypto propertyCrypto, String path, boolean resolveReferences, Crypto fileCrypto, String prefixToSkip)
          Load a properties file in memory.
PropertiesFile(String path, boolean resolveReferences)
          Load a properties file in memory.
 
Method Summary
 void store(String path)
          Write the contents of this properties file to disk.
 void store(String path, String header, Crypto fileCrypto)
          Write the contents of this properties file to disk.
 
Methods inherited from class com.ibm.di.util.BasePropertiesFile
getProperty, getProperty, isModified, isPropertyEncrypted, isPropertyProtected, keys, removeProperty, setProperty, setPropertyEncrypted, setPropertyProtected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCLUDE_DIRECTIVE

public static final 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.

See Also:
Constant Field Values

MERGE_DIRECTIVE

public static final 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.

See Also:
Constant Field Values
Constructor Detail

PropertiesFile

public PropertiesFile(Crypto propertyCrypto)
Create an empty object.

Parameters:
propertyCrypto - object used to encrypt/decrypt values of protected properties

PropertiesFile

public PropertiesFile(String path,
                      boolean resolveReferences)
               throws Exception
Load a properties file in memory. Uses a default Crypto.

Parameters:
path - properties file to load
resolveReferences - whether to load the properties files that the specified file references
Throws:
Exception - error while reading the properties file

PropertiesFile

public PropertiesFile(Crypto propertyCrypto,
                      String path,
                      boolean resolveReferences)
               throws Exception
Load a properties file in memory.

Parameters:
propertyCrypto - object used to encrypt/decrypt values of protected properties
path - properties file to load
resolveReferences - whether to load the properties files that the specified file references
Throws:
Exception - error while reading the properties file

PropertiesFile

public PropertiesFile(Crypto propertyCrypto,
                      String path,
                      boolean resolveReferences,
                      Crypto fileCrypto,
                      String prefixToSkip)
               throws Exception
Load a properties file in memory. If the specified file is encrypted as a whole, a cryptographic object to decrypt the file must be provided. If a file is encrypted as a whole, all the files it references are expected to be encrypted too. The specified crypto object will be used to decrypt them also.

Parameters:
propertyCrypto - object used to encrypt/decrypt values of protected properties
path - properties file to load
resolveReferences - whether to load the properties files that the specified file references
fileCrypto - object used to decrypt the file; pass null if the properties file is not encrypted as a whole
prefixToSkip - prefix that matches lines from the properties file, which will be skipped during processing; pass null to read all lines
Throws:
Exception - error while reading the properties file, or error while decrypting it
Method Detail

store

public void store(String path,
                  String header,
                  Crypto fileCrypto)
           throws Exception
Write the contents of this properties file to disk.

Parameters:
path - a file, whether the contents will be saved
header - an optional header, that will be put as the first line in the properties file; must be a single comment line
fileCrypto - object used to encrypt the file as a whole; if null the file will not be encrypted as a whole
Throws:
Exception - error while writing the file or error while encrypting the file

store

public void store(String path)
           throws Exception
Write the contents of this properties file to disk. The file is not encrypted and no header is written.

Specified by:
store in class BasePropertiesFile
Parameters:
path - a file, whether the contents will be saved
Throws:
Exception - error while writing the file