Package java.lang.reflect

Examples of java.lang.reflect.Constructor$ConstructorData


      {
         return null;
      }

      //instantiate it.
      Constructor constructor = null;
      try
      {
         constructor = soughtClass.getDeclaredConstructor( SinglePaneUIInteractionVersion1.class );
      }
      catch( NoSuchMethodException e )
      {
         e.printStackTrace();
         System.out.println( "Dumping available constructors on " + soughtClass.getName() + "\n" + ExternalUtility.dumpConstructors( soughtClass ) );

         throw e;
      }
      Object singlePaneUI = constructor.newInstance( singlePaneUIArguments );
      return (SinglePaneUIVersion1) singlePaneUI;
   }
View Full Code Here


      {
         return null;
      }

      //instantiate it.
      Constructor constructor = null;
      try
      {
         constructor = soughtClass.getDeclaredConstructor( DualPaneUIInteractionVersion1.class );
      }
      catch( NoSuchMethodException e )
      {
         e.printStackTrace();
         System.out.println( "Dumping available constructors on " + soughtClass.getName() + "\n" + ExternalUtility.dumpConstructors( soughtClass ) );

         throw e;
      }
      Object gradleUI = constructor.newInstance( interaction );
      return (DualPaneUIVersion1) gradleUI;
   }
View Full Code Here

                }
                Debug.output(" - created class arguments [" + sb.toString()
                        + "]");
            }

            Constructor constructor = null;
            Object obj = null;

            try {
                constructor = newObjClass.getConstructor(argClasses);

                if (DEBUG)
                    Debug.output(" - got constructor");

                // Create component
                obj = constructor.newInstance(constructorArgs);
                if (DEBUG)
                    Debug.output(" - got object");

            } catch (NoSuchMethodException nsmei) {
                /*
 
View Full Code Here

                    + " possible constructor"
                    + (numConstructors == 1 ? "" : "s"));
        }

        for (int i = 0; i < numConstructors; i++) {
            Constructor constructor = constructors[i];

            Class[] arguments = constructor.getParameterTypes();
            int numArgs = arguments.length;

            // First, check the number of arguments for a match
            if (numArgs != numArgClasses) {
                if (DEBUG) {
                    Debug.output(" - constructor " + i + " with " + numArgs
                            + " arguments not a match");
                }

                continue; // Nope, not it.
            }

            // OK, empty constructor desired, punch...
            if (numArgs == 0) {
                if (DEBUG) {
                    Debug.output(" - constructor " + i
                            + " with no arguments is a match");
                }
                return constructor;
            }

            // Check to see if the argument classes of the Constructor
            // are
            // assignable to the desired argClasses being sought.
            boolean good = false;
            for (int j = 0; j < numArgs; j++) {
                if (arguments[j] == argClasses[j]) {
                    if (DEBUG) {
                        Debug.output(" - direct arg class match, arg " + j);
                    }
                    good = true; // Maintain true...
                } else if (arguments[j].isAssignableFrom(argClasses[j])) {

                    // Doesn't work quite yet. May have to check for
                    // super-super class,etc, and we still get an
                    // IllegalArgumentException due to argument type
                    // mismatch.

                    // Is this even necessary? Don't think so...
                    argClasses[j] = argClasses[j].getSuperclass();
                    if (DEBUG) {
                        Debug.output(" - superclass arg class match, arg " + j
                                + " reassigning to " + argClasses[j].toString());
                    }
                    good = true; // Maintain true...
                    // } else if (constructorArgs[j] instanceof
                    // Number) {
                    // if (DEBUG) {
                    // Debug.output(" - Number type match, arg " + j);
                    // }
                    // good = true; // Maintain true...

                } else {
                    if (DEBUG) {
                        Debug.output(" - arg class mismatch on arg " + j
                                + ", bailing (" + arguments[j].getName()
                                + " vs. " + argClasses[j].getName() + ")");
                    }
                    good = false; // Punch with false
                    break;
                }
            }

            if (good) {
                if (DEBUG) {
                    Debug.debugging(" - creating object");
                }
                Object obj = constructor.newInstance(constructorArgs);
                if (DEBUG) {
                    Debug.debugging(" - created object");
                }
                return obj;
            }
View Full Code Here

                            " for converting default value of type " + tname);
                    } else if (m_deserializerItem.isInitializer()) {
                       
                        // invoke constructor to process default value
                        construct = true;
                        Constructor cons = clas.getConstructor
                            (STRING_CONSTRUCTOR_ARGUMENT_CLASSES);
                        try {
                            cons.setAccessible(true);
                        } catch (Exception e) { /* deliberately left empty */ }
                        Object[] args = new Object[1];
                        args[0] = m_defaultText;
                        m_default = cons.newInstance(args);
                       
                    } else {
                       
                        // invoke deserializer to convert default value
                        String mname = m_deserializerItem.getName();
View Full Code Here

      /*
       * If Class.valueOf(String) doesn't exist, try a direct constructor
       * Class<T>(String)
       */
     
      Constructor constructor = c.getDeclaredConstructor(String.class);
      return (T)constructor.newInstance(propertyValue);
    }
    res = valueOf.invoke(/* This is a static method obj=null */null, propertyValue);
   
    return (T) res;
  }
