Separate multiline code block language from remaining parameters
[sixth.git] / src / main / java / eu / svjatoslav / sixth / core / document / content / DocumentPropertyCollection.java
diff --git a/src/main/java/eu/svjatoslav/sixth/core/document/content/DocumentPropertyCollection.java b/src/main/java/eu/svjatoslav/sixth/core/document/content/DocumentPropertyCollection.java
new file mode 100644 (file)
index 0000000..adb3c12
--- /dev/null
@@ -0,0 +1,40 @@
+package eu.svjatoslav.sixth.core.document.content;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Things like:
+ * #+RESULTS:
+ * #+LATEX_HEADER: \\usepackage{parskip}
+ * #+OPTIONS: H:20 num:20
+ * #+attr_latex: :width 300px
+ */
+
+public class DocumentPropertyCollection implements Content {
+    private Map<String, List<String>> keyToValue = new HashMap<>();
+
+    @Override
+    public void toMD(StringBuilder sb, int indent) {
+    }
+
+    public void addProperty(String key, String value){
+        getOrCreateValueList(key).add(value);
+    }
+
+    private List<String> getOrCreateValueList(String key){
+        String actualKey = key.toLowerCase();
+        if (keyToValue.containsKey(actualKey))
+            return keyToValue.get(actualKey);
+
+        List valueList = new ArrayList<String>();
+        keyToValue.put(actualKey, valueList);
+        return valueList;
+    }
+
+    public boolean hasProperty(String key){
+        return keyToValue.containsKey(key.toLowerCase());
+    }
+}