1 package uk.ac.ebi.intenz.tools.sib.writer; 2 3 /** 4 * This interface provides a method to format lines according to the rules of the <code>enzyme.dat</code> file. 5 * <p/> 6 * Some of the rules can be found <a target="_blank" href="http://enzyme.expasy.org/enzuser.txt">here</a>. 7 * <p/> 8 * The formatting of lines is dependent on the {@link LineType line type} and the content of each line type. A 9 * <code>LineFormatter</code> implementation will provide a means to format and wrap the lines of a 10 * {@link LineType line type} by implementing {@link LineFormatter#formatLines(String, LineType) 11 * formatLines(String, LineType)}. 12 * <p/> 13 * As rules for wrapping lines are often applicable to several {@link LineType line types}, the wrapping is defined by 14 * the interface {@link LineWrapper LineWrapper}, which defines the implementation of line wrapping rules. These rules 15 * should be used within a <code>LineFormatter</code> concrete class. 16 * <p/> 17 * Apart from the correct line wrapping the <code>LineFormatter</code> must take care of proper formatting in the 18 * beginning of the line, i.e. line headers.<br/> 19 * For example, in case of the <code><b>CC</b></code> line type the 20 * <code>LineFormatter</code> must format each line beginning with <b><code>>CC <</code></b> plus an additional 21 * <code><b>>-!- <</b></code> to indicate the beginning of a sentence or spaces, if the line is a continuation of 22 * a sentence. 23 * <p/> 24 * <b>Example:</b> 25 * <p/> 26 * <img src="../../../../../../../images/example_formatter.gif"> 27 * 28 * @author Michael Darsow 29 * @version $Revision: 1.2 $ $Date: 2008/01/28 11:43:23 $ 30 */ 31 public interface LineFormatter { 32 33 /** Defines the maximum line width within the flat file. **/ 34 static final int LINEWIDTH = 78; 35 36 /** 37 * This method takes care of proper formatting of the line(s) corresponding one {@link LineType line type} as 38 * described in the class description. 39 * 40 * @param text The whole text of one line type. 41 * @param lineType The {@link LineType line type}. 42 * @return the formatted lines. 43 * @throws EnzymeFlatFileWriteException if an error occured during the formatting process. 44 */ 45 String formatLines(String text, LineType lineType) throws EnzymeFlatFileWriteException; 46 }