Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| HTML Parser Home Page
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.htmlparser
Interface Tag

All Superinterfaces:
  Cloneable, Node

All Known Implementing Classes:
  AppletTag, BaseHrefTag, BodyTag, Bullet, BulletList, CompositeTag, DefinitionList, DefinitionListBullet, Div, DoctypeTag, FormTag, FrameSetTag, FrameTag, HeadingTag, HeadTag, Html, ImageTag, InputTag, JspTag, LabelTag, LinkTag, MetaTag, ObjectTag, OptionTag, ParagraphTag, ProcessingInstructionTag, ScriptTag, SelectTag, Span, StyleTag, TableColumn, TableHeader, TableRow, TableTag, TagNode, TextareaTag, TitleTag

    public interface Tag

extends Node

This interface represents a tag (<xxx yyy="zzz">) in the HTML document. Adds capabilities to a Node that are specific to a tag.

Method Summary
`boolean` | `breaksFlow()` Determines if the given tag breaks the flow of text.
`String` | `getAttribute(String name)` Returns the value of an attribute.
`Attribute` | `getAttributeEx(String name)` Returns the attribute with the given name.
`Vector` | `getAttributesEx()` Gets the attributes in the tag.
`String[]` | `getEnders()` Return the set of tag names that cause this tag to finish.
`int` | `getEndingLineNumber()` Get the line number where this tag ends.
`Tag` | `getEndTag()` Get the end tag for this (composite) tag.
`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` | `getRawTagName()` Return the name of this tag.
`int` | `getStartingLineNumber()` Get the line number where this tag starts.
`String` | `getTagName()` Return the name of this tag.
`Scanner` | `getThisScanner()` Return the scanner associated with this tag.
`boolean` | `isEmptyXmlTag()` Is this an empty xml tag of the form <tag/>.
`boolean` | `isEndTag()` Predicate to determine if this tag is an end tag (i.e.
`void` | `removeAttribute(String key)` Remove the attribute with the given key, if it exists.
`void` | `setAttribute(String key, String value)` Set attribute with given key, value pair.
`void` | `setAttribute(String key, String value, char quote)` Set attribute with given key/value pair, the value is quoted by quote.
`void` | `setAttributeEx(Attribute attribute)` Set an attribute.
`void` | `setAttributesEx(Vector attribs)` Sets the attributes.
`void` | `setEmptyXmlTag(boolean emptyXmlTag)` Set this tag to be an empty xml node, or not.
`void` | `setEndTag(Tag tag)` Set the end tag for this (composite) tag.
`void` | `setTagName(String name)` Set the name of this tag.
`void` | `setThisScanner(Scanner scanner)` Set the scanner associated with this tag.

Methods inherited from interface org.htmlparser.Node
`accept, clone, collectInto, doSemanticAction, getChildren, getEndPosition, getFirstChild, getLastChild, getNextSibling, getPage, getParent, getPreviousSibling, getStartPosition, getText, setChildren, setEndPosition, setPage, setParent, setStartPosition, setText, toHtml, toHtml, toPlainTextString, toString`

Method Detail

### getAttribute

    String getAttribute(String name)

  Returns the value of an attribute.

  Parameters:
    `name` - Name of attribute, case insensitive.
  Returns:
    The value associated with the attribute or null if it does not exist, or is a stand-alone.
  See Also:
    `setAttribute(java.lang.String, java.lang.String)`

### setAttribute

    void setAttribute(String key,
                      String value)

  Set attribute with given key, value pair. Figures out a quote character to use if necessary.

  Parameters:
    `key` - The name of the attribute.
    `value` - The value of the attribute.
  See Also:
    `getAttribute(java.lang.String)`, `setAttribute(String,String,char)`

### setAttribute

    void setAttribute(String key,
                      String value,
                      char quote)

  Set attribute with given key/value pair, the value is quoted by quote.

  Parameters:
    `key` - The name of the attribute.
    `value` - The value of the attribute.
    `quote` - The quote character to be used around value. If zero, it is an unquoted value.
  See Also:
    `getAttribute(java.lang.String)`

### removeAttribute

    void removeAttribute(String key)

  Remove the attribute with the given key, if it exists.

  Parameters:
    `key` - The name of the attribute.

### getAttributeEx

    Attribute getAttributeEx(String name)

  Returns the attribute with the given name.

  Parameters:
    `name` - Name of attribute, case insensitive.
  Returns:
    The attribute or null if it does not exist.
  See Also:
    `setAttributeEx(org.htmlparser.Attribute)`

### setAttributeEx

    void setAttributeEx(Attribute attribute)

  Set an attribute. This replaces an attribute of the same name. To set the zeroth attribute (the tag name), use setTagName().

  Parameters:
    `attribute` - The attribute to set.
  See Also:
    `getAttributeEx(java.lang.String)`

### getAttributesEx

    Vector getAttributesEx()

  Gets the attributes in the tag.

  Returns:
    Returns the list of `Attributes` in the tag.
  See Also:
    `setAttributesEx(java.util.Vector)`

### setAttributesEx

    void setAttributesEx(Vector attribs)

  Sets the attributes. NOTE: Values of the extended hashtable are two element arrays of String, with the first element being the original name (not uppercased), and the second element being the value.

  Parameters:
    `attribs` - The attribute collection to set.
  See Also:
    `getAttributesEx()`

### getTagName

    String getTagName()

  Return the name of this tag.

  Note: This value is converted to uppercase and does not begin with "/" if it is an end tag. Nor does it end with a slash in the case of an XML type tag. The conversion to uppercase is performed with an ENGLISH locale.

  Returns:
    The tag name.
  See Also:
    `setTagName(java.lang.String)`

### setTagName

    void setTagName(String name)

  Set the name of this tag. This creates or replaces the first attribute of the tag (the zeroth element of the attribute vector).

  Parameters:
    `name` - The tag name.
  See Also:
    `getTagName()`

### getRawTagName

    String getRawTagName()

  Return the name of this tag.

  Returns:
    The tag name or null if this tag contains nothing or only whitespace.

### breaksFlow

    boolean breaksFlow()

  Determines if the given tag breaks the flow of text.

  Returns:
    `true` if following text would start on a new line, `false` otherwise.

### isEndTag

    boolean isEndTag()

  Predicate to determine if this tag is an end tag (i.e. </HTML>).

  Returns:
    `true` if this tag is an end tag.

### isEmptyXmlTag

    boolean isEmptyXmlTag()

  Is this an empty xml tag of the form <tag/>.

  Returns:
    true if the last character of the last attribute is a '/'.

### setEmptyXmlTag

    void setEmptyXmlTag(boolean emptyXmlTag)

  Set this tag to be an empty xml node, or not. Adds or removes an ending slash on the tag.

  Parameters:
    `emptyXmlTag` - If true, ensures there is an ending slash in the node, i.e. <tag/>, otherwise removes it.

### getIds

    String[] getIds()

  Return the set of names handled by this tag. Since this a a generic tag, it has no ids.

  Returns:
    The names to be matched that create tags of this type.

### getEnders

    String[] getEnders()

  Return the set of tag names that cause this tag to finish. These are the normal (non end tags) that if encountered while scanning (a composite tag) will cause the generation of a virtual tag. Since this a a non-composite tag, the default is no enders.

  Returns:
    The names of following tags that stop further scanning.

### getEndTagEnders

    String[] getEndTagEnders()

  Return the set of end tag names that cause this tag to finish. These are the end tags that if encountered while scanning (a composite tag) will cause the generation of a virtual tag. Since this a a non-composite tag, it has no end tag enders.

  Returns:
    The names of following end tags that stop further scanning.

### getEndTag

    Tag getEndTag()

  Get the end tag for this (composite) tag. For a non-composite tag this always returns `null`.

  Returns:
    The tag that terminates this composite tag, i.e. </HTML>.
  See Also:
    `setEndTag(org.htmlparser.Tag)`

### setEndTag

    void setEndTag(Tag tag)

  Set the end tag for this (composite) tag. For a non-composite tag this is a no-op.

  Parameters:
    `tag` - The tag that closes this composite tag, i.e. </HTML>.
  See Also:
    `getEndTag()`

### getThisScanner

    Scanner getThisScanner()

  Return the scanner associated with this tag.

  Returns:
    The scanner associated with this tag.
  See Also:
    `setThisScanner(org.htmlparser.scanners.Scanner)`

### setThisScanner

    void setThisScanner(Scanner scanner)

  Set the scanner associated with this tag.

  Parameters:
    `scanner` - The scanner for this tag.
  See Also:
    `getThisScanner()`

### getStartingLineNumber

    int getStartingLineNumber()

  Get the line number where this tag starts.

  Returns:
    The (zero based) line number in the page where this tag starts.

### getEndingLineNumber

    int getEndingLineNumber()

  Get the line number where this tag ends.

  Returns:
    The (zero based) line number in the page where this tag ends.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| © 2005 Derrick Oswald Jun 10, 2006
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

HTML Parser is an open source library released under LGPL. |