View Javadoc

1   /*
2    * Copyright 2005,2009 Ivan SZKIBA
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.ini4j;
17  
18  import org.ini4j.spi.WinEscapeTool;
19  
20  import java.io.File;
21  import java.io.IOException;
22  import java.io.InputStream;
23  import java.io.Reader;
24  
25  import java.net.URL;
26  
27  public class Wini extends Ini
28  {
29      private static final long serialVersionUID = -2781377824232440728L;
30      public static final char PATH_SEPARATOR = '\\';
31  
32      public Wini()
33      {
34          Config cfg = Config.getGlobal().clone();
35  
36          cfg.setEscape(false);
37          cfg.setEscapeNewline(false);
38          cfg.setGlobalSection(true);
39          cfg.setEmptyOption(true);
40          cfg.setMultiOption(false);
41          cfg.setPathSeparator(PATH_SEPARATOR);
42          setConfig(cfg);
43      }
44  
45      public Wini(File input) throws IOException, InvalidFileFormatException
46      {
47          this();
48          setFile(input);
49          load();
50      }
51  
52      public Wini(URL input) throws IOException, InvalidFileFormatException
53      {
54          this();
55          load(input);
56      }
57  
58      public Wini(InputStream input) throws IOException, InvalidFileFormatException
59      {
60          this();
61          load(input);
62      }
63  
64      public Wini(Reader input) throws IOException, InvalidFileFormatException
65      {
66          this();
67          load(input);
68      }
69  
70      public String escape(String value)
71      {
72          return WinEscapeTool.getInstance().escape(value);
73      }
74  
75      public String unescape(String value)
76      {
77          return WinEscapeTool.getInstance().unescape(value);
78      }
79  }