本文整理匯總了Java中org.ini4j.Ini.containsKey方法的典型用法代碼示例。如果您正苦於以下問題:Java Ini.containsKey方法的具體用法?Java Ini.containsKey怎麽用?Java Ini.containsKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.ini4j.Ini
的用法示例。
在下文中一共展示了Ini.containsKey方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isSubsetOf
import org.ini4j.Ini; //導入方法依賴的package包/類
private void isSubsetOf(String sourceIniPath, String expectedIniPath) throws IOException {
Ini goldenIni = new Ini(new FileInputStream(expectedIniPath));
Ini sourceIni = new Ini(new FileInputStream(sourceIniPath));
for(String key : goldenIni.keySet()) {
if(!sourceIni.containsKey(key) && goldenIni.get(key).size() > 0) {
fail("missing section " + key + " in file " + sourceIniPath);
}
Section goldenSection = goldenIni.get(key);
Section sourceSection = sourceIni.get(key);
for(String name : goldenSection.childrenNames()) {
if(!sourceSection.containsKey(name)) {
fail("missing name " + name + " in file " + sourceIniPath + " section [" + name + "]");
}
assertEquals(goldenSection.get(name), sourceSection.get(name));
}
}
}
示例2: setupLanguage
import org.ini4j.Ini; //導入方法依賴的package包/類
static void setupLanguage(String id, boolean silent) throws IOException {
File f = new File("messages.ini");
Config conf = new Config(f).setDefaultConfig(getDefaultIni()).compare();
if (conf.wasChanged() && !silent)
System.out.println("[Config] " + f.getName() + " has been updated.");
final Ini ini = conf.getIni();
if (!ini.containsKey(id))
Exceptions.handle(new Exception("Language code " + id + " is not valid!"), "Language code " + id + " is not valid!", true);
Section section = ini.get(id);
for (String key : section.keySet()) {
msg.put(key, section.get(key));
}
msg.put("help-dialog",
"[URL=https://sprum.ml]Sprummlbot[/URL] v" + Vars.VERSION + " by Scrumplex.");
}
示例3: configureSplitter
import org.ini4j.Ini; //導入方法依賴的package包/類
private void configureSplitter() throws FuseException {
Ini config = IniUtil.getIni(vtSplitterConfig.getText());
//TODO: check and write version
try {
if(config.get("splitter").containsKey("save")){
log.debug("save Splitter's configuration");
if(config.containsKey("database")){
saveDatabase(config);
}
String sessionNumber = config.fetch("splitter", "save", String.class);
config.remove("splitter", "save");
fileStore.writeMetaData(IniUtil.getString(config), "/.nubisave_database.meta"+sessionNumber);
storageServiceMgr.getServices().storeServiceNames(".nubisave_service_name.session"+sessionNumber);
} else if(config.get("splitter").containsKey("load")){
setServicesMapping(config);
config = loadDatabaseMetaData(config);
reloadDatabase(config);
}
} catch (IOException e) {
config.getFile().delete();
throw new FuseException("IO Exception on persisting Splitter's configuration.")
.initErrno(FuseException.EIO);
}
vtSplitterConfig.setText(IniUtil.getString(config));
setRedundancy(config.fetch("splitter", "redundancy", Integer.class));
setStorageStrategyName(config.fetch("splitter", "storagestrategy", String.class));
updateVTSplitterConfigFile();
config.getFile().delete();
}
示例4: deletePreviousSession
import org.ini4j.Ini; //導入方法依賴的package包/類
private void deletePreviousSession(Ini config) throws IOException{
String sectionName;
Ini previousSession;
int databasePartNr = 0;
while(true){ // remove previous database parts
sectionName = "databasePartNr_"+databasePartNr;
if( ! config.containsKey(sectionName) ){
break;
}
config.remove(sectionName);
databasePartNr++;
}
byte[] splitter_config = fileStore.readMetaData("/.nubisave_database.meta"+config.fetch("splitter", "load", Integer.class));
previousSession = IniUtil.getIni(new String(splitter_config, "UTF-8"));
ArrayList<String> fragmentNames = new ArrayList<String>();
ArrayList<String> absoluteFragmentNames;
int nr_of_file_fragments;
databasePartNr = 0;
while(true){
sectionName = "databasePartNr_"+databasePartNr;
if( ! previousSession.containsKey(sectionName) ){
break;
}
databasePartNr++;
nr_of_file_fragments = previousSession.fetch(sectionName, "nrOfFileFragments", Integer.class);
fragmentNames = new ArrayList<String>();
for(int i=0; i<nr_of_file_fragments; i++){
fragmentNames.add(previousSession.fetch(sectionName, "fileFragmentName_"+i, String.class));
}
absoluteFragmentNames = getAbsoluteFragmentPaths(fragmentNames, nr_of_file_fragments);
for(String previousFragment: absoluteFragmentNames){
new File(previousFragment).delete();
}
}
}
示例5: load
import org.ini4j.Ini; //導入方法依賴的package包/類
public boolean load(File fileToLoad) {
try {
System.out.println("[Plugins] Loading plugin " + fileToLoad.getName() + "...");
JarFile jarFile = new JarFile(fileToLoad);
JarEntry pluginIniEntry = jarFile.getJarEntry("plugin.ini");
if (pluginIniEntry == null) {
Exceptions.handlePluginError(new PluginLoadException("Ini file not found"), fileToLoad);
jarFile.close();
return false;
}
InputStream input = jarFile.getInputStream(pluginIniEntry);
String mainClassPath;
Ini ini = new Ini(input);
jarFile.close();
if (!ini.containsKey("Plugin")) {
Exceptions.handlePluginError(new PluginLoadException("Ini file is incompatible"), fileToLoad);
jarFile.close();
return false;
}
Section pluginSection = ini.get("Plugin");
if (!pluginSection.containsKey("main")) {
Exceptions.handlePluginError(new PluginLoadException("Ini file is incompatible"), fileToLoad);
return false;
}
mainClassPath = pluginSection.get("main");
String pluginName = fileToLoad.getName();
String pluginAuthors[] = {"undefined"};
String pluginVersion = "1.0.0";
if (ini.containsKey("Information")) {
pluginSection = ini.get("Information");
if (pluginSection.containsKey("name"))
pluginName = pluginSection.get("name").replace(" ", "_");
if (pluginSection.containsKey("author"))
pluginAuthors[0] = pluginSection.get("author");
else if (pluginSection.containsKey("authors"))
pluginAuthors = pluginSection.getAll("authors", String[].class);
if (pluginSection.containsKey("version"))
pluginVersion = pluginSection.get("version");
}
PluginInfo info = new PluginInfo(pluginName, pluginVersion, pluginAuthors, fileToLoad, new File("plugins", pluginName), mainClassPath);
if (isLoaded(pluginName))
throw new PluginLoadException("Plugin already loaded!");
System.out.println("[Plugins][" + info.getPluginName() + "] Enabling plugin " + info.getPluginName() + " version " + info.getPluginVersion() + " by " + info.getPluginAuthor() + "...");
PluginClassLoader loader = new PluginClassLoader(getClass().getClassLoader(), info);
SprummlbotPlugin sprummlPlugin = loader.getPlugin();
SprummlTasker tasker = new SprummlTasker(sprummlPlugin);
EventManager eventManager = new EventManager(sprummlPlugin);
sprummlPlugin.initialize(loader, tasker, eventManager, info, sprummlbot);
System.out.println("[Plugins][" + info.getPluginName() + "] Plugin " + pluginName + " successfully enabled!");
plugins.put(fileToLoad, sprummlPlugin);
classLoaders.put(sprummlPlugin, loader);
return true;
} catch (Throwable e) {
Exceptions.handlePluginError(e, fileToLoad);
}
return false;
}
示例6: loadDatabaseMetaData
import org.ini4j.Ini; //導入方法依賴的package包/類
private Ini loadDatabaseMetaData(Ini config) throws IOException,
UnsupportedEncodingException {
log.debug("load Splitter's configuration");
byte[] splitter_config = fileStore.readMetaData("/.nubisave_database.meta"+config.fetch("splitter", "load", Integer.class));
log.debug("new String(splitter_config)"+new String(splitter_config));
vtSplitterConfig.setText(new String(splitter_config, "UTF-8"));
config = IniUtil.getIni(new String(splitter_config, "UTF-8"));
config.remove("splitter", "load");
String dbPath = config.fetch("database", "path", String.class);
long dbSize = config.fetch("database", "size", long.class);
ArrayList<String> fragmentNames = new ArrayList<String>();
ArrayList<byte[]> checksums;
ArrayList<String> absoluteFragmentNames;
int nr_of_file_fragments_required;
int nr_of_file_fragments;
String sectionName, dbPartPath;
int databasePartNr = 0;
while(true){
sectionName = "databasePartNr_"+databasePartNr;
if( ! config.containsKey(sectionName) ){
break;
}
databasePartNr++;
dbPartPath = config.fetch(sectionName, "name", String.class);
nr_of_file_fragments_required = config.fetch(sectionName, "nrOfFileFragmentsRequired", Integer.class);
nr_of_file_fragments = config.fetch(sectionName, "nrOfFileFragments", Integer.class);
fragmentNames = new ArrayList<String>();
checksums = new ArrayList<byte[]>();
for(int i=0; i<nr_of_file_fragments; i++){
fragmentNames.add(config.fetch(sectionName, "fileFragmentName_"+i, String.class));
log.debug("fragment name "+i+": "+fragmentNames.get(i));
checksums.add( Hex.decode(config.fetch(sectionName, "fileFragmentNameChecksum_"+i, String.class)) );
}
absoluteFragmentNames = getAbsoluteFragmentPaths(fragmentNames, nr_of_file_fragments);
fileStore.fileFragmentMetaDataStore.setFragments(dbPartPath, absoluteFragmentNames, nr_of_file_fragments_required, nr_of_file_fragments, checksums, dbSize);
((FilePartFragmentMetaDataStore)fileStore.fileFragmentMetaDataStore).put(dbPath,dbSize);
}
FileEntry fileEntry;
//metaDataStore.makeFolderEntry(dbPath);
fileEntry = metaDataStore.makeFileEntry(dbPath);
fileEntry.uid = UID;
fileEntry.gid = GID;
log.debug("size:"+fileStore.getSize(dbPath));
metaDataStore.putFileEntry(dbPath, fileEntry);
log.debug("Metadata of database successfully created");
return config;
}