Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2006-2007 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.batch.item.file.transform;
A LineAggregator implementation which produces a String by aggregating the provided item via the java.util.Formatter syntax.

Author(s):
Dave Syer
See also:
java.util.Formatter
public class FormatterLineAggregator<T> extends ExtractorLineAggregator<T> {
	private String format;
	private Locale locale = Locale.getDefault();
	private int maximumLength = 0;
	private int minimumLength = 0;

Public setter for the minimum length of the formatted string. If this is not set the default is to allow any length.

Parameters:
minimumLength the minimum length to set
	public void setMinimumLength(int minimumLength) {
		this. = minimumLength;
	}

Public setter for the maximum length of the formatted string. If this is not set the default is to allow any length.

Parameters:
maximumLength the maximum length to set
	public void setMaximumLength(int maximumLength) {
		this. = maximumLength;
	}

Set the format string used to aggregate items.

	public void setFormat(String format) {
		this. = format;
	}

Public setter for the locale.

Parameters:
locale the locale to set
	public void setLocale(Locale locale) {
		this. = locale;
	}
	protected String doAggregate(Object[] fields) {
		Assert.notNull();
		String value = String.format(fields);
		if ( > 0) {
			Assert.state(value.length() <= , String.format("String overflowed in formatter -"
" longer than %d characters: [%s"value));
		}
		if ( > 0) {
			Assert.state(value.length() >= , String.format("String underflowed in formatter -"
" shorter than %d characters: [%s"value));
		}
		return value;
	}
New to GrepCode? Check out our FAQ X