User's Manual

54 Chapter 8. WAF Application Development Tutorial
package com.example.binder;
import com.arsdigita.db.Sequences;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException;
import java.io.IOException;
import java.io.Writer;
import java.sql.SQLException;
import java.math.BigInteger;
import org.apache.log4j.Logger;
/**
* A bit of text with a title.
*
* @see com.example.binder.Note
* @author Justin Ross
*/
public class Note extends DomainObject {
private static final Logger s_log = Logger.getLogger(Note.class);
public static final String BASE_DATA_OBJECT_TYPE =
"com.example.binder.Note";
static final String ID = "id";
static final String TITLE = "title";
static final String BODY = "body";
protected String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
protected Note(final DataObject data) {
super(data);
if (isNew()) {
try {
set(ID, Sequences.getNextValue().toBigInteger());
} catch (SQLException sqle) {
throw new UncheckedWrapperException(sqle);
}
}
}
/**
* Gets the note’s unique ID.
*
* @return The <code>BigInteger</code> ID; it cannot be null
*/
public final BigInteger getID() {
return (BigInteger) get(ID);
}
/**
* Gets the title of the note.
*
* @return The <code>String</code> title; it cannot be null
*/
public final String getTitle() {
return (String) get(TITLE);
}