Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyzzz committed Jan 2, 2016
1 parent e451fa3 commit 6f2ed06
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions jdom.examples/src/main/kotlin/XBind.Example.kt
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)
}

0 comments on commit 6f2ed06

Please sign in to comment.