Examples of Constructor


Examples of java.lang.reflect.Constructor

        List extensions = childElement.elements(QName.get(name, namespace));
        if (!extensions.isEmpty()) {
            Class extensionClass = PacketExtension.getExtensionClass(name, namespace);
            if (extensionClass != null) {
                try {
                    Constructor constructor = extensionClass.getDeclaredConstructor(new Class[]{
                        Element.class});
                    return (PacketExtension) constructor.newInstance(new Object[]{
                        extensions.get(0)});
                }
                catch (Exception e) {
                }
            }
View Full Code Here

Examples of java.lang.reflect.Constructor

      if( soughtClass == null ) {
         return null;
      }

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

         throw e;
      }

      Object gradleRunner = constructor.newInstance( gradleHomeDirectory, interaction );

      return (GradleRunnerVersion1) gradleRunner;
   }
View Full Code Here

Examples of java.lang.reflect.Constructor

    Object[] args = records.get(0);
    Class parameterTypes[] = new Class[args.length];
    for (int i = 0; i < args.length; i++) {
      parameterTypes[i] = args[i].getClass();
    }
    Constructor constructor = ConstructorUtils.getAccessibleConstructor(clz, parameterTypes);
    if (constructor == null) {
      String message = "找不到适合的构造方法:" + clz.getName() + "(" + StringUtils.join(parameterTypes, ", ") + ")";
      log.error(message);
      throw new IllegalArgumentException(message);
    }
    for (Object[] parameters : records) {
      try {
        result.add(constructor.newInstance(parameters));
      } catch (Exception e) {
        log.error("无法构建投影类型对象", e.getCause()); // 不应该出现该错误
      }
    }
    return result;
View Full Code Here

Examples of java.lang.reflect.Constructor

    Object[] args = records.get(0);
    Class parameterTypes[] = new Class[args.length];
    for (int i = 0; i < args.length; i++) {
      parameterTypes[i] = args[i].getClass();
    }
    Constructor constructor = ConstructorUtils.getAccessibleConstructor(clz, parameterTypes);
    if (constructor == null) {
      String message = "找不到适合的构造方法:" + clz.getName() + "(" + StringUtils.join(parameterTypes, ", ") + ")";
      log.error(message);
      throw new IllegalArgumentException(message);
    }
    for (Object[] parameters : records) {
      try {
        result.add(constructor.newInstance(parameters));
      } catch (Exception e) {
        log.error("无法构建投影类型对象", e.getCause()); // 不应该出现该错误
      }
    }
    return result;
View Full Code Here

Examples of java.lang.reflect.Constructor

    Widget widget = null;
    String widgetClass = widgetNode.getAttribute("class");
    String widgetName = widgetNode.getAttribute("name");
    String widgetPreset = widgetNode.getAttribute("preset");
    boolean hasPreset = !widgetPreset.equals("");
    Constructor widgetConstructor = (Constructor) constructorCache.get(widgetClass + (hasPreset ? "_P" : ""));
    NodeList childNodes = widgetNode.getChildNodes();

    try {
      try {
        if (widgetConstructor == null) {
          String classAttribute = widgetNode.getAttribute("class");
          String className = DEFAULT_PREFIX + classAttribute;
          if (classAttribute.indexOf('.') != -1)
            className = classAttribute;
 
          Class wClass = Class.forName(className);
          if (hasPreset)
            widgetConstructor = wClass.getConstructor(new Class[] { Widget.class, String.class, String.class });
          else
            widgetConstructor = wClass.getConstructor(new Class[] { Widget.class, String.class });
          constructorCache.put(widgetClass + (hasPreset ? "_P" : ""), widgetConstructor);
        }
        if (hasPreset)
          widget =
            (Widget) widgetConstructor.newInstance(
              new Object[] { parentWidget, widgetName.equals("") ? null : widgetName, widgetPreset });
        else
          widget =
            (Widget) widgetConstructor.newInstance(
              new Object[] { parentWidget, widgetName.equals("") ? null : widgetName });
      } catch (ClassNotFoundException e) {
        throw new GUIException("Unknown widget class [" + widgetNode.getAttribute("class") + "]");
      } catch (NoSuchMethodException e) {
        throw new GUIException("Widget constructor not found", e);
View Full Code Here

Examples of java.lang.reflect.Constructor

                        NameConverter prior = outer.getNameConverter();
                        if (prior != null) {
                           
                            // try to create instance of new converter passing old converter
                            try {
                                Constructor cons = clas.getConstructor(new Class[] { prior.getClass() });
                                try {
                                    return cons.newInstance(new Object[] { prior });
                                } catch (IllegalArgumentException e) { /* ignore failure */
                                } catch (InvocationTargetException e) {
                                    vctx.addWarning("Failed passing existing name converter to constructor for class " +
                                        cname + ": " + e.getMessage(), new ProblemLocation(ctx));
                                }
View Full Code Here

Examples of java.lang.reflect.Constructor

    // In the future, this class may do some logic to find out available
    // startup classes and pick one (like the uis one does)
    try {
      final Class startupClass = Class.forName("org.gudy.azureus2.ui.swt.Main");

      final Constructor constructor = startupClass.getConstructor(new Class[] {
        String[].class
      });
     
      constructor.newInstance(new Object[] {
        args
      });

    } catch (Exception e) {
      // TODO Auto-generated catch block
View Full Code Here

Examples of java.lang.reflect.Constructor

    {
      throw new ObjectFactoryException("The Object is null.");
    }
    try
    {
      final Constructor c = o.getClass().getConstructor(ClassLoaderObjectDescription.EMPTY_PARAMS);
      if (!Modifier.isPublic(c.getModifiers()))
      {
        throw new ObjectFactoryException
            ("The given object has no public default constructor. [" + o.getClass() + ']');
      }
      setParameter("class", o.getClass().getName());
View Full Code Here

Examples of java.lang.reflect.Constructor

    public static String dumpConstructors(Class classInQuestion) {
        StringBuilder builder = new StringBuilder();
        Constructor[] constructors = classInQuestion.getConstructors();
        for (int index = 0; index < constructors.length; index++) {
            Constructor constructor = constructors[index];
            builder.append(constructor).append('\n');
        }

        return builder.toString();
    }
View Full Code Here

Examples of java.lang.reflect.Constructor

      {
         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
TOP
Copyright © 2018 www.massapi.com. 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.