Clover Coverage Report - Impex Parent 1.0.21-SNAPSHOT (Aggregated)
Coverage timestamp: Tue Feb 8 2011 11:33:53 EST
../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
17   66   8   2.43
2   47   0.47   7
7     1.14  
1    
 
  Morpher       Line # 11 17 0% 8 26 0% 0.0
 
No Tests
 
1    package org.apache.torque.mojo.morph;
2   
3    import java.io.IOException;
4    import java.io.InputStream;
5    import java.io.OutputStream;
6   
7    import org.apache.commons.io.IOUtils;
8    import org.apache.commons.logging.Log;
9    import org.apache.commons.logging.LogFactory;
10   
 
11    public abstract class Morpher {
12    private static final Log log = LogFactory.getLog(Morpher.class);
13   
14    MorphRequest morphRequest;
15    String artifactId;
16   
 
17  0 toggle public Morpher() {
18  0 this(null, null);
19    }
20   
 
21  0 toggle public Morpher(MorphRequest morphRequest, String artifactId) {
22  0 super();
23  0 this.morphRequest = morphRequest;
24  0 this.artifactId = artifactId;
25    }
26   
27    protected abstract boolean isMorphNeeded(String contents);
28   
29    protected abstract String getMorphedContents(String contents);
30   
 
31  0 toggle public void executeMorph() throws IOException {
32    // Read the "old" data into a string
33  0 InputStream in = morphRequest.getInputStream();
34  0 String contents = IOUtils.toString(in, morphRequest.getEncoding());
35  0 IOUtils.closeQuietly(in);
36   
37    // May not need to morph
38  0 if (isMorphNeeded(contents)) {
39  0 contents = getMorphedContents(contents);
40    } else {
41  0 log.debug("Skipping morph on " + morphRequest.getName());
42    }
43   
44    // Write the morphed data to the output stream
45  0 OutputStream out = morphRequest.getOutputStream();
46  0 IOUtils.write(contents, out, morphRequest.getEncoding());
47  0 IOUtils.closeQuietly(out);
48    }
49   
 
50  0 toggle public MorphRequest getMorphRequest() {
51  0 return morphRequest;
52    }
53   
 
54  0 toggle public void setMorphRequest(MorphRequest morphRequest) {
55  0 this.morphRequest = morphRequest;
56    }
57   
 
58  0 toggle public String getArtifactId() {
59  0 return artifactId;
60    }
61   
 
62  0 toggle public void setArtifactId(String schema) {
63  0 this.artifactId = schema;
64    }
65   
66    }