Refine search
public Multiplicity particle( XSParticle p ) { Multiplicity m = p.getTerm().apply(this); Integer max; if(m.max==null || p.getMaxOccurs()==XSParticle.UNBOUNDED) max=null; else max=p.getMaxOccurs(); return Multiplicity.multiply( m, Multiplicity.create(p.getMinOccurs(),max) ); }
public void modelGroup(XSModelGroup mg) { String operator; if(mg.getCompositor()==XSModelGroup.CHOICE) operator = "Or"; else operator = "And"; int size = mg.getSize(); for( int i=0; i<size; i++ ) { XSParticle p = mg.getChild(i); boolean oldRep = rep; rep |= p.isRepeated(); p.getTerm().visit(this); rep = oldRep; if(count==3) return; // we have enough if(i!=size-1) name.append(operator); } }
public void modelGroup(XSModelGroup group) { for (XSParticle child : group.getChildren()) { child.visit(this); } }
private static List<XSModelGroupDecl> findModelGroups(final Iterable<XSParticle> modelGroup) { final List<XSModelGroupDecl> elementDecls = new ArrayList<>(); for (final XSParticle child : modelGroup) { if (!child.isRepeated() && (child.getTerm() instanceof XSModelGroupDecl)) { elementDecls.add((XSModelGroupDecl) child.getTerm()); } } return elementDecls; }
/** * Gets the {@link BIDom} object that applies to the given particle. */ protected final BIDom getLocalDomCustomization( XSParticle p ) { if (p == null) { return null; } BIDom dom = getBindInfo(p).get(BIDom.class); if(dom!=null) return dom; // if not, the term might have one. dom = getBindInfo(p.getTerm()).get(BIDom.class); if(dom!=null) return dom; XSTerm t = p.getTerm(); // type could also have one, in case of the dom customization if(t.isElementDecl()) return getBindInfo(t.asElementDecl().getType()).get(BIDom.class); // similarly the model group in a model group definition may have one. if(t.isModelGroupDecl()) return getBindInfo(t.asModelGroupDecl().getModelGroup()).get(BIDom.class); return null; }
XSParticle p; ps = modelGroup.getChildren(); for (int i = 0; i < ps.length; i++) { p = ps[i]; term = p.getTerm(); if (term.isModelGroup()) { write(st, term, goingup, xss); } else if (term.isElementDecl()) { if (term.asElementDecl().getType().getName() == null) { final String typeName = processType(term .asElementDecl().getType(), term .asElementDecl().getName(), xss); String ns = null; if (map.containsKey(typeName)) { st.addField(term.asElementDecl().getName(), ns, typeName, (goingup && p.getMinOccurs() .intValue() != 0), p.getMaxOccurs() .intValue() != 1, term.asElementDecl() .getFixedValue(), xsdMapping); .getTargetNamespace(), term .asElementDecl().getType().getName(), (goingup && p.getMinOccurs().intValue() != 0), p.getMaxOccurs().intValue() != 1, term .asElementDecl().getFixedValue(), xsdMapping);
public boolean isOptional(final String elementName) { for (final Entry<String, XSComplexType> entry : getComplexTypes().entrySet()) { final XSContentType content = entry.getValue().getContentType(); final XSParticle particle = content.asParticle(); if (null != particle) { final XSTerm term = particle.getTerm(); if (term.isModelGroup()) { final XSParticle[] particles = term.asModelGroup().getChildren(); for (final XSParticle p : particles) { final XSTerm pterm = p.getTerm(); if (pterm.isElementDecl()) { final XSElementDecl e = pterm.asElementDecl(); if (0 == e.getName().compareToIgnoreCase(elementName)) { return p.getMinOccurs() == 0; } } } } } } return true; }
protected void processParticle(XSParticle particle, ParseContext parseContext) throws Exception { parseContext.minOccurs = particle.getMinOccurs().intValue(); parseContext.maxOccurs = particle.getMaxOccurs().intValue(); XSTerm term = particle.getTerm(); if (term.isModelGroup()) { processGroup(term.asModelGroup(), parseContext); } else if (term.isModelGroupDecl()) { processGroupDecl(term.asModelGroupDecl(), parseContext); } else if (term.isElementDecl()) { processElement(term.asElementDecl(), parseContext); } }
XSTerm t = p.getTerm(); if(t.isElementDecl()) return makeJavaName(p,t.asElementDecl().getName()); if(t.isModelGroupDecl()) return makeJavaName(p,t.asModelGroupDecl().getName()); if(t.isModelGroup()) { try { return getSpecDefaultName(t.asModelGroup(),p.isRepeated()); } catch( ParseException e ) {
protected ListType createListType(Schema schema, String name, XSParticle particle) throws TypeBindingException { XSElementDecl element = particle.getTerm().asElementDecl(); if (element == null) { log.warn("Ignoring " + name + " unsupported list type"); Type type = loadType(schema, element.getType(), name + '#' + element.getName()); if (type == null) { log.warn("Unable to find type for " + element.getName()); return null; return new ListTypeImpl(schema.getName(), name, type, element.getName(), defValue, flags, constraints, particle.getMinOccurs().intValue(), particle.getMaxOccurs().intValue());
public void particle(XSParticle p) { // determine the binding of this complex type. builder.recordBindingMode(ct, bgmBuilder.getParticleBinder().checkFallback(p)?FALLBACK_CONTENT:NORMAL); bgmBuilder.getParticleBinder().build(p); XSTerm term = p.getTerm(); if(term.isModelGroup() && term.asModelGroup().getCompositor()==XSModelGroup.ALL) selector.getCurrentBean().setOrdered(false); }
private CCustomizations getCustomizations( XSParticle src ) { // customizations for a particle should include those defined in the term unless it's global // this is so that the schema like: // // <xs:sequence> // <xs:element name="foo" type="xs:int"> // <xs:annotation><xs:appinfo> // <hyperjaxb:... /> // // would be picked up if(src.getTerm().isElementDecl()) { XSElementDecl xed = src.getTerm().asElementDecl(); if(xed.isGlobal()) return getCustomizations((XSComponent)src); } return getCustomizations(src,src.getTerm()); }
public boolean isApplicable(XSComplexType ct) { if (!bgmBuilder.model.options.contentForWildcard) { return false; } XSType bt = ct.getBaseType(); if (bt ==schemas.getAnyType() && ct.getContentType() != null) { XSParticle part = ct.getContentType().asParticle(); if ((part != null) && (part.getTerm().isModelGroup())) { XSParticle[] parts = part.getTerm().asModelGroup().getChildren(); int wildcardCount = 0; int i = 0; while ((i < parts.length) && (wildcardCount <= 1)) { if (parts[i].getTerm().isWildcard()) { wildcardCount += 1; } i++; } return (wildcardCount > 1); } } return false; }
public Expression particle(XSParticle p) { current = p; Expression e = p.getTerm().apply(this); if(p.isRepeated()) e = new OneOrMore(e); if(p.getMinOccurs()==0) e = new Choice(e,Expression.EPSILON); return e; }
private boolean containingChoice(CClassInfo typeBean) { XSComponent component = typeBean.getSchemaComponent(); if (component instanceof XSComplexType) { XSContentType contentType = ((XSComplexType) component).getContentType(); XSParticle particle = contentType.asParticle(); if (particle != null) { XSTerm term = particle.getTerm(); XSModelGroup modelGroup = term.asModelGroup(); if (modelGroup != null) { return (modelGroup.getCompositor() == XSModelGroup.Compositor.CHOICE); } } } return false; }
/** * Gets a {@link NameClass} that represents all the terms in the given content type. * If t is not a particle, just return an empty name class. */ private NameClass getNameClass(XSContentType t) { if(t==null) return NameClass.NULL; XSParticle p = t.asParticle(); if(p==null) return NameClass.NULL; else return p.getTerm().apply(contentModelNameClassBuilder); }
i = part.getMaxOccurs(); if(i==XSParticle.UNBOUNDED) buf.append(" maxOccurs=\"unbounded\""); buf.append(" maxOccurs=\"").append(i).append('\"'); i = part.getMinOccurs(); if(i!=1) buf.append(" minOccurs=\"").append(i).append('\"'); part.getTerm().visit(new XSTermVisitor(){ public void elementDecl( XSElementDecl decl ) { if(decl.isLocal())
private static Collection<? extends XSDeclaration> findModelGroups(final XSComplexType complexType) { XSContentType contentType = complexType.getExplicitContent(); if (contentType == null) { contentType = complexType.getContentType(); } final XSParticle particle = contentType.asParticle(); if (particle != null && !particle.isRepeated()) { final XSTerm term = particle.getTerm(); if (term instanceof XSModelGroupDecl) { return Collections.singletonList((XSModelGroupDecl)term); } else { final XSModelGroup modelGroup = term.asModelGroup(); return modelGroup != null ? findModelGroups(modelGroup) : Collections.<XSModelGroupDecl>emptyList(); } } else { return Collections.emptyList(); } }
private boolean containsDefaultValue(Outline outline, FieldOutline field) { ClassOutline fClass = null; for (ClassOutline classOutline : outline.getClasses()) { if (classOutline.implClass == field.getRawType() && !classOutline.implClass.isAbstract()) { fClass = classOutline; break; } } if (fClass == null) { return false; } for (FieldOutline f : fClass.getDeclaredFields()) { if (f.getPropertyInfo().getSchemaComponent() instanceof XSParticle) { XSParticle particle = (XSParticle)f.getPropertyInfo().getSchemaComponent(); XSTerm term = particle.getTerm(); if (term.isElementDecl() && term.asElementDecl().getDefaultValue() != null) { return true; } } } return false; }