Example usage for java.lang InstantiationException printStackTrace

List of usage examples for java.lang InstantiationException printStackTrace

Introduction

In this page you can find the example usage for java.lang InstantiationException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

/**
 * This method clears backstack and loads fragment in a root.
 * //from   ww w  . ja va  2  s  .  co m
 * @param fragmentActivity
 * @param fragmentContainerId
 * @param fragmentClass
 * @param bundle
 * @param tag
 * @return true if loaded successfully, false otherwise
 */
public static boolean loadFragmentInRoot(FragmentActivity fragmentActivity, int fragmentContainerId,
        Class<? extends Fragment> fragmentClass, Bundle bundle, String tag) {
    // TODO Auto-generated method stub
    boolean status = false;

    FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager();
    // remove all fragments from back stack
    fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    // add new fragment
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out,
            android.R.anim.fade_in, android.R.anim.fade_out);
    Fragment fragment;
    try {
        fragment = fragmentClass.newInstance();
        fragment.setArguments(bundle);
        fragmentTransaction.replace(fragmentContainerId, fragment, tag).commit();
        // finish pending transactions
        fragmentManager.executePendingTransactions();
        status = true;
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return status;
}

From source file:com.fengduo.bee.commons.component.ObjectArrayDataBinder.java

@SuppressWarnings("unchecked")
public static <E> E[] createArray(Class<E> clazz, int capacity) {
    E[] array = (E[]) Array.newInstance(clazz, capacity);
    for (int i = 0; i < capacity; i++) {
        try {/*from ww w  .ja  v  a2  s.com*/
            array[i] = clazz.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    return array;
}

From source file:fr.calamus.common.db.core.DbCentralFactory.java

public static <T extends DbCentralFactory> T init(Class<T> factoryClass) {
    T db = null;/*from  w ww.  j  a  va  2s .com*/
    try {
        db = (T) factoryClass.newInstance();
        instances.put(null, db);
    } catch (InstantiationException ex) {
        ex.printStackTrace();
    } catch (IllegalAccessException ex) {
        ex.printStackTrace();
    }
    launchInstancesObserver();
    return db;
}

From source file:org.pentaho.reporting.engine.classic.core.testsupport.base.PreProcessorTestHelper.java

private static boolean validateCanInstantiate(final ReportPreProcessorMetaData metaData) {
    try {/*www . j  a  v  a2s .c om*/
        final Object type = metaData.create();
        if (type == null) {
            return true;
        }
        return false;
    } catch (InstantiationException e) {
        e.printStackTrace();
        return true;
    }
}

From source file:org.ovirt.engine.sdk.mapping.Mapper.java

/**
 * Maps model object to defined decorator
 * /* w w  w . ja  v a  2  s  .c o m*/
 * @param from
 *            model object
 * @param to
 *            decorator object
 * @param proxy
 *            HttpProxyDecorator to inject
 * 
 * @return Decorator instance
 */
@SuppressWarnings("unchecked")
public static synchronized <F, T> T map(F from, Class<T> to, HttpProxyBroker proxy) {
    T dstobj = null;
    try {
        if (proxy != null) {
            dstobj = (T) getConstracor(to).newInstance(proxy);
        } else {
            dstobj = to.newInstance();
        }
        if (dstobj != null) {
            PropertyUtils.copyProperties(dstobj, from);
            excludeExceptions(dstobj);
        }
    } catch (InstantiationException e) {
        // TODO: log error
        e.printStackTrace();
    } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
        // do nothing (PropertyUtils exceptions treatment #1007266)
    } catch (IllegalArgumentException e) {
        // TODO: log error
        e.printStackTrace();
    }

    return dstobj;
}

From source file:net.navasoft.madcoin.backend.services.controller.exception.impl.ControllerExceptionFactory.java

/**
 * Creates a new ControllerException object.
 * //w w  w.  j a va 2 s . com
 * @param expectedException
 *            the expected exception
 * @param allowedTips
 *            forwarded service tips
 * @param variables
 *            the variables
 * @return the session net.navasoft.madcoin.backend.model.controller.impl
 *         exception
 */
public static ControllerException createException(String expectedException, int allowedTips,
        ControllerExceptionArgument... variables) {
    ControllerException childMade = null;
    try {
        variables = (ControllerExceptionArgument[]) ArrayUtils.add(variables,
                new ControllerExceptionArgument(allowedTips));
        Object builtException = locator.get(expectedException)
                .getConstructor(MessageSource.class, Locale.class, ControllerExceptionArgument[].class)
                .newInstance(exceptionMessages, language, (Object) variables);
        childMade = ControllerException.class.cast(builtException);
        childMade.prepareTips(allowedTips, tips);
        childMade.formulateTips();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
    return childMade;
}

From source file:org.mule.providers.soap.axis.wsdl.wsrf.util.AdviceAdderHelper.java

/**
 * Get Advice from .aspect package and create for each Advice class instance an
 * Advisor with mapped name "*extend"./*  w  ww  . j  ava2 s.c o m*/
 * 
 * @return A List of Advisor.
 */
private static List getListAdvisorClass() {
    List advisors = new LinkedList();

    try {
        Class[] listClassAdvice = getClasses("org.mule.providers.soap.axis.wsdl.wsrf.aspect");
        Class advice = null;
        Advisor advisor = null;
        for (int i = 0; i < listClassAdvice.length; i++) {
            advice = listClassAdvice[i];
            try {

                advisor = new NameMatchMethodPointcutAdvisor((Advice) advice.newInstance());

            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            if (advisor != null) {
                ((NameMatchMethodPointcut) advisor).setMappedName(MAPPED_NAME);
                advisors.add(advisor);

            }

        }
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return advisors;
}

From source file:org.n52.oxf.ses.adapter.client.SESClient.java

public static ISESConnector getNewConnectorInstance(URL url) {
    ISESConnector inst;//from   ww  w  .  j  a va  2s  .c o  m
    try {
        inst = (ISESConnector) connectorImpl.newInstance();
    } catch (InstantiationException e) {
        e.printStackTrace();
        return null;
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        return null;
    }

    inst.setHost(url);
    inst.initialize();

    return inst;
}

From source file:org.processbase.ui.core.Constants.java

public static JdbcTemplate getJdbcTemplate(Properties properties) {
    String driver = properties.getProperty("hibernate.connection.driver_class");
    String url = properties.getProperty("hibernate.connection.url");
    String username = properties.getProperty("hibernate.connection.username");
    String password = properties.getProperty("hibernate.connection.password");
    Driver driverInstance = null;
    try {/*  w w  w  . j  a v a  2s  .co  m*/
        driverInstance = (Driver) Driver.class.forName(driver).newInstance();
        SimpleDriverDataSource dataSource = new SimpleDriverDataSource(driverInstance, url, username, password);
        return new JdbcTemplate(dataSource);

    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return null;

}

From source file:de.clusteval.data.randomizer.DataRandomizer.java

/**
 * Parses a dataconfig randomizer from string.
 * /*from   w ww. j a va 2 s .  c o m*/
 * @param repository
 *            the repository
 * @param dataRandomizer
 *            The simple name of the dataset randomizer class.
 * @return the clustering quality measure
 * @throws UnknownDataRandomizerException
 */
public static DataRandomizer parseFromString(final Repository repository, String dataRandomizer)
        throws UnknownDataRandomizerException {

    Class<? extends DataRandomizer> c = repository.getRegisteredClass(DataRandomizer.class,
            "de.clusteval.data.randomizer." + dataRandomizer);
    try {
        DataRandomizer generator = c.getConstructor(Repository.class, boolean.class, long.class, File.class)
                .newInstance(repository, false, System.currentTimeMillis(), new File(dataRandomizer));
        return generator;

    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (NullPointerException e) {

    } catch (IllegalArgumentException e1) {
        e1.printStackTrace();
    } catch (SecurityException e1) {
        e1.printStackTrace();
    } catch (InvocationTargetException e1) {
        e1.printStackTrace();
    } catch (NoSuchMethodException e1) {
        e1.printStackTrace();
    }
    throw new UnknownDataRandomizerException("\"" + dataRandomizer + "\" is not a known data randomizer.");
}