Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard

Opaque caching class that allows for caching format related data (to speed up reuse). This is intended to be stored on the config, thus reused through multiple serializations. Note that this requires the serialName attribute of SerialDescriptor instances to be unique.

Link copied to clipboard

Default implementation of a serialization policy that provides a behaviour that attempts to create an XML format that resembles what would be created manually in line with XML's design.

Link copied to clipboard

Interface for format caches that support being delegated to.

Link copied to clipboard
abstract class FormatCache

The FormatCache caches the calculations needed to determine the correct format for a specific serializable tree. There are 3 options provided by default:

Link copied to clipboard
Link copied to clipboard

This class is still here to stop breaking functionality.

Link copied to clipboard
Link copied to clipboard
typealias NonRecoveryUnknownChildHandler = (input: XmlReader, inputKind: InputKind, name: QName?, candidates: Collection<Any>) -> Unit
Link copied to clipboard
Link copied to clipboard
data class PolyInfo(val tagName: QName, val index: Int, val descriptor: XmlDescriptor)

Helper class that collates information used in matching tags with types.

Link copied to clipboard
Link copied to clipboard
class ThreadLocalFormatCache(val capacity: Int = 20, baseCacheFactory: () -> FormatCache = { DefaultFormatCache() }) : FormatCache

Native implementation of a format cache using threadLocals. Note that this uses a fifo queue of caches (up to capacity count) and it will evict the oldest element (independent of usage)

Link copied to clipboard
fun interface UnknownChildHandler
Link copied to clipboard
class UnknownXmlFieldException(extLocationInfo: XmlReader.LocationInfo?, xmlName: String, candidates: Collection<Any> = emptyList()) : XmlSerialException
Link copied to clipboard
annotation class WillBePrivate
Link copied to clipboard
class XML(val config: XmlConfig, serializersModule: SerializersModule = EmptySerializersModule()) : StringFormat

Class that provides access to XML parsing and serialization for the Kotlin Serialization system. In most cases the companion functions would be used. Creating an object explicitly however allows for the serialization to be configured.

Link copied to clipboard
annotation class XmlAfter(val value: String)

Require this property to be serialized after other (sibling) properties. Together XmlBefore and XmlAfter define a partial order over the properties. Using this annotation may cause values to be serialized as elements rather than attributes where not explicitly specified as attributes. If there is a conflict between serialization type (attribute/element) this takes precendence over this attribute. The names are the serialNames of the properties being serialized (not XML names).

Link copied to clipboard
annotation class XmlBefore(val value: String)

Require this property to be serialized before other (sibling) properties. Together XmlBefore and XmlAfter define a partial order over the properties. Using this annotation may cause values to be serialized as elements rather than attributes where not explicitly specified as attributes. If there is a conflict between serialization type (attribute/element) this takes precendence over this attribute. The names are the serialNames of the properties being serialized (not XML names).

Link copied to clipboard
annotation class XmlCData(val value: Boolean = true)

Mark the property for serialization as CData, rather than text (where appropriate). If used on a property this will override the annotation on a type. This is the only context in which a value of false is different from omitting the annotation.

Link copied to clipboard
annotation class XmlChildrenName(val value: String, val namespace: String = UNSET_ANNOTATION_VALUE, val prefix: String = UNSET_ANNOTATION_VALUE)

Specify additional information about child values in collections. This is only used for primitives, not for classes that have their own independent name. The outer tag name is determined regularly.

Link copied to clipboard
class XmlConfig

Configuration for the xml parser.

Link copied to clipboard
annotation class XmlDefault(val value: String)

Allow a property to be omitted with a default serialized string. This annotation primarily supports older versions of the framework that do not support default attribute values. The default value will not be written out if matched.

Link copied to clipboard
annotation class XmlElement(val value: Boolean = true)

Force a property that could be an attribute to be an element. Note that default behaviour requires this annotation to be absent.

Link copied to clipboard
annotation class XmlId

Annotation to mark the value as an ID attribute. This implies that the element is an attribute. This will allow the serializer to enforce uniqueness.

Link copied to clipboard
annotation class XmlIgnoreWhitespace(val value: Boolean = true)

Determine whether whitespace should be ignored or preserved for the tag.

Link copied to clipboard
annotation class XmlKeyName(val value: String, val namespace: String = UNSET_ANNOTATION_VALUE, val prefix: String = UNSET_ANNOTATION_VALUE)

Specify the xml name used for the key attribute/tag of a map.

Link copied to clipboard
annotation class XmlMapEntryName(val value: String, val namespace: String = UNSET_ANNOTATION_VALUE, val prefix: String = UNSET_ANNOTATION_VALUE)

Dual use annotation that both forces explicit map entry wrappers and specifies the tag name used. The default is to elude the wrappers in the case that data does not contain an attribute with the name of the key.

Link copied to clipboard

Annotation allowing to specify namespaces specifications to be generated upon the element. As multiple annotations are not supported by the plugin this uses a single string. Each declaration is of the form (prefix)=(namespace). To specify the default namespace it is valid to omit the equals sign.

Link copied to clipboard
annotation class XmlOtherAttributes

This annotation allows handling wildcard attributes. It should be specified on a Map<QName, String> to store unsupported attributes. The key is preferred to be a QName, alternatively it must convert to String (this could be "prefix:localName"). The value must be a String type. Note that if the key runtime type is a QName the value is directly used as attribute name without using the key serializer.

Link copied to clipboard
class XmlParsingException(extLocationInfo: XmlReader.LocationInfo?, message: String, cause: Exception? = null) : XmlSerialException
Link copied to clipboard
annotation class XmlPolyChildren(val value: Array<String>)

Indicate the valid polymorphic children for this element. This is a legacy annotation supporting polymorphic (de)serialization without modules.

Link copied to clipboard
open class XmlSerialException(message: String, val extLocationInfo: XmlReader.LocationInfo?, cause: Throwable? = null) : SerializationException
Link copied to clipboard

Policies allow for customizing the behaviour of the xml serialization

Link copied to clipboard
annotation class XmlSerialName(val value: String = UNSET_ANNOTATION_VALUE, val namespace: String = UNSET_ANNOTATION_VALUE, val prefix: String = UNSET_ANNOTATION_VALUE)

Specify more detailed name information than can be provided by kotlinx.serialization.SerialName. The default value is different from an empty value, in that it will result in a default behaviour.

Link copied to clipboard
annotation class XmlValue(val value: Boolean = true)

Force a property to be content of the tag (for the object containing the property). This is both for text content (polymorphic including a primitive), but if the type is a list of tag-like types (Node, Element, CompactFragment) it will also allow mixed content of tags not supported by the base type. Strings will be serialized/deserialized as (tag soup) string content without wrapper.

Properties

Link copied to clipboard

Accessor that reads the declared namespaces out of an XmlNamespaceDeclSpecs instance.

Functions

Link copied to clipboard

Get an instance of the default format cache that where supported uses threadlocals for thread safety.

Link copied to clipboard
fun XmlSerialName.toQName(serialName: String, parentNamespace: Namespace?): QName
Link copied to clipboard