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 027 * parsing and writing of INI documents. 028 * </p> 029 * <p> 030 * This class is not thread-safe. It is intended that an instance is constructed 031 * and initialized by a single thread during configuration of a 032 * {@code ConfigurationBuilder}. 033 * </p> 034 * 035 * @since 2.2 036 */ 037public class INIBuilderParametersImpl extends HierarchicalBuilderParametersImpl 038 implements INIBuilderProperties<INIBuilderParametersImpl> 039{ 040 /** The key for the separatorUsedInINIOutput property. */ 041 private static final String PROP_SEPARATOR_USED_IN_INI_OUTPUT 042 = "separatorUsedInOutput"; 043 044 /** The key for the separatorUsedInInput property. */ 045 private static final String PROP_SEPARATOR_USED_IN_INI_INPUT 046 = "separatorUsedInInput"; 047 048 /** The key for the commentLeadingCharsUsedInInput property. */ 049 private static final String PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT 050 = "commentLeadingCharsUsedInInput"; 051 052 @Override 053 public void inheritFrom(final Map<String, ?> source) 054 { 055 super.inheritFrom(source); 056 copyPropertiesFrom(source, PROP_SEPARATOR_USED_IN_INI_OUTPUT); 057 copyPropertiesFrom(source, PROP_SEPARATOR_USED_IN_INI_INPUT); 058 copyPropertiesFrom(source, PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT); 059 } 060 061 @Override 062 public INIBuilderParametersImpl setSeparatorUsedInOutput(final String separator) 063 { 064 storeProperty(PROP_SEPARATOR_USED_IN_INI_OUTPUT, separator); 065 return this; 066 } 067 068 @Override 069 public INIBuilderParametersImpl setSeparatorUsedInInput(final String separator) 070 { 071 storeProperty(PROP_SEPARATOR_USED_IN_INI_INPUT, separator); 072 return this; 073 } 074 075 @Override 076 public INIBuilderParametersImpl setCommentLeadingCharsUsedInInput(final String separator) 077 { 078 storeProperty(PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT, separator); 079 return this; 080 } 081}