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
13   63   10   1.44
2   40   0.77   9
9     1.11  
1    
 
  DataMorpher       Line # 5 13 0% 10 24 0% 0.0
 
No Tests
 
1    package org.apache.torque.mojo.morph;
2   
3    import org.codehaus.plexus.util.StringUtils;
4   
 
5    public class DataMorpher extends Morpher {
6    // Ant prologue
7    String antPrologue = "<?xml version=\"1.0\"?>";
8    // New prologue
9    String newPrologue = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
10   
11    // The hard coded Ant impex document type
12    String antDocType = "<!DOCTYPE dataset SYSTEM \"data.dtd\">";
13   
 
14  0 toggle public DataMorpher() {
15  0 this(null, null);
16    }
17   
 
18  0 toggle public DataMorpher(MorphRequest morphRequest, String artifactId) {
19  0 super(morphRequest, artifactId);
20    }
21   
 
22  0 toggle protected String getNewDocType() {
23  0 return "<!DOCTYPE dataset SYSTEM \"" + getArtifactId() + ".dtd\">";
24    }
25   
 
26  0 toggle protected String getMorphedContents(String contents) {
27  0 contents = StringUtils.replace(contents, antPrologue, newPrologue);
28  0 return StringUtils.replace(contents, antDocType, getNewDocType());
29    }
30   
31    /**
32    * Return true if we need to morph this file
33    */
 
34  0 toggle protected boolean isMorphNeeded(String contents) {
35    // Look for the DTD the Maven Impex Plugin uses
36  0 int pos = contents.indexOf(getNewDocType());
37   
38  0 if (pos == -1) {
39    // It isn't there so we should morph
40  0 return true;
41    } else {
42    // It is already there, we are good to go
43  0 return false;
44    }
45    }
46   
 
47  0 toggle public String getAntPrologue() {
48  0 return antPrologue;
49    }
50   
 
51  0 toggle public void setAntPrologue(String antPrologue) {
52  0 this.antPrologue = antPrologue;
53    }
54   
 
55  0 toggle public String getNewPrologue() {
56  0 return newPrologue;
57    }
58   
 
59  0 toggle public void setNewPrologue(String newPrologue) {
60  0 this.newPrologue = newPrologue;
61    }
62   
63    }