info.informatica.html.tag
Class HTMLTag

java.lang.Object
  extended by info.informatica.doc.DocumentFragment
      extended by info.informatica.html.tag.HTMLTag
All Implemented Interfaces:
info.informatica.doc.DocumentElement, AttributeListener, Comparable<info.informatica.doc.DocumentFragment>
Direct Known Subclasses:
BaseFont, Font, GenericHTMLTag, Paragraph, TableData, TableHeader, TableRow

public abstract class HTMLTag
extends info.informatica.doc.DocumentFragment
implements info.informatica.doc.DocumentElement, AttributeListener

HTML Tag.

Author:
amengual at informatica dot info

Nested Class Summary
 
Nested classes/interfaces inherited from class info.informatica.doc.DocumentFragment
info.informatica.doc.DocumentFragment.FragmentComp, info.informatica.doc.DocumentFragment.NotFragmentComp
 
Method Summary
 void align(int i)
           
 String endTag()
          Gets the end-Tag form of this tag.
 int getAlignment()
           
 Attributes getAttributes()
          Returns the tag attributes.
 info.informatica.doc.FragmentPosition getBlockPosition()
          Gets the position of this tag, intended as a block, thus including the start and close tags if any tag character data is inside.
 String getId()
          Gets the tag ID.
abstract  String getName()
          Gets the name of the tag.
 HTMLTag getParent()
          Get this tag's parent tag.
 org.w3c.dom.css.CSSStyleDeclaration getStyle()
          Gets the style declaration contained inside the style attribute.
 String getStyleClass()
          Gets the class attribute used for style sheets.
 info.informatica.doc.DocumentFragment getTagData()
          Gets the document fragment inside the start and end tags, if any.
 boolean isSelfClosing()
          Is this tag self-closing in XHTML sense?
 int length()
          The character length of this tag, in HTML style (without the slash at the end of the start tag).
 void onAttributeRemoved(String attrname)
          Called when removing any attribute.
 void onAttributes(String attrname, String attrvalue)
          This method must be called when setting or modifying an attribute.
 void onAttributeStringSet(String attributes)
          Called when the attributes are set in form of a string containing one or more name=value attributes.
 void onDummyAttributes(String attrname)
          Called when a plain-old HTML dummy attribute is set.
 void setAttributes(Attributes attr)
          Sets the attributes of the tag.
 void setId(String id)
          Sets the id attribute.
 void setParent(HTMLTag parent)
          Set this tag's parent tag.
 void setSelfClosing()
           
 void setSelfClosing(boolean selfClosing)
           
 void setTagData(info.informatica.doc.DocumentFragment tagdata)
          Sets the document fragment inside the start and end tags.
 void setTagData(String text)
          Convenience method that sets the text inside the start and end tags.
 String startTag()
          Gets the start-Tag form of this tag.
 String toString()
           
 String toString(info.informatica.doc.DocumentFragment el)
          Gives a String representation of the tag as startTag + fragment + endTag.
 String toString(String innerstring)
          Gives a String representation of the tag as startTag + innerstring + endTag.
 String toXml()
          Gives an XHTML representation of this tag.
 void vAlign(int i)
           
 
Methods inherited from class info.informatica.doc.DocumentFragment
adjustWidth, compareTo, getCurrentPosition, getPosition, setPosition
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

setParent

public void setParent(HTMLTag parent)
Set this tag's parent tag.

Parameters:
parent - the parent tag.

onAttributeStringSet

public void onAttributeStringSet(String attributes)
Description copied from interface: AttributeListener
Called when the attributes are set in form of a string containing one or more name=value attributes.

Specified by:
onAttributeStringSet in interface AttributeListener
Parameters:
attributes - the string containing the set of attributes.

getParent

public HTMLTag getParent()
Get this tag's parent tag. return the parent tag.


isSelfClosing

public boolean isSelfClosing()
Is this tag self-closing in XHTML sense?

Returns:
true if self-closing, false otherwise.

setSelfClosing

public void setSelfClosing(boolean selfClosing)

setSelfClosing

public void setSelfClosing()

onAttributes

public void onAttributes(String attrname,
                         String attrvalue)
                  throws TagParsingException
Description copied from interface: AttributeListener
This method must be called when setting or modifying an attribute.

