1 19 20 26 27 package org.netbeans.modules.xml.schema.model.impl; 28 29 import java.util.Collection ; 30 import java.util.Collections ; 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 ; 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 46 public ListImpl(SchemaModelImpl model, Element e) { 47 super(model, e); 48 } 49 50 54 public Class <? 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 <LocalSimpleType> types = getChildren(LocalSimpleType.class); 72 if (types.size() > 1 || types.size() < 0) { 73 throw new IllegalArgumentException ("'" + 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 <Class <? extends SchemaComponent>> classes = Collections.emptyList(); 85 setChild(LocalSimpleType.class, INLINE_TYPE_PROPERTY, st, classes); 86 } 87 } | Popular Tags |