List of usage examples for java.lang IllegalAccessException printStackTrace
public void printStackTrace()
From source file:org.oncoblocks.centromere.web.util.FilteringTextMessageConverter.java
@Override protected void writeInternal(Object o, HttpOutputMessage httpOutputMessage) throws IOException, HttpMessageNotWritableException { httpOutputMessage.getHeaders().setContentType(this.mediaType); OutputStream out = httpOutputMessage.getBody(); PrintWriter writer = new PrintWriter(out); boolean showHeader = true; Set<String> includedFields = new HashSet<>(); Set<String> excludedFields = new HashSet<>(); if (o.getClass().equals(ResponseEnvelope.class)) { includedFields = ((ResponseEnvelope) o).getFieldSet(); excludedFields = ((ResponseEnvelope) o).getExclude(); o = ((ResponseEnvelope) o).getEntity(); }//from w ww . java 2 s. com if (o.getClass().equals(PageImpl.class)) { o = ((Page) o).getContent(); } if (!(o instanceof Collection<?>)) { o = Arrays.asList(o); } for (Object entity : (Collection<?>) o) { String entityString; try { StringBuilder buffer = new StringBuilder(); if (showHeader) { for (Field field : entity.getClass().getDeclaredFields()) { if (includedFields != null && !includedFields.isEmpty()) { if (includedFields.contains(field.getName())) { buffer.append(field.getName()).append(delimiter); } } else if (excludedFields != null && !excludedFields.isEmpty()) { if (!excludedFields.contains(field.getName())) { buffer.append(field.getName()).append(delimiter); } } else { buffer.append(field.getName()).append(delimiter); } } buffer.append("\n"); } for (Field field : entity.getClass().getDeclaredFields()) { field.setAccessible(true); if (includedFields != null && !includedFields.isEmpty()) { if (includedFields.contains(field.getName())) { buffer.append(field.get(entity)).append(delimiter); } } else if (excludedFields != null && !excludedFields.isEmpty()) { if (!excludedFields.contains(field.getName())) { buffer.append(field.get(entity)).append(delimiter); } } else { buffer.append(field.get(entity)).append(delimiter); } } buffer.append("\n"); entityString = buffer.toString(); } catch (IllegalAccessException e) { e.printStackTrace(); entityString = "# Invalid record."; } writer.write(entityString); showHeader = false; } writer.close(); }
From source file:com.rolex.explore.beanutils.service.BeanUtilsSpecificService.java
public void exploreBeanUtil() { SampleBean bean = new SampleBean(); String property1 = "name"; String property2 = "currentAddress.city"; String property3 = "previousAddresses[0].city"; String property4 = "previousAddresses[3].city"; String property5 = "vehicleLicenseModel(R60)"; Place place1 = new Place("Sentosa", "Singapore"); Place place2 = new Place("Colombo", "Sri Lanka"); List<Place> places = new ArrayList<Place>(); places.add(place1);/* w w w . j a v a2 s .c o m*/ places.add(place2); String property6 = "yearlyPlacesVisited(2000)"; String property7 = "placesVisited"; String property8 = "placesVisited[0]"; TourismAward award = new TourismAward("World Award Committee", "USA"); String property9 = "yearlyPlacesVisited(2000)[0].tourismAwards[0]"; try { PropertyUtils.setSimpleProperty(bean, property1, "Rolex Rolex"); String value1 = (String) PropertyUtils.getSimpleProperty(bean, property1); System.out.println("###Reverse1: " + value1); PropertyUtils.setNestedProperty(bean, property2, "Hoffman Estates"); String value2 = (String) PropertyUtils.getNestedProperty(bean, property2); System.out.println("###Reverse2: " + value2); PropertyUtils.setNestedProperty(bean, property3, "Schaumburg"); String value3 = (String) PropertyUtils.getNestedProperty(bean, property3); System.out.println("###Reverse3: " + value3); PropertyUtils.setNestedProperty(bean, property4, "Des Plaines"); String value4 = (String) PropertyUtils.getNestedProperty(bean, property4); System.out.println("###Reverse4: " + value4); Address[] arrayValue1 = (Address[]) PropertyUtils.getSimpleProperty(bean, "previousAddresses"); System.out.println("###ReverseArray: " + Arrays.toString(arrayValue1)); PropertyUtils.setMappedProperty(bean, property5, "Sonata"); String value5 = (String) PropertyUtils.getMappedProperty(bean, property5); System.out.println("###Reverse5: " + value5); PropertyUtils.setMappedProperty(bean, property6, places); List<Place> value6 = (List<Place>) PropertyUtils.getMappedProperty(bean, property6); System.out.println("###Reverse6: " + value6.get(0)); PropertyUtils.setSimpleProperty(bean, property7, places); List<Place> value7 = (List<Place>) PropertyUtils.getSimpleProperty(bean, property7); System.out.println("###Reverse7: " + value7.get(0)); PropertyUtils.setIndexedProperty(bean, property8, place2); Place value8 = (Place) PropertyUtils.getIndexedProperty(bean, property8); System.out.println("###Reverse8: " + value8); PropertyUtils.setNestedProperty(bean, property9, award); TourismAward value9 = (TourismAward) PropertyUtils.getNestedProperty(bean, property9); System.out.println("###Reverse8: " + value8); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.liuguangqiang.permissionhelper.PermissionHelper.java
/** * Invoke a method with annotation PermissionGranted. * * @param obj/*from w w w . j a va 2 s .com*/ * @param permission */ private void invokeGrantedMethod(Object obj, String permission) { Class clazz = obj.getClass(); PermissionGranted permissionGranted; for (Method method : clazz.getMethods()) { if (method.isAnnotationPresent(PermissionGranted.class)) { permissionGranted = method.getAnnotation(PermissionGranted.class); if (permissionGranted.permission().equals(permission)) { if (method.getModifiers() != Modifier.PUBLIC) { throw new IllegalArgumentException( String.format("Annotation method %s must be public.", method)); } if (method.getParameterTypes().length > 0) { throw new RuntimeException(String.format("Cannot execute non-void method %s.", method)); } try { method.invoke(obj); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } }
From source file:com.liuguangqiang.permissionhelper.PermissionHelper.java
/** * Invoke a method with annotation PermissionDenied. * * @param obj//w w w .ja v a 2 s. c om * @param permission */ private void invokeDeniedMethod(Object obj, String permission) { Class clazz = obj.getClass(); PermissionDenied permissionDenied; for (Method method : clazz.getMethods()) { if (method.isAnnotationPresent(PermissionDenied.class)) { permissionDenied = method.getAnnotation(PermissionDenied.class); if (permissionDenied.permission().equals(permission)) { if (method.getModifiers() != Modifier.PUBLIC) { throw new IllegalArgumentException( String.format("Annotation method %s must be public.", method)); } if (method.getParameterTypes().length > 0) { throw new RuntimeException(String.format("Cannot execute non-void method %s.", method)); } try { method.invoke(obj); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } }
From source file:com.team3637.service.ScheduleServiceMySQLImpl.java
@Override public void update(Schedule schedule) { Field[] fields = Schedule.class.getDeclaredFields(); String valuesSting = "", SQL; List<Object> values = new ArrayList<>(); try {//from ww w . ja v a 2 s.com for (int i = 1; i < fields.length; i++) { fields[i].setAccessible(true); values.add(fields[i].get(schedule)); if (i == fields.length - 1) { valuesSting += fields[i].getName() + "=?"; } else { valuesSting += fields[i].getName() + "=?, "; } } } catch (IllegalAccessException e) { e.printStackTrace(); } SQL = "UPDATE schedule SET " + valuesSting + " WHERE id=" + schedule.getId() + ";"; jdbcTemplateObject.update(SQL, values.toArray()); }
From source file:org.hfoss.posit.android.api.fragment.DeleteFindsDialogFragment.java
/** * Deletes a find which the user was prompted to do so. * /* w ww. j av a 2s . c o m*/ * @return a boolean indicated that the find was deleted */ protected boolean deleteFind() { int rows = 0; String guid = null; // Get the appropriate find class from the plugin manager and // make an instance of it. Class<Find> findClass = FindPluginManager.mFindPlugin.getmFindClass(); Find find = null; try { find = findClass.newInstance(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (java.lang.InstantiationException e) { e.printStackTrace(); } find.setId(getArguments().getInt(Find.ORM_ID)); // store the guid of this find so that I can delete photos on phone find = getHelper().getFindById(find.getId()); guid = find.getGuid(); rows = getHelper().delete(find); if (rows > 0) { Toast.makeText(getActivity(), R.string.deleted_from_database, Toast.LENGTH_SHORT).show(); // delete photo if it exists if (getActivity().deleteFile(guid)) { Log.i(TAG, "Image with guid: " + guid + " deleted."); } // this.startService(new Intent(this, ToDoReminderService.class)); } else { Toast.makeText(getActivity(), R.string.delete_failed, Toast.LENGTH_SHORT).show(); } return rows > 0; }
From source file:de.weltraumschaf.maconha.server.service.SongServiceDbAccess.java
private void copyPartialProperties(final Song verifyPodcastExistenceById, final Song podcast) { final BeanUtilsBean notNull = new NullAwareBeanUtilsBean(); try {//from w w w. j a v a 2s . c om notNull.copyProperties(verifyPodcastExistenceById, podcast); } catch (final IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (final InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.team3637.service.ScheduleServiceMySQLImpl.java
@Override public void create(Schedule schedule) { Field[] fields = Schedule.class.getDeclaredFields(); String fieldsSting = "", valuesSting = "", SQL; List<Object> values = new ArrayList<>(); try {// w w w.ja v a 2 s . com for (int i = 1; i < fields.length; i++) { fields[i].setAccessible(true); values.add(fields[i].get(schedule)); if (i == fields.length - 1) { fieldsSting += fields[i].getName(); valuesSting += "?"; } else { fieldsSting += fields[i].getName() + ", "; valuesSting += "?, "; } } } catch (IllegalAccessException e) { e.printStackTrace(); } SQL = "INSERT INTO schedule (" + fieldsSting + ") VALUES (" + valuesSting + ");"; jdbcTemplateObject.update(SQL, values.toArray()); }
From source file:com.square.client.gwt.server.test.StringConverterTest.java
@SuppressWarnings("unchecked") private RemotePagingCriteriasDto<?> recupererCriteres(Map<String, String> map, Object criteres) { try {/* ww w . j av a 2 s . c o m*/ BeanUtils.populate(criteres, map); final RemotePagingCriteriasDto<?> criterias = new RemotePagingCriteriasDto(criteres, 0, Integer.MAX_VALUE); BeanUtils.populate(criterias, map); return criterias; } catch (IllegalAccessException e) { e.printStackTrace(); throw new TechnicalException(Messages.getString("StringConverterTest.63")); } catch (InvocationTargetException e) { e.printStackTrace(); throw new TechnicalException(Messages.getString("StringConverterTest.64")); } }
From source file:com.rolex.explore.beanutils.service.BeanUtilsService.java
public void exploreBeanUtil() { SampleBean bean = new SampleBean(); String property1 = "name"; String property2 = "currentAddress.city"; String property3 = "previousAddresses[0].city"; String property4 = "previousAddresses[3].city"; String property5 = "vehicleLicenseModel(R60)"; Place place1 = new Place("Sentosa", "Singapore"); Place place2 = new Place("Colombo", "Sri Lanka"); List<Place> places = new ArrayList<Place>(); places.add(place1);/*from w w w. j a v a 2s .c o m*/ places.add(place2); String property6 = "yearlyPlacesVisited(2000)"; String property7 = "placesVisited"; String property8 = "placesVisited[0]"; TourismAward award = new TourismAward("World Award Committee", "USA"); String property9 = "yearlyPlacesVisited(2000)[0].tourismAwards[0]"; try { PropertyUtils.setProperty(bean, property1, "Rolex Rolex"); String value1 = (String) PropertyUtils.getProperty(bean, property1); System.out.println("###Reverse1: " + value1); PropertyUtils.setProperty(bean, property2, "Hoffman Estates"); String value2 = (String) PropertyUtils.getProperty(bean, property2); System.out.println("###Reverse2: " + value2); PropertyUtils.setProperty(bean, property3, "Schaumburg"); String value3 = (String) PropertyUtils.getProperty(bean, property3); System.out.println("###Reverse3: " + value3); PropertyUtils.setProperty(bean, property4, "Des Plaines"); String value4 = (String) PropertyUtils.getProperty(bean, property4); System.out.println("###Reverse4: " + value4); Address[] arrayValue1 = (Address[]) PropertyUtils.getProperty(bean, "previousAddresses"); System.out.println("###ReverseArray: " + Arrays.toString(arrayValue1)); PropertyUtils.setProperty(bean, property5, "Sonata"); String value5 = (String) PropertyUtils.getProperty(bean, property5); System.out.println("###Reverse5: " + value5); PropertyUtils.setProperty(bean, property6, places); List<Place> value6 = (List<Place>) PropertyUtils.getProperty(bean, property6); System.out.println("###Reverse6: " + value6.get(0)); PropertyUtils.setProperty(bean, property7, places); List<Place> value7 = (List<Place>) PropertyUtils.getProperty(bean, property7); System.out.println("###Reverse7: " + value7.get(0)); PropertyUtils.setProperty(bean, property8, place2); Place value8 = (Place) PropertyUtils.getProperty(bean, property8); System.out.println("###Reverse8: " + value8); PropertyUtils.setProperty(bean, property9, award); TourismAward value9 = (TourismAward) PropertyUtils.getProperty(bean, property9); System.out.println("###Reverse8: " + value8); System.out.println("Bean: " + bean); SampleBean copyBean = new SampleBean(); BeanUtils.copyProperties(copyBean, bean); System.out.println("Bean: " + bean); System.out.println("Copy Bean: " + copyBean); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } }