KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > forte > services > XMLCCompiler


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  * Lisa Reese
21  *
22  */

23
24 package org.enhydra.kelp.forte.services;
25
26 import java.util.*;
27
28 import org.openide.compiler.*;
29 import org.openide.compiler.Compiler;
30 import org.openide.execution.NbProcessDescriptor;
31 import org.openide.filesystems.FileObject;
32 import org.openide.filesystems.FileUtil;
33
34 public class XMLCCompiler extends ExternalCompiler {
35
36     private boolean building;
37     private String JavaDoc myOpt; //options to pass???
38

39         /** Value of my compiler type */
40     private XMLCCompilerType myType;
41
42     /** Type of compilation */
43 // protected Object type;
44

45     /** Target filesystem, initially null.
46      */

47  // private FileSystem target;
48

49     /** @return XMLCCompilerType
50     */

51     XMLCCompilerType getMyType() {
52         return myType;
53     }
54
55     /** Create an external compiler.
56     * @param fo a file to compile
57     * @param type the type of compilation ({@link #COMPILE}, {@link #BUILD}, or {@link #CLEAN})
58     * @param nbDescriptor a description of an external compiler executable
59     * @param err a regular expression to scan for compiler errors
60     * @exception IllegalArgumentException if the file object is invalid
61     */

62 /* public XMLCCompiler(FileObject fo, Object type,
63         NbProcessDescriptor nbDescriptor, ErrorExpression err,
64         XMLCCompilerType ctype, FileSystem targetFS) {
65         super (fo, type, nbDescriptor, err);
66         this.myType = ctype;
67         this.type = type;
68         this.target = targetFS;
69     }*/

70
71     public XMLCCompiler(boolean building, FileObject primFile, NbProcessDescriptor compiler, ExternalCompiler.ErrorExpression errExpr, String JavaDoc myOpt) {
72         super (primFile, building ? BUILD : COMPILE, compiler, errExpr);
73         this.building = building;
74         this.myOpt = myOpt; //???
75
}
76
77     /** @return <tt>true</tt> if the compilers are equal */
78 /* public boolean equals(Object o) {
79         if (o instanceof XMLCCompiler) {
80             JExternalCompiler him = (JExternalCompiler) o;
81             return (super.equals(o) &&
82                     (him.getFileObject() == getFileObject()) &&
83                     (him.myType == myType));
84         } else {
85             return false;
86         }
87     } */

88
89     // This is important to write correctly!
90
public boolean equals (Object JavaDoc o) {
91         if (! super.equals (o)) return false;
92         if (! (o instanceof XMLCCompiler)) return false;
93         XMLCCompiler other = (XMLCCompiler) o;
94         // Add any other equality comparisons you may need,
95
// according to the instance variables:
96
return myOpt.equals (other.myOpt) &&
97                building == other.building;
98     }
99
100     // Also, this must be the same for equal compilers!
101
public int hashCode () {
102         return 9876 ^ getFileObject ().getPackageNameExt ('/', '.').hashCode ();
103     }
104
105     // Store this information for use by the compiler group.
106
public String JavaDoc getMyOpt () {
107         return myOpt;
108     }
109
110     public boolean isUpToDate () {
111         // Always recompile when building.
112
if (building) return false;
113         // Otherwise, check neighboring files, e.g., for an extension
114
// produced only by the compiler.
115
FileObject fo = getFileObject ();
116         FileObject compiled = FileUtil.findBrother (fo, "compiledExt");
117         // If no compiled file, then of course it is not up-to-date.
118
if (compiled == null) return false;
119         // Else, check timestamps.
120
return compiled.lastModified ().after (fo.lastModified ());
121     }
122
123     // Just specify the kind of compiler group to use. Its default constructor will be called.
124
public Class JavaDoc compilerGroupClass () {
125         return XMLCCompilerGroup.class;
126     }
127
128     // Make sure these compilers are split into separate groups if they do not
129
// agree on the value of myOpt.
130
public Object JavaDoc compilerGroupKey () {
131         List l = new ArrayList (2);
132         l.add (super.compilerGroupKey ());
133         l.add (getMyOpt ());
134         return l;
135     }
136
137 }
138
Popular Tags