org.htmlparser.tags

Class ImageTag

Implemented Interfaces:
Cloneable, Node, Serializable, Tag

public class ImageTag
extends TagNode

Identifies an image tag.

Field Summary

protected String
imageURL
Holds the set value of the SRC attribute, since this can differ from the attribute value due to relative references resolved by the scanner.

Fields inherited from class org.htmlparser.nodes.TagNode

breakTags, mAttributes, mDefaultScanner

Fields inherited from class org.htmlparser.nodes.AbstractNode

children, mPage, nodeBegin, nodeEnd, parent

Constructor Summary

ImageTag()
Create a new image tag.

Method Summary

String
extractImageLocn()
Extract the location of the image Given the tag (with attributes), and the url of the html page in which this tag exists, perform best effort to extract the 'intended' URL.
String[]
getIds()
Return the set of names handled by this tag.
String
getImageURL()
Returns the location of the image.
void
setImageURL(String url)
Set the SRC attribute.

Methods inherited from class org.htmlparser.nodes.TagNode

accept, breaksFlow, getAttribute, getAttributeEx, getAttributesEx, getEndTag, getEndTagEnders, getEnders, getEndingLineNumber, getIds, getRawTagName, getStartingLineNumber, getTagBegin, getTagEnd, getTagName, getText, getThisScanner, isEmptyXmlTag, isEndTag, removeAttribute, setAttribute, setAttribute, setAttribute, setAttributeEx, setAttributesEx, setEmptyXmlTag, setEndTag, setTagBegin, setTagEnd, setTagName, setText, setThisScanner, toHtml, toPlainTextString, toString

Methods inherited from class org.htmlparser.nodes.AbstractNode

accept, clone, collectInto, doSemanticAction, getChildren, getEndPosition, getFirstChild, getLastChild, getNextSibling, getPage, getParent, getPreviousSibling, getStartPosition, getText, setChildren, setEndPosition, setPage, setParent, setStartPosition, setText, toHtml, toHtml, toPlainTextString, toString

Field Details

imageURL

protected String imageURL
Holds the set value of the SRC attribute, since this can differ from the attribute value due to relative references resolved by the scanner.

Constructor Details

ImageTag

public ImageTag()
Create a new image tag.

Method Details

extractImageLocn

public String extractImageLocn()
Extract the location of the image Given the tag (with attributes), and the url of the html page in which this tag exists, perform best effort to extract the 'intended' URL. Attempts to handle such attributes as:
 <IMG SRC=http://www.redgreen.com> - normal
 <IMG SRC =http://www.redgreen.com> - space between attribute name and equals sign
 <IMG SRC= http://www.redgreen.com> - space between equals sign and attribute value
 <IMG SRC = http://www.redgreen.com> - space both sides of equals sign
 
Returns:
The relative URL for the image.

getIds

public String[] getIds()
Return the set of names handled by this tag.
Specified by:
getIds in interface Tag
Overrides:
getIds in interface TagNode
Returns:
The names to be matched that create tags of this type.

getImageURL

public String getImageURL()
Returns the location of the image.
Returns:
The absolute URL for this image.

setImageURL

public void setImageURL(String url)
Set the SRC attribute.
Parameters:
url - The new value of the SRC attribute.

HTML Parser is an open source library released under LGPL. SourceForge.net