@@ -4,24 +4,57 @@ A Java implementation of a parser for the [KDL Document Language](https://github
4
4
5
5
## Status
6
6
7
- ![ Gradle CI] ( https://github.com/hkolbeck/kdl4j/workflows/Gradle%20CI/badge.svg )
8
-
9
- This project is beta-quality. It's been extensively tested, but the spec it implements is still in flux.
7
+ This branch contains the code for version 0.x of KDL4j that supports KDL 1.0. We recommend that you switch to KDL 2.0
8
+ and use KDL4j 2.0 or up.
10
9
11
10
## Usage
12
11
12
+ ## Dependency
13
+
14
+ Releases are published on [ GitHub Packages] ( https://docs.github.com/en/packages ) . You need to authenticate with GitHub
15
+ using a token with ` read:packages ` permission. See the official documentation for more information on how to
16
+ authenticate on GitHub Packages for
17
+ [ Maven] ( https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry )
18
+ or for
19
+ [ Gradle] ( https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry ) .
20
+
21
+ Then you can add the KDL4j dependency. Maven:
22
+
23
+ ``` xml
24
+
25
+ <dependencies >
26
+ <dependency >
27
+ <groupId >kdl</groupId >
28
+ <artifactId >kdl4j</artifactId >
29
+ <version >0.3.0</version >
30
+ </dependency >
31
+ </dependencies >
32
+ ```
33
+
34
+ Gradle:
35
+
36
+ ``` groovy
37
+ dependencies {
38
+ implementation 'kdl:kdl4j:0.3.0'
39
+ }
40
+ ```
41
+
42
+ Alternatively, you can use the packages [ hosted by JitPack] ( https://jitpack.io/#kdl-org/kdl4j ) . In this case, make sure
43
+ you use the ` com.github.kdl-org ` groupId.
44
+
13
45
### Parsing
14
46
15
47
``` java
16
48
final KDLParser parser = new KDLParser ();
17
49
18
- final KDLDocument documentFromString = parser. parse(" node_name \" arg\" " )
50
+ final KDLDocument documentFromString = parser. parse(" node_name \" arg\" " );
19
51
// OR
20
- final KDLDocument documentFromReader = parser. parse(new FileReader (" some/file.kdl" ))
52
+ final KDLDocument documentFromReader = parser. parse(new FileReader (" some/file.kdl" ));
21
53
```
22
54
23
- ` KDLDocument ` objects, and all descendants of ` KDLObject ` , are immutable and threadsafe, though that is not true of their
24
- ` Builder ` objects. If you need to make changes to a ` KDLDocument ` , use the ` filter() ` and ` mutate() ` functions explained below.
55
+ ` KDLDocument ` objects, and all descendants of ` KDLObject ` , are immutable and threadsafe, though that is not true of
56
+ their ` Builder ` objects. If you need to make changes to a ` KDLDocument ` , use the ` filter() ` and ` mutate() ` functions
57
+ explained below.
25
58
26
59
### Searching and Mutating Documents
27
60
@@ -35,19 +68,20 @@ the document differs. There are three search types:
35
68
Each provides four methods for searching or mutating documents:
36
69
37
70
* ` anyMatch(document) ` - Returns true if any node matches the search, false otherwise
38
- * ` filter(document, trim) ` - Removes all nodes from the tree not on a branch that matches the predicates of the search. if
39
- ` trim ` is set, removes all their non-matching children
71
+ * ` filter(document, trim) ` - Removes all nodes from the tree not on a branch that matches the predicates of the search.
72
+ if ` trim ` is set, removes all their non-matching children
40
73
* ` list(document, trim) ` - Produces a new document with all matching nodes at the root. If ` trim ` is set, removes all
41
74
their non-matching children
42
75
* ` mutate(document, mutation) ` - Applies a provided ` Mutation ` to every matching node in the tree, depth first.
43
76
44
- There are 3 types of ` Mutations ` provided, and users may provide custom mutations. Provided are ` AddMutation ` ,
45
- ` SubtractMutation ` , and ` SetMutation ` . Each performs functions hinted at by the name. See individual javadocs for details.
77
+ There are 3 types of ` Mutations ` provided, and users may provide custom mutations. Provided are ` AddMutation ` ,
78
+ ` SubtractMutation ` , and ` SetMutation ` . Each performs functions hinted at by the name. See individual javadocs for
79
+ details.
46
80
47
81
### Printing
48
82
49
83
By default, calling ` document.toKDL() ` or ` document.writeKDL(writer) ` will print the structure with:
50
-
84
+
51
85
* 4 space indents
52
86
* No semicolons
53
87
* Printable ASCII characters which can be escaped, escaped
@@ -62,6 +96,6 @@ on PrintConfig for more information.
62
96
63
97
Please read the Code of Conduct before opening any issues or pull requests.
64
98
65
- Besides code fixes, the easiest way to contribute is by generating test cases. Check out
66
- [ the test cases directory] ( https://github.com/hkolbeck/kdl4j/tree/trunk/src/test/resources/test_cases ) to see the existing ones.
67
- See the README there for more details.
99
+ Besides code fixes, the easiest way to contribute is by generating test cases. Check out
100
+ [ the test cases directory] ( https://github.com/hkolbeck/kdl4j/tree/trunk/src/test/resources/test_cases ) to see the
101
+ existing ones. See the README there for more details.
0 commit comments