User's Manual

Chapter 8. WAF Application Development Tutorial 55
/**
* Sets the title of the note.
*
* @param title The <code>String</code> title; it cannot be null
*/
public final void setTitle(final String title) {
if (s_log.isDebugEnabled()) {
s_log.debug("Setting title of " + this + " to " + title);
}
Assert.exists(title, String.class);
set(TITLE, title);
}
/**
* Gets the body of the note.
*
* @return The <code>String</code> body; it may be null
*/
public final String getBody() {
return (String) get(BODY);
}
/**
* Sets the body of the note.
*
* @param body The <code>String</code> body; it may be null
*/
public final void setBody(final String body) {
if (s_log.isDebugEnabled()) {
s_log.debug("Setting body of " + this + " to " + body);
}
if (Assert.isEnabled() && body != null) {
Assert.truth(body.length() <= 4000, "The body text is too long");
}
set(BODY, body);
}
/**
* Writes an XML representation of the note and its content.
*
* @param out A <code>Writer</code> to write the XML to
*/
public final void render(final Writer out) throws IOException {
out.write("<note id=\"" + getID() + "\">");
out.write("<title>" + getTitle() + "</title>");
final String body = getBody();
if (body != null) {
out.write("<body>" + getBody() + "</body>");
}
out.write("</note>");
}
}
Example 8-4. binder/src/com/example/binder/Note.java