@Test public void testConvertStringValueWithoutFormatter() throws BeanException { Class type = String.class; String keyName = "key"; JTextComponent textComponent = mock( JTextComponent.class ); ParameterUpdateContext updateContext = mock( ParameterUpdateContext.class ); TextComponentEditHandler handler = new TextComponentEditHandler( type, keyName, textComponent, updateContext, null ); Object result = handler.convertValue( "test val" ); assertThat( (String) result, is( equalTo( "test val" ) ) ); }
protected Object convertValue( final String text ) throws BeanException { if ( text == null ) { return null; } if ( formatter != null ) { try { final Object o = formatter.parseObject( text ); final String asText = ConverterRegistry.toAttributeValue( o ); return ConverterRegistry.toPropertyValue( asText, getType() ); } catch ( ParseException e ) { throw new BeanException( "Failed to format object" ); } } if ( Object.class == type || String.class == type ) { return text; } return ConverterRegistry.toPropertyValue( text, type ); }
TextComponentEditHandler implements Runnable, DocumentListener, ActionListener { protected Object convertValue( final String text ) throws BeanException { if ( text == null ) { return null; } if ( formatter != null ) { try { final Object o = formatter.parseObject( text ); final String asText = ConverterRegistry.toAttributeValue( o ); return ConverterRegistry.toPropertyValue( asText, getType() ); } catch ( ParseException e ) { throw new BeanException( "Failed to format object" ); } } if ( Object.class == type || String.class == type ) { return text; } return ConverterRegistry.toPropertyValue( text, type ); } }
TextComponentEditHandler implements Runnable, DocumentListener, ActionListener { protected Object convertValue( final String text ) throws BeanException { if ( text == null ) { return null; } if ( formatter != null ) { try { final Object o = formatter.parseObject( text ); final String asText = ConverterRegistry.toAttributeValue( o ); return ConverterRegistry.toPropertyValue( asText, getType() ); } catch ( ParseException e ) { throw new BeanException( "Failed to format object" ); } } if ( Object.class == type || String.class == type ) { return text; } return ConverterRegistry.toPropertyValue( text, type ); } TextComponentEditHandler( final Class type, final String keyName, final JTextComponent textComponent,
      final ParameterUpdateContext updateContext, final Format formatter ); }
TextComponentEditHandler implements Runnable, DocumentListener, ActionListener { protected Object convertValue( final String text ) throws BeanException { if ( text == null ) { return null; } if ( formatter != null ) { try { final Object o = formatter.parseObject( text ); final String asText = ConverterRegistry.toAttributeValue( o ); return ConverterRegistry.toPropertyValue( asText, getType() ); } catch ( ParseException e ) { throw new BeanException( "Failed to format object" ); } } if ( Object.class == type || String.class == type ) { return text; } return ConverterRegistry.toPropertyValue( text, type ); } TextComponentEditHandler( final Class type, final String keyName, final JTextComponent textComponent,
      final ParameterUpdateContext updateContext, final Format formatter ); boolean isAdjustingToExternalInput(); void setAdjustingToExternalInput( final boolean adjustingToExternalInput ); void insertUpdate( final DocumentEvent e ); void removeUpdate( final DocumentEvent e ); void changedUpdate( final DocumentEvent e ); void run(); void actionPerformed( final ActionEvent e ); static TimeZone createTimeZone( final String selectedItem, final TimeZone defaultValue ); static Format createFormat( final String formatString, final Locale locale, final TimeZone timeZone,
      final Class parameterType ); }
TextComponentEditHandler implements Runnable, DocumentListener, ActionListener { protected Object convertValue( final String text ) throws BeanException { if ( text == null ) { return null; } if ( formatter != null ) { try { final Object o = formatter.parseObject( text ); final String asText = ConverterRegistry.toAttributeValue( o ); return ConverterRegistry.toPropertyValue( asText, getType() ); } catch ( ParseException e ) { throw new BeanException( "Failed to format object" ); } } if ( Object.class == type || String.class == type ) { return text; } return ConverterRegistry.toPropertyValue( text, type ); } TextComponentEditHandler( final Class type, final String keyName, final JTextComponent textComponent,
      final ParameterUpdateContext updateContext, final Format formatter ); boolean isAdjustingToExternalInput(); void setAdjustingToExternalInput( final boolean adjustingToExternalInput ); void insertUpdate( final DocumentEvent e ); void removeUpdate( final DocumentEvent e ); void changedUpdate( final DocumentEvent e ); void run(); void actionPerformed( final ActionEvent e ); static TimeZone createTimeZone( final String selectedItem, final TimeZone defaultValue ); static Format createFormat( final String formatString, final Locale locale, final TimeZone timeZone,
      final Class parameterType );  }