1 9 10 package org.ozoneDB.xml.dom4j.o3impl; 11 12 import org.dom4j.Element; 13 import org.dom4j.Node; 14 15 import java.util.Collections ; 16 import java.util.Map ; 17 18 27 public class FlyweightProcessingInstruction extends AbstractProcessingInstruction { 28 29 30 protected String target; 31 32 33 protected String text; 34 35 36 protected Map values; 37 38 40 public FlyweightProcessingInstruction() { 41 } 42 43 48 public FlyweightProcessingInstruction(String target, Map values) { 49 this.target = target; 50 this.values = values; 51 this.text = toString(values); 52 } 53 54 59 public FlyweightProcessingInstruction(String target, String text) { 60 this.target = target; 61 this.text = text; 62 this.values = parseValues(text); 63 } 64 65 public String getTarget() { 66 return target; 67 } 68 69 public void setTarget(String target) { 70 throw new UnsupportedOperationException ("This PI is read-only and cannot be modified"); 71 } 72 73 public String getText() { 74 return text; 75 } 76 77 public String getValue(String name) { 78 String answer = (String ) values.get(name); 79 if (answer == null) { 80 return ""; 81 } 82 return answer; 83 } 84 85 public Map getValues() { 86 return Collections.unmodifiableMap(values); 87 } 88 89 protected Node createXPathResult(Element parent) { 90 return new DefaultProcessingInstruction(parent, getTarget(), getText()); 91 } 92 } 93 94 95 139 | Popular Tags |