1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.model.io; 20 21 import java.io.File; 22 import java.io.IOException; 23 import java.io.InputStream; 24 import java.io.Reader; 25 import java.nio.file.Path; 26 import java.util.Map; 27 28 import org.apache.maven.model.Model; 29 30 /** 31 * Handles deserialization of a model from some kind of textual format like XML. 32 * 33 * @deprecated use {@link org.apache.maven.api.services.xml.ModelXmlFactory} instead 34 */ 35 @Deprecated(since = "4.0.0") 36 public interface ModelReader { 37 38 /** 39 * The key for the option to enable strict parsing. This option is of type {@link Boolean} and defaults to {@code 40 * true}. If {@code false}, unknown elements will be ignored instead of causing a failure. 41 */ 42 String IS_STRICT = "org.apache.maven.model.io.isStrict"; 43 44 /** 45 * The key for the option to enable tracking of line/column numbers. This option is of type 46 * {@link org.apache.maven.model.InputSource} and defaults to {@code null}. Providing an input source enables 47 * location tracking. 48 */ 49 String INPUT_SOURCE = "org.apache.maven.model.io.inputSource"; 50 51 /** 52 * Name of the property used to store the project's root directory to use with 53 * XInclude support. 54 */ 55 String ROOT_DIRECTORY = "rootDirectory"; 56 57 /** 58 * Reads the model from the specified file. 59 * 60 * @param input The file to deserialize the model from, must not be {@code null}. 61 * @param options The options to use for deserialization, may be {@code null} to use the default values. 62 * @return The deserialized model, never {@code null}. 63 * @throws IOException If the model could not be deserialized. 64 * @throws ModelParseException If the input format could not be parsed. 65 * @deprecated Use {@link #read(Path, Map)} instead. 66 */ 67 @Deprecated 68 Model read(File input, Map<String, ?> options) throws IOException, ModelParseException; 69 70 /** 71 * Reads the model from the specified file. 72 * 73 * @param input The file to deserialize the model from, must not be {@code null}. 74 * @param options The options to use for deserialization, may be {@code null} to use the default values. 75 * @return The deserialized model, never {@code null}. 76 * @throws IOException If the model could not be deserialized. 77 * @throws ModelParseException If the input format could not be parsed. 78 */ 79 Model read(Path input, Map<String, ?> options) throws IOException, ModelParseException; 80 81 /** 82 * Reads the model from the specified character reader. The reader will be automatically closed before the method 83 * returns. 84 * 85 * @param input The reader to deserialize the model from, must not be {@code null}. 86 * @param options The options to use for deserialization, may be {@code null} to use the default values. 87 * @return The deserialized model, never {@code null}. 88 * @throws IOException If the model could not be deserialized. 89 * @throws ModelParseException If the input format could not be parsed. 90 */ 91 Model read(Reader input, Map<String, ?> options) throws IOException, ModelParseException; 92 93 /** 94 * Reads the model from the specified byte stream. The stream will be automatically closed before the method 95 * returns. 96 * 97 * @param input The stream to deserialize the model from, must not be {@code null}. 98 * @param options The options to use for deserialization, may be {@code null} to use the default values. 99 * @return The deserialized model, never {@code null}. 100 * @throws IOException If the model could not be deserialized. 101 * @throws ModelParseException If the input format could not be parsed. 102 */ 103 Model read(InputStream input, Map<String, ?> options) throws IOException, ModelParseException; 104 }