[Htmlparser-cvs] htmlparser/src/org/htmlparser/tags CompositeTag.java,1.48,1.49 LinkTag.java,1.29,1.
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-08-23 19:15:23
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags In directory sc8-pr-cvs1:/tmp/cvs-serv20167/tags Modified Files: CompositeTag.java LinkTag.java SelectTag.java Tag.java Log Message: Sixth drop for new i/o subsystem. Isolated htmllexer.jar file and made it compileable and runnable on JDK 1.1 systems. The build.xml file now has four new targets for separate compiling and jaring of the lexer and parser. Significantly refactored the existing Node interface and AbstractNode class to achieve isolation. They now support get/setChildren(), rather than CompositeTag. Various scanners that were directly accessing the childTags node list were affected. The get/setParent is now a generic Node rather than a CompositeTag. The visitor accept() signature was changed to Object to avoid dragging in visitors code. This was *not* changed on classes derived from Tag, although it could be. ChainedException now uses/returns a Vector. Removed the cruft from lexer nodes where possible. Index: CompositeTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/CompositeTag.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** CompositeTag.java 11 Aug 2003 00:18:30 -0000 1.48 --- CompositeTag.java 23 Aug 2003 17:14:45 -0000 1.49 *************** *** 39,65 **** public abstract class CompositeTag extends Tag { protected Tag startTag, endTag; - protected NodeList childTags; public CompositeTag(TagData tagData, CompositeTagData compositeTagData) { super(tagData); - this.childTags = compositeTagData.getChildren(); this.startTag = compositeTagData.getStartTag(); this.endTag = compositeTagData.getEndTag(); } ! ! public SimpleNodeIterator children() { ! return childTags.elements(); } ! public Node getChild(int index) { ! return childTags.elementAt(index); } ! ! public Node [] getChildrenAsNodeArray() { ! return childTags.toNodeArray(); } ! public NodeList getChildren() { ! return childTags; } --- 39,85 ---- public abstract class CompositeTag extends Tag { protected Tag startTag, endTag; public CompositeTag(TagData tagData, CompositeTagData compositeTagData) { super(tagData); this.startTag = compositeTagData.getStartTag(); this.endTag = compositeTagData.getEndTag(); + setChildren (compositeTagData.getChildren()); } ! ! /** ! * Get an iterator over the children of this node. ! * @return Am iterator over the children of this node. ! */ ! public SimpleNodeIterator children () ! { ! return (getChildren ().elements ()); } ! /** ! * Get the child of this node at the given position. ! * @param index The in the node list of the child. ! * @return The child at that index. ! */ ! public Node getChild (int index) ! { ! return (getChildren ().elementAt (index)); } ! ! /** ! * Get the children as an array of <code>Node</code> objects. ! * @return The children in an array. ! */ ! public Node [] getChildrenAsNodeArray () ! { ! return (getChildren ().toNodeArray ()); } ! /** ! * Remove the child at the position given. ! * @param i The index of the child to remove. ! */ ! public void removeChild (int i) ! { ! getChildren ().remove (i); } *************** *** 178,183 **** * @return NodeList */ ! public NodeList searchFor(Class classType) { ! return childTags.searchFor(classType); } /** --- 198,204 ---- * @return NodeList */ ! public NodeList searchFor(Class classType) ! { ! return (getChildren ().searchFor (classType)); } /** *************** *** 247,251 **** */ public Node childAt(int index) { ! return childTags.elementAt(index); } --- 268,272 ---- */ public Node childAt(int index) { ! return (getChildren ().elementAt (index)); } *************** *** 290,294 **** public int getChildCount() { ! return childTags.size(); } --- 311,315 ---- public int getChildCount() { ! return (getChildren ().size ()); } Index: LinkTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/LinkTag.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** LinkTag.java 15 Aug 2003 20:51:48 -0000 1.29 --- LinkTag.java 23 Aug 2003 17:14:45 -0000 1.30 *************** *** 247,254 **** super.accept(visitor); } - - public void removeChild(int i) { - childTags.remove(i); - } - } --- 247,249 ---- Index: SelectTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/SelectTag.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** SelectTag.java 11 Aug 2003 00:18:30 -0000 1.22 --- SelectTag.java 23 Aug 2003 17:14:45 -0000 1.23 *************** *** 62,69 **** public String toString() { ! StringBuffer lString = new StringBuffer(ParserUtils.toString(this)); ! for(int i=0;i<childTags.size(); i++) { ! OptionTag optionTag = (OptionTag)childTags.elementAt(i); lString.append(optionTag.toString()).append("\n"); } --- 62,73 ---- public String toString() { ! StringBuffer lString; ! NodeList children; ! ! lString = new StringBuffer(ParserUtils.toString(this)); ! children = getChildren (); ! for(int i=0;i<children.size(); i++) { ! OptionTag optionTag = (OptionTag)children.elementAt(i); lString.append(optionTag.toString()).append("\n"); } Index: Tag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/Tag.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Tag.java 15 Aug 2003 20:51:48 -0000 1.40 --- Tag.java 23 Aug 2003 17:14:45 -0000 1.41 *************** *** 579,582 **** --- 579,592 ---- } + /** + * Handle a visitor. + * <em>NOTE: This currently defers to accept(NodeVisitor), but eventually + * subclasses of Node should be overriding accept(Object) directly.</em> + * @param visitor The <code>NodeVisitor</code> object. + */ + public void accept(Object visitor) { + accept ((NodeVisitor)visitor); + } + public void accept(NodeVisitor visitor) { visitor.visitTag(this); |