1 7 8 package org.dom4j.tree; 9 10 import java.util.Collections ; 11 import java.util.Map ; 12 13 import org.dom4j.Element; 14 import org.dom4j.Node; 15 16 30 public class FlyweightProcessingInstruction extends 31 AbstractProcessingInstruction { 32 33 protected String target; 34 35 36 protected String text; 37 38 39 protected Map values; 40 41 44 public FlyweightProcessingInstruction() { 45 } 46 47 57 public FlyweightProcessingInstruction(String target, Map values) { 58 this.target = target; 59 this.values = values; 60 this.text = toString(values); 61 } 62 63 73 public FlyweightProcessingInstruction(String target, String text) { 74 this.target = target; 75 this.text = text; 76 this.values = parseValues(text); 77 } 78 79 public String getTarget() { 80 return target; 81 } 82 83 public void setTarget(String target) { 84 throw new UnsupportedOperationException ("This PI is read-only and " 85 + "cannot be modified"); 86 } 87 88 public String getText() { 89 return text; 90 } 91 92 public String getValue(String name) { 93 String answer = (String ) values.get(name); 94 95 if (answer == null) { 96 return ""; 97 } 98 99 return answer; 100 } 101 102 public Map getValues() { 103 return Collections.unmodifiableMap(values); 104 } 105 106 protected Node createXPathResult(Element parent) { 107 return new DefaultProcessingInstruction(parent, getTarget(), getText()); 108 } 109 } 110 111 147 | Popular Tags |