1 2 package org.roller.pojos; 3 4 import java.io.Serializable ; 5 6 import org.apache.commons.lang.builder.EqualsBuilder; 7 import org.apache.commons.lang.builder.HashCodeBuilder; 8 import org.apache.commons.lang.builder.ToStringBuilder; 9 import org.apache.commons.lang.builder.ToStringStyle; 10 import org.roller.RollerException; 11 import org.roller.business.PersistenceStrategy; 12 import org.roller.model.RollerFactory; 13 14 17 public abstract class PersistentObject implements Serializable 18 { 19 private long mTimeStamp = 0L; 21 public PersistentObject() 22 { 23 } 24 25 26 public abstract void setData( PersistentObject vo ); 27 28 29 public abstract String getId(); 30 31 32 public abstract void setId( String id ); 33 34 36 37 public void save() throws RollerException 38 { 39 PersistenceStrategy pstrategy = 40 RollerFactory.getRoller().getPersistenceStrategy(); 41 pstrategy.store(this); 42 } 43 44 public void remove() throws RollerException 45 { 46 PersistenceStrategy pstrategy = 47 RollerFactory.getRoller().getPersistenceStrategy(); 48 pstrategy.remove(this); 49 } 50 51 52 public String toString() 53 { 54 try 55 { 56 return ToStringBuilder.reflectionToString( 58 this, ToStringStyle.MULTI_LINE_STYLE); 59 } 60 catch (Throwable e) 61 { 62 return getClass().getName() + ":" + getId(); 64 } 65 } 66 67 public boolean equals(Object o) { 68 return EqualsBuilder.reflectionEquals(this, o); 69 } 70 71 72 public boolean canSave() throws RollerException 73 { 74 return true; 75 } 76 } 77 78 | Popular Tags |