当前位置: 首页>>代码示例>>Java>>正文


Java Ini.Section方法代码示例

本文整理汇总了Java中org.ini4j.Ini.Section方法的典型用法代码示例。如果您正苦于以下问题:Java Ini.Section方法的具体用法?Java Ini.Section怎么用?Java Ini.Section使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ini4j.Ini的用法示例。


在下文中一共展示了Ini.Section方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getServerGroup

import org.ini4j.Ini; //导入方法依赖的package包/类
/**
 * Returns the section from the <b>servers</b> config file used by the Subversion module which 
 * is holding the proxy settings for the given host
 *
 * @param host the host
 * @return the section holding the proxy settings for the given host
 */ 
private Ini.Section getServerGroup(String host) {
    if(host == null || host.equals("")) {                                   // NOI18N
        return null;
    }
    Ini.Section groups = svnServers.get(GROUPS_SECTION);
    if(groups != null) {
        for (Iterator<String> it = groups.keySet().iterator(); it.hasNext();) {
            String key = it.next();
            String value = groups.get(key);
            if(value != null) {     
                value = value.trim();                    
                if(value != null && match(value, host)) {
                    return svnServers.get(key);
                }      
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SvnConfigFiles.java

示例2: setSSLCert

import org.ini4j.Ini; //导入方法依赖的package包/类
private boolean setSSLCert(RepositoryConnection rc, Ini.Section nbGlobalSection) {
    if(rc == null) {
        return false;
    }
    String certFile = rc.getCertFile();
    if(certFile == null || certFile.equals("")) {
        return false;
    }
    char[] certPasswordChars = rc.getCertPassword();
    String certPassword = certPasswordChars == null ? "" : new String(certPasswordChars); //NOI18N
    if(certPassword.equals("")) { // NOI18N
        return false;
    }
    nbGlobalSection.put("ssl-client-cert-file", certFile);
    if (!DO_NOT_SAVE_PASSPHRASE) {
        nbGlobalSection.put("ssl-client-cert-password", certPassword);
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SvnConfigFiles.java

示例3: testWithStrictOperator

import org.ini4j.Ini; //导入方法依赖的package包/类
@Test public void testWithStrictOperator() throws Exception
{
    Config cfg = new Config();

    cfg.setStrictOperator(true);
    Ini ini = new Ini();
    Ini.Section sec = ini.add(Dwarfs.PROP_BASHFUL);

    sec.put(Dwarf.PROP_AGE, DwarfsData.bashful.age);
    ini.setConfig(cfg);
    StringWriter writer = new StringWriter();

    ini.store(writer);
    StringBuilder exp = new StringBuilder();

    exp.append(IniParser.SECTION_BEGIN);
    exp.append(Dwarfs.PROP_BASHFUL);
    exp.append(IniParser.SECTION_END);
    exp.append(NL);
    exp.append(Dwarf.PROP_AGE);
    exp.append('=');
    exp.append(DwarfsData.bashful.age);
    exp.append(NL);
    exp.append(NL);
    assertEquals(exp.toString(), writer.toString());
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:27,代码来源:IniFormatterTest.java

示例4: sample01

import org.ini4j.Ini; //导入方法依赖的package包/类
void sample01(Ini.Section section)
    {

        //
        // read some values
        //
        String age = section.get("age");
        String weight = section.get("weight");
        String homeDir = section.get("homeDir");

        // get all option names
        Set<String> optionNames = section.keySet();

//}
        assertEquals(String.valueOf(DwarfsData.happy.age), age);
        assertEquals(String.valueOf(DwarfsData.happy.weight), weight);
        assertEquals(String.valueOf(DwarfsData.happy.homeDir), homeDir);
    }
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:19,代码来源:OptionMapTutorial.java

示例5: merge

import org.ini4j.Ini; //导入方法依赖的package包/类
/**
 * Merges only sections/keys/values into target which are not already present in source
 * 
 * @param source the source ini file
 * @param target the target ini file in which the values from the source file are going to be merged
 */
private void merge(Ini source, Ini target) {
    for (Iterator<String> itSections = source.keySet().iterator(); itSections.hasNext();) {
        String sectionName = itSections.next();
        Ini.Section sourceSection = source.get( sectionName );
        Ini.Section targetSection = target.get( sectionName );

        if(targetSection == null) {
            targetSection = target.add(sectionName);
        }

        for (Iterator<String> itVariables = sourceSection.keySet().iterator(); itVariables.hasNext();) {
            String key = itVariables.next();

            if(!targetSection.containsKey(key)) {
                targetSection.put(key, sourceSection.get(key));
            }
        }            
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:SvnConfigFiles.java

示例6: sample01

import org.ini4j.Ini; //导入方法依赖的package包/类
void sample01(Ini ini)
    {
        Ini.Section section = ini.get("happy");

        //
        // read some values
        //
        String age = section.get("age");
        String weight = section.get("weight");
        String homeDir = section.get("homeDir");

        //
        // .. or just use java.util.Map interface...
        //
        Map<String, String> map = ini.get("happy");

        age = map.get("age");
        weight = map.get("weight");
        homeDir = map.get("homeDir");

        // get all section names
        Set<String> sectionNames = ini.keySet();

//}
        Helper.assertEquals(DwarfsData.happy, section.as(Dwarf.class));
    }
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:27,代码来源:IniTutorial.java

示例7: test

import org.ini4j.Ini; //导入方法依赖的package包/类
private void test(String filename, String defaultEncoding) throws Exception
{
    Charset charset = (defaultEncoding == null) ? Config.DEFAULT_FILE_ENCODING : Charset.forName(defaultEncoding);
    UnicodeInputStreamReader reader = new UnicodeInputStreamReader(getClass().getResourceAsStream(filename), charset);
    Ini ini = new Ini();

    ini.setConfig(Config.getGlobal().clone());
    ini.getConfig().setFileEncoding(charset);
    ini.load(reader);
    Ini.Section sec = ini.get("section");

    if (sec == null)
    {
        throw new IllegalStateException("Missing section: section");
    }

    if (!"value".equals(sec.get("option")))
    {
        throw new IllegalStateException("Missing option: option");
    }
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:22,代码来源:UnicodeInputStreamReaderTest.java

示例8: sample01

import org.ini4j.Ini; //导入方法依赖的package包/类
void sample01(Ini ini)
    {
        Ini.Section sec = ini.get("happy");
        Dwarf happy = sec.as(Dwarf.class);
        int age = happy.getAge();
        URI homePage = happy.getHomePage();

        happy.setWeight(45.55);

//}
//|
//| The <<<happy instanceof Dwarf>>> relation is of course fulfilled in the
//| example above.
//|
        assertEquals(DwarfsData.happy.homePage.toString(), homePage.toString());
        assertEquals(DwarfsData.happy.age, age);
        assertEquals(45.55, happy.getWeight(), 0.01);
    }
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:19,代码来源:BeanTutorial.java

示例9: getPicUrl

import org.ini4j.Ini; //导入方法依赖的package包/类
private String getPicUrl(String filename)
{
	String url = null;
	Ini ini = new Ini();
	String filepath = configData.coolqDir + "/data/image/" + filename + ".cqimg";
	try
	{
		ini.load(new FileReader(filepath));
	} catch (IOException e)
	{
		e.printStackTrace();
	}
	Ini.Section section = ini.get("image");
	url = section.get("url");
	return url;
}
 
开发者ID:XiLingHost,项目名称:tg-qq-trans,代码行数:17,代码来源:GetQQPic.java

示例10: getLocationFromIni

import org.ini4j.Ini; //导入方法依赖的package包/类
public static String getLocationFromIni( String iniLocation )
	throws IOException
{
	// Format: "/Section/Key:URL_to_ini"
	String[] ss = iniLocation.split( ":", 2 );
	assertIOException( ss.length < 2, "invalid ini location; the format is /Section/Key:URL_to_ini" );
	
	String[] iniPath = ss[0].split( "/", 3 );
	assertIOException( iniPath.length < 3, "path to ini content is not well-formed; the format is /Section/Key" );
	
	URL iniURL = new URL( ss[1] );
	Ini ini = new Ini( new InputStreamReader( iniURL.openStream() ) );
	
	Ini.Section section = ini.get( iniPath[1] );
	assertIOException( section == null, "could not find section " + iniPath[1] + " in ini" );
	
	String retLocation = section.get( iniPath[2] );
	assertIOException( retLocation == null, "could not find key " + iniPath[2] + " in section " + iniPath[1] + " in ini" );
	
	return retLocation;
}
 
开发者ID:jolie,项目名称:jolie,代码行数:22,代码来源:AutoHelper.java

示例11: parseInibinKeys

import org.ini4j.Ini; //导入方法依赖的package包/类
private static Map<Integer, String> parseInibinKeys(Ini.Section section) {
	Map<Integer, String> outMap = new HashMap<>();

	if(section == null) {
		return outMap;
	}

	for(final String s : section.keySet()) {
		int key;

		try {
			key = Integer.parseInt(section.get(s));
		} catch(NumberFormatException e) {
			// Invalid key, skip.
			continue;
		}

		outMap.put(key, s);
	}
	return outMap;
}
 
开发者ID:vs49688,项目名称:RAFTools,代码行数:22,代码来源:Controller.java

示例12: createUserConfFile

import org.ini4j.Ini; //导入方法依赖的package包/类
private void createUserConfFile(Ca ca,
		Map<String, String> subjAlt) throws Exception {
	
	File f = new File(ca.getUserConfFileName());
	Ini confFile = new Ini(f);
	Ini.Section sect;
	sect = confFile.get("v3_req");
		sect.put("basicConstraints", "CA:FALSE");
		sect.put("keyUsage", "cRLSign, digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign");
		sect.put("subjectKeyIdentifier", "hash");
		sect.put("certificatePolicies", "@polsection");
	sect = confFile.get("v3_ca"); 
		sect.put("basicConstraints", "critical,CA:FALSE");
		sect.put("keyUsage", "digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign");
		sect.put("authorityKeyIdentifier", "keyid,issuer:always");
		sect.put("certificatePolicies", "@polsection");
		sect.put("subjectAltName", "@subject_alt_section");
	sect = confFile.get("subject_alt_section");
		sect.clear();
		for (String key : subjAlt.keySet()) {
			sect.put(key, subjAlt.get(key));
		}
	confFile.store();
}
 
开发者ID:robsonsmartins,项目名称:fiap-mba-java-projects,代码行数:25,代码来源:IcpBrasilDAO.java

示例13: createCaConfFile

import org.ini4j.Ini; //导入方法依赖的package包/类
@Override
protected void createCaConfFile(Ca rootCa, Ca ca, String crlURI,
		String cpsURI, String subject) throws Exception {
	
	super.createCaConfFile(rootCa, ca, crlURI, cpsURI, subject);
	File f = new File(ca.getConfFileName());
	Ini confFile = new Ini(f);
	Ini.Section sect;
	sect = confFile.get("v3_req");
		sect.put("certificatePolicies", "@polsection1, @polsection2");
	sect = confFile.get("v3_ca");
		sect.put("authorityKeyIdentifier", "keyid,issuer:always");
		sect.put("certificatePolicies", "@polsection1, @polsection2");
	sect = confFile.add("polsection1"); 
		sect.put("policyIdentifier", cpsCaA1);
		sect.put("CPS.1", "\"" + cpsURI + "\"");
	sect = confFile.add("polsection2"); 
		sect.put("policyIdentifier", cpsCaA3);
		sect.put("CPS.1", "\"" + cpsURI + "\"");
	confFile.store();
}
 
开发者ID:robsonsmartins,项目名称:fiap-mba-java-projects,代码行数:22,代码来源:CaDAO.java

示例14: MyConfig

import org.ini4j.Ini; //导入方法依赖的package包/类
MyConfig() throws IOException {
    System.out.println("Parsing config.ini");

    org.ini4j.Config.getGlobal().setEscape(false);
    Ini ini = new Ini();
    ini.load(new FileReader("config.ini"));

    Ini.Section section = ini.get("paths");
    //TODO check if these are valid directories
    this._inputRoot = this.getIniValue(section, "input dir") + File.separator;
    this._outputRoot = this.getIniValue(section, "output dir") + File.separator;
    this._imPath = this.getIniValue(section, "imagemagick dir") + File.separator;

    section = ini.get("surface map");
    this.minZoomSurface = Integer.parseInt(this.getIniValue(section, "min zoom"));
    this.maxZoomSurface = Integer.parseInt(this.getIniValue(section, "max zoom"));
    this.defZoomSurface = Integer.parseInt(this.getIniValue(section, "default zoom"));
    
    section = ini.get("underground map");
    this.minZoomUnderground = Integer.parseInt(this.getIniValue(section, "min zoom"));
    this.maxZoomUnderground = Integer.parseInt(this.getIniValue(section, "max zoom"));
    this.defZoomUnderground = Integer.parseInt(this.getIniValue(section, "default zoom"));
    
    ini.clear();
}
 
开发者ID:diggu,项目名称:wu2gmap,代码行数:26,代码来源:MyConfig.java

示例15: testWithEmptyOption

import org.ini4j.Ini; //导入方法依赖的package包/类
@Test public void testWithEmptyOption() throws Exception
{
    Config cfg = new Config();

    cfg.setEmptyOption(true);
    Ini ini = new Ini();
    Ini.Section sec = ini.add(Dwarfs.PROP_BASHFUL);

    sec.put(Dwarf.PROP_FORTUNE_NUMBER, null);
    ini.setConfig(cfg);
    IniHandler handler = EasyMock.createMock(IniHandler.class);

    handler.startIni();
    handler.startSection(Dwarfs.PROP_BASHFUL);
    handler.handleOption(Dwarf.PROP_FORTUNE_NUMBER, "");
    handler.endSection();
    handler.endIni();
    EasyMock.replay(handler);
    verify(ini, handler);
}
 
开发者ID:qxo,项目名称:ini4j,代码行数:21,代码来源:IniFormatterTest.java


注:本文中的org.ini4j.Ini.Section方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。