de.dbsystems.simplescrape
Class HTMLTagAttributes

java.lang.Object
  extended by de.dbsystems.simplescrape.HTMLTagAttributes

public class HTMLTagAttributes
extends java.lang.Object

Defines a class for parsing and storing the attributes of an HTML tag. Note that the attributes are not parsed until they are actually needed.

Since:
04.04.2007
Author:
Ronald Bieber, DB Systems GmbH

Field Summary
static java.lang.String NO_VALUE
           
static java.lang.String QUOTATION_CHARS
           
 
Constructor Summary
HTMLTagAttributes(java.lang.String attributesString)
          Constructs new attributes from a string.
 
Method Summary
 boolean exists(java.lang.String name)
          Returns, whether an attribute was defined within this tag.
 java.lang.String get(java.lang.String name)
          Get the value of a given attribute.
 java.util.Enumeration<java.lang.String> getAttributeNames()
          Returns an enumeration of all the attribute names found.
 int getSize()
          Return the number of attributes stored herein.
 boolean match(HTMLTagAttributes other, ScrapeOptions options)
           
 java.lang.String toString()
          Returns the attribute string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_VALUE

public static final java.lang.String NO_VALUE
See Also:
Constant Field Values

QUOTATION_CHARS

public static final java.lang.String QUOTATION_CHARS
See Also:
Constant Field Values
Constructor Detail

HTMLTagAttributes

public HTMLTagAttributes(java.lang.String attributesString)
Constructs new attributes from a string. The attributes are not parsed right away. Instead, they are only parsed when needed.

Parameters:
attributesString - The attribute string from inside the tag. Example: if the tag is "
", use " class=frame" as attributesString.
Method Detail

exists

public boolean exists(java.lang.String name)
Returns, whether an attribute was defined within this tag.

Parameters:
name - The name of the attribute to be checked.
Returns:
Whether it exists or not.

get

public java.lang.String get(java.lang.String name)
Get the value of a given attribute.

Parameters:
name - The attribute name (not case-sensitive).
Returns:
the value of that attribute, or null, if that attribute was not present in this tag. For unary attributes an empty string is returned. The result is not quoted, regardless of the quoting originally used.

toString

public java.lang.String toString()
Returns the attribute string. This string is identical to the original format and has not been normalized in any way.

Overrides:
toString in class java.lang.Object

getAttributeNames

public java.util.Enumeration<java.lang.String> getAttributeNames()
Returns an enumeration of all the attribute names found.

Returns:
The attribute names as an enumeration of strings. This can be null, if no attributes are present.

getSize

public int getSize()
Return the number of attributes stored herein.

Returns:
The number of attributes.

match

public boolean match(HTMLTagAttributes other,
                     ScrapeOptions options)