Package org.jboss.xb.binding

Examples of org.jboss.xb.binding.JBossXBRuntimeException


      throw new JBossXBRuntimeException("Simple types can't have attributes.");
   }

   public void addElement(QName qName, ElementBinding binding)
   {
      throw new JBossXBRuntimeException("Simple types can't have child elements.");
   }
View Full Code Here


               getter = parentClass.getMethod("get" + baseMethodName, null);
               setter = parentClass.getMethod("set" + baseMethodName, new Class[]{getter.getReturnType()});
            }
            catch(NoSuchMethodException e1)
            {
               throw new JBossXBRuntimeException("Failed to bind attribute " +
                  attributeName +
                  ": neither field nor getter/setter were found for field " +
                  fieldName +
                  " in " +
                  parentClass
               );
            }
         }
      }

      this.field = field;
      this.getter = getter;
      this.setter = setter;

      fieldType = field == null ? (getter == null ? null : getter.getReturnType()) : field.getType();
      if(fieldType == null)
      {
         throw new JBossXBRuntimeException("Failed to bind attribute " +
            attributeName +
            " to field " +
            fieldName +
            " in " +
            parentClass +
View Full Code Here

                  break;
               case XSConstants.WILDCARD:
                  break;
               case XSConstants.MODEL_GROUP:
               default:
                  throw new JBossXBRuntimeException(
                     "For now we don't support anything but elements in global model groups"
                  );
            }

         }
View Full Code Here

            break;
         case XSTypeDefinition.COMPLEX_TYPE:
            binding = bindComplexType(doc, (XSComplexTypeDefinition)type, sharedElements);
            break;
         default:
            throw new JBossXBRuntimeException("Unexpected type category: " + type.getTypeCategory());
      }
      return binding;
   }
View Full Code Here

                        );
                     }

                     if(classMetaData != null)
                     {
                        throw new JBossXBRuntimeException("Illegal binding: both jbxb:class and jbxb:mapEntry are specified for complex type " +
                           type.getName()
                        );
                     }
                     binding.setMapEntryMetaData(mapEntryMetaData);
                  }
View Full Code Here

                  MapEntryMetaData mapEntryMetaData = appInfo.getMapEntryMetaData();
                  if(mapEntryMetaData != null)
                  {
                     if(propertyMetaData != null)
                     {
                        throw new JBossXBRuntimeException("An element can be bound either as a property or as a map" +
                           " entry but not both: " +
                           new QName(element.getNamespace(), element.getName())
                        );
                     }

                     if(log.isTraceEnabled())
                     {
                        log.trace("element name=" +
                           new QName(element.getNamespace(), element.getName()) +
                           " is bound to a map entry: impl=" +
                           mapEntryMetaData.getImpl() +
                           ", getKeyMethod=" +
                           mapEntryMetaData.getGetKeyMethod() +
                           ", setKeyMethod=" +
                           mapEntryMetaData.getSetKeyMethod() +
                           ", getValueMethod=" +
                           mapEntryMetaData.getGetValueMethod() +
                           ", setValueMethod=" +
                           mapEntryMetaData.getSetValueMethod() +
                           ", valueType=" +
                           mapEntryMetaData.getValueType() +
                           ", nonNullValue=" + mapEntryMetaData.isNonNullValue()
                        );
                     }

                     if(classMetaData != null)
                     {
                        throw new JBossXBRuntimeException("Invalid binding: both jbxb:class and jbxb:mapEntry are specified for element " +
                           new QName(element.getNamespace(), element.getName())
                        );
                     }
                     binding.setMapEntryMetaData(mapEntryMetaData);
                  }
