001    /*
002     * Copyright 2005,2009 Ivan SZKIBA
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.ini4j;
017    
018    import org.ini4j.spi.WinEscapeTool;
019    
020    import java.io.File;
021    import java.io.IOException;
022    import java.io.InputStream;
023    import java.io.Reader;
024    
025    import java.net.URL;
026    
027    public class Wini extends Ini
028    {
029        private static final long serialVersionUID = -2781377824232440728L;
030        public static final char PATH_SEPARATOR = '\\';
031    
032        public Wini()
033        {
034            Config cfg = Config.getGlobal().clone();
035    
036            cfg.setEscape(false);
037            cfg.setGlobalSection(true);
038            cfg.setEmptyOption(true);
039            cfg.setMultiOption(false);
040            cfg.setPathSeparator(PATH_SEPARATOR);
041            setConfig(cfg);
042        }
043    
044        public Wini(File input) throws IOException, InvalidFileFormatException
045        {
046            this();
047            setFile(input);
048            load();
049        }
050    
051        public Wini(URL input) throws IOException, InvalidFileFormatException
052        {
053            this();
054            load(input);
055        }
056    
057        public Wini(InputStream input) throws IOException, InvalidFileFormatException
058        {
059            this();
060            load(input);
061        }
062    
063        public Wini(Reader input) throws IOException, InvalidFileFormatException
064        {
065            this();
066            load(input);
067        }
068    
069        public String escape(String value)
070        {
071            return WinEscapeTool.getInstance().escape(value);
072        }
073    
074        public String unescape(String value)
075        {
076            return WinEscapeTool.getInstance().unescape(value);
077        }
078    }