00001 /* 00002 * TableRecord.java 00003 * 00004 * Created on March 16, 2009, 08:32 AM 00005 * 00006 * Copyright 2009 Online Nederland Breedband B.V. 00007 * See the COPYRIGHT file for redistribution and use restrictions. 00008 * Authors: Guillermo Christen <guillermo.christen@is.online.nl> 00009 */ 00010 package dochelper; 00011 00012 import java.util.ArrayList; 00013 import java.util.HashMap; 00014 import java.util.Iterator; 00015 00020 public class TableRecord implements Record { 00021 00025 protected HashMap _fieldValues; 00026 00028 protected HashMap _fullFieldValues; 00029 00031 protected String _name; 00032 00033 00037 public TableRecord(HashMap fieldValues) { 00038 this._fieldValues = fieldValues; 00039 } 00040 00052 public TableRecord(HashMap fieldValues, HashMap fullFieldValues, String name) { 00053 this(fieldValues); 00054 this._fullFieldValues = fullFieldValues; 00055 this._name = name; 00056 } 00057 00058 00072 public ResultNode execute(ArrayList<DocPattern> patterns) { 00073 00074 ResultNode root = new ResultNode(null, _fullFieldValues, _name); 00075 00076 //match all the patterns 00077 if(patterns != null && _fieldValues != null && _fieldValues.size() > 0) { 00078 for (DocPattern pattern : patterns) { 00079 //look for pattern in each of the fields 00080 for(Iterator iter = _fieldValues.keySet().iterator(); iter.hasNext();) { 00081 String value = _fieldValues.get((String)iter.next()).toString(); 00082 root.addChild(pattern.execute(value)); 00083 } 00084 } 00085 } 00086 00087 return root; 00088 00089 } 00090 00098 public String getValue() { 00099 //loop through all of the keys and values: key:value 00100 return ""; 00101 } 00102 00103 }