View Full Code Here

        if (wmsLayerClass == null) {
            return new DefaultLayerAdapter(layer);
        }
        IWmsLayer wmsLayer = null;
        try {
            Constructor constructor = wmsLayerClass.getConstructor(new Class[] { Layer.class });
            wmsLayer = (IWmsLayer) constructor.newInstance(new Object[] { layer });
        } catch (Exception ex) {
            Debug.message("ms", "Problem calling constructor for class "
                    + wmsLayerClass.getName() + ":" + ex.getMessage());
        }
        if (wmsLayer == null) {
View Full Code Here

      public TableColumnCore createTableColumnCore(Class forDataSourceType,
          String tableID, String columnID) {
        cInfo info = c.get(columnID);

        try {
          Constructor constructor = info.cla.getDeclaredConstructor(new Class[] {
            String.class
          });
          TableColumnCore column = (TableColumnCore) constructor.newInstance(new Object[] {
            tableID
          });
          return column;
        } catch (Exception e) {
          Debug.out(e);
View Full Code Here

        constructorName = query.substring(0, parameterStartIdx);
      }

      try
      {
        final Constructor c = findDirectConstructor(constructorName, parameterNames.length);

        final Object[] params = new Object[parameterNames.length];
        for (int i = 0; i < parameterNames.length; i++)
        {
          final String name = parameterNames[i];
          params[i] = parameters.get(name);
        }
        return (TableModel) c.newInstance(params);
      }
      catch (Exception e)
      {
        throw new ReportDataFactoryException
            ("Unable to instantiate class for non static call.", e); //$NON-NLS-1$
View Full Code Here

    }

    // We have to find a suitable constructor ..
    final String className = query.substring(0, constParamIdx);
    final String[] parameterNames = createParameterList(constructorSpec, constParamIdx);
    final Constructor c = findIndirectConstructor(className, parameterNames.length);

    final String methodQuery = query.substring(methodSeparatorIdx + 1);
    final String[] methodParameterNames;
    final String methodName;
    final int parameterStartIdx = methodQuery.indexOf('(');
    if (parameterStartIdx == -1)
    {
      // no parameters. Nice.
      methodParameterNames = StaticDataFactory.EMPTY_PARAMS;
      methodName = methodQuery;
    }
    else
    {
      methodName = methodQuery.substring(0, parameterStartIdx);
      methodParameterNames = createParameterList(methodQuery, parameterStartIdx);
    }
    final Method m = findCallableMethod(className.trim(), methodName.trim(), methodParameterNames.length);

    try
    {
      final Object[] constrParams = new Object[parameterNames.length];
      for (int i = 0; i < parameterNames.length; i++)
      {
        final String name = parameterNames[i];
        constrParams[i] = parameters.get(name);
      }
      final Object o = c.newInstance(constrParams);

      final Object[] methodParams = new Object[methodParameterNames.length];
      for (int i = 0; i < methodParameterNames.length; i++)
      {
        final String name = methodParameterNames[i];
View Full Code Here

TOP

Related Classes of java.lang.reflect.Constructor$ConstructorData

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.