[Htmlparser-cvs] htmlparser/src/org/htmlparser/filters HasAttributeFilter.java,1.2,1.3 StringFilter.
Brought to you by:
derrickoswald
From: <der...@pr...> - 2004-01-27 14:09:14
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/filters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26191/filters Modified Files: HasAttributeFilter.java StringFilter.java TagNameFilter.java Log Message: Fix bug #883664 toUpperCase on tag names and attributes depends on locale Added locale information to all relevant toUpperCase() calls, with an English locale for tag names and attribute names, or developers choice of locale for methods that do uppercase conversion as part of their algorithms. Index: HasAttributeFilter.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/filters/HasAttributeFilter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HasAttributeFilter.java 10 Jan 2004 00:06:03 -0000 1.2 --- HasAttributeFilter.java 25 Jan 2004 21:32:57 -0000 1.3 *************** *** 27,30 **** --- 27,32 ---- package org.htmlparser.filters; + import java.util.Locale; + import org.htmlparser.Node; import org.htmlparser.NodeFilter; *************** *** 63,67 **** public HasAttributeFilter (String attribute, String value) { ! mAttribute = attribute.toUpperCase (); mValue = value; } --- 65,69 ---- public HasAttributeFilter (String attribute, String value) { ! mAttribute = attribute.toUpperCase (Locale.ENGLISH); mValue = value; } Index: StringFilter.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/filters/StringFilter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StringFilter.java 8 Nov 2003 21:30:58 -0000 1.1 --- StringFilter.java 25 Jan 2004 21:32:58 -0000 1.2 *************** *** 27,30 **** --- 27,32 ---- package org.htmlparser.filters; + import java.util.Locale; + import org.htmlparser.Node; import org.htmlparser.NodeFilter; *************** *** 47,50 **** --- 49,57 ---- /** + * The locale to use converting to uppercase in the case insensitive searches. + */ + protected Locale mLocale; + + /** * Creates a new instance of StringFilter that accepts string nodes containing a certain string. * The comparison is case insensitive. *************** *** 64,72 **** public StringFilter (String pattern, boolean case_sensitive) { mCaseSensitive = case_sensitive; if (mCaseSensitive) mPattern = pattern; else ! mPattern = pattern.toUpperCase (); } --- 71,93 ---- public StringFilter (String pattern, boolean case_sensitive) { + this (pattern, case_sensitive, null); + } + + /** + * Creates a new instance of StringFilter that accepts string nodes containing a certain string. + * @param pattern The pattern to search for. + * @param case_sensitive If <code>true</code>, comparisons are performed + * respecting case. + */ + public StringFilter (String pattern, boolean case_sensitive, Locale locale) + { mCaseSensitive = case_sensitive; if (mCaseSensitive) mPattern = pattern; else ! { ! mLocale = (null == locale) ? Locale.ENGLISH : locale; ! mPattern = pattern.toUpperCase (mLocale); ! } } *************** *** 85,89 **** string = ((StringNode)node).getText (); if (!mCaseSensitive) ! string = string.toUpperCase (); ret = -1 != string.indexOf (mPattern); } --- 106,110 ---- string = ((StringNode)node).getText (); if (!mCaseSensitive) ! string = string.toUpperCase (mLocale); ret = -1 != string.indexOf (mPattern); } Index: TagNameFilter.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/filters/TagNameFilter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TagNameFilter.java 8 Nov 2003 21:30:58 -0000 1.1 --- TagNameFilter.java 25 Jan 2004 21:32:58 -0000 1.2 *************** *** 27,30 **** --- 27,32 ---- package org.htmlparser.filters; + import java.util.Locale; + import org.htmlparser.Node; import org.htmlparser.NodeFilter; *************** *** 49,53 **** public TagNameFilter (String name) { ! mName = name.toUpperCase (); } --- 51,55 ---- public TagNameFilter (String name) { ! mName = name.toUpperCase (Locale.ENGLISH); } |