1 package net.sf.layoutParser.typeHandler; 2 3 import net.sf.layoutParser.processor.MalformedInputException; 4 import net.sf.layoutParser.processor.MalformedOutputException; 5 6 /** 7 * Serves as a template method to the type handlers taking care of the filling 8 * and alignment. 9 * 10 * 11 * @param <T> 12 * The type to be handle by the type handler. 13 * 14 * @author Leonardo Bueno Postacchini 15 * @since 1.1.2 16 * @date 2012-11-05 17 */ 18 public abstract class BaseTypeHandler<T> implements TypeHandler<T> { 19 20 public String format(T data, String format, String filler, int size) 21 throws MalformedOutputException { 22 // TODO Auto-generated method stub 23 return null; 24 } 25 26 public T parse(String dados, String format, String filler) 27 throws MalformedInputException { 28 // TODO Auto-generated method stub 29 return null; 30 } 31 32 /** 33 * <p> 34 * Shall format the data, regardless of filling as the filler will be added 35 * after by the BaseTypeHandler. 36 * </p> 37 * 38 * @param data 39 * The data to be formated. 40 * @param format 41 * The format to be used, if any. 42 * @param size 43 * The max size the resulting string should occupy. 44 */ 45 protected abstract String format(T data, String format, int size); 46 47 /** 48 * <p> 49 * Shall parse the data from the string, according to format if any, and 50 * return the resulting data. 51 * </p> 52 * <p> 53 * The filler stuff will be striped previous to the method invocation. 54 * </p> 55 * 56 * @param dados 57 * @param format 58 * @return 59 */ 60 protected abstract T parse(String dados, String format); 61 }