source: src/main/java/weka/core/AllJavadoc.java @ 8

Last change on this file since 8 was 4, checked in by gnappo, 14 years ago

Import di weka.

File size: 4.3 KB
Line 
1/*
2 *    This program is free software; you can redistribute it and/or modify
3 *    it under the terms of the GNU General Public License as published by
4 *    the Free Software Foundation; either version 2 of the License, or
5 *    (at your option) any later version.
6 *
7 *    This program is distributed in the hope that it will be useful,
8 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *    GNU General Public License for more details.
11 *
12 *    You should have received a copy of the GNU General Public License
13 *    along with this program; if not, write to the Free Software
14 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17/*
18 * AllJavadoc.java
19 * Copyright (C) 2006 University of Waikato, Hamilton, New Zealand
20 */
21
22package weka.core;
23
24import java.util.HashSet;
25import java.util.Vector;
26
27/**
28 * Applies all known Javadoc-derived classes to a source file.
29 *
30 <!-- options-start -->
31 * Valid options are: <p/>
32 *
33 * <pre> -W &lt;classname&gt;
34 *  The class to load.</pre>
35 *
36 * <pre> -nostars
37 *  Suppresses the '*' in the Javadoc.</pre>
38 *
39 * <pre> -dir &lt;dir&gt;
40 *  The directory above the package hierarchy of the class.</pre>
41 *
42 * <pre> -silent
43 *  Suppresses printing in the console.</pre>
44 *
45 <!-- options-end -->
46 *
47 * @author  fracpete (fracpete at waikato dot ac dot nz)
48 * @version $Revision: 6111 $
49 */
50public class AllJavadoc
51  extends Javadoc {
52
53  /** contains all the  */
54  protected static Vector<Javadoc> m_Javadocs;
55 
56  /** determine all classes derived from Javadoc and instantiate them */
57  static {
58    // get all classnames, besides this one
59    HashSet<String> set = new HashSet<String>(ClassDiscovery.find(Javadoc.class, Javadoc.class.getPackage().getName()));
60    if (set.contains(AllJavadoc.class.getName()))
61      set.remove(AllJavadoc.class.getName());
62   
63    // instantiate them
64    m_Javadocs = new Vector<Javadoc>();
65    for (String classname: set) {
66      try {
67        Class cls = Class.forName(classname);
68        m_Javadocs.add((Javadoc)cls.newInstance());
69      }
70      catch (Exception e) {
71        e.printStackTrace();
72      }
73    }
74  }
75 
76  /**
77   * sets the classname of the class to generate the Javadoc for
78   *
79   * @param value       the new classname
80   */
81  public void setClassname(String value) {
82    super.setClassname(value);
83    for (int i = 0; i < m_Javadocs.size(); i++)
84      ((Javadoc) m_Javadocs.get(i)).setClassname(value);
85  }
86 
87  /**
88   * sets whether to prefix the Javadoc with "*"
89   *
90   * @param value       true if stars are to be used
91   */
92  public void setUseStars(boolean value) {
93    super.setUseStars(value);
94    for (int i = 0; i < m_Javadocs.size(); i++)
95      ((Javadoc) m_Javadocs.get(i)).setUseStars(value);
96  }
97 
98  /**
99   * sets whether to suppress output in the console
100   *
101   * @param value       true if output is to be suppressed
102   */
103  public void setSilent(boolean value) {
104    super.setSilent(value);
105    for (int i = 0; i < m_Javadocs.size(); i++)
106      ((Javadoc) m_Javadocs.get(i)).setSilent(value);
107  }
108
109  /**
110   * generates and returns the Javadoc for the specified start/end tag pair.
111   *
112   * @param index       the index in the start/end tag array
113   * @return            the generated Javadoc
114   * @throws Exception  in case the generation fails
115   */
116  protected String generateJavadoc(int index) throws Exception {
117    throw new Exception("Not used!");
118  }
119 
120  /**
121   * updates the Javadoc in the given source code, using all the found
122   * Javadoc updaters.
123   *
124   * @param content     the source code
125   * @return            the updated source code
126   * @throws Exception  in case the generation fails
127   */
128  protected String updateJavadoc(String content) throws Exception {
129    String      result;
130    int         i;
131   
132    result = content;
133   
134    for (i = 0; i < m_Javadocs.size(); i++) {
135      result = ((Javadoc) m_Javadocs.get(i)).updateJavadoc(result);
136    }
137   
138    return result;
139  }
140 
141  /**
142   * Returns the revision string.
143   *
144   * @return            the revision
145   */
146  public String getRevision() {
147    return RevisionUtils.extract("$Revision: 6111 $");
148  }
149
150  /**
151   * Parses the given commandline parameters and generates the Javadoc.
152   *
153   * @param args        the commandline parameters for the object
154   */
155  public static void main(String[] args) {
156    runJavadoc(new AllJavadoc(), args);
157  }
158}
Note: See TracBrowser for help on using the repository browser.