1 17 package org.apache.ws.jaxme.xs.xml.impl; 18 19 import org.apache.ws.jaxme.xs.parser.impl.LocSAXException; 20 import org.apache.ws.jaxme.xs.xml.*; 21 import org.xml.sax.SAXException ; 22 23 24 64 public abstract class XsTElementImpl extends XsTAnnotatedImpl implements XsTElement { 65 private XsTLocalSimpleType simpleType; 66 private XsTLocalComplexType complexType; 67 private XsQName type; 68 private XsQName substitutionGroup; 69 private String defaultValue; 70 private String fixedValue; 71 private boolean isNillable; 72 private boolean isAbstract; 73 private XsDerivationSet finalSet; 74 private XsBlockSet blockSet; 75 private XsFormChoice formChoice; 76 private final XsAGDefRef defRef; 77 private final XsAGOccurs occurs; 78 private XsGIdentityConstraint constraint; 79 80 protected XsTElementImpl(XsObject pParent) { 81 super(pParent); 82 defRef = getObjectFactory().newXsAGDefRef(this); 83 occurs = getObjectFactory().newXsAGOccurs(this); 84 constraint = getObjectFactory().newXsGIdentityConstraint(this); 85 } 86 87 public XsTLocalSimpleType createSimpleType() throws SAXException { 88 if (simpleType != null) { 89 throw new LocSAXException("Multiple 'simpleType' childs are forbidden.", getLocator()); 90 } 91 if (complexType != null) { 92 throw new LocSAXException("The 'simpleType' and 'complexType' childs are mutually exclusive.", getLocator()); 93 } 94 if (type != null) { 95 throw new LocSAXException("The 'simpleType' child and the 'type' attribute are mutually exclusive.", getLocator()); 96 } 97 return simpleType = getObjectFactory().newXsTLocalSimpleType(this); 98 } 99 100 public XsTLocalSimpleType getSimpleType() { 101 return simpleType; 102 } 103 104 public XsTLocalComplexType createComplexType() throws SAXException { 105 if (complexType != null) { 106 throw new LocSAXException("Multiple 'complexType' childs are forbidden.", getLocator()); 107 } 108 if (simpleType != null) { 109 throw new LocSAXException("The 'simpleType' and 'complexType' childs are mutually exclusive.", getLocator()); 110 } 111 if (type != null) { 112 throw new LocSAXException("The 'complexType' child and the 'type' attribute are mutually exclusive.", getLocator()); 113 } 114 return complexType = getObjectFactory().newXsTLocalComplexType(this); 115 } 116 117 public XsTLocalComplexType getComplexType() { 118 return complexType; 119 } 120 121 public void setType(XsQName pType) throws SAXException { 122 if (simpleType != null) { 123 throw new LocSAXException("The 'simpleType' child element and the 'type' attribute are mutually exclusive.", getLocator()); 124 } 125 if (complexType != null) { 126 throw new LocSAXException("The 'complexType' child element and the 'type' attribute are mutually exclusive.", getLocator()); 127 } 128 type = pType; 129 } 130 131 public void setType(String pType) throws SAXException { 132 setType(asXsQName(pType)); 133 } 134 135 public XsQName getType() { 136 return type; 137 } 138 139 public void setSubstitutionGroup(XsQName pSubstitutionGroup) throws SAXException { 140 substitutionGroup = pSubstitutionGroup; 141 } 142 143 public void setSubstitutionGroup(String pSubstitutionGroup) throws SAXException { 144 setSubstitutionGroup(asXsQName(pSubstitutionGroup)); 145 } 146 147 public XsQName getSubstitutionGroup() { 148 return substitutionGroup; 149 } 150 151 public void setDefault(String pDefault) { 152 defaultValue = pDefault; 153 } 154 155 public String getDefault() { 156 return defaultValue; 157 } 158 159 public void setFixed(String pFixed) { 160 fixedValue = pFixed; 161 } 162 163 public String getFixed() { 164 return fixedValue; 165 } 166 167 public void setNillable(boolean pNillable) { 168 isNillable = pNillable; 169 } 170 171 public boolean getNillable() { 172 return isNillable; 173 } 174 175 public void setAbstract(boolean pAbstract) { 176 isAbstract = pAbstract; 177 } 178 179 public boolean getAbstract() { 180 return isAbstract; 181 } 182 183 public void setFinal(XsDerivationSet pFinal) { 184 finalSet = pFinal; 185 } 186 187 public XsDerivationSet getFinal() { 188 return finalSet; 189 } 190 191 public void setBlock(XsBlockSet pBlock) { 192 blockSet = pBlock; 193 } 194 195 public XsBlockSet getBlock() { 196 return blockSet; 197 } 198 199 public void setForm(XsFormChoice pForm) { 200 formChoice = pForm; 201 } 202 203 public XsFormChoice getForm() { 204 return formChoice; 205 } 206 207 public void validate() throws SAXException { 208 super.validate(); 209 if (type == null && simpleType == null && complexType == null && getRef() == null) { 210 setType(org.apache.ws.jaxme.xs.types.XSAnyType.getInstance().getName()); 211 } 212 defRef.validate(); 213 occurs.validate(); 214 } 215 216 public void setName(XsNCName pName) { 217 defRef.setName(pName); 218 } 219 220 public XsNCName getName() { 221 return defRef.getName(); 222 } 223 224 public void setRef(XsQName pRef) { 225 defRef.setRef(pRef); 226 } 227 228 public void setRef(String pRef) throws SAXException { 229 setRef(asXsQName(pRef)); 230 } 231 232 public XsQName getRef() { 233 return defRef.getRef(); 234 } 235 236 public void setMaxOccurs(String pMaxOccurs) { 237 occurs.setMaxOccurs(pMaxOccurs); 238 } 239 240 public int getMaxOccurs() { 241 return occurs.getMaxOccurs(); 242 } 243 244 public void setMinOccurs(int pMinOccurs) { 245 occurs.setMinOccurs(pMinOccurs); 246 } 247 248 public int getMinOccurs() { 249 return occurs.getMinOccurs(); 250 } 251 252 public XsEUnique createUnique() { 253 return constraint.createUnique(); 254 } 255 256 public XsEKey createKey() { 257 return constraint.createKey(); 258 } 259 260 public XsEKeyref createKeyref() { 261 return constraint.createKeyref(); 262 } 263 264 public XsTIdentityConstraint[] getIdentityConstraints() { 265 return constraint.getIdentityConstraints(); 266 } 267 } 268 | Popular Tags |