1 22 package org.jboss.xb.binding.sunday.unmarshalling; 23 24 28 public class ParticleBinding 29 { 30 private TermBinding term; 31 private int minOccurs = 1; 32 private int maxOccurs = -1; 33 private boolean maxOccursUnbounded; 34 35 public ParticleBinding(TermBinding term, int minOccurs, int maxOccurs, boolean maxOccursUnbounded) 36 { 37 this.term = term; 38 this.minOccurs = minOccurs; 39 this.maxOccurs = maxOccurs; 40 this.maxOccursUnbounded = maxOccursUnbounded; 41 } 42 43 public ParticleBinding(TermBinding term) 44 { 45 this.term = term; 46 } 47 48 public int getMinOccurs() 49 { 50 return minOccurs; 51 } 52 53 public int getMaxOccurs() 54 { 55 return maxOccurs; 56 } 57 58 public boolean getMaxOccursUnbounded() 59 { 60 return maxOccursUnbounded; 61 } 62 63 public void setMinOccurs(int minOccurs) 64 { 65 this.minOccurs = minOccurs; 66 } 67 68 public void setMaxOccurs(int maxOccurs) 69 { 70 this.maxOccurs = maxOccurs; 71 } 72 73 public void setMaxOccursUnbounded(boolean maxOccursUnbounded) 74 { 75 this.maxOccursUnbounded = maxOccursUnbounded; 76 } 77 78 public TermBinding getTerm() 79 { 80 return term; 81 } 82 83 public void setTerm(TermBinding term) 84 { 85 this.term = term; 86 } 87 88 public boolean isRepeatable() 89 { 90 return maxOccursUnbounded || maxOccurs > 1 || minOccurs > 1; 91 } 92 93 public boolean isRequired() 94 { 95 return isRequired(0); 96 } 97 98 public boolean isRequired(int occurs) 99 { 100 return minOccurs > occurs && (!term.isModelGroup() || ((ModelGroupBinding)term).hasRequiredParticle()); 101 } 102 103 public String toString() 104 { 105 return term.toString(); 106 } 107 } 108 | Popular Tags |