001/*
002 * SPDX-FileCopyrightText: none
003 * SPDX-License-Identifier: CC0-1.0
004 */
005
006package dev.metaschema.databind.io.xml;
007
008import org.codehaus.stax2.XMLStreamWriter2;
009
010import java.io.IOException;
011
012import dev.metaschema.core.model.IBoundObject;
013import dev.metaschema.databind.io.IWritingContext;
014import dev.metaschema.databind.model.IBoundDefinitionModelAssembly;
015import edu.umd.cs.findbugs.annotations.NonNull;
016
017/**
018 * Provides the writing context for serializing Java objects to XML format.
019 * <p>
020 * This interface extends {@link IWritingContext} with an XML-specific writer
021 * type and adds a method for writing root elements.
022 *
023 * @see XMLStreamWriter2
024 */
025public interface IXmlWritingContext extends IWritingContext<XMLStreamWriter2> {
026  /**
027   * Write the root element for the provided definition and bound object.
028   *
029   * @param definition
030   *          the assembly definition describing the root element
031   * @param item
032   *          the bound object to serialize as the root element
033   * @throws IOException
034   *           if an error occurs during writing
035   */
036  void writeRoot(
037      @NonNull IBoundDefinitionModelAssembly definition,
038      @NonNull IBoundObject item) throws IOException;
039}