openamf/src/java/org/openamf/filter Filter.java,NONE,1.1 FilterException.java,NONE,1.1 BeanListToRecordSet.java,NONE,1.1

[email protected]
Newsgroups gmane.comp.java.openamf.cvs
Message-ID <[email protected]>
Update of /cvsroot/openamf/openamf/src/java/org/openamf/filter
In directory sc8-pr-cvs1:/tmp/cvs-serv4353/src/java/org/openamf/filter

Added Files:
	Filter.java FilterException.java BeanListToRecordSet.java 
Log Message:
1) renamed Translator to Filter to avoid confusion with ASTranslator
2) added abilty to have multiple result filters on a service method

--- NEW FILE: Filter.java ---
package org.openamf.filter;

import org.openamf.config.FilterConfig;

public interface Filter {
	
	public Object translate(Object value, FilterConfig config) throws FilterException;

}

--- NEW FILE: FilterException.java ---
package org.openamf.filter;

public class FilterException extends Exception {
	
	public FilterException(String message) {
		super(message);
	}

	public FilterException(Throwable cause) {
		super(cause);
	}

	public FilterException(String message, Throwable cause) {
		super(message, cause);
	}
	
}

--- NEW FILE: BeanListToRecordSet.java ---
package org.openamf.filter;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openamf.config.FilterConfig;
import org.openamf.recordset.ASRecordSet;

public class BeanListToRecordSet implements Filter {

	private static Log log = LogFactory.getLog(BeanListToRecordSet.class);

	public Object translate(Object value, FilterConfig config)
		throws FilterException {
		
		log.debug("Translating BeanListToRecordSet");
		
		ASRecordSet recordSet = null;
		if (value instanceof List) {
			String[] ignoreProperties = config.getParameterValues("ignore");
			recordSet = new ASRecordSet();	
			try {	
				recordSet.populate((List)value, ignoreProperties);
			} catch (Exception e) {
				throw new FilterException(e);
			}
		} else {
			throw new FilterException("value is not an instance of List");
		}
	
		return recordSet;	
	}

}




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.