Package org.jboss.reflect.spi

Examples of org.jboss.reflect.spi.TypeInfo


      return result;
   }

   public TypeInfo getTypeInfo(Class clazz)
   {
      TypeInfo primitive = PrimitiveInfo.valueOf(clazz.getName());
      if (primitive != null)
         return primitive;
     
      return (TypeInfo) get(clazz);
   }
View Full Code Here


   // ClassAdapterFactory implementation ----------------------------

   public ClassAdapter getClassAdapter(Class clazz)
   {
      TypeInfo typeInfo = typeInfoFactory.getTypeInfo(clazz);
      return createClassAdapter(typeInfo);
   }
View Full Code Here

      return createClassAdapter(typeInfo);
   }
  
   public ClassAdapter getClassAdapter(String name, ClassLoader cl) throws ClassNotFoundException
   {
      TypeInfo typeInfo = typeInfoFactory.getTypeInfo(name, cl);
      return createClassAdapter(typeInfo);
   }
View Full Code Here

   {
      Collection result = (Collection) getCollectionInstance(info, cl, Collection.class);
      if (result == null)
         result = (Collection) getDefaultCollectionInstance();

      TypeInfo elementTypeInfo = getElementClassInfo(cl);

      for (int i = 0; i < collection.size(); ++i)
      {
         ValueMetaData vmd = (ValueMetaData) collection.get(i);
         result.add(vmd.getValue(elementTypeInfo, cl));
View Full Code Here

    * @return the class instance
    * @throws Throwable for any error
    */
   protected Object getCollectionInstance(TypeInfo info, ClassLoader cl, Class expected) throws Throwable
   {
      TypeInfo typeInfo = getClassInfo(cl);
     
      if (typeInfo != null && typeInfo instanceof ClassInfo == false)
         throw new IllegalArgumentException(typeInfo.getName() + " is not a class");
     
      if (typeInfo != null && ((ClassInfo) typeInfo).isInterface())
         throw new IllegalArgumentException(typeInfo.getName() + " is an interface");

      if (typeInfo == null)
      {
         // No type specified
         if (info == null)
            return null;
         // Not a class
         if (info instanceof ClassInfo == false)
            return null;
         // Not an interface
         if (((ClassInfo) info).isInterface())
            return null;
         // Type is too general
         if (Object.class.getName().equals(info.getName()))
            return null;
         // Try to use the passed type
         typeInfo = info;
      }
     
      BeanInfo beanInfo = configurator.getBeanInfo(typeInfo.getType());
      Joinpoint constructor = configurator.getConstructorJoinPoint(beanInfo);
      Object result = constructor.dispatch();
      if (expected.isAssignableFrom(result.getClass()) == false)
         throw new ClassCastException(result.getClass() + " is not a " + expected.getName());
      return result;
View Full Code Here

   public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
   {
      Collection result = (Collection) super.getValue(info, cl);

      TypeInfo typeInfo = getClassInfo(cl);
     
      if (typeInfo != null && typeInfo instanceof ClassInfo == false)
         throw new IllegalArgumentException(typeInfo.getName() + " is not a class");

      if (typeInfo == null)
      {
         // No type specified
         if (info == null)
            return null;
         // Not a class
         if (info instanceof ClassInfo == false)
            return null;
         // Not an interface
         if (((ClassInfo) info).isInterface())
            return null;
         // Type is too general
         if (Object.class.getName().equals(info.getName()))
            return null;
         // Try to use the passed type
         typeInfo = info;
      }
     
      Object[] array = new Object[result.size()];
      if (typeInfo != null)
      {
         Class clazz = typeInfo.getType();
         if (clazz != null)
         {
            if (clazz.isArray() == false)
               throw new ClassCastException(clazz + " is not an array.");
            array = (Object[]) Array.newInstance(clazz.getComponentType(), result.size());
View Full Code Here

   {
      boolean trace = log.isTraceEnabled();
      if (trace)
         log.trace("getValue value=" + value + " type=" + type + " info=" + info);
     
      TypeInfo typeInfo = getClassInfo(cl);
      if (typeInfo == null)
         typeInfo = info;
      if (typeInfo == null)
         throw new IllegalArgumentException("Unable to determine type for value: " + value);
        
      Class clazz = typeInfo.getType();
      PropertyEditor editor = PropertyEditorManager.findEditor(clazz);
      if (editor != null)
      {
         editor.setAsText((String) value);
         return editor.getValue();
View Full Code Here

   {
      Map result = (Map) getMapInstance(info, cl, Map.class);
      if (result == null)
         result = (Map) getDefaultMapInstance();

      TypeInfo keyTypeInfo = getKeyClassInfo(cl);
      TypeInfo valueTypeInfo = getValueClassInfo(cl);

      if (map.size() > 0)
      {
         for (Iterator i = map.entrySet().iterator(); i.hasNext();)
         {
View Full Code Here

    * @return the class instance
    * @throws Throwable for any error
    */
   protected Object getMapInstance(TypeInfo info, ClassLoader cl, Class expected) throws Throwable
   {
      TypeInfo typeInfo = getClassInfo(cl);

      if (typeInfo != null && typeInfo instanceof ClassInfo == false)
         throw new IllegalArgumentException(typeInfo.getName() + " is not a class");

      if (typeInfo != null && ((ClassInfo) typeInfo).isInterface())
         throw new IllegalArgumentException(typeInfo.getName() + " is an interface");

      if (typeInfo == null)
      {
         // No type specified
         if (info == null)
            return null;
         // Not a class
         if (info instanceof ClassInfo == false)
            return null;
         // Not an interface
         if (((ClassInfo) info).isInterface())
            return null;
         // Type is too general
         if (Object.class.getName().equals(info.getName()))
            return null;
         // Try to use the passed type
         typeInfo = info;
      }

      BeanInfo beanInfo = configurator.getBeanInfo(typeInfo.getType());
      Joinpoint constructor = configurator.getConstructorJoinPoint(beanInfo);
      Object result = constructor.dispatch();
      if (expected.isAssignableFrom(result.getClass()) == false)
         throw new ClassCastException(result.getClass() + " is not a " + expected.getName());
      return result;
View Full Code Here

   }

   protected ClassInfo getClassInfo(Class clazz)
   {
      IntrospectionTypeInfoFactory factory = new IntrospectionTypeInfoFactory();
      TypeInfo info = factory.getTypeInfo(clazz);
      assertNotNull(info);
      assertTrue(info instanceof ClassInfo);
      ClassInfo cinfo = (ClassInfo) info;
      getLog().debug(cinfo);
      return cinfo;
View Full Code Here

TOP

Related Classes of org.jboss.reflect.spi.TypeInfo

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.