Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.htmlparser.tags
Class LinkTag  view LinkTag download LinkTag.java

java.lang.Object
  extended byorg.htmlparser.Node
      extended byorg.htmlparser.tags.Tag
          extended byorg.htmlparser.tags.CompositeTag
              extended byorg.htmlparser.tags.LinkTag
All Implemented Interfaces:
java.io.Serializable

public class LinkTag
extends CompositeTag

Identifies a link tag


Field Summary
protected  java.lang.String accessKey
          The accesskey existing inside this link.
private  boolean javascriptLink
           
protected  java.lang.String link
          The URL where the link points to
static java.lang.String LINK_TAG_FILTER
           
protected  java.lang.String linkText
          The text of of the link element
private  boolean mailLink
           
 
Fields inherited from class org.htmlparser.tags.CompositeTag
childTags, endTag, startTag
 
Fields inherited from class org.htmlparser.tags.Tag
attributes, breakTags, EMPTYTAG, tagContents, TAGNAME, thisScanner, TYPE
 
Fields inherited from class org.htmlparser.Node
lineSeparator, nodeBegin, nodeEnd, parent
 
Constructor Summary
LinkTag(org.htmlparser.tags.data.TagData tagData, org.htmlparser.tags.data.CompositeTagData compositeTagData, org.htmlparser.tags.data.LinkData linkData)
          Constructor creates an HTMLLinkNode object, which basically stores the location where the link points to, and the text it contains.
 
Method Summary
 void accept(org.htmlparser.visitors.NodeVisitor visitor)
           
 java.lang.String getAccessKey()
          Returns the accesskey element if any inside this link tag
 java.lang.String getLink()
          Returns the url as a string, to which this link points
 java.lang.String getLinkText()
          Returns the text contained inside this link tag
 java.lang.String getText()
          Return the text contained in this linkinode Kaarle Kaila 23.10.2001
 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 isJavascriptLink()
          Tests if the link is javascript
 boolean isMailLink()
          Is this a mail address
 org.htmlparser.util.SimpleNodeIterator linkData()
          Deprecated. Use children() instead.
 void removeChild(int i)
           
 void setJavascriptLink(boolean newJavascriptLink)
          Set the link as a javascript link.
 void setLink(java.lang.String link)
           
 void setMailLink(boolean newMailLink)
          Insert the method's description here.
 java.lang.String toString()
          Print the contents of this Link Node
 
Methods inherited from class org.htmlparser.tags.CompositeTag
childAt, children, collectInto, collectInto, digupStringNode, elements, findPositionOf, findPositionOf, getChild, getChildCount, getChildren, getChildrenAsNodeArray, getChildrenHTML, getEndTag, getStartTag, putChildrenInto, putEndTagInto, putStartTagInto, searchByName, searchFor, searchFor, searchFor, toHtml, toPlainTextString
 
Methods inherited from class org.htmlparser.tags.Tag
append, append, breaksFlow, extractWord, find, getAttribute, getAttributes, getParameter, getParsed, getTagBegin, getTagEnd, getTagEndLine, getTagLine, getTagLines, getTagName, getTagStartLine, getThisScanner, getType, isEmptyXmlTag, redoParseAttributes, scan, setAttribute, setAttributes, setEmptyXmlTag, setTagBegin, setTagEnd, setTagLine, setTagParser, setText, setThisScanner
 
Methods inherited from class org.htmlparser.Node
elementBegin, elementEnd, getLineSeparator, getParent, setLineSeparator, setParent, toHTML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LINK_TAG_FILTER

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

link

protected java.lang.String link
The URL where the link points to


linkText

protected java.lang.String linkText
The text of of the link element


accessKey

protected java.lang.String accessKey
The accesskey existing inside this link.


mailLink

private boolean mailLink

javascriptLink

private boolean javascriptLink
Constructor Detail

LinkTag

public LinkTag(org.htmlparser.tags.data.TagData tagData,
               org.htmlparser.tags.data.CompositeTagData compositeTagData,
               org.htmlparser.tags.data.LinkData linkData)
Constructor creates an HTMLLinkNode 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
 	}
 }
 
There is another mechanism available that allows for uniform extraction of images. You could do this to get all images from a web page :
 Node node;
 Vector imageCollectionVector = new Vector();
 for (NodeIterator e = parser.elements(); e.hasMoreNode();) {
 	node = e.nextHTMLNode();
 	node.collectInto(imageCollectionVector, ImageTag.IMAGE_FILTER);
 }
 
The link tag processes all its contents in collectInto().

Method Detail

getAccessKey

public java.lang.String getAccessKey()
Returns the accesskey element if any inside this link tag


getLink

public java.lang.String getLink()
Returns the url as a string, to which this link points


getLinkText

public java.lang.String getLinkText()
Returns the text contained inside this link tag


getText

public java.lang.String getText()
Return the text contained in this linkinode Kaarle Kaila 23.10.2001

Overrides:
getText in class Tag

isMailLink

public boolean isMailLink()
Is this a mail address


isJavascriptLink

public boolean isJavascriptLink()
Tests if the link is javascript


isFTPLink

public boolean isFTPLink()
Tests if the link is an FTP link.


isHTTPLink

public boolean isHTTPLink()
Tests if the link is an HTTP link.


isHTTPSLink

public boolean isHTTPSLink()
Tests if the link is an HTTPS link.


isHTTPLikeLink

public boolean isHTTPLikeLink()
Tests if the 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)


setJavascriptLink

public void setJavascriptLink(boolean newJavascriptLink)
Set the link as a javascript link.


toString

public java.lang.String toString()
Print the contents of this Link Node

Overrides:
toString in class Tag

setLink

public void setLink(java.lang.String link)

linkData

public org.htmlparser.util.SimpleNodeIterator linkData()
Deprecated. Use children() instead.

This method returns an enumeration of data that it contains


accept

public void accept(org.htmlparser.visitors.NodeVisitor visitor)
Overrides:
accept in class CompositeTag

removeChild

public void removeChild(int i)