VisClient/org/hfbk/vis/source/SourceRegExp.java

Go to the documentation of this file.
00001 package org.hfbk.vis.source;
00002 
00003 import java.io.IOException;
00004 import java.io.UnsupportedEncodingException;
00005 import java.net.URL;
00006 import java.util.regex.Matcher;
00007 import java.util.regex.Pattern;
00008 
00009 import org.dronus.graph.Node;
00010 import org.hfbk.util.HTTPUtils;
00011 
00028 public abstract class SourceRegExp extends Source {
00029         
00030         public SourceRegExp(URL url) {super(url);}
00031 
00032         Matcher matcher;
00033         Node root;
00034         
00036         abstract String url() throws UnsupportedEncodingException;
00038         abstract String matcher();
00041         abstract void parse(String[] matches) throws IOException;
00042         
00043         
00044         void buildGraph() throws IOException {          
00045                 
00046                 String page=HTTPUtils.fetch(url(), silent);
00047                 
00048                 Pattern p=Pattern.compile(matcher());
00049                 Matcher matcher=p.matcher(page);
00050                 while (matcher.find()){
00051                         String[] groups=new String[matcher.groupCount()+1];
00052                         for (int i=0; i<groups.length; i++)
00053                                 groups[i]=matcher.group(i);
00054                         parse(groups);
00055                 }
00056         }
00057 }

Generated on Tue Apr 7 17:57:20 2009 for visclient by  doxygen 1.5.1