prefuse.data.parser
Class TypeInferencer

java.lang.Object
  extended by prefuse.data.parser.TypeInferencer

public class TypeInferencer
extends java.lang.Object

Infers the data types for a table of data by testing each value of the data against a bank of parsers and eliminating candidate parsers that do not successfully parse the data. This class leverages the mechanisms of ParserFactory, but while that class only supports one data field at a time, TypeInferencer maintains a collection of ParserFactory instances to infer type for multiple data columns simultaneously.

Author:
jeffrey heer
See Also:
ParserFactory

Field Summary
 java.util.ArrayList m_factories
           
 ParserFactory m_template
           
 
Constructor Summary
TypeInferencer()
          Create a new TypeInferencer using the default ParserFactory settings, thus the default parsers and parser ordering will be used.
TypeInferencer(ParserFactory template)
          Create a new TypeInferenced using the input ParserFactory as a template for the desired parsers to check and parser ordering to use.
 
Method Summary
 DataParser getParser(int column)
          Get the top-ranking candidate data parser for the given column index.
 java.lang.Class getType(int column)
          Get the data type for the highest ranking candidate parser still in the running for the given column index.
 void sample(int column, java.lang.String value)
          Sample the given text string for the given data column index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_template

public ParserFactory m_template

m_factories

public java.util.ArrayList m_factories
Constructor Detail

TypeInferencer

public TypeInferencer()
Create a new TypeInferencer using the default ParserFactory settings, thus the default parsers and parser ordering will be used.


TypeInferencer

public TypeInferencer(ParserFactory template)
Create a new TypeInferenced using the input ParserFactory as a template for the desired parsers to check and parser ordering to use.

Parameters:
template - the template ParserFactory to use for included parsers and their precedence.
Method Detail

sample

public void sample(int column,
                   java.lang.String value)
Sample the given text string for the given data column index.

Parameters:
column - the data column index of the sample
value - the text string sample

getType

public java.lang.Class getType(int column)
Get the data type for the highest ranking candidate parser still in the running for the given column index.

Parameters:
column - the data column index
Returns:
the currently inferred type of that column

getParser

public DataParser getParser(int column)
Get the top-ranking candidate data parser for the given column index.

Parameters:
column - the data column index
Returns:
the data parser to use for that column


Copyright © 2007 Regents of the University of California