com.devsphere.mapping
Class TextUtils

java.lang.Object
  |
  +--com.devsphere.mapping.TextUtils

public class TextUtils
extends java.lang.Object

Utility class that implements text related operations.

See Also:
AbstractLogger

Method Summary
static void beanToText(java.lang.Object bean, java.util.Hashtable errorTable, java.io.OutputStream output)
          Saves the values of the properties of a bean to an output stream in the format used by java.util.Properties.
static void beanToText(java.lang.Object bean, java.util.Hashtable errorTable, java.io.OutputStream output, AbstractLogger logger)
          Saves the values of the properties of a bean to an output stream in the format used by java.util.Properties.
static void beanToText(java.lang.Object bean, java.util.Hashtable errorTable, java.io.OutputStream output, AbstractLogger logger, java.util.Locale locale)
          Saves the values of the properties of a bean to an output stream in the format used by java.util.Properties.
static void beanToText(java.lang.Object bean, java.util.Hashtable errorTable, java.io.OutputStream output, AbstractLogger logger, java.lang.String prefix)
          Saves the values of the properties of a bean to an output stream in the format used by java.util.Properties.
static void beanToText(java.lang.Object bean, java.util.Hashtable errorTable, java.io.OutputStream output, AbstractLogger logger, java.lang.String prefix, java.util.Locale locale)
          Saves the values of the properties of a bean to an output stream in the format used by java.util.Properties.
static java.lang.String commentToProp(java.lang.String str)
          Encodes a comment so that it can be saved to a property file.
static java.lang.String keyOrValueToProp(java.lang.String str)
          Encodes a key or value so that it can be saved to a property file.
static java.util.Hashtable textToBean(java.io.InputStream input, java.lang.Object bean)
          Fills the properties of a bean with the values of a set of properties encoded as text.
static java.util.Hashtable textToBean(java.io.InputStream input, java.lang.Object bean, AbstractLogger logger)
          Fills the properties of a bean with the values of a set of properties encoded as text.
static java.util.Hashtable textToBean(java.io.InputStream input, java.lang.Object bean, AbstractLogger logger, java.util.Locale locale)
          Fills the properties of a bean with the values of a set of properties encoded as text.
static java.util.Hashtable textToBean(java.io.InputStream input, java.lang.Object bean, AbstractLogger logger, java.lang.String prefix)
          Fills the properties of a bean with the values of a set of properties encoded as text.
static java.util.Hashtable textToBean(java.io.InputStream input, java.lang.Object bean, AbstractLogger logger, java.lang.String prefix, java.util.Locale locale)
          Fills the properties of a bean with the values of a set of properties encoded as text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

textToBean

public static java.util.Hashtable textToBean(java.io.InputStream input,
                                             java.lang.Object bean)
                                      throws java.io.IOException
Fills the properties of a bean with the values of a set of properties encoded as text. The text properties are loaded from an input stream using java.util.Properties. All errors that occur during the mapping process are stored in a hashtable.
Parameters:
input - the input stream that is used to read the text properties.
bean - the bean instance whose properties must be filled.
Returns:
an hashtable containing the application and user errors or null if no error occurred.
Throws:
NullPointerException - if input is null or bean is null.
java.io.IOException - if an I/O error occurs.

textToBean

public static java.util.Hashtable textToBean(java.io.InputStream input,
                                             java.lang.Object bean,
                                             AbstractLogger logger)
                                      throws java.io.IOException
Fills the properties of a bean with the values of a set of properties encoded as text. The text properties are loaded from an input stream using java.util.Properties. All errors that occur during the mapping process are stored in a hashtable.
Parameters:
input - the input stream that is used to read the text properties.
bean - the bean instance whose properties must be filled.
logger - logging mechanism for application errors.
Returns:
an hashtable containing the application and user errors or null if no error occurred.
Throws:
NullPointerException - if input is null or bean is null.
java.io.IOException - if an I/O error occurs.

textToBean

public static java.util.Hashtable textToBean(java.io.InputStream input,
                                             java.lang.Object bean,
                                             AbstractLogger logger,
                                             java.lang.String prefix)
                                      throws java.io.IOException
Fills the properties of a bean with the values of a set of properties encoded as text. The text properties are loaded from an input stream using java.util.Properties. All errors that occur during the mapping process are stored in a hashtable.
Parameters:
input - the input stream that is used to read the text properties.
bean - the bean instance whose properties must be filled.
logger - logging mechanism for application errors.
prefix - the prefix of the names of the text properties.
Returns:
an hashtable containing the application and user errors or null if no error occurred.
Throws:
NullPointerException - if input is null or bean is null.
java.io.IOException - if an I/O error occurs.

textToBean

public static java.util.Hashtable textToBean(java.io.InputStream input,
                                             java.lang.Object bean,
                                             AbstractLogger logger,
                                             java.util.Locale locale)
                                      throws java.io.IOException
Fills the properties of a bean with the values of a set of properties encoded as text. The text properties are loaded from an input stream using java.util.Properties. All errors that occur during the mapping process are stored in a hashtable.
Parameters:
input - the input stream that is used to read the text properties.
bean - the bean instance whose properties must be filled.
logger - logging mechanism for application errors.
locale - internationalization support parameter.
Returns:
an hashtable containing the application and user errors or null if no error occurred.
Throws:
NullPointerException - if input is null or bean is null.
java.io.IOException - if an I/O error occurs.

textToBean

