001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.xml.axi;
042:
043: import java.util.List;
044: import org.netbeans.modules.xml.axi.visitor.AXIVisitor;
045: import org.netbeans.modules.xml.schema.model.SchemaComponent;
046:
047: /**
048: * Abstract element.
049: *
050: * @author Samaresh (Samaresh.Panda@Sun.Com)
051: */
052: public abstract class AbstractElement extends AXIContainer {
053:
054: /**
055: * Creates a new instance of Element
056: */
057: public AbstractElement(AXIModel model) {
058: super (model);
059: }
060:
061: /**
062: * Creates a new instance of Element
063: */
064: public AbstractElement(AXIModel model,
065: SchemaComponent schemaComponent) {
066: super (model, schemaComponent);
067: }
068:
069: /**
070: * Creates a proxy for this Element.
071: */
072: public AbstractElement(AXIModel model, AXIComponent sharedComponent) {
073: super (model, sharedComponent);
074: }
075:
076: /**
077: * Allows a visitor to visit this Element.
078: */
079: public abstract void accept(AXIVisitor visitor);
080:
081: /**
082: * Returns the MinOccurs.
083: */
084: public String getMinOccurs() {
085: return minOccurs;
086: }
087:
088: /**
089: * Sets the MinOccurs.
090: */
091: public void setMinOccurs(String value) {
092: String oldValue = getMinOccurs();
093: if ((oldValue == null && value == null)
094: || (oldValue != null && oldValue.equals(value))) {
095: return;
096: }
097: this .minOccurs = value;
098: firePropertyChangeEvent(PROP_MINOCCURS, oldValue, value);
099: }
100:
101: /**
102: * Returns the MaxOccurs.
103: */
104: public String getMaxOccurs() {
105: return maxOccurs;
106: }
107:
108: /**
109: * Sets the MaxOccurs.
110: */
111: public void setMaxOccurs(String value) {
112: String oldValue = getMaxOccurs();
113: if ((oldValue == null && value == null)
114: || (oldValue != null && oldValue.equals(value))) {
115: return;
116: }
117: this .maxOccurs = value;
118: firePropertyChangeEvent(PROP_MAXOCCURS, oldValue, value);
119: }
120:
121: /**
122: * true if #getMaxOccurs() and #getMinOccurs() allow multiciplity outside
123: * [0,1], false otherwise. This method is only accurate after the element
124: * has been inserted into the model.
125: */
126: public boolean allowsFullMultiplicity() {
127: return !(getParent() instanceof Compositor && ((Compositor) getParent())
128: .getType() == Compositor.CompositorType.ALL);
129: }
130:
131: protected String minOccurs = "1";
132: protected String maxOccurs = "1";
133:
134: public static final String PROP_MINOCCURS = "minOccurs"; // NOI18N
135: public static final String PROP_MAXOCCURS = "maxOccurs"; // NOI18N
136: public static final String PROP_ELEMENT = "element"; // NOI18N
137: }
|