KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > tools > doclets > standard > ConfigurationStandard


1 /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the debugger and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  */

22
23 package org.aspectj.tools.doclets.standard;
24
25 import com.sun.javadoc.RootDoc;
26 import com.sun.tools.doclets.MessageRetriever;
27
28 import java.io.IOException JavaDoc;
29 import java.net.URL JavaDoc;
30 import java.util.Locale JavaDoc;
31 import java.util.MissingResourceException JavaDoc;
32 import java.util.PropertyResourceBundle JavaDoc;
33 import java.util.ResourceBundle JavaDoc;
34
35 /**
36  * A customized configuration.
37  *
38  * @author Jeff Palm
39  */

40 public class ConfigurationStandard
41     extends com.sun.tools.doclets.standard.ConfigurationStandard
42 {
43     
44     /** It true we don't print crosscut information. */
45     public boolean nocrosscuts = false;
46
47     /** If true we don't print crosscut summary information. */
48     public boolean nosummarycrosscuts = false;
49
50     /** If true we log each pass in the doclet. */
51     public boolean log = false;
52     
53     public ConfigurationStandard() {
54 // standardmessage = new MessageRetriever
55
// ("org.aspectj.tools.doclets.standard.resources.standard");
56

57         String JavaDoc loc = "org.aspectj.tools.doclets.standard.resources.standard";
58         final ClassLoader JavaDoc loader = getClass().getClassLoader();
59         // XXX move persistant resource loader to util
60
ResourceBundle JavaDoc bundle = null;
61         for (int i = 0; ((null == bundle) && (i < 4)); i++) {
62             
63             try {
64                 switch (i) {
65                     case 0:
66                         bundle = ResourceBundle.getBundle(loc);
67                         standardmessage = new MessageRetriever(bundle);
68                     break;
69                     case 1:
70                         Locale JavaDoc locale = Locale.getDefault();
71                         bundle = ResourceBundle.getBundle(loc, locale, loader);
72                         standardmessage = new MessageRetriever(bundle);
73                     break;
74                     case 2:
75                         standardmessage = new MessageRetriever(loc);
76                     break;
77                     case 3:
78                         URL JavaDoc pURL = loader.getResource(loc + ".properties");
79                         bundle = new PropertyResourceBundle JavaDoc(pURL.openStream());
80                         standardmessage = new MessageRetriever(loc);
81                     break;
82                 }
83                 break; // from for loop
84
} catch (MissingResourceException JavaDoc e) { } // error below
85
catch (IOException JavaDoc ie) { } // error below
86
}
87         if (null == bundle) {
88             throw new Error JavaDoc("unable to load resource: " + loc);
89         }
90     }
91     
92     //TODO: Document the new options in help
93

94     public void setSpecificDocletOptions(RootDoc root) {
95         String JavaDoc[][] options = root.options();
96         for (int i = 0; i < options.length; ++i) {
97             String JavaDoc opt = options[i][0].toLowerCase();
98             if (opt.equals("-nocrosscuts")) {
99                 nocrosscuts = true;
100                 nosummarycrosscuts = true;
101             } else if (opt.equals("-nosummarycrosscuts")) {
102                 nosummarycrosscuts = true;
103             } else if (opt.equals("-log")) {
104                 log = true;
105             }
106         }
107         super.setSpecificDocletOptions(root);
108     }
109
110     public int specificDocletOptionLength(String JavaDoc opt) {
111         if (opt.equals("-nocrosscuts") ||
112             opt.equals("-nosummarycrosscuts") ||
113             opt.equals("-log")) {
114             return 1;
115         }
116         return super.specificDocletOptionLength(opt);
117     }
118 }
119         
120
121
Popular Tags