HTML Parser Home Page

org.htmlparser.tags
Class LinkTag

java.lang.Object
  extended byorg.htmlparser.AbstractNode
      extended byorg.htmlparser.lexer.nodes.TagNode
          extended byorg.htmlparser.tags.Tag
              extended byorg.htmlparser.tags.CompositeTag
                  extended byorg.htmlparser.tags.LinkTag
All Implemented Interfaces:
Cloneable, Node, Serializable

public class LinkTag
extends CompositeTag

Identifies a link tag.

See Also:
Serialized Form

Field Summary
protected  String mLink
          The URL where the link points to
 
Fields inherited from class org.htmlparser.tags.CompositeTag
mDefaultScanner, mEndTag
 
Fields inherited from class org.htmlparser.lexer.nodes.TagNode
breakTags, mAttributes
 
Fields inherited from class org.htmlparser.AbstractNode
children, mPage, nodeBegin, nodeEnd, parent
 
Constructor Summary
LinkTag()
          Constructor creates an LinkTag object, which basically stores the location where the link points to, and the text it contains.
 
Method Summary
 void accept(NodeVisitor visitor)
          Link visiting code.
 String extractLink()
          Extract the link from the HREF attribute.
 String getAccessKey()
          Returns the accesskey attribute value, if any.
 String[] getEnders()
          Return the set of tag names that cause this tag to finish.
 String[] getEndTagEnders()
          Return the set of end tag names that cause this tag to finish.
 String[] getIds()
          Return the set of names handled by this tag.
 String getLink()
          Returns the url as a string, to which this link points.
 String getLinkText()
          Returns the text contained inside this link tag
 boolean isFTPLink()
          Tests if the link is an FTP link.
 boolean isHTTPLikeLink()
          Tests if the link is an HTTP link or one of its variations (HTTPS, etc.).
 boolean isHTTPLink()
          Tests if the link is an HTTP link.
 boolean isHTTPSLink()
          Tests if the link is an HTTPS link.
 boolean isIRCLink()
          Tests if the link is an IRC link.
 boolean isJavascriptLink()
          Tests if the link is javascript
 boolean isMailLink()
          Is this a mail address
 SimpleNodeIterator linkData()
          Deprecated. Use children() instead.
 void setJavascriptLink(boolean newJavascriptLink)
          Set the link as a javascript link.
 void setLink(String link)
           
 void setMailLink(boolean newMailLink)
          Insert the method's description here.
 String toString()
          Print the contents of this Link Node
 
Methods inherited from class org.htmlparser.tags.CompositeTag
childAt, children, collectInto, digupStringNode, elements, findPositionOf, findPositionOf, findPositionOf, getChild, getChildCount, getChildrenAsNodeArray, getChildrenHTML, getEndTag, getStartTag, getStringText, getText, putChildrenInto, putEndTagInto, removeChild, searchByName, searchFor, searchFor, searchFor, searchFor, setEndTag, setStartTag, toHtml, toPlainTextString, toString
 
Methods inherited from class org.htmlparser.tags.Tag
accept, clone, getThisScanner, setThisScanner
 
Methods inherited from class org.htmlparser.lexer.nodes.TagNode
breaksFlow, getAttribute, getAttributeEx, getAttributes, getAttributesEx, getEndingLineNumber, getParameter, getParsed, getRawTagName, getStartingLineNumber, getTagBegin, getTagEnd, getTagName, isEmptyXmlTag, isEndTag, removeAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributesEx, setEmptyXmlTag, setTagBegin, setTagEnd, setTagName, setText
 
Methods inherited from class org.htmlparser.AbstractNode
doSemanticAction, elementBegin, elementEnd, getChildren, getEndPosition, getPage, getParent, getStartPosition, setChildren, setEndPosition, setPage, setParent, setStartPosition, toHTML
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mLink

protected String mLink
The URL where the link points to

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 linkData(), 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.linkData();e.hasMoreElements();) {
      node = (Node)e.nextElement();
      if (node instanceof ImageTag) {
          imageTag = (ImageTag)node;
          // Process imageTag
      }
 }
 

Method Detail

getIds

public String[] getIds()
Return the set of names handled by this tag.

Overrides:
getIds in class Tag
Returns:
The names to be matched that create tags of this type.

getEnders

public String[] getEnders()
Return the set of tag names that cause this tag to finish.

Overrides:
getEnders in class Tag
Returns:
The names of following tags that stop further scanning.

getEndTagEnders

public String[] getEndTagEnders()
Return the set of end tag names that cause this tag to finish.

Overrides:
getEndTagEnders in class Tag
Returns:
The names of following end tags that stop further scanning.

getAccessKey

public String getAccessKey()
Returns the accesskey attribute value, if any.


getLink

public 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 return true) but not for other protocols. Don't ask me why, it's a legacy thing.


getLinkText

public 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 String toString()
Print the contents of this Link Node

Specified by:
toString in interface Node
Overrides:
toString in class CompositeTag

setLink

public void setLink(String link)

linkData

public SimpleNodeIterator linkData()
Deprecated. Use children() instead.

This method returns an enumeration of data that it contains

Returns:
Enumeration

accept

public void accept(NodeVisitor visitor)
Link visiting code. Invokes visitLinkTag() on the visitor and then invokes the normal tag processing.

Overrides:
accept in class CompositeTag
Parameters:
visitor - The NodeVisitor object to invoke visitLinkTag() on.

extractLink

public String extractLink()
Extract the link from the HREF attribute. The URL of the actual html page is also provided.


© 2004 Somik Raha
Mar 14, 2004

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