1 28 29 package org.jibx.binding.model; 30 31 import org.jibx.binding.util.StringArray; 32 33 41 42 public abstract class StructureElementBase 43 extends ContainerElementBase implements IComponent 44 { 45 46 public static final StringArray s_allowedAttributes = 47 new StringArray(new StringArray(PropertyAttributes.s_allowedAttributes, 48 NameAttributes.s_allowedAttributes), 49 ContainerElementBase.s_allowedAttributes); 50 51 52 private boolean m_isOrdered; 53 54 55 private PropertyAttributes m_propertyAttrs; 56 57 58 private NameAttributes m_nameAttrs; 59 60 61 private String m_label; 62 63 64 private String m_using; 65 66 71 protected StructureElementBase(int type) { 72 super(type); 73 m_nameAttrs = new NameAttributes(); 74 m_propertyAttrs = new PropertyAttributes(); 75 m_isOrdered = true; 76 } 77 78 84 public void setOrdered(boolean ordered) { 85 m_isOrdered = ordered; 86 } 87 88 93 public boolean isOrdered() { 94 return m_isOrdered; 95 } 96 97 102 public String getLabel() { 103 return m_label; 104 } 105 106 111 public void setLabel(String label) { 112 m_label = label; 113 } 114 115 120 public String getUsing() { 121 return m_using; 122 } 123 124 129 public void setUsing(String label) { 130 m_using = label; 131 } 132 133 136 141 public String getName() { 142 return m_nameAttrs.getName(); 143 } 144 145 150 public void setName(String name) { 151 m_nameAttrs.setName(name); 152 } 153 154 159 public String getUri() { 160 return m_nameAttrs.getUri(); 161 } 162 163 168 public void setUri(String uri) { 169 m_nameAttrs.setUri(uri); 170 } 171 172 177 public String getPrefix() { 178 return m_nameAttrs.getPrefix(); 179 } 180 181 186 public void setPrefix(String prefix) { 187 m_nameAttrs.setPrefix(prefix); 188 } 189 190 196 public NamespaceElement getNamespace() { 197 return m_nameAttrs.getNamespace(); 198 } 199 200 203 208 public String getUsageName() { 209 return m_propertyAttrs.getUsageName(); 210 } 211 212 217 public int getUsage() { 218 return m_propertyAttrs.getUsage(); 219 } 220 221 226 public void setUsageName(String name) { 227 m_propertyAttrs.setUsageName(name); 228 } 229 230 235 public String getDeclaredType() { 236 return m_propertyAttrs.getDeclaredType(); 237 } 238 239 244 public void setDeclaredType(String type) { 245 m_propertyAttrs.setDeclaredType(type); 246 } 247 248 253 public String getFieldName() { 254 return m_propertyAttrs.getFieldName(); 255 } 256 257 262 public IClassItem getField() { 263 return m_propertyAttrs.getField(); 264 } 265 266 271 public void setFieldName(String field) { 272 m_propertyAttrs.setFieldName(field); 273 } 274 275 280 public String getTestName() { 281 return m_propertyAttrs.getTestName(); 282 } 283 284 290 public IClassItem getTest() { 291 return m_propertyAttrs.getTest(); 292 } 293 294 299 public void setTestName(String test) { 300 m_propertyAttrs.setTestName(test); 301 } 302 303 308 public String getGetName() { 309 return m_propertyAttrs.getGetName(); 310 } 311 312 318 public IClassItem getGet() { 319 return m_propertyAttrs.getGet(); 320 } 321 322 328 public IClass getGetType() { 329 return m_propertyAttrs.getGetType(); 330 } 331 332 337 public void setGetName(String get) { 338 m_propertyAttrs.setGetName(get); 339 } 340 341 346 public String getSetName() { 347 return m_propertyAttrs.getSetName(); 348 } 349 350 356 public IClassItem getSet() { 357 return m_propertyAttrs.getSet(); 358 } 359 360 366 public IClass getSetType() { 367 return m_propertyAttrs.getSetType(); 368 } 369 370 375 public void setSetName(String set) { 376 m_propertyAttrs.setSetName(set); 377 } 378 379 386 public boolean isImplicit() { 387 return m_propertyAttrs.isImplicit(); 388 } 389 390 393 396 public boolean isOptional() { 397 return m_propertyAttrs.getUsage() == PropertyAttributes.OPTIONAL_USAGE; 398 } 399 400 403 406 public boolean hasAttribute() { 407 if (m_nameAttrs.getName() != null) { 408 return false; 409 } else { 410 return getAttributeComponents().size() > 0; 411 } 412 } 413 414 417 public boolean hasContent() { 418 if (m_nameAttrs.getName() != null) { 419 return true; 420 } else { 421 return getContentComponents().size() > 0; 422 } 423 } 424 425 428 public boolean hasName() { 429 return m_nameAttrs.getName() != null; 430 } 431 432 435 public boolean hasType() { 436 return m_propertyAttrs.getType() != null; 437 } 438 439 442 public IClass getType() { 443 return m_propertyAttrs.getType(); 444 } 445 446 449 452 public void prevalidate(ValidationContext vctx) { 453 if (m_using != null && children().size() > 0) { 454 vctx.addFatal("Child elements not allowed with using attribute"); 455 } 456 m_nameAttrs.prevalidate(vctx); 457 m_propertyAttrs.prevalidate(vctx); 458 if (!vctx.isSkipped(this)) { 459 super.prevalidate(vctx); 460 } 461 } 462 463 466 public void validate(ValidationContext vctx) { 467 m_nameAttrs.validate(vctx); 468 m_propertyAttrs.validate(vctx); 469 if (!vctx.isSkipped(this)) { 470 super.validate(vctx); 471 } 472 } 473 } | Popular Tags |