KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tax > TreeProcessingInstruction


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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 /**
31  *
32  * @author Libor Kramolis
33  * @version 0.1
34  */

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 JavaDoc PROP_TARGET = "target"; // NOI18N
38

39     /** */
40     private String JavaDoc target;
41     
42     
43     //
44
// init
45
//
46

47     /** Creates new TreeProcessingInstruction.
48      * @throws InvalidArgumentException
49      */

50     public TreeProcessingInstruction (String JavaDoc target, String JavaDoc data) throws InvalidArgumentException {
51         super (data);
52         
53         checkTarget (target);
54         this.target = target;
55     }
56     
57     
58     /** Creates new TreeProcessingInstruction -- copy constructor. */
59     protected TreeProcessingInstruction (TreeProcessingInstruction processingInstruction) {
60         super (processingInstruction);
61         
62         this.target = processingInstruction.target;
63     }
64     
65     
66     //
67
// from TreeObject
68
//
69

70     /**
71      */

72     public Object JavaDoc clone () {
73         return new TreeProcessingInstruction (this);
74     }
75     
76     /**
77      */

78     public boolean equals (Object JavaDoc 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     /*
91      * Merges target property.
92      */

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     //
103
// from TreeData
104
//
105

106     /**
107      */

108     protected final void checkData (String JavaDoc data) throws InvalidArgumentException {
109         TreeUtilities.checkProcessingInstructionData (data);
110     }
111     
112     /**
113      * @throws InvalidArgumentException
114      */

115     protected TreeData createData (String JavaDoc data) throws InvalidArgumentException {
116         return new TreeProcessingInstruction (this.target, data);
117     }
118     
119     //
120
// itself
121
//
122

123     /**
124      */

125     public final String JavaDoc getTarget () {
126         return target;
127     }
128     
129     /**
130      */

131     private final void setTargetImpl (String JavaDoc newTarget) {
132         String JavaDoc oldTarget = this.target;
133         
134         this.target = newTarget;
135         
136         firePropertyChange (PROP_TARGET, oldTarget, newTarget);
137     }
138     
139     
140     /**
141      * @throws ReadOnlyException
142      * @throws InvalidArgumentException
143      */

144     public final void setTarget (String JavaDoc newTarget) throws ReadOnlyException, InvalidArgumentException {
145         //
146
// check new value
147
//
148
if ( Util.equals (this.target, newTarget) )
149             return;
150         checkReadOnly ();
151         checkTarget (newTarget);
152         
153         //
154
// set new value
155
//
156
setTargetImpl (newTarget);
157     }
158     
159     
160     /**
161      */

162     public final void checkTarget (String JavaDoc target) throws InvalidArgumentException {
163         TreeUtilities.checkProcessingInstructionTarget (target);
164     }
165     
166 }
167
Popular Tags