001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.configuration2.builder;
018
019import java.util.Map;
020
021/**
022 * <p>
023 * A specialized parameters class for INI configuration.
024 * </p>
025 * <p>
026 * This parameters class defines some properties which allow customizing the parsing and writing of INI documents.
027 * </p>
028 * <p>
029 * This class is not thread-safe. It is intended that an instance is constructed and initialized by a single thread
030 * during configuration of a {@code ConfigurationBuilder}.
031 * </p>
032 *
033 * @since 2.2
034 */
035public class INIBuilderParametersImpl extends HierarchicalBuilderParametersImpl implements INIBuilderProperties<INIBuilderParametersImpl> {
036    /** The key for the separatorUsedInINIOutput property. */
037    private static final String PROP_SEPARATOR_USED_IN_INI_OUTPUT = "separatorUsedInOutput";
038
039    /** The key for the separatorUsedInInput property. */
040    private static final String PROP_SEPARATOR_USED_IN_INI_INPUT = "separatorUsedInInput";
041
042    /** The key for the commentLeadingCharsUsedInInput property. */
043    private static final String PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT = "commentLeadingCharsUsedInInput";
044
045    @Override
046    public void inheritFrom(final Map<String, ?> source) {
047        super.inheritFrom(source);
048        copyPropertiesFrom(source, PROP_SEPARATOR_USED_IN_INI_OUTPUT);
049        copyPropertiesFrom(source, PROP_SEPARATOR_USED_IN_INI_INPUT);
050        copyPropertiesFrom(source, PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT);
051    }
052
053    @Override
054    public INIBuilderParametersImpl setSeparatorUsedInOutput(final String separator) {
055        storeProperty(PROP_SEPARATOR_USED_IN_INI_OUTPUT, separator);
056        return this;
057    }
058
059    @Override
060    public INIBuilderParametersImpl setSeparatorUsedInInput(final String separator) {
061        storeProperty(PROP_SEPARATOR_USED_IN_INI_INPUT, separator);
062        return this;
063    }
064
065    @Override
066    public INIBuilderParametersImpl setCommentLeadingCharsUsedInInput(final String separator) {
067        storeProperty(PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT, separator);
068        return this;
069    }
070}