All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mlrpc.protocol.2.0.1.source-code.MethodCall.kt Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
/*
 * Copyright (c) 2022 Andreas Scheja. Use of this source code is governed by the Apache 2.0 license.
 */

package org.ascheja.xmlrpc.protocol

import org.w3c.dom.Document
import javax.xml.parsers.DocumentBuilder

public data class MethodCall(
    val methodName: String,
    val params: List
) {
    public constructor(methodName: String, vararg params: Value) : this(methodName, params.toList())

    public fun toDocument(): Document {
        val document = createDocumentBuilder().newDocument()
        with(Serializer(document)) {
            appendToElement(document)
        }
        return document
    }

    public companion object {
        public fun parse(block: (DocumentBuilder) -> Document): MethodCall {
            return Deserializer().parseMethodCall(block(createDocumentBuilder()).documentElement)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy