]> git.argeo.org Git - lgpl/argeo-commons.git/blob - cms/gcr/xml/DomContentSession.java
Prepare next development cycle
[lgpl/argeo-commons.git] / cms / gcr / xml / DomContentSession.java
1 package org.argeo.cms.gcr.xml;
2
3 import java.nio.file.Files;
4 import java.nio.file.Path;
5 import java.nio.file.Paths;
6 import java.util.HashMap;
7 import java.util.HashSet;
8 import java.util.Set;
9
10 import javax.xml.parsers.DocumentBuilder;
11 import javax.xml.parsers.DocumentBuilderFactory;
12
13 import org.argeo.api.gcr.Content;
14 import org.argeo.api.gcr.ContentSystemProvider;
15 import org.argeo.api.gcr.ContentUtils;
16 import org.w3c.dom.Document;
17
18 public class DomContentSession implements ContentSystemProvider {
19 private Document document;
20
21 public DomContentSession(Document document) {
22 this.document = document;
23 this.document.normalizeDocument();
24 }
25
26 @Override
27 public Content get() {
28 return new DomContent(this, document.getDocumentElement());
29 }
30
31 public static void main(String args[]) throws Exception {
32 HashMap<String, Object> map = new HashMap<>();
33 map.put(null, "test");
34 System.out.println(map.get(null));
35
36 Set<String> set = new HashSet<>();
37 set.add(null);
38
39 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
40 DocumentBuilder dBuilder = factory.newDocumentBuilder();
41 Path testFile;
42 testFile = Paths.get(System.getProperty("user.home") + "/dev/git/unstable/argeo-commons/pom.xml");
43 testFile = Paths.get(System.getProperty("user.home") + "/tmp/test.xml");
44 Document doc = dBuilder.parse(Files.newInputStream(testFile));
45
46 DomContentSession contentSession = new DomContentSession(doc);
47 ContentUtils.traverse(contentSession.get(), (c, d) -> ContentUtils.print(c, System.out, d, true));
48
49 }
50 }