-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
|
||
import org.jonnyzzz.kotlin.xml.bind.* | ||
import org.jonnyzzz.kotlin.xml.bind.jdom.JDOM | ||
import org.jonnyzzz.kotlin.xml.bind.jdom.JXML | ||
import org.jonnyzzz.kotlin.xml.bind.jdom.XUnknown | ||
|
||
|
||
class Example { | ||
var content by JDOM / "aaa" / "ggg" / XText | ||
var attribute by JDOM.saveOrder(5) / "aaa" / XAttribute("yohoho") | ||
var sub by JDOM / "sub" / XSub(Sub::class.java) | ||
var content by JXML / "aaa" / "ggg" / XText | ||
var attribute by JXML.saveOrder(5) / "aaa" / XAttribute("yohoho") | ||
var sub by JXML / "sub" / XSub(Sub::class.java) | ||
|
||
var collection by JDOM / "parameters" / XElements("param") / "aaa" / XText | ||
var any by JDOM / "parameters" / XAnyElements / XSub(Sub::class.java) | ||
var collection by JXML / "parameters" / XElements("param") / "aaa" / XText | ||
var any by JXML / "parameters" / XAnyElements / XSub(Sub::class.java) | ||
} | ||
|
||
class Sub { | ||
var key by JDOM[2] / XAttribute("key") | ||
var value by JDOM[1] / XAttribute("value") - "defaultValue" | ||
var key by JXML[2] / XAttribute("key") | ||
var value by JXML[1] / XAttribute("value") - "defaultValue" | ||
|
||
var unknown by JDOM / XUnknown | ||
var unknown by JXML / XUnknown | ||
} | ||
|
||
fun test() { | ||
val e = Example() | ||
e.sub = Sub() | ||
|
||
/// save to XML | ||
val saved = JDOM.save(e) | ||
|
||
/// load from XML | ||
val copy = JDOM.load(saved, Example::class.java) | ||
} |