Thread: [Htmlparser-cvs] htmlparser/src/org/htmlparser/scanners ScriptScanner.java,1.57,1.58 StyleScanner.ja
Brought to you by:
derrickoswald
From: Derrick O. <der...@us...> - 2004-06-14 00:07:01
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/scanners In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3132/scanners Modified Files: ScriptScanner.java StyleScanner.java Log Message: Rework PrototypicalNodeFactory to use interfaces. Index: StyleScanner.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/scanners/StyleScanner.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** StyleScanner.java 24 May 2004 16:18:30 -0000 1.34 --- StyleScanner.java 14 Jun 2004 00:06:52 -0000 1.35 *************** *** 70,80 **** boolean done; int position; ! Text last; Tag end; NodeFactory factory; CompositeTag ret; done = false; ! last = null; end = null; factory = lexer.getNodeFactory (); --- 70,83 ---- boolean done; int position; ! int startpos; ! int endpos; Tag end; NodeFactory factory; + Text content; CompositeTag ret; done = false; ! startpos = lexer.getPosition (); ! endpos = startpos; end = null; factory = lexer.getNodeFactory (); *************** *** 87,91 **** node = lexer.nextNode (true); if (null == node) ! break; else if (node instanceof Tag) --- 90,94 ---- node = lexer.nextNode (true); if (null == node) ! done = true; else if (node instanceof Tag) *************** *** 102,144 **** } else - { // must be a string, even though it looks like a tag ! if (null != last) ! // append it to the previous one ! last.setEndPosition (node.elementEnd ()); ! else ! last = factory.createStringNode (lexer.getPage (), node.elementBegin (), node.elementEnd ()); ! } else if (node instanceof Remark) ! { ! if (null != last) ! last.setEndPosition (node.getEndPosition ()); ! else ! { ! // last = factory.createStringNode (lexer, node.elementBegin (), node.elementEnd ()); ! last = factory.createStringNode (lexer.getPage (), node.elementBegin (), node.elementEnd ()); ! } ! } else // Text ! { ! if (null != last) ! last.setEndPosition (node.getEndPosition ()); ! else ! last = (Text)node; ! } } while (!done); ! // build new string tag if required ! if (null == last) ! last = factory.createStringNode (lexer.getPage (), position, position); // build new end tag if required if (null == end) ! end = new Tag (lexer.getPage (), tag.getEndPosition (), tag.getEndPosition (), new Vector ()); ret = (CompositeTag)tag; ret.setEndTag (end); ! ret.setChildren (new NodeList (last)); ! last.setParent (ret); end.setParent (ret); ret.doSemanticAction (); --- 105,126 ---- } else // must be a string, even though it looks like a tag ! endpos = node.getEndPosition (); else if (node instanceof Remark) ! endpos = node.getEndPosition (); else // Text ! endpos = node.getEndPosition (); } while (!done); ! content = factory.createStringNode (lexer.getPage (), startpos, endpos); // build new end tag if required if (null == end) ! end = new Tag (lexer.getPage (), endpos, endpos, new Vector ()); ret = (CompositeTag)tag; ret.setEndTag (end); ! ret.setChildren (new NodeList (content)); ! content.setParent (ret); end.setParent (ret); ret.doSemanticAction (); Index: ScriptScanner.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/scanners/ScriptScanner.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** ScriptScanner.java 24 May 2004 16:18:30 -0000 1.57 --- ScriptScanner.java 14 Jun 2004 00:06:52 -0000 1.58 *************** *** 75,85 **** boolean done; int position; ! Text last; Tag end; NodeFactory factory; CompositeTag ret; done = false; ! last = null; end = null; factory = lexer.getNodeFactory (); --- 75,88 ---- boolean done; int position; ! int startpos; ! int endpos; Tag end; NodeFactory factory; + Text content; CompositeTag ret; done = false; ! startpos = lexer.getPosition (); ! endpos = startpos; end = null; factory = lexer.getNodeFactory (); *************** *** 94,98 **** String code = ScriptDecoder.Decode (lexer.getPage (), lexer.getCursor ()); ((ScriptTag)tag).setScriptCode (code); ! last = factory.createStringNode (lexer.getPage (), start, lexer.getPosition ()); } } --- 97,101 ---- String code = ScriptDecoder.Decode (lexer.getPage (), lexer.getCursor ()); ((ScriptTag)tag).setScriptCode (code); ! endpos = lexer.getPosition (); } } *************** *** 105,109 **** node = lexer.nextNode (true); if (null == node) ! break; else if (node instanceof Tag) --- 108,112 ---- node = lexer.nextNode (true); if (null == node) ! done = true; else if (node instanceof Tag) *************** *** 120,162 **** } else - { // must be a string, even though it looks like a tag ! if (null != last) ! // append it to the previous one ! last.setEndPosition (node.elementEnd ()); ! else ! last = factory.createStringNode (lexer.getPage (), node.elementBegin (), node.elementEnd ()); ! } else if (node instanceof Remark) ! { ! if (null != last) ! last.setEndPosition (node.getEndPosition ()); ! else ! { ! // last = factory.createStringNode (lexer, node.elementBegin (), node.elementEnd ()); ! last = factory.createStringNode (lexer.getPage (), node.elementBegin (), node.elementEnd ()); ! } ! } else // Text ! { ! if (null != last) ! last.setEndPosition (node.getEndPosition ()); ! else ! last = (Text)node; ! } ! } while (!done); ! // build new string tag if required ! if (null == last) ! last = factory.createStringNode (lexer.getPage (), position, position); // build new end tag if required if (null == end) ! end = new Tag (lexer.getPage (), tag.getEndPosition (), tag.getEndPosition (), new Vector ()); ret = (CompositeTag)tag; ret.setEndTag (end); ! ret.setChildren (new NodeList (last)); ! last.setParent (ret); end.setParent (ret); ret.doSemanticAction (); --- 123,143 ---- } else // must be a string, even though it looks like a tag ! endpos = node.getEndPosition (); else if (node instanceof Remark) ! endpos = node.getEndPosition (); else // Text ! endpos = node.getEndPosition (); } while (!done); ! content = factory.createStringNode (lexer.getPage (), startpos, endpos); // build new end tag if required if (null == end) ! end = new Tag (lexer.getPage (), endpos, endpos, new Vector ()); ret = (CompositeTag)tag; ret.setEndTag (end); ! ret.setChildren (new NodeList (content)); ! content.setParent (ret); end.setParent (ret); ret.doSemanticAction (); |