private boolean marshalModelGroup(ModelGroupBinding modelGroup, boolean declareNs) { boolean marshalled; if(modelGroup instanceof AllBinding) { marshalled = marshalModelGroupAll(modelGroup.getParticles(), declareNs); } else if(modelGroup instanceof ChoiceBinding) { marshalled = marshalModelGroupChoice(modelGroup.getParticles(), declareNs); } else { marshalled = marshalModelGroupSequence(modelGroup, declareNs); } return marshalled; }
public void addParticle(ParticleBinding particle) { switch(choices.size()) { case 0: choices = Collections.singletonList(particle); break; case 1: choices = new ArrayList(choices); default: choices.add(particle); } super.addParticle(particle); }
private ParticleHandler getHandler(ParticleBinding modelGroupParticle) { ParticleHandler handler = ((ModelGroupBinding)modelGroupParticle.getTerm()).getHandler(); return handler == null ? defParticleHandler : handler; }
if(modelGroup.isSkip() || stack.isEmpty()) PropertyMetaData propertyMetaData = modelGroup.getPropertyMetaData(); if(propertyMetaData == null) modelGroup.getSchema().isIgnoreUnresolvedFieldOrClass() ); TermBeforeMarshallingCallback marshallingHandler = modelGroup.getBeforeMarshallingCallback();
private boolean marshalModelGroupSequence(ModelGroupBinding sequence, boolean declareNs) { // if sequence is bound to a collection, // we assume the iterator over the collection is in sync with the particle iterator Iterator valueIterator = null; if(!sequence.isSkip() && !stack.isEmpty()) { Object o = stack.peek(); if(o != null && (Collection.class.isAssignableFrom(o.getClass()) || o.getClass().isArray())) { valueIterator = getIterator(o); } } boolean marshalled = true; for(Iterator i = sequence.getParticles().iterator(); i.hasNext();) { if(valueIterator != null) { Object o = valueIterator.hasNext() ? valueIterator.next() : null; stack.push(o); } ParticleBinding particle = (ParticleBinding)i.next(); marshalled &= marshalParticle(particle, declareNs); if(valueIterator != null) { stack.pop(); } } return marshalled; }
parentGroup.addParticle(particleBinding); if (trace) if (groupBinding.getParticles().isEmpty())
/** * This method is not actually used during parsing. It's here only for internal tests. * * @param qName an element name * @return true if the model group may start with the specified element */ public boolean mayStartWith(QName qName) { return mayStartWith(qName, Collections.EMPTY_SET); }
arrayItem = modelGroup == null ? null : modelGroup.getArrayItem();
public boolean isRequired(int occurs) { return minOccurs > occurs && (!term.isModelGroup() || ((ModelGroupBinding)term).hasRequiredParticle()); }
result = modelGroup.mayStartWith(qName, set);
arrayItem = modelGroup == null ? null : modelGroup.getArrayItem();
private ElementBinding findLocalPathElement(Iterator particles, String[] path, int pos) { while (particles.hasNext()) { TermBinding term = ((ParticleBinding)particles.next()).getTerm(); if (term instanceof ElementBinding) { ElementBinding element = (ElementBinding)term; element = findLocalPathElement(element, path, pos); if (element != null) return element; } else if (term instanceof ModelGroupBinding) { Iterator i = ((ModelGroupBinding)term).getParticles().iterator(); ElementBinding element = findLocalPathElement(i, path, pos); if (element != null) return element; } } return null; }
public void addParticle(ParticleBinding particle) { ModelGroupBinding modelGroup; if(this.particle == null) { modelGroup = new AllBinding(schemaBinding); this.particle = new ParticleBinding(modelGroup); } else { modelGroup = (ModelGroupBinding)this.particle.getTerm(); } modelGroup.addParticle(particle); }
result = modelGroup.mayStartWith(qName, set);
private ElementBinding findLocalPathElementInTypes(Iterator types, String[] path) { while (types.hasNext()) { TypeBinding type = (TypeBinding)types.next(); if (type.getQName().getLocalPart().equals(path[0])) { ParticleBinding particle = type.getParticle(); if (particle == null) continue; TermBinding term = particle.getTerm(); if (!term.isModelGroup()) continue; return findLocalPathElement(((ModelGroupBinding)term).getParticles().iterator(), path, 1); } } return null; }
public void addParticle(ParticleBinding particle) { switch(sequence.size()) { case 0: sequence = Collections.singletonList(particle); if(particle.isRepeatable() && particle.getTerm().isElement()) { ElementBinding element = (ElementBinding)particle.getTerm(); if(particle.isRepeatable()) { arrayItem = element; } } break; case 1: sequence = new ArrayList(sequence); arrayItem = null; default: sequence.add(particle); } super.addParticle(particle); }
private void bindGlobalGroupParticles(XSModelGroup group) { ModelGroupBinding groupBinding = sharedElements.getGlobalGroup(group); if (groupBinding.getParticles().isEmpty()) { pushModelGroup(groupBinding); bindModelGroupParticles(group); popModelGroup(); } }
public void addParticle(ParticleBinding particle) { if(!particle.getTerm().isElement()) { throw new JBossXBRuntimeException("Model group all may contain only elements!"); } ElementBinding element = (ElementBinding)particle.getTerm(); switch(elements.size()) { case 0: elements = Collections.singletonMap(element.getQName(), particle); break; case 1: elements = new HashMap(elements); default: elements.put(element.getQName(), particle); } super.addParticle(particle); }
private ElementBinding findLocalPathElement(ElementBinding element, String[] path, int pos) { String name = path[pos]; if (!name.equals(element.getQName().getLocalPart())) return null; // End of path if (path.length - 1 == pos) return element; ParticleBinding particle = element.getType().getParticle(); if (particle == null) return null; TermBinding term = particle.getTerm(); if (!term.isModelGroup()) return null; ModelGroupBinding group = (ModelGroupBinding)term; Iterator i = group.getParticles().iterator(); // Increase depth return findLocalPathElement(i, path, pos + 1); }
private void bindWildcard(XSParticle particle) { WildcardBinding binding = new WildcardBinding(schema); ModelGroupBinding group = (ModelGroupBinding)peekTypeOrGroup(); ParticleBinding particleBinding = new ParticleBinding(binding); particleBinding.setMaxOccurs(particle.getMaxOccurs()); particleBinding.setMaxOccursUnbounded(particle.getMaxOccursUnbounded()); particleBinding.setMinOccurs(particle.getMinOccurs()); group.addParticle(particleBinding); XSWildcard wildcard = (XSWildcard)particle.getTerm(); if(wildcard.getName() != null) { binding.setQName(new QName(wildcard.getNamespace(), wildcard.getName())); } binding.setProcessContents(wildcard.getProcessContents()); if (processAnnotations) { XSAnnotation annotation = wildcard.getAnnotation(); if(annotation != null) { customizeTerm(annotation, binding, trace); } } }