org.ploin.pmf.impl
Class PropertiesLoader

java.lang.Object
  extended by org.ploin.pmf.impl.PropertiesLoader
All Implemented Interfaces:
Serializable, IPropertiesLoader

public class PropertiesLoader
extends Object
implements IPropertiesLoader, Serializable

Description: Implementation of the IPropertiesLoader interface.
This class is responsible to read properties files.

$LastChangedBy: r.reiz $
$Revision: 83 $
$Date: 2010-08-09 11:14:25 +0200 (Mon, 09 Aug 2010) $

See Also:
Serialized Form

Constructor Summary
PropertiesLoader()
           
 
Method Summary
 String getDirectory()
          Gets the path to the properties file.
 Properties getProperties(String client, String name)
          This method looks for a properties file with the given name "propName".
It looks for a properties file in the following directories in this order: client directory mail directory class-root
 Properties getPropertiesOnlyClient(String client, String name)
          This method looks for a properties file with the given name "propertyFilename".
It looks for the file only in the client-directory.
 Properties getPropertiesOnlyDirectory(String name)
          This method looks for a properties file with the given name "propertyFilename".
It looks for the file only in the mail-directory.
 Properties getPropertiesOnlyRoot(String name)
          This method looks for a properties file with the given name "propertyFilename".
It looks for the file only in the root-directory (class-root).
 String getPropFile()
          Gets the name of the properties file.
 String getValue(String key)
          Returns a message with the key "key" from the property file "propFile".
 String getValue(String client, String key)
          Returns a message with the key "key" from the property file.
 void replaceVariables(String client, MailConfig mailConfig)
          This method replaces all variables with keys like "${variable}" in the email-addresses of the receivers (to, cc, bcc) with values found in the mail.properties having the key "variable".
 void replaceVariables(TemplateConfig templateConfig)
          This method replaces all variables with keys like "${variable}" in the map of the templateConfig with values found in the mail.properties having the key "variable".
 void setDirectory(String directory)
          Sets the path to the properties file.
 void setPropFile(String propFile)
          Sets the name of the properties file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesLoader

public PropertiesLoader()
Method Detail

getValue

public String getValue(String key)
                throws MailFactoryException
Description copied from interface: IPropertiesLoader
Returns a message with the key "key" from the property file "propFile". It looks for a properties file in the following directories in this order:
  1. mail directory
  2. class-root
If the key is null, the method throws a MailFactoryException.

Specified by:
getValue in interface IPropertiesLoader
Parameters:
key - :the key to search
Returns:
String :the value to the key.
Throws:
MailFactoryException

getValue

public String getValue(String client,
                       String key)
                throws MailFactoryException
Description copied from interface: IPropertiesLoader
Returns a message with the key "key" from the property file. It looks for a properties file in the following directories in this order:
  1. client directory
  2. mail directory
  3. class-root

Specified by:
getValue in interface IPropertiesLoader
Parameters:
client - :the client for the mail
key - :the key to search
Returns:
String :the value to the key.
Throws:
MailFactoryException

replaceVariables

public void replaceVariables(TemplateConfig templateConfig)
                      throws MailFactoryException
Description copied from interface: IPropertiesLoader
This method replaces all variables with keys like "${variable}" in the map of the templateConfig with values found in the mail.properties having the key "variable".

Specified by:
replaceVariables in interface IPropertiesLoader
Parameters:
templateConfig - containing client, locale, template-name and map.
Throws:
MailFactoryException

replaceVariables

public void replaceVariables(String client,
                             MailConfig mailConfig)
                      throws MailFactoryException
Description copied from interface: IPropertiesLoader
This method replaces all variables with keys like "${variable}" in the email-addresses of the receivers (to, cc, bcc) with values found in the mail.properties having the key "variable".

Specified by:
replaceVariables in interface IPropertiesLoader
mailConfig - containing receiver-Emailadresses (to, cc, bcc)
Throws:
MailFactoryException

getProperties

public Properties getProperties(String client,
                                String name)
                         throws MailFactoryException
Description copied from interface: IPropertiesLoader
This method looks for a properties file with the given name "propName".
It looks for a properties file in the following directories in this order:
  1. client directory
  2. mail directory
  3. class-root

Specified by:
getProperties in interface IPropertiesLoader
Parameters:
client - - the client of the mail
name - - the name of the properties file
Returns:
A Properties Object
Throws:
MailFactoryException

getPropertiesOnlyClient

public Properties getPropertiesOnlyClient(String client,
                                          String name)
                                   throws MailFactoryException
Description copied from interface: IPropertiesLoader
This method looks for a properties file with the given name "propertyFilename".
It looks for the file only in the client-directory. If there is no file with the given name it throws an MailFactoryException.

Specified by:
getPropertiesOnlyClient in interface IPropertiesLoader
Parameters:
client - - the client of the mail
name - - the file name of the properties file.
Returns:
A Properties Object
Throws:
MailFactoryException

getPropertiesOnlyDirectory

public Properties getPropertiesOnlyDirectory(String name)
                                      throws MailFactoryException
Description copied from interface: IPropertiesLoader
This method looks for a properties file with the given name "propertyFilename".
It looks for the file only in the mail-directory. If there is no file with the given name it throws an MailFactoryException.

Specified by:
getPropertiesOnlyDirectory in interface IPropertiesLoader
Parameters:
name - - the client of the mail
Returns:
A Properties Object
Throws:
MailFactoryException

getPropertiesOnlyRoot

public Properties getPropertiesOnlyRoot(String name)
                                 throws MailFactoryException
Description copied from interface: IPropertiesLoader
This method looks for a properties file with the given name "propertyFilename".
It looks for the file only in the root-directory (class-root). If there is no file with the given name it throws an MailFactoryException.

Specified by:
getPropertiesOnlyRoot in interface IPropertiesLoader
Parameters:
name - - the client of the mail
Returns:
A Properties Object
Throws:
MailFactoryException

getDirectory

public String getDirectory()
Description copied from interface: IPropertiesLoader
Gets the path to the properties file.

Specified by:
getDirectory in interface IPropertiesLoader
Returns:
the path to the directory there the mail-templates are placed

setDirectory

public void setDirectory(String directory)
Description copied from interface: IPropertiesLoader
Sets the path to the properties file.

Specified by:
setDirectory in interface IPropertiesLoader
Parameters:
directory - - path to the directory there the mail-templates are placed.

getPropFile

public String getPropFile()
Description copied from interface: IPropertiesLoader
Gets the name of the properties file.

Specified by:
getPropFile in interface IPropertiesLoader
Returns:
the name of the properties files. The standard is "mail.properties".

setPropFile

public void setPropFile(String propFile)
Description copied from interface: IPropertiesLoader
Sets the name of the properties file.

Specified by:
setPropFile in interface IPropertiesLoader
Parameters:
propFile - - the name of the properties files.


Copyright © 2012 PLOIN GmbH. All Rights Reserved.