com.plumtree.xpshared.htmlelements
Class HTMLElement

java.lang.Object
  extended by com.plumtree.xpshared.htmlelements.HTMLElement
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
HTMLAnchor, HTMLArea, HTMLB, HTMLBdo, HTMLBlockQuote, HTMLBody, HTMLBr, HTMLComment, HTMLDiv, HTMLElementCollection, HTMLEm, HTMLForm, HTMLFrame, HTMLFrameSet, HTMLGenericElement, HTMLGenericInputElement, HTMLH1, HTMLH2, HTMLH3, HTMLH4, HTMLHead, HTMLImg, HTMLLayer, HTMLLink, HTMLList, HTMLListItem, HTMLMap, HTMLMeta, HTMLNoScript, HTMLOption, HTMLP, HTMLPage, HTMLQ, HTMLScript, HTMLScriptCollection, HTMLSpan, HTMLStrong, HTMLTable, HTMLTableCell, HTMLTableRow, HTMLTitle

public abstract class HTMLElement
extends java.lang.Object
implements java.lang.Cloneable

All object representing HTML elements should subclass this class.

Defined within this abstract class are methods for getting and setting attributes common to all HTML elements, such as ID, NAME, CLASS, and STYLE.

Other methods, such as appendInnerHTML and appendTabs, will help subclasses display themselves. Most all of the code for displaying HTML and generating HTML strings is located in this class. For the most part, subclasses will not need to concern themselves with this functionality, but only with implementing the abstract methods of this class. Exceptions to this are those subclasses that need to modify their display in some way, such as the HTMLElementCollection class. This class displays much like any other HTMLElement object, except it does not display any HTML itself, but only that HTML generated by its children. For this reason, the HTMLElementCollection class needs to override the display methods of this class. Other classes may not support HTML formatting, such as the HTMLAnchor and HTMLTextArea class. Formatting of the HTML generated by these classes affects the display in a bad way, so formatting is not supported, and display methods need to be overridden.

This class also provides methods and data structures for managing nested HTML objects, such as addInnerHTMLElement and getInnerHTMLElements.


Nested Class Summary
static class HTMLElement.ValidationLevel
           
 
Field Summary
static byte[] aNewLine
           
static boolean bAllowEvents
          Toggle this false to log errors when clients attempt to set values for attributes such as onclick, and onmouseover.
static boolean bAllowSetStyleClassWithString
          Set this member variable to specify whether or not the SetStyleClass method throws an HTMLException when called with a String parameter.
static boolean bCheckNestedStringForHTML
          Set this boolean true to cause HTMLElements to write warnings to the log file if nested strings contain HTML.
protected  boolean bDisplayDidPause
           
static boolean bEnforceMaxTableDepth
          Set this member variable to specify whether or not a maximum table depth is enforced.
 boolean bForceFormattingOff
          Set this boolean true to force formatting of for this element as well as nested elements.
 boolean bForceFormattingOn
           
protected  boolean bPauseAfterDisplay
           
static boolean bPrintComments
          Set this member variable to specify whether or not comments are printed by the display methods.
protected  boolean bResumingAndChildFinished
           
protected  boolean bResumingAndChildInMidRender
           
protected  boolean bShowLang
           
static int iMaxTableDepth
          This int member specifies the maximum depth of table nesting.
protected  java.lang.String sLangLocal
          sLangLocal is used when an element's lang attribute is different from the global lang attribute.
static java.lang.String sNewLine
          Set this member to specify the newline character.
static java.lang.String sTab
          This member variable to specify the tab character.
 
Method Summary
 void AddInnerHTMLElement(HTMLElement e)
          Call this method to append an additional HTML element to be displayed within this HTML element.
 void AddInnerHTMLEncodedString(java.lang.String s)
          Call this method to append an additional HTML String to be displayed within this HTML element.
 void AddInnerHTMLString(java.lang.String s)
          Call this method to append an additional HTML String to be displayed within this HTML element.
protected abstract  void AppendBeginningOfOpeningTag(boolean bFormat, XPStringBuilder sb, IXPResponse response)
          Concrete subclasses must implement this method.
protected  void AppendClosingLineBreak(XPStringBuilder sb, IXPResponse response)
           
protected abstract  void AppendClosingTag(boolean bFormat, XPStringBuilder sb, IXPResponse response)
          Concrete subclasses must implement this method.
 void CleanupHTMLSubtreeAfterRendering()
          This is only called if this element is the root of the display tree.
 void ClearInnerHTMLElements()
          Call this method to remove all nested html elements from this element.
protected  java.lang.Object clone()
          Do not call this method.
 void Display(IXPResponse response)
          Call this method to display the HTML of this object to the IXPResponse object.
 void Display(IXPResponse response, boolean bFormat)
          Call this method to display this object's HTML to an IXPResponse object.
 void ForceFormattingOff()
          Call this method to force formatting off for this HTMLElement object.
