public class DhHTMLGenerator
Represents a base class for HTML generation. Override this class to create alternate HTML generations from the package. Call DhElement.setHTMLGenerator with an instance of your override to enable. On each tag, style, and attribute, the appropriate function is called, and you can manipulate the element in any way you choose.
Fields
Name | Description |
---|---|
UNKNOWN_KEY | This value is returned by getNameKey if the name is not registered. |
Methods
Name | Description |
---|---|
addAttrString( String strAttr, String strValue ) | Adds an attribute inside the current tag's less than (<) and greater than (>) brackets. |
addEnclosingTag( String strTag, String strAttrs, boolean fClose ) | Adds an enclosing tag around the current tag. |
addInnerTag( String strTag, String strAttrs, boolean fClose ) | Adds an inner tag inside the current tag, but encloses its contents. |
addStyleString( String strStyle, String strValue ) | Adds an attribute inside the current tag's "STYLE=" attribute. |
generateHTML( DhElement e ) | Generates browser-targeted HTML for the specified DhElement. |
getAttributeValue( String strAttrName ) | Retrieves the value of a specified attribute. |
getContent() | Retrieves the current content string. |
getNameKey( String strName ) | Returns the integer key associated with the given name. |
getStyleValue( String strStyleName ) | Retrieves the value of a specified style. |
getSupportsCSS() | Retrieves target's ability to support cascading style sheets. |
getSupportsOM() | Retrieves the target's ability to support the Document Object Model. |
getTagName() | Retreives the tag name for the current generation. |
onAttrGenerate( String strName, String strValue ) | Called for each attribute[,value] pair. |
onAttrGenerate( int key, String strName, String strValue ) | Topic under construction. |
onStyleGenerate( int key, String strName, String strValue ) | Called for each style-attribute[,value] pair. |
onStyleGenerate( String strName, String strValue ) | Topic under construction. |
onTagGenerate( int key, String strTagName ) | Called with the default name for the current tag. |
onTagGenerate( String strTagName ) | Topic under construction. |
registerName( String strName, int key ) | Use this function to associate an integer value with a style or attribute name or tag. |
setContent( String strNewContent ) | Replaces the current content, destroying any existing content. |
setFormatItems( char cAttrAssign, char cAttrSeparator, char cAttrQuote, char cStyleAssign, char cStyleSeparator, char cStyleQuote ) | Sets the delimeter items. |
setSupportsCSS( boolean supportsCSS ) | Specifies whether the target browser supports style sheets. |
setSupportsOM( boolean supportsOM ) | Specifies whether the target browser supports an object model. |
setTagName( String strNewName ) | Replaces the current tag name with the new value. |
Adds an attribute inside the current tag's less than (<) and greater than (>) brackets.
Adds an enclosing tag around the current tag. This tag also encloses any existing enclosing tags.
Adds an inner tag inside the current tag, but encloses its contents. This tag appears between the contents and any existing inner tags.
Adds an attribute inside the current tag's "STYLE=" attribute. These styles are emitted only if supportsCSS is true.
Returns a StringBuffer with the generated HTML.
Generates browser-targeted HTML for the specified DhElement.
Returns s the value of the attribute, or returns null if it is not present.
Retrieves the value of a specified attribute.
Returns the current content string.
Retrieves the current content string.
Returns the key for the name, or returns UNKNOWN_KEY if it is not present.
Returns the integer key associated with the given name. This function is not case sensitive.
Returns s the value of the style, or returns null if it is not present.
Retrieves the value of a specified style.
Returns true if cascading style sheets are supported.
Retrieves target's ability to support cascading style sheets.
Returns true if the Document Object Model is supported (currently Microsoft Internet Explorer version 4.0 or later only)
Retrieves the target's ability to support the Document Object Model.
Returns the current tag name string.
Retreives the tag name for the current generation.
Returns true to generate the default tag, or returns false to skip it.
Called for each attribute[,value] pair. You can perform any desired additions or manipulations for the specified attribute. The following is an example of moving WIDTH attribute into style text:
if ( strName.equalsIgnoreCase( "WIDTH" ) ){ addStyleString( "width", strValue ); return false; }
Topic under construction.
Returns true to generate the default tag, or returns false to skip it.
Called for each style-attribute[,value] pair. You can perform any desired additions or manipulations for the specified style.
The following is an example of non-CSS-compatible code for font color:
if ( strName.equalsIgnoreCase( "color" ) ){ addEnclosingTag( "FONT", "COLOR=" + strValue ); return false; }
Topic under construction.
Returns true to use the default tag.
Called with the default name for the current tag. You can perform any desired operations within your override.
The following is an example of replacing <STRONG> with <BOLD>
if ( strTagName.equalsIgnoreCase( "STRONG" ) ){ setTagName( "BOLD" ); return false; }
Topic under construction.
Returns true if the name was successfully registered, or returns false if -1 is used or the key is already assigned to another name.
Use this function to associate an integer value with a style or attribute name or tag. If registered, you will receive this value with the name in calls to onTagGenerate, onAttrGenerate, and onStyleGenerate. Registering a key allows you to avoid string comparison in your handler functions.
Note: key cannot be -1;
Example:
public class MyHTMLGenerator{ public final static TAG_BR = 0; public final static TAG_DIV = 1; public MyHTMLGenerator(){ registerName( "BR", TAG_BR ); registerName( "DIV", TAG_DIV ); } // ... public boolean onTagGenerate( int key, String strTagName ){ switch ( key ){ case TAG_BR: case TAG_DIV: setTagName( "P" ); return false; break; } return true; } }
Replaces the current content, destroying any existing content.
Sets the delimeter items.
Specifies whether the target browser supports style sheets. The default is false.
Specifies whether the target browser supports an object model. The default is false.
Replaces the current tag name with the new value.