1 11 12 package org.eclipse.birt.chart.examples.api.data.autobinding; 13 14 import java.util.HashMap ; 15 import java.util.Map ; 16 17 import org.eclipse.birt.chart.factory.DataRowExpressionEvaluatorAdapter; 18 19 public class DataRowExpressionEvaluator extends 20 DataRowExpressionEvaluatorAdapter 21 { 22 23 private int k = 0; 24 private Object [] column; 25 private Map map; 26 27 public DataRowExpressionEvaluator( String [] set, Object [][] data ) 28 { 29 if ( set == null ) 30 { 31 throw new IllegalArgumentException ( ); 32 } 33 34 map = new HashMap ( ); 35 for ( int i = 0; i < set.length; i++ ) 36 { 37 map.put( set[i], data[i] ); 38 } 39 } 40 41 46 public Object evaluate( String expression ) 47 { 48 column = (Object []) map.get( expression ); 49 return column[k]; 50 } 51 52 57 public boolean first( ) 58 { 59 k = 0; 60 61 if ( map.size( ) > 0 ) 62 { 63 column = (Object []) map.values( ).iterator( ).next( ); 64 65 if ( column != null && k < column.length ) 66 { 67 return true; 68 } 69 } 70 71 return false; 72 } 73 74 79 public boolean next( ) 80 { 81 if ( column != null && k < ( column.length - 1 ) ) 82 { 83 k++; 84 return true; 85 } 86 return false; 87 } 88 89 94 public void close( ) 95 { 96 } 98 99 } | Popular Tags |