Package org.jboss.xb.annotations

Examples of org.jboss.xb.annotations.JBossXmlModelGroup


/*  967 */     typeBinding.setParticle(typeParticle);
/*      */
/*  969 */     if (typeInfo.isCollection())
/*      */     {
/*  971 */       TypeInfo memberBaseType = findComponentType(typeInfo);
/*  972 */       JBossXmlModelGroup xmlModelGroup = (JBossXmlModelGroup)((ClassInfo)memberBaseType).getUnderlyingAnnotation(JBossXmlModelGroup.class);
/*      */
/*  974 */       if ((xmlModelGroup != null) && (xmlModelGroup.particles().length > 0))
/*      */       {
/*  976 */         if (this.trace) {
/*  977 */           log.trace("Item base type for " + typeInfo.getName() + " is " + memberBaseType.getName() + " and bound to repeatable choice");
/*      */         }
/*      */
/*  982 */         ModelGroupBinding choiceGroup = null;
/*  983 */         QName choiceName = null;
/*  984 */         if (!"##default".equals(xmlModelGroup.name()))
/*      */         {
/*  986 */           choiceName = new QName(this.defaultNamespace, xmlModelGroup.name());
/*  987 */           choiceGroup = this.schemaBinding.getGroup(choiceName);
/*      */         }
/*      */
/*  990 */         if (choiceGroup == null)
/*      */         {
/*  992 */           choiceGroup = new ChoiceBinding(this.schemaBinding);
/*  993 */           choiceGroup.setHandler(BuilderParticleHandler.INSTANCE);
/*  994 */           if (choiceName != null)
/*      */           {
/*  996 */             choiceGroup.setQName(choiceName);
/*  997 */             this.schemaBinding.addGroup(choiceGroup.getQName(), choiceGroup);
/*      */           }
/*      */
/* 1000 */           ParticleBinding choiceParticle = new ParticleBinding(choiceGroup, 0, 1, true);
/* 1001 */           model.addParticle(choiceParticle);
/*      */
/* 1003 */           for (JBossXmlModelGroup.Particle member : xmlModelGroup.particles())
/*      */           {
/* 1005 */             XmlElement element = member.element();
/* 1006 */             QName memberQName = generateXmlName(element.name(), XmlNsForm.QUALIFIED, element.namespace(), null);
/* 1007 */             TypeInfo memberTypeInfo = typeInfo.getTypeInfoFactory().getTypeInfo(member.type());
/*      */
View Full Code Here


/* 1240 */       if (propXmlElement != null)
/*      */       {
/* 1242 */         propClassInfo = (ClassInfo)propClassInfo.getTypeInfoFactory().getTypeInfo(propXmlElement.type());
/*      */       }
/*      */
/* 1245 */       JBossXmlModelGroup xmlModelGroup = (JBossXmlModelGroup)propClassInfo.getUnderlyingAnnotation(JBossXmlModelGroup.class);
/* 1246 */       if ((xmlModelGroup != null) && (xmlModelGroup.particles().length == 0))
/*      */       {
/* 1248 */         if (this.trace) {
/* 1249 */           log.trace("Property " + property.getName() + " is bound to " + xmlModelGroup.kind());
/*      */         }
/* 1251 */         ModelGroupBinding propertyGroup = null;
/* 1252 */         QName groupName = null;
/* 1253 */         if (!"##default".equals(xmlModelGroup.name())) {
/* 1254 */           groupName = new QName(xmlModelGroup.name());
/*      */         }
/* 1256 */         if (groupName != null) {
/* 1257 */           propertyGroup = this.schemaBinding.getGroup(groupName);
/*      */         }
/* 1259 */         if (propertyGroup == null)
/*      */         {
/* 1261 */           if (xmlModelGroup.kind().equals("sequence"))
/*      */           {
/* 1263 */             propertyGroup = new SequenceBinding(this.schemaBinding);
/*      */           }
/* 1265 */           else if (xmlModelGroup.kind().equals("choice"))
/*      */           {
/* 1267 */             propertyGroup = new ChoiceBinding(this.schemaBinding);
/*      */           }
/* 1269 */           else if (xmlModelGroup.kind().equals("all"))
/*      */           {
/* 1271 */             propertyGroup = new AllBinding(this.schemaBinding);
/*      */           }
/*      */           else
/*      */           {
/* 1275 */             throw new IllegalStateException("Unexpected JBossXmlModelGroup.kind=" + xmlModelGroup.kind());
/*      */           }
/*      */
/* 1278 */           if (groupName != null)
/*      */           {
/* 1281 */             propertyGroup.setQName(groupName);
/* 1282 */             this.schemaBinding.addGroup(propertyGroup.getQName(), propertyGroup);
/*      */           }
/*      */
/* 1285 */           propertyGroup.setSkip(Boolean.FALSE);
/*      */
/* 1288 */           BeanInfo propBeanInfo = JBossXBBuilder.configuration.getBeanInfo(propClassInfo);
/* 1289 */           BeanAdapterFactory propBeanAdapterFactory = null;
/*      */           try
/*      */           {
/* 1293 */             BeanInfo propBeanAdapterBuilderInfo = JBossXBBuilder.configuration.getBeanInfo(DefaultBeanAdapterBuilder.class);
/*      */
/* 1295 */             BeanAdapterBuilder propBeanAdapterBuilder = (BeanAdapterBuilder)propBeanAdapterBuilderInfo.newInstance();
/*      */
/* 1297 */             propBeanAdapterFactory = propBeanAdapterBuilder.newFactory(propBeanInfo, null);
/*      */           }
/*      */           catch (Throwable t)
/*      */           {
/* 1301 */             throw new RuntimeException("Error creating BeanAdapterFactory for " + DefaultBeanAdapterBuilder.class.getName(), t);
/*      */           }
/*      */
/* 1304 */           BeanHandler propHandler = new BeanHandler(propBeanInfo.getName(), propBeanAdapterFactory);
/* 1305 */           propertyGroup.setHandler(propHandler);
/*      */
/* 1307 */           String[] memberOrder = xmlModelGroup.propOrder();
/* 1308 */           if ((memberOrder.length == 0) || (memberOrder[0].length() == 0))
/*      */           {
/* 1310 */             List propNames = new ArrayList();
/* 1311 */             for (PropertyInfo prop : propBeanInfo.getProperties())
/*      */             {
/* 1313 */               propNames.add(prop.getName());
/*      */             }
/* 1315 */             memberOrder = (String[])propNames.toArray(new String[propNames.size()]);
/*      */           }
/*      */
/* 1318 */           if (this.trace) {
/* 1319 */             log.trace("Property order for " + xmlModelGroup.kind() + " property " + property.getName() + ": " + Arrays.asList(memberOrder));
/*      */           }
/*      */
/* 1323 */           for (String memberPropName : memberOrder)
/*      */           {
/* 1325 */             if ("class".equals(memberPropName))
/*      */             {
/*      */               continue;
/*      */             }
/*      */
/* 1330 */             PropertyInfo memberProp = propBeanInfo.getProperty(memberPropName);
/* 1331 */             TypeInfo memberTypeInfo = memberProp.getType();
/* 1332 */             String memberNamespace = null;
/*      */
/* 1334 */             JBossXmlNsPrefix nsPrefix = (JBossXmlNsPrefix)memberProp.getUnderlyingAnnotation(JBossXmlNsPrefix.class);
/* 1335 */             if (nsPrefix != null)
/*      */             {
/* 1337 */               memberNamespace = this.schemaBinding.getNamespace(nsPrefix.prefix());
/* 1338 */               if ((memberNamespace == null) && (nsPrefix.schemaTargetIfNotMapped()))
/*      */               {
/* 1340 */                 throw new IllegalStateException("Prefix '" + nsPrefix.prefix() + "' is not mapped to any namespace!");
/*      */               }
/*      */
/*      */             }
/*      */
/* 1345 */             String memberName = null;
/* 1346 */             XmlElement memberXmlElement = (XmlElement)memberProp.getUnderlyingAnnotation(XmlElement.class);
/* 1347 */             if (memberXmlElement != null)
/*      */             {
/* 1349 */               if (!XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
/*      */               {
/* 1351 */                 memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(memberXmlElement.type());
/*      */               }
/*      */
/* 1354 */               if (memberNamespace == null)
/* 1355 */                 memberNamespace = memberXmlElement.namespace();
/* 1356 */               memberName = memberXmlElement.name();
/*      */             }
/*      */
/* 1359 */             if (memberNamespace == null)
/*      */             {
/* 1361 */               memberNamespace = this.defaultNamespace;
/*      */             }
/*      */
/* 1364 */             boolean isCol = false;
/* 1365 */             AbstractPropertyHandler memberPropertyHandler = null;
/* 1366 */             if (memberProp.getType().isCollection())
/*      */             {
/* 1368 */               memberPropertyHandler = new CollectionPropertyHandler(memberProp, memberProp.getType());
/* 1369 */               isCol = true;
/*      */
/* 1371 */               if ((memberXmlElement == null) || (XmlElement.DEFAULT.class.equals(memberXmlElement.type())))
/*      */               {
/* 1373 */                 JBossXmlCollection jbossXmlCollection = (JBossXmlCollection)memberProp.getUnderlyingAnnotation(JBossXmlCollection.class);
/*      */
/* 1375 */                 if (jbossXmlCollection != null)
/*      */                 {
/* 1377 */                   memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(jbossXmlCollection.type());
/*      */                 }
/* 1379 */                 memberTypeInfo = findComponentType((ClassInfo)memberTypeInfo);
/*      */               }
/*      */
/*      */             }
/* 1383 */             else if (memberTypeInfo.isCollection())
/*      */             {
/* 1385 */               memberPropertyHandler = new CollectionPropertyHandler(memberProp, memberTypeInfo);
/* 1386 */               isCol = true;
/* 1387 */               memberTypeInfo = findComponentType((ClassInfo)memberTypeInfo);
/*      */             }
/*      */             else
/*      */             {
/* 1391 */               memberPropertyHandler = new PropertyHandler(memberProp, memberTypeInfo);
/*      */             }
/*      */
/* 1394 */             QName memberQName = generateXmlName(memberProp.getName(), this.elementForm, memberNamespace, memberName);
/* 1395 */             propBeanAdapterFactory.addProperty(memberQName, memberPropertyHandler);
/*      */
/* 1397 */             XBValueAdapter valueAdapter = null;
/* 1398 */             XmlJavaTypeAdapter xmlTypeAdapter = (XmlJavaTypeAdapter)memberProp.getUnderlyingAnnotation(XmlJavaTypeAdapter.class);
/* 1399 */             if (xmlTypeAdapter != null)
/*      */             {
/* 1401 */               valueAdapter = new XBValueAdapter(xmlTypeAdapter.value(), memberTypeInfo.getTypeInfoFactory());
/* 1402 */               memberTypeInfo = valueAdapter.getAdaptedTypeInfo();
/*      */             }
/*      */
/* 1405 */             TypeBinding memberTypeBinding = resolveTypeBinding(memberTypeInfo);
/* 1406 */             ElementBinding memberElement = createElementBinding(memberTypeInfo, memberTypeBinding, memberQName, false);
/*      */
/* 1408 */             memberElement.setNillable(true);
/* 1409 */             memberElement.setValueAdapter(valueAdapter);
/* 1410 */             ParticleBinding memberParticle = new ParticleBinding(memberElement, 0, 1, isCol);
/* 1411 */             propertyGroup.addParticle(memberParticle);
/*      */
/* 1413 */             if (this.trace) {
/* 1414 */               log.trace("added " + memberParticle + " to " + xmlModelGroup.kind() + ", property " + property.getName());
/*      */             }
/*      */           }
/*      */         }
/*      */
/* 1419 */         model.addParticle(new ParticleBinding(propertyGroup));
View Full Code Here

      // The current model
      ModelGroupBinding localModel = parentModel;

      TypeInfo propertyComponentType = propertyType;
      XmlType propertyXmlType = null;
      JBossXmlModelGroup propertyXmlModelGroup = null;
      // Setup any new model
      if (propertyType.isArray())
      {
         if (trace)
            log.trace("Property " + property.getName() + " is an array");
View Full Code Here

TOP

Related Classes of org.jboss.xb.annotations.JBossXmlModelGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.