protected  HTMLElement GetChildInMidRender()
          Call this method to obtain a reference to the child that is in mid render.
 java.lang.Object GetClone()
          Call this method to obtain a clone of this HTMLElement object.
 boolean GetDisabled()
          Call this method to determine whether or not the disabled attribute is displayed for this HTML element.
 boolean GetDisplayDidPause()
          Call this method to determine whether or not the most recent call to one of the display methods paused.
protected  DisplayOptions GetDisplayOptions()
          Helper method to do lazy initialization of display options.
 java.lang.String GetDisplayString()
          Call this method to obtain a String of HTML markup that represents this HTML element, and all HTML elements nested within.
protected  java.lang.String GetDisplayString(boolean bFormat)
          This method is the internal String generator for all HTMLElement classes.
protected  void GetDisplayString(boolean bFormat, XPStringBuilder sbLocal)
          This method is the internal String generator for all HTMLElement classes.
 boolean GetDo508Checking()
          This method returns whether or not to do 508 validity checking for HTMLElements.
 boolean GetDoFormat()
          Call this method to determine whether or not this HTML element generates HTML text formatted for readabilty.
 java.lang.String GetElementName()
          Call this method to determine the name of this element.
 boolean GetForceLineBreaksAfterSafeElements()
          This method returns whether or not to use line breaks after elements where it does not affect the HTML output.
protected  boolean GetHTMLElementReadOnly()
           
 java.lang.String GetID()
          Call this method to determine the value of the id attribute of this HTML element.
 java.lang.String GetImgBaseUrl()
          Call this method to obtain the base url used for all HTMLImg objects being displayed
 java.lang.String GetInnerHTML()
           
 void GetInnerHTML(XPStringBuilder sbLocal, IXPResponse response, boolean bFormatLocal)
          Call this method to obtain the HTML nested within this element.
 java.lang.String GetInnerHTMLDisplayString()
           
 IXPEnumerator GetInnerHTMLElements(boolean bRecursive)
          Call this method to obtain an enumeration of the HTMLElement objects nested within this HTMLElement.
 XPArrayList GetInnerHTMLElementsAsArrayList(boolean bRecursive)
          Call this method to get an XPArrayList containing all nested HTMLElement objects.
 boolean GetIsNetscape()
          This method returns whether or not the browser is Netscape.
 java.lang.String GetLang()
          Returns the language for use in the attribute, either the local language if available, or the global language.
protected  HTMLElement GetLastChildFullyRendered()
          Call this method to obtain a reference to the last child that fully rendered.
 java.lang.String GetName()
          Call this method to determine the value of the name attribute of this HTML element.
 java.lang.String GetOnClick()
          Call this method to obtain the value of the setonclick attribute.
 java.lang.String GetOnKeyDown()
          Call this method to obtain the value of the onkeydown attribute.
 java.lang.String GetOnKeyPress()
          Call this method to obtain the value of the onkeypress attribute.
 java.lang.String GetOnKeyUp()
          Call this method to obtain the value of the onkeyup attribute.
 java.lang.String GetOnMouseOut()
          Call this method to obtain the value of the onmouseout attribute.
 java.lang.String GetOnMouseOver()
          Call this method to obtain the value of the onmouseover attribute.
 boolean GetPauseAfterDisplay()
          Call this method to determine whether or not this element pauses after display.
 java.lang.String GetPostComment()
          Call this method to obtain the comment that is written after the closing tag of this element.
 java.lang.String GetPreComment()
          Call this method to obtain the comment that is written before the opening tag of this element.
protected  XPStringBuilder GetStringBuilder()
          This method is used to get a reasonable sized String Builder.
 java.lang.String GetStyle()
          Call this method to obtain the value of the style attribute of this HTML element.
 java.lang.String GetStyleClass()
          Call this method to determine the style class assigned to this HTML element.
 java.lang.String GetStyleClassPrefix()
          This method returns the style class prefix used for all HTMLElement objects being displayed.
 java.lang.String GetTitle()
           
static HTMLElement.ValidationLevel GetValidationLevel()
          Call this method to obtain the ValidationLevel.
 HTMLElement InsertInnerHTMLElement(HTMLElement e)
          Adds an innerHTMLElement to the specified element, while also returning the element added.
protected  void InternalWrite(boolean bFormat, XPStringBuilder sbLocal, IXPResponse response)
          This method contains the bulk of the logic for writting an HTMLElement.
