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