Thread: [Htmlparser-cvs] htmlparser/src/org/htmlparser/lexer/nodes AbstractNode.java,1.4,1.5 Attribute.java,
Brought to you by:
derrickoswald
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/lexer/nodes In directory sc8-pr-cvs1:/tmp/cvs-serv24483/src/org/htmlparser/lexer/nodes Modified Files: AbstractNode.java Attribute.java RemarkNode.java StringNode.java TagNode.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: AbstractNode.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/lexer/nodes/AbstractNode.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AbstractNode.java 8 Sep 2003 02:26:28 -0000 1.4 --- AbstractNode.java 10 Sep 2003 03:38:18 -0000 1.5 *************** *** 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,31 **** // 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 ! // ! // This class was contributed by // Derrick Oswald // --- 18,31 ---- // 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 ! // ! // This class was contributed by // Derrick Oswald // *************** *** 45,49 **** */ protected Page mPage; ! /** * Create a lexeme. --- 45,49 ---- */ protected Page mPage; ! /** * Create a lexeme. Index: Attribute.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/lexer/nodes/Attribute.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Attribute.java 8 Sep 2003 02:26:28 -0000 1.6 --- Attribute.java 10 Sep 2003 03:38:18 -0000 1.7 *************** *** 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,31 **** // 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 ! // ! // This class was contributed by // Derrick Oswald // --- 18,31 ---- // 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 ! // ! // This class was contributed by // Derrick Oswald // *************** *** 58,62 **** */ protected Page mPage; ! /** * The starting offset of the name within the page. --- 58,62 ---- */ protected Page mPage; ! /** * The starting offset of the name within the page. *************** *** 88,92 **** */ protected String mName; ! /** * The value of the attribute. --- 88,92 ---- */ protected String mName; ! /** * The value of the attribute. *************** *** 96,100 **** */ protected String mValue; ! /** * The quote, if any, surrounding the value of the attribute, if any. --- 96,100 ---- */ protected String mValue; ! /** * The quote, if any, surrounding the value of the attribute, if any. *************** *** 179,183 **** StringBuffer buffer; String ret; ! ret = getValue (); if (null != ret && (0 != (quote = getQuote ()))) --- 179,183 ---- StringBuffer buffer; String ret; ! ret = getValue (); if (null != ret && (0 != (quote = getQuote ()))) *************** *** 252,256 **** { String name; ! name = getName (); if (null == name) --- 252,256 ---- { String name; ! name = getName (); if (null == name) *************** *** 301,305 **** ret = new StringBuffer (length); toString (ret); ! return (ret.toString ()); } --- 301,305 ---- ret = new StringBuffer (length); toString (ret); ! return (ret.toString ()); } Index: RemarkNode.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/lexer/nodes/RemarkNode.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RemarkNode.java 8 Sep 2003 02:26:28 -0000 1.5 --- RemarkNode.java 10 Sep 2003 03:38:18 -0000 1.6 *************** *** 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 *************** *** 40,45 **** { public final static String REMARK_NODE_FILTER="-r"; ! ! /** * Constructor takes in the text string, beginning and ending posns. * @param page The page this string is on. --- 40,45 ---- { public final static String REMARK_NODE_FILTER="-r"; ! ! /** * Constructor takes in the text string, beginning and ending posns. * @param page The page this string is on. *************** *** 52,56 **** } ! /** * Returns the text contents of the comment tag. * todo: this only works for the usual case. --- 52,56 ---- } ! /** * Returns the text contents of the comment tag. * todo: this only works for the usual case. *************** *** 75,79 **** Cursor start; Cursor end; ! start = new Cursor (getPage (), elementBegin ()); end = new Cursor (getPage (), elementEnd ()); --- 75,79 ---- Cursor start; Cursor end; ! start = new Cursor (getPage (), elementBegin ()); end = new Cursor (getPage (), elementEnd ()); Index: StringNode.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/lexer/nodes/StringNode.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** StringNode.java 8 Sep 2003 02:26:28 -0000 1.5 --- StringNode.java 10 Sep 2003 03:38:18 -0000 1.6 *************** *** 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 *************** *** 41,46 **** { public static final String STRING_FILTER = "-string"; ! ! /** * Constructor takes in the text string, beginning and ending posns. * @param page The page this string is on. --- 41,46 ---- { public static final String STRING_FILTER = "-string"; ! ! /** * Constructor takes in the text string, beginning and ending posns. * @param page The page this string is on. *************** *** 77,96 **** } } ! public String toPlainTextString () { return (toHtml ()); } ! public String toHtml () { return (mPage.getText (elementBegin (), elementEnd ())); } ! public String toString () { Cursor start; Cursor end; ! start = new Cursor (getPage (), elementBegin ()); end = new Cursor (getPage (), elementEnd ()); --- 77,96 ---- } } ! public String toPlainTextString () { return (toHtml ()); } ! public String toHtml () { return (mPage.getText (elementBegin (), elementEnd ())); } ! public String toString () { Cursor start; Cursor end; ! start = new Cursor (getPage (), elementBegin ()); end = new Cursor (getPage (), elementEnd ()); *************** *** 98,102 **** } ! public void collectInto (NodeList collectionList, String filter) { --- 98,102 ---- } ! public void collectInto (NodeList collectionList, String filter) { *************** *** 104,108 **** collectionList.add (this); } ! public void accept (Object visitor) { --- 104,108 ---- collectionList.add (this); } ! public void accept (Object visitor) { Index: TagNode.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/lexer/nodes/TagNode.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TagNode.java 8 Sep 2003 02:26:28 -0000 1.8 --- TagNode.java 10 Sep 2003 03:38:18 -0000 1.9 *************** *** 59,63 **** public final static String NOTHING = "$<NOTHING>$"; private final static String EMPTY_STRING=""; ! private boolean emptyXmlTag = false; --- 59,63 ---- public final static String NOTHING = "$<NOTHING>$"; private final static String EMPTY_STRING=""; ! private boolean emptyXmlTag = false; *************** *** 139,143 **** * @param name Name of attribute, case insensitive. * @return The value associated with the attribute or null if it does ! * not exist, or is a stand-alone or */ public String getAttribute (String name) --- 139,143 ---- * @param name Name of attribute, case insensitive. * @return The value associated with the attribute or null if it does ! * not exist, or is a stand-alone or */ public String getAttribute (String name) *************** *** 148,152 **** String string; String ret; ! ret = null; --- 148,152 ---- String string; String ret; ! ret = null; *************** *** 168,172 **** } } ! return (ret); } --- 168,172 ---- } } ! return (ret); } *************** *** 203,207 **** doubleq = false; } ! // now apply quoting if (needed) --- 203,207 ---- doubleq = false; } ! // now apply quoting if (needed) *************** *** 291,299 **** return (getAttribute (name)); } ! /** * Gets the attributes in the tag. * NOTE: Values of the extended hashtable are two element arrays of String, ! * with the first element being the original name (not uppercased), * and the second element being the value. * @return Returns a special hashtable of attributes in two element String arrays. --- 291,299 ---- return (getAttribute (name)); } ! /** * Gets the attributes in the tag. * NOTE: Values of the extended hashtable are two element arrays of String, ! * with the first element being the original name (not uppercased), * and the second element being the value. * @return Returns a special hashtable of attributes in two element String arrays. *************** *** 315,319 **** StringBuffer _value; Hashtable ret; ! ret = new SpecialHashtable (); attributes = getAttributesEx (); --- 315,319 ---- StringBuffer _value; Hashtable ret; ! ret = new SpecialHashtable (); attributes = getAttributesEx (); *************** *** 414,418 **** char quote; Attribute attribute; ! att = new Vector (); for (Enumeration e = attributes.keys (); e.hasMoreElements (); ) --- 414,418 ---- char quote; Attribute attribute; ! att = new Vector (); for (Enumeration e = attributes.keys (); e.hasMoreElements (); ) *************** *** 441,445 **** * Sets the attributes. * NOTE: Values of the extended hashtable are two element arrays of String, ! * with the first element being the original name (not uppercased), * and the second element being the value. * @param attribs The attribute collection to set. --- 441,445 ---- * Sets the attributes. * NOTE: Values of the extended hashtable are two element arrays of String, ! * with the first element being the original name (not uppercased), * and the second element being the value. * @param attribs The attribute collection to set. *************** *** 467,471 **** return (nodeBegin); } ! /** * Sets the nodeEnd. --- 467,471 ---- return (nodeBegin); } ! /** * Sets the nodeEnd. *************** *** 476,480 **** nodeEnd = tagEnd; } ! /** * Gets the nodeEnd. --- 476,480 ---- nodeEnd = tagEnd; } ! /** * Gets the nodeEnd. *************** *** 613,617 **** /** * Is this an empty xml tag of the form<br> ! * <tag/> * @return boolean */ --- 613,617 ---- /** * Is this an empty xml tag of the form<br> ! * <tag/> * @return boolean */ Index: package.html =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/lexer/nodes/package.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** package.html 8 Sep 2003 02:26:28 -0000 1.3 --- package.html 10 Sep 2003 03:38:18 -0000 1.4 *************** *** 19,23 **** 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 --- 19,23 ---- 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 *************** *** 26,38 **** 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 ! --> <TITLE>Nodes Package</TITLE> --- 26,38 ---- 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 ! --> <TITLE>Nodes Package</TITLE> |