protected abstract  boolean ProvidesClosingTag()
          Implement this method to indicate whether a concrete subclass of HTMLElement provides a closing tag.
 java.lang.String SaveToTempFile()
          This method saves the display string of this object to a temporary file.
 java.lang.String SaveToTempFile(java.lang.String sFileName)
          This method saves the display string of this object to a temporary file.
protected  void SetChildInMidRender(HTMLElement e)
          Call this method to set the member reference to the child that is in mid render.
 void SetDisabled(boolean b)
          Call this method to toggle the "disabled" attribute for this element.
protected  void SetDisplayOptions(DisplayOptions options)
          Call this method to set the display options for this HTML tree.
 void SetDo508Checking(boolean b)
          This method sets whether or not to do 508 validity checking for HTMLElements.
 void SetDoFormat(boolean b)
          Call this method to specify whether or not this HTML element generates HTML text formatted for readabilty.
 void SetElementName(java.lang.String s)
          Call this method to give this element a name.
 void SetFlushAfterDisplay(boolean b)
          Call this method to cause the IXPResponse.Flush() method to be called after this element displays itself.
 void SetForceLineBreaksAfterSafeElements(boolean b)
          This method controls whether or not to use line breaks after elements where it does not affect the HTML output.
protected  void SetHTMLElementReadOnly(boolean b)
           
 void SetID(java.lang.String s)
          Call this method to set the ID attribute for this HTML element.
 void SetImgBaseUrl(java.lang.String s)
          Call this method to set the base url used for all HTMLImg objects being displayed.
protected  void SetInner(XPArrayList al)
          Call this method to set the internal XPArrayList of nested HTMLElement objects.
 void SetIsNetscape(boolean b)
          This method sets whether or not the browser is Netscape.
 void SetLangGlobal(java.lang.String s)
          Set the default language available for all child elements -- not necessarily displayed unless the element is set to display the language attribute.
 void SetLangLocal(java.lang.String s)
          Sets the value of the language attribute used by this element not the parent or child element(s).
protected  void SetLastChildFullyRendered(HTMLElement e)
          Call this method to set the member reference to the last child fully rendered.
 void SetName(java.lang.String s)
          Call this method to set the value of the name attribute of this HTML element.
 void SetOnClick(java.lang.String s)
          Call this method to set the setonclick attribute
 void SetOnKeyDown(java.lang.String s)
          Call this method to set the onkeydown attribute
 void SetOnKeyPress(java.lang.String s)
          Call this method to set the onkeypress attribute
 void SetOnKeyUp(java.lang.String s)
          Call this method to set the onkeyup attribute
 void SetOnMouseOut(java.lang.String s)
          Call this method to set the onmouseout attribute
 void SetOnMouseOver(java.lang.String s)
          Call this method to set the onmouseover attribute
 void SetPauseAfterDisplay(boolean b)
          Call this method to specify whether or not this element pauses after display.
 void SetPostComment(java.lang.String s)
          Use this method to set a comment that will be written after the closing tag of this element.
 void SetPreComment(java.lang.String s)
          Use this method to set a comment that will be written before the opening tag of this element.
 void SetStyle(java.lang.String s)
          Call this method to set the style attribute for this html element.
 void SetStyleClass(java.lang.String s)
          Call this method to Set the style class for this HTML element.
 void SetStyleClass(StyleClass s)
          Call this method to Set the style class for this HTML element.
 void SetStyleClassPrefix(java.lang.String s)
          Call this method to set the prefix used for all HTMLElement objects being displayed.
 void SetTitle(java.lang.String s)
           
static void SetValidationLevel(HTMLElement.ValidationLevel l)
          Call this method to specify the level at which html validation will occur.
static byte[] ToByteArray(java.lang.String _String)
          Convert a String to a byte array using XPStringUtility's default encoding, UTF-8.
protected  void VerifyWritability()
          This method checks whether or not this tree is read only and throws an exception if it is not.
protected  void WriteNugget(byte[] b, XPStringBuilder sbLocal, IXPResponse response)
          This protected method is used by this class an all subclasses to write the smallest divisible units of HTML.
protected  void WriteNugget(java.lang.String s, XPStringBuilder sbLocal, IXPResponse response)
          This protected method is used by this class an all subclasses to write the smallest divisible units of HTML.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bShowLang

protected boolean bShowLang

bPauseAfterDisplay

protected boolean bPauseAfterDisplay

bDisplayDidPause

protected boolean bDisplayDidPause

bResumingAndChildInMidRender

protected boolean bResumingAndChildInMidRender

bResumingAndChildFinished

protected boolean bResumingAndChildFinished

iMaxTableDepth

public static final int iMaxTableDepth
This int member specifies the maximum depth of table nesting. This is not enforced if bEnforceMaxTableDepth is false.

See Also:
Constant Field Values

bEnforceMaxTableDepth

