1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package dev.metaschema.databind.io.xml;
7
8 import org.codehaus.stax2.XMLStreamWriter2;
9
10 import java.io.IOException;
11
12 import dev.metaschema.core.model.IBoundObject;
13 import dev.metaschema.databind.io.IWritingContext;
14 import dev.metaschema.databind.model.IBoundDefinitionModelAssembly;
15 import edu.umd.cs.findbugs.annotations.NonNull;
16
17 /**
18 * Provides the writing context for serializing Java objects to XML format.
19 * <p>
20 * This interface extends {@link IWritingContext} with an XML-specific writer
21 * type and adds a method for writing root elements.
22 *
23 * @see XMLStreamWriter2
24 */
25 public interface IXmlWritingContext extends IWritingContext<XMLStreamWriter2> {
26 /**
27 * Write the root element for the provided definition and bound object.
28 *
29 * @param definition
30 * the assembly definition describing the root element
31 * @param item
32 * the bound object to serialize as the root element
33 * @throws IOException
34 * if an error occurs during writing
35 */
36 void writeRoot(
37 @NonNull IBoundDefinitionModelAssembly definition,
38 @NonNull IBoundObject item) throws IOException;
39 }