使用的某个DO要能使用CLONE方法首先这个类要实现这个接口
implements Cloneable
类的实现体里面写入这个方法:
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return null;
}
这样就可以直接调用.clone()来生成一个克隆对象了。这个类如下:
/*
* Created on 2007-7-23 11:40:12
* @author hejing
*/
package com.megaeyes.sms.gateway.databean;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
public class MessageBean implements Serializable, Cloneable {
private static final long serialVersionUID = -1353347933934679190L;
private String topic; //
private String msgSrcID; //
private String msgTypeID; //
private String deviceName; //
private String deviceTypeName; //
private String deviceIP; //
private String msgTypeName; //
private String msgID; //
private String severityName; //
private String faultTime; //
private String content; //
private String targetNumber;//
private Integer spId;//
private String spName;//
private String spOrganId;//
private Integer spType;//
private Integer spInterfaceType;//
private String spInterfaceUrl;//
private String spInterfaceUser;//
private String spInterfacePass;//
private String spProvider;//
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return null;
}
public Integer getSpId() {
return spId;
}
public void setSpId(Integer spId) {
this.spId = spId;
}
public String getSpName() {
return spName;
}
public void setSpName(String spName) {
this.spName = spName;
}
public String getSpOrganId() {
return spOrganId;
}
public void setSpOrganId(String spOrganId) {
this.spOrganId = spOrganId;
}
public Integer getSpType() {
return spType;
}
public void setSpType(Integer spType) {
this.spType = spType;
}
public Integer getSpInterfaceType() {
return spInterfaceType;
}
public void setSpInterfaceType(Integer spInterfaceType) {
this.spInterfaceType = spInterfaceType;
}
public String getSpInterfaceUrl() {
return spInterfaceUrl;
}
public void setSpInterfaceUrl(String spInterfaceUrl) {
this.spInterfaceUrl = spInterfaceUrl;
}
public String getSpInterfaceUser() {
return spInterfaceUser;
}
public void setSpInterfaceUser(String spInterfaceUser) {
this.spInterfaceUser = spInterfaceUser;
}
public String getSpInterfacePass() {
return spInterfacePass;
}
public void setSpInterfacePass(String spInterfacePass) {
this.spInterfacePass = spInterfacePass;
}
public String getSpProvider() {
return spProvider;
}
public void setSpProvider(String spProvider) {
this.spProvider = spProvider;
}
public String getTargetNumber() {
return targetNumber;
}
public void setTargetNumber(String targetNumber) {
this.targetNumber = targetNumber;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
public String getDeviceIP() {
return deviceIP;
}
public void setDeviceIP(String deviceIP) {
this.deviceIP = deviceIP;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceTypeName() {
return deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
public String getFaultTime() {
return faultTime;
}
public void setFaultTime(String faultTime) {
this.faultTime = faultTime;
}
public String getMsgID() {
return msgID;
}
public void setMsgID(String msgID) {
this.msgID = msgID;
}
public String getMsgSrcID() {
return msgSrcID;
}
public void setMsgSrcID(String msgSrcID) {
this.msgSrcID = msgSrcID;
}
public String getMsgTypeID() {
return msgTypeID;
}
public void setMsgTypeID(String msgTypeID) {
this.msgTypeID = msgTypeID;
}
public String getMsgTypeName() {
return msgTypeName;
}
public void setMsgTypeName(String msgTypeName) {
this.msgTypeName = msgTypeName;
}
public String getSeverityName() {
return severityName;
}
public void setSeverityName(String severityName) {
this.severityName = severityName;
}
public String toString() {
return new ToStringBuilder(this).append("msgSrcID", this.msgSrcID)
.append("severityName", this.severityName).append("deviceIP",
this.deviceIP).append("content", this.content).append(
"deviceName", this.deviceName).append("msgTypeID",
this.msgTypeID).append("targetNumber",
this.targetNumber).append("deviceTypeName",
this.deviceTypeName)
.append("faultTime", this.faultTime)
.append("topic", this.topic).append("msgTypeName",
this.msgTypeName).append("msgID", this.msgID)
.toString();
}
}
implements Cloneable
类的实现体里面写入这个方法:
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return null;
}
这样就可以直接调用.clone()来生成一个克隆对象了。这个类如下:
/*
* Created on 2007-7-23 11:40:12
* @author hejing
*/
package com.megaeyes.sms.gateway.databean;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
public class MessageBean implements Serializable, Cloneable {
private static final long serialVersionUID = -1353347933934679190L;
private String topic; //
private String msgSrcID; //
private String msgTypeID; //
private String deviceName; //
private String deviceTypeName; //
private String deviceIP; //
private String msgTypeName; //
private String msgID; //
private String severityName; //
private String faultTime; //
private String content; //
private String targetNumber;//
private Integer spId;//
private String spName;//
private String spOrganId;//
private Integer spType;//
private Integer spInterfaceType;//
private String spInterfaceUrl;//
private String spInterfaceUser;//
private String spInterfacePass;//
private String spProvider;//
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return null;
}
public Integer getSpId() {
return spId;
}
public void setSpId(Integer spId) {
this.spId = spId;
}
public String getSpName() {
return spName;
}
public void setSpName(String spName) {
this.spName = spName;
}
public String getSpOrganId() {
return spOrganId;
}
public void setSpOrganId(String spOrganId) {
this.spOrganId = spOrganId;
}
public Integer getSpType() {
return spType;
}
public void setSpType(Integer spType) {
this.spType = spType;
}
public Integer getSpInterfaceType() {
return spInterfaceType;
}
public void setSpInterfaceType(Integer spInterfaceType) {
this.spInterfaceType = spInterfaceType;
}
public String getSpInterfaceUrl() {
return spInterfaceUrl;
}
public void setSpInterfaceUrl(String spInterfaceUrl) {
this.spInterfaceUrl = spInterfaceUrl;
}
public String getSpInterfaceUser() {
return spInterfaceUser;
}
public void setSpInterfaceUser(String spInterfaceUser) {
this.spInterfaceUser = spInterfaceUser;
}
public String getSpInterfacePass() {
return spInterfacePass;
}
public void setSpInterfacePass(String spInterfacePass) {
this.spInterfacePass = spInterfacePass;
}
public String getSpProvider() {
return spProvider;
}
public void setSpProvider(String spProvider) {
this.spProvider = spProvider;
}
public String getTargetNumber() {
return targetNumber;
}
public void setTargetNumber(String targetNumber) {
this.targetNumber = targetNumber;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
public String getDeviceIP() {
return deviceIP;
}
public void setDeviceIP(String deviceIP) {
this.deviceIP = deviceIP;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceTypeName() {
return deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
public String getFaultTime() {
return faultTime;
}
public void setFaultTime(String faultTime) {
this.faultTime = faultTime;
}
public String getMsgID() {
return msgID;
}
public void setMsgID(String msgID) {
this.msgID = msgID;
}
public String getMsgSrcID() {
return msgSrcID;
}
public void setMsgSrcID(String msgSrcID) {
this.msgSrcID = msgSrcID;
}
public String getMsgTypeID() {
return msgTypeID;
}
public void setMsgTypeID(String msgTypeID) {
this.msgTypeID = msgTypeID;
}
public String getMsgTypeName() {
return msgTypeName;
}
public void setMsgTypeName(String msgTypeName) {
this.msgTypeName = msgTypeName;
}
public String getSeverityName() {
return severityName;
}
public void setSeverityName(String severityName) {
this.severityName = severityName;
}
public String toString() {
return new ToStringBuilder(this).append("msgSrcID", this.msgSrcID)
.append("severityName", this.severityName).append("deviceIP",
this.deviceIP).append("content", this.content).append(
"deviceName", this.deviceName).append("msgTypeID",
this.msgTypeID).append("targetNumber",
this.targetNumber).append("deviceTypeName",
this.deviceTypeName)
.append("faultTime", this.faultTime)
.append("topic", this.topic).append("msgTypeName",
this.msgTypeName).append("msgID", this.msgID)
.toString();
}
}