List of usage examples for java.lang IllegalAccessException getMessage
public String getMessage()
From source file:org.apache.struts.action.TestDynaActionForm.java
public void setUp() { super.setUp(); try {//www .ja v a 2 s .c o m dynaForm = (DynaActionForm) dynaClass.newInstance(); } catch (IllegalAccessException e) { throw new RuntimeException(e.getMessage()); } catch (InstantiationException e) { throw new RuntimeException(e.getMessage()); } setupComplexProperties(); moduleConfig = new DynaActionFormConfig(beanConfig); mapping = new DynaActionFormMapping(moduleConfig); log = LogFactory.getLog(this.getClass().getName() + "." + this.getName()); }
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 w w w.jav 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:fr.paris.lutece.util.datatable.DataTableManager.java
/** * Get filter properties updated with values in the request * @param request The request/* ww w.ja va2s . c o m*/ * @param <K> Type of the filter to use. This type must have accessors for * every declared filter. * @param filterObject Filter to apply. * @return The filter properties up to date */ public <K> K getAndUpdateFilter(HttpServletRequest request, K filterObject) { List<DataTableFilter> listFilters = _filterPanel.getListFilter(); boolean bSubmitedDataTable = hasDataTableFormBeenSubmited(request); boolean bResetFilter = false; boolean bUpdateFilter = false; Map<String, Object> mapFilter = new HashMap<String, Object>(); if (bSubmitedDataTable) { bUpdateFilter = true; StringUtils.equals( request.getParameter(FilterPanel.PARAM_FILTER_PANEL_PREFIX + FilterPanel.PARAM_RESET_FILTERS), Boolean.TRUE.toString()); if (!bResetFilter) { bUpdateFilter = StringUtils.equals( request.getParameter( FilterPanel.PARAM_FILTER_PANEL_PREFIX + FilterPanel.PARAM_UPDATE_FILTERS), Boolean.TRUE.toString()); } } for (DataTableFilter filter : listFilters) { if (bSubmitedDataTable) { String strFilterValue = request .getParameter(FilterPanel.PARAM_FILTER_PANEL_PREFIX + filter.getParameterName()); if (bUpdateFilter) { filter.setValue(strFilterValue); } } if (StringUtils.isNotBlank(filter.getValue())) { mapFilter.put(filter.getParameterName(), filter.getValue()); } } try { BeanUtilsBean.getInstance().populate(filterObject, mapFilter); } catch (IllegalAccessException e) { AppLogService.error(e.getMessage(), e); return null; } catch (InvocationTargetException e) { AppLogService.error(e.getMessage(), e); return null; } return filterObject; }
From source file:com.legstar.coxb.gen.CoxbBindingGenerator.java
/** * Returns a new instance of the requested JAXB object. * // ww w .j ava2 s. c o m * @param jaxbObjectFactory an instance of a JAXB Object Factory * @param rootObjectName the JAXB root object name (non qualified) * @return an instance of the JAXB root object */ protected Object getRootObject(final Object jaxbObjectFactory, final String rootObjectName) { Object jaxbRootObject = null; if (jaxbObjectFactory == null) { throw (new BuildException("You must provide a JAXB object factory.")); } if (rootObjectName == null || rootObjectName.length() == 0) { throw (new BuildException("You must provide a JAXB object name.")); } try { String createName = "create" + rootObjectName; Method creator = jaxbObjectFactory.getClass().getMethod(createName); jaxbRootObject = creator.invoke(jaxbObjectFactory); } catch (IllegalAccessException e) { e.printStackTrace(); throw (new BuildException( "IllegalAccessException " + e.getMessage() + " rootObjectName=" + rootObjectName)); } catch (SecurityException e) { e.printStackTrace(); throw (new BuildException("SecurityException " + e.getMessage() + " rootObjectName=" + rootObjectName)); } catch (NoSuchMethodException e) { e.printStackTrace(); throw (new BuildException( "NoSuchMethodException " + e.getMessage() + " rootObjectName=" + rootObjectName)); } catch (IllegalArgumentException e) { e.printStackTrace(); throw (new BuildException( "IllegalArgumentException " + e.getMessage() + " rootObjectName=" + rootObjectName)); } catch (InvocationTargetException e) { e.printStackTrace(); throw (new BuildException( "InvocationTargetException " + e.getMessage() + " rootObjectName=" + rootObjectName)); } return jaxbRootObject; }
From source file:com.liusoft.dlog4j.action.PhotoAction.java
/** * //from w w w . ja v a 2s . c o m * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ protected ActionForward doUpload(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception { PhotoForm photo1 = (PhotoForm) form; validateClientId(request, photo1); ActionMessages msgs = new ActionMessages(); do { FormFile[] files = new FormFile[5]; files[0] = photo1.getImage(); files[1] = photo1.getImage2(); files[2] = photo1.getImage3(); files[3] = photo1.getImage4(); files[4] = photo1.getImage5(); //? AlbumBean album = AlbumDAO.getAlbumByID(photo1.getAlbum()); if (album == null) { msgs.add(ERROR_KEY, new ActionMessage("error.object_not_found", String.valueOf(photo1.getAlbum()))); break; } SiteBean site = super.getSiteBean(request); UserBean loginUser = super.getLoginUserAfterValidateSiteOwner(request); String photo_desc; if (StringUtils.isNotEmpty(photo1.getDesc())) { photo_desc = StringUtils.abbreviate(super.autoFiltrate(site, photo1.getDesc()), MAX_PHOTO_DESC_LENGTH); photo_desc = super.filterScriptAndStyle(photo_desc); } else photo_desc = " "; for (int i = 0; i < files.length; i++) { if (files[i] == null || files[i].getFileSize() <= 0 || StringUtils.isEmpty(files[i].getFileName())) continue; //?? /* if(files[i].getFileSize()>4194304){//4*1024*1024 msgs.add(ERROR_KEY, new ActionMessage("error.file_too_large")); break; }*/ if (!accept(files[i])) { msgs.add(ERROR_KEY, new ActionMessage("error.upload_file_not_supported")); break; } //? int photo_size = DLOG4JUtils.sizeInKbytes(files[i].getFileSize()); int max_photo_size = site.getCapacity().getPhotoTotal(); if (max_photo_size >= 0) { int current_size = site.getCapacity().getPhotoUsed(); if ((current_size + photo_size) > max_photo_size) { msgs.add(ERROR_KEY, new ActionMessage("error.photo_space_full")); break; } } //?? Photo img = null; try { img = getPhotoSaver().save(getHttpContext(mapping, form, request, response), files[i], photo1.getAutoRotate() == 1); if (img == null) { msgs.add(ERROR_KEY, new ActionMessage("error.upload_failed")); break; } //? PhotoBean pbean = new PhotoBean(); pbean.setSite(site); pbean.setUser(loginUser); if (StringUtils.isNotEmpty(photo1.getName())) { pbean.setName(super.autoFiltrate(site, photo1.getName())); } else pbean.setName(img.getName()); pbean.setDesc(photo_desc); if (StringUtils.isNotEmpty(photo1.getKeyword())) { if (site.isFlagSet(SiteBean.Flag.ILLEGAL_GLOSSARY_IGNORE)) pbean.setKeyword(photo1.getKeyword()); else pbean.setKeyword( DLOGSecurityManager.IllegalGlossary.deleteIllegalWord(photo1.getKeyword())); } pbean.setPreviewURL(img.getPreviewURL()); pbean.setImageURL(img.getImageURL()); pbean.setPhotoInfo(img); pbean.setFileName(super.autoFiltrate(site, img.getFileName())); pbean.setStatus(photo1.getStatus());//?? PhotoDAO.create(album, pbean, (photo1.getCover() == 1)); } catch (IllegalAccessException e) { msgs.add(ERROR_KEY, new ActionMessage("error.access_deny", e.getMessage())); break; } catch (Exception e) { log.error("Upload photo file failed.", e); msgs.add(ERROR_KEY, new ActionMessage("error.upload_failed", e.getMessage())); break; } } break; } while (true); if (!msgs.isEmpty()) { saveMessages(request, msgs); ActionForward upload = makeForward(mapping.findForward("photo_upload"), photo1.getSid()); upload.setRedirect(false); return upload; } String ext = "aid=" + photo1.getAlbum(); return makeForward(mapping.findForward("photo_album"), photo1.getSid(), ext); }
From source file:org.kuali.kra.budget.calculator.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 w ww . j av a2 s .co 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) { noSuchMethodException.printStackTrace(); 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.eclipse.jubula.rc.rcp.e3.gef.tester.FigureCanvasTester.java
/** * Checks the given property of the figure at the given path. * * @param textPath The path to the figure. * @param textPathOperator The operator used for matching the text path. * @param propertyName The name of the property * @param expectedPropValue The value of the property as a string * @param valueOperator The operator used to verify *//*from ww w .j a v a 2 s . co m*/ public void rcVerifyFigureProperty(String textPath, String textPathOperator, final String propertyName, String expectedPropValue, String valueOperator) { final IFigure figure = findFigure(findEditPart(textPath, textPathOperator)); if (figure == null) { throw new StepExecutionException("No figure could be found for the given text path.", //$NON-NLS-1$ EventFactory.createActionError(TestErrorEvent.NOT_FOUND)); } Object prop = getEventThreadQueuer().invokeAndWait("getProperty", //$NON-NLS-1$ new IRunnable() { public Object run() throws StepExecutionException { try { return PropertyUtils.getProperty(figure, propertyName); } catch (IllegalAccessException e) { throw new StepExecutionException(e.getMessage(), EventFactory.createActionError(TestErrorEvent.PROPERTY_NOT_ACCESSABLE)); } catch (InvocationTargetException e) { throw new StepExecutionException(e.getMessage(), EventFactory.createActionError(TestErrorEvent.PROPERTY_NOT_ACCESSABLE)); } catch (NoSuchMethodException e) { throw new StepExecutionException(e.getMessage(), EventFactory.createActionError(TestErrorEvent.PROPERTY_NOT_ACCESSABLE)); } } }); final String propToStr = String.valueOf(prop); Verifier.match(propToStr, expectedPropValue, valueOperator); }
From source file:com.snaplogic.snaps.firstdata.Create.java
private Object setArrayObj(Object requestObj, String claszPath, Map<String, Object> inputData) { if (inputData != null) { Class<?> clasz = getClassType(claszPath); Object obj = null;/*from w w w . ja v a 2 s .c o m*/ List<Object> list; for (Method method : findGetters(clasz)) { String declareClasz = method.getReturnType().getName(); if (declareClasz != List.class.getSimpleName()) { continue; } try { list = (List<Object>) method.invoke(requestObj); if ((obj = inputData.get(getFieldName(method.getName()))) == null) { continue; } if (obj instanceof List) { for (Object data : List.class.cast(obj)) { list.add(data); } } else if (obj instanceof String) { list.add(obj); } } catch (IllegalAccessException e) { log.warn(e.getMessage(), e); } catch (IllegalArgumentException e) { log.warn(e.getMessage(), e); } catch (InvocationTargetException e) { log.warn(e.getMessage(), e); } catch (Exception e) { log.warn(e.getMessage(), e); } } } return requestObj; }
From source file:au.org.theark.lims.web.component.biospecimen.batchaliquot.form.BatchAliquotBiospecimenForm.java
/** * //from w w w .j a v a2 s .c om * @return the listEditor of Biospecimens to aliquot */ public AbstractListEditor<Biospecimen> buildListEditor() { listEditor = new AbstractListEditor<Biospecimen>("aliquots", new PropertyModel(getModelObject(), "aliquots")) { private static final long serialVersionUID = 1L; @SuppressWarnings("serial") @Override protected void onPopulateItem(final ListItem<Biospecimen> item) { item.setOutputMarkupId(true); Biospecimen parentBiospecimen = BatchAliquotBiospecimenForm.this.getModelObject() .getParentBiospecimen(); try { PropertyUtils.copyProperties(item.getModelObject(), parentBiospecimen); } catch (IllegalAccessException e1) { log.error(e1.getMessage()); } catch (InvocationTargetException e1) { log.error(e1.getMessage()); } catch (NoSuchMethodException e1) { log.error(e1.getMessage()); } if (copyBiospecimen) { item.getModelObject().setParent(parentBiospecimen); item.getModelObject().setParentUid(parentBiospecimen.getBiospecimenUid()); item.getModelObject().setQuantity(biospecimenToCopy.getQuantity()); item.getModelObject().setTreatmentType(biospecimenToCopy.getTreatmentType()); item.getModelObject().setConcentration(biospecimenToCopy.getConcentration()); } else { item.getModelObject().setParent(parentBiospecimen); item.getModelObject().setParentUid(parentBiospecimen.getBiospecimenUid()); item.getModelObject().setQuantity(null); item.getModelObject().setConcentration(null); } biospecimenUidTxtFld = new TextField<String>("biospecimenUid", new PropertyModel(item.getModelObject(), "biospecimenUid")); if (parentBiospecimen.getStudy().getAutoGenerateBiospecimenUid()) { biospecimenUidTxtFld.setEnabled(false); biospecimenUidTxtFld.setModelObject(Constants.AUTO_GENERATED); } else { biospecimenUidTxtFld.setEnabled(true); biospecimenUidTxtFld.setModelObject(null); } quantityTxtFld = new TextField<Double>("quantity", new PropertyModel(item.getModelObject(), "quantity")) { private static final long serialVersionUID = 1L; @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; initTreatmentTypeDdc(item); concentrationTxtFld = new TextField<Number>("concentration", new PropertyModel(item.getModelObject(), "concentration")); item.add(biospecimenUidTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (!item.getModelObject().getStudy().getAutoGenerateBiospecimenUid()) { // Check BiospecimenUID is unique String biospecimenUid = (getComponent().getDefaultModelObject().toString() != null ? getComponent().getDefaultModelObject().toString() : new String()); Biospecimen biospecimen = iLimsService.getBiospecimenByUid(biospecimenUid, item.getModelObject().getStudy()); if (biospecimen != null && biospecimen.getId() != null) { error("Biospecimen UID must be unique. Please try again."); target.focusComponent(getComponent()); } } target.add(feedbackPanel); biospecimenToCopy.setBiospecimenUid(getComponent().getDefaultModelObject().toString()); } })); item.add(quantityTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (!totalQuantityLessThanParentQuantity()) { target.focusComponent(getComponent()); } target.add(feedbackPanel); biospecimenToCopy.setQuantity((Double) getComponent().getDefaultModelObject()); item.getModelObject().setQuantity((Double) getComponent().getDefaultModelObject()); } @Override protected void onError(AjaxRequestTarget target, RuntimeException e) { target.add(feedbackPanel); } })); item.add(treatmentTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { biospecimenToCopy.setTreatmentType((TreatmentType) getComponent().getDefaultModelObject()); item.getModelObject() .setTreatmentType((TreatmentType) getComponent().getDefaultModelObject()); } })); item.add(concentrationTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { biospecimenToCopy.setConcentration((Double) getComponent().getDefaultModelObject()); item.getModelObject().setConcentration((Double) getComponent().getDefaultModelObject()); } })); // Copy button allows entire row details to be copied item.add(new AjaxEditorButton(Constants.COPY) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Biospecimen biospecimen = new Biospecimen(); copyBiospecimen = true; try { PropertyUtils.copyProperties(biospecimen, getItem().getModelObject()); PropertyUtils.copyProperties(biospecimenToCopy, getItem().getModelObject()); listEditor.addItem(biospecimen); target.add(form); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } }.setDefaultFormProcessing(false)); item.add(new AjaxEditorButton(Constants.DELETE) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { listEditor.removeItem(item); target.add(form); } }.setDefaultFormProcessing(false).setVisible(item.getIndex() > 0)); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return listEditor; }
From source file:org.commonjava.rwx.binding.internal.reflect.ReflectionUnbinder.java
private Object fireValueEvents(final FieldBinding binding, final Object parent, final XmlRpcListener listener, boolean ignoreSkipNulls, EventCallback before, EventCallback after) throws XmlRpcException { Logger logger = LoggerFactory.getLogger(getClass()); final Class<?> parentCls = parent.getClass(); try {// w ww . j a v a 2s .co m final Field field = findField(binding, parentCls); field.setAccessible(true); Object value = field.get(parent); if (!ignoreSkipNulls && isNullSuppressed(field, parentCls, value)) { logger.debug("Skipping null value for: {}", field); return null; } // else if ( value == null ) // { // listener.value( null, ValueType.NIL ); // return null; // } ValueType type = typeOf(value, binding); logger.debug("ValueType for {} in binding: {} is: {}.", value, binding, type); if (before != null) { if (!before.call(value, type)) { return null; } } Converter converter = field.getAnnotation(Converter.class); if (converter == null) { Class<?> fieldType = field.getType(); converter = fieldType.getAnnotation(Converter.class); } if (converter != null) { final ValueBinder vc = XBRBinderInstantiator.newValueUnbinder(converter); logger.debug("Calling: {}.generate(..)", vc.getClass().getName()); vc.generate(listener, value, recipesByClass); } else if (recipesByClass.containsKey(binding.getFieldType())) { logger.debug( "Finding appropriate event-firing mechanism for field: {} with value-type: {} (value is: {})", binding, type, value); if (type == ValueType.ARRAY) { logger.debug("Firing array events for: {}", binding); value = fireArrayEvents(binding, value, listener); } else if (type == ValueType.STRUCT) { logger.debug("Firing struct events for: {}", binding); value = fireStructEvents(binding, value, listener); } else if (type != NIL) { throw new BindException("Unknown recipe reference type: " + binding.getFieldType() + "\nValue: " + value + "\nField: " + binding.getFieldName() + "\nClass: " + parentCls.getName() + "\nAll recipe classes:\n\n " + StringUtils.join(recipesByClass.keySet(), "\n ")); } logger.debug("Firing value event for: {} on binding: {} with ValueType: {}", value, binding, type); listener.value(value, type); } else { logger.debug( "No recipe found for field: {} with value-type: {} (value is: {}). Trying to fire raw map/collection events...", binding, type, value); final Contains contains = field.getAnnotation(Contains.class); final SkipContainedNull skipContainedNull = field.getAnnotation(SkipContainedNull.class); if (Map.class.isAssignableFrom(binding.getFieldType())) { logger.debug("Firing map events for: {}", binding); type = ValueType.STRUCT; fireMapEvents(value, binding, contains, skipContainedNull, listener); } else if (binding.getFieldType().isArray() || Collection.class.isAssignableFrom(binding.getFieldType())) { logger.debug("Firing collection events for: {}", binding); type = ValueType.ARRAY; fireCollectionEvents(value, binding, contains, skipContainedNull, listener); } logger.debug("Firing value event for: {} on binding: {} with ValueType: {}", value, binding, type); listener.value(value, type); } if (after != null) { if (!after.call(value, type)) { return null; } } return value; } catch (final IllegalAccessException e) { throw new BindException("Cannot retrieve field: " + binding.getFieldName() + " in class: " + parentCls.getName() + "\nError: " + e.getMessage(), e); } }