public ExpressionPropertiesReadHandler( final Expression expression, final String originalExpressionClass, final String expressionClass ) throws IntrospectionException { this.originalExpressionClass = originalExpressionClass; this.expressionClass = expressionClass; this.beanUtility = new BeanUtility( expression ); this.expression = expression; }
public ExpressionsDataAttributes( final Expression expression ) { if ( expression == null ) { throw new NullPointerException(); } if ( expression.getName() == null ) { throw new IllegalStateException(); } this.expressionType = expression.getClass(); if ( ExpressionRegistry.getInstance().isExpressionRegistered( expressionType.getName() ) ) { this.expressionMetaData = ExpressionRegistry.getInstance().getExpressionMetaData( expressionType.getName() ); this.resultType = expressionMetaData.getResultType(); this.expressionProperties = StringUtils.merge( expressionMetaData.getPropertyNames(), ExpressionsDataAttributes.EXPRESSIONNAMES ); } else { this.expressionMetaData = null; this.resultType = Object.class; this.expressionProperties = ExpressionsDataAttributes.EXPRESSIONNAMES; } this.expressionName = expression.getName(); try { this.beanUtility = new BeanUtility( expression ); } catch ( IntrospectionException e ) { // should not happen, but if it does, we simply ignore the bean-metadata. } }
private void writePreProcessor( final XmlWriter writer, final ReportPreProcessor preProcessor ) throws IntrospectionException, BeanException, IOException { if ( writer == null ) { throw new NullPointerException(); } if ( preProcessor == null ) { throw new NullPointerException(); } // the classic way, in case the expression does not provide any meta-data. This is // in the code for legacy reasons, as there are many expression implementations out there // that do not yet provide meta-data descriptions .. final BeanUtility beanUtility = new BeanUtility( preProcessor ); final String[] propertyNames = beanUtility.getProperties(); for ( int i = 0; i < propertyNames.length; i++ ) { final String key = propertyNames[i]; final Object property = beanUtility.getProperty( key ); final Class propertyType = beanUtility.getPropertyType( key ); final String value = beanUtility.getPropertyAsString( key ); if ( value != null && property != null ) { final AttributeList attList = new AttributeList(); attList.setAttribute( BundleNamespaces.LAYOUT, "name", key ); if ( BeanUtility.isSameType( propertyType, property.getClass() ) == false ) { attList.setAttribute( BundleNamespaces.LAYOUT, "class", property.getClass().getName() ); } writer.writeTag( BundleNamespaces.LAYOUT, "property", attList, XmlWriterSupport.OPEN ); writer.writeTextNormalized( value, false ); writer.writeCloseTag(); } } }
/** * Starts parsing. * * @param attrs * the attributes. * @throws SAXException * if there is a parsing error. */ protected void startParsing( final Attributes attrs ) throws SAXException { final String preprocessorClass = attrs.getValue( getUri(), "class" ); if ( preprocessorClass == null ) { throw new ParseException( "Required attribute 'class' is missing" ); } preProcessor = (ReportPreProcessor) ObjectUtilities.loadAndInstantiate( CompatibilityMapperUtil .mapClassName( preprocessorClass ), LayoutPreprocessorReadHandler.class, ReportPreProcessor.class ); if ( preProcessor == null ) { throw new ParseException( "Failed to instantiate the specified preprocessor '" + preprocessorClass + '\'', getLocator() ); } try { this.beanUtility = new BeanUtility( preProcessor ); } catch ( IntrospectionException e ) { throw new ParseException( "Failed to introspect the specified preprocessor '" + preprocessorClass + '\'', getLocator() ); } }
public void testSimpleProperties() throws IntrospectionException, BeanException { final BeanUtility bu = new BeanUtility( new TestBean() ); validateProperty( bu, "simpleColor", Color.red, null ); validateProperty( bu, "simpleString", "Hello World", null ); validateProperty( bu, "simpleBool", Boolean.TRUE, Boolean.FALSE ); validateProperty( bu, "simpleDouble", new Double( 100 ), new Double( 0 ) ); validateProperty( bu, "arrayOnly", new String[] { "test" }, new String[0] ); validateProperty( bu, "fullyIndexed", new String[] { "test" }, new String[0] ); }
final BeanUtility bu = new BeanUtility( expression ); final ExpressionPropertyMetaData[] expressionProperties = emd.getPropertyDescriptions(); boolean propertiesOpen = false; final BeanUtility beanUtility = new BeanUtility( expression ); final String[] propertyNames = beanUtility.getProperties();
public void testIndexedProperties() throws IntrospectionException, BeanException { final TestBean testBean = new TestBean(); testBean.setArrayOnly( new String[1] ); testBean.setFullyIndexed( new String[1] ); testBean.setIndexOnly( 0, null ); final BeanUtility bu = new BeanUtility( testBean ); validateProperty( bu, "arrayOnly[0]", "Color.red", null ); validateProperty( bu, "fullyIndexed[0]", "Hello World", null ); validateProperty( bu, "indexOnly[0]", "Boolean.TRUE", null ); }
final BeanUtility bu = new BeanUtility( expression ); final String[] propertyNames = bu.getProperties(); if ( propertyNames.length == 0 ) {
final BeanUtility bu = new BeanUtility( expression ); final String[] propertyNames = bu.getProperties(); if ( propertyNames.length == 0 ) {