List of usage examples for java.lang NoSuchMethodException getMessage
public String getMessage()
From source file:org.kuali.coeus.common.budget.framework.query.QueryList.java
/** returns the field value in the base bean for the specified field. * @param fieldName fieldname whose value has to be got. * @param baseBean Bean containing the field. * @return value of the field.//w ww . j av a2 s. co m */ private Object getFieldValue(String fieldName, Object baseBean) { Field field = null; Method method = null; Class dataClass = baseBean.getClass(); Object value = null; try { field = dataClass.getDeclaredField(fieldName); if (!field.isAccessible()) { throw new NoSuchFieldException(); } } catch (NoSuchFieldException noSuchFieldException) { try { String methodName = "get" + (fieldName.charAt(0) + "").toUpperCase() + fieldName.substring(1); method = dataClass.getMethod(methodName, null); } catch (NoSuchMethodException noSuchMethodException) { LOG.error(noSuchMethodException.getMessage(), noSuchMethodException); } } try { if (field != null && field.isAccessible()) { value = field.get(baseBean); } else { value = method.invoke(baseBean, null); } } catch (IllegalAccessException illegalAccessException) { LOG.error(illegalAccessException.getMessage(), illegalAccessException); } catch (InvocationTargetException invocationTargetException) { LOG.error(invocationTargetException.getMessage(), invocationTargetException); } return value; }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.forms.wizard.AddExperimentScenarioForm.java
private void addModalWindowAndButton(MarkupContainer container, final String cookieName, final String buttonName, final String targetClass, final ModalWindow window) { window.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; @Override//w w w .j a va 2 s . c om public void onClose(AjaxRequestTarget target) { ChoiceRenderer<Person> renderer = new ChoiceRenderer<Person>("fullName", "personId"); List<Person> choices = personFacade.getAllRecords(); Collections.sort(choices); coexperimenters.setChoiceRenderer(renderer); coexperimenters.setChoices(choices); ChoiceRenderer<ResearchGroup> groupRenderer = new ChoiceRenderer<ResearchGroup>("title", "researchGroupId"); List<ResearchGroup> groupChoices = researchGroupFacade .getResearchGroupsWhereAbleToWriteInto(EEGDataBaseSession.get().getLoggedUser()); researchGroupChoice.setChoiceRenderer(groupRenderer); researchGroupChoice.setChoices(groupChoices); licenses.clear(); licenses.addAll(model.getObject().getExperimentLicences()); licenses.addAll(EEGDataBaseSession.get().getCreateExperimentLicenseMap().values()); target.add(AddExperimentScenarioForm.this); } }); AjaxButton ajaxButton = new AjaxButton(buttonName) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { window.setCookieName(cookieName); window.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; @Override @SuppressWarnings("serial") public Page createPage() { try { Constructor<?> cons = null; if (targetClass.equals(AddLicensePage.class.getName())) { p = new AddLicensePage(getPage().getPageReference(), window, model) { @Override protected void onSubmitAction(IModel<ExperimentLicence> experimentLicenseModel, Integer licenseId, AjaxRequestTarget target, Form<?> form) { ExperimentLicence experimentLicense = experimentLicenseModel.getObject(); EEGDataBaseSession.get().addLicenseToCreateLicenseMap(licenseId, experimentLicense); ModalWindow.closeCurrent(target); } }; return (Page) p; } else { cons = Class.forName(targetClass).getConstructor(PageReference.class, ModalWindow.class); return (Page) cons.newInstance(getPage().getPageReference(), window); } } catch (NoSuchMethodException e) { log.error(e.getMessage(), e); } catch (IllegalAccessException e) { log.error(e.getMessage(), e); } catch (InstantiationException e) { log.error(e.getMessage(), e); } catch (InvocationTargetException e) { log.error(e.getMessage(), e); } catch (ClassNotFoundException e) { log.error(e.getMessage(), e); } return null; } }); window.show(target); } }; ajaxButton.setDefaultFormProcessing(false); container.add(ajaxButton); }
From source file:velo.entity.EmailTemplate.java
@Deprecated public Object executeGetMethod(Object obj, String methodName) throws MethodExecutionException { //System.out.println("Trying to execute Method name: '" + methodName + "', on Object: " + obj); try {/*from w ww.jav a2 s .c o m*/ Class[] parameterTypes = new Class[] {}; Method name = obj.getClass().getMethod(methodName, parameterTypes); Object[] arguments = new Object[] {}; Object result = name.invoke(obj, arguments); return result; } catch (InvocationTargetException ite) { throw new MethodExecutionException("Could not execute method named: '" + methodName + "' over object: '" + obj + "', failed message is: " + ite.getMessage()); } catch (IllegalAccessException iae) { throw new MethodExecutionException("Could not execute method named: '" + methodName + "' over object: '" + obj + "', failed message is: " + iae.getMessage()); } catch (NoSuchMethodException nsme) { throw new MethodExecutionException("Could not execute method named: '" + methodName + "' over object: '" + obj + "', failed message is: " + nsme.getMessage()); } }
From source file:net.firejack.platform.core.utils.Factory.java
private void set(Object bean, String name, Object value) { if (value != null) { try {/*from w w w . j a va2s . co m*/ getInstance().setProperty(bean, name, value); } catch (NoSuchMethodException e) { try { getInstance().setProperty(bean, fixPath(name), value); } catch (Exception ex) { logger.warn(e.getMessage()); } } catch (Exception e) { logger.warn(e.getMessage()); } } }
From source file:org.wso2.carbon.social.sql.SQLActivityPublisher.java
@SuppressWarnings("rawtypes") private void insertLikeActivity(SQLActivity activity, int likeValue, Connection connection) throws SocialActivityException { String targetId = activity.getTargetId(); String actor = activity.getActorId(); int timestamp = activity.getTimestamp(); String tenantDomain = SocialUtil.getTenantDomain(); String errorMessage = "Error while adding like activity to the table: " + Constants.SOCIAL_LIKES_TABLE_NAME; try {/*from w w w . j ava 2 s. co m*/ if (obj == null) { cls = SocialUtil.loadQueryAdapterClass(); obj = SocialUtil.getQueryAdaptorObject(cls); } Class[] param = { Connection.class, String.class, String.class, String.class, int.class, int.class }; Method method = cls.getDeclaredMethod("insertLikeActivity", param); method.invoke(obj, connection, targetId, actor, tenantDomain, likeValue, timestamp); } catch (NoSuchMethodException e) { log.error(errorMessage + e.getMessage(), e); throw new SocialActivityException(errorMessage, e); } catch (SecurityException e) { log.error(errorMessage + e.getMessage(), e); throw new SocialActivityException(errorMessage, e); } catch (IllegalAccessException e) { log.error(errorMessage + e.getMessage(), e); throw new SocialActivityException(errorMessage, e); } catch (IllegalArgumentException e) { log.error(errorMessage + e.getMessage(), e); throw new SocialActivityException(errorMessage, e); } catch (InvocationTargetException e) { log.error(errorMessage + e.getMessage(), e); throw new SocialActivityException(errorMessage, e); } }
From source file:org.kuali.coeus.common.budget.framework.query.QueryList.java
/** calculates the sum of the field in this QueryList. * @param fieldName field of bean whose sum has to be calculated. * @param arg argument for the getter method of field if it takes any argumnt, * else can be null.//from w ww. ja v a 2s .co m * @param value value for the argument, else can be null. * @return returns sum. */ public double sum(String fieldName, Class arg, Object value) { if (size() == 0) { return 0; } Object current; Field field = null; Method method = null; Class dataClass = get(0).getClass(); double sum = 0; try { field = dataClass.getDeclaredField(fieldName); Class fieldClass = field.getType(); if (!(fieldClass.equals(Integer.class) || fieldClass.equals(Long.class) || fieldClass.equals(Double.class) || fieldClass.equals(Float.class) || fieldClass.equals(BigDecimal.class) || fieldClass.equals(BigInteger.class) || fieldClass.equals(ScaleTwoDecimal.class) || fieldClass.equals(ScaleTwoDecimal.class) || fieldClass.equals(int.class) || fieldClass.equals(long.class) || fieldClass.equals(float.class) || fieldClass.equals(double.class))) { throw new UnsupportedOperationException("Data Type not numeric"); } if (!field.isAccessible()) { throw new NoSuchFieldException(); } } catch (NoSuchFieldException noSuchFieldException) { try { String methodName = "get" + (fieldName.charAt(0) + "").toUpperCase() + fieldName.substring(1); if (arg != null) { Class args[] = { arg }; method = dataClass.getMethod(methodName, args); } else { method = dataClass.getMethod(methodName, null); } } catch (NoSuchMethodException noSuchMethodException) { LOG.error(noSuchMethodException.getMessage(), noSuchMethodException); } } for (int index = 0; index < size(); index++) { current = get(index); try { if (field != null && field.isAccessible()) { sum = sum + Double.parseDouble(((Comparable) field.get(current)).toString()); } else { Comparable dataValue; if (value != null) { Object values[] = { value }; dataValue = (Comparable) method.invoke(current, values); } else { dataValue = (Comparable) method.invoke(current, null); } if (dataValue != null) { sum += Double.parseDouble(dataValue.toString()); } } } catch (IllegalAccessException illegalAccessException) { LOG.error(illegalAccessException.getMessage(), illegalAccessException); } catch (InvocationTargetException invocationTargetException) { LOG.error(invocationTargetException.getMessage(), invocationTargetException); } } return sum; }
From source file:org.kuali.coeus.common.budget.framework.query.QueryList.java
/** * sorts the QueryList by the fieldName in ascending or descending order. * Note: the field Object should be of Comparable type. * @return boolean indicating whether the sort is completed successfully or not. * @param ignoreCase use only when comparing strings. as default implementation uses case sensitive comparison. * @param fieldName field which is used to sort the bean. * @param ascending if true sorting is done in ascending order, * else sorting is done in descending order. *//*from www . j a v a 2 s.c o m*/ @SuppressWarnings("rawtypes") public boolean sort(String fieldName, boolean ascending, boolean ignoreCase) { Object current, next; int compareValue = 0; Field field = null; Method method = null; if (this.size() == 0) { return false; } Class dataClass = get(0).getClass(); String methodName = null; try { field = dataClass.getDeclaredField(fieldName); if (!field.isAccessible()) { throw new NoSuchFieldException(); } } catch (NoSuchFieldException noSuchFieldException) { //field not available. Use method invokation. try { methodName = "get" + (fieldName.charAt(0) + "").toUpperCase() + fieldName.substring(1); method = dataClass.getMethod(methodName, null); } catch (NoSuchMethodException noSuchMethodException) { LOG.error(noSuchMethodException.getMessage(), noSuchMethodException); return false; } } for (int index = 0; index < size() - 1; index++) { for (int nextIndex = index + 1; nextIndex < size(); nextIndex++) { current = get(index); next = get(nextIndex); //Check if current and next implements Comparable else can't compare. //so return without comparing.May be we can have an exception for this purpose. try { if (field != null && field.isAccessible()) { Comparable thisObj = (Comparable) field.get(current); Comparable otherObj = (Comparable) field.get(next); if (thisObj == null) { compareValue = -1; } else if (otherObj == null) { compareValue = 1; } else { if (thisObj instanceof String && ignoreCase) { compareValue = ((String) thisObj).compareToIgnoreCase((String) otherObj); } else { compareValue = thisObj.compareTo(otherObj); } } } else { Comparable thisObj = null; Comparable otherObj = null; if (methodName != null) { Method thisObjMethod = current.getClass().getMethod(methodName, null); Method otherObjMethod = next.getClass().getMethod(methodName, null); thisObj = (Comparable) thisObjMethod.invoke(current, null); otherObj = (Comparable) otherObjMethod.invoke(next, null); } else { thisObj = (Comparable) method.invoke(current, null); otherObj = (Comparable) method.invoke(next, null); } if (thisObj == null) { compareValue = -1; } else if (otherObj == null) { compareValue = 1; } else { if (thisObj instanceof String && ignoreCase) { compareValue = ((String) thisObj).compareToIgnoreCase((String) otherObj); } else { compareValue = thisObj.compareTo(otherObj); } } } } catch (IllegalAccessException illegalAccessException) { LOG.warn(illegalAccessException.getMessage()); return false; } catch (InvocationTargetException invocationTargetException) { LOG.warn(invocationTargetException.getMessage(), invocationTargetException); return false; } catch (SecurityException e) { LOG.warn(e.getMessage(), e); return false; } catch (NoSuchMethodException e) { LOG.warn(e.getMessage(), e); return false; } if (ascending && compareValue > 0) { E temp = get(index); set(index, get(nextIndex)); set(nextIndex, temp); } else if (!ascending && compareValue < 0) { E temp = get(index); set(index, get(nextIndex)); set(nextIndex, temp); } } } return true; }
From source file:org.apache.struts.taglib.tiles.PutTag.java
/** * Extract real value from specified bean. * @throws JspException If something goes wrong while getting value from bean. *///from w ww . j a v a 2s . c o m protected void getRealValueFromBean() throws JspException { try { Object bean = TagUtils.retrieveBean(beanName, beanScope, pageContext); if (bean != null && beanProperty != null) { realValue = PropertyUtils.getProperty(bean, beanProperty); } else { realValue = bean; // value can be null } } catch (NoSuchMethodException ex) { throw new JspException("Error - component.PutAttributeTag : Error while retrieving value from bean '" + beanName + "' with property '" + beanProperty + "' in scope '" + beanScope + "'. (exception : " + ex.getMessage()); } catch (InvocationTargetException ex) { throw new JspException("Error - component.PutAttributeTag : Error while retrieving value from bean '" + beanName + "' with property '" + beanProperty + "' in scope '" + beanScope + "'. (exception : " + ex.getMessage()); } catch (IllegalAccessException ex) { throw new JspException("Error - component.PutAttributeTag : Error while retrieving value from bean '" + beanName + "' with property '" + beanProperty + "' in scope '" + beanScope + "'. (exception : " + ex.getMessage()); } }