org.ploin.pmf.impl
Class PropertiesLoader

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

public class PropertiesLoader
extends java.lang.Object
implements IPropertiesLoader, java.io.Serializable

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

                                    ........
                                 .WHHUUVOOOOU&,
     dMMMMMMMMMMMa,   .MMMMF   .MHW0Oz+!``````?G.   .MMMM% .MMMMMMMMMMMN,
    .MMMMMMMMMMMMMMr  JMMMM   JHHXwOz;:^..```  `O,  JMMM#  dMMMMMMMMMMMMN
    JMMM#     ,MMMMF  MMMMF  .MHVXwOz++.^.````  +n .MMMM$ .MMMMt    dMMM#
   .MMMMt     .MMMMt .MMMM!  JMHWWXwOz++....  `.+X JMMMM  JMMMM    .MMMM%
   JMMM#     .MMMM@  dMMM#   ,MHHWWXwOzz+++....?df MMMMF .MMMMF    JMMM#
  .MMMMNNNNNMMMMMD   MMMMMNNm 4MHHWWXXwOOzzz1+1wX'.MMMM! .MMMM`   .MMMM$
  .MMMMMMMMMMMM"`    .YMMMMMF  TMHHHWWWXXXwwwwXK! MMMMF  MMMMF    JMMMM
  MMMMF                          TMMHHHHHWWWHY^
 .MMMM'                             `7""""^`
 dMMM#
 

$HeadURL: https://ploinscm.de/svn/ploinMailFactory/trunk/src/main/java/org/ploin/pmf/impl/PropertiesLoader.java $
$LastChangedBy: r.reiz $
$Revision: 48 $
$Date: 2009-11-18 01:06:13 +0100 (Wed, 18 Nov 2009) $

See Also:
Serialized Form

Constructor Summary
PropertiesLoader()
           
 
Method Summary
 java.lang.String getDirectory()
          Gets the path to the properties file.
 java.lang.String getMessage(java.lang.String key)
          Returns a message with the key "key" from the property file "propFile".
 java.lang.String getMessage(java.lang.String mandant, java.lang.String key)
          Returns a message with the key "key" from the property file.
 java.util.Properties getProperties(java.lang.String mandant, java.lang.String propName)
          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
 java.util.Properties getPropertiesFromDirectory(java.lang.String propName)
          This method looks for a properties file with the given name "propName".
It looks for the file only in the mail-directory.
 java.util.Properties getPropertiesFromMandant(java.lang.String mandant, java.lang.String propName)
          This method looks for a properties file with the given name "propName".
It looks for the file only in the client-directory.
 java.util.Properties getPropertiesFromRoot(java.lang.String propName)
          This method looks for a properties file with the given name "propName".
It looks for the file only in the root-directory (class-root).
 java.lang.String getPropFile()
          Gets the name of the properties file.
 java.util.Map<java.lang.String,java.lang.String> replaceVariables(TemplateConfig templateConfig)
          This method replaces all variables (${variable}) in the map with values found in the mail.properties.
 void setDirectory(java.lang.String directory)
          Sets the path to the properties file.
 void setPropFile(java.lang.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

getMessage

public java.lang.String getMessage(java.lang.String key)
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 returns null.

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

getMessage

public java.lang.String getMessage(java.lang.String mandant,
                                   java.lang.String key)
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:
getMessage in interface IPropertiesLoader
Parameters:
mandant - :the client/mandant for the mail
key - :the key to search
Returns:
String :the value to the key.

replaceVariables

public java.util.Map<java.lang.String,java.lang.String> replaceVariables(TemplateConfig templateConfig)
Description copied from interface: IPropertiesLoader
This method replaces all variables (${variable}) in the map with values found in the mail.properties. The variable-name is the key.

Specified by:
replaceVariables in interface IPropertiesLoader
Parameters:
templateConfig - containing mandant/client, locale, template-name and map.
Returns:
a new map with replaced values

getProperties

public java.util.Properties getProperties(java.lang.String mandant,
                                          java.lang.String propName)
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:
mandant - - the client to the mail
propName - - the name of the properties file
Returns:
A Properties Object

getPropertiesFromMandant

public java.util.Properties getPropertiesFromMandant(java.lang.String mandant,
                                                     java.lang.String propName)
Description copied from interface: IPropertiesLoader
This method looks for a properties file with the given name "propName".
It looks for the file only in the client-directory. If there is no file with the given name it returns null.

Specified by:
getPropertiesFromMandant in interface IPropertiesLoader
Parameters:
mandant - - the client to the mail
propName - - the file name of the properties file.
Returns:
A Properties Object

getPropertiesFromDirectory

public java.util.Properties getPropertiesFromDirectory(java.lang.String propName)
Description copied from interface: IPropertiesLoader
This method looks for a properties file with the given name "propName".
It looks for the file only in the mail-directory. If there is no file with the given name it returns null.

Specified by:
getPropertiesFromDirectory in interface IPropertiesLoader
Parameters:
propName - - the client to the mail
Returns:
A Properties Object

getPropertiesFromRoot

public java.util.Properties getPropertiesFromRoot(java.lang.String propName)
Description copied from interface: IPropertiesLoader
This method looks for a properties file with the given name "propName".
It looks for the file only in the root-directory (class-root). If there is no file with the given name it returns null.

Specified by:
getPropertiesFromRoot in interface IPropertiesLoader
Parameters:
propName - - the client to the mail
Returns:
A Properties Object

getDirectory

public java.lang.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(java.lang.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 java.lang.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(java.lang.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 © 2009 PLOIN GmbH. All Rights Reserved.