-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" path="src"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>\r
+ <classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
-#Fri Mar 09 20:00:25 CET 2012
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.5
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7\r
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
+org.eclipse.jdt.core.compiler.compliance=1.7\r
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
+org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning\r
+org.eclipse.jdt.core.compiler.source=1.7\r
import org.apache.commons.io.FileUtils;
public class Config {
+ public int niceMilliseconds;
public List<Channel> channels;
public Map<String, String> cattrans;
protected File cacheFile;
private Config() {
}
+ public static Config getDefaultConfig() {
+ Config result = new Config();
+ result.channels = new ArrayList<Channel>();
+ result.cattrans = getDefaultCattrans();
+ result.cacheFile = defaultCacheFile();
+ result.niceMilliseconds = 500;
+ return result;
+ }
+
public Map<String,String> getCategories() {
return cattrans;
}
+ public void setChannels(List<Channel> channels) {
+ this.channels = channels;
+ }
+
public static File defaultCacheFile() {
return FileUtils.getFile(FileUtils.getUserDirectory(), ".xmltv", "tv_grab_nl_java.cache");
}
FileUtils.forceMkdir(configFile.getParentFile());
PrintWriter out = new PrintWriter(new OutputStreamWriter( new FileOutputStream( configFile )));
out.println("cache-file: " + escape(cacheFile.getPath()));
+ out.println("nice-time-milliseconds: " + niceMilliseconds);
for(Channel c: channels) {
if (!c.selected) {
out.print("#");
}
return parts;
}
+
public static Config readConfig(File file) {
- Config result = new Config();
+ Config result = getDefaultConfig();
+ result.cattrans = new HashMap<String,String>();
try {
BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream( file)));
- List<Channel> channels = new ArrayList<Channel>();
- Map<String,String> cattrans = new HashMap<String,String>();
- File cacheFile = defaultCacheFile();
+
while(true) {
String s = reader.readLine();
if(s==null) break;
if (parts.size()>3) {
c.setIconUrl(parts.get(3));
}
- channels.add(c);
- }
- if (parts.get(0).toLowerCase().equals("category")) {
- cattrans.put(parts.get(1), parts.get(2));
+ result.channels.add(c);
}
- if (parts.get(0).toLowerCase().equals("cache-file")) {
- cacheFile = new File(parts.get(1));
+ switch (parts.get(0).toLowerCase()) {
+ case "category" :
+ result.cattrans.put(parts.get(1), parts.get(2));
+ break;
+ case "cache-file":
+ result.cacheFile = new File(parts.get(1));
+ break;
+ case "nice-time-milliseconds":
+ result.niceMilliseconds = Integer.parseInt(parts.get(1));
}
}
- result.setChannels(channels);
- result.cattrans = cattrans;
- result.cacheFile = cacheFile;
} catch (IOException e) {
- System.out.println("Cannot read configuration file, continuing with empty configuration");
+ e.printStackTrace();
+ System.out.println("Error reading configuration file, continuing with empty configuration");
return getDefaultConfig();
}
return result;
}
-
- public static Config getDefaultConfig() {
- Config result = new Config();
- result.channels = new ArrayList<Channel>();
- result.cattrans = getDefaultCattrans();
- result.cacheFile = defaultCacheFile();
- return result;
- }
-
- public void setChannels(List<Channel> channels) {
- this.channels = channels;
- }
}