public static int getIntegerAttributeValue(Element el, String key, int def)(Code)
Fetches an integer attribute value. HtmlAttribute values
are stored as a string, and this is a convenience method
to convert to an actual integer.
Parameters: attr - the set of attributes to use to try to fetch a value Parameters: key - the key to use to fetch the value Parameters: def - the default value to use if the attribute isn'tdefined or there is an error converting to an integer
Very similar to Integer.parseInt (based on it), but more liberal
about what it allows. Specifically, it allows the string to have
a suffix that's not a number; this is ignored. For example
"100px" will return "100". Integer.parseInt would throw an
exception. This specific case is useful, since for example a
buggy
tag might set border="1px" - confusing attributes
with CSS style attributes - and this would with Integer.parseInt
evaluate to 0, whereas both Mozilla and Safari will use a border
of 1. Unlike Integer.parseInt, we only support base 10.