/** * Starts parsing. * * @param attrs the attributes. * @throws org.xml.sax.SAXException if there is a parsing error. */ public void startParsing(final PropertyAttributes attrs) throws SAXException { super.startParsing(attrs); propertyType = CompatibilityMapperUtil.mapClassName( attrs.getValue(getUri(), ExpressionPropertyReadHandler.CLASS_ATT)); propertyName = attrs.getValue(getUri(), ExpressionPropertyReadHandler.NAME_ATT); if (propertyName == null) { throw new ParseException("Required attribute 'name' is null.", getLocator()); } }
/** * Done parsing. * * @throws org.xml.sax.SAXException if there is a parsing error. */ public void doneParsing() throws SAXException { super.doneParsing(); final String result = getResult(); final String propertyName = CompatibilityMapperUtil.mapExpressionProperty( originalExpressionClass, expressionClass, this.propertyName); if (beanUtility == null) { throw new ParseException("No current beanUtility", getLocator()); } try { if (propertyType != null) { final ClassLoader cl = ObjectUtilities.getClassLoader(ExpressionPropertyReadHandler.class); final Class c = Class.forName(propertyType, false, cl); beanUtility.setPropertyAsString(propertyName, c, result); } else { beanUtility.setPropertyAsString(propertyName, result); } } catch (BeanException e) { if (strictParsing) { throw new ParseException( "Unable to assign property '" + propertyName + "' to expression '" + expressionName + '\'', e, getLocator()); } logger.warn( "Legacy-Parser warning: Unable to assign property '" + propertyName + "' to expression '" + expressionName + '\'', new ParseException( "Unable to assign property '" + propertyName + "' to expression '" + expressionName + '\'', e, getLocator())); } catch (ClassNotFoundException e) { throw new ParseException( "Unable to assign property '" + propertyName + "' to expression '" + expressionName + '\'', e, getLocator()); } }