1 7 8 package org.dom4j.tree; 9 10 import org.dom4j.Element; 11 import org.dom4j.Node; 12 13 33 public class FlyweightEntity extends AbstractEntity { 34 35 protected String name; 36 37 38 protected String text; 39 40 43 protected FlyweightEntity() { 44 } 45 46 52 public FlyweightEntity(String name) { 53 this.name = name; 54 } 55 56 64 public FlyweightEntity(String name, String text) { 65 this.name = name; 66 this.text = text; 67 } 68 69 74 public String getName() { 75 return name; 76 } 77 78 83 public String getText() { 84 return text; 85 } 86 87 98 public void setText(String text) { 99 if (this.text != null) { 100 this.text = text; 101 } else { 102 throw new UnsupportedOperationException ( 103 "This Entity is read-only. " + "It cannot be modified"); 104 } 105 } 106 107 protected Node createXPathResult(Element parent) { 108 return new DefaultEntity(parent, getName(), getText()); 109 } 110 } 111 112 148 | Popular Tags |