KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > model > impl > SchemaAttributes


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
20 package org.netbeans.modules.xml.schema.model.impl;
21 import java.util.Arrays JavaDoc;
22 import java.util.HashMap JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.Map JavaDoc;
25 import java.util.Set JavaDoc;
26 import javax.swing.text.Element JavaDoc;
27 import javax.xml.namespace.QName JavaDoc;
28 import org.netbeans.modules.xml.schema.model.Any.ProcessContents;
29 import org.netbeans.modules.xml.schema.model.Derivation;
30 import org.netbeans.modules.xml.schema.model.Form;
31 import org.netbeans.modules.xml.schema.model.LocalAttribute;
32 import org.netbeans.modules.xml.schema.model.Schema;
33 import org.netbeans.modules.xml.xam.dom.Attribute;
34
35 /**
36  * An enumeration representing the schema attribute names.
37  * @author Samaresh Panda (Samaresh.Panda@Sun.Com)
38  * @author Chris Webster
39  */

40 public enum SchemaAttributes implements Attribute {
41     ABSTRACT("abstract", Boolean JavaDoc.class),
42     ATTR_FORM_DEFAULT("attributeFormDefault", Form.class),
43     BASE("base", String JavaDoc.class),
44     BLOCK("block", Set JavaDoc.class, Derivation.Type.class),
45     BLOCK_DEFAULT("blockDefault", Set JavaDoc.class, Schema.Block.class),
46     DEFAULT("default", String JavaDoc.class),
47     ELEM_FORM_DEFAULT("elementFormDefault", Form.class),
48     ID("id", String JavaDoc.class),
49     ITEM_TYPE("itemType", String JavaDoc.class),
50     FINAL("final", Set JavaDoc.class, Derivation.Type.class),
51     FINAL_DEFAULT("finalDefault", Set JavaDoc.class, Schema.Final.class),
52     FIXED("fixed", Boolean JavaDoc.class),
53     FORM("form", Form.class),
54     LANGUAGE("xml:lang", String JavaDoc.class),
55     MAX_OCCURS("maxOccurs", String JavaDoc.class),
56     MEMBER_TYPES("memberTypes", String JavaDoc.class),
57     MIN_OCCURS("minOccurs", Integer JavaDoc.class),
58     MIXED("mixed", Boolean JavaDoc.class),
59     NAME("name", String JavaDoc.class),
60     NAMESPACE("namespace", String JavaDoc.class),
61     NILLABLE("nillable", Boolean JavaDoc.class),
62     PROCESS_CONTENTS("processContents", ProcessContents.class),
63     PUBLIC("public", String JavaDoc.class),
64     REF("ref", String JavaDoc.class),
65     REFER("refer", String JavaDoc.class),
66     SCHEMA_LOCATION("schemaLocation", String JavaDoc.class),
67     SOURCE("source", String JavaDoc.class),
68     SUBSTITUTION_GROUP("substitutionGroup", String JavaDoc.class),
69     SYSTEM("system", String JavaDoc.class),
70     TARGET_NS("targetNamespace", String JavaDoc.class),
71     TYPE("type", String JavaDoc.class),
72     USE("use", LocalAttribute.Use.class),
73     VALUE("value", String JavaDoc.class),
74     VERSION("version", String JavaDoc.class),
75     XPATH("xpath", String JavaDoc.class);
76
77     SchemaAttributes(String JavaDoc docName, Class JavaDoc type, Class JavaDoc memberType) {
78         this.docName = docName;
79         this.type = type;
80         this.memberType = memberType;
81     }
82     
83     SchemaAttributes(String JavaDoc docName, Class JavaDoc type) {
84         this(docName, type, null);
85     }
86     
87     public String JavaDoc getName() {
88         return docName;
89     }
90     
91     public Class JavaDoc getType() {
92         return type;
93     }
94     
95     public Class JavaDoc getMemberType() {
96         return memberType;
97     }
98     
99     public static Map JavaDoc<QName JavaDoc,List JavaDoc<QName JavaDoc>> getQNameValuedAttributes() {
100         return qnameValuedAttributes;
101     }
102     
103     private QName JavaDoc qname() {
104         return new QName JavaDoc(docName);
105     }
106     
107     private final String JavaDoc docName;
108     private final Class JavaDoc type;
109     private final Class JavaDoc memberType;
110
111     
112     private static Map JavaDoc<QName JavaDoc,List JavaDoc<QName JavaDoc>> qnameValuedAttributes = new HashMap JavaDoc<QName JavaDoc,List JavaDoc<QName JavaDoc>>();
113     static {
114         qnameValuedAttributes.put(
115                 SchemaElements.UNION.getQName(), Arrays.asList(new QName JavaDoc[] { MEMBER_TYPES.qname()}));
116         qnameValuedAttributes.put(
117                 SchemaElements.RESTRICTION.getQName(), Arrays.asList(new QName JavaDoc[] { BASE.qname()}));
118         qnameValuedAttributes.put(
119                 SchemaElements.EXTENSION.getQName(), Arrays.asList(new QName JavaDoc[] { BASE.qname()}));
120         qnameValuedAttributes.put(
121                 SchemaElements.LIST.getQName(), Arrays.asList(new QName JavaDoc[] { ITEM_TYPE.qname()}));
122         qnameValuedAttributes.put(
123                 SchemaElements.ATTRIBUTE.getQName(), Arrays.asList(new QName JavaDoc[] { REF.qname(), TYPE.qname()}));
124         qnameValuedAttributes.put(
125                 SchemaElements.ELEMENT.getQName(), Arrays.asList(new QName JavaDoc[] { REF.qname(), SUBSTITUTION_GROUP.qname(), TYPE.qname() }));
126         qnameValuedAttributes.put(
127                 SchemaElements.GROUP.getQName(), Arrays.asList(new QName JavaDoc[] { REF.qname()}));
128         qnameValuedAttributes.put(
129                 SchemaElements.ATTRIBUTE_GROUP.getQName(), Arrays.asList(new QName JavaDoc[] { REF.qname()}));
130     }
131
132 }
133
Popular Tags