|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.click.util.HtmlStringBuffer
Provides a HTML element StringBuffer for rendering, automatically escaping string values. HtmlStringBuffer is used by Click controls for HTML rendering.
For example the following code:public String toString() { HtmlStringBuffer buffer = new HtmlStringBuffer(); buffer.elementStart("input"); buffer.appendAttribute("type", "text"); buffer.appendAttribute("name", getName()); buffer.appendAttribute("value", getValue()); buffer.elementEnd(); return buffer.toString(); }Would render:
<input type="text" name="address" value="23 Holt's Street"/>
| Field Summary | |
protected char[] |
characters
The character storage array. |
protected int |
count
The count is the number of characters used. |
| Constructor Summary | |
HtmlStringBuffer()
Create a new HTML StringBuffer with an initial capacity of 128 characters. |
|
HtmlStringBuffer(int length)
Create a new HTML StringBuffer with the specified initial capacity. |
|
| Method Summary | |
HtmlStringBuffer |
append(char value)
Append the char value to the buffer. |
HtmlStringBuffer |
append(double value)
Append the double value to the buffer. |
HtmlStringBuffer |
append(int value)
Append the integer value to the buffer. |
HtmlStringBuffer |
append(long value)
Append the long value to the buffer. |
HtmlStringBuffer |
append(Object value)
Append the raw object value of the given object to the buffer. |
HtmlStringBuffer |
append(String value)
Append the raw string value of the given object to the buffer. |
HtmlStringBuffer |
appendAttribute(String name,
int value)
Append the given HTML attribute name and value to the string buffer. |
HtmlStringBuffer |
appendAttribute(String name,
Object value)
Append the given HTML attribute name and value to the string buffer, and do not escape the attribute value. |
HtmlStringBuffer |
appendAttributeDisabled()
Append the HTML "disabled" attribute to the string buffer. |
HtmlStringBuffer |
appendAttributeEscaped(String name,
Object value)
Append the given attribute name and value to the buffer, if the value is not null. |
HtmlStringBuffer |
appendAttributeReadonly()
Append the HTML "readonly" attribute to the string buffer. |
HtmlStringBuffer |
appendAttributes(Map attributes)
Append the given map of attribute names and values to the string buffer. |
HtmlStringBuffer |
appendEscaped(Object value)
Append the given value to the buffer and escape its HMTL value. |
HtmlStringBuffer |
appendStyleAttributes(Map attributes)
Append the given map of CSS style name and value pairs as a style attribute to the string buffer. |
HtmlStringBuffer |
closeTag()
Append a HTML element end to the string buffer. |
HtmlStringBuffer |
elementEnd()
Append a HTML element end to the string buffer. |
HtmlStringBuffer |
elementEnd(String name)
Append a HTML element end to the string buffer. |
HtmlStringBuffer |
elementStart(String name)
Append a HTML element start to the string buffer. |
protected void |
expandCapacity(int minimumCapacity)
Ensures that the capacity is at least equal to the specified minimum. |
boolean |
isJavaScriptAttribute(String name)
Return true if the given attribute name is a JavaScript attribute, or false otherwise. |
int |
length()
Return the length of the string buffer. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected char[] characters
protected int count
| Constructor Detail |
public HtmlStringBuffer(int length)
length - the initial capacitypublic HtmlStringBuffer()
| Method Detail |
public HtmlStringBuffer append(double value)
value - the double value to append
public HtmlStringBuffer append(char value)
value - the char value to append
public HtmlStringBuffer append(int value)
value - the integer value to append
public HtmlStringBuffer append(long value)
value - the long value to append
public HtmlStringBuffer append(Object value)
value - the object value to append
public HtmlStringBuffer append(String value)
value - the string value to append
public HtmlStringBuffer appendEscaped(Object value)
value - the object value to append
IllegalArgumentException - if the value is null
public HtmlStringBuffer appendAttribute(String name,
Object value)
appendAttribute("size", 10) -> size="10"
name - the HTML attribute namevalue - the HTML attribute value
IllegalArgumentException - if name is null
public HtmlStringBuffer appendAttributeEscaped(String name,
Object value)
appendAttribute("class", "required") -> class="required"
The attribute value will be HMTL escaped. If the attribute name is a
JavaScript event handler the value will not be escaped.
name - the HTML attribute namevalue - the object value to append
IllegalArgumentException - if name is null
public HtmlStringBuffer appendAttribute(String name,
int value)
appendAttribute("size", 10) -> size="10"
name - the HTML attribute namevalue - the HTML attribute value
IllegalArgumentException - if name is nullpublic HtmlStringBuffer appendAttributeDisabled()
appendAttributeDisabled() -> disabled="disabled"
public HtmlStringBuffer appendAttributeReadonly()
appendAttributeReadonly() -> readonly="readonly"
public HtmlStringBuffer appendAttributes(Map attributes)
attributes - the map of attribute names and values
IllegalArgumentException - if attributes is nullpublic HtmlStringBuffer appendStyleAttributes(Map attributes)
attributes - the map of CSS style names and values
IllegalArgumentException - if attributes is nullpublic HtmlStringBuffer elementEnd(String name)
elementEnd("textarea") -> </textarea>
name - the HTML element name to end
IllegalArgumentException - if name is nullpublic HtmlStringBuffer closeTag()
closeTag() -> >
public HtmlStringBuffer elementEnd()
elementEnd() -> />
public HtmlStringBuffer elementStart(String name)
elementStart("input") -> <input
name - the HTML element name to start
public boolean isJavaScriptAttribute(String name)
name - the HTML attribute name to test
public int length()
public String toString()
Object.toString()protected void expandCapacity(int minimumCapacity)
minimumCapacity argument.
2.
minimumCapacity argument is nonpositive, this method
takes no action and simply returns.
minimumCapacity - the minimum desired capacity
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||