[Htmlparser-cvs] htmlparser/src/org/htmlparser/filters HasAttributeFilter.java,1.1,1.2
Brought to you by:
derrickoswald
From: <der...@us...> - 2004-01-10 00:06:06
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/filters In directory sc8-pr-cvs1:/tmp/cvs-serv24025/filters Modified Files: HasAttributeFilter.java Log Message: First pass at the wiki capturer. Added useful extensions to the HasAttributeFilter, SiteCapturer and NodeList Index: HasAttributeFilter.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/filters/HasAttributeFilter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HasAttributeFilter.java 8 Nov 2003 21:30:58 -0000 1.1 --- HasAttributeFilter.java 10 Jan 2004 00:06:03 -0000 1.2 *************** *** 29,36 **** import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.lexer.nodes.TagNode; /** ! * This class accepts all tags that have a child acceptable to the filter. */ public class HasAttributeFilter implements NodeFilter --- 29,37 ---- import org.htmlparser.Node; import org.htmlparser.NodeFilter; + import org.htmlparser.lexer.nodes.Attribute; import org.htmlparser.lexer.nodes.TagNode; /** ! * This class accepts all tags that have a certain attribute, and optionally, with a certain value. */ public class HasAttributeFilter implements NodeFilter *************** *** 42,45 **** --- 43,51 ---- /** + * The value to check for. + */ + protected String mValue; + + /** * Creates a new instance of HasAttributeFilter that accepts tags with the given attribute. * @param attribute The attribute to search for. *************** *** 47,51 **** --- 53,68 ---- public HasAttributeFilter (String attribute) { + this (attribute, null); + } + + /** + * Creates a new instance of HasAttributeFilter that accepts tags with the given attribute. + * @param attribute The attribute to search for. + * @param value The value that must be matched, or null if any value will match. + */ + public HasAttributeFilter (String attribute, String value) + { mAttribute = attribute.toUpperCase (); + mValue = value; } *************** *** 57,60 **** --- 74,78 ---- { TagNode tag; + Attribute attribute; boolean ret; *************** *** 63,67 **** { tag = (TagNode)node; ! ret = null != tag.getAttributeEx (mAttribute); } --- 81,88 ---- { tag = (TagNode)node; ! attribute = tag.getAttributeEx (mAttribute); ! ret = null != attribute; ! if (ret && (null != mValue)) ! ret = mValue.equals (attribute.getValue ()); } |