persistentobject.java

来自「这个weblogging 设计得比较精巧」· Java 代码 · 共 78 行

JAVA
78
字号
package org.roller.pojos;import java.io.Serializable;import org.apache.commons.lang.builder.EqualsBuilder;import org.apache.commons.lang.builder.HashCodeBuilder;import org.apache.commons.lang.builder.ToStringBuilder;import org.apache.commons.lang.builder.ToStringStyle;import org.roller.RollerException;import org.roller.business.PersistenceStrategy;import org.roller.model.RollerFactory;/**  * Base class for all of Roller's persistent objects. */public abstract class PersistentObject implements Serializable{	private long mTimeStamp = 0L; // this was only for Castor, right? -Lance	public PersistentObject()	{	}	/** Setter needed by RollerImpl.storePersistentObject() */	public abstract void setData( PersistentObject vo );    /** Get ID */	public abstract String getId();    /** Set ID */	public abstract void setId( String id );	//---------------------------------------------------------- TimeStampable    public void save() throws RollerException     {        PersistenceStrategy pstrategy =            RollerFactory.getRoller().getPersistenceStrategy();        pstrategy.store(this);    }        public void remove() throws RollerException     {        PersistenceStrategy pstrategy =            RollerFactory.getRoller().getPersistenceStrategy();        pstrategy.remove(this);    }            public String toString()     {        try         {            // this may throw an exception if called by a thread that            return ToStringBuilder.reflectionToString(                this, ToStringStyle.MULTI_LINE_STYLE);        }        catch (Throwable e)        {            // alternative toString() implementation used in case of exception            return getClass().getName() + ":" + getId();        }    }    public boolean equals(Object o) {        return EqualsBuilder.reflectionEquals(this, o);    }        /** Can user associated with persistence session save this object? */    public boolean canSave() throws RollerException    {        return true;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?