KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > node > OtterXMLCNode


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  *
21  */

22 package org.enhydra.kelp.common.node;
23
24 // Toolbox imports
25
import org.enhydra.tool.common.PathHandle;
26 import org.enhydra.tool.ToolBoxInfo;
27
28 // Enhydra imports
29
import org.enhydra.xml.xmlc.compiler.Parse;
30 import org.enhydra.xml.xmlc.XMLCException;
31
32 // Kelp imports
33
import org.enhydra.kelp.common.Constants;
34 import org.enhydra.kelp.common.PropUtil;
35 import org.enhydra.kelp.common.bridge.XMLCConnectionFactory;
36 import org.enhydra.kelp.common.bridge.MetaDataHandler;
37 import org.enhydra.kelp.common.map.Mapper;
38 import org.enhydra.kelp.common.node.OtterProject;
39
40 // Standard imports
41
import java.io.File JavaDoc;
42 import java.io.IOException JavaDoc;
43 import java.io.PrintWriter JavaDoc;
44 import java.lang.reflect.Constructor JavaDoc;
45 import java.lang.reflect.Method JavaDoc;
46 import java.lang.reflect.InvocationTargetException JavaDoc;
47 import java.util.ArrayList JavaDoc;
48 import java.util.Arrays JavaDoc;
49 import java.util.Vector JavaDoc;
50 import java.util.StringTokenizer JavaDoc;
51 import java.util.ResourceBundle JavaDoc;
52
53 /**
54  * Class declaration
55  *
56  *
57  * @author Paul Mahar
58  */

