Package org.jboss.xb.annotations

Examples of org.jboss.xb.annotations.JBossXmlCollection


      {
         if (trace)
            log.trace("Property " + property.getName() + " is a collection");
         localModel = createCollection(localModel);

         JBossXmlCollection xmlCol = property.getUnderlyingAnnotation(JBossXmlCollection.class);
         if (xmlCol != null)
         {
            // this is the type that should be analyzed
            propertyType = propertyType.getTypeInfoFactory().getTypeInfo(xmlCol.type());
         }
      }
      // Is this property bound to a model group
      else if (!property.getType().isPrimitive())
      {
         ClassInfo propClassInfo = (ClassInfo) property.getType();

         // TODO XmlElement on this property?..
         XmlElement propXmlElement = property.getUnderlyingAnnotation(XmlElement.class);
         if (propXmlElement != null)
         {
            propClassInfo = (ClassInfo) propClassInfo.getTypeInfoFactory().getTypeInfo(propXmlElement.type());
         }

         JBossXmlModelGroup xmlModelGroup = propClassInfo.getUnderlyingAnnotation(JBossXmlModelGroup.class);
         if (xmlModelGroup != null && xmlModelGroup.particles().length == 0)
         {
            if (trace)
               log.trace("Property " + property.getName() + " is bound to " + xmlModelGroup.kind());

            ModelGroupBinding propertyGroup = null;
            QName groupName = null;
            if (!JBossXmlConstants.DEFAULT.equals(xmlModelGroup.name()))
               groupName = new QName(xmlModelGroup.name());

            if (groupName != null)
               propertyGroup = schemaBinding.getGroup(groupName);

            if (propertyGroup == null)
            {
               if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_SEQUENCE))
               {
                  propertyGroup = new SequenceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_CHOICE))
               {
                  propertyGroup = new ChoiceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_ALL))
               {
                  propertyGroup = new AllBinding(schemaBinding);
               }
               else
               {
                  throw new IllegalStateException("Unexpected JBossXmlModelGroup.kind=" + xmlModelGroup.kind());
               }

               if (groupName != null)
               {
                  // TODO what if it doesn't have a name? should an artificial one be created?
                  propertyGroup.setQName(groupName);
                  schemaBinding.addGroup(propertyGroup.getQName(), propertyGroup);
               }

               propertyGroup.setSkip(Boolean.FALSE);

               // handler for the model group members
               BeanInfo propBeanInfo = JBossXBBuilder.configuration.getBeanInfo(propClassInfo);
               BeanAdapterFactory propBeanAdapterFactory = createAdapterFactory(DefaultBeanAdapterBuilder.class, propBeanInfo, null);
               BeanHandler propHandler = new BeanHandler(propBeanInfo.getName(), propBeanAdapterFactory);
               propertyGroup.setHandler(propHandler);

               String[] memberOrder = xmlModelGroup.propOrder();
               if (memberOrder.length == 0 || memberOrder[0].length() == 0)
               {
                  List<String> propNames = new ArrayList<String>();
                  for (PropertyInfo prop : propBeanInfo.getProperties())
                  {
                     propNames.add(prop.getName());
                  }
                  memberOrder = propNames.toArray(new String[propNames.size()]);
               }

               if (trace)
                  log.trace("Property order for " + xmlModelGroup.kind() + " property " + property.getName() + ": "
                        + Arrays.asList(memberOrder));

               // bind model group members
               for (String memberPropName : memberOrder)
               {
                  if ("class".equals(memberPropName))
                  {
                     continue;
                  }

                  PropertyInfo memberProp = propBeanInfo.getProperty(memberPropName);
                  TypeInfo memberTypeInfo = memberProp.getType();
                  String memberNamespace = null;

                  JBossXmlNsPrefix nsPrefix = memberProp.getUnderlyingAnnotation(JBossXmlNsPrefix.class);
                  if (nsPrefix != null)
                  {
                     memberNamespace = schemaBinding.getNamespace(nsPrefix.prefix());
                     if (memberNamespace == null && nsPrefix.schemaTargetIfNotMapped())
                     {
                        throw new IllegalStateException("Prefix '" + nsPrefix.prefix()
                              + "' is not mapped to any namespace!");
                     }
                  }

                  String memberName = null;
                  XmlElement memberXmlElement = memberProp.getUnderlyingAnnotation(XmlElement.class);
                  if (memberXmlElement != null)
                  {
                     if (!XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
                     {
                        memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(memberXmlElement.type());
                     }

                     if (memberNamespace == null)
                        memberNamespace = memberXmlElement.namespace();
                     memberName = memberXmlElement.name();
                  }

                  if (memberNamespace == null)
                  {
                     memberNamespace = defaultNamespace;
                  }

                  boolean isCol = false;
                  AbstractPropertyHandler memberPropertyHandler = null;
                  if (memberProp.getType().isCollection())
                  {
                     memberPropertyHandler = new CollectionPropertyHandler(memberProp, memberProp.getType());
                     isCol = true;
                     // if memberXmlElement is present then the collection item type is set explicitly
                     if (memberXmlElement == null || XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
                     {
                        JBossXmlCollection jbossXmlCollection = memberProp
                              .getUnderlyingAnnotation(JBossXmlCollection.class);
                        if (jbossXmlCollection != null)
                        {
                           memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(jbossXmlCollection.type());
                        }
                        memberTypeInfo = ((ClassInfo) memberTypeInfo).getComponentType();
                     }
                  }
                  // if it is bound with XmlElement.type to a collection
View Full Code Here


      {
         if (trace)
            log.trace("Property " + property.getName() + " is a collection");
         localModel = createCollection(localModel);

         JBossXmlCollection xmlCol = property.getUnderlyingAnnotation(JBossXmlCollection.class);
         if (xmlCol != null)
         {
            // this is the type that should be analyzed
            propertyType = propertyType.getTypeInfoFactory().getTypeInfo(xmlCol.type());
         }
      }
      // Is this property bound to a model group
      else if (!property.getType().isPrimitive())
      {
         ClassInfo propClassInfo = (ClassInfo) property.getType();

         // TODO XmlElement on this property?..
         XmlElement propXmlElement = property.getUnderlyingAnnotation(XmlElement.class);
         if (propXmlElement != null)
         {
            propClassInfo = (ClassInfo) propClassInfo.getTypeInfoFactory().getTypeInfo(propXmlElement.type());
         }

         JBossXmlModelGroup xmlModelGroup = propClassInfo.getUnderlyingAnnotation(JBossXmlModelGroup.class);
         if (xmlModelGroup != null && xmlModelGroup.particles().length == 0)
         {
            if (trace)
               log.trace("Property " + property.getName() + " is bound to " + xmlModelGroup.kind());

            ModelGroupBinding propertyGroup = null;
            QName groupName = null;
            if (!JBossXmlConstants.DEFAULT.equals(xmlModelGroup.name()))
               groupName = new QName(xmlModelGroup.name());

            if (groupName != null)
               propertyGroup = schemaBinding.getGroup(groupName);

            if (propertyGroup == null)
            {
               if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_SEQUENCE))
               {
                  propertyGroup = new SequenceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_CHOICE))
               {
                  propertyGroup = new ChoiceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_ALL))
               {
                  propertyGroup = new AllBinding(schemaBinding);
               }
               else
               {
                  throw new IllegalStateException("Unexpected JBossXmlModelGroup.kind=" + xmlModelGroup.kind());
               }

               if (groupName != null)
               {
                  // TODO what if it doesn't have a name? should an artificial one be created?
                  propertyGroup.setQName(groupName);
                  schemaBinding.addGroup(propertyGroup.getQName(), propertyGroup);
               }

               propertyGroup.setSkip(Boolean.FALSE);

               // handler for the model group members
               BeanInfo propBeanInfo = JBossXBBuilder.configuration.getBeanInfo(propClassInfo);
               BeanAdapterFactory propBeanAdapterFactory = createAdapterFactory(DefaultBeanAdapterBuilder.class, propBeanInfo, null);
               BeanHandler propHandler = new BeanHandler(propBeanInfo.getName(), propBeanAdapterFactory);
               propertyGroup.setHandler(propHandler);

               String[] memberOrder = xmlModelGroup.propOrder();
               if (memberOrder.length == 0 || memberOrder[0].length() == 0)
               {
                  List<String> propNames = new ArrayList<String>();
                  for (PropertyInfo prop : propBeanInfo.getProperties())
                  {
                     propNames.add(prop.getName());
                  }
                  memberOrder = propNames.toArray(new String[propNames.size()]);
               }

               if (trace)
                  log.trace("Property order for " + xmlModelGroup.kind() + " property " + property.getName() + ": "
                        + Arrays.asList(memberOrder));

               // bind model group members
               for (String memberPropName : memberOrder)
               {
                  if ("class".equals(memberPropName))
                  {
                     continue;
                  }

                  PropertyInfo memberProp = propBeanInfo.getProperty(memberPropName);
                  TypeInfo memberTypeInfo = memberProp.getType();
                  String memberNamespace = null;

                  JBossXmlNsPrefix nsPrefix = memberProp.getUnderlyingAnnotation(JBossXmlNsPrefix.class);
                  if (nsPrefix != null)
                  {
                     memberNamespace = schemaBinding.getNamespace(nsPrefix.prefix());
                     if (memberNamespace == null && nsPrefix.schemaTargetIfNotMapped())
                     {
                        throw new IllegalStateException("Prefix '" + nsPrefix.prefix()
                              + "' is not mapped to any namespace!");
                     }
                  }

                  String memberName = null;
                  XmlElement memberXmlElement = memberProp.getUnderlyingAnnotation(XmlElement.class);
                  if (memberXmlElement != null)
                  {
                     if (!XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
                     {
                        memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(memberXmlElement.type());
                     }

                     if (memberNamespace == null)
                        memberNamespace = memberXmlElement.namespace();
                     memberName = memberXmlElement.name();
                  }

                  if (memberNamespace == null)
                  {
                     memberNamespace = defaultNamespace;
                  }

                  boolean isCol = false;
                  AbstractPropertyHandler memberPropertyHandler = null;
                  if (memberProp.getType().isCollection())
                  {
                     memberPropertyHandler = new CollectionPropertyHandler(memberProp, memberProp.getType());
                     isCol = true;
                     // if memberXmlElement is present then the collection item type is set explicitly
                     if (memberXmlElement == null || XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
                     {
                        JBossXmlCollection jbossXmlCollection = memberProp
                              .getUnderlyingAnnotation(JBossXmlCollection.class);
                        if (jbossXmlCollection != null)
                        {
                           memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(jbossXmlCollection.type());
                        }
                        memberTypeInfo = ((ClassInfo) memberTypeInfo).getComponentType();
                     }
                  }
                  // if it is bound with XmlElement.type to a collection
View Full Code Here

      {
         if (trace)
            log.trace("Property " + property.getName() + " is a collection");
         localModel = createCollection(localModel);

         JBossXmlCollection xmlCol = property.getUnderlyingAnnotation(JBossXmlCollection.class);
         if (xmlCol != null)
         {
            // this is the type that should be analyzed
            propertyType = propertyType.getTypeInfoFactory().getTypeInfo(xmlCol.type());
         }
      }
      // Is this property bound to a model group
      else if (!property.getType().isPrimitive())
      {
         ClassInfo propClassInfo = (ClassInfo) property.getType();

         // TODO XmlElement on this property?..
         XmlElement propXmlElement = property.getUnderlyingAnnotation(XmlElement.class);
         if (propXmlElement != null)
         {
            propClassInfo = (ClassInfo) propClassInfo.getTypeInfoFactory().getTypeInfo(propXmlElement.type());
         }

         JBossXmlModelGroup xmlModelGroup = propClassInfo.getUnderlyingAnnotation(JBossXmlModelGroup.class);
         if (xmlModelGroup != null && xmlModelGroup.particles().length == 0)
         {
            if (trace)
               log.trace("Property " + property.getName() + " is bound to " + xmlModelGroup.kind());

            ModelGroupBinding propertyGroup = null;
            QName groupName = null;
            if (!JBossXmlConstants.DEFAULT.equals(xmlModelGroup.name()))
               groupName = new QName(xmlModelGroup.name());

            if (groupName != null)
               propertyGroup = schemaBinding.getGroup(groupName);

            if (propertyGroup == null)
            {
               if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_SEQUENCE))
               {
                  propertyGroup = new SequenceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_CHOICE))
               {
                  propertyGroup = new ChoiceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_ALL))
               {
                  propertyGroup = new AllBinding(schemaBinding);
               }
               else
               {
                  throw new IllegalStateException("Unexpected JBossXmlModelGroup.kind=" + xmlModelGroup.kind());
               }

               if (groupName != null)
               {
                  // TODO what if it doesn't have a name? should an artificial one be created?
                  propertyGroup.setQName(groupName);
                  schemaBinding.addGroup(propertyGroup.getQName(), propertyGroup);
               }

               propertyGroup.setSkip(Boolean.FALSE);

               // handler for the model group members
               BeanInfo propBeanInfo = JBossXBBuilder.configuration.getBeanInfo(propClassInfo);
               BeanAdapterFactory propBeanAdapterFactory = createAdapterFactory(DefaultBeanAdapterBuilder.class, propBeanInfo, null);
               BeanHandler propHandler = new BeanHandler(propBeanInfo.getName(), propBeanAdapterFactory);
               propertyGroup.setHandler(propHandler);

               String[] memberOrder = xmlModelGroup.propOrder();
               if (memberOrder.length == 0 || memberOrder[0].length() == 0)
               {
                  List<String> propNames = new ArrayList<String>();
                  for (PropertyInfo prop : propBeanInfo.getProperties())
                  {
                     propNames.add(prop.getName());
                  }
                  memberOrder = propNames.toArray(new String[propNames.size()]);
               }

               if (trace)
                  log.trace("Property order for " + xmlModelGroup.kind() + " property " + property.getName() + ": "
                        + Arrays.asList(memberOrder));

               // bind model group members
               for (String memberPropName : memberOrder)
               {
                  if ("class".equals(memberPropName))
                  {
                     continue;
                  }

                  PropertyInfo memberProp = propBeanInfo.getProperty(memberPropName);
                  TypeInfo memberTypeInfo = memberProp.getType();
                  String memberNamespace = null;

                  JBossXmlNsPrefix nsPrefix = memberProp.getUnderlyingAnnotation(JBossXmlNsPrefix.class);
                  if (nsPrefix != null)
                  {
                     memberNamespace = schemaBinding.getNamespace(nsPrefix.prefix());
                     if (memberNamespace == null && nsPrefix.schemaTargetIfNotMapped())
                     {
                        throw new IllegalStateException("Prefix '" + nsPrefix.prefix()
                              + "' is not mapped to any namespace!");
                     }
                  }

                  String memberName = null;
                  XmlElement memberXmlElement = memberProp.getUnderlyingAnnotation(XmlElement.class);
                  if (memberXmlElement != null)
                  {
                     if (!XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
                     {
                        memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(memberXmlElement.type());
                     }

                     if (memberNamespace == null)
                        memberNamespace = memberXmlElement.namespace();
                     memberName = memberXmlElement.name();
                  }

                  if (memberNamespace == null)
                  {
                     memberNamespace = defaultNamespace;
                  }

                  boolean isCol = false;
                  AbstractPropertyHandler memberPropertyHandler = null;
                  if (memberProp.getType().isCollection())
                  {
                     memberPropertyHandler = new CollectionPropertyHandler(memberProp, memberProp.getType());
                     isCol = true;
                     // if memberXmlElement is present then the collection item type is set explicitly
                     if (memberXmlElement == null || XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
                     {
                        JBossXmlCollection jbossXmlCollection = memberProp
                              .getUnderlyingAnnotation(JBossXmlCollection.class);
                        if (jbossXmlCollection != null)
                        {
                           memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(jbossXmlCollection.type());
                        }
                        memberTypeInfo = ((ClassInfo) memberTypeInfo).getComponentType();
                     }
                  }
                  // if it is bound with XmlElement.type to a collection
View Full Code Here

   public CollectionPropertyHandler(PropertyInfo propertyInfo, TypeInfo propertyType)
   {
      super(propertyInfo, propertyType);

      ClassInfo collectionType = null;
      JBossXmlCollection xmlCol = propertyInfo.getUnderlyingAnnotation(JBossXmlCollection.class);
      if (xmlCol != null)
      {
         collectionType = (ClassInfo) propertyType.getTypeInfoFactory().getTypeInfo(xmlCol.type());
      }
      else if (!Modifier.isAbstract(((ClassInfo) propertyType).getModifiers()))
      {
         collectionType = (ClassInfo) propertyType;
      }
View Full Code Here

      {
         if (trace)
            log.trace("Property " + property.getName() + " is a collection");
         localModel = createCollection(localModel);

         JBossXmlCollection xmlCol = property.getUnderlyingAnnotation(JBossXmlCollection.class);
         if (xmlCol != null)
         {
            // this is the type that should be analyzed
            propertyType = propertyType.getTypeInfoFactory().getTypeInfo(xmlCol.type());
         }
      }
      // Is this property bound to a model group
      else if (!property.getType().isPrimitive())
      {
         ClassInfo propClassInfo = (ClassInfo) property.getType();

         // TODO XmlElement on this property?..
         XmlElement propXmlElement = property.getUnderlyingAnnotation(XmlElement.class);
         if (propXmlElement != null)
         {
            propClassInfo = (ClassInfo) propClassInfo.getTypeInfoFactory().getTypeInfo(propXmlElement.type());
         }

         JBossXmlModelGroup xmlModelGroup = propClassInfo.getUnderlyingAnnotation(JBossXmlModelGroup.class);
         if (xmlModelGroup != null && xmlModelGroup.particles().length == 0)
         {
            if (trace)
               log.trace("Property " + property.getName() + " is bound to " + xmlModelGroup.kind());

            ModelGroupBinding propertyGroup = null;
            QName groupName = null;
            if (!JBossXmlConstants.DEFAULT.equals(xmlModelGroup.name()))
               groupName = new QName(xmlModelGroup.name());

            if (groupName != null)
               propertyGroup = schemaBinding.getGroup(groupName);

            if (propertyGroup == null)
            {
               if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_SEQUENCE))
               {
                  propertyGroup = new SequenceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_CHOICE))
               {
                  propertyGroup = new ChoiceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_ALL))
               {
                  propertyGroup = new AllBinding(schemaBinding);
               }
               else
               {
                  throw new IllegalStateException("Unexpected JBossXmlModelGroup.kind=" + xmlModelGroup.kind());
               }

               if (groupName != null)
               {
                  // TODO what if it doesn't have a name? should an artificial one be created?
                  propertyGroup.setQName(groupName);
                  schemaBinding.addGroup(propertyGroup.getQName(), propertyGroup);
               }

               propertyGroup.setSkip(Boolean.FALSE);

               // handler for the model group members
               BeanInfo propBeanInfo = JBossXBBuilder.configuration.getBeanInfo(propClassInfo);
               BeanAdapterFactory propBeanAdapterFactory = createAdapterFactory(DefaultBeanAdapterBuilder.class, propBeanInfo, null);
               BeanHandler propHandler = new BeanHandler(propBeanInfo.getName(), propBeanAdapterFactory);
               propertyGroup.setHandler(propHandler);

               String[] memberOrder = xmlModelGroup.propOrder();
               if (memberOrder.length == 0 || memberOrder[0].length() == 0)
               {
                  List<String> propNames = new ArrayList<String>();
                  for (PropertyInfo prop : propBeanInfo.getProperties())
                  {
                     propNames.add(prop.getName());
                  }
                  memberOrder = propNames.toArray(new String[propNames.size()]);
               }

               if (trace)
                  log.trace("Property order for " + xmlModelGroup.kind() + " property " + property.getName() + ": "
                        + Arrays.asList(memberOrder));

               // bind model group members
               for (String memberPropName : memberOrder)
               {
                  if ("class".equals(memberPropName))
                  {
                     continue;
                  }

                  PropertyInfo memberProp = propBeanInfo.getProperty(memberPropName);
                  TypeInfo memberTypeInfo = memberProp.getType();
                  String memberNamespace = null;

                  JBossXmlNsPrefix nsPrefix = memberProp.getUnderlyingAnnotation(JBossXmlNsPrefix.class);
                  if (nsPrefix != null)
                  {
                     memberNamespace = schemaBinding.getNamespace(nsPrefix.prefix());
                     if (memberNamespace == null && nsPrefix.schemaTargetIfNotMapped())
                     {
                        throw new IllegalStateException("Prefix '" + nsPrefix.prefix()
                              + "' is not mapped to any namespace!");
                     }
                  }

                  String memberName = null;
                  XmlElement memberXmlElement = memberProp.getUnderlyingAnnotation(XmlElement.class);
                  if (memberXmlElement != null)
                  {
                     if (!XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
                     {
                        memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(memberXmlElement.type());
                     }

                     if (memberNamespace == null)
                        memberNamespace = memberXmlElement.namespace();
                     memberName = memberXmlElement.name();
                  }

                  if (memberNamespace == null)
                  {
                     memberNamespace = defaultNamespace;
                  }

                  boolean isCol = false;
                  AbstractPropertyHandler memberPropertyHandler = null;
                  if (memberProp.getType().isCollection())
                  {
                     memberPropertyHandler = new CollectionPropertyHandler(memberProp, memberProp.getType());
                     isCol = true;
                     // if memberXmlElement is present then the collection item type is set explicitly
                     if (memberXmlElement == null || XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
                     {
                        JBossXmlCollection jbossXmlCollection = memberProp
                              .getUnderlyingAnnotation(JBossXmlCollection.class);
                        if (jbossXmlCollection != null)
                        {
                           memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(jbossXmlCollection.type());
                        }
                        memberTypeInfo = ((ClassInfo) memberTypeInfo).getComponentType();
                     }
                  }
                  // if it is bound with XmlElement.type to a collection
View Full Code Here

      {
         if (trace)
            log.trace("Property " + property.getName() + " is a collection");
         localModel = createCollection(localModel);

         JBossXmlCollection xmlCol = property.getUnderlyingAnnotation(JBossXmlCollection.class);
         if (xmlCol != null)
         {
            // this is the type that should be analyzed
            propertyType = propertyType.getTypeInfoFactory().getTypeInfo(xmlCol.type());
         }
      }
      // Is this property bound to a model group
      else if (!property.getType().isPrimitive())
      {
         ClassInfo propClassInfo = (ClassInfo) property.getType();

         // TODO XmlElement on this property?..
         XmlElement propXmlElement = property.getUnderlyingAnnotation(XmlElement.class);
         if (propXmlElement != null)
         {
            propClassInfo = (ClassInfo) propClassInfo.getTypeInfoFactory().getTypeInfo(propXmlElement.type());
         }

         JBossXmlModelGroup xmlModelGroup = propClassInfo.getUnderlyingAnnotation(JBossXmlModelGroup.class);
         if (xmlModelGroup != null && xmlModelGroup.particles().length == 0)
         {
            if (trace)
               log.trace("Property " + property.getName() + " is bound to " + xmlModelGroup.kind());

            ModelGroupBinding propertyGroup = null;
            QName groupName = null;
            if (!JBossXmlConstants.DEFAULT.equals(xmlModelGroup.name()))
               groupName = new QName(xmlModelGroup.name());

            if (groupName != null)
               propertyGroup = schemaBinding.getGroup(groupName);

            if (propertyGroup == null)
            {
               if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_SEQUENCE))
               {
                  propertyGroup = new SequenceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_CHOICE))
               {
                  propertyGroup = new ChoiceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_ALL))
               {
                  propertyGroup = new AllBinding(schemaBinding);
               }
               else
               {
                  throw new IllegalStateException("Unexpected JBossXmlModelGroup.kind=" + xmlModelGroup.kind());
               }

               if (groupName != null)
               {
                  // TODO what if it doesn't have a name? should an artificial one be created?
                  propertyGroup.setQName(groupName);
                  schemaBinding.addGroup(propertyGroup.getQName(), propertyGroup);
               }

               propertyGroup.setSkip(Boolean.FALSE);

               // handler for the model group members
               BeanInfo propBeanInfo = JBossXBBuilder.configuration.getBeanInfo(propClassInfo);
               BeanAdapterFactory propBeanAdapterFactory = null;
               try
               {
                  // TODO this has to use its own adapter class and the factory method
                  BeanInfo propBeanAdapterBuilderInfo = JBossXBBuilder.configuration
                        .getBeanInfo(DefaultBeanAdapterBuilder.class);
                  BeanAdapterBuilder propBeanAdapterBuilder = (BeanAdapterBuilder) propBeanAdapterBuilderInfo
                        .newInstance();
                  propBeanAdapterFactory = propBeanAdapterBuilder.newFactory(propBeanInfo, null);
               }
               catch (Throwable t)
               {
                  throw new RuntimeException("Error creating BeanAdapterFactory for "
                        + DefaultBeanAdapterBuilder.class.getName(), t);
               }
               BeanHandler propHandler = new BeanHandler(propBeanInfo.getName(), propBeanAdapterFactory);
               propertyGroup.setHandler(propHandler);

               String[] memberOrder = xmlModelGroup.propOrder();
               if (memberOrder.length == 0 || memberOrder[0].length() == 0)
               {
                  List<String> propNames = new ArrayList<String>();
                  for (PropertyInfo prop : propBeanInfo.getProperties())
                  {
                     propNames.add(prop.getName());
                  }
                  memberOrder = propNames.toArray(new String[propNames.size()]);
               }

               if (trace)
                  log.trace("Property order for " + xmlModelGroup.kind() + " property " + property.getName() + ": "
                        + Arrays.asList(memberOrder));

               // bind model group members
               for (String memberPropName : memberOrder)
               {
                  if ("class".equals(memberPropName))
                  {
                     continue;
                  }

                  PropertyInfo memberProp = propBeanInfo.getProperty(memberPropName);
                  TypeInfo memberTypeInfo = memberProp.getType();
                  String memberNamespace = null;

                  JBossXmlNsPrefix nsPrefix = memberProp.getUnderlyingAnnotation(JBossXmlNsPrefix.class);
                  if (nsPrefix != null)
                  {
                     memberNamespace = schemaBinding.getNamespace(nsPrefix.prefix());
                     if (memberNamespace == null && nsPrefix.schemaTargetIfNotMapped())
                     {
                        throw new IllegalStateException("Prefix '" + nsPrefix.prefix()
                              + "' is not mapped to any namespace!");
                     }
                  }

                  String memberName = null;
                  XmlElement memberXmlElement = memberProp.getUnderlyingAnnotation(XmlElement.class);
                  if (memberXmlElement != null)
                  {
                     if (!XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
                     {
                        memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(memberXmlElement.type());
                     }

                     if (memberNamespace == null)
                        memberNamespace = memberXmlElement.namespace();
                     memberName = memberXmlElement.name();
                  }

                  if (memberNamespace == null)
                  {
                     memberNamespace = defaultNamespace;
                  }

                  boolean isCol = false;
                  AbstractPropertyHandler memberPropertyHandler = null;
                  if (memberProp.getType().isCollection())
                  {
                     memberPropertyHandler = new CollectionPropertyHandler(memberProp, memberProp.getType());
                     isCol = true;
                     // if memberXmlElement is present then the collection item type is set explicitly
                     if (memberXmlElement == null || XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
                     {
                        JBossXmlCollection jbossXmlCollection = memberProp
                              .getUnderlyingAnnotation(JBossXmlCollection.class);
                        if (jbossXmlCollection != null)
                        {
                           memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(jbossXmlCollection.type());
                        }
                        memberTypeInfo = findComponentType((ClassInfo) memberTypeInfo);
                     }
                  }
                  // if it is bound with XmlElement.type to a collection
View Full Code Here

   public CollectionPropertyHandler(PropertyInfo propertyInfo, TypeInfo propertyType)
   {
      super(propertyInfo, propertyType);

      ClassInfo collectionType = null;
      JBossXmlCollection xmlCol = propertyInfo.getUnderlyingAnnotation(JBossXmlCollection.class);
      if (xmlCol != null)
      {
         collectionType = (ClassInfo) propertyType.getTypeInfoFactory().getTypeInfo(xmlCol.type());
      }
      else if (!Modifier.isAbstract(((ClassInfo) propertyType).getModifiers()))
      {
         collectionType = (ClassInfo) propertyType;
      }
View Full Code Here

/*      */     {
/* 1222 */       if (this.trace)
/* 1223 */         log.trace("Property " + property.getName() + " is a collection");
/* 1224 */       localModel = createCollection(localModel);
/*      */
/* 1226 */       JBossXmlCollection xmlCol = (JBossXmlCollection)property.getUnderlyingAnnotation(JBossXmlCollection.class);
/* 1227 */       if (xmlCol != null)
/*      */       {
/* 1230 */         propertyType = propertyType.getTypeInfoFactory().getTypeInfo(xmlCol.type());
/*      */       }
/*      */
/*      */     }
/* 1234 */     else if (!property.getType().isPrimitive())
/*      */     {
/* 1236 */       ClassInfo propClassInfo = (ClassInfo)property.getType();
/*      */
/* 1239 */       XmlElement propXmlElement = (XmlElement)property.getUnderlyingAnnotation(XmlElement.class);
/* 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);
/*      */               }
/*      */
/*      */             }
View Full Code Here

/*     */   public CollectionPropertyHandler(PropertyInfo propertyInfo, TypeInfo propertyType)
/*     */   {
/*  58 */     super(propertyInfo, propertyType);
/*     */
/*  60 */     ClassInfo collectionType = null;
/*  61 */     JBossXmlCollection xmlCol = (JBossXmlCollection)propertyInfo.getUnderlyingAnnotation(JBossXmlCollection.class);
/*  62 */     if (xmlCol != null)
/*     */     {
/*  64 */       collectionType = (ClassInfo)propertyType.getTypeInfoFactory().getTypeInfo(xmlCol.type());
/*     */     }
/*  66 */     else if (!Modifier.isAbstract(((ClassInfo)propertyType).getModifiers()))
/*     */     {
/*  68 */       collectionType = (ClassInfo)propertyType;
/*     */     }
View Full Code Here

      super(propertyInfo, propertyType);

      componentType = ((ClassInfo) propertyType).getComponentType();

      ClassInfo collectionType = null;
      JBossXmlCollection xmlCol = propertyInfo.getUnderlyingAnnotation(JBossXmlCollection.class);
      if (xmlCol != null)
      {
         collectionType = (ClassInfo) propertyType.getTypeInfoFactory().getTypeInfo(xmlCol.type());
      }
      else if (!Modifier.isAbstract(((ClassInfo) propertyType).getModifiers()))
      {
         collectionType = (ClassInfo) propertyType;
      }
View Full Code Here

TOP

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

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.