Package org.htmlparser.tags
Class LinkTag
- java.lang.Object
-
- org.htmlparser.nodes.AbstractNode
-
- org.htmlparser.nodes.TagNode
-
- org.htmlparser.tags.CompositeTag
-
- org.htmlparser.tags.LinkTag
-
public class LinkTag extends CompositeTag
Identifies a link tag.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringmLinkThe URL where the link points to-
Fields inherited from class org.htmlparser.tags.CompositeTag
mDefaultCompositeScanner, mEndTag
-
Fields inherited from class org.htmlparser.nodes.TagNode
breakTags, mAttributes, mDefaultScanner
-
-
Constructor Summary
Constructors Constructor Description LinkTag()Constructor creates an LinkTag object, which basically stores the location where the link points to, and the text it contains.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringextractLink()Extract the link from the HREF attribute.java.lang.StringgetAccessKey()Get theACCESSKEYattribute, if any.java.lang.String[]getEnders()Return the set of tag names that cause this tag to finish.java.lang.String[]getEndTagEnders()Return the set of end tag names that cause this tag to finish.java.lang.String[]getIds()Return the set of names handled by this tag.java.lang.StringgetLink()Returns the url as a string, to which this link points.java.lang.StringgetLinkText()Returns the text contained inside this link tag.booleanisFTPLink()Tests if the link is an FTP link.booleanisHTTPLikeLink()Tests if the link is an HTTP link or one of its variations (HTTPS, etc.).booleanisHTTPLink()Tests if the link is an HTTP link.booleanisHTTPSLink()Tests if the link is an HTTPS link.booleanisIRCLink()Tests if the link is an IRC link.booleanisJavascriptLink()Tests if the link is javascriptbooleanisMailLink()Is this a mail addressvoidsetJavascriptLink(boolean newJavascriptLink)Set the link as a javascript link.voidsetLink(java.lang.String link)Set theHREFattribute.voidsetMailLink(boolean newMailLink)Insert the method's description here.java.lang.StringtoString()Return the contents of this link node as a string suitable for debugging.-
Methods inherited from class org.htmlparser.tags.CompositeTag
accept, childAt, children, collectInto, digupStringNode, elements, findPositionOf, findPositionOf, findPositionOf, getChild, getChildCount, getChildrenAsNodeArray, getChildrenHTML, getEndTag, getStringText, getText, putChildrenInto, putEndTagInto, removeChild, searchByName, searchFor, searchFor, searchFor, searchFor, setEndTag, toHtml, toPlainTextString, toString
-
Methods inherited from class org.htmlparser.nodes.TagNode
breaksFlow, getAttribute, getAttributeEx, getAttributesEx, getEndingLineNumber, getRawTagName, getStartingLineNumber, getTagBegin, getTagEnd, getTagName, getThisScanner, isEmptyXmlTag, isEndTag, removeAttribute, setAttribute, setAttribute, setAttribute, setAttributeEx, setAttributesEx, setEmptyXmlTag, setTagBegin, setTagEnd, setTagName, setText, setThisScanner
-
Methods inherited from class org.htmlparser.nodes.AbstractNode
clone, doSemanticAction, getChildren, getEndPosition, getFirstChild, getLastChild, getNextSibling, getPage, getParent, getPreviousSibling, getStartPosition, setChildren, setEndPosition, setPage, setParent, setStartPosition, toHtml
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.htmlparser.Node
clone, doSemanticAction, getChildren, getEndPosition, getFirstChild, getLastChild, getNextSibling, getPage, getParent, getPreviousSibling, getStartPosition, setChildren, setEndPosition, setPage, setParent, setStartPosition, toHtml
-
-
-
-
Constructor Detail
-
LinkTag
public LinkTag()
Constructor creates an LinkTag object, which basically stores the location where the link points to, and the text it contains.In order to get the contents of the link tag, use the method children(), which returns an enumeration of nodes encapsulated within the link.
The following code will get all the images inside a link tag.
Node node ; ImageTag imageTag; for (Enumeration e=linkTag.children();e.hasMoreElements();) { node = (Node)e.nextElement(); if (node instanceof ImageTag) { imageTag = (ImageTag)node; // Process imageTag } }
-
-
Method Detail
-
getIds
public java.lang.String[] getIds()
Return the set of names handled by this tag.
-
getEnders
public java.lang.String[] getEnders()
Return the set of tag names that cause this tag to finish.
-
getEndTagEnders
public java.lang.String[] getEndTagEnders()
Return the set of end tag names that cause this tag to finish.- Specified by:
getEndTagEndersin interfaceTag- Overrides:
getEndTagEndersin classTagNode- Returns:
- The names of following end tags that stop further scanning.
-
getAccessKey
public java.lang.String getAccessKey()
Get theACCESSKEYattribute, if any.- Returns:
- The value of the
ACCESSKEYattribute, ornullif the attribute doesn't exist.
-
getLink
public java.lang.String getLink()
Returns the url as a string, to which this link points. This string has had the "mailto:" and "javascript:" protocol stripped off the front (if those predicates returntrue) but not for other protocols. Don't ask me why, it's a legacy thing.- Returns:
- The URL for this
Atag.
-
getLinkText
public java.lang.String getLinkText()
Returns the text contained inside this link tag.
-
isMailLink
public boolean isMailLink()
Is this a mail address- Returns:
- boolean true/false
-
isJavascriptLink
public boolean isJavascriptLink()
Tests if the link is javascript- Returns:
- flag indicating if the link is a javascript code
-
isFTPLink
public boolean isFTPLink()
Tests if the link is an FTP link.- Returns:
- flag indicating if this link is an FTP link
-
isIRCLink
public boolean isIRCLink()
Tests if the link is an IRC link.- Returns:
- flag indicating if this link is an IRC link
-
isHTTPLink
public boolean isHTTPLink()
Tests if the link is an HTTP link.- Returns:
- flag indicating if this link is an HTTP link
-
isHTTPSLink
public boolean isHTTPSLink()
Tests if the link is an HTTPS link.- Returns:
- flag indicating if this link is an HTTPS link
-
isHTTPLikeLink
public boolean isHTTPLikeLink()
Tests if the link is an HTTP link or one of its variations (HTTPS, etc.).- Returns:
- flag indicating if this link is an HTTP link or one of its variations (HTTPS, etc.)
-
setMailLink
public void setMailLink(boolean newMailLink)
Insert the method's description here. Creation date: (8/3/2001 1:49:31 AM)- Parameters:
newMailLink- boolean
-
setJavascriptLink
public void setJavascriptLink(boolean newJavascriptLink)
Set the link as a javascript link.- Parameters:
newJavascriptLink- flag indicating if the link is a javascript code
-
toString
public java.lang.String toString()
Return the contents of this link node as a string suitable for debugging.- Specified by:
toStringin interfaceNode- Overrides:
toStringin classCompositeTag- Returns:
- A string representation of this node.
-
setLink
public void setLink(java.lang.String link)
Set theHREFattribute.- Parameters:
link- The new value of theHREFattribute.
-
extractLink
public java.lang.String extractLink()
Extract the link from the HREF attribute.- Returns:
- The URL from the HREF attibute. This is absolute if the tag has a valid page.
-
-