com.ibm.di.connector
Class PropertiesConnector

java.lang.Object
  extended by com.ibm.di.connector.Connector
      extended by com.ibm.di.connector.PropertiesConnector
All Implemented Interfaces:
ConnectorInterface, VersionInfoInterface

public class PropertiesConnector
extends Connector
implements ConnectorInterface

Properties Connector operates on a file or URL.


Field Summary
static String INCLUDE_PREFIX
          Include prefix - "!include <other-file/url>"
protected  boolean isJavaProperties
           
protected  Iterator jpIterator
           
protected  ArrayList lines
           
protected  Map map
          In-memory data
protected  Iterator mapIterator
          Helper objects
static String MERGE_PREFIX
          Merge prefix - "!merge <other-file/url>".
protected  boolean modified
           
static String PARAM_AUTOREWRITE
           
static String PARAM_CIPHER
           
static String PARAM_COLLECTION
          Connector parameters
static String PARAM_COLLECTION_TYPE
           
static String PARAM_CREATE_FILE
           
static String PARAM_ENCRYPTION
           
static String PARAM_PASSWORD
           
static String PROTECT_PREFIX
          Prefix used by encrypted property values
static String PROTECT_VAL_PREFIX
          Prefix used in property value to indicate encrypted data
static String[] SUPPORTED_MODES
          Supported connector modes
protected  PropertyStore systemStore
           
protected  UserFunctions uf
           
 
Fields inherited from class com.ibm.di.connector.Connector
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER
 
Constructor Summary
PropertiesConnector()
          Constructor
 
Method Summary
 void deleteEntry(Entry entry, SearchCriteria search)
          Deletes an existing entry.
 Entry findEntry(SearchCriteria search)
          Finds an existing entry.
 Entry getNextEntry()
          Returns the next Entry from the connector.
 String getVersion()
          Return version information
 int indexOfProperty(String key)
           
 void initialize(Object o)
          Initialize the connector.
protected  void loadProperties(String path, Map map, boolean overwrite)
          Loads the data from path into a buffer where decryption is applied before parsing the properites into the map object.
 void modEntry(Entry entry, SearchCriteria search)
          Modifies an existing entry.
 void putEntry(Entry entry)
          Adds a new entry to the data source
 Object querySchema(Object source)
          Returns a vector of schema entries for this connector.
protected  void readStream(BufferedReader inp, Map map, boolean overwrite)
          Read data from input reader
 void saveProperties(String path)
           
 void savePropertiesFile(String path)
           
 void selectEntries()
          Prepare the Connector for sequential read.
 void setModified()
          Set the modified flag, to make sure that the values are saved even if no change has been made
 void setProperty(String key, Object value, boolean encr)
           
 String[] splitString(String str)
           
 void terminate()
          Terminate the connector.
 
Methods inherited from class com.ibm.di.connector.Connector
addFindEntry, allModes, clearFindEntries, debug, debugMode, findEntry, getBoolean, getClassInstance, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getLog, getMaxDuplicateEntries, getModes, getModes, getName, getNextClient, getNextFindEntry, getParam, getParser, getProperty, getPushbackEntry, getRawConnectorConfiguration, getRSInterface, hasConfigValue, hasParser, initParser, isDeltaSupported, isExceptionFatal, isIOException, logmsg, modEntry, pushback, queryOperations, queryReply, queryTables, reconnect, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setModes, setModes, setName, setParam, setParser, setProperty, setRSInterface, terminateServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.di.connector.ConnectorInterface
getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getMaxDuplicateEntries, getName, getNextClient, getNextFindEntry, getParam, getPushbackEntry, getRawConnectorConfiguration, isDeltaSupported, isExceptionFatal, isIOException, modEntry, pushback, queryOperations, queryReply, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface, terminateServer
 

Field Detail

PARAM_COLLECTION

public static final String PARAM_COLLECTION
Connector parameters

See Also:
Constant Field Values

PARAM_COLLECTION_TYPE

public static final String PARAM_COLLECTION_TYPE
See Also:
Constant Field Values

PARAM_ENCRYPTION

public static final String PARAM_ENCRYPTION
See Also:
Constant Field Values

PARAM_CIPHER

public static final String PARAM_CIPHER
See Also:
Constant Field Values

PARAM_PASSWORD

public static final String PARAM_PASSWORD
See Also:
Constant Field Values

PARAM_AUTOREWRITE

public static final String PARAM_AUTOREWRITE
See Also:
Constant Field Values

PARAM_CREATE_FILE

public static final String PARAM_CREATE_FILE
See Also:
Constant Field Values

PROTECT_PREFIX

public static final String PROTECT_PREFIX
Prefix used by encrypted property values

See Also:
Constant Field Values

PROTECT_VAL_PREFIX

public static final String PROTECT_VAL_PREFIX
Prefix used in property value to indicate encrypted data

See Also:
Constant Field Values

INCLUDE_PREFIX

public static final String INCLUDE_PREFIX
Include prefix - "!include <other-file/url>"

See Also:
Constant Field Values

MERGE_PREFIX

public static final String MERGE_PREFIX
Merge prefix - "!merge <other-file/url>".

See Also:
Constant Field Values

SUPPORTED_MODES

public static final String[] SUPPORTED_MODES
Supported connector modes


map

protected Map map
In-memory data


