1 package prefuse.data.parser; 2 3 import java.util.ArrayList ; 4 5 17 public class TypeInferencer { 18 19 public ParserFactory m_template; 20 public ArrayList m_factories = new ArrayList (); 21 22 26 public TypeInferencer() { 27 this(new ParserFactory()); 28 } 29 30 37 public TypeInferencer(ParserFactory template) { 38 m_template = template; 39 } 40 41 43 private void rangeCheck(int column, boolean grow) { 44 if ( column < 0 || (!grow && column >= m_factories.size())) 45 throw new IndexOutOfBoundsException ( 46 "Index out of bounds: "+column); 47 48 if ( column < m_factories.size() ) 49 return; 50 51 for ( int i=m_factories.size(); i<=column; ++i ) 52 m_factories.add(m_template.clone()); 53 } 54 55 60 public void sample(int column, String value) { 61 rangeCheck(column, true); 62 ((ParserFactory)m_factories.get(column)).sample(value); 63 } 64 65 71 public Class getType(int column) { 72 return getParser(column).getType(); 73 } 74 75 80 public DataParser getParser(int column) { 81 rangeCheck(column, false); 82 return ((ParserFactory)m_factories.get(column)).getParser(); 83 } 84 85 } | Popular Tags |