View Javadoc

1   package org.apache.maven.settings.io;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.io.IOException;
24  import java.io.InputStream;
25  import java.io.Reader;
26  import java.util.Map;
27  
28  import org.apache.maven.settings.Settings;
29  
30  /**
31   * Handles deserialization of settings from some kind of textual format like XML.
32   * 
33   * @author Benjamin Bentmann
34   */
35  public interface SettingsReader
36  {
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.settings.io.isStrict";
43  
44      /**
45       * Reads the settings from the specified file.
46       * 
47       * @param input The file to deserialize the settings from, must not be {@code null}.
48       * @param options The options to use for deserialization, may be {@code null} to use the default values.
49       * @return The deserialized settings, never {@code null}.
50       * @throws IOException If the settings could not be deserialized.
51       * @throws SettingsParseException If the input format could not be parsed.
52       */
53      Settings read( File input, Map<String, ?> options )
54          throws IOException, SettingsParseException;
55  
56      /**
57       * Reads the settings from the specified character reader. The reader will be automatically closed before the method
58       * returns.
59       * 
60       * @param input The reader to deserialize the settings 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 settings, never {@code null}.
63       * @throws IOException If the settings could not be deserialized.
64       * @throws SettingsParseException If the input format could not be parsed.
65       */
66      Settings read( Reader input, Map<String, ?> options )
67          throws IOException, SettingsParseException;
68  
69      /**
70       * Reads the settings from the specified byte stream. The stream will be automatically closed before the method
71       * returns.
72       * 
73       * @param input The stream to deserialize the settings 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 settings, never {@code null}.
76       * @throws IOException If the settings could not be deserialized.
77       * @throws SettingsParseException If the input format could not be parsed.
78       */
79      Settings read( InputStream input, Map<String, ?> options )
80          throws IOException, SettingsParseException;
81  
82  }