View Javadoc
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.settings.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.util.Map;
26  import org.apache.maven.api.settings.Settings;
27  
28  /**
29   * Handles deserialization of settings from some kind of textual format like XML.
30   *
31   * @author Benjamin Bentmann
32   */
33  public interface SettingsReader {
34  
35      /**
36       * The key for the option to enable strict parsing. This option is of type {@link Boolean} and defaults to {@code
37       * true}. If {@code false}, unknown elements will be ignored instead of causing a failure.
38       */
39      String IS_STRICT = "org.apache.maven.settings.io.isStrict";
40  
41      /**
42       * Reads the settings from the specified file.
43       *
44       * @param input The file to deserialize the settings from, must not be {@code null}.
45       * @param options The options to use for deserialization, may be {@code null} to use the default values.
46       * @return The deserialized settings, never {@code null}.
47       * @throws IOException If the settings could not be deserialized.
48       * @throws SettingsParseException If the input format could not be parsed.
49       */
50      Settings read(File input, Map<String, ?> options) throws IOException, SettingsParseException;
51  
52      /**
53       * Reads the settings from the specified character reader. The reader will be automatically closed before the method
54       * returns.
55       *
56       * @param input The reader to deserialize the settings from, must not be {@code null}.
57       * @param options The options to use for deserialization, may be {@code null} to use the default values.
58       * @return The deserialized settings, never {@code null}.
59       * @throws IOException If the settings could not be deserialized.
60       * @throws SettingsParseException If the input format could not be parsed.
61       */
62      Settings read(Reader input, Map<String, ?> options) throws IOException, SettingsParseException;
63  
64      /**
65       * Reads the settings from the specified byte stream. The stream will be automatically closed before the method
66       * returns.
67       *
68       * @param input The stream to deserialize the settings from, must not be {@code null}.
69       * @param options The options to use for deserialization, may be {@code null} to use the default values.
70       * @return The deserialized settings, never {@code null}.
71       * @throws IOException If the settings could not be deserialized.
72       * @throws SettingsParseException If the input format could not be parsed.
73       */
74      Settings read(InputStream input, Map<String, ?> options) throws IOException, SettingsParseException;
75  }