1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.geronimo.genesis.plugins.script;
21
22 import java.net.URL;
23 import java.io.File;
24
25 import org.apache.maven.plugin.MojoExecutionException;
26
27 /**
28 * Configuration for a scripts code source.
29 *
30 * @version $Rev: 463140 $ $Date: 2006-10-11 23:24:07 -0700 (Wed, 11 Oct 2006) $
31 */
32 public class CodeSource
33 {
34 private URL url = null;
35
36 private File file = null;
37
38 private String body = null;
39
40 public String toString() {
41 return "{ url: " + url +
42 ", file: " + file +
43 ", body: " + body +
44 " }";
45 }
46
47 public URL getUrl() {
48 return url;
49 }
50
51 public File getFile() {
52 return file;
53 }
54
55 public String getBody() {
56 return body;
57 }
58
59 public void validate() throws MojoExecutionException {
60 if (url == null && file == null && (body == null || body.trim().length() == 0)) {
61 throw new MojoExecutionException("Must specify one of: file, url or body");
62 }
63
64 int count = 0;
65 if (url != null) {
66 count++;
67 }
68 if (file != null) {
69 count++;
70 }
71 if (body != null) {
72 count++;
73 }
74
75 if (count != 1) {
76 throw new MojoExecutionException("Can only specify one of: file, url or body");
77 }
78 }
79 }