Interface PropertyConverter

  • All Known Implementing Classes:
    Converter, DateConverter, DefaultConverter, NumberConverter, TimeConverter

    public interface PropertyConverter
    Converts strings to objects and back.
    Version:
    $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/util/convert/PropertyConverter.java#1 $
    Author:
    Harald Kuhr, last modified by $Author: haku $
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Object toObject​(java.lang.String pString, java.lang.Class pType, java.lang.String pFormat)
      Converts the string to an object, using the given format for parsing.
      java.lang.String toString​(java.lang.Object pObject, java.lang.String pFormat)
      Converts the object to a string, using the given format
    • Method Detail

      • toObject

        java.lang.Object toObject​(java.lang.String pString,
                                  java.lang.Class pType,
                                  java.lang.String pFormat)
                           throws ConversionException
        Converts the string to an object, using the given format for parsing.
        Parameters:
        pString - the string to convert
        pType - the type to convert to. PropertyConverter implementations may choose to ignore this parameter.
        pFormat - the format used for parsing. PropertyConverter implementations may choose to ignore this parameter. Also, implementations that require a parser format, should provide a default format, and allow null as the format argument.
        Returns:
        the object created from the given string.
        Throws:
        ConversionException - if the string could not be converted to the specified type and format.
      • toString

        java.lang.String toString​(java.lang.Object pObject,
                                  java.lang.String pFormat)
                           throws ConversionException
        Converts the object to a string, using the given format
        Parameters:
        pObject - the object to convert
        pFormat - the format used for parsing. PropertyConverter implementations may choose to ignore this parameter. Also, implementations that require a parser format, should provide a default format, and allow null as the format argument.
        Returns:
        the string representation of the object, on the correct format.
        Throws:
        ConversionException - if the string could not be converted to the specified type and format.