KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > gen > AntClassGenerator


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20
21 package org.apache.cayenne.gen;
22
23 import java.io.File JavaDoc;
24
25 import org.apache.tools.ant.Task;
26
27 /**
28  * Ant-specific extension of DefaultClassGenerator that provides logging
29  * functions.
30  *
31  * @author Andrus Adamchik
32  */

33 public class AntClassGenerator extends DefaultClassGenerator {
34
35     protected Task parentTask;
36
37     protected File JavaDoc fileForSuperclass(String JavaDoc pkgName, String JavaDoc className)
38             throws Exception JavaDoc {
39
40         File JavaDoc outFile = super.fileForSuperclass(pkgName, className);
41         if (outFile != null) {
42             parentTask.log("Generating superclass file: " + outFile.getCanonicalPath());
43         }
44         
45         return outFile;
46     }
47
48     protected File JavaDoc fileForClass(String JavaDoc pkgName, String JavaDoc className)
49             throws Exception JavaDoc {
50
51         File JavaDoc outFile = super.fileForClass(pkgName, className);
52         if (outFile != null) {
53             parentTask.log("Generating class file: "
54                     + outFile.getCanonicalPath());
55         }
56         return outFile;
57     }
58
59     public Task getParentTask() {
60         return parentTask;
61     }
62
63     /**
64      * Sets the Ant task that uses this generator.
65      *
66      * @param parentTask An Ant task that provides Ant context to this generator.
67      */

68     public void setParentTask(Task parentTask) {
69         this.parentTask = parentTask;
70     }
71 }
72
Popular Tags