• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CDATA类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: visit

import org.dom4j.CDATA; //导入依赖的package包/类
public void visit(Node node) {
	int type = node.getNodeType();
	switch (type) {
	case Node.ELEMENT_NODE:
		visit((Element) node);
		break;
	case Node.TEXT_NODE:
		visit((Text) node);
		break;

	case Node.CDATA_SECTION_NODE:
		visit((CDATA) node);
		break;

	default:

		push(null);
	}
}
 
开发者ID:jackhatedance,项目名称:visual-programming,代码行数:20,代码来源:XmlDomVisitor.java


示例2: getConfigFormSnippet

import org.dom4j.CDATA; //导入依赖的package包/类
@Override
public String getConfigFormSnippet(ConnectorManager connectorManager, String connectorType,
    String connectorName, Locale locale) {
    Element xml;

    Map<String, String> paramsMap = new HashMap<String, String>();
    paramsMap.put(ServletUtil.QUERY_PARAM_LANG, locale.getLanguage());

    if (connectorName == null) {
        // New connector
        paramsMap.put(ServletUtil.XMLTAG_CONNECTOR_TYPE, connectorType);
        xml = ConnectorManagerRequestUtils.sendGet(connectorManager, "/getConfigForm", paramsMap);
    } else {
        // Existing connector
        paramsMap.put(ServletUtil.XMLTAG_CONNECTOR_NAME, connectorName);
        xml = ConnectorManagerRequestUtils.sendGet(connectorManager, "/getConnectorConfigToEdit",
            paramsMap);
    }

    Element formSnippet = xml.element(ServletUtil.XMLTAG_CONFIGURE_RESPONSE).element(
        ServletUtil.XMLTAG_FORM_SNIPPET);
    CDATA cdata = (CDATA) formSnippet.node(0);
    String configFormSnippetText = cdata.getStringValue();

    return configFormSnippetText;
}
 
开发者ID:BassJel,项目名称:Jouve-Project,代码行数:27,代码来源:ConnectorManagerServicesImpl.java


示例3: assertNodesEqual

import org.dom4j.CDATA; //导入依赖的package包/类
public void assertNodesEqual( Node n1, Node n2 ) {
    int nodeType1 = n1.getNodeType();
    int nodeType2 = n2.getNodeType();
    assertTrue( "Nodes are of same type: ", nodeType1 == nodeType2 );
    
    switch (nodeType1) {
        case Node.ELEMENT_NODE:
            assertNodesEqual((Element) n1, (Element) n2);
            break;
        case Node.DOCUMENT_NODE:
            assertNodesEqual((Document) n1, (Document) n2);
            break;
        case Node.ATTRIBUTE_NODE:
            assertNodesEqual((Attribute) n1, (Attribute) n2);
            break;
        case Node.TEXT_NODE:
            assertNodesEqual((Text) n1, (Text) n2);
            break;
        case Node.CDATA_SECTION_NODE:
            assertNodesEqual((CDATA) n1, (CDATA) n2);
            break;
        case Node.ENTITY_REFERENCE_NODE:
            assertNodesEqual((Entity) n1, (Entity) n2);
            break;
        case Node.PROCESSING_INSTRUCTION_NODE:
            assertNodesEqual((ProcessingInstruction) n1, (ProcessingInstruction) n2);
            break;
        case Node.COMMENT_NODE:
            assertNodesEqual((Comment) n1, (Comment) n2);
            break;
        case Node.DOCUMENT_TYPE_NODE:
            assertNodesEqual((DocumentType) n1, (DocumentType) n2);
            break;
        case Node.NAMESPACE_NODE:
            assertNodesEqual((Namespace) n1, (Namespace) n2);
            break;
        default:
            assertTrue( "Invalid node types. node1: " + n1 + " and node2: " + n2, false );
    }
}
 
开发者ID:NCAR,项目名称:dls-repository-stack,代码行数:41,代码来源:AbstractTestCase.java


示例4: setInvalidFormSnippetElement

