@Test( expected = NullPointerException.class ) public void testGetReferencedFieldsWithoutElement() { attrCore.getReferencedFields( metaData, null, null ); }
public String[] getReferencedFields( final AttributeMetaData metaData, final ReportElement element, final Object attributeValue ) { if ( element == null ) { throw new NullPointerException(); } if ( attributeValue == null ) { return EMPTY; } final String valueRole = metaData.getValueRole(); if ( "Field".equals( valueRole ) ) { if ( attributeValue instanceof String[] ) { final String[] vals = (String[]) attributeValue; return vals.clone(); } return new String[] { String.valueOf( attributeValue ) }; } else if ( "Message".equals( valueRole ) ) { final String message = String.valueOf( attributeValue ); final MessageFormatSupport messageFormatSupport = new MessageFormatSupport(); messageFormatSupport.setFormatString( message ); return messageFormatSupport.getFields(); } else if ( "Formula".equals( valueRole ) ) { final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList<String> list = new ArrayList<String>(); for ( int i = 0; i < objects.length; i++ ) { final Object object = objects[i]; if ( object instanceof String ) { list.add( (String) object ); } } return list.toArray( new String[list.size()] ); } catch ( ParseException e ) { return EMPTY; } } return EMPTY; }
DefaultAttributeCore implements AttributeCore { public String[] getReferencedFields( final AttributeMetaData metaData, final ReportElement element, final Object attributeValue ) { if ( element == null ) { throw new NullPointerException(); } if ( attributeValue == null ) { return EMPTY; } final String valueRole = metaData.getValueRole(); if ( "Field".equals( valueRole ) ) { if ( attributeValue instanceof String[] ) { final String[] vals = (String[]) attributeValue; return vals.clone(); } return new String[] { String.valueOf( attributeValue ) }; } else if ( "Message".equals( valueRole ) ) { final String message = String.valueOf( attributeValue ); final MessageFormatSupport messageFormatSupport = new MessageFormatSupport(); messageFormatSupport.setFormatString( message ); return messageFormatSupport.getFields(); } else if ( "Formula".equals( valueRole ) ) { final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList<String> list = new ArrayList<String>(); for ( int i = 0; i < objects.length; i++ ) { final Object object = objects[i]; if ( object instanceof String ) { list.add( (String) object ); } } return list.toArray( new String[list.size()] ); } catch ( ParseException e ) { return EMPTY; } } return EMPTY; } }
DefaultAttributeCore implements AttributeCore { public String[] getReferencedFields( final AttributeMetaData metaData, final ReportElement element, final Object attributeValue ) { if ( element == null ) { throw new NullPointerException(); } if ( attributeValue == null ) { return EMPTY; } final String valueRole = metaData.getValueRole(); if ( "Field".equals( valueRole ) ) { if ( attributeValue instanceof String[] ) { final String[] vals = (String[]) attributeValue; return vals.clone(); } return new String[] { String.valueOf( attributeValue ) }; } else if ( "Message".equals( valueRole ) ) { final String message = String.valueOf( attributeValue ); final MessageFormatSupport messageFormatSupport = new MessageFormatSupport(); messageFormatSupport.setFormatString( message ); return messageFormatSupport.getFields(); } else if ( "Formula".equals( valueRole ) ) { final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList<String> list = new ArrayList<String>(); for ( int i = 0; i < objects.length; i++ ) { final Object object = objects[i]; if ( object instanceof String ) { list.add( (String) object ); } } return list.toArray( new String[list.size()] ); } catch ( ParseException e ) { return EMPTY; } } return EMPTY; } DefaultAttributeCore(); }
DefaultAttributeCore implements AttributeCore { public String[] getReferencedFields( final AttributeMetaData metaData, final ReportElement element, final Object attributeValue ) { if ( element == null ) { throw new NullPointerException(); } if ( attributeValue == null ) { return EMPTY; } final String valueRole = metaData.getValueRole(); if ( "Field".equals( valueRole ) ) { if ( attributeValue instanceof String[] ) { final String[] vals = (String[]) attributeValue; return vals.clone(); } return new String[] { String.valueOf( attributeValue ) }; } else if ( "Message".equals( valueRole ) ) { final String message = String.valueOf( attributeValue ); final MessageFormatSupport messageFormatSupport = new MessageFormatSupport(); messageFormatSupport.setFormatString( message ); return messageFormatSupport.getFields(); } else if ( "Formula".equals( valueRole ) ) { final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList<String> list = new ArrayList<String>(); for ( int i = 0; i < objects.length; i++ ) { final Object object = objects[i]; if ( object instanceof String ) { list.add( (String) object ); } } return list.toArray( new String[list.size()] ); } catch ( ParseException e ) { return EMPTY; } } return EMPTY; } DefaultAttributeCore(); String[] getReferencedFields( final AttributeMetaData metaData, final ReportElement element,
      final Object attributeValue ); String[] getReferencedGroups( final AttributeMetaData metaData, final ReportElement element,
      final Object attributeValue ); ResourceReference[] getReferencedResources( final AttributeMetaData metaData, final ReportElement element,
      final ResourceManager resourceManager, final Object attributeValue ); String[] getExtraCalculationFields( final AttributeMetaData metaData ); }
DefaultAttributeCore implements AttributeCore { public String[] getReferencedFields( final AttributeMetaData metaData, final ReportElement element, final Object attributeValue ) { if ( element == null ) { throw new NullPointerException(); } if ( attributeValue == null ) { return EMPTY; } final String valueRole = metaData.getValueRole(); if ( "Field".equals( valueRole ) ) { if ( attributeValue instanceof String[] ) { final String[] vals = (String[]) attributeValue; return vals.clone(); } return new String[] { String.valueOf( attributeValue ) }; } else if ( "Message".equals( valueRole ) ) { final String message = String.valueOf( attributeValue ); final MessageFormatSupport messageFormatSupport = new MessageFormatSupport(); messageFormatSupport.setFormatString( message ); return messageFormatSupport.getFields(); } else if ( "Formula".equals( valueRole ) ) { final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList<String> list = new ArrayList<String>(); for ( int i = 0; i < objects.length; i++ ) { final Object object = objects[i]; if ( object instanceof String ) { list.add( (String) object ); } } return list.toArray( new String[list.size()] ); } catch ( ParseException e ) { return EMPTY; } } return EMPTY; } DefaultAttributeCore(); String[] getReferencedFields( final AttributeMetaData metaData, final ReportElement element,
      final Object attributeValue ); String[] getReferencedGroups( final AttributeMetaData metaData, final ReportElement element,
      final Object attributeValue ); ResourceReference[] getReferencedResources( final AttributeMetaData metaData, final ReportElement element,
      final ResourceManager resourceManager, final Object attributeValue ); String[] getExtraCalculationFields( final AttributeMetaData metaData );  }