001 package org.apache.maven.settings.io;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements. See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership. The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License. You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied. See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022 import java.io.File;
023 import java.io.IOException;
024 import java.io.OutputStream;
025 import java.io.Writer;
026 import java.util.Map;
027
028 import org.apache.maven.settings.Settings;
029
030 /**
031 * Handles serialization of settings into some kind of textual format like XML.
032 *
033 * @author Benjamin Bentmann
034 */
035 public interface SettingsWriter
036 {
037
038 /**
039 * Writes the supplied settings to the specified file. Any non-existing parent directories of the output file will
040 * be created automatically.
041 *
042 * @param output The file to serialize the settings to, must not be {@code null}.
043 * @param options The options to use for serialization, may be {@code null} to use the default values.
044 * @param settings The settings to serialize, must not be {@code null}.
045 * @throws IOException If the settings could not be serialized.
046 */
047 void write( File output, Map<String, Object> options, Settings settings )
048 throws IOException;
049
050 /**
051 * Writes the supplied settings to the specified character writer. The writer will be automatically closed before
052 * the method returns.
053 *
054 * @param output The writer to serialize the settings to, must not be {@code null}.
055 * @param options The options to use for serialization, may be {@code null} to use the default values.
056 * @param settings The settings to serialize, must not be {@code null}.
057 * @throws IOException If the settings could not be serialized.
058 */
059 void write( Writer output, Map<String, Object> options, Settings settings )
060 throws IOException;
061
062 /**
063 * Writes the supplied settings to the specified byte stream. The stream will be automatically closed before the
064 * method returns.
065 *
066 * @param output The stream to serialize the settings to, must not be {@code null}.
067 * @param options The options to use for serialization, may be {@code null} to use the default values.
068 * @param settings The settings to serialize, must not be {@code null}.
069 * @throws IOException If the settings could not be serialized.
070 */
071 void write( OutputStream output, Map<String, Object> options, Settings settings )
072 throws IOException;
073
074 }