public static boolean bEnforceMaxTableDepth
Set this member variable to specify whether or not a maximum table depth is enforced. If this member is true, then the display methods will throw exceptions if there are tables nested too deeply. See iMaxTableDepth.


bPrintComments

public static boolean bPrintComments
Set this member variable to specify whether or not comments are printed by the display methods.


bAllowSetStyleClassWithString

public static boolean bAllowSetStyleClassWithString
Set this member variable to specify whether or not the SetStyleClass method throws an HTMLException when called with a String parameter. If this member is set false, SetStyleClass( String ) will always throw an HTMLException. This is intended to force use of the corresponding method SetStyleClass( StyleClass ), to ensure valid style classes.


sNewLine

public static final java.lang.String sNewLine
Set this member to specify the newline character. If output is being formatted, this character is appended frequently. If output is not being formatted, this character is not used.

See Also:
Constant Field Values

aNewLine

public static final byte[] aNewLine

bCheckNestedStringForHTML

public static boolean bCheckNestedStringForHTML
Set this boolean true to cause HTMLElements to write warnings to the log file if nested strings contain HTML.


bForceFormattingOff

public boolean bForceFormattingOff
Set this boolean true to force formatting of for this element as well as nested elements.


bForceFormattingOn

public boolean bForceFormattingOn

sTab

public static final java.lang.String sTab
This member variable to specify the tab character. If output is being formatted, this character is appended zero or more times to the beginning of each line.

See Also:
Constant Field Values

bAllowEvents

public static boolean bAllowEvents
Toggle this false to log errors when clients attempt to set values for attributes such as onclick, and onmouseover.


sLangLocal

protected java.lang.String sLangLocal
sLangLocal is used when an element's lang attribute is different from the global lang attribute. For example a search result page may display results in languages different from the page itself.

Method Detail

SetHTMLElementReadOnly

protected void SetHTMLElementReadOnly(boolean b)

GetHTMLElementReadOnly

protected boolean GetHTMLElementReadOnly()

SetForceLineBreaksAfterSafeElements

public void SetForceLineBreaksAfterSafeElements(boolean b)
This method controls whether or not to use line breaks after elements where it does not affect the HTML output. This can only be used on a top-level HTMLElement (usually an HTMLPage).

Parameters:
b - boolean true implies use line breaks.

GetForceLineBreaksAfterSafeElements

public boolean GetForceLineBreaksAfterSafeElements()
This method returns whether or not to use line breaks after elements where it does not affect the HTML output.

Returns:
boolean true implies use line breaks.

SetTitle

public void SetTitle(java.lang.String s)

GetTitle

public java.lang.String GetTitle()

SetLangGlobal

public void SetLangGlobal(java.lang.String s)
Set the default language available for all child elements -- not necessarily displayed unless the element is set to display the language attribute.

Parameters:
s - String value

GetLang

public java.lang.String GetLang()
Returns the language for use in the attribute, either the local language if available, or the global language.

Returns:
String value

SetLangLocal

public void SetLangLocal(java.lang.String s)
Sets the value of the language attribute used by this element not the parent or child element(s).

Parameters:
s - String value

SetIsNetscape

public void SetIsNetscape(boolean b)
This method sets whether or not the browser is Netscape. Certain HTMLElements will display differently on Netscape versus other browsers. This can only be used on a top-level HTMLElement (usually an HTMLPage).

Parameters:
b - boolean true implies the browser is Netscape

GetIsNetscape

public boolean GetIsNetscape()
This method returns whether or not the browser is Netscape.

Returns:
boolean true implies the browser is Netscape.

SetFlushAfterDisplay

public void SetFlushAfterDisplay(boolean b)
Call this method to cause the IXPResponse.Flush() method to be called after this element displays itself. This will only cause a flushing of the response buffer if the IXPResponse object is passed to the display method.

Parameters:
b - boolean

SetPauseAfterDisplay

public void SetPauseAfterDisplay(boolean b)
Call this method to specify whether or not this element pauses after display. If you pass true, after this html element fully renders, display will stop. The resulting HTML will not be complete. One of the display methods must be called again, and rendering will resume with the html immediately after this element. Call GetDisplayPaused() to determine whether or not the previous call to one of the display methods resulted in a pause.

Parameters:
b - boolean indicating whether or not this node pauses.

GetPauseAfterDisplay

public boolean GetPauseAfterDisplay()
Call this method to determine whether or not this element pauses after display.

Returns:
boolean value

GetLastChildFullyRendered

protected HTMLElement GetLastChildFullyRendered()
Call this method to obtain a reference to the last child that fully rendered.

Returns:
HTMLElement child

SetLastChildFullyRendered

protected void SetLastChildFullyRendered(HTMLElement e)
Call this method to set the member reference to the last child fully rendered.

