| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.ini4j; |
| 17 | |
|
| 18 | |
import org.ini4j.Profile.Section; |
| 19 | |
|
| 20 | |
import org.ini4j.spi.IniHandler; |
| 21 | |
import org.ini4j.spi.RegEscapeTool; |
| 22 | |
import org.ini4j.spi.TypeValuesPair; |
| 23 | |
|
| 24 | 516 | public class BasicRegistry extends BasicProfile implements Registry |
| 25 | |
{ |
| 26 | |
private static final long serialVersionUID = -6432826330714504802L; |
| 27 | |
private String _version; |
| 28 | |
|
| 29 | |
public BasicRegistry() |
| 30 | 22 | { |
| 31 | 22 | _version = VERSION; |
| 32 | 22 | } |
| 33 | |
|
| 34 | |
@Override public String getVersion() |
| 35 | |
{ |
| 36 | 17 | return _version; |
| 37 | |
} |
| 38 | |
|
| 39 | |
@Override public void setVersion(String value) |
| 40 | |
{ |
| 41 | 1 | _version = value; |
| 42 | 1 | } |
| 43 | |
|
| 44 | |
@Override public Key add(String name) |
| 45 | |
{ |
| 46 | 145 | return (Key) super.add(name); |
| 47 | |
} |
| 48 | |
|
| 49 | |
@Override public Key get(Object key) |
| 50 | |
{ |
| 51 | 234 | return (Key) super.get(key); |
| 52 | |
} |
| 53 | |
|
| 54 | |
@Override public Key get(Object key, int index) |
| 55 | |
{ |
| 56 | 1 | return (Key) super.get(key, index); |
| 57 | |
} |
| 58 | |
|
| 59 | |
@Override public Key put(String key, Section value) |
| 60 | |
{ |
| 61 | 1 | return (Key) super.put(key, value); |
| 62 | |
} |
| 63 | |
|
| 64 | |
@Override public Key put(String key, Section value, int index) |
| 65 | |
{ |
| 66 | 1 | return (Key) super.put(key, value, index); |
| 67 | |
} |
| 68 | |
|
| 69 | |
@Override public Key remove(Section section) |
| 70 | |
{ |
| 71 | 1 | return (Key) super.remove(section); |
| 72 | |
} |
| 73 | |
|
| 74 | |
@Override public Key remove(Object key) |
| 75 | |
{ |
| 76 | 2 | return (Key) super.remove(key); |
| 77 | |
} |
| 78 | |
|
| 79 | |
@Override public Key remove(Object key, int index) |
| 80 | |
{ |
| 81 | 1 | return (Key) super.remove(key, index); |
| 82 | |
} |
| 83 | |
|
| 84 | |
@Override Key newSection(String name) |
| 85 | |
{ |
| 86 | 145 | return new BasicRegistryKey(this, name); |
| 87 | |
} |
| 88 | |
|
| 89 | |
@Override void store(IniHandler formatter, Section section, String option) |
| 90 | |
{ |
| 91 | 89 | store(formatter, section.getComment(option)); |
| 92 | 89 | Type type = ((Key) section).getType(option, Type.REG_SZ); |
| 93 | 89 | String rawName = option.equals(Key.DEFAULT_NAME) ? option : RegEscapeTool.getInstance().quote(option); |
| 94 | 89 | String[] values = new String[section.length(option)]; |
| 95 | |
|
| 96 | 183 | for (int i = 0; i < values.length; i++) |
| 97 | |
{ |
| 98 | 94 | values[i] = section.get(option, i); |
| 99 | |
} |
| 100 | |
|
| 101 | 89 | String rawValue = RegEscapeTool.getInstance().encode(new TypeValuesPair(type, values)); |
| 102 | |
|
| 103 | 89 | formatter.handleOption(rawName, rawValue); |
| 104 | 89 | } |
| 105 | |
} |