adb3c1295751ea1c995f1b4b5359186e693820d4
[sixth.git] / src / main / java / eu / svjatoslav / sixth / core / document / content / DocumentPropertyCollection.java
1 package eu.svjatoslav.sixth.core.document.content;
2
3 import java.util.ArrayList;
4 import java.util.HashMap;
5 import java.util.List;
6 import java.util.Map;
7
8 /**
9  * Things like:
10  * #+RESULTS:
11  * #+LATEX_HEADER: \\usepackage{parskip}
12  * #+OPTIONS: H:20 num:20
13  * #+attr_latex: :width 300px
14  */
15
16 public class DocumentPropertyCollection implements Content {
17     private Map<String, List<String>> keyToValue = new HashMap<>();
18
19     @Override
20     public void toMD(StringBuilder sb, int indent) {
21     }
22
23     public void addProperty(String key, String value){
24         getOrCreateValueList(key).add(value);
25     }
26
27     private List<String> getOrCreateValueList(String key){
28         String actualKey = key.toLowerCase();
29         if (keyToValue.containsKey(actualKey))
30             return keyToValue.get(actualKey);
31
32         List valueList = new ArrayList<String>();
33         keyToValue.put(actualKey, valueList);
34         return valueList;
35     }
36
37     public boolean hasProperty(String key){
38         return keyToValue.containsKey(key.toLowerCase());
39     }
40 }