public static java.util.Hashtable textToBean(java.io.InputStream input,
                                             java.lang.Object bean,
                                             AbstractLogger logger,
                                             java.lang.String prefix,
                                             java.util.Locale locale)
                                      throws java.io.IOException
Fills the properties of a bean with the values of a set of properties encoded as text. The text properties are loaded from an input stream using java.util.Properties. All errors that occur during the mapping process are stored in a hashtable.
Parameters:
input - the input stream that is used to read the text properties.
bean - the bean instance whose properties must be filled.
logger - logging mechanism for application errors.
prefix - the prefix of the names of the text properties.
locale - internationalization support parameter.
Returns:
an hashtable containing the application and user errors or null if no error occurred.
Throws:
NullPointerException - if input is null or bean is null.
java.io.IOException - if an I/O error occurs.

beanToText

public static void beanToText(java.lang.Object bean,
                              java.util.Hashtable errorTable,
                              java.io.OutputStream output)
                       throws java.io.IOException
Saves the values of the properties of a bean to an output stream in the format used by java.util.Properties. The errorTable parameter may be null or it must be a hashtable returned by one of the mapping methods of the framework. In the latter case, the error messages are saved as comments.
Parameters:
bean - the bean instance whose properties must be saved.
errorTable - hashtable containing mapping errors.
output - the output stream used to save the bean's data.
Throws:
NullPointerException - if bean is null or output is null.
java.lang.IllegalArgumentException - if errorTable wasn't created by this framework.
java.io.IOException - if an I/O error occurs.

beanToText

public static void beanToText(java.lang.Object bean,
                              java.util.Hashtable errorTable,
                              java.io.OutputStream output,
                              AbstractLogger logger)
                       throws java.io.IOException
Saves the values of the properties of a bean to an output stream in the format used by java.util.Properties. The errorTable parameter may be null or it must be a hashtable returned by one of the mapping methods of the framework. In the latter case, the error messages are saved as comments.
Parameters:
bean - the bean instance whose properties must be saved.
errorTable - hashtable containing mapping errors.
output - the output stream used to save the bean's data.
logger - logging mechanism for application errors.
Throws:
NullPointerException - if bean is null or output is null.
java.lang.IllegalArgumentException - if errorTable wasn't created by this framework.
java.io.IOException - if an I/O error occurs.

beanToText

public static void beanToText(java.lang.Object bean,
                              java.util.Hashtable errorTable,
                              java.io.OutputStream output,
                              AbstractLogger logger,
                              java.lang.String prefix)
                       throws java.io.IOException
Saves the values of the properties of a bean to an output stream in the format used by java.util.Properties. The errorTable parameter may be null or it must be a hashtable returned by one of the mapping methods of the framework. In the latter case, the error messages are saved as comments.
Parameters:
bean - the bean instance whose properties must be saved.
errorTable - hashtable containing mapping errors.
output - the output stream used to save the bean's data.
logger - logging mechanism for application errors.
prefix - the prefix of the names of the text properties.
Throws:
NullPointerException - if bean is null or output is null.
java.lang.IllegalArgumentException - if errorTable wasn't created by this framework.
java.io.IOException - if an I/O error occurs.

beanToText

public static void beanToText(java.lang.Object bean,
                              java.util.Hashtable errorTable,
                              java.io.OutputStream output,
                              AbstractLogger logger,
                              java.util.Locale locale)
                       throws java.io.IOException
Saves the values of the properties of a bean to an output stream in the format used by java.util.Properties. The errorTable parameter may be null or it must be a hashtable returned by one of the mapping methods of the framework. In the latter case, the error messages are saved as comments.
Parameters:
bean - the bean instance whose properties must be saved.
errorTable - hashtable containing mapping errors.
output - the output stream used to save the bean's data.
logger - logging mechanism for application errors.
locale - internationalization support parameter.
Throws:
NullPointerException - if bean is null or output is null.
java.lang.IllegalArgumentException - if errorTable wasn't created by this framework.
java.io.IOException - if an I/O error occurs.

beanToText

public static void beanToText(java.lang.Object bean,
                              java.util.Hashtable errorTable,
                              java.io.OutputStream output,
                              AbstractLogger logger,
                              java.lang.String prefix,
                              java.util.Locale locale)
                       throws java.io.IOException
Saves the values of the properties of a bean to an output stream in the format used by java.util.Properties. The errorTable parameter may be null or it must be a hashtable returned by one of the mapping methods of the framework. In the latter case, the error messages are saved as comments.
Parameters:
bean - the bean instance whose properties must be saved.
errorTable - hashtable containing mapping errors.
output - the output stream used to save the bean's data.
logger - logging mechanism for application errors.
prefix - the prefix of the names of the text properties.
locale - internationalization support parameter.
Throws:
NullPointerException - if bean is null or output is null.
java.lang.IllegalArgumentException - if errorTable wasn't created by this framework.
java.io.IOException - if an I/O error occurs.

keyOrValueToProp

public static java.lang.String keyOrValueToProp(java.lang.String str)
Encodes a key or value so that it can be saved to a property file.
Parameters:
str - the string that has to be encoded.
Returns:
the encoded string.
Throws:
NullPointerException - if str is null.

commentToProp

public static java.lang.String commentToProp(java.lang.String str)
Encodes a comment so that it can be saved to a property file.
Parameters:
str - the string that has to be encoded.
Returns:
the encoded string.
Throws:
NullPointerException - if str is null.