[Htmlparser-cvs] htmlparser/src/org/htmlparser/beans BeanyBaby.java,1.14,1.15 HTMLLinkBean.java,1.15
Brought to you by:
derrickoswald
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/beans In directory sc8-pr-cvs1:/tmp/cvs-serv24483/src/org/htmlparser/beans Modified Files: BeanyBaby.java HTMLLinkBean.java HTMLTextBean.java LinkBean.java StringBean.java package.html Log Message: Add style checking target to ant build script: ant checkstyle It uses a jar from http://checkstyle.sourceforge.net which is dropped in the lib directory. The rules are in the file htmlparser_checks.xml in the src directory. Added lexerapplications package with Tabby as the first app. It performs whitespace manipulation on source files to follow the style rules. This reduced the number of style violations to roughly 14,000. There are a few issues with the style checker that need to be resolved before it should be taken too seriously. For example: It thinks all method arguments should be final, even if they are modified by the code (which the compiler frowns on). It complains about long lines, even when there is no possibility of wrapping the line, i.e. a URL in a comment that's more than 80 characters long. It considers all naked integers as 'magic numbers', even when they are obvious, i.e. the 4 corners of a box. It complains about whitespace following braces, even in array initializers, i.e. X[][] = { {a, b} { } } But it points out some really interesting things, even if you don't agree with the style guidelines, so it's worth a look. Index: BeanyBaby.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/beans/BeanyBaby.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** BeanyBaby.java 8 Sep 2003 02:26:28 -0000 1.14 --- BeanyBaby.java 10 Sep 2003 03:38:18 -0000 1.15 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 49,58 **** */ java.util.Vector mTrail; ! /** * Current position on the bread crumb trail. */ int mCrumb; ! /** Creates new form BeanyBaby */ public BeanyBaby () --- 49,58 ---- */ java.util.Vector mTrail; ! /** * Current position on the bread crumb trail. */ int mCrumb; ! /** Creates new form BeanyBaby */ public BeanyBaby () *************** *** 95,99 **** Object source; String name; ! source = event.getSource (); if (source == mLinkBean) --- 95,99 ---- Object source; String name; ! source = event.getSource (); if (source == mLinkBean) *************** *** 170,176 **** } } ! } ! // // MouseListener interface --- 170,176 ---- } } ! } ! // // MouseListener interface *************** *** 232,241 **** mTrail.setElementAt (url, mCrumb); mLinkBean.setURL (url); ! // update navigation menu mBack.setEnabled (mCrumb > 0); mForward.setEnabled (mCrumb + 1 < mTrail.size ()); } ! /** This method is called from within the constructor to * initialize the form. --- 232,241 ---- mTrail.setElementAt (url, mCrumb); mLinkBean.setURL (url); ! // update navigation menu mBack.setEnabled (mCrumb > 0); mForward.setEnabled (mCrumb + 1 < mTrail.size ()); } ! /** This method is called from within the constructor to * initialize the form. *************** *** 345,349 **** setLocation((screenSize.width-640)/2,(screenSize.height-480)/2); }//GEN-END:initComponents ! /** Exit the Application */ private void exitForm (java.awt.event.WindowEvent evt) --- 345,349 ---- setLocation((screenSize.width-640)/2,(screenSize.height-480)/2); }//GEN-END:initComponents ! /** Exit the Application */ private void exitForm (java.awt.event.WindowEvent evt) *************** *** 351,355 **** System.exit (0); }//GEN-LAST:event_exitForm ! // Variables declaration - do not modify//GEN-BEGIN:variables private org.htmlparser.beans.HTMLLinkBean mLinkBean; --- 351,355 ---- System.exit (0); }//GEN-LAST:event_exitForm ! // Variables declaration - do not modify//GEN-BEGIN:variables private org.htmlparser.beans.HTMLLinkBean mLinkBean; Index: HTMLLinkBean.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/beans/HTMLLinkBean.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** HTMLLinkBean.java 8 Sep 2003 02:26:28 -0000 1.15 --- HTMLLinkBean.java 10 Sep 2003 03:38:18 -0000 1.16 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 100,104 **** getBean ().addPropertyChangeListener (listener); } ! /** * Remove a PropertyChangeListener from the listener list. --- 100,104 ---- getBean ().addPropertyChangeListener (listener); } ! /** * Remove a PropertyChangeListener from the listener list. *************** *** 112,116 **** getBean ().removePropertyChangeListener (listener); } ! // // Properties --- 112,116 ---- getBean ().removePropertyChangeListener (listener); } ! // // Properties *************** *** 126,130 **** return (getBean ().getLinks ()); } ! /** * Getter for property URL. --- 126,130 ---- return (getBean ().getLinks ()); } ! /** * Getter for property URL. *************** *** 136,140 **** return (getBean ().getURL ()); } ! /** * Setter for property URL. --- 136,140 ---- return (getBean ().getURL ()); } ! /** * Setter for property URL. *************** *** 155,159 **** return (getBean ().getConnection ()); } ! /** * Setter for property Connection. --- 155,159 ---- return (getBean ().getConnection ()); } ! /** * Setter for property Connection. *************** *** 180,184 **** } } ! // /** // * Unit test. --- 180,184 ---- } } ! // /** // * Unit test. Index: HTMLTextBean.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/beans/HTMLTextBean.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** HTMLTextBean.java 8 Sep 2003 02:26:28 -0000 1.16 --- HTMLTextBean.java 10 Sep 2003 03:38:18 -0000 1.17 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 67,71 **** int width; int height; ! metrics = getFontMetrics (getFont ()); width = metrics.stringWidth ("Hello World"); --- 67,71 ---- int width; int height; ! metrics = getFontMetrics (getFont ()); width = metrics.stringWidth ("Hello World"); *************** *** 86,90 **** getBean ().addPropertyChangeListener (listener); } ! /** * Remove a PropertyChangeListener from the listener list. --- 86,90 ---- getBean ().addPropertyChangeListener (listener); } ! /** * Remove a PropertyChangeListener from the listener list. *************** *** 98,102 **** getBean ().removePropertyChangeListener (listener); } ! // // Properties --- 98,102 ---- getBean ().removePropertyChangeListener (listener); } ! // // Properties *************** *** 135,139 **** return (getBean ().getLinks ()); } ! /** * Setter for property links. --- 135,139 ---- return (getBean ().getLinks ()); } ! /** * Setter for property links. *************** *** 145,149 **** getBean ().setLinks (links); } ! /** * Getter for property URL. --- 145,149 ---- getBean ().setLinks (links); } ! /** * Getter for property URL. *************** *** 155,159 **** return (getBean ().getURL ()); } ! /** * Setter for property URL. --- 155,159 ---- return (getBean ().getURL ()); } ! /** * Setter for property URL. *************** *** 176,180 **** return (getBean ().getReplaceNonBreakingSpaces ()); } ! /** * Set the 'replace non breaking spaces' state. --- 176,180 ---- return (getBean ().getReplaceNonBreakingSpaces ()); } ! /** * Set the 'replace non breaking spaces' state. *************** *** 204,208 **** return (getBean ().getCollapse ()); } ! /** * Set the current 'collapse whitespace' state. --- 204,208 ---- return (getBean ().getCollapse ()); } ! /** * Set the current 'collapse whitespace' state. *************** *** 223,227 **** return (getBean ().getConnection ()); } ! /** * Setter for property Connection. --- 223,227 ---- return (getBean ().getConnection ()); } ! /** * Setter for property Connection. *************** *** 249,253 **** } } ! // /** // * Unit test. --- 249,253 ---- } } ! // /** // * Unit test. Index: LinkBean.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/beans/LinkBean.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** LinkBean.java 8 Sep 2003 02:26:28 -0000 1.19 --- LinkBean.java 10 Sep 2003 03:38:18 -0000 1.20 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 69,73 **** */ protected URL[] mLinks; ! /** * The parser used to extract strings. --- 69,73 ---- */ protected URL[] mLinks; ! /** * The parser used to extract strings. *************** *** 93,97 **** LinkTag link; URL[] ret; ! parser = new Parser (url); parser.registerScanners (); --- 93,97 ---- LinkTag link; URL[] ret; ! parser = new Parser (url); parser.registerScanners (); *************** *** 127,131 **** { boolean ret; ! ret = false; if ((null == array1) && (null == array2)) --- 127,131 ---- { boolean ret; ! ret = false; if ((null == array1) && (null == array2)) *************** *** 139,143 **** ret = false; } ! return (ret); } --- 139,143 ---- ret = false; } ! return (ret); } *************** *** 166,170 **** mPropertySupport.removePropertyChangeListener (listener); } ! // // Properties --- 166,170 ---- mPropertySupport.removePropertyChangeListener (listener); } ! // // Properties *************** *** 218,222 **** } ! /** * Getter for property URL. --- 218,222 ---- } ! /** * Getter for property URL. *************** *** 227,231 **** return (mParser.getURL ()); } ! /** * Setter for property URL. --- 227,231 ---- return (mParser.getURL ()); } ! /** * Setter for property URL. *************** *** 235,239 **** { String old; ! old = getURL (); if (((null == old) && (null != url)) || ((null != old) && !old.equals (url))) --- 235,239 ---- { String old; ! old = getURL (); if (((null == old) && (null != url)) || ((null != old) && !old.equals (url))) *************** *** 260,264 **** return (mParser.getConnection ()); } ! /** * Setter for property Connection. --- 260,264 ---- return (mParser.getConnection ()); } ! /** * Setter for property Connection. Index: StringBean.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/beans/StringBean.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** StringBean.java 8 Sep 2003 02:26:28 -0000 1.25 --- StringBean.java 10 Sep 2003 03:38:18 -0000 1.26 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 116,120 **** */ protected String mStrings; ! /** * If <code>true</code> the link URLs are embedded in the text output. --- 116,120 ---- */ protected String mStrings; ! /** * If <code>true</code> the link URLs are embedded in the text output. *************** *** 148,153 **** */ protected boolean mIsPre; ! ! /** * Create a StringBean object. * Default property values are set to 'do the right thing': --- 148,153 ---- */ protected boolean mIsPre; ! ! /** * Create a StringBean object. * Default property values are set to 'do the right thing': *************** *** 183,187 **** { int length; ! length = mBuffer.length (); if ( (0 != length) // why bother appending newlines to the beginning of a buffer --- 183,187 ---- { int length; ! length = mBuffer.length (); if ( (0 != length) // why bother appending newlines to the beginning of a buffer *************** *** 190,194 **** mBuffer.append (newline); } ! /** * Add the given text collapsing whitespace. --- 190,194 ---- mBuffer.append (newline); } ! /** * Add the given text collapsing whitespace. *************** *** 217,221 **** int state; char character; ! chars = string.length (); if (0 != chars) --- 217,221 ---- int state; char character; ! chars = string.length (); if (0 != chars) *************** *** 269,273 **** ret = mBuffer.toString (); mBuffer = null; ! return (ret); } --- 269,273 ---- ret = mBuffer.toString (); mBuffer = null; ! return (ret); } *************** *** 361,365 **** mPropertySupport.removePropertyChangeListener (listener); } ! // // Properties --- 361,365 ---- mPropertySupport.removePropertyChangeListener (listener); } ! // // Properties *************** *** 388,392 **** return (mLinks); } ! /** * Set the 'include links' state. --- 388,392 ---- return (mLinks); } ! /** * Set the 'include links' state. *************** *** 406,410 **** } } ! /** * Get the current URL. --- 406,410 ---- } } ! /** * Get the current URL. *************** *** 416,420 **** return ((null != mParser) ? mParser.getURL () : null); } ! /** * Set the URL to extract strings from. --- 416,420 ---- return ((null != mParser) ? mParser.getURL () : null); } ! /** * Set the URL to extract strings from. *************** *** 427,431 **** String old; URLConnection conn; ! old = getURL (); conn = getConnection (); --- 427,431 ---- String old; URLConnection conn; ! old = getURL (); conn = getConnection (); *************** *** 459,463 **** return (mReplaceSpace); } ! /** * Set the 'replace non breaking spaces' state. --- 459,463 ---- return (mReplaceSpace); } ! /** * Set the 'replace non breaking spaces' state. *************** *** 496,500 **** return (mCollapse); } ! /** * Set the current 'collapse whitespace' state. --- 496,500 ---- return (mCollapse); } ! /** * Set the current 'collapse whitespace' state. *************** *** 524,528 **** return ((null != mParser) ? mParser.getConnection () : null); } ! /** * Set the parser's connection. --- 524,528 ---- return ((null != mParser) ? mParser.getConnection () : null); } ! /** * Set the parser's connection. *************** *** 535,539 **** String url; URLConnection conn; ! url = getURL (); conn = getConnection (); --- 535,539 ---- String url; URLConnection conn; ! url = getURL (); conn = getConnection (); *************** *** 560,564 **** // NodeVisitor overrides // ! /** * Appends the link as text between angle brackets to the output. --- 560,564 ---- // NodeVisitor overrides // ! /** * Appends the link as text between angle brackets to the output. *************** *** 613,617 **** mIsScript = false; } ! /** * Appends a newline to the output if the tag breaks flow, and --- 613,617 ---- mIsScript = false; } ! /** * Appends a newline to the output if the tag breaks flow, and *************** *** 630,634 **** carriage_return (); } ! /** * Unit test. --- 630,634 ---- carriage_return (); } ! /** * Unit test. Index: package.html =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/beans/package.html,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** package.html 8 Sep 2003 02:26:28 -0000 1.13 --- package.html 10 Sep 2003 03:38:18 -0000 1.14 *************** *** 18,22 **** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. ! You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software --- 18,22 ---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. ! You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software *************** *** 25,41 **** For any questions or suggestions, you can write to me at : Email :so...@in... ! ! Postal Address : Somik Raha Extreme Programmer & Coach Industrial Logic Corporation ! 2583 Cedar Street, Berkeley, CA 94708, USA Website : http://www.industriallogic.com ! --> </head> <body bgcolor="white"> ! The beans package contains Java Beans that can integrate within IDEs. There are visual and non-visual beans, the former follow the naming pattern HTMLxxx. --- 25,41 ---- For any questions or suggestions, you can write to me at : Email :so...@in... ! ! Postal Address : Somik Raha Extreme Programmer & Coach Industrial Logic Corporation ! 2583 Cedar Street, Berkeley, CA 94708, USA Website : http://www.industriallogic.com ! --> </head> <body bgcolor="white"> ! The beans package contains Java Beans that can integrate within IDEs. There are visual and non-visual beans, the former follow the naming pattern HTMLxxx. |