1 29 package net.sourceforge.groboutils.autodoc.v1.testserver; 30 31 import java.io.IOException ; 32 import java.io.Writer ; 33 34 import org.apache.log4j.Logger; 35 36 37 46 public abstract class AbstractWriterServer implements Server 47 { 48 private static final Logger LOG = Logger.getLogger( AbstractWriterServer.class ); 49 50 51 57 public void addTestData( TestData td ) 58 { 59 if (td == null) 60 { 61 LOG.warn("addTestData() received null TestData."); 63 return; 64 } 65 66 Writer w; 68 try 69 { 70 w = openOutput( td ); 71 } 72 catch (IOException e) 73 { 74 LOG.error( "Problem opening output.", e ); 75 76 return; 78 } 79 80 try 81 { 82 writeTestData( td, w ); 83 } 84 catch (IOException e) 85 { 86 LOG.error( "Problem writing to output.", e ); 87 } 88 finally 89 { 90 try 93 { 94 closeOutput( w ); 95 } 96 catch (IOException e) 97 { 98 LOG.error( "Problem closing output.", e ); 99 } 100 } 101 } 102 103 104 108 protected abstract void writeTestData( TestData td, Writer w ) 109 throws IOException ; 110 111 112 116 protected abstract Writer openOutput( TestData td ) 117 throws IOException ; 118 119 120 125 protected void closeOutput( Writer w ) 126 throws IOException 127 { 128 w.close(); 129 } 130 } 131 132 | Popular Tags |