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
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.springframework.batch.classify;
A special purpose Classifier with easy configuration options for mapping from one arbitrary type of object to another via a pattern matcher.

Dave Syer
public class BackToBackPatternClassifier<C, T> implements Classifier<C, T> {
	private Classifier<C, Stringrouter;
	private Classifier<String, T> matcher;

Default constructor, provided as a convenience for people using setter injection.

Set up a classifier with input to the router and output from the matcher.

	public BackToBackPatternClassifier(Classifier<C, StringrouterClassifier<String, T> matcher) {
		this. = router;
		this. = matcher;

A convenience method for creating a pattern matching classifier for the matcher component.

map maps pattern keys with wildcards to output values
	public void setMatcherMap(Map<String, T> map) {
		this. = new PatternMatchingClassifier<T>(map);

A convenience method of creating a router classifier based on a plain old Java Object. The object provided must have precisely one public method that either has the

delegate the delegate object used to create a router classifier
annotation or accepts a single argument and outputs a String. This will be used to create an input classifier for the router component.
	public void setRouterDelegate(Object delegate) {
		this. = new ClassifierAdapter<C,String>(delegate);

Classify the input and map to a String, then take that and put it into a pattern matcher to match to an output value.
	public T classify(C classifiable) {
		return .classify(.classify(classifiable));
New to GrepCode? Check out our FAQ X