if (tokentype == NAME)
{
String attrib = token;
nextToken ();
if ("]".equals (token))
ret = new HasAttributeFilter (unescape (attrib));
else if (tokentype == RELATION)
{
String val = null, rel = token;
nextToken ();
if (tokentype == QUOTEDSTRING)
val = unescape (token.substring (1, token.length () - 1));
else if (tokentype == NAME)
val = unescape (token);
if ("~=".equals (rel) && val != null)
ret = new AttribMatchFilter (unescape (attrib), "\\b"
+ val.replaceAll ("([^a-zA-Z0-9])", "\\\\$1")
+ "\\b");
else if ("|=".equals (rel) && val != null)
ret = new AttribMatchFilter (unescape (attrib), val.replaceAll ("([^a-zA-Z0-9])", "\\\\$1")
+ "\\-[^a-zA-Z0-9]*");
else if ("=".equals (rel) && val != null)
ret = new HasAttributeFilter (attrib, val);
}
}
if (ret == null)
throw new IllegalArgumentException ("Syntax error at " + token
+ tokentype);