TreebuildConfig.java: implemented own caching
[treebuild.git] / base / TreebuildConfig.java
blob6557c0bc0afaa995a58bb6894e88ecd2261b2d52
2 package org.de.metux.treebuild.base;
4 import java.io.File;
5 import java.util.Properties;
6 import org.de.metux.util.StrUtil;
7 import org.de.metux.datasource.Cached_TextDB_Loader;
8 import org.de.metux.propertylist.IPropertylist;
9 import org.de.metux.propertylist.Propertylist;
10 import org.de.metux.propertylist.EIllegalValue;
11 import org.de.metux.unitool.base.ToolConfig;
12 import org.de.metux.unitool.db.UnitoolConf;
14 public class TreebuildConfig
16 public IPropertylist conf;
17 public IPropertylist unitool_conf;
18 public ToolConfig unitool;
20 public static final String cf_unitool_config = "@TARGET/unitool-config";
21 private Cached_TextDB_Loader textdb_loader = new Cached_TextDB_Loader();
23 private boolean __load_properties_top(String filename)
25 Properties pr = textdb_loader.load(filename);
26 if (pr == null)
27 return false;
28 conf.loadProperties_top(pr);
29 return true;
32 public TreebuildConfig(File f)
33 throws EPIException
35 String filename = f.getAbsolutePath();
36 System.err.println("Using treebuild config file: "+filename);
37 conf = new Propertylist();
38 if (!__load_properties_top(filename))
39 throw new RuntimeException("coud not load treebuild config: "+filename);
41 // now load the unitool config
42 try{
43 String cfname = conf.get_str(cf_unitool_config);
44 if (StrUtil.isEmpty(cfname))
45 throw new EPropertyMissing(cf_unitool_config);
47 // now load the unitool config
48 unitool = UnitoolConf.getToolConfig(new File(cfname));
49 unitool_conf = unitool.getPropertylist();
51 catch (EIllegalValue e)
53 throw new EPropertyMissing(cf_unitool_config,e);
57 public IPropertylist getPropertylist()
59 return conf;
62 public IPropertylist getUnitoolPropertylist()
64 return unitool_conf;