Find attached a large patch which adds JavaDoc comments and generally conforms to the requirements of the checkstyle target.
There are only 2 errors now: [checkstyle] C:\Jakarta\jakarta-log4j\src\java\org\apache\log4j\chainsaw\ControlPanel.jav a:100: Constructor length is 198 lines (max allowed is 150). [checkstyle] C:\Jakarta\jakarta-log4j\src\java\org\apache\log4j\chainsaw\EventDetails.jav a:49:5: More than 7 parameters. I didn't have time to do these ones, and both are really refactoring issues. I just wanted to get the annoying checkstyle ones out of the way first. cheers <<patch-chainsaw-checkstyle-fixes.txt>> _________________________ Paul Smith Lawlex Compliance Solutions phone: +61 3 9278 1511 email: [EMAIL PROTECTED]
Index: ChainsawAppender.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawAppender.java,v retrieving revision 1.1 diff -u -r1.1 ChainsawAppender.java --- ChainsawAppender.java 10 Mar 2003 10:24:12 -0000 1.1 +++ ChainsawAppender.java 11 Mar 2003 04:05:22 -0000 @@ -66,11 +66,29 @@ extends AppenderSkeleton implements EventDetailSink, TableModel { + /** + * Shared model used by the shared Appender + */ private static MyTableModel sSharedModel; + + /** + * The model that is used by this Appender, we ensure + * here that we only use a single Model as the current + * release is effetively an in-JVM singleton + */ private final MyTableModel wrappedTableModel = getDefaultModel(); + /** + * The in-JVM singleton instance of the ChainsawAppender. + * + * If somehow Log4j initialises more than one, then the first one to + * initialise wins! + */ private static ChainsawAppender sSharedAppender = null; + /** + * Constructor, initialises the singleton instance of the appender + */ public ChainsawAppender() { synchronized (ChainsawAppender.class) { if (sSharedAppender == null) { @@ -87,8 +105,7 @@ * received inside Chainsaw go to a single model. * @return MyTableModel */ - private static synchronized MyTableModel getDefaultModel() - { + private static synchronized MyTableModel getDefaultModel() { if (sSharedModel == null) { sSharedModel = new MyTableModel(); } @@ -98,10 +115,10 @@ /** * Return the singleton instance of the ChainsawAppender, it should only * be initialised once. - * @return + * @return the One and only instance of the ChainsawAppender that is + * allowed to be referenced by the GUI */ - static ChainsawAppender getInstance() - { + static ChainsawAppender getInstance() { return sSharedAppender; } @@ -110,13 +127,17 @@ * * NOTE: it is strongly recommended at this time not to rely on this method * until further refactoring is completed. - * @return MyTableModel + * @return MyTableModel the MyTableModel that can be used by external + * components */ - MyTableModel getWrappedModel() - { + MyTableModel getWrappedModel() { return wrappedTableModel; } + /** + * This appender does not require layout and so return false + * @return false and only false + */ public boolean requiresLayout() { return false; } @@ -124,9 +145,9 @@ /** * Implements the EventDetailSink interface by forwarding the EventDetails * object onto an internal Model + * @param aDetails the EventDetails to add to the model */ - public void addEvent(EventDetails aDetails) - { + public void addEvent(EventDetails aDetails) { synchronized (wrappedTableModel) { wrappedTableModel.addEvent(aDetails); } @@ -147,7 +168,7 @@ * Close does nothing */ public void close() { - // TODO: perhaps it should clear the internal TableModel + /** @todo perhaps it should clear the internal TableModel */ } // ========================================================================== @@ -155,38 +176,82 @@ // internal wrappedTableModel instance // ========================================================================== + /** + * Implementation of TableModel interface + * @return int rowCount + */ public int getRowCount() { return wrappedTableModel.getRowCount(); } + /** + * Implementation of TableModel interface + * @return int column Count + */ public int getColumnCount() { return wrappedTableModel.getColumnCount(); } + /** + * Implementation of TableModel interface + * @param aColumnIndex the Column index to query the name for + * @return String column name + */ public String getColumnName(int aColumnIndex) { return wrappedTableModel.getColumnName(aColumnIndex); } + /** + * Implementation of TableModel interface + * @param columnIndex column Index to query the Class of + * @return Class class of Column + */ public Class getColumnClass(int columnIndex) { return wrappedTableModel.getColumnClass(columnIndex); } + /** + * Implementation of TableModel interface + * @param rowIndex row Index to query + * @param columnIndex column Index to query + * @return boolean is Cell Editable? + */ public boolean isCellEditable(int rowIndex, int columnIndex) { return wrappedTableModel.isCellEditable(rowIndex, columnIndex); } - public Object getValueAt(int rowIndex, int columnIndex) { + /** + * Implementation of TableModel interface + * @param rowIndex the row index to retrieve value from + * @param columnIndex to the column index to retrieve value from + * @return Object value at a particular row/column point + */ + public Object getValueAt(int rowIndex, int columnIndex) { return wrappedTableModel.getValueAt(rowIndex, columnIndex); } + /** + * Implementation of TableModel interface + * @param aValue the value to set + * @param rowIndex the row + * @param columnIndex the column + */ public void setValueAt(Object aValue, int rowIndex, int columnIndex) { wrappedTableModel.setValueAt(aValue, rowIndex, columnIndex); } + /** + * Implementation of TableModel interface + * @param l a TableModelListener to add + */ public void addTableModelListener(TableModelListener l) { wrappedTableModel.addTableModelListener(l); } + /** + * Implementation of TableModel interface + * @param l listener to remove from the currently registered listeners + */ public void removeTableModelListener(TableModelListener l) { wrappedTableModel.removeTableModelListener(l); } Index: ControlPanel.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/ControlPanel.java,v retrieving revision 1.5 diff -u -r1.5 ControlPanel.java --- ControlPanel.java 25 Feb 2003 12:49:14 -0000 1.5 +++ ControlPanel.java 11 Mar 2003 04:05:22 -0000 @@ -105,7 +105,7 @@ setBorder(BorderFactory.createTitledBorder("Controls: ")); final GridBagLayout gridbag = new GridBagLayout(); final GridBagConstraints c = new GridBagConstraints(); - final Dimension d = new Dimension(80,24); + final Dimension d = new Dimension(80, 24); setLayout(gridbag); // Pad everything @@ -258,9 +258,9 @@ final JPanel buttonPanel = new JPanel(); gridbag.setConstraints(buttonPanel, c); add(buttonPanel); - buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT,1,1)); + buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 1, 1)); - final Insets insets = new Insets(2,2,2,2); + final Insets insets = new Insets(2, 2, 2, 2); final JButton toggleButton = new JButton("Pause"); toggleButton.setMnemonic('p'); toggleButton.addActionListener(new ActionListener() { @@ -296,18 +296,40 @@ buttonPanel.add(exitButton); } + /** Convenience class that filters all document events to one method */ - private static abstract class DocumentChangeListener + private abstract static class DocumentChangeListener implements DocumentListener { + /** + * Receives the DocumentEvent and does something + * @param aEvent the DocumentEvent + */ public abstract void update(DocumentEvent aEvent); + /** + * Receives the DocumentEvent and simply forwards to + * update(DocumentEvent) + * @param aEvent the DocumentEvent + */ public void insertUpdate(DocumentEvent aEvent) { update(aEvent); } + + /** + * Receives the DocumentEvent and simply forwards to + * update(DocumentEvent) + * @param aEvent the DocumentEvent + */ public void removeUpdate(DocumentEvent aEvent) { update(aEvent); } + + /** + * Receives the DocumentEvent and simply forwards to + * update(DocumentEvent) + * @param aEvent the DocumentEvent + */ public void changedUpdate(DocumentEvent aEvent) { update(aEvent); } Index: DetailPanel.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/DetailPanel.java,v retrieving revision 1.2 diff -u -r1.2 DetailPanel.java --- DetailPanel.java 10 Mar 2003 10:24:12 -0000 1.2 +++ DetailPanel.java 11 Mar 2003 04:05:22 -0000 @@ -69,24 +69,24 @@ */ class DetailPanel extends JPanel - implements ListSelectionListener -{ + implements ListSelectionListener { + /** used to log events **/ private static final Category LOG = Category.getInstance(DetailPanel.class); /** used to format the logging event **/ private static final MessageFormat FORMATTER = new MessageFormat( - "<b>Time:</b> <code>{0,time,medium}</code>" + - " <b>Priority:</b> <code>{1}</code>" + - " <b>Thread:</b> <code>{2}</code>" + - " <b>NDC:</b> <code>{3}</code>" + - "<br><b>Category:</b> <code>{4}</code>" + - "<br><b>Location:</b> <code>{5}</code>" + - "<br><b>Message:</b>" + - "<pre>{6}</pre>" + - "<b>Throwable:</b>" + - "<pre>{7}</pre>"); + "<b>Time:</b> <code>{0,time,medium}</code>" + + " <b>Priority:</b> <code>{1}</code>" + + " <b>Thread:</b> <code>{2}</code>" + + " <b>NDC:</b> <code>{3}</code>" + + "<br><b>Category:</b> <code>{4}</code>" + + "<br><b>Location:</b> <code>{5}</code>" + + "<br><b>Message:</b>" + + "<pre>{6}</pre>" + + "<b>Throwable:</b>" + + "<pre>{7}</pre>"); /** the model for the data to render **/ private final MyTableModel mModel; Index: EventDetails.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/EventDetails.java,v retrieving revision 1.2 diff -u -r1.2 EventDetails.java --- EventDetails.java 9 Oct 2002 22:50:02 -0000 1.2 +++ EventDetails.java 11 Mar 2003 04:05:22 -0000 @@ -53,8 +53,7 @@ String aThreadName, String aMessage, String[] aThrowableStrRep, - String aLocationDetails) - { + String aLocationDetails) { mTimeStamp = aTimeStamp; mPriority = aPriority; mCategoryName = aCategoryName; @@ -114,7 +113,7 @@ } /** @see #mLocationDetails **/ - String getLocationDetails(){ + String getLocationDetails() { return mLocationDetails; } Index: EventDetailSink.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/EventDetailSink.java,v retrieving revision 1.1 diff -u -r1.1 EventDetailSink.java --- EventDetailSink.java 10 Mar 2003 10:24:12 -0000 1.1 +++ EventDetailSink.java 11 Mar 2003 04:05:22 -0000 @@ -56,5 +56,9 @@ */ public interface EventDetailSink { + /** + * Adds an EventDetails instance to an internal structure + * @param aDetail the EventDetails to add + */ public void addEvent(EventDetails aDetail); } Index: ExitAction.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/ExitAction.java,v retrieving revision 1.2 diff -u -r1.2 ExitAction.java --- ExitAction.java 25 Feb 2003 12:49:14 -0000 1.2 +++ ExitAction.java 11 Mar 2003 04:05:22 -0000 @@ -63,8 +63,8 @@ * @version 1.0 */ class ExitAction - extends AbstractAction -{ + extends AbstractAction { + /** use to log messages **/ private static final Category LOG = Category.getInstance(ExitAction.class); /** The instance to share **/ @@ -77,7 +77,7 @@ private boolean mShuttingDown = false; /** Stop people creating instances **/ - private ExitAction() {} + private ExitAction() { } /** * Will shutdown the application. @@ -86,7 +86,7 @@ public void actionPerformed(ActionEvent aIgnore) { LOG.info("shutting down"); mShuttingDown = true; - for (Iterator i = mShutdownHooks.iterator(); i.hasNext(); ) { + for (Iterator i = mShutdownHooks.iterator(); i.hasNext();) { try { final Thread t = (Thread) i.next(); t.start(); Index: LoadXMLAction.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoadXMLAction.java,v retrieving revision 1.3 diff -u -r1.3 LoadXMLAction.java --- LoadXMLAction.java 10 Mar 2003 10:24:12 -0000 1.3 +++ LoadXMLAction.java 11 Mar 2003 04:05:22 -0000 @@ -65,8 +65,8 @@ * @version 1.0 */ class LoadXMLAction - extends AbstractAction -{ + extends AbstractAction { + /** use to log messages **/ private static final Logger LOG = Logger.getLogger(LoadXMLAction.class); @@ -78,8 +78,7 @@ * the file chooser - configured to allow only the selection of a * single file. */ - private final JFileChooser mChooser = new JFileChooser(); - { + private final JFileChooser mChooser = new JFileChooser(); { mChooser.setMultiSelectionEnabled(false); mChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); } @@ -94,8 +93,7 @@ * @param aParent the parent frame * @param eventSink the eventSink to add events to */ - LoadXMLAction(JFrame aParent, EventDetailSink eventSink) - { + LoadXMLAction(JFrame aParent, EventDetailSink eventSink) { mParent = aParent; mHandler = new XMLFileHandler(eventSink); } Index: Log4JConfigurationFinder.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/Log4JConfigurationFinder.java,v retrieving revision 1.1 diff -u -r1.1 Log4JConfigurationFinder.java --- Log4JConfigurationFinder.java 10 Mar 2003 10:24:12 -0000 1.1 +++ Log4JConfigurationFinder.java 11 Mar 2003 04:05:22 -0000 @@ -50,6 +50,17 @@ import java.net.URL; +/** + * Instances of this class are able to locate a URL of a Log4J configuration + * file using different means. This is intended to be a Strategy pattern. + * @author Paul Smith + */ public interface Log4JConfigurationFinder { + + /** + * Returns the URL of the configuration found according to the + * underlying implementation + * @return URL of configuration file + */ public URL findConfiguration(); } Index: LoggingReceiver.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggingReceiver.java,v retrieving revision 1.4 diff -u -r1.4 LoggingReceiver.java --- LoggingReceiver.java 10 Mar 2003 10:24:12 -0000 1.4 +++ LoggingReceiver.java 11 Mar 2003 04:05:22 -0000 @@ -98,8 +98,8 @@ while (true) { LOG.debug("Waiting for a connection"); final Socket client = mSvrSock.accept(); - LOG.debug("Got a connection from " + - client.getInetAddress().getHostName()); + LOG.debug("Got a connection from " + + client.getInetAddress().getHostName()); final Thread t = new Thread(new Slurper(client)); t.setDaemon(true); t.start(); Index: Main.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/Main.java,v retrieving revision 1.5 diff -u -r1.5 Main.java --- Main.java 10 Mar 2003 10:24:12 -0000 1.5 +++ Main.java 11 Mar 2003 04:05:22 -0000 @@ -75,8 +75,8 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Oliver Burn</a> */ public class Main - extends JFrame -{ + extends JFrame { + /** Window x-position property */ public static final String X_POSITION_PROPERTY = Preferences.PROP_PREFIX + ".x"; @@ -93,9 +93,19 @@ public static final String DETAILS_SEPARATOR_PROPERTY = Preferences.PROP_PREFIX + ".details.separator"; + /** + * A Preferences instance reference + */ private static final Preferences PREFS = Preferences.getInstance(); + /** + * The split pane to divide the Event List and the Event details area + */ private JSplitPane aDetailsDivider; + + /** + * The TableColumnModel used by this GUI app + */ private final MyTableColumnModel mColumnModel; /** @@ -126,12 +136,13 @@ /** * Constructs the JTable used for displaying the Events logs - * @param tableModel - * @param tableColumnModel - * @return + * @param tableModel the model to wrap with the JTable + * @param tableColumnModel the column model to wrap with the JTable + * @return JTable used to wrap the ColumnModel and the TableModel + * configured appropriately */ - private JTable buildTable(TableModel tableModel, TableColumnModel tableColumnModel) - { + private JTable buildTable(TableModel tableModel, + TableColumnModel tableColumnModel) { final JTable table = new JTable(tableModel, mColumnModel); table.setAutoCreateColumnsFromModel(true); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); @@ -141,10 +152,10 @@ /** * Constructs all the components required for this frame * and attaches the ChainsawAppender to components that require it - * @param model + * @param model the ChainsawAppender instance that this GUI is based + * around */ - private void buildComponents(ChainsawAppender model) - { + private void buildComponents(ChainsawAppender model) { // Add control panel final ControlPanel cp = new ControlPanel(model.getWrappedModel()); getContentPane().add(cp, BorderLayout.NORTH); @@ -169,10 +180,9 @@ /** * Initialises the Menu bar for this frame, and bind * actions - * @param eventSink + * @param eventSink EventDetailSink to use */ - private void buildMenus(EventDetailSink eventSink) - { + private void buildMenus(EventDetailSink eventSink) { //Create the menu bar. final JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); @@ -187,14 +197,15 @@ menu.add(loadMenuItem); loadMenuItem.addActionListener(lxa); } catch (NoClassDefFoundError e) { - System.err.println("Missing classes for XML parser :" +e ); + System.err.println("Missing classes for XML parser :" + e); JOptionPane.showMessageDialog( this, "XML parser not in classpath - unable to load XML events.", "CHAINSAW", JOptionPane.ERROR_MESSAGE); } catch (Exception e) { - System.err.println("Unable to create the action to load XML files:" + e.getMessage()); + System.err.println("Unable to create the action to load XML files:" + + e.getMessage()); JOptionPane.showMessageDialog( this, "Unable to create a XML parser - unable to load XML events.", @@ -224,6 +235,9 @@ } + /** + * Loads the GUI prefs from the Preferences sub-system + */ private void loadGuiPrefs() { // table prefs mColumnModel.loadPrefs(); @@ -246,6 +260,9 @@ } } + /** + * Saves the GUI preferences via the Preferences sub-system + */ private void saveGuiPrefs() { mColumnModel.savePrefs(); @@ -262,15 +279,22 @@ // static methods //////////////////////////////////////////////////////////////////////////// + /** + * A simple Shutdown hook that ensures that the Preferences are saved + */ private class Shutdown implements Runnable { - public void run() { - saveGuiPrefs(); - } + + /** + * "runs" by simply saving the preferences. + */ + public void run() { + saveGuiPrefs(); + } } /** * @deprecated, should be started from the Start class - * @param args + * @param args the command line arguments */ public static void main(String[] args) { Start.main(args); Index: MyTableColumnModel.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/MyTableColumnModel.java,v retrieving revision 1.2 diff -u -r1.2 MyTableColumnModel.java --- MyTableColumnModel.java 10 Mar 2003 10:24:12 -0000 1.2 +++ MyTableColumnModel.java 11 Mar 2003 04:05:22 -0000 @@ -82,10 +82,18 @@ /** Logger for the class */ private static final Logger LOG = Logger.getLogger(MyTableColumnModel.class); + + /** + * The one and only instance of the Preferences + */ private static final Preferences PREFS = Preferences.getInstance(); /** Map of TableColumns to PreferenceSets */ private final Map mColPrefMap = new HashMap(); + + /** + * The internal TableModel used by this ColumnModel + */ private final TableModel mTableModel; /** @@ -153,7 +161,10 @@ } } - /** [EMAIL PROTECTED] */ + /** + * Adds a column to the ColumnModel + * @param column the column to add + */ public void addColumn(TableColumn column) { PreferenceSet colPrefSet = getColumnPreferences(column); @@ -164,7 +175,8 @@ super.addColumn(column); } - /** [EMAIL PROTECTED] */ + /** [EMAIL PROTECTED] + * @param column the column to remove*/ public void removeColumn(TableColumn column) { PreferenceSet colPrefSet = getColumnPreferences(column); @@ -175,7 +187,9 @@ super.removeColumn(column); } - /** [EMAIL PROTECTED] */ + /** [EMAIL PROTECTED] + * @param columnIndex the columnIndex to move + * @param newIndex the new index for that columnIndex*/ public void moveColumn(int columnIndex, int newIndex) { super.moveColumn(columnIndex, newIndex); saveColumnOrder(); @@ -204,12 +218,19 @@ return (PreferenceSet) mColPrefMap.get(col); } - /* Store the column preferences in the map. */ + /** + * Store the column preferences in the map. + * @param col the TableColumn to put + * @param colPrefSet the PreferenceSet to put + */ private void putColumnPreferences(TableColumn col, PreferenceSet colPrefSet) { mColPrefMap.put(col, colPrefSet); } - /* Determine the order of the columns based on the preferences. */ + /** + * Determine the order of the columns based on the preferences. + * @return String[] of Column names in order + */ private String[] getColumnOrder() { String colOrder = PREFS.getProperty(ORDER_PROPERTY); @@ -235,7 +256,9 @@ return (String[]) result.toArray(new String[result.size()]); } - /** Save the current column order to the preferences */ + /** + * Save the current column order to the preferences + */ private void saveColumnOrder() { StringBuffer colList = new StringBuffer(45); Index: MyTableModel.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/MyTableModel.java,v retrieving revision 1.5 diff -u -r1.5 MyTableModel.java --- MyTableModel.java 10 Mar 2003 10:24:12 -0000 1.5 +++ MyTableModel.java 11 Mar 2003 04:05:22 -0000 @@ -69,19 +69,18 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Oliver Burn</a> */ class MyTableModel - extends AbstractTableModel implements EventDetailSink -{ + extends AbstractTableModel implements EventDetailSink { /** used to log messages **/ private static final Category LOG = Category.getInstance(MyTableModel.class); /** use the compare logging events **/ - private static final Comparator MY_COMP = new Comparator() - { + private static final Comparator MY_COMP = new Comparator() { /** @see Comparator **/ public int compare(Object aObj1, Object aObj2) { - if ((aObj1 == null) && (aObj2 == null)) { + if ((aObj1 == null) + && (aObj2 == null)) { return 0; // treat as equal } else if (aObj1 == null) { return -1; // null less than everything @@ -106,8 +105,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Oliver Burn</a> */ private class Processor - implements Runnable - { + implements Runnable { /** loops getting the events **/ public void run() { while (true) { @@ -404,13 +402,12 @@ * @return whether the event matches */ private boolean matchFilter(EventDetails aEvent) { - if (aEvent.getPriority().isGreaterOrEqual(mPriorityFilter) && - (aEvent.getThreadName().indexOf(mThreadFilter) >= 0) && - (aEvent.getCategoryName().indexOf(mCategoryFilter) >= 0) && - ((mNDCFilter.length() == 0) || - ((aEvent.getNDC() != null) && - (aEvent.getNDC().indexOf(mNDCFilter) >= 0)))) - { + if (aEvent.getPriority().isGreaterOrEqual(mPriorityFilter) + && (aEvent.getThreadName().indexOf(mThreadFilter) >= 0) + && (aEvent.getCategoryName().indexOf(mCategoryFilter) >= 0) + && ((mNDCFilter.length() == 0) + || ((aEvent.getNDC() != null) + && (aEvent.getNDC().indexOf(mNDCFilter) >= 0)))) { final String rm = aEvent.getMessage(); if (rm == null) { // only match if we have not filtering in place Index: Preferences.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/Preferences.java,v retrieving revision 1.1 diff -u -r1.1 Preferences.java --- Preferences.java 25 Feb 2003 12:51:16 -0000 1.1 +++ Preferences.java 11 Mar 2003 04:05:22 -0000 @@ -358,7 +358,10 @@ return Collections.unmodifiableList(files); } - /* Create the single instance */ + /** + * Create the single instance + * @return Preference the one and only + */ private static Preferences createInstance() { String filename = getPropertyFilename(); File file = new File(filename); @@ -390,7 +393,10 @@ return sInstance; } - /* Determine the property file to use */ + /** + * Determine the property file to use + * @return String property file name to load + */ private static String getPropertyFilename() { String filename = System.getProperty(PROP_FILE); @@ -413,13 +419,17 @@ return filename; } - /** Load the preferences from the file. */ + /** + * Load the preferences from the file. + */ private void load() { mMaxFiles = getInteger(MAX_FILES_PROPERTY, 5); loadFiles(); } - /** Load the recent files list. */ + /** + * Load the recent files list. + */ private void loadFiles() { final char[] ch = getProperty(FILES_PROPERTY, "").toCharArray(); final StringBuffer filename = new StringBuffer(ch.length); @@ -454,7 +464,9 @@ } } - /** Rebuild the recent files list property and menu */ + /** + * Rebuild the recent files list property and menu + */ private void rebuildRecentFilesData() { StringBuffer fileList = new StringBuffer(); boolean first = true; Index: PreferencesDialog.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/PreferencesDialog.java,v retrieving revision 1.1 diff -u -r1.1 PreferencesDialog.java --- PreferencesDialog.java 25 Feb 2003 12:51:16 -0000 1.1 +++ PreferencesDialog.java 11 Mar 2003 04:05:22 -0000 @@ -81,9 +81,25 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Raymond DeCampo</a> */ class PreferencesDialog extends JDialog { + + /** + * The one and only Preferences reference + */ private static final Preferences PREFS = Preferences.getInstance(); + + /** + * The ColumnModel to use to save/load stuff from + */ private final MyTableColumnModel mColModel; + + /** + * TextField to enter the max # of files available on MRU list + */ private final JTextField mMaxFilesField = new JTextField(6); + + /** + * CheckBox used to indicate whether the filters should be saved + */ private final JCheckBox mSaveFilters = new JCheckBox("Save filters?"); /** Map relating TableColumns to JCheckBoxes */ @@ -181,7 +197,10 @@ setLocationRelativeTo(owner); } - /* Get the columns from the model in alphabetical order */ + /** + * Get the columns from the model in alphabetical order + * @return Iterator of available columns + */ private Iterator getAvailableColumns() { SortedSet cols = new TreeSet( @@ -199,12 +218,22 @@ return cols.iterator(); } - /** OK button handler */ + /** + * OK button handler + */ private class OKAction extends AbstractAction { + + /** + * Constructor + */ public OKAction() { putValue(NAME, "OK"); } + /** + * ActionPerformed handler when they press Ok + * @param ae ActionEvent when the button is pressed + */ public void actionPerformed(ActionEvent ae) { // File preferences try { @@ -244,12 +273,22 @@ } } - /** Cancel button handler */ + /** + * Cancel button handler + */ private class CancelAction extends AbstractAction { + + /** + * Constructor for the action + */ public CancelAction() { putValue(NAME, "Cancel"); } + /** + * ActionEvent handler + * @param ae ActionEvent when they press Cancel + */ public void actionPerformed(ActionEvent ae) { hide(); } Index: RecentFilesMenu.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/RecentFilesMenu.java,v retrieving revision 1.2 diff -u -r1.2 RecentFilesMenu.java --- RecentFilesMenu.java 10 Mar 2003 10:24:12 -0000 1.2 +++ RecentFilesMenu.java 11 Mar 2003 04:05:22 -0000 @@ -68,14 +68,22 @@ public class RecentFilesMenu extends JMenu { /** Logger for class */ private static final Logger LOG = Logger.getLogger(RecentFilesMenu.class); + + /** + * The EventDetailSink instance to use + */ private final EventDetailSink eventSink; + + /** + * The XMLFileHandler instance to use + */ private final XMLFileHandler mHandler; /** * Construct a RecentFilesMenu object based on the given model. When a * file is selected from the menu, it will be loaded to the given model. * - * @param model the table model + * @param eventSink the sink to add events to */ public RecentFilesMenu(EventDetailSink eventSink) { super("Recent Files"); @@ -118,12 +126,21 @@ /** File to load */ private final String mFilename; + /** + * Constructor that uses the filename and the order as descriptors + * for use within the GUI + * @param filename the file name to load + * @param order a sorting number + */ public LoadRecentFileAction(String filename, int order) { mFilename = filename; putValue(NAME, order + " - " + filename); } - /* Load the file */ + /** + * Loads the File + * @param ae the ActionEvent from the pressing of the button + */ public void actionPerformed(ActionEvent ae) { try { final File f = new File(mFilename); Index: Start.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/Start.java,v retrieving revision 1.1 diff -u -r1.1 Start.java --- Start.java 10 Mar 2003 10:24:12 -0000 1.1 +++ Start.java 11 Mar 2003 04:05:22 -0000 @@ -67,32 +67,53 @@ */ public class Start { + /** + * Main entry point of Chainsaw, initialises the Log4j system + * and hands off to Main + * @param args command line arguments + */ public static void main(String[] args) { initLog4J(); new Main(); } - private static void initLog4J() - { + /** + * Initialises the Log4J system by using a series of configured + * Stategy's to progressively search for a configuration file + */ + private static void initLog4J() { /** initialise log4j **/ final FinderStrategies strategies = new FinderStrategies(); final URL url = strategies.findConfiguration(); - DOMConfigurator.configure( url ); + DOMConfigurator.configure(url); } - private static class FinderStrategies implements Log4JConfigurationFinder - { - public FinderStrategies() - { + /** + * A class that implements the Log4JConfigurationFinder interface + * but simply forwards on to each instance of a collection + * of internal Log4JConfigurationFinder, until one of them finds it. + */ + private static class FinderStrategies implements Log4JConfigurationFinder { + + /** + * Initialises by adding a series of defined Log4JConfigurationFinder + * instances to an internal structure + */ + public FinderStrategies() { mStrategies.add(new ResourceLoaderFinder()); mStrategies.add(new FileOpenFinder()); - // TODO: add any more stategies + /** @todo add any more stategies */ } - public URL findConfiguration() - { - for (Iterator i = mStrategies.iterator(); i.hasNext(); ) { + /** + * Returns the URL of the configuration from the first + * strategy implementation this class has been configured with or + * null if none of the strategies could find one. + * @return URL of configuration or null + */ + public URL findConfiguration() { + for (Iterator i = mStrategies.iterator(); i.hasNext();) { final Log4JConfigurationFinder finder = (Log4JConfigurationFinder) i.next(); final URL resource = finder.findConfiguration(); @@ -104,6 +125,9 @@ + " via any means"); } + /** + * The collection of Stategies to attempt to find the configuration + */ private final Collection mStrategies = new ArrayList(); } @@ -112,15 +136,23 @@ * @author Paul Smith * @version 1.0 */ - private static class ResourceLoaderFinder implements Log4JConfigurationFinder - { - public URL findConfiguration() - { - return this.getClass().getClassLoader().getResource(LOG4J_CONFIG_FILE); + private static class ResourceLoaderFinder + implements Log4JConfigurationFinder { + + /** + * Finds a URL of configuration file by using this class' classloader's + * getResource() method. + * @return URL of the found configuration file + */ + public URL findConfiguration() { + return this.getClass().getClassLoader().getResource(LOG4J_CONFIGFILENAME); } } - private static final String LOG4J_CONFIG_FILE = "log4j.xml"; + /** + * The configuration file name to attempt to locate + */ + private static final String LOG4J_CONFIGFILENAME = "log4j.xml"; /** * Allows the user to locate the Log4J initialization file @@ -128,12 +160,15 @@ * @author Paul Smith * @version 1.0 */ - private static class FileOpenFinder implements Log4JConfigurationFinder - { - public URL findConfiguration() - { + private static class FileOpenFinder implements Log4JConfigurationFinder { + + /** + * Finds the configuration file by providing the user with a JFileChooser + * @return URL of chosen Configuration file + */ + public URL findConfiguration() { final JFileChooser chooser = new JFileChooser(); - chooser.setFileFilter( LOG4J_FILE_FILTER ); + chooser.setFileFilter(log4jFileFilter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); final int returnVal = chooser.showOpenDialog(null); @@ -141,27 +176,28 @@ final File f = chooser.getSelectedFile(); try { return f.toURL(); - } - catch (MalformedURLException ex) { + } catch (MalformedURLException ex) { ex.printStackTrace(); } } return null; } - private static FileFilter LOG4J_FILE_FILTER = new FileFilter(){ + /** + * File file that restricts to Directories or the defined + * configuration file name + */ + private static FileFilter log4jFileFilter = new FileFilter(){ - public boolean accept(File f) - { - return f.isDirectory() || f.getName().equals(LOG4J_CONFIG_FILE); + public boolean accept(File f) { + return f.isDirectory() || f.getName().equals(LOG4J_CONFIGFILENAME); } /** * The description of this filter. For example: "JPG and GIF Images" * @see FileView#getName */ - public String getDescription() - { + public String getDescription() { return "Log4J Configuration File"; } }; Index: XMLFileHandler.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/chainsaw/XMLFileHandler.java,v retrieving revision 1.7 diff -u -r1.7 XMLFileHandler.java --- XMLFileHandler.java 10 Mar 2003 10:24:12 -0000 1.7 +++ XMLFileHandler.java 11 Mar 2003 04:05:22 -0000 @@ -70,8 +70,11 @@ * @version 1.0 */ class XMLFileHandler - extends DefaultHandler -{ + extends DefaultHandler { + + /** + * The Logger to use for logging during execution of this class + */ private static final Logger LOG = Logger.getLogger(XMLFileHandler.class); /** represents the event tag **/ @@ -112,7 +115,7 @@ /** * Creates a new <code>XMLFileHandler</code> instance. * - * @param aModel where to add the events + * @param aEventSink where to add the events */ XMLFileHandler(EventDetailSink aEventSink) { mEventSink = aEventSink; @@ -120,8 +123,7 @@ /** @see DefaultHandler **/ public void startDocument() - throws SAXException - { + throws SAXException { mNumEvents = 0; } @@ -133,8 +135,7 @@ /** @see DefaultHandler **/ public void endElement(String aNamespaceURI, String aLocalName, - String aQName) - { + String aQName) { if (TAG_EVENT.equals(aQName)) { addEvent(); resetData(); @@ -159,8 +160,7 @@ public void startElement(String aNamespaceURI, String aLocalName, String aQName, - Attributes aAtts) - { + Attributes aAtts) { mBuf.setLength(0); if (TAG_EVENT.equals(aQName)) { @@ -184,6 +184,14 @@ return mNumEvents; } + /** + * Loads the file and updates the preferences + * @param file to load + * @return int the number of eVents loaded + * @throws SAXException if an error occurrs + * @throws IOException if an error occurrs + * @throws ParserConfigurationException if an error occurrs + */ public int loadFile(File file) throws SAXException, IOException, ParserConfigurationException { @@ -230,6 +238,7 @@ * @return the number of events loaded * @throws SAXException if an error occurs * @throws IOException if an error occurs + * @throws ParserConfigurationException if an error occurs */ private int loadFile(String aFile) throws SAXException, IOException, ParserConfigurationException {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]