All Projects → hkolbeck → kdl4j

hkolbeck / kdl4j

Licence: MIT license
KDL Parser for the JVM

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to kdl4j

Xmlutil
XML Serialization library for Kotlin
Stars: ✭ 143 (+793.75%)
Mutual labels:  serialization, jvm
Ysoserial
A proof-of-concept tool for generating payloads that exploit unsafe Java object deserialization.
Stars: ✭ 4,808 (+29950%)
Mutual labels:  serialization, jvm
rake
A Java library for Rapid Automatic Keyword Extraction (RAKE) 🍂
Stars: ✭ 23 (+43.75%)
Mutual labels:  jvm
jwEngine
A cross-platform C++<->lua server quick solution
Stars: ✭ 226 (+1312.5%)
Mutual labels:  serialization
laravel5-hal-json
Laravel 5 HAL+JSON API Transformer Package
Stars: ✭ 15 (-6.25%)
Mutual labels:  serialization
generator-jvm
Generate JVM (java, kotlin, scala) project with gradle / maven / sbt build systems and docker / docker-compose for rapid development
Stars: ✭ 40 (+150%)
Mutual labels:  jvm
jvm-dump-proxy
A proxy DLL for Windows to dump JVM classes at JNI level
Stars: ✭ 53 (+231.25%)
Mutual labels:  jvm
ark-java
Library for interacting with an Ark Ecosystem Blockchain using the JVM.
Stars: ✭ 15 (-6.25%)
Mutual labels:  jvm
JsonKnownTypes
Simple way to serialize and deserialize polymorphic types for Json.NET
Stars: ✭ 33 (+106.25%)
Mutual labels:  serialization
protoc-plugin
A protoc compiler plugin for Clojure applications
Stars: ✭ 28 (+75%)
Mutual labels:  serialization
persistity
A persistence framework for game developers
Stars: ✭ 34 (+112.5%)
Mutual labels:  serialization
jsonrec
JSON parser/encoder "type spec"-based code-generator
Stars: ✭ 13 (-18.75%)
Mutual labels:  serialization
Latte-lang
100% Java compatibility and Functional Programming.
Stars: ✭ 128 (+700%)
Mutual labels:  jvm
2p-kt
A Kotlin Multi-Platform ecosystem for symbolic AI
Stars: ✭ 52 (+225%)
Mutual labels:  jvm
library-template-jvm
A Kotlin/JVM library template (with a sample project).
Stars: ✭ 46 (+187.5%)
Mutual labels:  jvm
gctoolkit
Tool for parsing GC logs
Stars: ✭ 1,127 (+6943.75%)
Mutual labels:  jvm
use-query-string
🆙 A React hook that serializes state into the URL query string
Stars: ✭ 50 (+212.5%)
Mutual labels:  serialization
serialize-json
A serialize algorithm for JSON
Stars: ✭ 22 (+37.5%)
Mutual labels:  serialization
BinaryLove3
Simple C++ 20 Serialization Library that works out of the box with aggregate types!
Stars: ✭ 13 (-18.75%)
Mutual labels:  serialization
play-scala-streaming-example
Example Play application showing Comet and Server Sent Events in Scala
Stars: ✭ 42 (+162.5%)
Mutual labels:  jvm

KDL4j

A Java implementation of a parser for the KDL Document Language.

Status

Gradle CI

This project is beta-quality. It's been extensively tested, but the spec it implements is still in flux.

Usage

Parsing

final KDLParser parser = new KDLParser();

final KDLDocument documentFromString = parser.parse("node_name \"arg\"")
// OR
final KDLDocument documentFromReader = parser.parse(new FileReader("some/file.kdl"))

KDLDocument objects, and all descendants of KDLObject, are immutable and threadsafe, though that is not true of their Builder objects. If you need to make changes to a KDLDocument, use the filter() and mutate() functions explained below.

Searching and Mutating Documents

Several utilities are provided for finding nodes in documents. Each presents the same interface, but the way they search the document differs. There are three search types:

  • RootSearch - Searches entirely at the root, primarily used for mutations to the root as discussed below
  • GeneralSearch - Searches for nodes anywhere in the tree matching a single, possibly compound, node predicate
  • PathedSearch - Searches for nodes down a specified path. At each level a different node predicate can be specified

Each provides four methods for searching or mutating documents:

  • anyMatch(document) - Returns true if any node matches the search, false otherwise
  • filter(document, trim) - Removes all nodes from the tree not on a branch that matches the predicates of the search. if trim is set, removes all their non-matching children
  • list(document, trim) - Produces a new document with all matching nodes at the root. If trim is set, removes all their non-matching children
  • mutate(document, mutation) - Applies a provided Mutation to every matching node in the tree, depth first.

There are 3 types of Mutations provided, and users may provide custom mutations. Provided are AddMutation, SubtractMutation, and SetMutation. Each performs functions hinted at by the name. See individual javadocs for details.

Printing

By default, calling document.toKDL() or document.writeKDL(writer) will print the structure with:

  • 4 space indents
  • No semicolons
  • Printable ASCII characters which can be escaped, escaped
  • Empty children printed
  • null arguments and properties with null values printed
  • \n (unicode \u{0a}) for newlines

Any of these can be changed by creating a new PrintConfig object and passing it into the print method. See the javadocs on PrintConfig for more information.

Contributing

Please read the Code of Conduct before opening any issues or pull requests.

Besides code fixes, the easiest way to contribute is by generating test cases. Check out the test cases directory to see the existing ones. See the README there for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].