openamf/src/java/org/openamf/filter MapListToRecordSet.java,1.1,1.2 BeanListToRecordSet.java,1.4,1.5

[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-serv20780/src/java/org/openamf/filter

Modified Files:
	MapListToRecordSet.java BeanListToRecordSet.java 
Log Message:
fixed bug with empty lists

Index: MapListToRecordSet.java
===================================================================
RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/filter/MapListToRecordSet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MapListToRecordSet.java	8 Jul 2003 18:36:04 -0000	1.1
--- MapListToRecordSet.java	14 Jul 2003 09:01:26 -0000	1.2
***************
*** 46,56 ****
  		ASRecordSet recordSet = new ASRecordSet();	
  		
! 		String[] columnNames = getColumnNames(list);
! 		list = convertList(list);
! 		try {	
! 			recordSet.populate(columnNames, list);
! 		} catch (Exception e) {
! 			throw new FilterException(e);
  		}
  		return recordSet;
  	}
--- 46,59 ----
  		ASRecordSet recordSet = new ASRecordSet();	
  		
! 		if (list.size() > 0) {
! 			String[] columnNames = getColumnNames(list);
! 			list = convertList(list);
! 			try {	
! 				recordSet.populate(columnNames, list);
! 			} catch (Exception e) {
! 				throw new FilterException(e);
! 			}
  		}
+ 		
  		return recordSet;
  	}

Index: BeanListToRecordSet.java
===================================================================
RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/filter/BeanListToRecordSet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** BeanListToRecordSet.java	5 Jul 2003 19:50:48 -0000	1.4
--- BeanListToRecordSet.java	14 Jul 2003 09:01:26 -0000	1.5
***************
*** 16,48 ****
  	public Object filter(Object value, FilterConfig config)
  		throws FilterException {
! 		
  		log.info("Translating BeanListToRecordSet");
! 		
  		ASRecordSet recordSet = null;
  		if (value instanceof List) {
! 			recordSet = processList(value, config);
  		} else if (value instanceof Iterator) {
! 			Iterator iterator = (Iterator)value;
! 			ArrayList list = new ArrayList();
  			while (iterator.hasNext()) {
  				list.add(iterator.next());
  			}
- 			recordSet = processList(list, config);
  		} else {
  			throw new FilterException("value is not an instance of List or Iterator");
  		}
! 	
! 		return recordSet;	
  	}
  
! 	private ASRecordSet processList(Object value, FilterConfig config)
  		throws FilterException {
  		ASRecordSet recordSet;
! 		String[] ignoreProperties = config.getParameterValues("ignore");
! 		recordSet = new ASRecordSet();	
! 		try {	
! 			recordSet.populate((List)value, ignoreProperties);
! 		} catch (Exception e) {
! 			throw new FilterException(e);
  		}
  		return recordSet;
--- 16,53 ----
  	public Object filter(Object value, FilterConfig config)
  		throws FilterException {
! 
  		log.info("Translating BeanListToRecordSet");
! 
  		ASRecordSet recordSet = null;
+ 		List list = null;
  		if (value instanceof List) {
! 			list = (List) value;
  		} else if (value instanceof Iterator) {
! 			Iterator iterator = (Iterator) value;
! 			list = new ArrayList();
  			while (iterator.hasNext()) {
  				list.add(iterator.next());
  			}
  		} else {
  			throw new FilterException("value is not an instance of List or Iterator");
  		}
! 
! 		recordSet = processList(list, config);
! 
! 		return recordSet;
  	}
  
! 	private ASRecordSet processList(List list, FilterConfig config)
  		throws FilterException {
  		ASRecordSet recordSet;
! 
! 		recordSet = new ASRecordSet();
! 		if (list.size() > 0) {
! 			String[] ignoreProperties = config.getParameterValues("ignore");
! 			try {
! 				recordSet.populate(list, ignoreProperties);
! 			} catch (Exception e) {
! 				throw new FilterException(e);
! 			}
  		}
  		return recordSet;




-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1
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.