Parameters:
e - HTMLElement child

GetChildInMidRender

protected HTMLElement GetChildInMidRender()
Call this method to obtain a reference to the child that is in mid render.

Returns:
HTMLElement child

SetChildInMidRender

protected void SetChildInMidRender(HTMLElement e)
Call this method to set the member reference to the child that is in mid render.

Parameters:
e - HTMLElement child

GetDisplayDidPause

public boolean GetDisplayDidPause()
Call this method to determine whether or not the most recent call to one of the display methods paused. If this method returns true, a display method must be called again to render a complete HTML page.

Returns:

SetDo508Checking

public void SetDo508Checking(boolean b)
This method sets whether or not to do 508 validity checking for HTMLElements. If this is true, HTMLElements will try to enforce that the developer does not make HTML that is not 508 compliant. This can only be used on a top-level HTMLElement (usually an HTMLPage).

Parameters:
b - boolean true implies enforce 508 validity.

GetDo508Checking

public boolean GetDo508Checking()
This method returns whether or not to do 508 validity checking for HTMLElements. If this is true, HTMLElements will try to enforce that the developer does not make HTML that is not 508 compliant.

Returns:
boolean true implies enforce 508 validity.

GetImgBaseUrl

public java.lang.String GetImgBaseUrl()
Call this method to obtain the base url used for all HTMLImg objects being displayed

Returns:
String base url.

SetImgBaseUrl

public void SetImgBaseUrl(java.lang.String s)
Call this method to set the base url used for all HTMLImg objects being displayed.

Call this method only on the root HTMLElement object. If you are building an HTMLPage, for example, call myPage.SetImgBaseUrl( "http://blah/" );. All nested HTMLImg objects may use the base url specified on the HTMLPage object.

HTMLImg objects may or may not use this base url specified. This can only be used on a top-level HTMLElement (usually an HTMLPage).

Parameters:
s - Pass a base url string. It should look something like: "http://blah/".

GetStyleClassPrefix

public java.lang.String GetStyleClassPrefix()
This method returns the style class prefix used for all HTMLElement objects being displayed.

Returns:
The base URL used for style classes.

SetStyleClassPrefix

public void SetStyleClassPrefix(java.lang.String s)
Call this method to set the prefix used for all HTMLElement objects being displayed.

Call this method only on the root HTMLElement object. If you are building an HTMLPage, for example, call myPage.SetStyleClassPrefix( "PREFIX" );. All nested objects may use the prefix specified on the HTMLPage object.

This can only be used on a top-level HTMLElement (usually an HTMLPage).

Parameters:
s - Pass a base url string. It should look something like: "http://blah/".

SetDisplayOptions

protected void SetDisplayOptions(DisplayOptions options)
Call this method to set the display options for this HTML tree.

This method is called internally during the execution of display methods.

Parameters:
options - DisplayOptions object.

GetDisplayOptions

protected DisplayOptions GetDisplayOptions()
Helper method to do lazy initialization of display options. Call this method to get the display options for display of this HTML tree. This method will only return a meaningful value during the execution of the display methods. This value will be cleared when display is finished.

Returns:
DisplayOptions the display options for this HTML tree.

SetElementName

public void SetElementName(java.lang.String s)
Call this method to give this element a name. The name does not affect the HTML output of this element, the name is purely for identification puposes.

Parameters:
s - Pass a String.

GetElementName

public java.lang.String GetElementName()
Call this method to determine the name of this element.


clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Do not call this method. This is implemented only so that internal clone methods can call clone() on HTMLElement objects.

Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

GetClone

public java.lang.Object GetClone()
Call this method to obtain a clone of this HTMLElement object.


SetInner

protected void SetInner(XPArrayList al)
Call this method to set the internal XPArrayList of nested HTMLElement objects. Warning: This will erase all elements previously added to this element through calls to AddInnerHTMLElement.

Throws:
HTMLException - if this element is read only.

AppendBeginningOfOpeningTag

protected abstract void AppendBeginningOfOpeningTag(boolean bFormat,
                                                    XPStringBuilder sb,
                                                    IXPResponse response)
Concrete subclasses must implement this method. This method is responsible for appending the begining of the opening tag, for example: <tagname attribute="blah"

Common attributes will be automatically appended to the begninning of the opening tag.

Parameters:
bFormat - Pass a boolean indicating whether or not to format.
sb - Pass an XPStringBuilder. If this is not null, HTML will be appended to this string builder.
response - Pass an IXPResponse. If this is not null, HTML will be written to this response.

AppendClosingTag

protected abstract void AppendClosingTag(boolean bFormat,
                                         XPStringBuilder sb,
                                         IXPResponse response)
Concrete subclasses must implement this method. This method is responsible for appending the closing tag.

