org.springframework.batch.item.file.transform
Class RangeArrayPropertyEditor

java.lang.Object
  extended by java.beans.PropertyEditorSupport
      extended by org.springframework.batch.item.file.transform.RangeArrayPropertyEditor
All Implemented Interfaces:
PropertyEditor

public class RangeArrayPropertyEditor
extends PropertyEditorSupport

Property editor implementation which parses string and creates array of ranges. Ranges can be provided in any order.
Input string should be provided in following format: 'range1, range2, range3,...' where range is specified as:

Minimum and maximum values can be from interval <1, Integer.MAX_VALUE-1>

Examples:
'1, 15, 25, 38, 55-60' is equal to '1-14, 15-24, 25-37, 38-54, 55-60'
'36, 14, 1-10, 15, 49-57' is equal to '36-48, 14-14, 1-10, 15-35, 49-57'

Property editor also allows to validate whether ranges are disjoint. Validation can be turned on/off by using setForceDisjointRanges(boolean). By default validation is turned off.

Author:
peter.zozom

Constructor Summary
RangeArrayPropertyEditor()
           
 
Method Summary
 String getAsText()
           
 void setAsText(String text)
           
 void setForceDisjointRanges(boolean forceDisjointRanges)
          Set force disjoint ranges.
 
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, setValue, supportsCustomEditor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RangeArrayPropertyEditor

public RangeArrayPropertyEditor()
Method Detail

setForceDisjointRanges

public void setForceDisjointRanges(boolean forceDisjointRanges)
Set force disjoint ranges. If set to TRUE, ranges are validated to be disjoint. For example: defining ranges '1-10, 5-15' will cause IllegalArgumentException in case of forceDisjointRanges=TRUE.

Parameters:
forceDisjointRanges -

setAsText

public void setAsText(String text)
               throws IllegalArgumentException
Specified by:
setAsText in interface PropertyEditor
Overrides:
setAsText in class PropertyEditorSupport
Throws:
IllegalArgumentException

getAsText

public String getAsText()
Specified by:
getAsText in interface PropertyEditor
Overrides:
getAsText in class PropertyEditorSupport


Copyright © 2013 SpringSource. All Rights Reserved.