org.xml.sax.ext.Attributes2Impl源码实例Demo

类org.xml.sax.ext.Attributes2Impl源码实例Demo

下面列出了org.xml.sax.ext.Attributes2Impl 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk9   文件: Attributes2ImplTest.java
@Test
public void test03() {
    System.out.println("===in test03()===");
    Attributes2Impl impl1 = new Attributes2Impl();
    impl1.addAttribute("http://www.cars.com/xml", "attr1", "Qname1", "type", "value");
    impl1.addAttribute("http://www.cars.com/xml", "attr2", "Qname2", "type", "value");
    impl1.addAttribute("http://www.cars.com/xml", "attr3", "Qname3", "type", "value");

    Attributes2Impl impl2 = new Attributes2Impl(impl1);

    Attributes2Impl impl3 = new Attributes2Impl();
    impl3.setAttributes(impl1);

    Assert.assertTrue(impl1.getQName(0).equals(impl2.getQName(0)));
    Assert.assertTrue(impl1.getQName(0).equals(impl3.getQName(0)));

    Assert.assertTrue(impl1.getQName(1).equals(impl2.getQName(1)));
    Assert.assertTrue(impl1.getQName(1).equals(impl3.getQName(1)));

    Assert.assertTrue(impl1.getQName(2).equals(impl2.getQName(2)));
    Assert.assertTrue(impl1.getQName(2).equals(impl3.getQName(2)));
}
 
源代码2 项目: openjdk-jdk9   文件: MyDefaultHandler2.java
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);
    if (qName.equals("toy")) {
        Attributes2Impl impl = new Attributes2Impl();
        impl.setAttributes(attributes);
        System.out.println("\ntoy id=" + impl.getValue("id"));
    } else if (qName.equals("price") || qName.equals("name")) {
        System.out.print("       " + qName + " : ");
        currentValue = new StringBuffer();
    }
}
 
源代码3 项目: sling-whiteboard   文件: HtmlSAXSupport.java
public static Attributes convert(Map<String,AttrValue> attributes) {
    Attributes2Impl response = new Attributes2Impl();
    attributes.entrySet().forEach(attr ->
        response.addAttribute("",attr.getKey(), attr.getKey(), "xsi:String", attr.getValue().toString())
    );
    return response;
}
 
源代码4 项目: mycore   文件: MCRIFSCommands.java
void addBaseAttributes(MCRFSNODES node, Attributes2Impl atts) {
    atts.clear();
    atts.addAttribute(NS_URI, ATT_SIZE, ATT_SIZE, CDATA, Long.toString(node.getSize()));
    atts.addAttribute(NS_URI, ATT_MD5, ATT_MD5, CDATA, node.getMd5());
    atts.addAttribute(NS_URI, ATT_STORAGEID, ATT_STORAGEID, CDATA, node.getStorageid());
    atts.addAttribute(NS_URI, ATT_OWNER, ATT_OWNER, CDATA, node.getOwner());
    atts.addAttribute(NS_URI, ATT_NAME, ATT_NAME, CDATA, node.getName());
    atts.addAttribute(NS_URI, ATT_IFS_ID, ATT_IFS_ID, CDATA, node.getId());
}
 
源代码5 项目: mycore   文件: MCRIFSCommands.java
@Override
public boolean checkNode(MCRFSNODES node, File localFile, Attributes2Impl atts) {
    if (localFile != null && localFile.exists()) {
        return true;
    }
    LOGGER.warn("File is missing: {}", localFile);
    addBaseAttributes(node, atts);
    return false;
}
 
源代码6 项目: sonar-flow-plugin   文件: LocationFilter.java
@Override
public void startElement(String uri, String localName,
    String qualifiedName, Attributes attributes)
    throws SAXException {

  // Add extra attribute to elements to hold location
  String location = String.valueOf(locator.getLineNumber());
  Attributes2Impl attrs = new Attributes2Impl(attributes);
  attrs.addAttribute("", "location", "location", "String", location);
  super.startElement(uri, localName, qualifiedName, attrs);
}
 
源代码7 项目: j2objc   文件: Attributes2ImplTest.java
public void testAddAttribute() {
    Attributes2Impl attrs = new Attributes2Impl();

    // Ordinary case
    attrs.addAttribute("http://yet.another.uri", "doe", "john:doe",
            "string", "abc");

    assertEquals(1, attrs.getLength());

    assertEquals("http://yet.another.uri", attrs.getURI(0));
    assertEquals("doe", attrs.getLocalName(0));
    assertEquals("john:doe", attrs.getQName(0));
    assertEquals("string", attrs.getType(0));
    assertEquals("abc", attrs.getValue(0));

    assertEquals(true, attrs.isDeclared(0));
    assertEquals(true, attrs.isSpecified(0));

    // CDATA case
    attrs.addAttribute("http://yet.another.uri", "doe", "jane:doe",
            "CDATA", "abc");

    assertEquals(2, attrs.getLength());

    assertEquals("http://yet.another.uri", attrs.getURI(1));
    assertEquals("doe", attrs.getLocalName(1));
    assertEquals("jane:doe", attrs.getQName(1));
    assertEquals("CDATA", attrs.getType(1));
    assertEquals("abc", attrs.getValue(1));

    assertEquals(false, attrs.isDeclared(1));
    assertEquals(true, attrs.isSpecified(1));
}
 
源代码8 项目: j2objc   文件: Attributes2ImplTest.java
public void testSetAttributes() {
    // Ordinary case with Attributes2Impl
    Attributes2Impl attrs = new Attributes2Impl();
    attrs.addAttribute("", "", "john", "string", "doe");

    attrs.setAttributes(empty);
    assertEquals(0, attrs.getLength());

    attrs.setAttributes(multi);
    for (int i = 0; i < multi.getLength(); i++) {
        assertEquals(multi.getURI(i), attrs.getURI(i));
        assertEquals(multi.getLocalName(i), attrs.getLocalName(i));
        assertEquals(multi.getQName(i), attrs.getQName(i));
        assertEquals(multi.getType(i), attrs.getType(i));
        assertEquals(multi.getValue(i), attrs.getValue(i));
        assertEquals(multi.isDeclared(i), attrs.isDeclared(i));
        assertEquals(multi.isSpecified(i), attrs.isSpecified(i));
    }

    attrs.setAttributes(empty);
    assertEquals(0, attrs.getLength());

    // Ordinary case with AttributesImpl
    attrs.setAttributes(new AttributesImpl(multi));
    assertEquals(multi.getLength(), attrs.getLength());

    for (int i = 0; i < multi.getLength(); i++) {
        assertEquals(multi.getURI(i), attrs.getURI(i));
        assertEquals(multi.getLocalName(i), attrs.getLocalName(i));
        assertEquals(multi.getQName(i), attrs.getQName(i));
        assertEquals(multi.getType(i), attrs.getType(i));
        assertEquals(multi.getValue(i), attrs.getValue(i));
        assertEquals(true, attrs.isDeclared(i));
        assertEquals(true, attrs.isSpecified(i));
    }

    // Special case with CDATA
    attrs.setAttributes(new AttributesImpl(cdata));
    assertEquals(1, attrs.getLength());
    assertEquals(false, attrs.isDeclared(0));
    assertEquals(true, attrs.isSpecified(0));

    // null case
    try {
        attrs.setAttributes(null);
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
        // Expected
    }
}
 
源代码9 项目: mycore   文件: MCRIFSCommands.java
public abstract boolean checkNode(MCRFSNODES node, File localFile, Attributes2Impl atts);