1 23 24 package org.enhydra.xml.lazydom; 25 26 import org.enhydra.apache.xerces.dom.TextImpl; 27 import org.enhydra.xml.io.PreFormattedText; 28 import org.w3c.dom.Document ; 29 import org.w3c.dom.Node ; 30 31 34 public class LazyText extends TextImpl implements LazyNode, PreFormattedText { 35 41 protected LazyText(LazyDocument ownerDoc, 42 LazyText template, 43 String data) { 44 super(ownerDoc, 45 (template != null) ? template.getData() : data); 46 if (template != null) { 47 fTemplateNode = template; 48 fNodeId = template.getNodeId(); 49 } 50 } 51 52 56 59 private LazyText fTemplateNode = null; 60 61 65 public LazyText getTemplateText() { 66 return fTemplateNode; 67 } 68 69 72 public Node cloneNode(boolean deep) { 73 return super.cloneNode(deep); 75 } 76 77 81 84 private int fNodeId = NULL_NODE_ID; 85 86 89 private boolean fIsTemplateNode; 90 91 96 public void makeTemplateNode(int nodeId, 97 String text) { 98 fNodeId = nodeId; 99 fIsTemplateNode = true; 100 fPreFormattedText = text; 101 } 102 103 106 public void makeTemplateNode(int nodeId) { 107 fNodeId = nodeId; 108 fIsTemplateNode = true; 109 } 110 111 114 public int getNodeId() { 115 return fNodeId; 116 } 117 118 121 public boolean isTemplateNode() { 122 return fIsTemplateNode; 123 } 124 125 128 public LazyNode getTemplateNode() { 129 return fTemplateNode; 130 } 131 132 135 public LazyNode templateClone(Document ownerDocument) { 136 return new LazyText((LazyDocument)ownerDocument, this, null); 137 } 138 139 144 public void setNodeValue(String value) { 145 fNodeId = NULL_NODE_ID; 146 super.setNodeValue(value); 147 } 148 149 153 156 private String fPreFormattedText; 157 158 161 public String getPreFormattedText() { 162 return fPreFormattedText; 163 } 164 165 168 public void setPreFormattedText(String text) { 169 fPreFormattedText = text; 170 } 171 172 } 173 | Popular Tags |