import org.dom4j.CDATA; //导入依赖的package包/类
public void setInvalidFormSnippetElement(Element formSnippetElement) {
    if (formSnippetElement != null) {
        CDATA cdata = (CDATA) formSnippetElement.node(0);
        String configFormSnippetText = cdata.getStringValue();
        this.configFormSnippetTextModel = new Model(configFormSnippetText);
    }
}
 
开发者ID:BassJel,项目名称:Jouve-Project,代码行数:8,代码来源:ConnectorInstanceConfigFormSnippet.java


示例5: add

import org.dom4j.CDATA; //导入依赖的package包/类
public void add(CDATA cdata) {
	element.add( cdata );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:ElementWrapper.java


示例6: remove

import org.dom4j.CDATA; //导入依赖的package包/类
public boolean remove(CDATA cdata) {
	return element.remove( cdata );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:ElementWrapper.java


示例7: add

import org.dom4j.CDATA; //导入依赖的package包/类
public void add(CDATA cdata) {
	target().add( cdata );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:Dom4jProxy.java


示例8: remove

import org.dom4j.CDATA; //导入依赖的package包/类
public boolean remove(CDATA cdata) {
	return target().remove( cdata );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:Dom4jProxy.java


示例9: isText

import org.dom4j.CDATA; //导入依赖的package包/类
public boolean isText(Object obj)
{
    return ( obj instanceof Text 
             ||
             obj instanceof CDATA );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:7,代码来源:DocumentNavigator.java


示例10: setProperties

import org.dom4j.CDATA; //导入依赖的package包/类
/**
 * Sets a property to an array of values. Multiple values matching the same property
 * is mapped to an XML file as multiple elements containing each value.
 * For example, using the name "foo.bar.prop", and the value string array containing
 * {"some value", "other value", "last value"} would produce the following XML:
 * <pre>
 * &lt;foo&gt;
 *     &lt;bar&gt;
 *         &lt;prop&gt;some value&lt;/prop&gt;
 *         &lt;prop&gt;other value&lt;/prop&gt;
 *         &lt;prop&gt;last value&lt;/prop&gt;
 *     &lt;/bar&gt;
 * &lt;/foo&gt;
 * </pre>
 *
 * @param name the name of the property.
 * @param values the values for the property (can be empty but not null).
 */
public void setProperties(String name, List<String> values) {
    String[] propName = parsePropertyName(name);
    // Search for this property by traversing down the XML hierarchy,
    // stopping one short.
    Element element = document.getRootElement();
    for (int i = 0; i < propName.length - 1; i++) {
        // If we don't find this part of the property in the XML hierarchy
        // we add it as a new node
        if (element.element(propName[i]) == null) {
            element.addElement(propName[i]);
        }
        element = element.element(propName[i]);
    }
    String childName = propName[propName.length - 1];
    // We found matching property, clear all children.
    List<Element> toRemove = new ArrayList<>();
    Iterator<Element> iter = element.elementIterator(childName);
    while (iter.hasNext()) {
        toRemove.add(iter.next());
    }
    for (iter = toRemove.iterator(); iter.hasNext();) {
        element.remove(iter.next());
    }
    // Add the new children.
    for (String value : values) {
        Element childElement = element.addElement(childName);
        if (value.startsWith("<![CDATA[")) {
            Iterator<Node> it = childElement.nodeIterator();
            while (it.hasNext()) {
                Node node = it.next();
                if (node instanceof CDATA) {
                    childElement.remove(node);
                    break;
                }
            }
            childElement.addCDATA(value.substring(9, value.length()-3));
        }
        else {
            String propValue = StringEscapeUtils.escapeXml(value);
            // check to see if the property is marked as encrypted
            if (JiveGlobals.isPropertyEncrypted(name)) {
                propValue = JiveGlobals.getPropertyEncryptor().encrypt(value);
                childElement.addAttribute(ENCRYPTED_ATTRIBUTE, "true");
            }
            childElement.setText(propValue);
        }
    }
    saveProperties();

    // Generate event.
    Map<String, Object> params = new HashMap<>();
    params.put("value", values);
    PropertyEventDispatcher.dispatchEvent(name,
            PropertyEventDispatcher.EventType.xml_property_set, params);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:74,代码来源:XMLProperties.java


示例11: setProperty

import org.dom4j.CDATA; //导入依赖的package包/类
/**
 * Sets the value of the specified property. If the property doesn't
 * currently exist, it will be automatically created.
 *
 * @param name  the name of the property to set.
 * @param value the new value for the property.
 */
public synchronized void setProperty(String name, String value) {
    if(!StringEscapeUtils.escapeXml(name).equals(name)) {
        throw new IllegalArgumentException("Property name cannot contain XML entities.");
    }
    if (name == null) {
        return;
    }
    if (value == null) {
        value = "";
    }

    // Set cache correctly with prop name and value.
    propertyCache.put(name, value);

    String[] propName = parsePropertyName(name);
    // Search for this property by traversing down the XML hierarchy.
    Element element = document.getRootElement();
    for (String aPropName : propName) {
        // If we don't find this part of the property in the XML hierarchy
        // we add it as a new node
        if (element.element(aPropName) == null) {
            element.addElement(aPropName);
        }
        element = element.element(aPropName);
    }
    // Set the value of the property in this node.
    if (value.startsWith("<![CDATA[")) {
        Iterator it = element.nodeIterator();
        while (it.hasNext()) {
            Node node = (Node) it.next();
            if (node instanceof CDATA) {
                element.remove(node);
                break;
            }
        }
        element.addCDATA(value.substring(9, value.length()-3));
    }
    else {
        String propValue = StringEscapeUtils.escapeXml(value);
        // check to see if the property is marked as encrypted
        if (JiveGlobals.isXMLPropertyEncrypted(name)) {
            propValue = JiveGlobals.getPropertyEncryptor().encrypt(value);
            element.addAttribute(ENCRYPTED_ATTRIBUTE, "true");
        }
        element.setText(propValue);
    }
    // Write the XML properties to disk
    saveProperties();

    // Generate event.
    Map<String, Object> params = new HashMap<>();
    params.put("value", value);
    PropertyEventDispatcher.dispatchEvent(name,
            PropertyEventDispatcher.EventType.xml_property_set, params);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:63,代码来源:XMLProperties.java


示例12: setProperties

import org.dom4j.CDATA; //导入依赖的package包/类
/**
 * Sets a property to an array of values. Multiple values matching the same property
 * is mapped to an XML file as multiple elements containing each value.
 * For example, using the name "foo.bar.prop", and the value string array containing
 * {"some value", "other value", "last value"} would produce the following XML:
 * <pre>
 * &lt;foo&gt;
 *     &lt;bar&gt;
 *         &lt;prop&gt;some value&lt;/prop&gt;
 *         &lt;prop&gt;other value&lt;/prop&gt;
 *         &lt;prop&gt;last value&lt;/prop&gt;
 *     &lt;/bar&gt;
 * &lt;/foo&gt;
 * </pre>
 *
 * @param name the name of the property.
 * @param values the values for the property (can be empty but not null).
 */
public void setProperties(String name, List<String> values) {
    String[] propName = parsePropertyName(name);
    // Search for this property by traversing down the XML heirarchy,
    // stopping one short.
    Element element = document.getRootElement();
    for (int i = 0; i < propName.length - 1; i++) {
        // If we don't find this part of the property in the XML heirarchy
        // we add it as a new node
        if (element.element(propName[i]) == null) {
            element.addElement(propName[i]);
        }
        element = element.element(propName[i]);
    }
    String childName = propName[propName.length - 1];
    // We found matching property, clear all children.
    List<Element> toRemove = new ArrayList<Element>();
    Iterator iter = element.elementIterator(childName);
    while (iter.hasNext()) {
        toRemove.add((Element) iter.next());
    }
    for (iter = toRemove.iterator(); iter.hasNext();) {
        element.remove((Element)iter.next());
    }
    // Add the new children.
    for (String value : values) {
        Element childElement = element.addElement(childName);
        if (value.startsWith("<![CDATA[")) {
            Iterator it = childElement.nodeIterator();
            while (it.hasNext()) {
                Node node = (Node) it.next();
                if (node instanceof CDATA) {
                    childElement.remove(node);
                    break;
                }
            }
            childElement.addCDATA(value.substring(9, value.length()-3));
        }
        else {
            childElement.setText(StringEscapeUtils.escapeXml(value));
        }
    }
    saveProperties();

    // Generate event.
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("value", values);
    PropertyEventDispatcher.dispatchEvent(name,
            PropertyEventDispatcher.EventType.xml_property_set, params);
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:68,代码来源:XMLProperties.java


示例13: setProperty

import org.dom4j.CDATA; //导入依赖的package包/类
/**
 * Sets the value of the specified property. If the property doesn't
 * currently exist, it will be automatically created.
 *
 * @param name  the name of the property to set.
 * @param value the new value for the property.
 */
public synchronized void setProperty(String name, String value) {
    if(!StringEscapeUtils.escapeXml(name).equals(name)) {
        throw new IllegalArgumentException("Property name cannot contain XML entities.");
    }
    if (name == null) {
        return;
    }
    if (value == null) {
        value = "";
    }

    // Set cache correctly with prop name and value.
    propertyCache.put(name, value);

    String[] propName = parsePropertyName(name);
    // Search for this property by traversing down the XML heirarchy.
    Element element = document.getRootElement();
    for (String aPropName : propName) {
        // If we don't find this part of the property in the XML heirarchy
        // we add it as a new node
        if (element.element(aPropName) == null) {
            element.addElement(aPropName);
        }
        element = element.element(aPropName);
    }
    // Set the value of the property in this node.
    if (value.startsWith("<![CDATA[")) {
        Iterator it = element.nodeIterator();
        while (it.hasNext()) {
            Node node = (Node) it.next();
            if (node instanceof CDATA) {
                element.remove(node);
                break;
            }
        }
        element.addCDATA(value.substring(9, value.length()-3));
    }
    else {
        element.setText(value);
    }
    // Write the XML properties to disk
    saveProperties();

    // Generate event.
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("value", value);
    PropertyEventDispatcher.dispatchEvent(name,
            PropertyEventDispatcher.EventType.xml_property_set, params);
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:57,代码来源:XMLProperties.java


示例14: setProperties

import org.dom4j.CDATA; //导入依赖的package包/类
/**
 * Sets a property to an array of values. Multiple values matching the same property
 * is mapped to an XML file as multiple elements containing each value.
 * For example, using the name "foo.bar.prop", and the value string array containing
 * {"some value", "other value", "last value"} would produce the following XML:
 * <pre>
 * &lt;foo&gt;
 *     &lt;bar&gt;
 *         &lt;prop&gt;some value&lt;/prop&gt;
 *         &lt;prop&gt;other value&lt;/prop&gt;
 *         &lt;prop&gt;last value&lt;/prop&gt;
 *     &lt;/bar&gt;
 * &lt;/foo&gt;
 * </pre>
 *
 * @param name the name of the property.
 * @param values the values for the property (can be empty but not null).
 */
public void setProperties(String name, List<String> values) {
    String[] propName = parsePropertyName(name);
    // Search for this property by traversing down the XML hierarchy,
    // stopping one short.
    Element element = document.getRootElement();
    for (int i = 0; i < propName.length - 1; i++) {
        // If we don't find this part of the property in the XML hierarchy
        // we add it as a new node
        if (element.element(propName[i]) == null) {
            element.addElement(propName[i]);
        }
        element = element.element(propName[i]);
    }
    String childName = propName[propName.length - 1];
    // We found matching property, clear all children.
    List<Element> toRemove = new ArrayList<Element>();
    Iterator<Element> iter = element.elementIterator(childName);
    while (iter.hasNext()) {
        toRemove.add(iter.next());
    }
    for (iter = toRemove.iterator(); iter.hasNext();) {
        element.remove((Element)iter.next());
    }
    // Add the new children.
    for (String value : values) {
        Element childElement = element.addElement(childName);
        if (value.startsWith("<![CDATA[")) {
            Iterator<Node> it = childElement.nodeIterator();
            while (it.hasNext()) {
                Node node = it.next();
                if (node instanceof CDATA) {
                    childElement.remove(node);
                    break;
                }
            }
            childElement.addCDATA(value.substring(9, value.length()-3));
        }
        else {
        	String propValue = StringEscapeUtils.escapeXml(value);
        	// check to see if the property is marked as encrypted
        	if (JiveGlobals.isPropertyEncrypted(name)) {
        		propValue = JiveGlobals.getPropertyEncryptor().encrypt(propValue);
        		childElement.addAttribute(ENCRYPTED_ATTRIBUTE, "true");
        	}
            childElement.setText(propValue);
        }
    }
    saveProperties();

    // Generate event.
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("value", values);
    PropertyEventDispatcher.dispatchEvent(name,
            PropertyEventDispatcher.EventType.xml_property_set, params);
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:74,代码来源:XMLProperties.java


示例15: setProperty

import org.dom4j.CDATA; //导入依赖的package包/类
/**
 * Sets the value of the specified property. If the property doesn't
 * currently exist, it will be automatically created.
 *
 * @param name  the name of the property to set.
 * @param value the new value for the property.
 */
public synchronized void setProperty(String name, String value) {
    if(!StringEscapeUtils.escapeXml(name).equals(name)) {
        throw new IllegalArgumentException("Property name cannot contain XML entities.");
    }
    if (name == null) {
        return;
    }
    if (value == null) {
        value = "";
    }

    // Set cache correctly with prop name and value.
    propertyCache.put(name, value);

    String[] propName = parsePropertyName(name);
    // Search for this property by traversing down the XML hierarchy.
    Element element = document.getRootElement();
    for (String aPropName : propName) {
        // If we don't find this part of the property in the XML hierarchy
        // we add it as a new node
        if (element.element(aPropName) == null) {
            element.addElement(aPropName);
        }
        element = element.element(aPropName);
    }
    // Set the value of the property in this node.
    if (value.startsWith("<![CDATA[")) {
        Iterator it = element.nodeIterator();
        while (it.hasNext()) {
            Node node = (Node) it.next();
            if (node instanceof CDATA) {
                element.remove(node);
                break;
            }
        }
        element.addCDATA(value.substring(9, value.length()-3));
    }
    else {
    	String propValue = StringEscapeUtils.escapeXml(value);
    	// check to see if the property is marked as encrypted
    	if (JiveGlobals.isPropertyEncrypted(name)) {
    		propValue = JiveGlobals.getPropertyEncryptor().encrypt(propValue);
    		element.addAttribute(ENCRYPTED_ATTRIBUTE, "true");
    	}
    	element.setText(propValue);
    }
    // Write the XML properties to disk
    saveProperties();

    // Generate event.
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("value", value);
    PropertyEventDispatcher.dispatchEvent(name,
            PropertyEventDispatcher.EventType.xml_property_set, params);
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:63,代码来源:XMLProperties.java


示例16: write

import org.dom4j.CDATA; //导入依赖的package包/类
/**
 * Writes the given {@link CDATA}.
 * 
 * @param cdata
 *            <code>CDATA</code> to output.
 * 
 * @throws IOException
 *             DOCUMENT ME!
 */
public void write(CDATA cdata) throws IOException {
	writeCDATA(cdata.getText());

	if (autoFlush) {
		flush();
	}
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:17,代码来源:XMLAttibuteFormatWriter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ComponentConnector类代码示例发布时间:2022-05-21
下一篇:
Java GSSCaller类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap