[Htmlparser-cvs] htmlparser/src/org/htmlparser Parser.java,1.89,1.90
Brought to you by:
derrickoswald
From: Derrick O. <der...@us...> - 2004-03-18 04:13:47
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24099/src/org/htmlparser Modified Files: Parser.java Log Message: Deprecate LinkProcessor. Functionality moved to Page. Index: Parser.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/Parser.java,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** Parser.java 14 Mar 2004 16:31:40 -0000 1.89 --- Parser.java 18 Mar 2004 04:04:07 -0000 1.90 *************** *** 44,48 **** import org.htmlparser.util.DefaultParserFeedback; import org.htmlparser.util.IteratorImpl; - import org.htmlparser.util.LinkProcessor; import org.htmlparser.util.NodeIterator; import org.htmlparser.util.NodeList; --- 44,47 ---- *************** *** 607,610 **** --- 606,641 ---- /** + * Turn spaces into %20. + * @param url The url containing spaces. + * @return The URL with spaces as %20 sequences. + */ + public static String fixSpaces (String url) + { + int index; + int length; + char ch; + StringBuffer returnURL; + + index = url.indexOf (' '); + if (-1 != index) + { + length = url.length (); + returnURL = new StringBuffer (length * 3); + returnURL.append (url.substring (0, index)); + for (int i = index; i < length; i++) + { + ch = url.charAt (i); + if (ch==' ') + returnURL.append ("%20"); + else + returnURL.append (ch); + } + url = returnURL.toString (); + } + + return (url); + } + + /** * Opens a connection based on a given string. * The string is either a file, in which case <code>file://localhost</code> *************** *** 628,632 **** try { ! url = new URL (LinkProcessor.fixSpaces (string)); ret = openConnection (url, feedback); } --- 659,663 ---- try { ! url = new URL (fixSpaces (string)); ret = openConnection (url, feedback); } *************** *** 642,646 **** buffer.append ("/"); buffer.append (resource); ! url = new URL (LinkProcessor.fixSpaces (buffer.toString ())); ret = openConnection (url, feedback); if (null != feedback) --- 673,677 ---- buffer.append ("/"); buffer.append (resource); ! url = new URL (fixSpaces (buffer.toString ())); ret = openConnection (url, feedback); if (null != feedback) |