net.sourceforge.ajaxtags.helpers
Class AbstractHTMLElement

java.lang.Object
  extended by net.sourceforge.ajaxtags.helpers.AbstractHTMLElement
All Implemented Interfaces:
Appendable, CharSequence
Direct Known Subclasses:
DIVElement, JavaScript

public abstract class AbstractHTMLElement
extends Object
implements CharSequence, Appendable

This class should help to write HTML-Tags we will have a simple append operation and a easy use in connection with strings.


Nested Class Summary
static class AbstractHTMLElement.HTMLAttribute
          A simple enumeration holding some HTML-Attributes we are using.
 
Constructor Summary
protected AbstractHTMLElement(String name)
          Create a HTML element.
protected AbstractHTMLElement(String name, String id)
          Create a HTML element.
protected AbstractHTMLElement(String name, String id, String body)
          Create a HTML element.
 
Method Summary
 AbstractHTMLElement append(char c)
          Append a char.
 AbstractHTMLElement append(CharSequence string)
          Append CharSequence to this object.
 AbstractHTMLElement append(CharSequence csq, int start, int end)
           
 char charAt(int index)
           
protected  void cleanAttributes()
          Cleaning the attributes.
protected  SortedMap<Object,String> getAttributes()
           
 String getBody()
           
 String getClassName()
           
 String getId()
           
protected  String getName()
           
 int length()
           
 void setBody(CharSequence body)
          Set the body content.
 void setClassName(String className)
          Set the class name attribute.
 void setId(String id)
          Set the id attribute.
 CharSequence subSequence(int start, int end)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractHTMLElement

protected AbstractHTMLElement(String name,
                              String id,
                              String body)
Create a HTML element.

Parameters:
name - name of start and end tag
id - id of element
body - content

AbstractHTMLElement

protected AbstractHTMLElement(String name)
Create a HTML element.

Parameters:
name - the tag name

AbstractHTMLElement

protected AbstractHTMLElement(String name,
                              String id)
Create a HTML element.

Parameters:
name - the tag name
id - the id attribute
Method Detail

getAttributes

protected final SortedMap<Object,String> getAttributes()
Returns:
the map of attributes

getName

protected final String getName()
Returns:
the tag name

getBody

public final String getBody()
Returns:
the body content or empty string if body is null

setBody

public final void setBody(CharSequence body)
Set the body content.

Parameters:
body - the body content

getClassName

public final String getClassName()
Returns:
the class name attribute

setClassName

public final void setClassName(String className)
Set the class name attribute.

Parameters:
className - the class attribute value

getId

public final String getId()
Returns:
the id attribute

setId

public final void setId(String id)
Set the id attribute.

Parameters:
id - the id attribute value

length

public final int length()
Specified by:
length in interface CharSequence
Returns:
the length

charAt

public final char charAt(int index)
Specified by:
charAt in interface CharSequence
Parameters:
index - the index
Returns:
the char at index
See Also:
CharSequence.charAt(int)

subSequence

public final CharSequence subSequence(int start,
                                      int end)
Specified by:
subSequence in interface CharSequence
Parameters:
start - the start index
end - the end index
Returns:
the substring from start to end
See Also:
CharSequence.subSequence(int, int)

cleanAttributes

protected void cleanAttributes()
Cleaning the attributes. This method does nothing by default.


toString

public final String toString()
Specified by:
toString in interface CharSequence
Overrides:
toString in class Object
Returns:
the string representation of this HTML element

append

public final AbstractHTMLElement append(CharSequence string)
Append CharSequence to this object.

Specified by:
append in interface Appendable
Parameters:
string - the data to append
Returns:
self

append

public final AbstractHTMLElement append(char c)
Append a char.

Specified by:
append in interface Appendable
Parameters:
c - the char to append
Returns:
self

append

public final AbstractHTMLElement append(CharSequence csq,
                                        int start,
                                        int end)
Specified by:
append in interface Appendable
Parameters:
csq - the char sequence
start - the start index
end - the end index
Returns:
self


Copyright © 2005-2010 The Ajaxtags Team. All Rights Reserved.