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

Java Comment类代码示例

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

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



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

示例1: removeComments

import org.dom4j.Comment; //导入依赖的package包/类
/**
 * Remove comments from XML
 *
 * @param document
 * @throws IOException
 * @throws DocumentException
 */
private static void removeComments(Document document) throws IOException, DocumentException {
    Visitor visitor = new VisitorSupport() {

        @Override
        public void visit(Comment comment) {
            comment.setText(" ");
        }
    };
    document.accept(visitor);
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:18,代码来源:ManifestFileUtils.java


示例2: assertNodesEqual

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


示例3: print

import org.dom4j.Comment; //导入依赖的package包/类
/**
 * Print the given element using the given print writer and initial 
 * indention
 * @param elem		the xml element
 * @param indention	the initial indention
 * @param writer	the print writer to use for the output
 */
@SuppressWarnings("unchecked")
public void print(Element elem, String indention, PrintWriter writer) {
	writer.print(indention + "<" + elem.getName());
	
	Iterator<Attribute> itAtt	= elem.attributeIterator();
	Iterator<Element>	itElem	= elem.elementIterator();

	if (elem.hasMixedContent() || (elem.hasContent() && !itElem.hasNext())) {
		Iterator<Node> it = elem.nodeIterator();
		while (it.hasNext()) {
			Node node = it.next();
			if (node instanceof CharacterData) {					
				if (!(node instanceof Comment) && node.getText().trim().length() != 0) {
					throw new IllegalArgumentException("text content not supported: \"" + node.getText() + "\"");						
				}
			}
			else if (!(node instanceof Element || node instanceof Attribute)) {
				throw new IllegalArgumentException("only attributes and elements are supported");					
			}
		}
	}
	while (itAtt.hasNext()) {
		Attribute att = itAtt.next();
		final String attName 	= att.getName();
		final String attValue	= att.getValue();
		writer.print(" " + attName + "=\"" + escapeAttributeValue(attValue) + "\"");
	}
	if (!itElem.hasNext()) {
		writer.println("/>");
	}
	else {
		writer.println(">");
		while (itElem.hasNext()) {
			print(itElem.next(), indention + getIndention(), writer);
		}
		writer.println(indention + "</" + elem.getName() + ">");			
	}
	writer.flush();
}
 
开发者ID:mpgerstl,项目名称:tEFMA,代码行数:47,代码来源:XmlPrint.java


示例4: add

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


示例5: remove

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


示例6: writeElement

import org.dom4j.Comment; //导入依赖的package包/类
protected void writeElement(Element element) throws IOException {
    int size = element.nodeCount();
    String qualifiedName = element.getQualifiedName();

    writePrintln();
    indent();

    writer.write("<");
    writer.write(qualifiedName);

    boolean textOnly = true;

    for (int i = 0; i < size; i++) {
        Node node = element.node(i);
        if (node instanceof Element) {
            textOnly = false;
        } else if (node instanceof Comment) {
            textOnly = false;
        }
    }

    writeAttributes(element);

    lastOutputNodeType = Node.ELEMENT_NODE;

    if (size <= 0) {
        writeEmptyElementClose(qualifiedName);
    } else {
        writer.write(">");

        if (textOnly) {
            // we have at least one text node so lets assume
            // that its non-empty
            writeElementContent(element);
        } else {
        	if (element.attributeCount() > 3)
        		writePrintln();
            // we know it's not null or empty from above
            ++indentLevel;

            writeElementContent(element);

            --indentLevel;

            writePrintln();
            indent();
        }

        writer.write("</");
        writer.write(qualifiedName);
        writer.write(">");
    }
   	if (element.attributeCount() > 2 && indentLevel > 0)
   		writePrintln();

    lastOutputNodeType = Node.ELEMENT_NODE;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:58,代码来源:LowercaseTableNames.java


示例7: add

import org.dom4j.Comment; //导入依赖的package包/类
public void add(Comment comment) {
	getWrapped().add(comment);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:4,代码来源:VersionedDocument.java


示例8: remove

import org.dom4j.Comment; //导入依赖的package包/类
public boolean remove(Comment comment) {
	return getWrapped().remove(comment);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:4,代码来源:VersionedDocument.java


示例9: writeElement

import org.dom4j.Comment; //导入依赖的package包/类
protected void writeElement(Element element) throws IOException {
	int size = element.nodeCount();
	String qualifiedName = element.getQualifiedName();

	writePrintln();
	indent();

	writer.write("<");
	writer.write(qualifiedName);

	int previouslyDeclaredNamespaces = namespaceStack.size();
	Namespace ns = element.getNamespace();

	if (isNamespaceDeclaration(ns)) {
		namespaceStack.push(ns);
		writeNamespace(ns);
	}

	// Print out additional namespace declarations
	boolean textOnly = true;

	for (int i = 0; i < size; i++) {
		Node node = element.node(i);

		if (node instanceof Namespace) {
			Namespace additional = (Namespace) node;

			if (isNamespaceDeclaration(additional)) {
				namespaceStack.push(additional);
				writeNamespace(additional);
			}
		} else if (node instanceof Element) {
			textOnly = false;
		} else if (node instanceof Comment) {
			textOnly = false;
		}
	}

	writeAttributes(element);

	lastOutputNodeType = Node.ELEMENT_NODE;

	if (size <= 0) {
		writeEmptyElementClose(qualifiedName);
	} else {
		writer.write(">");

		if (textOnly) {
			// we have at least one text node so lets assume
			// that its non-empty
			writeElementContent(element);
		} else {
			// we know it's not null or empty from above
			++indentLevel;

			writeElementContent(element);

			--indentLevel;

			writePrintln();
			indent();
		}

		writer.write("</");
		writer.write(qualifiedName);
		writer.write(">");
	}

	// remove declared namespaceStack from stack
	while (namespaceStack.size() > previouslyDeclaredNamespaces) {
		namespaceStack.pop();
	}

	lastOutputNodeType = Node.ELEMENT_NODE;
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:76,代码来源:XMLAttibuteFormatWriter.java


示例10: add

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


示例11: remove

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


示例12: isComment

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


示例13: getCommentStringValue

import org.dom4j.Comment; //导入依赖的package包/类
public String getCommentStringValue(Object obj)
{
    Comment cmt = (Comment) obj;

    return cmt.getText();
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:7,代码来源:DocumentNavigator.java


示例14: write

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

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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