com.google.code.validationframework.swing.dataprovider
Class JSpinnerEditorValueProvider<DPO>

java.lang.Object
  extended by com.google.code.validationframework.swing.dataprovider.JSpinnerEditorValueProvider<DPO>
Type Parameters:
DPO - Type of data in the spinner editor.
You may use Object.
All Implemented Interfaces:
com.google.code.validationframework.api.dataprovider.DataProvider<DPO>

public class JSpinnerEditorValueProvider<DPO>
extends Object
implements com.google.code.validationframework.api.dataprovider.DataProvider<DPO>

Data provider reading the value from a spinner.
Note that the value is not read from the model, but instead corresponds to the current text.

See Also:
DataProvider, JSpinner

Constructor Summary
JSpinnerEditorValueProvider(JSpinner spinner)
          Constructor specifying the spinner to get the value from.
JSpinnerEditorValueProvider(JSpinner spinner, com.google.code.validationframework.base.transform.Transformer<Object,DPO> transformer)
          Constructor specifying the spinner to get the value from and the transformer to convert it to the required type.
 
Method Summary
 JSpinner getComponent()
          Gets the component providing the data to be validated.
 DPO getData()
           
protected  JFormattedTextField.AbstractFormatter getFormatter()
          Retrieves the formatter currently in the text component of the spinner, if any.
Note that if editor of the spinner has been customized, this method may need to be adapted in a sub-class.
protected  String getText()
          Retrieves the text currently in the text component of the spinner, if any.
Note that if editor of the spinner has been customized, this method may need to be adapted in a sub-class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSpinnerEditorValueProvider

public JSpinnerEditorValueProvider(JSpinner spinner)
Constructor specifying the spinner to get the value from.

Parameters:
spinner - Spinner to get the value from.

JSpinnerEditorValueProvider

public JSpinnerEditorValueProvider(JSpinner spinner,
                                   com.google.code.validationframework.base.transform.Transformer<Object,DPO> transformer)
Constructor specifying the spinner to get the value from and the transformer to convert it to the required type.

Parameters:
spinner - Spinner to get the value from.
transformer - Transformer used to convert the object parsed from the spinner to the expected type.
Method Detail

getComponent

public JSpinner getComponent()
Gets the component providing the data to be validated.

Returns:
Component providing the data to be validated.

getData

public DPO getData()
Specified by:
getData in interface com.google.code.validationframework.api.dataprovider.DataProvider<DPO>
See Also:
DataProvider.getData()

getText

protected String getText()
Retrieves the text currently in the text component of the spinner, if any.
Note that if editor of the spinner has been customized, this method may need to be adapted in a sub-class.

Returns:
Spinner text or null if not found.

getFormatter

protected JFormattedTextField.AbstractFormatter getFormatter()
Retrieves the formatter currently in the text component of the spinner, if any.
Note that if editor of the spinner has been customized, this method may need to be adapted in a sub-class.

Returns:
Spinner formatter or null if not found.


Copyright © 2013. All Rights Reserved.