Parameters:
bFormat - Pass a boolean indicating whether or not to format.
sb - Pass an XPStringBuilder. If this is not null, HTML will be appended to this string builder.
response - Pass an IXPResponse. If this is not null, HTML will be written to this response.

ProvidesClosingTag

protected abstract boolean ProvidesClosingTag()
Implement this method to indicate whether a concrete subclass of HTMLElement provides a closing tag. Elements such as BR do not provide closing tags, they are self-closing.


SaveToTempFile

public java.lang.String SaveToTempFile()
This method saves the display string of this object to a temporary file.

Returns:
The absolute path of the file saved.

SaveToTempFile

public java.lang.String SaveToTempFile(java.lang.String sFileName)
This method saves the display string of this object to a temporary file.

Parameters:
sFileName - Pass the name of the file within which you wish to save this HTMLPage.

Returns:
The absolute path of the file saved.

SetOnClick

public void SetOnClick(java.lang.String s)
Call this method to set the setonclick attribute

Parameters:
s - Pass the value of this attribute.

GetOnClick

public java.lang.String GetOnClick()
Call this method to obtain the value of the setonclick attribute.


SetOnMouseOver

public void SetOnMouseOver(java.lang.String s)
Call this method to set the onmouseover attribute

Parameters:
s - Pass the value of this attribute.

GetOnMouseOver

public java.lang.String GetOnMouseOver()
Call this method to obtain the value of the onmouseover attribute.


SetOnMouseOut

public void SetOnMouseOut(java.lang.String s)
Call this method to set the onmouseout attribute

Parameters:
s - Pass the value of this attribute.

GetOnMouseOut

public java.lang.String GetOnMouseOut()
Call this method to obtain the value of the onmouseout attribute.


SetOnKeyUp

public void SetOnKeyUp(java.lang.String s)
Call this method to set the onkeyup attribute

Parameters:
s - Pass the value of this attribute.

GetOnKeyUp

public java.lang.String GetOnKeyUp()
Call this method to obtain the value of the onkeyup attribute.


SetOnKeyDown

public void SetOnKeyDown(java.lang.String s)
Call this method to set the onkeydown attribute

Parameters:
s - Pass the value of this attribute.

GetOnKeyDown

public java.lang.String GetOnKeyDown()
Call this method to obtain the value of the onkeydown attribute.


SetOnKeyPress

public void SetOnKeyPress(java.lang.String s)
Call this method to set the onkeypress attribute

Parameters:
s - Pass the value of this attribute.

GetOnKeyPress

public java.lang.String GetOnKeyPress()
Call this method to obtain the value of the onkeypress attribute.


SetPreComment

public void SetPreComment(java.lang.String s)
Use this method to set a comment that will be written before the opening tag of this element.


GetPreComment

public java.lang.String GetPreComment()
Call this method to obtain the comment that is written before the opening tag of this element.


SetPostComment

public void SetPostComment(java.lang.String s)
Use this method to set a comment that will be written after the closing tag of this element.


GetPostComment

public java.lang.String GetPostComment()
Call this method to obtain the comment that is written after the closing tag of this element.


GetDoFormat

public boolean GetDoFormat()
Call this method to determine whether or not this HTML element generates HTML text formatted for readabilty.


SetDoFormat

public void SetDoFormat(boolean b)
Call this method to specify whether or not this HTML element generates HTML text formatted for readabilty.


ForceFormattingOff

public void ForceFormattingOff()
Call this method to force formatting off for this HTMLElement object.

Whether or not HTML is formatted generally percolates down through an HTMLElement structure.


AppendClosingLineBreak

protected void AppendClosingLineBreak(XPStringBuilder sb,
                                      IXPResponse response)

GetStringBuilder

protected XPStringBuilder GetStringBuilder()
This method is used to get a reasonable sized String Builder. It should be overridden by larger HTMLElements such as HTMLPage.

Returns:
XPStringBuilder

GetDisplayString

public java.lang.String GetDisplayString()
Call this method to obtain a String of HTML markup that represents this HTML element, and all HTML elements nested within.

Throws:
HTMLException

GetInnerHTML

public java.lang.String GetInnerHTML()

GetInnerHTMLDisplayString

public java.lang.String GetInnerHTMLDisplayString()

Display

public void Display(IXPResponse response,
                    boolean bFormat)
Call this method to display this object's HTML to an IXPResponse object.

Parameters:
response - Pass an IXPResponse object.
bFormat - Pass a boolean indicating whether or not you wish this element's HTML to be formatted.
Throws:
HTMLException - If display fails, an HTMLException will be thrown.

Display

public void Display(IXPResponse response)
Call this method to display the HTML of this object to the IXPResponse object.

