Java 8 CDATASection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CDATASection class.

This code example shows how to use the following methods:getNodeValue
    Element myDataElement = XmlUtil.getElementByTagName(root, "mydata");
    assertNotNull(myDataElement);
    Node childNode = myDataElement.getChildNodes().item(0);
    assertTrue(childNode instanceof CDATASection);
    CDATASection cData = (CDATASection) childNode;
    assertEquals("<>&#;", cData.getNodeValue());
  } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getNodeValue
    String nodeValue = text.getNodeValue();
    write(nodeValue.trim());
  } 
 
  private void writeCdata(CDATASection cData) throws IOException {
    String cDataText = "<![CDATA[" + cData.getNodeValue() + "]]>";
    write(cDataText);
  } 
 
  private void write(Node node, int tabs) throws IOException {
    if (node instanceof Element)
      write((Element) node, tabs);
    else if (node instanceof CDATASection)
      writeCdata((CDATASection) node);
    else if (node instanceof Text)
      writeText((Text) node);
    else 
      throw new IOException("XmlWriter: unsupported node type: " + node.getClass());
  } 
 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:substringData
        return section.getData();
    } 
 
    @Override 
    public String substringData(int offset, int count) throws DOMException {
        return section.substringData(offset,count);
    } 
 
    @Override 
    public void replaceData(int offset, int count, String arg)
            throws DOMException {
        section.replaceData(offset,count,arg);
    } 
 
    @Override 
    public void insertData(int offset, String arg) throws DOMException {
        section.insertData(offset,arg);
    } 
 
    @Override 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBaseURI
    } 
 
    public void testBaseUriNotInheritedForTextsOrCdatas() { 
        document.setDocumentURI("http://d1/d2");
        assertNull(descriptionText1.getBaseURI());
        assertNull(descriptionText2.getBaseURI());
        assertNull(option2Reference.getBaseURI());
    } 
 
    public void testBaseUriNotInheritedForComments() { 
        document.setDocumentURI("http://d1/d2");
        assertNull(descriptionText1.getBaseURI());
        assertNull(descriptionText2.getBaseURI());
    } 
 
    public void testBaseUriNotInheritedForEntityReferences() { 
        document.setDocumentURI("http://d1/d2");
        assertNull(option2Reference.getBaseURI());
    } 
 
2
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:replaceWholeText
        assertEquals(expected, domToString(document));
    } 
 
    public void testReplaceWholeTextMiddle() throws TransformerException { 
        String original = domToString(document);
        Text replacement = descriptionText2.replaceWholeText("Eggos");
        assertSame(descriptionText2, replacement);
        String expected = original.replace(
                "Belgian<![CDATA[ waffles & strawberries (< 5g ]]>of fat)", "<![CDATA[Eggos]]>"); 
        assertEquals("This implementation doesn't remove preceding nodes in replaceWholeText()",
                expected, domToString(document));
    } 
 
    public void testReplaceWholeTextLast() throws TransformerException { 
        String original = domToString(document);
        Text replacement = descriptionText3.replaceWholeText("Eggos");
        assertSame(descriptionText3, replacement);
        String expected = original.replace(
                "Belgian<![CDATA[ waffles & strawberries (< 5g ]]>of fat)", "Eggos"); 
        assertEquals("This implementation doesn't remove preceding nodes in replaceWholeText()",
2
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getData
     * @param node 
     * @param mTreeNode 
     * @throws SAXException 
     */ 
    private void initCDATASectionNode(CDATASection node, DefaultMutableTreeNode mTreeNode) throws SAXException {
        String data = node.getData();
        if (data != null && data.length() > 0) {
            String value = "<!-[CDATA" + node.getData() + "]]>"; // $NON-NLS-1$ $NON-NLS-2$
            XMLDefaultMutableTreeNode commentNode = new XMLDefaultMutableTreeNode(value, node);
            mTreeNode.add(commentNode);
        } 
    } 
 
    /** 
     * init the TextNode 
     * 
     * @param node 
     * @param mTreeNode 
     * @throws SAXException 
     */ 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getData
    } 
 
    public boolean enter(CDATASection cdata) {
        try { 
            lexical_.startCDATA();
            String data = cdata.getData();
            content_.characters(data.toCharArray(), 0, data.length());
            lexical_.endCDATA();
        } catch (SAXException e) {
            _errorReport(e);
        } 
        return (false); 
    } 
 
    public boolean enter(EntityReference entityRef) {
        try { 
            lexical_.startEntity(entityRef.getNodeName());
        } catch (SAXException e) {
            _errorReport(e);
        } 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getNodeValue
		printWriter.flush();
	} 
 
	protected void write(CDATASection node) {
		printWriter.print("<![CDATA["); //$NON-NLS-1$
		printWriter.print(node.getNodeValue());
		printWriter.print("]]>"); //$NON-NLS-1$
		printWriter.flush();
	} 
 
	protected void write(Text node) {
		normalizeAndPrint(node.getNodeValue(), false);
		printWriter.flush();
	} 
 
	protected void write(ProcessingInstruction node) {
		printWriter.print("<?"); //$NON-NLS-1$
		printWriter.print(node.getNodeName());
		String data = node.getNodeValue();
		if (data != null && data.length() > 0) {
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getNodeValue
        printWriter.flush();
    } 
 
    protected void write(CDATASection node) {
        printWriter.print("<![CDATA["); //$NON-NLS-1$
        printWriter.print(node.getNodeValue());
        printWriter.print("]]>"); //$NON-NLS-1$
        printWriter.flush();
    } 
 
    protected void write(Text node) {
        normalizeAndPrint(node.getNodeValue(), false);
        printWriter.flush();
    } 
 
    protected void write(ProcessingInstruction node) {
        printWriter.print("<?"); //$NON-NLS-1$
        printWriter.print(node.getNodeName());
        String data = node.getNodeValue();
        if (data != null && data.length() > 0) {
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:lookupNamespaceURI
        assertEquals("http://addons", name.lookupNamespaceURI("a"));
        assertEquals("http://addons", standard.lookupNamespaceURI("a"));
        assertEquals("http://addons", deluxe.lookupNamespaceURI("a"));
        assertEquals("http://addons", description.lookupNamespaceURI("a"));
        assertEquals("http://addons", descriptionText1.lookupNamespaceURI("a"));
        assertEquals("http://addons", descriptionText2.lookupNamespaceURI("a"));
        assertEquals("http://addons", descriptionText3.lookupNamespaceURI("a"));
        assertEquals("http://addons", option1.lookupNamespaceURI("a"));
        assertEquals("http://addons", option2.lookupNamespaceURI("a"));
        assertEquals("http://addons", option2Reference.lookupNamespaceURI("a"));
        assertEquals("http://addons", wafflemaker.lookupNamespaceURI("a"));
        assertEquals("http://addons", nutrition.lookupNamespaceURI("a"));
        assertEquals("http://usda", vitamins.lookupNamespaceURI("a"));
        assertEquals("http://usda", vitaminsXmlnsA.lookupNamespaceURI("a"));
        assertEquals("http://usda", comment.lookupNamespaceURI("a"));
        assertEquals("http://usda", vitaminc.lookupNamespaceURI("a"));
        assertEquals("http://usda", vitamincText.lookupNamespaceURI("a"));
    } 
 
    public void testLookupNamespaceURIWithNullPrefix() { 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 CDATASection Methods: