KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.netbeans.modules.xml.axi.visitor.AXIVisitor;
22 import org.netbeans.modules.xml.schema.model.GlobalAttributeGroup;
23 import org.netbeans.modules.xml.schema.model.GlobalComplexType;
24 import org.netbeans.modules.xml.schema.model.GlobalGroup;
25 import org.netbeans.modules.xml.schema.model.SchemaComponent;
26
27 /**
28  * A content model represents various content models in XML Schema
29  * language, e.g. ComplexType, Group, AttributeGroup etc.
30  * These are few constructs for reusability and extension.
31  *
32  * @author Samaresh (Samaresh.Panda@Sun.Com)
33  */

34 public class ContentModel extends AXIContainer implements AXIType {
35     
36     /**
37      * Various types of content model.
38      */

39     public static enum ContentModelType {
40         COMPLEX_TYPE,
41         GROUP,
42         ATTRIBUTE_GROUP
43     }
44     
45     /**
46      * Creates a new instance of ContentModel
47      */

48     public ContentModel(AXIModel model, ContentModelType type) {
49         super(model);
50         this.type = type;
51     }
52     
53     /**
54      * Creates a new instance of ContentModel
55      */

56     public ContentModel(AXIModel model, SchemaComponent schemaComponent) {
57         super(model, schemaComponent);
58         if(schemaComponent instanceof GlobalGroup)
59             type = ContentModelType.GROUP;
60         if(schemaComponent instanceof GlobalAttributeGroup)
61             type = ContentModelType.ATTRIBUTE_GROUP;
62         if(schemaComponent instanceof GlobalComplexType)
63             type = ContentModelType.COMPLEX_TYPE;
64     }
65
66     /**
67      * Allows a visitor to visit this Element.
68      */

69     public void accept(AXIVisitor visitor) {
70         visitor.visit(this);
71     }
72     
73     /**
74      * Returns the type of this component.
75      * @see ComponentType.
76      */

77     public ComponentType getComponentType() {
78         return ComponentType.SHARED;
79     }
80     
81     /**
82      * Returns the type of this content model.
83      */

84     public ContentModelType getType() {
85         return type;
86     }
87     
88     public String JavaDoc toString() {
89         return getName();
90     }
91
92     private ContentModelType type;
93     public static final String JavaDoc PROP_CONTENT_MODEL = "contentModel";
94 }
95
Popular Tags