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 java.nio.charset.Charset;
019
020 import java.util.HashMap;
021 import java.util.Map;
022
023 public interface Registry extends Profile
024 {
025 enum Hive
026 {
027 HKEY_CLASSES_ROOT,
028 HKEY_CURRENT_CONFIG,
029 HKEY_CURRENT_USER,
030 HKEY_LOCAL_MACHINE,
031 HKEY_USERS;
032 }
033
034 // TODO handle delete operations with special Type
035 enum Type
036 {
037 REG_NONE("hex(0)"),
038 REG_SZ(""),
039 REG_EXPAND_SZ("hex(2)"),
040 REG_BINARY("hex"),
041 REG_DWORD("dword"),
042 REG_DWORD_BIG_ENDIAN("hex(5)"),
043 REG_LINK("hex(6)"),
044 REG_MULTI_SZ("hex(7)"),
045 REG_RESOURCE_LIST("hex(8)"),
046 REG_FULL_RESOURCE_DESCRIPTOR("hex(9)"),
047 REG_RESOURCE_REQUIREMENTS_LIST("hex(a)"),
048 REG_QWORD("hex(b)");
049 private static final Map<String, Type> MAPPING;
050
051 static
052 {
053 MAPPING = new HashMap<String, Type>();
054 for (Type t : values())
055 {
056 MAPPING.put(t.toString(), t);
057 }
058 }
059
060 public static final char SEPARATOR_CHAR = ':';
061 public static final String SEPARATOR = String.valueOf(SEPARATOR_CHAR);
062 public static final char REMOVE_CHAR = '-';
063 public static final String REMOVE = String.valueOf(REMOVE_CHAR);
064 private final String _prefix;
065
066 private Type(String prefix)
067 {
068 _prefix = prefix;
069 }
070
071 public static Type fromString(String str)
072 {
073 return MAPPING.get(str);
074 }
075
076 @Override public String toString()
077 {
078 return _prefix;
079 }
080 }
081
082 char ESCAPE_CHAR = '\\';
083 Charset FILE_ENCODING = Charset.forName("UnicodeLittle");
084 char KEY_SEPARATOR = '\\';
085 String LINE_SEPARATOR = "\r\n";
086 char TYPE_SEPARATOR = ':';
087 String VERSION = "Windows Registry Editor Version 5.00";
088
089 String getVersion();
090
091 void setVersion(String value);
092
093 @Override Key get(Object key);
094
095 @Override Key get(Object key, int index);
096
097 @Override Key put(String key, Section value);
098
099 @Override Key put(String key, Section value, int index);
100
101 @Override Key remove(Object key);
102
103 @Override Key remove(Object key, int index);
104
105 interface Key extends Section
106 {
107 String DEFAULT_NAME = "@";
108
109 @Override Key getChild(String key);
110
111 @Override Key getParent();
112
113 Type getType(Object key);
114
115 Type getType(Object key, Type defaulType);
116
117 @Override Key addChild(String key);
118
119 @Override Key lookup(String... path);
120
121 Type putType(String key, Type type);
122
123 Type removeType(Object key);
124 }
125 }