打字猴:1.700471127e+09
1700471127 }
1700471128
1700471129 public String getState3(){
1700471130
1700471131 return state3;
1700471132
1700471133 }
1700471134
1700471135 public void setState3(String state3){
1700471136
1700471137 this.state3=state3;
1700471138
1700471139 }
1700471140
1700471141 //创建一个备忘录
1700471142
1700471143 public Memento createMemento(){
1700471144
1700471145 return new Memento(BeanUtils.backupProp(this));
1700471146
1700471147 }
1700471148
1700471149 //恢复一个备忘录
1700471150
1700471151 public void restoreMemento(Memento_memento){
1700471152
1700471153 BeanUtils.restoreProp(this,_memento.getStateMap());
1700471154
1700471155 }
1700471156
1700471157 //增加一个toString方法
1700471158
1700471159 @Override
1700471160
1700471161 public String toString(){
1700471162
1700471163 return”state1=”+state1+”\nstat2=”+state2+”\nstate3=”+state3;
1700471164
1700471165 }
1700471166
1700471167 }
1700471168
1700471169 覆写toString方法是为了方便打印,可以让展示的结果更清晰。我们再来看BeanUtils工具类,如代码清单24-17所示。
1700471170
1700471171 代码清单24-17  BeanUtils工具类
1700471172
1700471173 public class BeanUtils{
1700471174
1700471175 //把bean的所有属性及数值放入到Hashmap中
1700471176
[ 上一页 ]  [ :1.700471127e+09 ]  [ 下一页 ]