Examples of Constructor


Examples of java.lang.reflect.Constructor

      }

      final Constructor[] methods = c.getConstructors();
      for (int i = 0; i < methods.length; i++)
      {
        final Constructor method = methods[i];
        if (Modifier.isPublic(method.getModifiers()) == false)
        {
          continue;
        }
        if (method.getParameterTypes().length != paramCount)
        {
          continue;
        }
        return method;
      }
View Full Code Here

Examples of java.lang.reflect.Constructor

        Class lnfClass = Class.forName(clazz);

        Method method = lnfClass.getMethod("setProperty", new Class[] { String.class, String.class });
        method.invoke(null, new Object[] { "alloy.licenseCode", licenseCode });

        Constructor constructor =
          lnfClass.getConstructor(new Class[] { Class.forName("com.incors.plaf.alloy.AlloyTheme")});
        LookAndFeel lnfInstance =
          (LookAndFeel) constructor.newInstance(new Object[] { Class.forName(themeClass).newInstance()});

        return lnfInstance;
      } catch (Exception e) {
        throw new GUIException("Error while setting theme", e);
      }
View Full Code Here

Examples of java.lang.reflect.Constructor

    throws GUIException {
    try {
      if (className.indexOf('.') == -1)
        className = WidgetFactory.DEFAULT_PREFIX + className;
      Class wClass = Class.forName(className);
      Constructor widgetConstructor = null;
      Widget widget = null;
      if (preset != null)
        widgetConstructor = wClass.getConstructor(new Class[] { Widget.class, String.class, String.class });
      else
        widgetConstructor = wClass.getConstructor(new Class[] { Widget.class, String.class });
      if (preset != null)
        widget = (Widget) widgetConstructor.newInstance(new Object[] { parentWidget, widgetName, preset });
      else
        widget = (Widget) widgetConstructor.newInstance(new Object[] { parentWidget, widgetName });

      widget.setDataModel(debuggingMapDataModel);

      return widget;
    } catch (ClassNotFoundException e) {
View Full Code Here

Examples of java.lang.reflect.Constructor

            }
            break;
        case MRJ_3_0:
            try {
                Class linker = Class.forName("com.apple.mrj.jdirect.Linker");
                Constructor constructor = linker.getConstructor(new Class[]{ Class.class });
                /*linkage = */constructor.newInstance(new Object[] { BrowserLauncher.class });
            } catch (ClassNotFoundException cnfe) {
                errorMessage = cnfe.getMessage();
                return false;
            } catch (NoSuchMethodException nsme) {
                errorMessage = nsme.getMessage();
View Full Code Here

Examples of java.lang.reflect.Constructor

   
    private static transient ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
    private static transient Map constructorCache = Collections.synchronizedMap(new HashMap());

    public static Object newInstance(Class type) throws Exception {
        Constructor customConstructor = getMungedConstructor(type);
        return customConstructor.newInstance(new Object[0]);
    }
View Full Code Here

Examples of java.lang.reflect.Constructor

        return customConstructor.newInstance(new Object[0]);
    }

    private static Constructor getMungedConstructor(Class type) throws NoSuchMethodException {
        if (!constructorCache.containsKey(type)) {
            Constructor javaLangObjectConstructor = Object.class.getDeclaredConstructor(new Class[0]);
            Constructor customConstructor = reflectionFactory.newConstructorForSerialization(type, javaLangObjectConstructor);
            constructorCache.put(type, customConstructor);
        }
        return (Constructor) constructorCache.get(type);
    }
View Full Code Here

Examples of java.lang.reflect.Constructor

    }

    // Instantiate the desired CrawlableDataset.
    Class [] argTypes = { String.class, Object.class };
    Object [] args = { path, configObj };
    Constructor constructor = crDsClass.getDeclaredConstructor( argTypes );

    try
    {
      return (CrawlableDataset) constructor.newInstance( args );
    }
    catch ( InvocationTargetException e )
    {
      if ( IOException.class.isAssignableFrom( e.getCause().getClass()) )
        throw (IOException) e.getCause();
View Full Code Here

Examples of java.lang.reflect.Constructor

        if ( name.indexOf("."== -1 ) {
            name = "org.jzonic.jlo.handler."+name;
        }
        try {
            Class c = Class.forName(name);
            Constructor con = c.getDeclaredConstructor(new Class[]{String.class});
            Handler hndl = (Handler)con.newInstance(new Object[]{new String(configurationName)});
            return hndl;
        } catch (Exception e) {
            ErrorHandler.reportError("Exception while instantiating the handler: " + name,e);
            return new ConsoleHandler("Default");
        }
View Full Code Here

Examples of java.lang.reflect.Constructor

        name = "org.jzonic.jlo.formatter."+name;
    }
    try {
  // now we instantiate the formatter
        Class c = Class.forName(name);
        Constructor con = c.getDeclaredConstructor(new Class[]{String.class});
        Formatter fmt = (Formatter)con.newInstance(new Object[]{new String(configurationName)});               
        return fmt;
    } catch (Exception e) {
  // something went wrong and we send it to the ErrorHandler
        ErrorHandler.reportError("Exception while instantiating the formatter: " + name, e);
        return new SimpleFormatter("Default");
View Full Code Here

Examples of java.lang.reflect.Constructor

    for(int i = 0; i < DEFAULT_CONTRIBUTORS.length; i++)
    {
      try
      {
        Class saveContribClass = JRClassLoader.loadClassForName(DEFAULT_CONTRIBUTORS[i]);
        Constructor constructor = saveContribClass.getConstructor(new Class[]{Locale.class, ResourceBundle.class});
        JRSaveContributor saveContrib = (JRSaveContributor)constructor.newInstance(new Object[]{getLocale(), viewerContext.getResourceBundle()});
        saveContributors.add(saveContrib);
      }
      catch (Exception e)
      {
      }
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.