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


Java NamespaceSupport.popContext方法代码示例

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


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

示例1: testPopContext

import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@Test
public void testPopContext() {
    String[] parts = new String[3];
    NamespaceSupport nssupport = new NamespaceSupport();

    nssupport.pushContext();
    nssupport.declarePrefix("dc", "http://www.purl.org/dc");
    Assert.assertEquals(nssupport.getPrefix("http://www.purl.org/dc"), "dc");

    nssupport.popContext();
    Assert.assertNull(nssupport.getPrefix("http://www.purl.org/dc"));
    nssupport.processName("dc:name1", parts, false);
    Assert.assertNull(parts[0]);
    Assert.assertNull(parts[1]);
    Assert.assertNull(parts[2]);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:NSSupportTest.java

示例2: testcase01

import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
 * Test for NamespaceSupport.getDeclaredPrefixes().
 */
@Test
public void testcase01() {
    String[] prefixes = new String[2];
    NamespaceSupport support = new NamespaceSupport();
    support.pushContext();
    support.declarePrefix(EMPTY_PREFIX, W3_URI);
    support.declarePrefix(DC_PREFIX, PURL_URI);

    Enumeration e = support.getDeclaredPrefixes();
    int i = 0;
    while(e.hasMoreElements()) {
        prefixes[i++] = e.nextElement().toString();
    }
    support.popContext();

    assertEquals(prefixes, new String[]{EMPTY_PREFIX, DC_PREFIX});
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:NSSupportTest.java

示例3: testcase02

import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
 * Test for NamespaceSupport.getDeclaredPrefixes() and support.processName().
 */
@Test
public void testcase02() {
    String[] parts = new String[3];
    NamespaceSupport support = new NamespaceSupport();

    support.pushContext();
    support.declarePrefix(DC_PREFIX, PURL_URI);
    parts = support.processName("dc:title", parts, false);
    support.popContext();
    assertEquals(parts, new String[]{PURL_URI, "title", "dc:title"});
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:NSSupportTest.java

示例4: testcase03

import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
 * Test for NamespaceSupport.getDeclaredPrefixes() and support.processName().
 */
@Test
public void testcase03() {
    String[] parts = new String[3];
    NamespaceSupport support = new NamespaceSupport();
    support.pushContext();
    support.declarePrefix(EMPTY_PREFIX, W3_URI);
    parts = support.processName("a", parts, false);
    support.popContext();
    assertEquals(parts, new String[]{W3_URI, "a", "a"});
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:NSSupportTest.java

示例5: testcase04

import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
 * Test for NamespaceSupport.popContext().
 */
@Test
public void testcase04() {
    NamespaceSupport support = new NamespaceSupport();

    support.pushContext();
    support.declarePrefix(EMPTY_PREFIX, W3_URI);
    support.declarePrefix(DC_PREFIX, PURL_URI);

    assertEquals(support.getURI(EMPTY_PREFIX), W3_URI);
    assertEquals(support.getURI(DC_PREFIX), PURL_URI);
    support.popContext();
    assertNull(support.getURI(EMPTY_PREFIX));
    assertNull(support.getURI(DC_PREFIX));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:NSSupportTest.java

示例6: testConstructor

import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@TestTargets ({
    @TestTargetNew(
            level = TestLevel.COMPLETE,
            notes = "Checks that a new NamespaceSupport object contains a " +
            "default context with two predefined prefixes.",
            method = "NamespaceSupport",
            args = {}
    ),
    @TestTargetNew(
            level = TestLevel.PARTIAL_COMPLETE,
            method = "popContext",
            args = {}
    )
})
public void testConstructor() {
    String prefix;
    boolean xmlPrefixExists = false;

    ns = new NamespaceSupport();
    Enumeration<String> prefixes = ns.getDeclaredPrefixes();

    while (prefixes.hasMoreElements()) {
        prefix = prefixes.nextElement();
        if (prefix.equals("xml")) xmlPrefixExists = true;
    }

    assertTrue("Test 1: xml prefix does not exist.", xmlPrefixExists);

    // Check that only one context has been created by the constructor.
    try {
        ns.popContext();
        fail("Test 2: EmptyStackException expected.");
    } catch (EmptyStackException e) {
        // Expected.
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:38,代码来源:NamespaceSupportTest.java

示例7: testPush_PopContext

import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@TestTargets ({
    @TestTargetNew(
            level = TestLevel.COMPLETE,
            method = "pushContext",
            args = {}
    ),
    @TestTargetNew(
            level = TestLevel.PARTIAL_COMPLETE,
            method = "popContext",
            args = {}
    )
})
public void testPush_PopContext() {
    int count;

    ns = new NamespaceSupport();
    count = countPrefixes();

    ns.pushContext();
    ns.declarePrefix("dc", "http://www.purl.org/dc#");
    assertEquals("Test 1: Incorrect prefix count;",
            count + 1, countPrefixes());

    ns.popContext();
    assertEquals("Test 2: Incorrect prefix count;",
            count, countPrefixes());

    // Check that only one context has been created by pushContext().
    try {
        ns.popContext();
        fail("Test 3: EmptyStackException expected.");
    } catch (EmptyStackException e) {
        // Expected.
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:36,代码来源:NamespaceSupportTest.java

示例8: testReset

import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@TestTargets ({
    @TestTargetNew(
            level = TestLevel.COMPLETE,
            method = "reset",
            args = {}
    ),
    @TestTargetNew(
            level = TestLevel.PARTIAL_COMPLETE,
            method = "popContext",
            args = {}
    )
})
public void testReset() {
    int count;

    ns = new NamespaceSupport();
    count = countPrefixes();

    ns.pushContext();
    ns.declarePrefix("dc", "http://www.purl.org/dc#");

    assertEquals("Test 1: Incorrect prefix count;",
            count + 1, countPrefixes());

    ns.reset();
    assertEquals("Test 2: Incorrect prefix count;",
            count, countPrefixes());

    // Check that only one context has been created by reset().
    try {
        ns.popContext();
        fail("Test 3: EmptyStackException expected.");
    } catch (EmptyStackException e) {
        // Expected.
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:37,代码来源:NamespaceSupportTest.java


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