lines

protected ArrayList lines

modified

protected boolean modified

isJavaProperties

protected boolean isJavaProperties

systemStore

protected PropertyStore systemStore

mapIterator

protected Iterator mapIterator
Helper objects


jpIterator

protected Iterator jpIterator

uf

protected UserFunctions uf
Constructor Detail

PropertiesConnector

public PropertiesConnector()
Constructor

Method Detail

initialize

public void initialize(Object o)
                throws Exception
Initialize the connector. For file/url collections the contents is loaded at this point

Specified by:
initialize in interface ConnectorInterface
Overrides:
initialize in class Connector
Parameters:
o - This parameter is ignored by this connector.
Throws:
Exception - Any exception thrown by java.io/java.net classes when loading a file/url.

terminate

public void terminate()
               throws Exception
Description copied from class: Connector
Terminate the connector. This function closes all connection and releases all resources used by the connector. This function also calls the parser's closeParser() method if a parser is active.

Specified by:
terminate in interface ConnectorInterface
Overrides:
terminate in class Connector
Throws:
Exception

loadProperties

protected void loadProperties(String path,
                              Map map,
                              boolean overwrite)
                       throws Exception
Loads the data from path into a buffer where decryption is applied before parsing the properites into the map object. If overwrite is false, only non-existing props are loaded.

Parameters:
path - The filename or URL from which to read props
map - The map object to receive props
overwrite - If true, all values from prop file are added to map.
Throws:
Exception - if an error occurs while loading properties

readStream

protected void readStream(BufferedReader inp,
                          Map map,
                          boolean overwrite)
                   throws Exception
Read data from input reader

Parameters:
inp - The reader from which data is read
map - The target Map object to insert key/values
overwrite - True if existing values in the map can be overwritten by contents of reader
Throws:
Exception - if an error occurs while reading the stream

indexOfProperty

public int indexOfProperty(String key)

setProperty

public void setProperty(String key,
                        Object value,
                        boolean encr)
                 throws Exception
Throws:
Exception

saveProperties

public void saveProperties(String path)
                    throws Exception
Throws:
Exception

savePropertiesFile

public void savePropertiesFile(String path)
                        throws Exception
Throws:
Exception

selectEntries

public void selectEntries()
                   throws Exception
Description copied from class: Connector
Prepare the Connector for sequential read. If necessary, create a result set to be used for getNextEntry(). When the Connector is used as an Iterator in an AssemblyLine, this method will be called. Default is an empty method.

Specified by:
selectEntries in interface ConnectorInterface
Overrides:
selectEntries in class Connector
Throws:
Exception

getNextEntry

public Entry getNextEntry()
                   throws Exception
Description copied from class: Connector
Returns the next Entry from the connector. The entry is populated with attributes and values from the next entry in the input set.

Specified by:
getNextEntry in interface ConnectorInterface
Overrides:
getNextEntry in class Connector
Returns:
- the next Entry, or null if no more data
Throws:
Exception
See Also:
Connector.selectEntries()

findEntry

public Entry findEntry(SearchCriteria search)
                throws Exception
Description copied from class: Connector
Finds an existing entry. The search criteria specifies which entry to locate

Specified by:
findEntry in interface ConnectorInterface
Overrides:
findEntry in class Connector
Parameters:
search - The search criteria used to locate the entry to be modified
Returns:
The entry found, or null if no or multiple entries found
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

querySchema

public Object querySchema(Object source)
                   throws Exception
Returns a vector of schema entries for this connector.

Specified by:
querySchema in interface ConnectorInterface
Overrides:
querySchema in class Connector
Parameters:
source - The object on which to discover schema. This may be an Entry or a string value
Returns:
A Vector with schema entries for this connector
Throws:
Any - Runtime exception
Exception
See Also:
Entry, Vector

putEntry

public void putEntry(Entry entry)
              throws Exception
Description copied from class: Connector
Adds a new entry to the data source

Specified by:
putEntry in interface ConnectorInterface
Overrides:
putEntry in class Connector
Parameters:
entry - The entry data to add
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

modEntry

public void modEntry(Entry entry,
                     SearchCriteria search)
              throws Exception
Modifies an existing entry. The new entry data is given by the entry parameter and the search criteria specifies which entry to modify.

Specified by:
modEntry in interface ConnectorInterface
Overrides:
modEntry in class Connector
Parameters:
entry - The entry data
search - The search criteria used to locate the entry to be modified
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

deleteEntry

public void deleteEntry(Entry entry,
                        SearchCriteria search)
                 throws Exception
Description copied from class: Connector
Deletes an existing entry. The search criteria specifies which entry to modify. Some connectors may silently ignore the search criteria. For example, the LDAP connector will use the distinguished name ($dn) from the entry parameter (if it exists) rather than expanding the search criteria and search for the entry. Each connector's inner semantics governs wheter the search parameter is used or not.

Specified by:
deleteEntry in interface ConnectorInterface
Overrides:
deleteEntry in class Connector
Parameters:
entry - The entry data
search - The search criteria used to locate the entry to be deleted
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

splitString

public String[] splitString(String str)

setModified

public void setModified()
Set the modified flag, to make sure that the values are saved even if no change has been made


getVersion

public String getVersion()
Return version information

Specified by:
getVersion in interface VersionInfoInterface
Returns:
The version value