Skip to content

Commit

Permalink
Add support for adding initial namespace context to an XmlBufferReader.
Browse files Browse the repository at this point in the history
  • Loading branch information
pdvrieze committed Mar 1, 2024
1 parent 3440f6b commit b7327c6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions core/api/android/core.api
Expand Up @@ -264,6 +264,7 @@ public final class nl/adaptivity/xmlutil/XMLConstants {

public final class nl/adaptivity/xmlutil/XmlBufferReader : nl/adaptivity/xmlutil/XmlReader {
public fun <init> (Ljava/util/List;)V
public fun <init> (Ljava/util/List;Lnl/adaptivity/xmlutil/IterableNamespaceContext;)V
public fun close ()V
public fun getAttributeCount ()I
public fun getAttributeLocalName (I)Ljava/lang/String;
Expand Down
1 change: 1 addition & 0 deletions core/api/jvm/core.api
Expand Up @@ -287,6 +287,7 @@ public final class nl/adaptivity/xmlutil/XMLConstants {

public final class nl/adaptivity/xmlutil/XmlBufferReader : nl/adaptivity/xmlutil/XmlReader {
public fun <init> (Ljava/util/List;)V
public fun <init> (Ljava/util/List;Lnl/adaptivity/xmlutil/IterableNamespaceContext;)V
public fun close ()V
public fun getAttributeCount ()I
public fun getAttributeLocalName (I)Ljava/lang/String;
Expand Down
Expand Up @@ -28,10 +28,19 @@ import nl.adaptivity.xmlutil.core.impl.NamespaceHolder
* A reader that presents a list of events as an xml reader. This is designed to work together with
* [XmlBufferedWriter].
*/
public class XmlBufferReader(private val buffer: List<XmlEvent>) : XmlReader {
public class XmlBufferReader private constructor(
private val buffer: List<XmlEvent>,
private val namespaceHolder: NamespaceHolder
) : XmlReader {
private var currentPos = -1

private val namespaceHolder = NamespaceHolder()
public constructor(buffer: List<XmlEvent>): this(buffer, NamespaceHolder())
public constructor(buffer: List<XmlEvent>, initialContext: IterableNamespaceContext): this(
buffer,
NamespaceHolder().also {
initialContext.forEach { ns -> it.addPrefixToContext(ns) }
}
)

override val eventType: EventType get() = buffer[currentPos].eventType

Expand Down

0 comments on commit b7327c6

Please sign in to comment.