1 19 package org.netbeans.tax; 20 21 import org.netbeans.tax.spec.Document; 22 import org.netbeans.tax.spec.DocumentFragment; 23 import org.netbeans.tax.spec.Element; 24 import org.netbeans.tax.spec.GeneralEntityReference; 25 import org.netbeans.tax.spec.DTD; 26 import org.netbeans.tax.spec.ParameterEntityReference; 27 import org.netbeans.tax.spec.DocumentType; 28 import org.netbeans.tax.spec.ConditionalSection; 29 30 35 public class TreeProcessingInstruction extends TreeData implements Document.Child, DocumentFragment.Child, Element.Child, GeneralEntityReference.Child, DTD.Child, ParameterEntityReference.Child, DocumentType.Child, ConditionalSection.Child { 36 37 public static final String PROP_TARGET = "target"; 39 40 private String target; 41 42 43 47 50 public TreeProcessingInstruction (String target, String data) throws InvalidArgumentException { 51 super (data); 52 53 checkTarget (target); 54 this.target = target; 55 } 56 57 58 59 protected TreeProcessingInstruction (TreeProcessingInstruction processingInstruction) { 60 super (processingInstruction); 61 62 this.target = processingInstruction.target; 63 } 64 65 66 70 72 public Object clone () { 73 return new TreeProcessingInstruction (this); 74 } 75 76 78 public boolean equals (Object object, boolean deep) { 79 if (!!! super.equals (object, deep)) 80 return false; 81 82 TreeProcessingInstruction peer = (TreeProcessingInstruction) object; 83 if (!!! Util.equals (this.getTarget (), peer.getTarget ())) { 84 return false; 85 } 86 87 return true; 88 } 89 90 93 public void merge (TreeObject treeObject) throws CannotMergeException { 94 super.merge (treeObject); 95 96 TreeProcessingInstruction peer = (TreeProcessingInstruction) treeObject; 97 setTargetImpl (peer.getTarget ()); 98 } 99 100 101 102 106 108 protected final void checkData (String data) throws InvalidArgumentException { 109 TreeUtilities.checkProcessingInstructionData (data); 110 } 111 112 115 protected TreeData createData (String data) throws InvalidArgumentException { 116 return new TreeProcessingInstruction (this.target, data); 117 } 118 119 123 125 public final String getTarget () { 126 return target; 127 } 128 129 131 private final void setTargetImpl (String newTarget) { 132 String oldTarget = this.target; 133 134 this.target = newTarget; 135 136 firePropertyChange (PROP_TARGET, oldTarget, newTarget); 137 } 138 139 140 144 public final void setTarget (String newTarget) throws ReadOnlyException, InvalidArgumentException { 145 if ( Util.equals (this.target, newTarget) ) 149 return; 150 checkReadOnly (); 151 checkTarget (newTarget); 152 153 setTargetImpl (newTarget); 157 } 158 159 160 162 public final void checkTarget (String target) throws InvalidArgumentException { 163 TreeUtilities.checkProcessingInstructionTarget (target); 164 } 165 166 } 167 | Popular Tags |