Specified by:
onAttributes in interface AttributeListener
Parameters:
attrname - the attribute name.
attrvalue - the attribute value.
Throws:
TagParsingException - if the name of the attribute is syntactically wrong.

onDummyAttributes

public void onDummyAttributes(String attrname)
                       throws TagParsingException
Description copied from interface: AttributeListener
Called when a plain-old HTML dummy attribute is set.

Specified by:
onDummyAttributes in interface AttributeListener
Parameters:
attrname - the attribute name.
Throws:
TagParsingException

onAttributeRemoved

public void onAttributeRemoved(String attrname)
                        throws TagParsingException
Description copied from interface: AttributeListener
Called when removing any attribute.

Specified by:
onAttributeRemoved in interface AttributeListener
Parameters:
attrname - the attribute name.
Throws:
TagParsingException

getName

public abstract String getName()
Gets the name of the tag.

Must return the lowercase name of this tag.

Returns:
a String with the tag name

getId

public String getId()
Gets the tag ID.

Returns:
tag ID

getAttributes

public Attributes getAttributes()
Returns the tag attributes.

Returns:
the attributes

setAttributes

public void setAttributes(Attributes attr)
Sets the attributes of the tag.


setId

public final void setId(String id)
                 throws TagParsingException
Sets the id attribute.

Parameters:
id - the id attribute.
Throws:
TagParsingException - if a problem arises when parsing the attributes.

getStyleClass

public String getStyleClass()
                     throws TagParsingException
Gets the class attribute used for style sheets.

Returns:
the content of the class attribute.
Throws:
TagParsingException - if a problem arises when parsing the attributes.

getStyle

public org.w3c.dom.css.CSSStyleDeclaration getStyle()
                                             throws TagParsingException
Gets the style declaration contained inside the style attribute.

Returns:
the style declaration.
Throws:
TagParsingException - if a problem arises when parsing the attributes or the style declaration.

align

public void align(int i)

getAlignment

public int getAlignment()

vAlign

public void vAlign(int i)

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(info.informatica.doc.DocumentFragment el)
Gives a String representation of the tag as startTag + fragment + endTag.

For example, if this tag was an anchor with the href attribute "example.html", calling with argument "" would return:

<a href="example.html"><img src="foo.jpg"></a>

Parameters:
el - the fragment to put between the start and close tags.
Returns:
the startTag + element + closeTag.

toString

public String toString(String innerstring)
Gives a String representation of the tag as startTag + innerstring + endTag.

For example, if this tag was an anchor with the href attribute "example.html", calling with argument "Example page" would return:

<a href="example.html">Example page</a>

Parameters:
innerstring - the string to put between the start and close tags.
Returns:
the startTag + innerstring + closeTag.

toXml

public String toXml()
Gives an XHTML representation of this tag.

It is useful for cases where you need a tag representation as <tagname attributes/>.

Returns:
the XHTML representation of this tag.

startTag

public String startTag()
Gets the start-Tag form of this tag.

For example, the start-Tag of a "tr" tag with bgcolor attribute "white" is <tr bgcolor="white">.

Returns:
the start-Tag, closed if the tag is self-closing.

endTag

public String endTag()
Gets the end-Tag form of this tag.

For example, the end-Tag of a "p" tag is </p>.

This is returned regardless of this tag being self-closing or not.

Returns:
the end-Tag.

length

public int length()
The character length of this tag, in HTML style (without the slash at the end of the start tag).

Specified by:
length in class info.informatica.doc.DocumentFragment
Returns:
the length of this tag.

setTagData

public void setTagData(info.informatica.doc.DocumentFragment tagdata)
Sets the document fragment inside the start and end tags.

Parameters:
tagdata - the document fragment inside the start and end tags.

setTagData

public void setTagData(String text)
Convenience method that sets the text inside the start and end tags.

Parameters:
text - the text inside the start and end tags.

getTagData

public info.informatica.doc.DocumentFragment getTagData()
Gets the document fragment inside the start and end tags, if any.

Returns:
the document fragment inside the start and end tags, or null if none.

getBlockPosition

public info.informatica.doc.FragmentPosition getBlockPosition()
Gets the position of this tag, intended as a block, thus including the start and close tags if any tag character data is inside.

Returns:
the block position of this tag.