All HTML of this object, as well as the HTML of any nested HTMLElement objects will be displayed.

Parameters:
response - Pass an IXPResponse object.

WriteNugget

protected void WriteNugget(java.lang.String s,
                           XPStringBuilder sbLocal,
                           IXPResponse response)
This protected method is used by this class an all subclasses to write the smallest divisible units of HTML. These nuggets of HTML are either appended to an XPStringBuilder, written to the IXPResponse, both, or neither.

Parameters:
s - Pass a String you wish appended or written.
sb - Pass an XPStringBuilder to which you wish the String appended. Pass null if you do not wish the string appended to an XPStringBuilder.
response - Pass an IXPResponse to which you wish the String written. Pass null if you do not wish the string written to an IXPResponse.

WriteNugget

protected void WriteNugget(byte[] b,
                           XPStringBuilder sbLocal,
                           IXPResponse response)
This protected method is used by this class an all subclasses to write the smallest divisible units of HTML. These nuggets of HTML are either appended to an XPStringBuilder, written to the IXPResponse, both, or neither.

This method is similar to the WriteNugget method with the String argument, but different in that it does not require the response to convert the String argument to a byte array.

Parameters:
s - Pass a byte array you wish appended or written.
sbLocal - Pass an XPStringBuilder to which you wish the String appended. Pass null if you do not wish the string appended to an XPStringBuilder.
response - Pass an IXPResponse to which you wish the String written. Pass null if you do not wish the string written to an IXPResponse.

InternalWrite

protected void InternalWrite(boolean bFormat,
                             XPStringBuilder sbLocal,
                             IXPResponse response)
This method contains the bulk of the logic for writting an HTMLElement. For subclasses needing to modify their display behavior, this is the primary method to override.

Parameters:
bFormat - Pass a boolean indicating whether or not to format the output.
sb - Pass an XPStringBuilder to which you wish the String appended. Pass null if you do not wish the string appended to an XPStringBuilder.
response - Pass an IXPResponse to which you wish the String written. Pass null if you do not wish the string written to an IXPResponse.

CleanupHTMLSubtreeAfterRendering

public void CleanupHTMLSubtreeAfterRendering()
This is only called if this element is the root of the display tree.


GetDisplayString

protected void GetDisplayString(boolean bFormat,
                                XPStringBuilder sbLocal)
This method is the internal String generator for all HTMLElement classes. This method may be overridden by subclasses, but this shouldn't be necessary.

Parameters:
bFormat - This parameter toggles whether or not all formating text is included in the display string.

GetDisplayString

protected java.lang.String GetDisplayString(boolean bFormat)
This method is the internal String generator for all HTMLElement classes. This method may be overridden by subclasses, but this shouldn't be necessary.

Parameters:
bFormat - This parameter toggles whether or not all formating text is included in the display string.

SetStyleClass

public void SetStyleClass(java.lang.String s)
Call this method to Set the style class for this HTML element. Calling this method with the parameter "gContentSection", for example, will cause this element to display something like: <td class="gContentSection"...


SetStyleClass

public void SetStyleClass(StyleClass s)
Call this method to Set the style class for this HTML element. Calling this method with the parameter "gContentSection", for example, will cause this element to display something like: <td class="gContentSection"...


GetStyleClass

public java.lang.String GetStyleClass()
Call this method to determine the style class assigned to this HTML element. This style class will be rendered as an attribute of this element, like: <a class="styleclass"...


SetStyle

public void SetStyle(java.lang.String s)
Call this method to set the style attribute for this html element. Calling this method with the parameter "text-decoration:none" for example, will cause this element to display something like: <a style="text-decoration:none"...

Parameters:
s -

GetStyle

public java.lang.String GetStyle()
Call this method to obtain the value of the style attribute of this HTML element.

Returns:
String indicating the style attribute value.

SetID

public void SetID(java.lang.String s)
Call this method to set the ID attribute for this HTML element.

ID attributes may not contain spaces or dollar signs or anything weird. ID attributes must be unique to each element on a given HTML page. This is currently not enforced by this method.

Parameters:
s - Pass the ID you wish to use for this element.

GetID

public java.lang.String GetID()
Call this method to determine the value of the id attribute of this HTML element.


SetName

public void SetName(java.lang.String s)
Call this method to set the value of the name attribute of this HTML element.


GetName

public java.lang.String GetName()
Call this method to determine the value of the name attribute of this HTML element.


SetDisabled

public void SetDisabled(boolean b)
Call this method to toggle the "disabled" attribute for this element.

Parameters:
b -
Throws:
HTMLException

GetDisabled

public boolean GetDisabled()
Call this method to determine whether or not the disabled attribute is displayed for this HTML element.


VerifyWritability

