1 package org
.argeo
.cms
.gcr
.xml
;
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
;
10 import javax
.xml
.parsers
.DocumentBuilder
;
11 import javax
.xml
.parsers
.DocumentBuilderFactory
;
13 import org
.argeo
.api
.gcr
.Content
;
14 import org
.argeo
.api
.gcr
.ContentSession
;
15 import org
.argeo
.api
.gcr
.Contents
;
16 import org
.w3c
.dom
.Document
;
18 public class DomContentSession
implements ContentSession
{
19 private Document document
;
21 public DomContentSession(Document document
) {
22 this.document
= document
;
23 this.document
.normalizeDocument();
27 public Content
get() {
28 return new DomContent(this, document
.getDocumentElement());
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));
36 Set
<String
> set
= new HashSet
<>();
39 DocumentBuilderFactory factory
= DocumentBuilderFactory
.newInstance();
40 DocumentBuilder dBuilder
= factory
.newDocumentBuilder();
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
));
46 DomContentSession contentSession
= new DomContentSession(doc
);
47 Contents
.traverse(contentSession
.get(), (c
, d
) -> Contents
.print(c
, System
.out
, d
, true));