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 * https://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 /** 046 * Constructs a new instance. 047 */ 048 public INIBuilderParametersImpl() { 049 // empty 050 } 051 052 @Override 053 public void inheritFrom(final Map<String, ?> source) { 054 super.inheritFrom(source); 055 copyPropertiesFrom(source, PROP_SEPARATOR_USED_IN_INI_OUTPUT); 056 copyPropertiesFrom(source, PROP_SEPARATOR_USED_IN_INI_INPUT); 057 copyPropertiesFrom(source, PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT); 058 } 059 060 @Override 061 public INIBuilderParametersImpl setCommentLeadingCharsUsedInInput(final String separator) { 062 storeProperty(PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT, separator); 063 return this; 064 } 065 066 @Override 067 public INIBuilderParametersImpl setSeparatorUsedInInput(final String separator) { 068 storeProperty(PROP_SEPARATOR_USED_IN_INI_INPUT, separator); 069 return this; 070 } 071 072 @Override 073 public INIBuilderParametersImpl setSeparatorUsedInOutput(final String separator) { 074 storeProperty(PROP_SEPARATOR_USED_IN_INI_OUTPUT, separator); 075 return this; 076 } 077}