added footer support
[asciidoctor_to_rss.git] / src / main / java / net / wpitchoune / asciidoctor / Configuration.java
1 package net.wpitchoune.asciidoctor;
2
3 import java.io.File;
4 import java.io.FileInputStream;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.util.Properties;
8
9 public final class Configuration {
10         private static final String KEY_HTML_HEADER_FILE = "html.header.file";
11         private static final String KEY_HTML_FOOTER_FILE = "html.footer.file";
12         private static final String KEY_FEED_TITLE = "feed.title";
13         private static final String KEY_FEED_LINK = "feed.link";
14         private static final String KEY_FEED_DESCRIPTION = "feed.description";
15         private static final String KEY_FEED_BASEURL = "feed.baseurl";
16         private Properties properties;
17         
18         private Configuration(Properties properties) {
19                 this.properties = properties;
20         }
21         
22         public String getFeedLink() {
23                 return properties.getProperty(KEY_FEED_LINK);
24         }       
25         
26         public String getFeedTitle() {
27                 return properties.getProperty(KEY_FEED_TITLE);
28         }       
29         
30         public String getFeedDescription() {
31                 return properties.getProperty(KEY_FEED_DESCRIPTION);
32         }
33         
34         public String getFeedBaseURL() {
35                 return properties.getProperty(KEY_FEED_BASEURL);
36         }
37         
38         public File getHTMLHeaderFile() {
39                 String str;
40                 
41                 str = properties.getProperty(KEY_HTML_HEADER_FILE);
42                                 
43                 if (str == null)
44                         return null;
45                 
46                 return new File(str);
47         }
48
49         public File getHTMLFooterFile() {
50                 String str;
51                 
52                 str = properties.getProperty(KEY_HTML_FOOTER_FILE);
53                                 
54                 if (str == null)
55                         return null;
56                 
57                 return new File(str);
58         }
59         
60         public static Configuration load(File f) throws IOException {
61                 Properties props;
62                 InputStream in;
63                                 
64                 props = new Properties();
65                 in = new FileInputStream(f);
66                                 
67                 try {
68                         props.load(in);
69                 } finally {
70                         in.close();
71                 }
72                 
73                 return new Configuration(props);
74         }
75 }