because I want a deep Clone of the R so that I can change one Text of the R but the other is not be changed,
however it is not work.they also quote the same object(for example the rPr or the runContent in the R)
the clone method in Text Class:
- Code: Select all
public Text clone() throws CloneNotSupportedException{
return (Text)super.clone();
}
the clone method in R Class:
- Code: Select all
public R clone() throws CloneNotSupportedException{
R r= (R)super.clone();
Text text = new Text();
for (Object o2 : runContent) {
if (o2 instanceof javax.xml.bind.JAXBElement) {
// directly to Text.
if (((JAXBElement) o2).getDeclaredType().getName().equals("org.docx4j.wml.Text")) {
org.docx4j.wml.Text t = (org.docx4j.wml.Text) ((JAXBElement) o2).getValue();
text = t.clone();
}
}
}
for (int i=0;i<r.getRunContent().size();i++){
if (r.getRunContent().get(i) instanceof javax.xml.bind.JAXBElement) {
// directly to Text.
if (((JAXBElement) r.getRunContent().get(i)).getDeclaredType().getName().equals("org.docx4j.wml.Text")) {
((JAXBElement) r.getRunContent().get(i)).setValue(text);
}
}
}
return r;
}
has any problem?? what I forget to do??