1 19 20 package org.netbeans.modules.xml.schema.model.impl; 21 22 import org.netbeans.modules.xml.schema.model.Form; 23 import org.netbeans.modules.xml.schema.model.GlobalElement; 24 import org.netbeans.modules.xml.schema.model.LocalElement; 25 import org.netbeans.modules.xml.schema.model.SchemaComponent; 26 import org.netbeans.modules.xml.schema.model.visitor.SchemaVisitor; 27 import org.netbeans.modules.xml.xam.dom.NamedComponentReference; 28 import org.w3c.dom.Element ; 29 30 34 public abstract class LocalElementBaseImpl extends ElementImpl { 35 36 public LocalElementBaseImpl(SchemaModelImpl model) { 37 this(model,createNewComponent(SchemaElements.ELEMENT,model)); 38 } 39 40 43 public LocalElementBaseImpl(SchemaModelImpl model, Element el) { 44 super(model, el); 45 } 46 47 50 public void setForm(Form f) { 51 setAttribute(LocalElement.FORM_PROPERTY, SchemaAttributes.FORM, f); 52 } 53 54 57 public void setRef(NamedComponentReference<GlobalElement> ref) { 58 setAttribute(LocalElement.REF_PROPERTY, SchemaAttributes.REF, ref); 59 } 60 61 64 public void setMinOccurs(Integer min) { 65 setAttribute(LocalElement.MIN_OCCURS_PROPERTY, SchemaAttributes.MIN_OCCURS, min); 66 } 67 68 71 public void setMaxOccurs(String max) { 72 setAttribute(LocalElement.MAX_OCCURS_PROPERTY, SchemaAttributes.MAX_OCCURS, max); 73 } 74 75 78 public NamedComponentReference<GlobalElement> getRef() { 79 return resolveGlobalReference(GlobalElement.class, SchemaAttributes.REF); 80 } 81 82 85 public Integer getMinOccurs() { 86 String s = getAttribute(SchemaAttributes.MIN_OCCURS); 87 return s == null ? null : Integer.valueOf(s); 88 } 89 90 93 public String getMaxOccurs() { 94 return getAttribute(SchemaAttributes.MAX_OCCURS); 95 } 96 97 100 public Form getForm() { 101 String s = super.getAttribute(SchemaAttributes.FORM); 102 return s == null ? null : Util.parse(Form.class, s); 103 } 104 105 public int getMinOccursEffective() { 106 Integer v = getMinOccurs(); 107 return v == null ? getMinOccursDefault() : v; 108 } 109 110 public int getMinOccursDefault() { 111 return 1; 112 } 113 114 public String getMaxOccursEffective() { 115 String v = getMaxOccurs(); 116 return v == null ? getMaxOccursDefault() : v; 117 } 118 119 public String getMaxOccursDefault() { 120 return String.valueOf(1); 121 } 122 123 public Form getFormEffective() { 124 Form v = getForm(); 125 return v == null ? getFormDefault() : v; 126 } 127 128 public Form getFormDefault() { 129 return getModel().getSchema().getElementFormDefaultEffective(); 130 } 131 } 132 | Popular Tags |