org.loom.tags
Class AbstractWriterWrapper<T extends java.io.Writer>

java.lang.Object
  extended by org.loom.tags.AbstractWriterWrapper<T>
All Implemented Interfaces:
WriterWrapper<T>
Direct Known Subclasses:
JspWriterWrapper, PrintWriterWrapper, StringWriterWrapper

public abstract class AbstractWriterWrapper<T extends java.io.Writer>
extends java.lang.Object
implements WriterWrapper<T>

Abstract writer implementation


Field Summary
protected  T writer
           
 
Constructor Summary
AbstractWriterWrapper(T writer)
           
 
Method Summary
 WriterWrapper<T> end(java.lang.String tag)
          Ends a HTML tag
 WriterWrapper<T> endJavascript()
          Write a javascript end tag
 void flush()
          Flush the written contents
 T getWriter()
           
 WriterWrapper<T> print(java.lang.Object o)
          Print ant Object, invoking its toString() method
 WriterWrapper<T> printAttribute(java.lang.String name, java.lang.Object value)
          Prints a tag attribute and value, if not null
 WriterWrapper<T> printHiddenField(java.lang.String name, java.lang.Object value)
          Prints a hidden form field if its value is not null
 WriterWrapper<T> start(java.lang.String tag, java.lang.Object... attributes)
          Start an HTML tag.
 WriterWrapper<T> startEnd(java.lang.String tag, java.lang.Object... attributes)
          Start and end a bodyless HTML tag.
 WriterWrapper<T> startJavascript()
          Write a javascript start tag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.loom.tags.WriterWrapper
print
 

Field Detail

writer

protected T extends java.io.Writer writer
Constructor Detail

AbstractWriterWrapper

public AbstractWriterWrapper(T writer)
Method Detail

printAttribute

public WriterWrapper<T> printAttribute(java.lang.String name,
                                       java.lang.Object value)
                                                       throws java.io.IOException
Description copied from interface: WriterWrapper
Prints a tag attribute and value, if not null

Specified by:
printAttribute in interface WriterWrapper<T extends java.io.Writer>
Parameters:
name - name of the attribute
value - value of the attribute. If null, nothing will be written
Returns:
this same instance
Throws:
java.io.IOException

getWriter

public T getWriter()
Specified by:
getWriter in interface WriterWrapper<T extends java.io.Writer>
Returns:
the true writer instance

print

public WriterWrapper<T> print(java.lang.Object o)
                                              throws java.io.IOException
Description copied from interface: WriterWrapper
Print ant Object, invoking its toString() method

Specified by:
print in interface WriterWrapper<T extends java.io.Writer>
Parameters:
o - the object to be written
Returns:
this same instance
Throws:
java.io.IOException

printHiddenField

public WriterWrapper<T> printHiddenField(java.lang.String name,
                                         java.lang.Object value)
                                                         throws java.io.IOException
Description copied from interface: WriterWrapper
Prints a hidden form field if its value is not null

Specified by:
printHiddenField in interface WriterWrapper<T extends java.io.Writer>
Parameters:
name - name of the field
value - value of the field. If null, nothing will be written
Throws:
java.io.IOException

startJavascript

public WriterWrapper<T> startJavascript()
                                                        throws java.io.IOException
Description copied from interface: WriterWrapper
Write a javascript start tag

Specified by:
startJavascript in interface WriterWrapper<T extends java.io.Writer>
Throws:
java.io.IOException

endJavascript

public WriterWrapper<T> endJavascript()
                                                      throws java.io.IOException
Description copied from interface: WriterWrapper
Write a javascript end tag

Specified by:
endJavascript in interface WriterWrapper<T extends java.io.Writer>
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Description copied from interface: WriterWrapper
Flush the written contents

Specified by:
flush in interface WriterWrapper<T extends java.io.Writer>
Throws:
java.io.IOException

startEnd

public WriterWrapper<T> startEnd(java.lang.String tag,
                                 java.lang.Object... attributes)
                                                 throws java.io.IOException
Description copied from interface: WriterWrapper
Start and end a bodyless HTML tag. This method will write the tag complete with all the provided attributes. The attributes must be in pairs (name, value) Example of use: startEnd("img", "href", "foo.html", "class", "bar") will write <img href="foo.html" class="bar"/> If any of the provided attribute values is null, it will be ignored.

Specified by:
startEnd in interface WriterWrapper<T extends java.io.Writer>
Throws:
java.io.IOException

start

public WriterWrapper<T> start(java.lang.String tag,
                              java.lang.Object... attributes)
                                              throws java.io.IOException
Description copied from interface: WriterWrapper
Start an HTML tag. This method will write the starting tag complete with all the provided attributes. The attributes must be in pairs (name, value) Example of use: start("a", "href", "foo.html", "class", "bar") will write <a href="foo.html" class="bar"> If any of the provided attribute values is null, it will be ignored.

Specified by:
start in interface WriterWrapper<T extends java.io.Writer>
Throws:
java.io.IOException

end

public WriterWrapper<T> end(java.lang.String tag)
                                            throws java.io.IOException
Description copied from interface: WriterWrapper
Ends a HTML tag

Specified by:
end in interface WriterWrapper<T extends java.io.Writer>
Throws:
java.io.IOException