List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:com.dl2974.andgeofencedetection.MainActivity.java
/** * Called when the user clicks the "Remove geofence 2" button * @param view The view that triggered this callback *//*ww w . j a va 2 s . c om*/ public void onUnregisterGeofence2Clicked(View view) { /* * Remove the geofence by creating a List of geofences to * remove and sending it to Location Services. The List * contains the id of geofence 2, which is "2". * The removal happens asynchronously; Location Services calls * onRemoveGeofencesByPendingIntentResult() (implemented in * the current Activity) when the removal is done. */ /* * Record the removal as remove by list. If a connection error occurs, * the app can automatically restart the removal if Google Play services * can fix the error */ mRemoveType = GeofenceUtils.REMOVE_TYPE.LIST; // Create a List of 1 Geofence with the ID "2" and store it in the global list mGeofenceIdsToRemove = Collections.singletonList("2"); /* * Check for Google Play services. Do this after * setting the request type. If connecting to Google Play services * fails, onActivityResult is eventually called, and it needs to * know what type of request was in progress. */ if (!servicesConnected()) { return; } // Try to remove the geofence try { mGeofenceRemover.removeGeofencesById(mGeofenceIdsToRemove); // Catch errors with the provided geofence IDs } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (UnsupportedOperationException e) { // Notify user that previous request hasn't finished. Toast.makeText(this, R.string.remove_geofences_already_requested_error, Toast.LENGTH_LONG).show(); } }
From source file:org.mili.core.graphics.GraphicsUtilTest.java
@Test public void test_Image_readImage_File() { // negativ/* ww w . jav a 2 s . c om*/ try { GraphicsUtil.readImage(null); fail("here was null given, but method works !"); } catch (IllegalArgumentException e) { assertTrue(true); } catch (IOException e) { fail(); } try { GraphicsUtil.readImage(new File(this.dir, "/xyz/test.jpg")); fail("file not exists here, but method works !"); } catch (IOException e) { assertTrue(true); } // positiv try { Image i = GraphicsUtil.readImage(new File(this.dir, "test.jpg")); assertTrue(i != null); assertEquals(100, i.getHeight(null)); assertEquals(100, i.getWidth(null)); } catch (IOException e) { e.printStackTrace(); fail(); } return; }
From source file:cn.edu.zafu.corepage.base.BaseActivity.java
/** * ???/*from w w w .j a v a 2 s . com*/ * * @param savedInstanceState Bundle */ private void loadActivitySavedData(Bundle savedInstanceState) { Field[] fields = this.getClass().getDeclaredFields(); Field.setAccessible(fields, true); Annotation[] ans; for (Field f : fields) { ans = f.getDeclaredAnnotations(); for (Annotation an : ans) { if (an instanceof SaveWithActivity) { try { String fieldName = f.getName(); @SuppressWarnings("rawtypes") Class cls = f.getType(); if (cls == int.class || cls == Integer.class) { f.setInt(this, savedInstanceState.getInt(fieldName)); } else if (String.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getString(fieldName)); } else if (Serializable.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getSerializable(fieldName)); } else if (cls == long.class || cls == Long.class) { f.setLong(this, savedInstanceState.getLong(fieldName)); } else if (cls == short.class || cls == Short.class) { f.setShort(this, savedInstanceState.getShort(fieldName)); } else if (cls == boolean.class || cls == Boolean.class) { f.setBoolean(this, savedInstanceState.getBoolean(fieldName)); } else if (cls == byte.class || cls == Byte.class) { f.setByte(this, savedInstanceState.getByte(fieldName)); } else if (cls == char.class || cls == Character.class) { f.setChar(this, savedInstanceState.getChar(fieldName)); } else if (CharSequence.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getCharSequence(fieldName)); } else if (cls == float.class || cls == Float.class) { f.setFloat(this, savedInstanceState.getFloat(fieldName)); } else if (cls == double.class || cls == Double.class) { f.setDouble(this, savedInstanceState.getDouble(fieldName)); } else if (String[].class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getStringArray(fieldName)); } else if (Parcelable.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getParcelable(fieldName)); } else if (Bundle.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getBundle(fieldName)); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } }
From source file:com.snaptic.api.SnapticAPI.java
/** * Get notes from users account./*from ww w. j ava 2 s. c om*/ * * @param ArrayList<SnapticNote> notes reference to an array of SnapticNote where fetched * notes will be placed. * @return int returnCode enum code indicating whether call was successful or not. */ public int getNotes(ArrayList<SnapticNote> notes) { int returnCode = RESULT_ERROR; if (notes == null) { return returnCode; } String endpoint = API_ENDPOINT_NOTES + ".xml"; HttpResponse response = performGET(endpoint, null); if (response != null) { if (isResponseOK(response)) { boolean parseResult = false; try { SnapticNotesXmlParser xmlParser = new SnapticNotesXmlParser(); xmlParser.parseNotesXml(response, notes); sync_trace("parsed " + notes.size() + " notes"); parseResult = true; } catch (IllegalArgumentException e) { log("caught an IllegalArgumentException processing response from GET " + endpoint); e.printStackTrace(); } catch (XmlPullParserException e) { log("caught an XmlPullParserException processing response from GET " + endpoint); e.printStackTrace(); } catch (IOException e) { log("caught an IOException processing response from GET " + endpoint); e.printStackTrace(); } returnCode = (parseResult == true) ? RESULT_OK : RESULT_ERROR_RESPONSE; } else if (isResponseUnauthorized(response)) { returnCode = RESULT_UNAUTHORIZED; } consumeResponse(response); } return returnCode; }
From source file:com.snaptic.api.SnapticAPI.java
/** * Get notes from users account that match query string. * /* ww w .j a v a2s . c om*/ * @param String query search for notes that match this string. * @param ArrayList<SnapticNote> notes reference to an array of SnapticNote where fetched * notes will be placed. * @return int returnCode enum code indicating whether call was successful or not. * */ public int searchNotes(String query, ArrayList<SnapticNote> notes) { int returnCode = RESULT_ERROR; if (notes == null || query == null) { return returnCode; } String endpoint = API_ENDPOINT_SEARCH; List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("q", query)); HttpResponse response = performGET(endpoint, params); if (response != null) { if (isResponseOK(response)) { boolean parseResult = false; try { SnapticNotesXmlParser xmlParser = new SnapticNotesXmlParser(); xmlParser.parseNotesXml(response, notes); sync_trace("parsed " + notes.size() + " notes"); parseResult = true; } catch (IllegalArgumentException e) { log("caught an IllegalArgumentException processing response from GET " + endpoint); e.printStackTrace(); } catch (XmlPullParserException e) { log("caught an XmlPullParserException processing response from GET " + endpoint); e.printStackTrace(); } catch (IOException e) { log("caught an IOException processing response from GET " + endpoint); e.printStackTrace(); } returnCode = (parseResult == true) ? RESULT_OK : RESULT_ERROR_RESPONSE; } else if (isResponseUnauthorized(response)) { returnCode = RESULT_UNAUTHORIZED; } consumeResponse(response); } return returnCode; }
From source file:cn.edu.zafu.corepage.base.BaseActivity.java
/** * ??//from w w w . j a v a 2 s . c o m * * @param outState Bundle */ @Override protected void onSaveInstanceState(Bundle outState) { Field[] fields = this.getClass().getDeclaredFields(); Field.setAccessible(fields, true); Annotation[] ans; for (Field f : fields) { ans = f.getDeclaredAnnotations(); for (Annotation an : ans) { if (an instanceof SaveWithActivity) { try { Object o = f.get(this); if (o == null) { continue; } String fieldName = f.getName(); if (o instanceof Integer) { outState.putInt(fieldName, f.getInt(this)); } else if (o instanceof String) { outState.putString(fieldName, (String) f.get(this)); } else if (o instanceof Long) { outState.putLong(fieldName, f.getLong(this)); } else if (o instanceof Short) { outState.putShort(fieldName, f.getShort(this)); } else if (o instanceof Boolean) { outState.putBoolean(fieldName, f.getBoolean(this)); } else if (o instanceof Byte) { outState.putByte(fieldName, f.getByte(this)); } else if (o instanceof Character) { outState.putChar(fieldName, f.getChar(this)); } else if (o instanceof CharSequence) { outState.putCharSequence(fieldName, (CharSequence) f.get(this)); } else if (o instanceof Float) { outState.putFloat(fieldName, f.getFloat(this)); } else if (o instanceof Double) { outState.putDouble(fieldName, f.getDouble(this)); } else if (o instanceof String[]) { outState.putStringArray(fieldName, (String[]) f.get(this)); } else if (o instanceof Parcelable) { outState.putParcelable(fieldName, (Parcelable) f.get(this)); } else if (o instanceof Serializable) { outState.putSerializable(fieldName, (Serializable) f.get(this)); } else if (o instanceof Bundle) { outState.putBundle(fieldName, (Bundle) f.get(this)); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } super.onSaveInstanceState(outState); }
From source file:org.elasticsearch.index.mapper.attachment.AttachmentMapper.java
@Override public void parse(ParseContext context) throws IOException { System.out.println("Parse Index Request"); // byte[] content = null; String contentType = null;/*from w w w .j av a2 s . c om*/ int indexedChars = defaultIndexedChars; String name = null; Map fieldMapping = new HashMap<String, Object>(); XContentParser parser = context.parser(); //create reference //TODO Map<String, Object> parseAndChecksumResults = null; XContentParser.Token token = parser.currentToken(); try { if (token == XContentParser.Token.VALUE_STRING || token == XContentParser.Token.VALUE_EMBEDDED_OBJECT) { parseAndChecksumResults = parseAndCalculateChecksumWithThreads(parser, indexedChars); } else { String currentFieldName = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); System.out.println(currentFieldName); } else { if ("content".equals(currentFieldName)) { //for both smile and string parseAndChecksumResults = parseAndCalculateChecksumWithThreads(parser, indexedChars); } else if (isString(token) && "_content_type".equals(currentFieldName)) { contentType = parser.text(); } else if (isString(token) && "_name".equals(currentFieldName)) { name = parser.text(); } else if (token == XContentParser.Token.VALUE_NUMBER && ("_indexed_chars".equals(currentFieldName) || "_indexedChars".equals(currentFieldName))) { indexedChars = parser.intValue(); } else { logger.info("non-default mapping:" + currentFieldName); if ("content".equals(currentFieldName)) { } else { Object object = parser.objectText(); System.out.println(object); // content = parser.binaryValue(); fieldMapping.put(currentFieldName, object); } } } // Handle the mapping when doc come logger.info("fieldMapping" + fieldMapping); } } } catch (SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (NoSuchFieldException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (parseAndChecksumResults == null) { throw new IOException("parse failed, result is null"); } CalcualteChecksumResult checksumResult = (CalcualteChecksumResult) parseAndChecksumResults .get("checksumResult"); ParseResult parseResult = (ParseResult) parseAndChecksumResults.get("parseResult"); Metadata metadata = parseResult.metadata; if (contentType != null) { metadata.add(Metadata.CONTENT_TYPE, contentType); } if (name != null) { metadata.add(Metadata.RESOURCE_NAME_KEY, name); } // used same interface for image / non-image as decouple detection // logic to detect done by tika on the fly. but check aftewards // logger.info("parsedContent" + parsedContent); if (isImage(metadata)) { System.out.println(metadata); } else { if (parseResult.parseContent.equalsIgnoreCase("")) { logger.info("Content is empty after parsed by Tika"); System.out.println(metadata); try { throw new TikaException("Content is empty after parsed by Tika"); } catch (TikaException e) { // TODO Auto-generated catch block throw new IOException(e); } } } context.externalValue(parseResult.parseContent); contentMapper.parse(context); context.externalValue(name); nameMapper.parse(context); context.externalValue(metadata.get(Metadata.DATE)); dateMapper.parse(context); context.externalValue(metadata.get(Metadata.TITLE)); titleMapper.parse(context); context.externalValue(metadata.get(Metadata.AUTHOR)); authorMapper.parse(context); context.externalValue("ImKeyWord"); keywordsMapper.parse(context); context.externalValue(metadata.get(Metadata.CONTENT_TYPE)); contentTypeMapper.parse(context); context.externalValue(metadata); imageExifTikaMetaMapper.parse(context); FileMeta fileMeta = new FileMeta(); fileMeta.setChecksum(checksumResult.checksum); fileMeta.setChecksumTook(checksumResult.took); fileMeta.setParseTook(parseResult.took); context.externalValue(fileMeta); fileMetaMapper.parse(context); }
From source file:com.aliyun.odps.mapred.bridge.streaming.StreamJob.java
public int run(String[] args) throws Exception { for (String aa : args) { LOG.debug("arg: '" + aa + "'"); }/*from ww w.j a v a2 s. c o m*/ try { this.argv_ = Arrays.copyOf(args, args.length); init(); preProcessArgs(); parseArgv(); if (printUsage) { printUsage(detailedUsage_); return 0; } postProcessArgs(); setJobConf(); } catch (IllegalArgumentException ex) { //ignore, since log will already be printed // print the log in debug mode. LOG.debug("Error in streaming job", ex); ex.printStackTrace(); return 1; } return submitAndMonitorJob(); }
From source file:com.example.cityrally.app.engine.view.GeoActivity.java
/** * Called when the user clicks the "Remove geofence 1" button * @param view The view that triggered this callback *//* w w w .j av a2 s . c o m*/ public void onUnregisterGeofence1Clicked(View view) { /* * Remove the geofence by creating a List of geofences to * remove and sending it to Location Services. The List * contains the id of geofence 1 ("1"). * The removal happens asynchronously; Location Services calls * onRemoveGeofencesByPendingIntentResult() (implemented in * the current Activity) when the removal is done. */ // Create a List of 1 Geofence with the ID "1" and store it in the global list mGeofenceIdsToRemove = Collections.singletonList("1"); /* * Record the removal as remove by list. If a connection error occurs, * the app can automatically restart the removal if Google Play services * can fix the error */ mRemoveType = GeofenceUtils.REMOVE_TYPE.LIST; /* * Check for Google Play services. Do this after * setting the request type. If connecting to Google Play services * fails, onActivityResult is eventually called, and it needs to * know what type of request was in progress. */ if (!servicesConnected()) { return; } // Try to remove the geofence try { mGeofenceRemover.removeGeofencesById(mGeofenceIdsToRemove); // Catch errors with the provided geofence IDs } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (UnsupportedOperationException e) { // Notify user that previous request hasn't finished. Toast.makeText(getView().getContext(), R.string.remove_geofences_already_requested_error, Toast.LENGTH_LONG).show(); } }
From source file:com.example.cityrally.app.engine.view.GeoActivity.java
/** * Called when the user clicks the "Remove geofence 2" button * @param view The view that triggered this callback *///from w ww .j a v a 2 s . co m public void onUnregisterGeofence2Clicked(View view) { /* * Remove the geofence by creating a List of geofences to * remove and sending it to Location Services. The List * contains the id of geofence 2, which is "2". * The removal happens asynchronously; Location Services calls * onRemoveGeofencesByPendingIntentResult() (implemented in * the current Activity) when the removal is done. */ /* * Record the removal as remove by list. If a connection error occurs, * the app can automatically restart the removal if Google Play services * can fix the error */ mRemoveType = GeofenceUtils.REMOVE_TYPE.LIST; // Create a List of 1 Geofence with the ID "2" and store it in the global list mGeofenceIdsToRemove = Collections.singletonList("2"); /* * Check for Google Play services. Do this after * setting the request type. If connecting to Google Play services * fails, onActivityResult is eventually called, and it needs to * know what type of request was in progress. */ if (!servicesConnected()) { return; } // Try to remove the geofence try { mGeofenceRemover.removeGeofencesById(mGeofenceIdsToRemove); // Catch errors with the provided geofence IDs } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (UnsupportedOperationException e) { // Notify user that previous request hasn't finished. Toast.makeText(getView().getContext(), R.string.remove_geofences_already_requested_error, Toast.LENGTH_LONG).show(); } }