info.informatica.html
Class TagFinder

java.lang.Object
  extended by info.informatica.html.TagFinder
Direct Known Subclasses:
IdTagFinder, NameTagFinder

public class TagFinder
extends Object

This class and subclasses contain serveral methods for finding tags by its type and ID.

Author:
amengual at informatica dot info

Constructor Summary
TagFinder(HTMLFragment doc)
           
 
Method Summary
 info.informatica.doc.FragmentPosition findEndTag(String tagname, int inipos)
          Finds the end tag (</...) of the given name.
 info.informatica.doc.FragmentPosition findNextTag(String tagname, int inipos)
          Finds the next Tag of the given type in the document.
 CharData getNextBlock(int inipos)
          Gets the block of character data formed by the next Tag found by this class, and the enclosed character data.
 HTMLTag getNextTag(int inipos)
          Gets the next Tag according to the requisites of this class.
 HTMLTag getNextTagBlock(int inipos)
          Gets the tag block formed by the next Tag found by this class, and the enclosed character data.
 CharData getNextTagData(int inipos)
          Gets the character data enclosed by the next Tag found by this class.
 HTMLTag getTag()
          Find the first Tag according to the requisites of this class.
 HTMLTag getTagAt(info.informatica.doc.FragmentPosition pos)
           
 HTMLTag getTagBlock()
          Gets the Tag Block corresponding to the found tag.
 CharData getTagData()
          Gets the Tag Data corresponding to the found tag.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TagFinder

public TagFinder(HTMLFragment doc)
Parameters:
doc - HTML document.
Method Detail

getTagAt

public HTMLTag getTagAt(info.informatica.doc.FragmentPosition pos)
                 throws TagParsingException
Throws:
TagParsingException

findNextTag

public info.informatica.doc.FragmentPosition findNextTag(String tagname,
                                                         int inipos)
Finds the next Tag of the given type in the document.

Parameters:
inipos - position to start search.
Returns:
position of the tag, or null if none found.

findEndTag

public info.informatica.doc.FragmentPosition findEndTag(String tagname,
                                                        int inipos)
Finds the end tag (</...) of the given name.

Parameters:
tagname - name of the tag.
inipos - a position after the end of the starting tag (<...>) to start searching for the closing tag.
Returns:
the position of the Closing tag, or null if could not be found.

getTag

public final HTMLTag getTag()
Find the first Tag according to the requisites of this class.

Returns:
the tag, or null if none found.

getTagData

public CharData getTagData()
Gets the Tag Data corresponding to the found tag.

A "tag data" is the Character Data found between the start and closing tag.

For example, the Tag Data in the tag block "<p> This is a paragraph</p>" is "This is a paragraph".

Returns:
the Character Data containing the block of HTML.

getTagBlock

public HTMLTag getTagBlock()
Gets the Tag Block corresponding to the found tag.

A "tag block" is the block of HTML comprised by both the opening and closing tag, and all the Character Data contained between the two.

Returns:
the Character Data containing the block of HTML.

getNextTag

public HTMLTag getNextTag(int inipos)
Gets the next Tag according to the requisites of this class.

By default, gets the next tag of any kind.

Parameters:
inipos - position to start search.
Returns:
the tag, or null if none found.

getNextTagData

public CharData getNextTagData(int inipos)
Gets the character data enclosed by the next Tag found by this class.

Be careful using Tag Data for tags with optional end tag.

Parameters:
inipos - position to start search.
Returns:
the character data enclosed, or null if no tag was found.

getNextTagBlock

public HTMLTag getNextTagBlock(int inipos)
Gets the tag block formed by the next Tag found by this class, and the enclosed character data.

Be careful using Tag blocks for tags with optional end tag.

Parameters:
inipos - position to start search.
Returns:
the block of character data, or null if no tag was found.

getNextBlock

public CharData getNextBlock(int inipos)
Gets the block of character data formed by the next Tag found by this class, and the enclosed character data.

Parameters:
inipos - position to start search.
Returns:
the block of character data, or null if no tag was found.