source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 4.1 KB
Line 
1/*
2 * Copyright 2001-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
19
20import java.io.File;
21import java.util.Enumeration;
22import java.util.Vector;
23import org.apache.tools.ant.Project;
24import org.apache.tools.ant.taskdefs.optional.jsp.JspC;
25import org.apache.tools.ant.types.CommandlineJava;
26
27/**
28 * This is the default implementation for the JspCompilerAdapter interface.
29 * This is currently very light on the ground since only one compiler type is
30 * supported.
31 *
32 */
33public abstract class DefaultJspCompilerAdapter
34 implements JspCompilerAdapter {
35
36 private static String lSep = System.getProperty("line.separator");
37
38 /**
39 * Logs the compilation parameters, adds the files to compile and logs the
40 * "niceSourceList"
41 */
42 protected void logAndAddFilesToCompile(JspC jspc,
43 Vector compileList,
44 CommandlineJava cmd) {
45 jspc.log("Compilation " + cmd.describeJavaCommand(),
46 Project.MSG_VERBOSE);
47
48 StringBuffer niceSourceList = new StringBuffer("File");
49 if (compileList.size() != 1) {
50 niceSourceList.append("s");
51 }
52 niceSourceList.append(" to be compiled:");
53
54 niceSourceList.append(lSep);
55
56 Enumeration e = compileList.elements();
57 while (e.hasMoreElements()) {
58 String arg = (String) e.nextElement();
59 cmd.createArgument().setValue(arg);
60 niceSourceList.append(" " + arg + lSep);
61 }
62
63 jspc.log(niceSourceList.toString(), Project.MSG_VERBOSE);
64 }
65
66 /**
67 * our owner
68 */
69 protected JspC owner;
70
71 /**
72 * set the owner
73 */
74 public void setJspc(JspC owner) {
75 this.owner = owner;
76 }
77
78 /** get the owner
79 * @return the owner; should never be null
80 */
81 public JspC getJspc() {
82 return owner;
83 }
84
85
86 /**
87 * add an argument oneple to the argument list, if the value aint null
88 *
89 * @param argument The argument
90 */
91 protected void addArg(CommandlineJava cmd, String argument) {
92 if (argument != null && argument.length() != 0) {
93 cmd.createArgument().setValue(argument);
94 }
95 }
96
97
98 /**
99 * add an argument tuple to the argument list, if the value aint null
100 *
101 * @param argument The argument
102 * @param value the parameter
103 */
104 protected void addArg(CommandlineJava cmd, String argument, String value) {
105 if (value != null) {
106 cmd.createArgument().setValue(argument);
107 cmd.createArgument().setValue(value);
108 }
109 }
110
111 /**
112 * add an argument tuple to the arg list, if the file parameter aint null
113 *
114 * @param argument The argument
115 * @param file the parameter
116 */
117 protected void addArg(CommandlineJava cmd, String argument, File file) {
118 if (file != null) {
119 cmd.createArgument().setValue(argument);
120 cmd.createArgument().setFile(file);
121 }
122 }
123
124 /**
125 * ask if compiler can sort out its own dependencies
126 * @return true if the compiler wants to do its own
127 * depends
128 */
129 public boolean implementsOwnDependencyChecking() {
130 return false;
131 }
132
133 /**
134 * get our project
135 * @return owner project data
136 */
137 public Project getProject() {
138 return getJspc().getProject();
139 }
140}
141
Note: See TracBrowser for help on using the repository browser.