View Full Code Here

                  field = parentType.getField(Util.xmlNameToFieldName(name.getLocalPart(), true));
                  fieldType = field.getType();
               }
               catch(NoSuchFieldException e1)
               {
                  throw new JBossXBRuntimeException("Failed to bind " + name + " to any field in " + parentType);
               }
            }
         }

         if(javaType == null)
         {
            javaType = fieldType;
         }
         else if(fieldType != null && fieldType != javaType && fieldType.isAssignableFrom(javaType))
         {
            javaType = fieldType;
         }

         if(javaType == null)
         {
            throw new JBossXBRuntimeException("Failed to bind " +
               name +
               " to any Java type: field=" +
               field +
               ", getter=" +
               getter +
               ", parent=" +
               parentType
            );
         }
         else if(Collection.class == javaType || Collection.class.isAssignableFrom(javaType))
         {
            // todo support other collections
            javaType = ArrayList.class;
         }
         else if(javaType.isInterface() || Modifier.isAbstract(javaType.getModifiers()))
         {
            throw new JBossXBRuntimeException("Failed to bind " +
               name +
               " to a non-abstract Java type: field=" +
               field +
               ", getter=" +
               getter +
View Full Code Here

                     // this one is immutable
                  }
               }
               catch(NoSuchMethodException e1)
               {
                  throw new JBossXBRuntimeException("Failed to bind " +
                     elementName +
                     " to field " +
                     fieldName +
                     " in " +
                     parentType +
                     ": neither field nor getter/setter were found."
                  );
               }
            }

            field = tmpField;
            getter = tmpGetter;
            setter = tmpSetter;
            fieldType = tmpFieldType;
         }

         if(fieldType == null)
         {
            this.javaType = javaType == null ? String.class : javaType;
         }
         else
         {
            if(javaType == null)
            {
               this.javaType = fieldType;
            }
            else if(Collection.class == fieldType ||
               Collection.class.isAssignableFrom(fieldType) ||
               fieldType.isAssignableFrom(javaType))
            {
               this.javaType = javaType;
            }
            else
            {
               throw new JBossXBRuntimeException("Failed to bind " +
                  elementName +
                  " to field " +
                  fieldName +
                  " in " +
                  parentType +
                  ": field type " + fieldType + " is not assignable from the specified Java type " + javaType
               );
            }

            if(this.javaType.isInterface() || Modifier.isAbstract(this.javaType.getModifiers()))
            {
               throw new JBossXBRuntimeException("Failed to bind " +
                  elementName +
                  " to field " +
                  fieldName +
                  " in " +
                  parentType +
View Full Code Here

                     // this one is immutable
                  }
               }
               catch(NoSuchMethodException e1)
               {
                  throw new JBossXBRuntimeException("Failed to bind value of " +
                     container.getName() +
                     " to field " +
                     fieldName +
                     " in " +
                     parentType +
                     ": neither field nor getter/setter were found."
                  );
               }
            }

            field = tmpField;
            getter = tmpGetter;
            setter = tmpSetter;
            fieldType = tmpFieldType;
         }

         if(fieldType == null)
         {
            this.javaType = javaType == null ? String.class : javaType;
         }
         else
         {
            if(javaType == null)
            {
               this.javaType = fieldType;
            }
            else if(Collection.class == fieldType ||
               Collection.class.isAssignableFrom(fieldType) ||
               fieldType.isAssignableFrom(javaType))
            {
               this.javaType = javaType;
            }
            else
            {
               throw new JBossXBRuntimeException("Failed to bind value of " +
                  container.getName() +
                  " to field " +
                  fieldName +
                  " in " +
                  parentType +
                  ": field type " + fieldType + " is not assignable from the specified Java type " + javaType
               );
            }

            if(this.javaType.isInterface() || Modifier.isAbstract(this.javaType.getModifiers()))
            {
               throw new JBossXBRuntimeException("Failed to bind value of " +
                  container.getName() +
                  " to field " +
                  fieldName +
                  " in " +
                  parentType +
View Full Code Here

      private DocumentBinding pushNewDocumentBinding(Class documentBindingClass)
      {
         if(!DocumentBinding.class.isAssignableFrom(documentBindingClass))
         {
            throw new JBossXBRuntimeException("The class must implement " + DocumentBinding.class);
         }

         DocumentBinding doc;
         try
         {
            Constructor ctor = documentBindingClass.getConstructor(new Class[]{DocumentBinding.class});
            doc = (DocumentBinding)ctor.newInstance(new Object[]{this});
            push(doc);
         }
         catch(NoSuchMethodException e)
         {
            throw new JBossXBRuntimeException(
               "The class must have a constructor with one parameter of type " + DocumentBinding.class
            );
         }
         catch(Exception e)
         {
            throw new JBossXBRuntimeException("Failed to create an instance of " +
               documentBindingClass +
               " using constructor which takes one parameter of type " +
               DocumentBinding.class +
               ": " +
               e.getMessage()
View Full Code Here

TOP

Related Classes of org.jboss.xb.binding.JBossXBRuntimeException

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.