KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > axi > AbstractElement


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.axi;
20
21 import java.util.List JavaDoc;
22 import org.netbeans.modules.xml.axi.visitor.AXIVisitor;
23 import org.netbeans.modules.xml.schema.model.SchemaComponent;
24
25 /**
26  * Abstract element.
27  *
28  * @author Samaresh (Samaresh.Panda@Sun.Com)
29  */

30 public abstract class AbstractElement extends AXIContainer {
31     
32     /**
33      * Creates a new instance of Element
34      */

35     public AbstractElement(AXIModel model) {
36         super(model);
37     }
38     
39     /**
40      * Creates a new instance of Element
41      */

42     public AbstractElement(AXIModel model, SchemaComponent schemaComponent) {
43         super(model, schemaComponent);
44     }
45     
46     /**
47      * Creates a proxy for this Element.
48      */

49     public AbstractElement(AXIModel model, AXIComponent sharedComponent) {
50         super(model, sharedComponent);
51     }
52     
53     /**
54      * Allows a visitor to visit this Element.
55      */

56     public abstract void accept(AXIVisitor visitor);
57             
58     /**
59      * Returns the MinOccurs.
60      */

61     public String JavaDoc getMinOccurs() {
62         return minOccurs;
63     }
64     
65     /**
66      * Sets the MinOccurs.
67      */

68     public void setMinOccurs(String JavaDoc value) {
69         String JavaDoc oldValue = getMinOccurs();
70         if( (oldValue == null && value == null) ||
71             (oldValue != null && oldValue.equals(value)) ) {
72             return;
73         }
74         this.minOccurs = value;
75         firePropertyChangeEvent(PROP_MINOCCURS, oldValue, value);
76     }
77     
78     /**
79      * Returns the MaxOccurs.
80      */

81     public String JavaDoc getMaxOccurs() {
82         return maxOccurs;
83     }
84     
85     /**
86      * Sets the MaxOccurs.
87      */

88     public void setMaxOccurs(String JavaDoc value) {
89         String JavaDoc oldValue = getMaxOccurs();
90         if( (oldValue == null && value == null) ||
91             (oldValue != null && oldValue.equals(value)) ) {
92             return;
93         }
94         this.maxOccurs = value;
95         firePropertyChangeEvent(PROP_MAXOCCURS, oldValue, value);
96     }
97     
98     /**
99      * true if #getMaxOccurs() and #getMinOccurs() allow multiciplity outside
100      * [0,1], false otherwise. This method is only accurate after the element
101      * has been inserted into the model.
102      */

103     public boolean allowsFullMultiplicity() {
104         return !(getParent() instanceof Compositor &&
105                 ((Compositor)getParent()).getType() == Compositor.CompositorType.ALL);
106     }
107     
108     protected String JavaDoc minOccurs = "1";
109     protected String JavaDoc maxOccurs = "1";
110     
111     public static final String JavaDoc PROP_MINOCCURS = "minOccurs"; // NOI18N
112
public static final String JavaDoc PROP_MAXOCCURS = "maxOccurs"; // NOI18N
113
public static final String JavaDoc PROP_ELEMENT = "element"; // NOI18N
114
}
115
Popular Tags