cox.jmatt.java.MathTools.markup.html
Class BaseHTag

java.lang.Object
  extended by cox.jmatt.java.MathTools.markup.Tag
      extended by cox.jmatt.java.MathTools.markup.html.BaseHTag
Direct Known Subclasses:
ContainerTag, DLTag, IMGTag, ListTag, TableTag, TRTag

public abstract class BaseHTag
extends Tag

This is the abstract superclass for all HTML tag classes. Since HTML's structure is incredibly flexible (and possibly convoluted!) there are no 'subclass chains' involved with this package. Instead each tag class implements the behavior that is absolutely required for that tag. Proper structure is up to the user! The only intelligence applied innately is whether the tag should be added to a document's <head> or <body> and the TagKeys enum handles that.

As with the SVG package, HTML uses CSS (only!) to provide styling and presentation information. The tacit assumption is that an external stylesheet is provided so nothing analogous to the StylePen class is used here.

Since most of the tags represented in this package may have content rudimentary content handling is supplied. Content is held in an internal buffer until needed and returned as a String when that happens. No XML-escaping is done so that must be handled manually!


Nested Class Summary
static class BaseHTag.TagKeys
          This enum holds information and default values for the various tag classes, all of which subclass BaseHTag.
 
Field Summary
 
Fields inherited from class cox.jmatt.java.MathTools.markup.Tag
myTagName
 
Constructor Summary
protected BaseHTag(BaseHTag.TagKeys pKey)
          Standard constructor for building HTML tag classes.
 
Method Summary
protected  void _addTag(BaseHTag pTag)
          Add a tag to the content.
protected  java.lang.String _content()
          Return the contents of the internal StringBuffer.
protected  void _enableCopy()
          This method enables tag copying.
protected  void _setContent(java.lang.String pContent)
          Handle the internal buffer.
 void addCDATA(java.lang.String pData)
          Add non-null, non-blank content enclosed in a CDATA block.
 void addContent(java.lang.String pContent)
          Add content to the current tag.
 java.lang.String getID()
          Fetch a copy of the tag's ID if one is set.
 java.lang.String getRawContent()
          Fetch the content of the tag, unaltered and unedited.
 java.lang.String getTagKey()
          Return the String name of this tag's TagKeys constant.
 java.lang.String getTagName()
          Return the current tag name.
 boolean isInBody()
          Determine where to add this tag to the HTML document: true for body, false for head.
 void setClicked(java.lang.String pClickHandler)
          This method is provided for (external!!) script interactions.
 void setCSS(java.lang.String pRuleName)
          Set or clear the (CSS) 'class=' attribute for the tag.
 void setName(java.lang.String pName)
          This method sets the tag's 'name=' attribute and not the name of the tag itself! Since is is common among HTML tags it is handled here.
 void setStyle(java.lang.String pStyle)
          Set or clear the tag's (inline CSS) 'style=' attribute.
 
Methods inherited from class cox.jmatt.java.MathTools.markup.Tag
_addAttribute, _addAttributes, _addNAttribute, _asBoolean, _asDouble, _asInt, _attributes, _clampNAttribute, _clampNAttribute, _fixKey, _setEnableXMLTag, badPizza, closeTag, configureTag, configureTagFromGlobalPizza, makeTag, openTag, reset, setID, toString, validString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseHTag

protected BaseHTag(BaseHTag.TagKeys pKey)
Standard constructor for building HTML tag classes. If a copy is created its 'id=' attribute is cleared.

Method Detail

isInBody

public boolean isInBody()
Determine where to add this tag to the HTML document: true for body, false for head. Return value based on its TagKeys constant.


_enableCopy

protected final void _enableCopy()
This method enables tag copying. All attributes and content are stored temporarily and the next tag instance created retrieves and clears them.


getTagKey

public java.lang.String getTagKey()
Return the String name of this tag's TagKeys constant.


getTagName

public java.lang.String getTagName()
Return the current tag name.


getID

public java.lang.String getID()
Fetch a copy of the tag's ID if one is set. If not a blank String is returned.


setName

public void setName(java.lang.String pName)
This method sets the tag's 'name=' attribute and not the name of the tag itself! Since is is common among HTML tags it is handled here. Setting null or blank clears the name.


setCSS

public void setCSS(java.lang.String pRuleName)
Set or clear the (CSS) 'class=' attribute for the tag. Null or blank clears it, if it was set.


setStyle

public void setStyle(java.lang.String pStyle)
Set or clear the tag's (inline CSS) 'style=' attribute. Null or blank clears any previous value.


setClicked

public void setClicked(java.lang.String pClickHandler)
This method is provided for (external!!) script interactions. For tags that don't allow it, DON'T USE IT!! The attribute set is 'onclick='.


getRawContent

public java.lang.String getRawContent()
Fetch the content of the tag, unaltered and unedited. This returns ONLY the content tracked innately by this class; other classes that override the _content() method may not dump their content via this method. Use with care!


_content

protected java.lang.String _content()
Return the contents of the internal StringBuffer. May be blank but will never be null.

Overrides:
_content in class Tag

_setContent

protected void _setContent(java.lang.String pContent)
Handle the internal buffer. If pContent is null all data is cleared. If it is non-null it becomes the new content. Either way, all previous data is LOST.

Overrides:
_setContent in class Tag

addContent

public void addContent(java.lang.String pContent)
Add content to the current tag. Ignored if null or blank, should not be intermixed with CDATA content.


addCDATA

public void addCDATA(java.lang.String pData)
Add non-null, non-blank content enclosed in a CDATA block. This method should not be intermixed with addContent().


_addTag

protected void _addTag(BaseHTag pTag)
Add a tag to the content. Ignored if null. Protected to allow exclusion from tags that don't contain arbitrary other HTML tags.