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 org.netbeans.modules.xml.axi.datatype.Datatype;
044: import org.netbeans.modules.xml.axi.datatype.StringType;
045: import org.netbeans.modules.xml.axi.impl.DatatypeBuilder;
046: import org.netbeans.modules.xml.axi.visitor.AXIVisitor;
047: import org.netbeans.modules.xml.schema.model.Form;
048: import org.netbeans.modules.xml.schema.model.SchemaComponent;
049: import org.netbeans.modules.xml.schema.model.Attribute.Use;
050:
051: /**
052: * Represents an attribute in XML Schema.
053: *
054: * @author Samaresh (Samaresh.Panda@Sun.Com)
055: */
056: public abstract class Attribute extends AbstractAttribute implements
057: AXIType {
058:
059: /**
060: * Creates a new instance of Attribute
061: */
062: public Attribute(AXIModel model) {
063: super (model);
064: }
065:
066: /**
067: * Creates a new instance of Attribute
068: */
069: public Attribute(AXIModel model, SchemaComponent schemaComponent) {
070: super (model, schemaComponent);
071: }
072:
073: /**
074: * Creates a proxy for this Attribute.
075: */
076: public Attribute(AXIModel model, AXIComponent sharedComponent) {
077: super (model, sharedComponent);
078: }
079:
080: /**
081: * Allows a visitor to visit this Attribute.
082: */
083: public void accept(AXIVisitor visitor) {
084: visitor.visit(this );
085: }
086:
087: /**
088: * Returns true if it is a reference, false otherwise.
089: */
090: public abstract boolean isReference();
091:
092: /**
093: * Returns the referent if isReference() is true.
094: */
095: public abstract Attribute getReferent();
096:
097: /**
098: * Sets the name.
099: */
100: public abstract void setName(String name);
101:
102: /**
103: * Returns the type. This is expensive, since it uses a visitor
104: * to traverse to obtain the type information.
105: */
106: public abstract AXIType getType();
107:
108: /**
109: * Sets the type.
110: */
111: public abstract void setType(AXIType type);
112:
113: /**
114: * Returns the form.
115: */
116: public abstract Form getForm();
117:
118: /**
119: * Sets the form.
120: */
121: public abstract void setForm(Form form);
122:
123: /**
124: * Returns the fixed value.
125: */
126: public abstract String getFixed();
127:
128: /**
129: * Sets the fixed value.
130: */
131: public abstract void setFixed(String value);
132:
133: /**
134: * Returns the default value.
135: */
136: public abstract String getDefault();
137:
138: /**
139: * Sets the default value.
140: */
141: public abstract void setDefault(String value);
142:
143: /**
144: * Returns the use.
145: */
146: public abstract Use getUse();
147:
148: /**
149: * Sets the use.
150: */
151: public abstract void setUse(Use use);
152:
153: /**
154: * Returns the string representation of this Attribute.
155: */
156: public String toString() {
157: return getName(); //NOI18N
158: }
159:
160: ////////////////////////////////////////////////////////////////////
161: ////////////////////////// member variables ////////////////////////
162: ////////////////////////////////////////////////////////////////////
163: protected String name;
164: protected Form form;
165: protected Use use;
166: protected String defaultValue;
167: protected String fixedValue;
168: protected AXIType datatype;
169:
170: ////////////////////////////////////////////////////////////////////
171: ////////////////// Properties for firing events ////////////////////
172: ////////////////////////////////////////////////////////////////////
173: public static final String PROP_NAME = "name"; //NOI18N
174: public static final String PROP_FORM = "form"; //NOI18N
175: public static final String PROP_USE = "use"; //NOI18N
176: public static final String PROP_DEFAULT = "default"; //NOI18N
177: public static final String PROP_FIXED = "fixed"; //NOI18N
178: public static final String PROP_TYPE = "type"; //NOI18N
179: public static final String PROP_ATTRIBUTE_REF = "attributeRef"; // NOI18N
180: }
|