001    /*
002     @license.text@
003     */
004    package biz.hammurapi.sql;
005    
006    import java.sql.SQLException;
007    import java.util.Properties;
008    
009    import org.w3c.dom.Element;
010    
011    import biz.hammurapi.config.ConfigurationException;
012    
013    /**
014     * Interface of DatabaseObject. This interface is used for creating dynamic proxies backed
015     * up with database obects.
016     * @author Pavel Vlasov
017     * @revision $Revision$
018     */
019    public interface IDatabaseObject {
020    
021            /**
022             * Updates row in a table by primary key
023             * @param processor SQLProcessor
024             * @param tableName Target table
025             * @return Number of updates
026             * @throws SQLException
027             */
028            public abstract int update(SQLProcessor processor, String tableName) throws SQLException;
029    
030            /**
031             * Deletes row in a table by primary key.
032             * @param processor SQLProcessor
033             * @param tableName Target table
034             * @return Number of updates
035             * @throws SQLException
036             */
037            public abstract int delete(SQLProcessor processor, String tableName) throws SQLException;
038    
039            public abstract int insert(SQLProcessor processor, String tableName) throws SQLException;
040    
041            /**
042             * Loads columns from XML element
043             * @param holder
044             * @throws ConfigurationException If loading fails
045             */
046            public abstract void fromDom(Element holder) throws ConfigurationException;
047    
048            public abstract void fromDom(Element holder, Properties nameMap) throws ConfigurationException;
049    
050            /**
051             * Serializes to DOM.
052             * @param holder Holder element
053             * @param nameMap Name map
054             * @param originals Output original values if any.
055             */
056            public abstract void toDom(Element holder, Properties nameMap, boolean originals);
057    
058            /**
059             * Sets current values as original values in primary key columns.
060             */
061            public abstract void setOriginal();
062    
063            /**
064             * @return true if object was modified since last database operation.
065             */
066            public abstract boolean isModified();
067    
068            /**
069             * isDeleted flag is cleared when primary key columns are modified
070             * @return true if delete() method was executed.
071             */
072            public abstract boolean isDeleted();
073    
074            /**
075             * Sets all columns to default values and clears 
076             * modified and deleted flags.
077             *
078             */
079            public abstract void clear();
080    
081            /**
082             * Copies values from source object to this object
083             * @param source
084             */
085            public abstract void copy(DatabaseObject source);
086    
087            public abstract void setColumnAttribute(String columnName, Object key, Object value);
088    
089            public abstract Object getColumnAttribute(String columnName, Object key);
090    
091            public abstract Object removeColumnAttribute(String columnName, Object key);
092    
093    }