| 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 |
|
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 8 |
Complexity Density: 0.47 |
|
| 11 |
|
public abstract class Morpher { |
| 12 |
|
private static final Log log = LogFactory.getLog(Morpher.class); |
| 13 |
|
|
| 14 |
|
MorphRequest morphRequest; |
| 15 |
|
String artifactId; |
| 16 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 17 |
0
|
public Morpher() {... |
| 18 |
0
|
this(null, null); |
| 19 |
|
} |
| 20 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 21 |
0
|
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 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
| 31 |
0
|
public void executeMorph() throws IOException {... |
| 32 |
|
|
| 33 |
0
|
InputStream in = morphRequest.getInputStream(); |
| 34 |
0
|
String contents = IOUtils.toString(in, morphRequest.getEncoding()); |
| 35 |
0
|
IOUtils.closeQuietly(in); |
| 36 |
|
|
| 37 |
|
|
| 38 |
0
|
if (isMorphNeeded(contents)) { |
| 39 |
0
|
contents = getMorphedContents(contents); |
| 40 |
|
} else { |
| 41 |
0
|
log.debug("Skipping morph on " + morphRequest.getName()); |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
|
| 45 |
0
|
OutputStream out = morphRequest.getOutputStream(); |
| 46 |
0
|
IOUtils.write(contents, out, morphRequest.getEncoding()); |
| 47 |
0
|
IOUtils.closeQuietly(out); |
| 48 |
|
} |
| 49 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 50 |
0
|
public MorphRequest getMorphRequest() {... |
| 51 |
0
|
return morphRequest; |
| 52 |
|
} |
| 53 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 54 |
0
|
public void setMorphRequest(MorphRequest morphRequest) {... |
| 55 |
0
|
this.morphRequest = morphRequest; |
| 56 |
|
} |
| 57 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 58 |
0
|
public String getArtifactId() {... |
| 59 |
0
|
return artifactId; |
| 60 |
|
} |
| 61 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 62 |
0
|
public void setArtifactId(String schema) {... |
| 63 |
0
|
this.artifactId = schema; |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
} |