59 public class OtterXMLCNode implements OtterDocumentNode {
60
61     // strings not to be resourced
62
static ResourceBundle JavaDoc res =
63         ResourceBundle.getBundle("org.enhydra.kelp.common.Res"); // nores
64
private final String JavaDoc POUND = "#"; // nores
65
private final String JavaDoc DOMFACTORY = "-domfactory"; // nores
66
private final String JavaDoc IMPL = "Impl"; // nores
67

68     //
69
public final static int CLASS_NAME_DEFAULT = 1;
70     public final static int CLASS_NAME_CUSTOM = 2;
71     public final static int CLASS_NAME_MAPPED = 3;
72
73     //
74
private MetaDataHandler metaDataHandler;
75     private OtterDocumentNode docNode;
76
77     /**
78      * Create a node to use when calling XMLC.
79      *
80      */

81     public OtterXMLCNode(OtterDocumentNode d) {
82         docNode = d;
83         initMetaDataHandler();
84     }
85
86     /**
87      * Method declaration
88      *
89      *
90      * @return
91      */

92     public String JavaDoc getXMLCOptionFilePath() {
93         return docNode.getXMLCOptionFilePath();
94     }
95
96     /**
97      * Method declaration
98      *
99      *
100      * @param n
101      */

102     public void setXMLCOptionFilePath(String JavaDoc n) {
103         docNode.setXMLCOptionFilePath(n);
104     }
105
106     /**
107      * Method declaration
108      *
109      *
110      * @return
111      */

112     public String JavaDoc getXMLCParameters() {
113         String JavaDoc params = new String JavaDoc();
114         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
115         int index = -1;
116
117         params = docNode.getXMLCParameters();
118         params = PropUtil.removeQuotes(params);
119         return params;
120     }
121
122     /**
123      * Method declaration
124      *
125      *
126      * @param p
127      */

128     public void setXMLCParameters(String JavaDoc p) {
129         docNode.setXMLCParameters(p);
130     }
131
132     /**
133      * Method declaration
134      *
135      *
136      * @return
137      */

138     public boolean isSelected() {
139         return docNode.isSelected();
140     }
141
142     /**
143      * Method declaration
144      *
145      *
146      * @param b
147      */

148     public void setSelected(boolean b) {
149         docNode.setSelected(b);
150         if (b) {
151             setStatic(false);
152         }
153     }
154
155     public boolean isStatic() {
156         return docNode.isStatic();
157     }
158
159     public void setStatic(boolean b) {
160         docNode.setStatic(b);
161         if (b) {
162             setSelected(false);
163         }
164     }
165
166     /**
167      * Method declaration
168      *
169      *
170      * @return
171      */

172     public String JavaDoc getFilePath() {
173         return docNode.getFilePath();
174     }
175
176     /**
177      * Method declaration
178      *
179      *
180      * @return
181      */

182     public String JavaDoc getCustomClassName() {
183         String JavaDoc custom = getProperty(PropertyKeys.NAME_XMLC_CUSTOM);
184
185         if (custom == null) {
186             custom = new String JavaDoc();
187         }
188         return custom;
189     }
190
191     /**
192      * Method declaration
193      *
194      *
195      * @param n
196      */

197     public void setCustomClassName(String JavaDoc n) {
198         setProperty(PropertyKeys.NAME_XMLC_CUSTOM, n);
199     }
200
201     /**
202      * Method declaration
203      *
204      *
205      * @return
206      */

207     public Object JavaDoc getNativeNode() {
208         return docNode.getNativeNode();
209     }
210
211     /**
212      * Method declaration
213      *
214      *
215      * @param o
216      */

217     public void setNativeNode(Object JavaDoc o) {
218         docNode.setNativeNode(o);
219     }
220
221     /**
222      * Method declaration
223      *
224      *
225      * @return
226      */

227     public OtterProject getProject() {
228         return docNode.getProject();
229     }
230
231     /**
232      * Method declaration
233      *
234      *
235      * @param n
236      *
237      * @return
238      */

239     public String JavaDoc getProperty(String JavaDoc n) {
240         return docNode.getProperty(n);
241     }
242
243     /**
244      * Method declaration
245      *
246      *
247      * @param n
248      * @param v
249      */

250     public void setProperty(String JavaDoc n, String JavaDoc v) {
251         docNode.setProperty(n, v);
252     }
253
254     /**
255      * Method declaration
256      *
257      *
258      * @param n
259      * @param v
260      */

261     public void setProperty(String JavaDoc n, int v) {
262         docNode.setProperty(n, v);
263     }
264
265     /**
266      * Method declaration
267      *
268      *
269      * @return
270      */

271     public int getClassNameType() {
272
273         // When getting the project scope overrides
274
// local type.
275
int type;
276         int projectScope;
277         String JavaDoc stringType = getProperty(PropertyKeys.NAME_XMLC_TYPE);
278
279         projectScope = getProject().getMapScope();
280         type = PropUtil.stringToInt(stringType, CLASS_NAME_MAPPED);
281         switch (type) {
282         case CLASS_NAME_DEFAULT:
283         case CLASS_NAME_CUSTOM:
284             if (projectScope == OtterProject.MAP_SCOPE_ALL) {
285                 type = CLASS_NAME_MAPPED;
286                 setProperty(PropertyKeys.NAME_XMLC_TYPE, type);
287             }
288             break;
289         case CLASS_NAME_MAPPED:
290             if (projectScope == OtterProject.MAP_SCOPE_NONE) {
291                 type = CLASS_NAME_DEFAULT;
292                 setProperty(PropertyKeys.NAME_XMLC_TYPE, type);
293             }
294             break;
295         }
296         return type;
297     }
298
299     /**
300      * Method declaration
301      *
302      *
303      * @param newType
304      */

305     public void setClassNameType(int newType) {
306
307         // If conflict exists with project scope,
308
// change project scope.
309
int oldType = getClassNameType();
310         int projectScope = getProject().getMapScope();
311
312         setProperty(PropertyKeys.NAME_XMLC_TYPE, newType);
313         syncProjectToType(newType);
314         if ((newType != oldType)
315                 || (newType == OtterXMLCNode.CLASS_NAME_MAPPED)) {
316             initClassName();
317         }
318     }
319
320     /**
321      * Method declaration
322      *
323      *
324      * @param forPrint
325      *
326      * @return
327      */

328     private String JavaDoc[] getAllParameters(boolean forPrint) {
329         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
330         String JavaDoc[] parameters = new String JavaDoc[0];
331         StringTokenizer JavaDoc tokenizer = null;
332         int count = 0;
333         int index = 0;
334
335         // File - Node
336
if (getXMLCParameters() != null) {
337             buf.append(getXMLCParameters().trim());
338         }
339         if (forPrint) {
340             buf.append('#');
341         } else {
342             buf.append(' ');
343         }
344
345         // Package - Folder
346
OtterNode packNode = null;
347         String JavaDoc packParam = new String JavaDoc();
348
349         packNode = docNode.getParent();
350         if (packNode == null || packNode instanceof OtterProject) {
351
352             // skip it.
353
} else {
354             packParam = packNode.getXMLCParameters();
355         }
356         if ((packParam != null) && (packParam.trim().length() > 0)) {
357             buf.append(packParam);
358             if (forPrint) {
359                 buf.append('#');
360             } else {
361                 buf.append(' ');
362             }
363         }
364
365         // Project
366
if (docNode.getProject().getXMLCParameters() != null) {
367             buf.append(docNode.getProject().getXMLCParameters().trim());
368         }
369         if (forPrint) {
370             tokenizer = new StringTokenizer JavaDoc(buf.toString().trim(), POUND);
371         } else {
372             tokenizer = new StringTokenizer JavaDoc(buf.toString().trim());
373         }
374         count = tokenizer.countTokens();
375         parameters = new String JavaDoc[tokenizer.countTokens()];
376         while (tokenizer.hasMoreTokens()) {
377             parameters[index] = tokenizer.nextToken();
378             index++;
379         }
380
381         // Add domFactory if required
382
parameters = addDomFactory(parameters);
383         return parameters;
384     }
385
386     private String JavaDoc[] addDomFactory(String JavaDoc[] in) {
387         PathHandle path = null;
388         String JavaDoc[] out = in;
389         ArrayList JavaDoc list = null;
390         boolean found = false;
391
392         path = PathHandle.createPathHandle(docNode.getFilePath());
393         for (int i = 0; i < in.length; i++) {
394             if (in[i].trim().equalsIgnoreCase(DOMFACTORY)) {
395                 found = true;
396                 break;
397             }
398         }
399         if (found) {
400
401             // don't overwride
402
} else if (path.hasExtension(Constants.TYPE_HTML)
403                    || path.hasExtension(Constants.TYPE_HTM)) {
404
405             // use default
406
} else if (path.hasExtension(Constants.TYPE_WML)
407                    && ToolBoxInfo.isClassAvailable(ToolBoxInfo.WML_FACTORY)) {
408             list = new ArrayList JavaDoc(Arrays.asList(in));
409             list.add(DOMFACTORY);
410             list.add(ToolBoxInfo.WML_FACTORY);
411             out = (String JavaDoc[]) list.toArray(out);
412         } else if (path.hasExtension(Constants.TYPE_CHTML)
413                    && ToolBoxInfo.isClassAvailable(ToolBoxInfo.CHTML_FACTORY)) {
414             list = new ArrayList JavaDoc(Arrays.asList(in));
415             list.add(DOMFACTORY);
416             list.add(ToolBoxInfo.CHTML_FACTORY);
417             out = (String JavaDoc[]) list.toArray(out);
418         } else if (path.hasExtension(Constants.TYPE_XHTML)
419                    && ToolBoxInfo.isClassAvailable(ToolBoxInfo.XHTML_FACTORY)) {
420             list = new ArrayList JavaDoc(Arrays.asList(in));
421             list.add(DOMFACTORY);
422             list.add(ToolBoxInfo.XHTML_FACTORY);
423             out = (String JavaDoc[]) list.toArray(out);
424         }
425         return out;
426     }
427
428     /**
429      * Method declaration
430      *
431      *
432      * @return
433      */

434     private String JavaDoc[] getAllOptionFilenames() {
435         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
436         File JavaDoc file = null;
437         PathHandle handle = null;
438         String JavaDoc filename = new String JavaDoc();
439         String JavaDoc[] filenames = new String JavaDoc[0];
440         StringTokenizer JavaDoc tokenizer = null;
441         int count = 0;
442         int index = 0;
443
444         // Project
445
handle =
446             PathHandle.createPathHandle(docNode.getProject().getXMLCOptionFilePath());
447         if (handle.isFile() && handle.hasExtension(Constants.TYPE_XMLC)) {
448             buf.append(handle.getPath());
449         }
450
451         // Package
452
OtterNode parent = docNode.getParent();
453
454         if (parent == null || parent instanceof OtterProject) {
455
456             // skip it
457
} else {
458             handle =
459                 PathHandle.createPathHandle(parent.getXMLCOptionFilePath());
460             if (handle.isFile() && handle.hasExtension(Constants.TYPE_XMLC)) {
461                 buf.append('#');
462                 buf.append(handle.getPath());
463             }
464         }
465         buf.append('#');
466
467         // Node
468
handle = PathHandle.createPathHandle(getXMLCOptionFilePath());
469         if (handle.isFile() && handle.hasExtension(Constants.TYPE_XMLC)) {
470             buf.append(handle.getPath());
471         }
472         tokenizer = new StringTokenizer JavaDoc(buf.toString().trim(), POUND);
473         count = tokenizer.countTokens();
474         filenames = new String JavaDoc[tokenizer.countTokens()];
475         while (tokenizer.hasMoreTokens()) {
476             filenames[index] = tokenizer.nextToken();
477             index++;
478         }
479         return filenames;
480     }
481
482     /**
483      * Method declaration
484      *
485      *
486      * @param type
487      */

488     private void syncProjectToType(int type) {
489         int projectScope = getProject().getMapScope();
490
491         switch (type) {
492         case CLASS_NAME_CUSTOM:
493         case CLASS_NAME_DEFAULT:
494             if (projectScope == OtterProject.MAP_SCOPE_ALL) {
495                 getProject().setMapScope(OtterProject.MAP_SCOPE_SELECTED);
496             }
497             break;
498         case CLASS_NAME_MAPPED:
499             if (projectScope == OtterProject.MAP_SCOPE_NONE) {
500                 getProject().setMapScope(OtterProject.MAP_SCOPE_SELECTED);
501             }
502             break;
503         }
504     }
505
506     /**
507      * Save Exception information for reporting. This lets exceptions from
508      * multiple nodes to be reported in a batch.
509      *
510      * @param e
511      * An exception that occured while invoking XMLC.
512      */

513     public void setException(Throwable JavaDoc e) {
514         if (e == null) {
515             docNode.setException(null);
516         } else {
517             docNode.setException(new LocalException(e));
518         }
519     }
520
521     /**
522      * Get an exception that occured when invoking XMLC. Null if the node
523      * has not been compiled or was compiled without error.
524      */

525     public Throwable JavaDoc getException() {
526         return docNode.getException();
527     }
528
529     public OtterNode getParent() {
530         return docNode.getParent();
531     }
532
533     public void save() {
534         docNode.save();
535     }
536
537     /**
538      * Get the XMLC options selected this HTML/WML file.
539      */

540     public MetaDataHandler getMetaDataHandler() {
541         return metaDataHandler;
542     }
543
544     /**
545      * Add the generated Java source file to the IDE project. Do not call
546      * this when using Win32 JBuilder as it can't handle the width of source
547      * lines generated by XMLC.
548      */

549     public void replaceGeneratedSource(boolean forRecomp) {
550         if ((metaDataHandler.getJavaClassSource().exists())
551                 && (getProject().isOpenBuild())) {
552             int count = 1;
553
554             if (forRecomp) {
555                 count = 2;
556             }
557             String JavaDoc[] source = new String JavaDoc[count];
558             OtterNodeFactory factory = null;
559
560             source[0] =
561                 metaDataHandler.getJavaClassSource().getAbsolutePath();
562             factory = getProject().getNodeFactory();
563             if (forRecomp) {
564                 source[1] =
565                     metaDataHandler.getJavaInterfaceSource().getAbsolutePath();
566             }
567             factory.replaceGeneratedSource(getProject(), docNode, source);
568         }
569     }
570
571     /**
572      * Method declaration
573      *
574      */

575     public void initProjectOptions() {
576         metaDataHandler.setKeepGeneratedSource(true); // always keep Java source
577
metaDataHandler.setCompileSource(false); // never compile Java source
578
setXMLCOptionFilePath(docNode.getProject().getSourcePath()+getResourceRelativePath()+"/resources/options.xmlc");
579         // loging options
580
metaDataHandler.setPrintAccessorInfo(getProject().isPrintAccessorInfo());
581         metaDataHandler.setPrintDocumentInfo(getProject().isPrintDocumentInfo());
582         metaDataHandler.setPrintDOM(getProject().isPrintDOM());
583         metaDataHandler.setPrintParseInfo(getProject().isPrintParseInfo());
584         metaDataHandler.setVerbose(getProject().isVerbose());
585
586         // Call XMLC with the do not call javac option.
587
}
588
589     public String JavaDoc getGenerateToRoot() {
590         String JavaDoc projectGenTo = getProject().getGenerateToDirectory();
591         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
592
593         if (projectGenTo == null) {
594             buf.append(docNode.getProject().getSourcePathOf(docNode));
595         } else {
596             buf.append(projectGenTo);
597         }
598         return buf.toString();
599     }
600
601     /**
602      * Initialize the XMLC options.
603      *
604      * @throws XMLCException
605      * Thrown when options are invalid.
606      *
607      */

608     private void initMetaDataHandler() {
609         metaDataHandler = XMLCConnectionFactory.createMetaDataHandler();
610         initClassName();
611         initProjectOptions();
612         metaDataHandler.setInputDocument(getFilePath());
613         initJavaSourceFile();
614     }
615
616     /**
617      * Method declaration
618      *
619      *
620      * @exception IOException
621      * @exception XMLCException
622      */

623     private void parseOptions() throws XMLCException, IOException JavaDoc {
624         metaDataHandler.parse(getAllOptionFilenames(),
625                               getAllParameters(false), (PrintWriter JavaDoc) null,
626                               this);
627     }
628
629     /**
630      * Method declaration
631      *
632      */

633     private void initJavaSourceFile() {
634         StringBuffer JavaDoc filename = new StringBuffer JavaDoc();
635         String JavaDoc className = new String JavaDoc();
636         String JavaDoc packageName = new String JavaDoc();
637         File JavaDoc source = null;
638         int index = -1;
639
640         filename.append(getGenToDirectory().toString());
641         filename.append(File.separator);
642         className = metaDataHandler.getClassName();
643         packageName = metaDataHandler.getPackageName();
644         if ((packageName == null) || (packageName.trim().length() == 0)) {
645             index = -1;
646         } else {
647             index = className.indexOf(packageName);
648         }
649         if (index > -1) {
650             className =
651                 className.substring(metaDataHandler.getPackageName().length()
652                                     + 1);
653         }
654         index = className.lastIndexOf('.');
655         if (index > -1) {
656             className = className.substring(index + 1);
657         }
658         filename.append(className);
659         filename.append('.');
660         filename.append(Constants.TYPE_JAVA);
661         source = new File JavaDoc(filename.toString());
662         metaDataHandler.setJavaClassSource(source, this);
663     }
664
665     /**
666      * Get the generate to directory and create the directory if needed.
667      * This is where the Java source files are created.
668      */

669     private File JavaDoc getGenToDirectory() {
670         String JavaDoc genTo = getGenToPath();
671         File JavaDoc genDir = new File JavaDoc(genTo);
672
673         if (genDir.exists()) {
674             if (!genDir.isDirectory()) {
675                 System.err.println(res.getString("Unable_to_write") + genTo);
676             }
677         } else {
678             genDir.mkdirs();
679         }
680         return genDir;
681     }
682
683     /**
684      * Get the generate to directory as a string. This is where XMLC will create
685      * Java source files.
686      */

687     private String JavaDoc getGenToPath() {
688         String JavaDoc packagePath = getPackagePath();
689         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
690
691         buf.append(getGenerateToRoot());
692         if (packagePath.length() > 0) {
693             buf.append(File.separator);
694             buf.append(packagePath);
695         }
696         return buf.toString();
697     }
698
699     /**
700      * Method declaration
701      *
702      *
703      * @return
704      */

705     private String JavaDoc getPackagePath() {
706         String JavaDoc packPath = new String JavaDoc();
707
708         if (metaDataHandler.getPackageName() != null) {
709             packPath = metaDataHandler.getPackageName();
710         } else if (metaDataHandler.getClassName() != null) {
711             int index = metaDataHandler.getClassName().lastIndexOf('.');
712
713             if (index > -1) {
714                 packPath = metaDataHandler.getClassName().substring(0, index);
715             }
716         }
717         packPath = packPath.replace('.', File.separatorChar);
718         return packPath;
719     }
720
721     /**
722      * Create a class name for the given HTML/WML file and map the
723      * package name as needed. Mapping allows users to specify
724      * a package name to use for all the HTML/WML files in a directory.
725      */

726     private void initClassName() {
727         Mapper mapper = new Mapper(getProject());
728         String JavaDoc className = mapper.getClassName(this);
729
730         metaDataHandler.setClassName(className);
731     }
732
733     private String JavaDoc getResourceRelativePath() {
734         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
735         String JavaDoc path = new String JavaDoc();
736
737         buf.append(File.separator);
738           path = metaDataHandler.getPackageName();
739           int index = path.lastIndexOf("presentation");
740           if(index !=-1) {
741                 path = path.substring(0,index-1);
742           }
743         path = path.replace('.', File.separatorChar);
744         buf.append(path);
745         return buf.toString();
746     }
747
748
749     private String JavaDoc baseOut() {
750         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
751         String JavaDoc path = new String JavaDoc();
752
753         buf.append(getProject().getClassOutputPath());
754         buf.append(File.separator);
755         path = metaDataHandler.getClassName();
756         path = path.replace('.', File.separatorChar);
757         buf.append(path);
758         return buf.toString();
759     }
760
761     /**
762      * Get the class file that we expect after XMLC has generated
763      * a java file and called javac to compile it.
764      */

765     public File JavaDoc getClassFile() {
766         File JavaDoc file = null;
767         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
768
769         buf.append(baseOut());
770         buf.append('.');
771         buf.append(Constants.TYPE_CLASS);
772         file = new File JavaDoc(buf.toString());
773         return file;
774     }
775
776     public File JavaDoc getOptionFileForRecomp() {
777         File JavaDoc file = null;
778         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
779
780         buf.append(baseOut());
781         buf.append('.');
782         buf.append(Constants.TYPE_XMLC);
783         file = new File JavaDoc(buf.toString());
784         return file;
785     }
786
787     /**
788      * True if we can find the Java source file that we expect XMLC to create.
789      * This is used to in reporting compilation results.
790      */

791     public boolean isNewJavaFound() {
792         boolean newFound = false;
793
794         if (metaDataHandler.getKeepGeneratedSource()) {
795             newFound = metaDataHandler.getJavaClassSource().exists();
796         }
797         return newFound;
798     }
799
800     /**
801      * Method declaration
802      *
803      *
804      * @exception IOException
805      * @exception XMLCException
806      */

807     public void preCompile() throws XMLCException, IOException JavaDoc {
808         parseOptions();
809
810         // clear out any existing impl or standard classes.
811
File JavaDoc implSource = null;
812         StringBuffer JavaDoc implName = new StringBuffer JavaDoc();
813         int index = -1;
814
815         implName.append(metaDataHandler.getJavaClassSource());
816         index = implName.toString().lastIndexOf('.');
817         implName.insert(index, IMPL);
818         implSource = new File JavaDoc(implName.toString());
819         if (implSource.exists()) {
820             implSource.delete();
821         }
822         if (metaDataHandler.getJavaClassSource().exists()) {
823             metaDataHandler.getJavaClassSource().delete();
824         }
825
826         // reset names if needed
827
if (metaDataHandler.getRecompilation()) {
828             metaDataHandler.setJavaInterfaceSource(metaDataHandler.getJavaClassSource(),
829                                                    this);
830             metaDataHandler.setJavaClassSource(implSource, this);
831         }
832         docNode.preCompile();
833     }
834
835     /**
836      * Class declaration
837      *
838      * @author Paul Mahar
839      */

840     class LocalException extends Exception JavaDoc {
841         private Throwable JavaDoc baseException = null;
842
843         /**
844          * Constructor declaration
845          *
846          *
847          * @param e
848          */

849         public LocalException(Throwable JavaDoc e) {
850             baseException = e;
851         }
852
853         /**
854          * Method declaration
855          *
856          *
857          * @return
858          */

859         public String JavaDoc getMessage() {
860             StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
861             String JavaDoc[] parameters = getAllParameters(true);
862             String JavaDoc[] filenames = getAllOptionFilenames();
863
864             buf.append(baseException.getMessage());
865             buf.append('\n');
866             if (parameters.length >= 1) {
867                 buf.append(Constants.TAB2);
868                 buf.append(res.getString("Command_line"));
869                 buf.append('\n');
870                 for (int i = 0; i < parameters.length; i++) {
871                     buf.append(Constants.TAB4);
872                     buf.append(parameters[i]);
873                     buf.append('\n');
874                 }
875             }
876             if (filenames.length >= 1) {
877                 buf.append(Constants.TAB2);
878                 if (filenames.length >= 2) {
879                     buf.append(res.getString("Option_files"));
880                 } else {
881                     buf.append(res.getString("Option_file"));
882                 }
883                 buf.append('\n');
884                 for (int i = 0; i < filenames.length; i++) {
885                     buf.append(Constants.TAB4);
886                     buf.append(filenames[i]);
887                 }
888             }
889             return buf.toString().trim();
890         }
891
892     }
893 }
894
Popular Tags