Package org.jboss.xb.binding

Examples of org.jboss.xb.binding.JBossXBRuntimeException


      {
         getKeyMethod = cls.getMethod(getMethodName, null);
      }
      catch(NoSuchMethodException e)
      {
         throw new JBossXBRuntimeException("Method " + getMethodName + " not found in " + cls);
      }

      Method setKeyMethod;
      try
      {
         setKeyMethod = cls.getMethod(setMethodName, new Class[]{getKeyMethod.getReturnType()});
      }
      catch(NoSuchMethodException e)
      {
         throw new JBossXBRuntimeException("Method " +
            setMethodName +
            "(" +
            getKeyMethod.getReturnType().getName() +
            " p) not found in " +
            cls
View Full Code Here


                  schema != null &&
                  schema.isStrictSchema()
                  // todo this isSkip() doesn't look nice here
                  && !element.isSkip())
               {
                  throw new JBossXBRuntimeException("Element " +
                     endName +
                     " with type binding " +
                     type.getQName() +
                     " does not include text content binding: " + dataContent
                  );
View Full Code Here

               "annonymous" :
               element.getType().getQName().toString()
               ) +
               " type.";
         }
         throw new JBossXBRuntimeException(msg);
      }
      return mapEntryMetaData;
   }
View Full Code Here

      else
      {
         Constructor[] ctors = cls.getConstructors();
         if(ctors.length == 0)
         {
            throw new JBossXBRuntimeException(
               "Class " + cls.getName() + " has no public constructors or the class reflects a primitive type or void"
            );
         }

         if(useNoArgCtorIfFound)
         {
            try
            {
               Constructor ctor = cls.getConstructor(null);
               o = ctor.newInstance(null);
            }
            catch(NoSuchMethodException e)
            {
               o = new ValueListInitializer().newValueList(ValueListHandler.NON_DEFAULT_CTOR, cls);
            }
            catch(Exception e)
            {
               throw new JBossXBRuntimeException("Failed to create an instance of " +
                  cls +
                  " using default constructor for element " +
                  elementName + ": " + e.getMessage(), e
               );
            }
         }
         else if(ctors.length > 1 || ctors[0].getParameterTypes().length > 0)
         {
            o = new ValueListInitializer().newValueList(ValueListHandler.NON_DEFAULT_CTOR, cls);
         }
         else
         {
            try
            {
               o = ctors[0].newInstance(null);
            }
            catch(Exception e)
            {
               throw new JBossXBRuntimeException("Failed to create an instance of " +
                  cls +
                  " using default constructor for element " +
                  elementName + ": " + e.getMessage(), e
               );
            }
View Full Code Here

                                         boolean ignoreCNFE,
                                         QName elementName)
   {
      if(className == null)
      {
         throw new JBossXBRuntimeException("No class for " + elementName);
      }

      Class cls = null;
      try
      {
         cls = Thread.currentThread().getContextClassLoader().loadClass(className);
      }
      catch(ClassNotFoundException e)
      {
         if(ignoreCNFE)
         {
            if(log.isTraceEnabled())
            {
               log.trace("Failed to resolve class for element " +
                  elementName +
                  ": " +
                  className
               );
            }
         }
         else
         {
            throw new JBossXBRuntimeException("Failed to resolve class name for " +
               elementName +
               ": " +
               e.getMessage()
            );
         }
View Full Code Here

            valueType = Thread.currentThread().getContextClassLoader().
               loadClass(addMethodMetaData.getValueType());
         }
         catch(ClassNotFoundException e)
         {
            throw new JBossXBRuntimeException("Failed to load value type for addMethod.name=" +
               addMethodMetaData.getMethodName() +
               ", valueType=" +
               addMethodMetaData.getValueType() +
               ": " + e.getMessage(), e
            );
         }
      }
      else if(addMethodMetaData.isChildType())
      {
         if(o == null)
         {
            throw new JBossXBRuntimeException("addMethod=" +
               addMethodMetaData.getMethodName() +
               " for element " +
               qName +
               " is configured with valueType='child'. The valueType cannot be determined because" +
               " the child is null"
            );
         }
         valueType = o.getClass();
      }

      Class ownerClass = owner.getClass();
      Method addMethod;
      try
      {
         addMethod = ownerClass.getMethod(addMethodMetaData.getMethodName(), new Class[]{valueType});
      }
      catch(NoSuchMethodException e)
      {
         throw new JBossXBRuntimeException("Failed to find addMethod.name=" +
            addMethodMetaData.getMethodName() +
            ", addMethod.valueType=" +
            valueType.getName() +
            " in class " +
            ownerClass.getName() +
            ": " +
            e.getMessage(), e
         );
      }

      try
      {
         addMethod.invoke(owner, new Object[]{o});
      }
      catch(Exception e)
      {
         throw new JBossXBRuntimeException("setParent failed for " +
            qName +
            "=" +
            o +
            ": addMethod=" +
            addMethodMetaData.getMethodName() +
View Full Code Here

      PutMethodMetaData putMethodMetaData = term.getPutMethodMetaData();

      MapEntryMetaData mapEntryMetaData = term.getMapEntryMetaData();
      if(mapEntryMetaData == null)
      {
         throw new JBossXBRuntimeException((putMethodMetaData == null ?
            "Parent object is an instance of java.util.Map" :
            "putMethod is specified for element " + qName
            ) +
            " but mapEntry is specified for neither element " +
            qName +
            " nor it's type."
         );
      }

      Class oClass = o.getClass();
      String getKeyMethodName = mapEntryMetaData.getGetKeyMethod();
      if(getKeyMethodName == null)
      {
         getKeyMethodName = "getKey";
      }

      Method keyMethod;
      try
      {
         keyMethod = oClass.getMethod(getKeyMethodName, null);
      }
      catch(NoSuchMethodException e)
      {
         throw new JBossXBRuntimeException("setParent failed for " +
            qName +
            "=" +
            o +
            ": getKeyMethod=" +
            getKeyMethodName +
            " not found in " + oClass
         );
      }

      Object key;
      try
      {
         key = keyMethod.invoke(o, null);
      }
      catch(Exception e)
      {
         throw new JBossXBRuntimeException("setParent failed for " +
            qName +
            "=" +
            o +
            ": getKeyMethod=" +
            getKeyMethodName +
            " threw an exception: " + e.getMessage(), e
         );
      }

      Class keyType = Object.class;
      Class valueType = Object.class;
      String putMethodName = "put";
      Class ownerClass = owner.getClass();

      if(putMethodMetaData != null)
      {
         if(putMethodMetaData.getKeyType() != null)
         {
            try
            {
               keyType = Thread.currentThread().getContextClassLoader().loadClass(putMethodMetaData.getKeyType());
            }
            catch(ClassNotFoundException e)
            {
               throw new JBossXBRuntimeException("setParent failed for " + qName + ": " + e.getMessage(), e);
            }
         }

         if(putMethodMetaData.getValueType() != null)
         {
            try
            {
               valueType = Thread.currentThread().getContextClassLoader().loadClass(putMethodMetaData.getValueType());
            }
            catch(ClassNotFoundException e)
            {
               throw new JBossXBRuntimeException("setParent failed for " + qName + ": " + e.getMessage(), e);
            }
         }

         String name = putMethodMetaData.getName();
         if(name != null)
         {
            putMethodName = name;
         }
      }

      Method putMethod;
      try
      {
         putMethod = ownerClass.getMethod(putMethodName, new Class[]{keyType, valueType});
      }
      catch(NoSuchMethodException e)
      {
         throw new JBossXBRuntimeException("setParent failed for " +
            qName +
            "=" +
            o +
            ": putMethod=" +
            putMethodName +
            "(" + keyType.getName() + " key, " + valueType.getName() + " value) not found in " + ownerClass
         );
      }

      Object value = o;
      String valueMethodName = mapEntryMetaData.getGetValueMethod();
      if(valueMethodName != null)
      {
         Method valueMethod;
         try
         {
            valueMethod = oClass.getMethod(valueMethodName, null);
         }
         catch(NoSuchMethodException e)
         {
            throw new JBossXBRuntimeException("setParent failed for " +
               qName +
               "=" +
               o +
               ": getValueMethod=" +
               mapEntryMetaData.getGetValueMethod() +
               " not found in " + oClass
            );
         }

         try
         {
            value = valueMethod.invoke(o, null);
         }
         catch(Exception e)
         {
            throw new JBossXBRuntimeException("setParent failed for " +
               qName +
               "=" +
               o +
               ": getValueMethod=" +
               mapEntryMetaData.getGetValueMethod() +
               " threw an exception: " + e.getMessage(), e
            );
         }
      }
      else if(o instanceof MapEntry)
      {
         value = ((MapEntry)o).getValue();
      }

      try
      {
         putMethod.invoke(owner, new Object[]{key, value});
      }
      catch(Exception e)
      {
         throw new JBossXBRuntimeException("setParent failed for " +
            qName +
            "=" +
            o +
            ": putMethod=" +
            putMethodName +
View Full Code Here

         else
         {
            TypeBinding baseType = type.getBaseType();
            if(baseType == null)
            {
               throw new JBossXBRuntimeException("Expected a base type here.");
            }

            return classForSimpleType(baseType, nillable);
         }
      }
View Full Code Here

      void reset()
      {
         if(!ended)
         {
            throw new JBossXBRuntimeException(
               "Attempt to reset a particle that has already been reset: " + particle.getTerm()
            );
         }

         ended = false;
View Full Code Here

      public void popType()
      {
         Object o = typeGroupStack.remove(typeGroupStack.size() - 1);
         if(!(o instanceof TypeBinding))
         {
            throw new JBossXBRuntimeException("Should have poped type binding but got " + o);
         }
      }
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.