protected void VerifyWritability()
This method checks whether or not this tree is read only and throws an exception if it is not.

Throws:
HTMLException - if this element is read only.

AddInnerHTMLElement

public void AddInnerHTMLElement(HTMLElement e)
Call this method to append an additional HTML element to be displayed within this HTML element. For example, if this is a <body> element, and you append an <img> element, and then you append an <a> element, the body element will display something like: "<body><img><a></body>"

Not all HTML elements allow you to append inner HTML elements. Such elements will throw an exception if you attempt to do this.

Throws:
HTMLException - if this element is read only.

InsertInnerHTMLElement

public HTMLElement InsertInnerHTMLElement(HTMLElement e)
Adds an innerHTMLElement to the specified element, while also returning the element added.

Throws:
HTMLException - if this element is read only.

ClearInnerHTMLElements

public void ClearInnerHTMLElements()
Call this method to remove all nested html elements from this element.

Throws:
HTMLException - if this element is read only.

GetInnerHTMLElementsAsArrayList

public XPArrayList GetInnerHTMLElementsAsArrayList(boolean bRecursive)
Call this method to get an XPArrayList containing all nested HTMLElement objects.

Parameters:
bRecursive - Pass a boolean indicating whether or not you wish this list to be recursive.

GetInnerHTMLElements

public IXPEnumerator GetInnerHTMLElements(boolean bRecursive)
Call this method to obtain an enumeration of the HTMLElement objects nested within this HTMLElement.

Parameters:
bRecursive - Pass true to obtain an enumeration of all nested elements. Pass false to obtain an enumeration of only those elements nested immediately within this element.

AddInnerHTMLString

public void AddInnerHTMLString(java.lang.String s)
Call this method to append an additional HTML String to be displayed within this HTML element. For example, if this is a <body> element, and you append the "<img>" String, and then you append the "<a>" String, the body element will display something like: "<body><img><a></body>"

Not all HTML elements allow you to append inner HTML Strings. Such elements will throw an exception if you attempt to do this.

The String appended is not validated. You are free to append garbage. This String will not be HTMLEncoded, therefore this method will be faster than addInnerHTMLEncodedString(). All localized strings should be safe and should therefore use this method. If a string contains some text that should be encoded, and some that should not, it should be manually encoded and this method should be used instead of addInnerHTMLEncodedString().

Parameters:
s - Pass a String representation of a valid HTML element.
Throws:
HTMLException

AddInnerHTMLEncodedString

public void AddInnerHTMLEncodedString(java.lang.String s)
Call this method to append an additional HTML String to be displayed within this HTML element. For example, if this is a <body> element, and you append the "<img>" String, and then you append the "<a>" String, the body element will display something like: "<body><img><a></body>"

Not all HTML elements allow you to append inner HTML Strings. Such elements will throw an exception if you attempt to do this.

The String appended is not validated. You are free to append garbage. This String will be automatically HTMLEncoded for you. This method will be significantly slower than addInnerHTMLString(), so it should only be used for data that really needs to be HTMLEncoded (things entered by users). This method should not be used for localized strings, which should be safe. If a string contains some text that should be encoded, and some that should not, it should be manually encoded and addInnerHTMLString() should be used.

Parameters:
s - Pass a String representation of a valid HTML element.
Throws:
HTMLException - if this element is read only

GetInnerHTML

public void GetInnerHTML(XPStringBuilder sbLocal,
                         IXPResponse response,
                         boolean bFormatLocal)
Call this method to obtain the HTML nested within this element. This HTML does not contain the HTML for this element.

Parameters:
sbLocal - Pass an XPStringBuilder. Pass null if you do not wish for the HTML string to be added to a buffer.
IXPResponse - Pass an IXPResponse. Pass null if you do not wish for the HTML string to be written to the response.
bFormat - Pass a boolean indicating whether or not to format this HTML.

SetValidationLevel

public static void SetValidationLevel(HTMLElement.ValidationLevel l)
Call this method to specify the level at which html validation will occur. Each available level will toggle each of the methods of validation that can occur.

Methods of validation currently include:



This method is offered as a convenience. Individual validation methods can be toggled individually.

Validation methods are enabled on a package-level-scope. For example, if maximum table depth is being enforced, it's enforced for all HTMLPage objects created. Validation methods cannot be toggled on an object-level-scope.


ToByteArray

public static byte[] ToByteArray(java.lang.String _String)
Convert a String to a byte array using XPStringUtility's default encoding, UTF-8. If the string is null return an array of zero length.

Parameters:
_String - String to convert to a byte array.
Returns:
a byte array derived from the String argument.

GetValidationLevel

public static HTMLElement.ValidationLevel GetValidationLevel()
Call this method to obtain the ValidationLevel.




Copyright 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.