KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
21  * This implements interface List, represents the xs:list element, which is a whitespace
22  * separated list of values.
23  *
24  * @author Nam Nguyen
25  */

26
27 package org.netbeans.modules.xml.schema.model.impl;
28
29 import java.util.Collection JavaDoc;
30 import java.util.Collections JavaDoc;
31 import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
32 import org.netbeans.modules.xml.schema.model.List;
33 import org.netbeans.modules.xml.schema.model.LocalSimpleType;
34 import org.netbeans.modules.xml.schema.model.SchemaComponent;
35 import org.netbeans.modules.xml.schema.model.visitor.SchemaVisitor;
36 import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
37 import org.w3c.dom.Element JavaDoc;
38
39 public class ListImpl extends SchemaComponentImpl implements List {
40     
41     public ListImpl(SchemaModelImpl model) {
42         this(model, createNewComponent(SchemaElements.LIST,model));
43     }
44     
45     /** Creates a new instance of ListImpl */
46     public ListImpl(SchemaModelImpl model, Element JavaDoc e) {
47         super(model, e);
48     }
49
50     /**
51      *
52      *
53      */

54     public Class JavaDoc<? extends SchemaComponent> getComponentType() {
55         return List.class;
56     }
57     
58     public void accept(SchemaVisitor visitor) {
59         visitor.visit(this);
60     }
61     
62     public NamedComponentReference<GlobalSimpleType> getType() {
63         return resolveGlobalReference(GlobalSimpleType.class, SchemaAttributes.ITEM_TYPE);
64     }
65     
66     public void setType(NamedComponentReference<GlobalSimpleType> type) {
67         setAttribute(TYPE_PROPERTY, SchemaAttributes.ITEM_TYPE, type );
68     }
69     
70     public LocalSimpleType getInlineType() {
71         Collection JavaDoc<LocalSimpleType> types = getChildren(LocalSimpleType.class);
72         if (types.size() > 1 || types.size() < 0) {
73             throw new IllegalArgumentException JavaDoc("'" + SchemaElements.LIST + "' can only local simpleType child");
74         }
75         LocalSimpleType[] typesA = types.toArray(new LocalSimpleType[1]);
76         if (typesA.length == 0) {
77             return null;
78         } else {
79             return typesA[0];
80         }
81     }
82     
83     public void setInlineType(LocalSimpleType st) {
84         java.util.List JavaDoc<Class JavaDoc<? extends SchemaComponent>> classes = Collections.emptyList();
85         setChild(LocalSimpleType.class, INLINE_TYPE_PROPERTY, st, classes);
86     }
87 }
Popular Tags