[Htmlparser-cvs] htmlparser/src/org/htmlparser/lexer/nodes PageAttribute.java,1.7,1.8
Brought to you by:
derrickoswald
From: <der...@us...> - 2004-03-14 15:51:36
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/lexer/nodes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23217/lexer/nodes Modified Files: PageAttribute.java Log Message: Fix bug #911565 isValued() and isNull() don't work. Rework predicates. Add testPredicates() to attribute tests. Don't rely on value of quote character when getting assignment string. Add testSetQuote(). Index: PageAttribute.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/lexer/nodes/PageAttribute.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PageAttribute.java 2 Jan 2004 16:24:53 -0000 1.7 --- PageAttribute.java 14 Mar 2004 15:42:38 -0000 1.8 *************** *** 240,244 **** public String getAssignment () { - int end; String ret; --- 240,243 ---- *************** *** 248,255 **** if ((null != mPage) && (0 <= mNameEnd) && (0 <= mValueStart)) { ! end = mValueStart; ! if (0 != getQuote ()) ! end--; ! ret = mPage.getText (mNameEnd, end); setAssignment (ret); // cache the value } --- 247,255 ---- if ((null != mPage) && (0 <= mNameEnd) && (0 <= mValueStart)) { ! ret = mPage.getText (mNameEnd, mValueStart); ! // remove a possible quote included in the assignment ! // since mValueStart points at the real start of the value ! if (ret.endsWith ("\"") || ret.endsWith ("'")) ! ret = ret.substring (0, ret.length () - 1); setAssignment (ret); // cache the value } *************** *** 266,270 **** public void getAssignment (StringBuffer buffer) { ! int end; String assignment; --- 266,271 ---- public void getAssignment (StringBuffer buffer) { ! int length; ! char ch; String assignment; *************** *** 274,281 **** if ((null != mPage) && (0 <= mNameEnd) && (0 <= mValueStart)) { ! end = mValueStart; ! if (0 != getQuote ()) ! end--; ! mPage.getText (buffer, mNameEnd, end); } } --- 275,285 ---- if ((null != mPage) && (0 <= mNameEnd) && (0 <= mValueStart)) { ! mPage.getText (buffer, mNameEnd, mValueStart); ! // remove a possible quote included in the assignment ! // since mValueStart points at the real start of the value ! length = buffer.length () - 1; ! ch = buffer.charAt (length); ! if (('\'' == ch) || ('"' == ch)) ! buffer.setLength (length); } } *************** *** 507,512 **** public boolean isStandAlone () { ! return ((null != super.getName ()) && (null == super.getAssignment ()) ! || ((null != mPage) && (0 <= mNameEnd) && (0 > mValueStart))); } --- 511,520 ---- public boolean isStandAlone () { ! return (!isWhitespace () // not whitespace ! && (null == super.getAssignment ()) // and no explicit assignment provided ! && !isValued () // and has no value ! && ((null == mPage) // and either its not coming from a page ! // or it is coming from a page and it doesn't have an assignment part ! || ((null != mPage) && (0 <= mNameEnd) && (0 > mValueStart)))); } *************** *** 518,523 **** public boolean isEmpty () { ! return (((null != super.getAssignment ()) && (null == super.getValue ())) ! || ((null != mPage) && ((0 <= mValueStart) && (0 > mValueEnd)))); } --- 526,535 ---- public boolean isEmpty () { ! return (!isWhitespace () // not whitespace ! && !isStandAlone () // and not standalone ! && (null == super.getValue ()) // and no explicit value provided ! && ((null == mPage) // and either its not coming from a page ! // or it is coming from a page and has no value ! || ((null != mPage) && (0 > mValueEnd)))); } *************** *** 529,534 **** public boolean isValued () { ! return ((null != super.getValue ()) ! || ((null != mPage) && ((0 <= mValueStart) && (0 <= mValueEnd)))); } --- 541,547 ---- public boolean isValued () { ! return ((null != super.getValue ()) // an explicit value provided ! // or it is coming from a page and has a non-empty value ! || ((null != mPage) && ((0 <= mValueStart) && (0 <= mValueEnd)) && (mValueStart != mValueEnd))); } |