KickJava   Java API By Example, From Geeks To Geeks.

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


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.DTD;
22 import org.netbeans.tax.spec.ParameterEntityReference;
23 import org.netbeans.tax.spec.ConditionalSection;
24
25 /**
26  *
27  * @author Libor Kramolis
28  * @version 0.1
29  */

30 public class TreeConditionalSection extends AbstractTreeDTD implements DTD.Child, ParameterEntityReference.Child, ConditionalSection.Child {
31
32     /** */
33     public static final String JavaDoc PROP_INCLUDE = "include"; // NOI18N
34
/** */
35     public static final String JavaDoc PROP_IGNORED_CONTENT = "ignoredContent"; // NOI18N
36

37     /** */
38     public static final boolean IGNORE = false;
39     
40     /** */
41     public static final boolean INCLUDE = true;
42     
43     
44     /** */
45     private boolean include;
46     
47     /** -- can be null. */
48     private String JavaDoc ignoredContent; //or null
49

50     
51     //
52
// init
53
//
54

55     /** Creates new TreeConditionalSection. */
56     public TreeConditionalSection (boolean include) {
57         super ();
58         
59         this.include = include;
60         this.ignoredContent = new String JavaDoc ();
61     }
62     
63     /** Creates new TreeConditionalSection -- copy constructor. */
64     protected TreeConditionalSection (TreeConditionalSection conditionalSection, boolean deep) {
65         super (conditionalSection, deep);
66         
67         this.include = conditionalSection.include;
68         this.ignoredContent = conditionalSection.ignoredContent;
69     }
70     
71     
72     //
73
// from TreeObject
74
//
75

76     /**
77      */

78     public Object JavaDoc clone (boolean deep) {
79         return new TreeConditionalSection (this, deep);
80     }
81     
82     /**
83      */

84     public boolean equals (Object JavaDoc object, boolean deep) {
85         if (!!! super.equals (object, deep))
86             return false;
87         
88         TreeConditionalSection peer = (TreeConditionalSection) object;
89         if (this.include != peer.include)
90             return false;
91         if (!!! Util.equals (this.getIgnoredContent (), peer.getIgnoredContent ()))
92             return false;
93         
94         return true;
95     }
96     
97     /*
98      * Merges following properties: ignored, ignoredContent.
99      */

100     public void merge (TreeObject treeObject) throws CannotMergeException {
101         super.merge (treeObject);
102         
103         TreeConditionalSection peer = (TreeConditionalSection) treeObject;
104         
105         setIncludeImpl (peer.isInclude ());
106         setIgnoredContentImpl (peer.getIgnoredContent ());
107     }
108     
109     
110     //
111
// itself
112
//
113

114     /**
115      */

116     public final boolean isInclude () {
117         return include;
118     }
119     
120     /**
121      */

122     private final void setIncludeImpl (boolean newInclude) {
123         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("\nTreeConditionalSection::setIncludeImpl: oldInclude = " + this.include); // NOI18N
124
if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (" ::setIncludeImpl: newInclude = " + newInclude); // NOI18N
125

126         boolean oldInclude = this.include;
127         
128         this.include = newInclude;
129         
130         firePropertyChange (PROP_INCLUDE, oldInclude ? Boolean.TRUE : Boolean.FALSE, newInclude ? Boolean.TRUE : Boolean.FALSE);
131     }
132     
133     /**
134      * @throws ReadOnlyException
135      * @throws InvalidArgumentException
136      */

137     public final void setInclude (boolean newInclude) throws ReadOnlyException, InvalidArgumentException {
138         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("\nTreeConditionalSection::setInclude: oldInclude = " + this.include); // NOI18N
139
if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (" ::setInclude: newInclude = " + newInclude); // NOI18N
140

141         //
142
// check new value
143
//
144
if ( this.include == newInclude )
145             return;
146         checkReadOnly ();
147         // checkInclude (newInclude);
148

149         //
150
// set new value
151
//
152
setIncludeImpl (newInclude);
153     }
154     
155     
156     /**
157      */

158     public final String JavaDoc getIgnoredContent () {
159         return ignoredContent;
160     }
161     
162     /**
163      */

164     private void setIgnoredContentImpl (String JavaDoc newContent) {
165         String JavaDoc oldContent = this.ignoredContent;
166         
167         this.ignoredContent = newContent;
168         
169         firePropertyChange (PROP_IGNORED_CONTENT, oldContent, newContent);
170     }
171     
172     /**
173      * @throws ReadOnlyException
174      * @throws InvalidArgumentException
175      */

176     public final void setIgnoredContent (String JavaDoc newIgnoredContent) throws ReadOnlyException, InvalidArgumentException {
177         //
178
// check new value
179
//
180
if ( Util.equals (this.ignoredContent, newIgnoredContent) )
181             return;
182         checkReadOnly ();
183         // checkIgnoredContent (newIgnoredContent);
184

185         //
186
// set new value
187
//
188
setIgnoredContentImpl (newIgnoredContent);
189     }
190     
191     
192     //
193
// TreeObjectList.ContentManager
194
//
195

196     /**
197      */

198     protected TreeObjectList.ContentManager createChildListContentManager () {
199         return new ChildListContentManager ();
200     }
201     
202     
203     /**
204      *
205      */

206     protected class ChildListContentManager extends AbstractTreeDTD.ChildListContentManager {
207         
208         /**
209          */

210         public TreeNode getOwnerNode () {
211             return TreeConditionalSection.this;
212         }
213         
214         /**
215          */

216         public void checkAssignableObject (Object JavaDoc obj) {
217             super.checkAssignableObject (obj);
218             checkAssignableClass (ConditionalSection.Child.class, obj);
219         }
220         
221     } // end: class ChildListContentManager
222

223 }
224
Popular Tags