1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package gov.nist.secauto.metaschema.databind.io.xml;
7
8 import gov.nist.secauto.metaschema.core.model.IBoundObject;
9 import gov.nist.secauto.metaschema.databind.io.IParsingContext;
10 import gov.nist.secauto.metaschema.databind.model.IBoundDefinitionModelComplex;
11 import gov.nist.secauto.metaschema.databind.model.IBoundInstanceModel;
12
13 import org.codehaus.stax2.XMLEventReader2;
14
15 import java.io.IOException;
16
17 import javax.xml.stream.XMLStreamConstants;
18
19 import edu.umd.cs.findbugs.annotations.NonNull;
20
21 public interface IXmlParsingContext extends IParsingContext<XMLEventReader2, IXmlProblemHandler> {
22
23 /**
24 * Parses XML into a bound object based on the provided {@code definition}.
25 * <p>
26 * Parses the {@link XMLStreamConstants#START_DOCUMENT}, any processing
27 * instructions, and the element.
28 *
29 * @param <CLASS>
30 * the returned object type
31 * @param definition
32 * the definition describing the element data to read
33 * @return the parsed object
34 * @throws IOException
35 * if an error occurred while parsing the input
36 */
37 <CLASS> CLASS read(@NonNull IBoundDefinitionModelComplex definition) throws IOException;
38
39 /**
40 * Read the data associated with the {@code instance} and apply it to the
41 * provided {@code parentObject}.
42 *
43 * @param <T>
44 * the item Java type
45 * @param instance
46 * the instance to parse data for
47 * @param parentObject
48 * the Java object that data parsed by this method will be stored in
49 * @param parseGrouping
50 * if {@code true} parse the instance's grouping element or
51 * {@code false} otherwise
52 * @return {@code true} if the instance was parsed, or {@code false} if the data
53 * did not contain information for this instance
54 * @throws IOException
55 * if an error occurred while parsing the input
56 *
57 */
58 <T> boolean readItems(
59 @NonNull IBoundInstanceModel<T> instance,
60 @NonNull IBoundObject parentObject,
61 boolean parseGrouping) throws IOException;
62 }