ported over the HTML Checker from the original Venice source, somewhat improved

in design
This commit is contained in:
Eric J. Bowersox
2003-06-07 02:50:42 +00:00
parent 2e395d636a
commit 92a569cbbd
41 changed files with 4517 additions and 49 deletions

View File

@@ -11,7 +11,7 @@
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -33,7 +33,6 @@ public final class AnyCharMatcher
*/
private char[] charset; // the set of characters to look for
private int[] locs; // a temporary array used for locations
/*--------------------------------------------------------------------------------
* Constructors
@@ -48,7 +47,6 @@ public final class AnyCharMatcher
public AnyCharMatcher(char[] charset)
{
this.charset = charset;
this.locs = new int[charset.length];
} // end constructor
@@ -60,7 +58,6 @@ public final class AnyCharMatcher
public AnyCharMatcher(String charset)
{
this.charset = charset.toCharArray();
this.locs = new int[charset.length()];
} // end constructor
@@ -83,32 +80,22 @@ public final class AnyCharMatcher
{
if (str==null)
return -1;
int numindexes = 0;
int i;
for (i=0; i<charset.length; i++)
{ // locate the index of the first HTML character
boolean found = false;
int rc = Integer.MAX_VALUE;
for (int i=0; (rc>0) && (i<charset.length); i++)
{ // get the index of this character
int tmp = str.indexOf(charset[i]);
if (tmp>=0)
locs[numindexes++] = tmp;
{ // found a matching character
found = true;
if (tmp<rc)
rc = tmp;
} // end if
} // end for
if (numindexes==0)
return -1; // no characters found
else if (numindexes==1)
return locs[0]; // only one found
int rc = locs[0];
for (i=1; i<numindexes; i++)
{ // this loop determines the lowest possible return value
if (rc==0)
return 0; // can't get any lower!
if (locs[i]<rc)
rc = locs[i]; // this is now the lowest
} // end for
return rc;
return (found ? rc : -1);
} // end get
@@ -126,34 +113,23 @@ public final class AnyCharMatcher
{
if (str==null)
return -1;
int numindexes = 0;
int i;
for (i=0; i<charset.length; i++)
{ // locate the index of the first HTML character
boolean found = false;
int limit = str.length() - 1;
int rc = Integer.MIN_VALUE;
for (int i=0; (rc<limit) && (i<charset.length); i++)
{ // get the index of this character
int tmp = str.lastIndexOf(charset[i]);
if (tmp>=0)
locs[numindexes++] = tmp;
{ // found a matching character
found = true;
if (tmp>rc)
rc = tmp;
} // end if
} // end for
if (numindexes==0)
return -1; // no characters found
else if (numindexes==1)
return locs[0]; // only one found
int rc = locs[0];
int limit = str.length() - 1;
for (i=1; i<numindexes; i++)
{ // this loop determines the highest possible return value
if (rc==limit)
return limit; // can't get any higher!
if (locs[i]>rc)
rc = locs[i]; // this is now the highest
} // end for
return rc;
return (found ? rc : -1);
} // end getLast