|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--objectivehtml.oms.OMSObject | +--objectivehtml.htmlwidget.HtmlElement
This abstract class is represents a html element and is the base class of all the html widgets in this library.
The class holds the start and eng tag for html element it represents. All attribute values for the html element are also contained in this class.
The class also allows you to change the quote type for this element. The quote type is used when the element is written to the output stream. All attribute values are quoted using the quote type. The default quote type is the double quote character ".
All classes that extend this class must implement the printHtml methods.
setQuoteType(String)
,
printHtml(JspWriter)
,
printHtml(PrintWriter)
Field Summary | |
protected java.util.HashMap |
m_hmAttributes
The internal hash-map of (attribute, value) pairs for this element |
protected java.lang.String |
m_sEndTag
The end tag of this element |
protected java.lang.String |
m_sQuoteType
The quote type for this element |
protected java.lang.String |
m_sStartTag
The start tag of this element |
Constructor Summary | |
HtmlElement()
Constructs an instance of the HtmlElement object. |
Method Summary | |
protected java.lang.String |
genEndTag(int nOutputType)
Generates the end tag. |
protected java.lang.String |
genStartTag(int nOutputType)
Generates the start tag with all the attribute values that have been set for this object. |
protected java.lang.String |
genStartTag(int nOutputType,
java.lang.String sAttributeToBeEscaped,
boolean bEscaped)
Generates the start tag with all the attribute values that have been set for this object. |
java.lang.String |
getAttribute(java.lang.String sName)
Returns the value of the specified attribute, the name is case-insensitive. |
java.util.HashMap |
getAttributes()
Returns all the attributes of this element in a HashMap object. |
boolean |
getBooleanAttribute(java.lang.String sName)
Returns the value of the specified boolean-attribute, the name is case-insensitive. |
java.lang.String |
getQuoteType()
Returns the quote type. |
void |
printHtml(javax.servlet.jsp.JspWriter objWriter)
This overloaded version is simply a wrapper for the other version of this method. |
abstract void |
printHtml(javax.servlet.jsp.JspWriter objWriter,
int nOutputType)
This virtual method must be implemented by all children classes. |
protected void |
printHtml(javax.servlet.jsp.JspWriter objWriter,
int nOutputType,
java.util.Collection clChildElements)
Prints the html that represents this object to the output stream. |
protected void |
printHtml(javax.servlet.jsp.JspWriter objWriter,
int nOutputType,
java.lang.String sText,
boolean bEscapeText)
Prints the html that represents this object to the output stream. |
void |
printHtml(java.io.PrintWriter objWriter)
This overloaded version is simply a wrapper for the other version of this method. |
abstract void |
printHtml(java.io.PrintWriter objWriter,
int nOutputType)
This virtual method must be implemented by all children classes. |
protected void |
printHtml(java.io.PrintWriter objWriter,
int nOutputType,
java.util.Collection clChildElements)
Prints the html that represents this object to the output stream. |
protected void |
printHtml(java.io.PrintWriter objWriter,
int nOutputType,
java.lang.String sText,
boolean bEscapeText)
Prints the html that represents this object to the output stream. |
void |
setAttribute(java.lang.String sName,
java.lang.String sValue)
Sets a html attribute for this object. |
void |
setBooleanAttribute(java.lang.String sName,
boolean bIsOn)
Sets a html boolean-attribute for this object. |
void |
setQuoteType(java.lang.String sQuoteType)
Sets the quote type. |
java.lang.String |
toString()
Writes a string representing this element in html format. |
java.lang.String |
toString(int nOutputType)
Writes a string representing this element. |
Methods inherited from class objectivehtml.oms.OMSObject |
compareClasses, connect, disconnect, emit, isAlive, setAlive, signal, slot, slot |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.String m_sStartTag
protected java.lang.String m_sEndTag
protected java.util.HashMap m_hmAttributes
protected java.lang.String m_sQuoteType
Constructor Detail |
public HtmlElement()
Method Detail |
public void setQuoteType(java.lang.String sQuoteType) throws InvalidQuoteTypeException
Sets the quote type. The only valid quote types allowed are ", ' or a null string.
The default quote type is ". If the html-type is xhtml then this setting is ignored, for xhtml the quote type is always the double quote character.
sQuoteType
- the new quote typeInvalidQuoteTypeException
- if the quote type specified is not allowedgetQuoteType()
public java.lang.String getQuoteType()
setQuoteType(String)
protected java.lang.String genStartTag(int nOutputType)
Generates the start tag with all the attribute values that have been set for this object. The output generated will depend on the output-type specified. The output-types currently supported are listed in the OutputType class.
This overloaded version is simply a wrapper for the other version of this method. i.e.
genStartTag(nOutputType, null, false);
nOutputType
- the output typegenStartTag(int, String, boolean)
,
OutputType
,
genEndTag(int)
,
printHtml(JspWriter)
,
printHtml(PrintWriter)
protected java.lang.String genStartTag(int nOutputType, java.lang.String sAttributeToBeEscaped, boolean bEscaped)
Generates the start tag with all the attribute values that have been set for this object. The output generated will depend on the output-type specified. The output-types currently supported are listed in the OutputType class.
This overloaded version can escape the characters of an attribute given by sAttributeToBeEscaped. The value of this attribute is escaped with the htmlSpecialChars() method.
This method is used internally by the printHtml methods to generate the output strings.
nOutputType
- the output typesAttributeToBeEscaped
- the attribute to be escapedbEscaped
- true if the attribute should be escaped, false otherwiseOutputType
,
HtmlUtils.htmlSpecialChars(String)
,
genEndTag(int)
,
printHtml(JspWriter)
,
printHtml(PrintWriter)
protected java.lang.String genEndTag(int nOutputType)
Generates the end tag. Not all HtmlElement objects need to have an end tag.
This method is used internally by the printHtml methods to generate the output strings.
nOutputType
- the output typegenStartTag(int)
,
printHtml(JspWriter)
,
printHtml(PrintWriter)
public void setAttribute(java.lang.String sName, java.lang.String sValue) throws InvalidAttributeException
Sets a html attribute for this object. The name of the attribute is case-insensitive.
Setting an attribute with this method and calling a wrapper method will result in the same effect on the object. e.g. Calling setAttribute("value", "Some text."), is the same as calling setValue("Some text.").
To clear the attribute specify the null reference for the value. If you specify an empty string, the attribute is still written out by printHtml methods but with a blank value. If the attribute is cleared the attribute is not written out at all.
sName
- the name of the attributesValue
- the value of the attribute, if null is specified
then the attribute will be clearedInvalidAttributeException
- if the name is not validgetAttribute(String)
,
setBooleanAttribute(String, boolean)
public void setBooleanAttribute(java.lang.String sName, boolean bIsOn) throws InvalidAttributeException
Sets a html boolean-attribute for this object. The name of the attribute is case-insensitive.
Setting a boolean-attribute with this method and calling a wrapper method will result in the same effect on the object. e.g. Calling setBooleanAttribute("disabled", true), is the same as calling setDisabled(true).
sName
- the name of the attributebIsOn
- true if attribute should be set, if false
is specified then the attribute is clearedInvalidAttributeException
- if the name is not validgetBooleanAttribute(String)
,
setAttribute(String, String)
public java.util.HashMap getAttributes()
public java.lang.String getAttribute(java.lang.String sName)
setAttribute(String, String)
,
getBooleanAttribute(String)
public boolean getBooleanAttribute(java.lang.String sName)
setBooleanAttribute(String, boolean)
,
getAttribute(String)
public void printHtml(java.io.PrintWriter objWriter) throws java.io.IOException
This overloaded version is simply a wrapper for the other version of this method. i.e.
printHtml(objWriter, OutputType.HTML);
This version should be used by servlets.
objWriter
- the output stream for a servlet objectjava.io.IOException
- if it cannot write the outputOutputType
,
printHtml(JspWriter)
public abstract void printHtml(java.io.PrintWriter objWriter, int nOutputType) throws java.io.IOException
This virtual method must be implemented by all children classes. The method prints out the contents of itself in the specified output-type onto the output stream.
The output generated will depend on the output-type specified. The output-types currently supported are listed in the OutputType class.
This version should be used by servlets.
objWriter
- the output stream for a servlet objectnOutputType
- the output typejava.io.IOException
- if it cannot write the outputOutputType
,
printHtml(JspWriter)
public void printHtml(javax.servlet.jsp.JspWriter objWriter) throws java.io.IOException
This overloaded version is simply a wrapper for the other version of this method. i.e.
printHtml(objWriter, OutputType.HTML);
This version should be used by Jsp pages.
objWriter
- the output stream for a servlet objectjava.io.IOException
- if it cannot write the outputOutputType
,
printHtml(JspWriter)
public abstract void printHtml(javax.servlet.jsp.JspWriter objWriter, int nOutputType) throws java.io.IOException
This virtual method must be implemented by all children classes. The method prints out the contents of itself in the specified output-type onto the output stream.
The output generated will depend on the output-type specified. The output-types currently supported are listed in the OutputType class.
This version should be used by jsp pages.
objWriter
- the output stream for a jsp objectnOutputType
- the output typejava.io.IOException
- if it cannot write the outputOutputType
,
printHtml(PrintWriter)
protected void printHtml(java.io.PrintWriter objWriter, int nOutputType, java.lang.String sText, boolean bEscapeText) throws java.io.IOException
Prints the html that represents this object to the output stream.
This is a helper version of printHtml. Should only be used by other classes in this toolkit.
objWriter
- the output stream for a Servlet objectnOutputType
- the output typesText
- the text between the start and end tagbEscapeText
- indicates if the text is to be escapedjava.io.IOException
- if it cannot write the outputprotected void printHtml(javax.servlet.jsp.JspWriter objWriter, int nOutputType, java.lang.String sText, boolean bEscapeText) throws java.io.IOException
Prints the html that represents this object to the output stream.
This is a helper version of printHtml. Should only be used by other classes in this toolkit.
objWriter
- the output stream for a Jsp pagenOutputType
- the output typesText
- the text between the start and end tagbEscapeText
- indicates if the text is to be escapedjava.io.IOException
- if it cannot write the outputprotected void printHtml(java.io.PrintWriter objWriter, int nOutputType, java.util.Collection clChildElements) throws java.io.IOException
Prints the html that represents this object to the output stream.
This is a helper version of printHtml. Should only be used by other classes in this toolkit.
objWriter
- the output stream for a Servlet objectnOutputType
- the output typeclChildElements
- a collection of children widgetsjava.io.IOException
- if it cannot write the outputprotected void printHtml(javax.servlet.jsp.JspWriter objWriter, int nOutputType, java.util.Collection clChildElements) throws java.io.IOException
Prints the html that represents this object to the output stream.
This is a helper version of printHtml. Should only be used by other classes in this toolkit.
objWriter
- the output stream for a Jsp pagenOutputType
- the output typeclChildElements
- a collection of children widgetsjava.io.IOException
- if it cannot write the outputpublic java.lang.String toString(int nOutputType)
nOutputType
- the output typepublic java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |