List of usage examples for java.lang InstantiationException printStackTrace
public void printStackTrace()
From source file:io.konik.utils.RandomInvoiceGenerator.java
@SuppressWarnings({ "unchecked" }) public <T> T generate(Class<T> root) { try {//from ww w . jav a 2s. c o m return (T) populteData(root, null); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return null; }
From source file:org.exolab.castor.xml.parsing.primitive.objects.PrimitiveObjectFactory.java
/** * Looks up a handler from the map for the given type. <br> * Returns null if there isn't any suitable handler. * //from www. j a v a2s. c o m * @param type * @return a handler to instantiate the given class */ private PrimitiveObject lookupHandler(Class<?> type) { PrimitiveObject instance = null; if (type == null) { return null; } Class<? extends PrimitiveObject> result = typeHandlers.get(type); if (result == null) { result = typeHandlers.get(type.getSuperclass()); } if (result != null) { try { instance = result.newInstance(); } catch (InstantiationException e) { this.logger.error("Problem instantiating an instance of " + result.getName()); e.printStackTrace(); } catch (IllegalAccessException e) { this.logger.error("Problem accessing default constructor of " + result.getName()); e.printStackTrace(); } } return instance; }
From source file:com.kriminal.main_activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w ww . j a v a 2 s .c o m FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null) .show(); } }); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); //Set fragments Class tasksView = TasksView.class; try { tasksList = (Fragment) tasksView.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } //load list fragment Log.d(Utils.TAG, "before load fragment"); if (savedInstanceState == null) { Log.d(Utils.TAG, "Going to load fragment"); FragmentTransaction transaction = getFragmentManager().beginTransaction(); //set animations transaction.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit); // transaction.addToBackStack(null); transaction.add(R.id.container, tasksList).commit(); } // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); }
From source file:org.dkpro.bigdata.io.hadoop.MultiLineText2CASInputFormat.java
@Override public RecordReader<Text, CASWritable> getRecordReader(InputSplit split, JobConf jobConf, Reporter reporter) throws IOException { DocumentTextExtractor textConverter = null; String textConverterClass = jobConf.get("dkpro.uima.text2casinputformat.documenttextextractor"); if (textConverterClass != null) { try {// w w w .j a v a2 s . c o m textConverter = (DocumentTextExtractor) Class.forName(textConverterClass).newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } AnnotationExtractor annotationExtractor = null; String annotationExtractorClass = jobConf.get("dkpro.uima.text2casinputformat.annotationextractor"); if (annotationExtractorClass != null) { try { annotationExtractor = (AnnotationExtractor) Class.forName(annotationExtractorClass).newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } DocumentMetadataExtractor metadataConverter = null; String metadataConverterClass = jobConf.get("dkpro.uima.text2casinputformat.documentmetadataextractor"); if (metadataConverterClass != null) { try { metadataConverter = (DocumentMetadataExtractor) Class.forName(metadataConverterClass).newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } return new MultiLineText2CASRecordReader((FileSplit) split, jobConf, reporter, textConverter, annotationExtractor, metadataConverter); }
From source file:org.apache.horn.core.AbstractNeuralNetwork.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override// w ww.j a v a2 s . co m public void readFields(DataInput input) throws IOException { // read model type this.modelType = WritableUtils.readString(input); // read learning rate this.learningRate = input.readFloat(); // read model path this.modelPath = WritableUtils.readString(input); if (this.modelPath.equals("null")) { this.modelPath = null; } // read feature transformer int bytesLen = input.readInt(); byte[] featureTransformerBytes = new byte[bytesLen]; for (int i = 0; i < featureTransformerBytes.length; ++i) { featureTransformerBytes[i] = input.readByte(); } Class<? extends FloatFeatureTransformer> featureTransformerCls = (Class<? extends FloatFeatureTransformer>) SerializationUtils .deserialize(featureTransformerBytes); Constructor[] constructors = featureTransformerCls.getDeclaredConstructors(); Constructor constructor = constructors[0]; try { this.featureTransformer = (FloatFeatureTransformer) constructor.newInstance(new Object[] {}); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } }
From source file:org.apache.hama.ml.ann.NeuralNetwork.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override/*from w w w.j av a2 s . c om*/ public void readFields(DataInput input) throws IOException { // read model type this.modelType = WritableUtils.readString(input); // read learning rate this.learningRate = input.readDouble(); // read model path this.modelPath = WritableUtils.readString(input); if (this.modelPath.equals("null")) { this.modelPath = null; } // read feature transformer int bytesLen = input.readInt(); byte[] featureTransformerBytes = new byte[bytesLen]; for (int i = 0; i < featureTransformerBytes.length; ++i) { featureTransformerBytes[i] = input.readByte(); } Class<? extends FeatureTransformer> featureTransformerCls = (Class<? extends FeatureTransformer>) SerializationUtils .deserialize(featureTransformerBytes); Constructor[] constructors = featureTransformerCls.getDeclaredConstructors(); Constructor constructor = constructors[0]; try { this.featureTransformer = (FeatureTransformer) constructor.newInstance(new Object[] {}); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } }
From source file:com.intel.hadoop.graphbuilder.partition.mapreduce.edge.EdgeIngressMR.java
/** * Set the intermediate key value class. * //www. j a va 2 s .com * @param keyClass * @param valClass */ public void setKeyValueClass(Class keyClass, Class valClass) { try { this.mapkeytype = (IngressKeyType) keyClass.newInstance(); this.mapvaltype = (IngressValueType) valClass.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:com.intel.hadoop.graphbuilder.partition.mapreduce.edge.EdgeIngressMR.java
/** * Set the parser class./*from w ww . j a v a 2 s . c om*/ * * @param parser */ public void setParser(Class graphparser, Class vidparser, Class vdataparser, Class edataparser) { try { this.graphparser = (GraphParser) graphparser.newInstance(); this.vidparser = (FieldParser) vidparser.newInstance(); this.vdataparser = (FieldParser) vdataparser.newInstance(); this.edataparser = (FieldParser) edataparser.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); LOG.fatal("Parser classes: \n" + graphparser + "\n" + vidparser + "\n" + vdataparser + "\n" + edataparser + " do not exist."); } catch (IllegalAccessException e) { e.printStackTrace(); LOG.fatal("Parser classes: \n" + graphparser + "\n" + vidparser + "\n" + vdataparser + "\n" + edataparser + " do not exist."); } }
From source file:org.onecmdb.core.utils.transform.jdbc.JDBCDataSourceWrapper.java
public void setupDataSource(Properties p) throws IOException { // Load this under the provieded DriverLib class path. URLClassLoader loader = new URLClassLoader(getDriverLibURL(), this.getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(loader); try {/*from ww w . j a v a2s . c o m*/ Class driver = loader.loadClass(p.getProperty("jdbc.driverClass")); try { Object instance = driver.newInstance(); System.out.println("Instance...." + instance); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } /* Class cl = null; String clazz = "org.apache.commons.dbcp.BasicDataSource"; try { cl = loader.loadClass(clazz); } catch (ClassNotFoundException e) { throw new IOException("Can't load class '" + clazz + "', using driver lib '" + driverLib + "'"); } BasicDataSource jdbcSrc; try { jdbcSrc = (BasicDataSource) cl.newInstance(); } catch (Exception e) { throw new IOException("Can't instanciate class '" + clazz + "', using driver lib '" + driverLib + "'"); } */ ClassLoaderBasicDataSource jdbcSrc = new ClassLoaderBasicDataSource(); jdbcSrc.setDriverClassLoader(loader); jdbcSrc.setUrl(p.getProperty("db.url")); jdbcSrc.setUrl(p.getProperty("jdbc.url")); jdbcSrc.setDriverClassName(p.getProperty("db.driverClass")); jdbcSrc.setDriverClassName(p.getProperty("jdbc.driverClass")); jdbcSrc.setUsername(p.getProperty("db.user")); jdbcSrc.setUsername(p.getProperty("jdbc.user")); jdbcSrc.setPassword(p.getProperty("db.password")); jdbcSrc.setPassword(p.getProperty("jdbc.password")); /* String clazz2 = "org.onecmdb.core.utils.transform.jdbc.ClassLoaderBasicDataSource"; try { cl = loader.loadClass(clazz2); } catch (ClassNotFoundException e) { throw new IOException("Can't load class '" + clazz + "', using driver lib '" + driverLib + "'"); } ClassLoaderBasicDataSource jdbcSrc1; try { jdbcSrc1 = (ClassLoaderBasicDataSource) cl.newInstance(); jdbcSrc1.setDs(jdbcSrc); } catch (Exception e) { throw new IOException("Can't instanciate class '" + clazz + "', using driver lib '" + driverLib + "'"); } */ setDataSource(jdbcSrc); }
From source file:net.reichholf.dreamdroid.activities.SimpleFragmentActivity.java
private void initViews(boolean initFragment) { setContentView(R.layout.simple_layout); if (initFragment) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); if (mFragment == null) { Fragment f = null;/*www . j av a2 s . c om*/ @SuppressWarnings("unchecked") Class<Fragment> c = (Class<Fragment>) getIntent().getExtras().get("fragmentClass"); Bundle args = new Bundle(); try { f = c.newInstance(); args.putAll(getIntent().getExtras()); f.setArguments(args); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } mFragment = f; } mCallBackHandler = null; ft.replace(R.id.content, mFragment, "fragment"); ft.commit(); } }