cox.jmatt.java.MathTools.markup
Class SimpleTagImpl

java.lang.Object
  extended by cox.jmatt.java.MathTools.markup.Tag
      extended by cox.jmatt.java.MathTools.markup.SimpleTagImpl

public class SimpleTagImpl
extends Tag

This class provides a concrete implementation of the Tag class. Besides that it serves to provide MathTools with a simple way to produce proper XML tags of any necessary complexity. It is similar to MathXML.wrapTag() but with many more features! SimpleTagImpl acts as a container for tag information; it maintains an internal StringBuffer for content and, of course, the Hashtable for attributes. In addition to this it provides instance methods to shadow each of Tag's static factory methods.

This class can be used to create any XML tags, up to full documents. Methods that operate on this instance return a self-reference to allow method chaining and tags are easy to create and edit. SimpleTagImpl is not really meant to be subclassed. It is primarily meant for low-level XML tag construction. This might not be the easiest way to do things, but it is easier than trying to slap together Strings manually. It is best used for quick construction of one or two highly-specialized tags. For stricter, more frequent, or greater needs it is probably better to create a markup language package using Tag and StyleInfo.


Field Summary
 
Fields inherited from class cox.jmatt.java.MathTools.markup.Tag
myTagName
 
Constructor Summary
SimpleTagImpl()
          Standard constructor used for scripting or other purposes.
SimpleTagImpl(java.lang.String pTagName)
          Constructor to create a named tag.
 
Method Summary
protected  java.lang.String _content()
          Fetch the content of the internal StringBuffer.
protected  void _setContent(java.lang.String pContent)
          Set or clear the current tag contents.
 SimpleTagImpl addContent(java.lang.String pContent)
          Add content to what's currently there.
 java.lang.String closeNewTag(java.lang.String pTagName)
          Instance form of Tag.closeTag().
static SimpleStyleImpl createStyleImpl()
          Fetch a SimpleStyleImpl if needed.
 java.util.Hashtable<java.lang.String,java.lang.String> getAttributes()
          Return a copy of the current attributes.
 java.lang.String getContent()
          Fetch the current content.
static SimpleTagImpl getNewInstance()
          Instance method to create a new blank SimpleTagImpl instance.
 SimpleTagImpl getNewInstance(java.lang.String pName)
          Instance method to create a new named SimpleTagImpl instance.
 SimpleStyleImpl getNewStyleImpl()
          Create and return a SimpleStyleImpl
 boolean isValidString(java.lang.String pStr)
          Instance form of Tag.validString().
 java.lang.String makeNewTag(java.lang.String pTagName, java.util.Hashtable<java.lang.String,java.lang.String> pAttributes, java.lang.String pContent)
          Instance form of Tag.makeTag().
static SimpleTagImpl newInstance()
          Static method to create a new blank SimpleTagImpl instance.
static SimpleTagImpl newInstance(java.lang.String pName)
          Static method to create a new named SimpleTagImpl instance.
 java.lang.String openNewTag(java.lang.String pTagName, java.util.Hashtable<java.lang.String,java.lang.String> pAttributes, boolean isEmpty)
          Instance form of Tag.openTag().
 SimpleTagImpl setAttribute(java.lang.String pKey, java.lang.String pValue)
          Set or remove an attribute value.
 SimpleTagImpl setContent(java.lang.String pContent)
          Send a String to the _setContent() method.
 SimpleTagImpl setTagName(java.lang.String pTagName)
          This method can change the tag name, just in case such a thing is needed.
 
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

SimpleTagImpl

public SimpleTagImpl()
Standard constructor used for scripting or other purposes. Tag name is 'SimpleTag' with no (default) attributes.


SimpleTagImpl

public SimpleTagImpl(java.lang.String pTagName)
Constructor to create a named tag. If the name is null or blank it becomes 'SimpleTag'.

Method Detail

createStyleImpl

public static SimpleStyleImpl createStyleImpl()
Fetch a SimpleStyleImpl if needed.


newInstance

public static SimpleTagImpl newInstance(java.lang.String pName)
Static method to create a new named SimpleTagImpl instance.


getNewInstance

public SimpleTagImpl getNewInstance(java.lang.String pName)
Instance method to create a new named SimpleTagImpl instance.


newInstance

public static SimpleTagImpl newInstance()
Static method to create a new blank SimpleTagImpl instance.


getNewInstance

public static SimpleTagImpl getNewInstance()
Instance method to create a new blank SimpleTagImpl instance.


openNewTag

public java.lang.String openNewTag(java.lang.String pTagName,
                                   java.util.Hashtable<java.lang.String,java.lang.String> pAttributes,
                                   boolean isEmpty)
Instance form of Tag.openTag(). Arguments are per that method.


closeNewTag

public java.lang.String closeNewTag(java.lang.String pTagName)
Instance form of Tag.closeTag(). Arguments are per that method. (This method name is a bit odd but it is consistent!)


makeNewTag

public java.lang.String makeNewTag(java.lang.String pTagName,
                                   java.util.Hashtable<java.lang.String,java.lang.String> pAttributes,
                                   java.lang.String pContent)
Instance form of Tag.makeTag(). Arguments are per that method.


isValidString

public boolean isValidString(java.lang.String pStr)
Instance form of Tag.validString(). Just because it's there.


getNewStyleImpl

public SimpleStyleImpl getNewStyleImpl()
Create and return a SimpleStyleImpl


setTagName

public SimpleTagImpl setTagName(java.lang.String pTagName)
This method can change the tag name, just in case such a thing is needed. If the tag name sent in is null or blank, 'SimpleTag' is assigned.


_content

protected java.lang.String _content()
Fetch the content of the internal StringBuffer. If there is none, the return is null.

Overrides:
_content in class Tag

getContent

public java.lang.String getContent()
Fetch the current content. No content is lost from this method.


_setContent

protected void _setContent(java.lang.String pContent)
Set or clear the current tag contents. If 'pContent' is null or blank all content is cleared. If not, all previousl content is lost and the new content is set.

Overrides:
_setContent in class Tag

setContent

public SimpleTagImpl setContent(java.lang.String pContent)
Send a String to the _setContent() method.


addContent

public SimpleTagImpl addContent(java.lang.String pContent)
Add content to what's currently there. Ignored if null or blank.


setAttribute

public SimpleTagImpl setAttribute(java.lang.String pKey,
                                  java.lang.String pValue)
Set or remove an attribute value.


getAttributes

public java.util.Hashtable<java.lang.String,java.lang.String> getAttributes()
Return a copy of the current attributes. This is a copy, so changing it will not affect the original.