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


Java Config类代码示例

本文整理汇总了Java中org.ini4j.Config的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testWithEmptyOption

import org.ini4j.Config; //导入依赖的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:JetBrains,项目名称:intellij-deps-ini4j,代码行数:21,代码来源:IniFormatterTest.java

示例2: testWithStrictOperator

import org.ini4j.Config; //导入依赖的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

示例3: testEmptyOption

import org.ini4j.Config; //导入依赖的package包/类
@Test public void testEmptyOption() throws Exception
{
    OptionsParser parser = new OptionsParser();
    OptionsHandler handler = EasyMock.createMock(OptionsHandler.class);

    handler.startOptions();
    handler.handleOption(OPTION, null);
    handler.endOptions();
    EasyMock.replay(handler);
    Config cfg = new Config();

    cfg.setEmptyOption(true);
    parser.setConfig(cfg);
    parser.parse(new StringReader(CFG_EMPTY_OPTION), handler);
    EasyMock.verify(handler);
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:17,代码来源:OptionsParserTest.java

示例4: test

import org.ini4j.Config; //导入依赖的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

示例5: testWithoutInclude

import org.ini4j.Config; //导入依赖的package包/类
@Test public void testWithoutInclude() throws Exception
{
    HandlerBase handler = EasyMock.createMock(HandlerBase.class);

    handler.handleComment("-1" + NESTED);
    handler.handleComment("-2" + NESTED);
    handler.handleComment("-3" + NESTED);
    handler.handleComment("-4" + NESTED);
    EasyMock.replay(handler);
    Config cfg = new Config();

    cfg.setInclude(false);
    IniSource src = new IniSource(Helper.getResourceURL(NESTED_PATH), handler, COMMENTS, cfg);

    assertEquals("1" + NESTED, src.readLine());
    assertEquals("<include.txt>", src.readLine());
    assertEquals("2" + NESTED, src.readLine());
    assertNull(src.readLine());
    EasyMock.verify(handler);
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:21,代码来源:IniSourceTest.java

示例6: testEscape

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

    cfg.setStrictOperator(false);
    cfg.setEscape(true);
    cfg.setEscapeKeyOnly(false);
    Options opts = new Options();

    opts.setConfig(cfg);
    opts.put(ESCAPE_KEY_UNESCAPED, ESCAPE_VALUE_UNESCAPED);
    opts.put(Dwarf.PROP_WEIGHT, null);
    StringWriter writer = new StringWriter();

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

    exp.append(ESCAPE_KEY_ESCAPED);
    exp.append(" = ");
    exp.append(ESCAPE_VALUE_ESCAPED);
    exp.append(NL);
    assertEquals(exp.toString(), writer.toString());
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:24,代码来源:OptionsFormatterTest.java

示例7: testEscapeFalse

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

    cfg.setStrictOperator(false);
    cfg.setEscape(false);
    cfg.setEscapeKeyOnly(false);
    Options opts = new Options();

    opts.setConfig(cfg);
    opts.put(ESCAPE_KEY_UNESCAPED, ESCAPE_VALUE_UNESCAPED);
    opts.put(Dwarf.PROP_WEIGHT, null);
    StringWriter writer = new StringWriter();

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

    exp.append(ESCAPE_KEY_UNESCAPED);
    exp.append(" = ");
    exp.append(ESCAPE_VALUE_UNESCAPED);
    exp.append(NL);
    assertEquals(exp.toString(), writer.toString());
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:24,代码来源:OptionsFormatterTest.java

示例8: testEscapeKeyOnly

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

    cfg.setStrictOperator(false);
    cfg.setEscape(true);
    cfg.setEscapeKeyOnly(true);
    Options opts = new Options();

    opts.setConfig(cfg);
    opts.put(ESCAPE_KEY_UNESCAPED, ESCAPE_VALUE_UNESCAPED);
    opts.put(Dwarf.PROP_WEIGHT, null);
    StringWriter writer = new StringWriter();

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

    exp.append(ESCAPE_KEY_ESCAPED);
    exp.append(" = ");
    exp.append(ESCAPE_VALUE_UNESCAPED);
    exp.append(NL);
    assertEquals(exp.toString(), writer.toString());
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:24,代码来源:OptionsFormatterTest.java

示例9: testWithStrictOperatorEmptyOptions

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

    cfg.setStrictOperator(true);
    cfg.setEmptyOption(true);
    Options opts = new Options();

    opts.setConfig(cfg);
    opts.put(Dwarf.PROP_AGE, DwarfsData.bashful.age);
    opts.put(Dwarf.PROP_WEIGHT, null);
    StringWriter writer = new StringWriter();

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

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

示例10: testWithStrictOperatorEscape

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

    cfg.setStrictOperator(true);
    cfg.setEscape(true);
    cfg.setEscapeKeyOnly(false);
    Options opts = new Options();

    opts.setConfig(cfg);
    opts.put(ESCAPE_KEY_UNESCAPED, ESCAPE_VALUE_UNESCAPED);
    opts.put(Dwarf.PROP_WEIGHT, null);
    StringWriter writer = new StringWriter();

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

    exp.append(ESCAPE_KEY_ESCAPED);
    exp.append('=');
    exp.append(ESCAPE_VALUE_ESCAPED);
    exp.append(NL);
    assertEquals(exp.toString(), writer.toString());
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:24,代码来源:OptionsFormatterTest.java

示例11: testWithStrictOperatorEscapeFalse

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

    cfg.setStrictOperator(true);
    cfg.setEscape(false);
    cfg.setEscapeKeyOnly(false);
    Options opts = new Options();

    opts.setConfig(cfg);
    opts.put(ESCAPE_KEY_UNESCAPED, ESCAPE_VALUE_UNESCAPED);
    opts.put(Dwarf.PROP_WEIGHT, null);
    StringWriter writer = new StringWriter();

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

    exp.append(ESCAPE_KEY_UNESCAPED);
    exp.append('=');
    exp.append(ESCAPE_VALUE_UNESCAPED);
    exp.append(NL);
    assertEquals(exp.toString(), writer.toString());
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:24,代码来源:OptionsFormatterTest.java

示例12: testWithStrictOperatorEscapeKeyOnly

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

    cfg.setStrictOperator(true);
    cfg.setEscape(true);
    cfg.setEscapeKeyOnly(true);
    Options opts = new Options();

    opts.setConfig(cfg);
    opts.put(ESCAPE_KEY_UNESCAPED, ESCAPE_VALUE_UNESCAPED);
    opts.put(Dwarf.PROP_WEIGHT, null);
    StringWriter writer = new StringWriter();

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

    exp.append(ESCAPE_KEY_ESCAPED);
    exp.append('=');
    exp.append(ESCAPE_VALUE_UNESCAPED);
    exp.append(NL);
    assertEquals(exp.toString(), writer.toString());
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:24,代码来源:OptionsFormatterTest.java

示例13: testWithStrictOperatorNoEmptyOptions

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

    cfg.setStrictOperator(true);
    cfg.setEmptyOption(false);
    Options opts = new Options();

    opts.setConfig(cfg);
    opts.put(Dwarf.PROP_AGE, DwarfsData.bashful.age);
    opts.put(Dwarf.PROP_WEIGHT, null);
    StringWriter writer = new StringWriter();

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

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

示例14: testEmptyOption

import org.ini4j.Config; //导入依赖的package包/类
@Test public void testEmptyOption() throws Exception
{
    IniParser parser = new IniParser();
    IniHandler handler = EasyMock.createMock(IniHandler.class);

    handler.startIni();
    handler.startSection(SECTION);
    handler.handleOption(OPTION, null);
    handler.endSection();
    handler.endIni();
    EasyMock.replay(handler);
    Config cfg = new Config();

    cfg.setEmptyOption(true);
    parser.setConfig(cfg);
    parser.parse(new StringReader(CFG_EMPTY_OPTION), handler);
    EasyMock.verify(handler);
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:19,代码来源:IniParserTest.java

示例15: testGlobalSection

import org.ini4j.Config; //导入依赖的package包/类
@Test public void testGlobalSection() throws Exception
{
    IniParser parser = new IniParser();
    IniHandler handler = EasyMock.createMock(IniHandler.class);

    handler.startIni();
    handler.startSection(ANONYMOUS);
    handler.handleOption(OPTION, VALUE);
    handler.endSection();
    handler.endIni();
    EasyMock.replay(handler);
    Config cfg = new Config();

    cfg.setGlobalSection(true);
    parser.setConfig(cfg);
    parser.parse(new StringReader(CFG_GLOBAL), handler);
    EasyMock.verify(handler);
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:19,代码来源:IniParserTest.java


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