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

mlrpc.protocol.2.0.3.source-code.MethodResponse.kt Maven / Gradle / Ivy

The 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 sealed interface MethodResponse {

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

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

public data class MethodResponseSuccess(
    val params: List
) : MethodResponse {

    public constructor(vararg params: Value) : this(params.toList())
}

public data class MethodResponseFault(
    val faultCode: Int,
    val faultString: String
) : MethodResponse




© 2015 - 2024 Weber Informatics LLC | Privacy Policy