@Test public void testGetReferencedFields() { String[] result = preProcessor.getReferencedFields( metaData, expression, null ); assertThat( result, is( emptyArray() ) ); String[] attributeValue = new String[] { "attr_0" }; doReturn( "Field" ).when( metaData ).getPropertyRole(); result = preProcessor.getReferencedFields( metaData, expression, attributeValue ); assertThat( result, is( equalTo( attributeValue ) ) ); result = preProcessor.getReferencedFields( metaData, expression, attributeValue[0] ); assertThat( result, is( equalTo( attributeValue ) ) ); doReturn( "Message" ).when( metaData ).getPropertyRole(); result = preProcessor.getReferencedFields( metaData, expression, attributeValue[0] ); assertThat( result, is( emptyArray() ) ); doReturn( "Formula" ).when( metaData ).getPropertyRole(); result = preProcessor.getReferencedFields( metaData, expression, "namespace:[a+b]" ); assertThat( result, is( equalTo( new String[] { "a+b" } ) ) ); doReturn( "Formula" ).when( metaData ).getPropertyRole(); result = preProcessor.getReferencedFields( metaData, expression, "namespace" ); assertThat( result, is( emptyArray() ) ); doReturn( "incorrect" ).when( metaData ).getPropertyRole(); result = preProcessor.getReferencedFields( metaData, expression, "namespace:[a+b]" ); assertThat( result, is( emptyArray() ) ); }
public String[] getReferencedFields( final ReportPreProcessorPropertyMetaData metaData, final Expression expression, final Object attributeValue ) { if ( expression == null ) { throw new NullPointerException(); } if ( attributeValue == null ) { return EMPTY; } final String propertyRole = metaData.getPropertyRole(); if ( "Field".equals( propertyRole ) ) { if ( attributeValue instanceof String[] ) { final String[] vals = (String[]) attributeValue; return (String[]) vals.clone(); } return new String[] { String.valueOf( attributeValue ) }; } else if ( "Message".equals( propertyRole ) ) { final String message = String.valueOf( attributeValue ); final MessageFormatSupport messageFormatSupport = new MessageFormatSupport(); messageFormatSupport.setFormatString( message ); return messageFormatSupport.getFields(); } else if ( "Formula".equals( propertyRole ) ) { final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList list = new ArrayList(); for ( int i = 0; i < objects.length; i++ ) { final Object object = objects[i]; if ( object instanceof String ) { list.add( object ); } } return (String[]) list.toArray( new String[list.size()] ); } catch ( ParseException e ) { return EMPTY; } } return EMPTY; }
DefaultReportPreProcessorPropertyCore implements ReportPreProcessorPropertyCore { public String[] getReferencedFields( final ReportPreProcessorPropertyMetaData metaData, final Expression expression, final Object attributeValue ) { if ( expression == null ) { throw new NullPointerException(); } if ( attributeValue == null ) { return EMPTY; } final String propertyRole = metaData.getPropertyRole(); if ( "Field".equals( propertyRole ) ) { if ( attributeValue instanceof String[] ) { final String[] vals = (String[]) attributeValue; return (String[]) vals.clone(); } return new String[] { String.valueOf( attributeValue ) }; } else if ( "Message".equals( propertyRole ) ) { final String message = String.valueOf( attributeValue ); final MessageFormatSupport messageFormatSupport = new MessageFormatSupport(); messageFormatSupport.setFormatString( message ); return messageFormatSupport.getFields(); } else if ( "Formula".equals( propertyRole ) ) { final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList list = new ArrayList(); for ( int i = 0; i < objects.length; i++ ) { final Object object = objects[i]; if ( object instanceof String ) { list.add( object ); } } return (String[]) list.toArray( new String[list.size()] ); } catch ( ParseException e ) { return EMPTY; } } return EMPTY; } }
DefaultReportPreProcessorPropertyCore implements ReportPreProcessorPropertyCore { public String[] getReferencedFields( final ReportPreProcessorPropertyMetaData metaData, final Expression expression, final Object attributeValue ) { if ( expression == null ) { throw new NullPointerException(); } if ( attributeValue == null ) { return EMPTY; } final String propertyRole = metaData.getPropertyRole(); if ( "Field".equals( propertyRole ) ) { if ( attributeValue instanceof String[] ) { final String[] vals = (String[]) attributeValue; return (String[]) vals.clone(); } return new String[] { String.valueOf( attributeValue ) }; } else if ( "Message".equals( propertyRole ) ) { final String message = String.valueOf( attributeValue ); final MessageFormatSupport messageFormatSupport = new MessageFormatSupport(); messageFormatSupport.setFormatString( message ); return messageFormatSupport.getFields(); } else if ( "Formula".equals( propertyRole ) ) { final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList list = new ArrayList(); for ( int i = 0; i < objects.length; i++ ) { final Object object = objects[i]; if ( object instanceof String ) { list.add( object ); } } return (String[]) list.toArray( new String[list.size()] ); } catch ( ParseException e ) { return EMPTY; } } return EMPTY; } DefaultReportPreProcessorPropertyCore(); }
DefaultReportPreProcessorPropertyCore implements ReportPreProcessorPropertyCore { public String[] getReferencedFields( final ReportPreProcessorPropertyMetaData metaData, final Expression expression, final Object attributeValue ) { if ( expression == null ) { throw new NullPointerException(); } if ( attributeValue == null ) { return EMPTY; } final String propertyRole = metaData.getPropertyRole(); if ( "Field".equals( propertyRole ) ) { if ( attributeValue instanceof String[] ) { final String[] vals = (String[]) attributeValue; return (String[]) vals.clone(); } return new String[] { String.valueOf( attributeValue ) }; } else if ( "Message".equals( propertyRole ) ) { final String message = String.valueOf( attributeValue ); final MessageFormatSupport messageFormatSupport = new MessageFormatSupport(); messageFormatSupport.setFormatString( message ); return messageFormatSupport.getFields(); } else if ( "Formula".equals( propertyRole ) ) { final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList list = new ArrayList(); for ( int i = 0; i < objects.length; i++ ) { final Object object = objects[i]; if ( object instanceof String ) { list.add( object ); } } return (String[]) list.toArray( new String[list.size()] ); } catch ( ParseException e ) { return EMPTY; } } return EMPTY; } DefaultReportPreProcessorPropertyCore(); String[] getReferencedFields( final ReportPreProcessorPropertyMetaData metaData, final Expression expression,
      final Object attributeValue ); String[] getReferencedGroups( final ReportPreProcessorPropertyMetaData metaData, final Expression expression,
      final Object attributeValue ); String[] getReferencedElements( final ReportPreProcessorPropertyMetaData metaData,
      final Expression expression, final Object attributeValue ); ResourceReference[] getReferencedResources( final ReportPreProcessorPropertyMetaData metaData,
      final Expression expression, final Object attributeValue, final Element reportElement,
      final ResourceManager resourceManager ); String[] getExtraCalculationFields( final ReportPreProcessorPropertyMetaData metaData ); }
DefaultReportPreProcessorPropertyCore implements ReportPreProcessorPropertyCore { public String[] getReferencedFields( final ReportPreProcessorPropertyMetaData metaData, final Expression expression, final Object attributeValue ) { if ( expression == null ) { throw new NullPointerException(); } if ( attributeValue == null ) { return EMPTY; } final String propertyRole = metaData.getPropertyRole(); if ( "Field".equals( propertyRole ) ) { if ( attributeValue instanceof String[] ) { final String[] vals = (String[]) attributeValue; return (String[]) vals.clone(); } return new String[] { String.valueOf( attributeValue ) }; } else if ( "Message".equals( propertyRole ) ) { final String message = String.valueOf( attributeValue ); final MessageFormatSupport messageFormatSupport = new MessageFormatSupport(); messageFormatSupport.setFormatString( message ); return messageFormatSupport.getFields(); } else if ( "Formula".equals( propertyRole ) ) { final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList list = new ArrayList(); for ( int i = 0; i < objects.length; i++ ) { final Object object = objects[i]; if ( object instanceof String ) { list.add( object ); } } return (String[]) list.toArray( new String[list.size()] ); } catch ( ParseException e ) { return EMPTY; } } return EMPTY; } DefaultReportPreProcessorPropertyCore(); String[] getReferencedFields( final ReportPreProcessorPropertyMetaData metaData, final Expression expression,
      final Object attributeValue ); String[] getReferencedGroups( final ReportPreProcessorPropertyMetaData metaData, final Expression expression,
      final Object attributeValue ); String[] getReferencedElements( final ReportPreProcessorPropertyMetaData metaData,
      final Expression expression, final Object attributeValue ); ResourceReference[] getReferencedResources( final ReportPreProcessorPropertyMetaData metaData,
      final Expression expression, final Object attributeValue, final Element reportElement,
      final ResourceManager resourceManager ); String[] getExtraCalculationFields( final ReportPreProcessorPropertyMetaData metaData );  }