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

Java Comment类代码示例

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

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



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

示例1: getText

import javax.xml.stream.events.Comment; //导入依赖的package包/类
@Override
public String getText() {
    XMLSecEvent xmlSecEvent = getCurrentEvent();

    switch (xmlSecEvent.getEventType()) {
        case ENTITY_REFERENCE:
            return ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText();
        case DTD:
            return ((DTD) xmlSecEvent).getDocumentTypeDeclaration();
        case COMMENT:
            return ((Comment) xmlSecEvent).getText();
        case CDATA:
        case SPACE:
        case CHARACTERS:
            return xmlSecEvent.asCharacters().getData();
        default:
            throw new IllegalStateException("Current state not TEXT");
    }
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:20,代码来源:XMLSecurityStreamReader.java


示例2: getTextCharacters

import javax.xml.stream.events.Comment; //导入依赖的package包/类
@Override
public char[] getTextCharacters() {
    XMLSecEvent xmlSecEvent = getCurrentEvent();
    switch (xmlSecEvent.getEventType()) {
        case ENTITY_REFERENCE:
            return ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText().toCharArray();
        case DTD:
            return ((DTD) xmlSecEvent).getDocumentTypeDeclaration().toCharArray();
        case COMMENT:
            return ((Comment) xmlSecEvent).getText().toCharArray();
        case CDATA:
        case SPACE:
        case CHARACTERS:
            return xmlSecEvent.asCharacters().getText();
        default:
            throw new IllegalStateException("Current state not TEXT");
    }
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:19,代码来源:XMLSecurityStreamReader.java


示例3: getTextLength

import javax.xml.stream.events.Comment; //导入依赖的package包/类
@Override
public int getTextLength() {
    XMLSecEvent xmlSecEvent = getCurrentEvent();
    switch (xmlSecEvent.getEventType()) {
        case ENTITY_REFERENCE:
            return ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText().length();
        case DTD:
            return ((DTD) xmlSecEvent).getDocumentTypeDeclaration().length();
        case COMMENT:
            return ((Comment) xmlSecEvent).getText().length();
        case CDATA:
        case SPACE:
        case CHARACTERS:
            return xmlSecEvent.asCharacters().getData().length();
        default:
            throw new IllegalStateException("Current state not TEXT");
    }
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:19,代码来源:XMLSecurityStreamReader.java


示例4: getText

import javax.xml.stream.events.Comment; //导入依赖的package包/类
@Override
public String getText() {
	if (this.event.isCharacters()) {
		return event.asCharacters().getData();
	}
	else if (this.event.getEventType() == XMLEvent.COMMENT) {
		return ((Comment) this.event).getText();
	}
	else {
		throw new IllegalStateException();
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:XMLEventStreamReader.java


示例5: processEvent

import javax.xml.stream.events.Comment; //导入依赖的package包/类
private void processEvent(XmlParserContext ctx, XMLEvent xmlEvent) throws BagriException {
	
	if (ctx.getDocRoot() == null) {
		ctx.firstEvents.add(xmlEvent);
		if (xmlEvent.getEventType() == XMLStreamConstants.START_ELEMENT) {
			String root = "/" + xmlEvent.asStartElement().getName();
			ctx.addDocument(root);
			for (XMLEvent event: ctx.firstEvents) {
				processEvent(ctx, event);
			}
		}
	} else {
		switch (xmlEvent.getEventType()) {
			case XMLStreamConstants.START_ELEMENT:
				startElement(ctx, xmlEvent.asStartElement());
				break;
			case XMLStreamConstants.CHARACTERS:
				if (!xmlEvent.asCharacters().isWhiteSpace()) {
					ctx.addCharacters(xmlEvent.asCharacters().getData());
				}
				break;
			case XMLStreamConstants.END_ELEMENT:
				ctx.endElement();
				break;
			case XMLStreamConstants.ATTRIBUTE:
				ctx.addAttribute(((Attribute) xmlEvent).getName(), ((Attribute) xmlEvent).getValue());
				break;
			case XMLStreamConstants.COMMENT:
				ctx.addComment(((Comment) xmlEvent).getText());
				break;
			case XMLStreamConstants.PROCESSING_INSTRUCTION:
				ctx.addProcessingInstruction(((ProcessingInstruction) xmlEvent).getTarget(), ((ProcessingInstruction) xmlEvent).getData());
				break;
			default:
				break;
		}
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:39,代码来源:XmlStaxParser.java


示例6: getText

import javax.xml.stream.events.Comment; //导入依赖的package包/类
public String getText() {
	if (this.event.isCharacters()) {
		return event.asCharacters().getData();
	}
	else if (this.event.getEventType() == XMLEvent.COMMENT) {
		return ((Comment) this.event).getText();
	}
	else {
		throw new IllegalStateException();
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:12,代码来源:XMLEventStreamReader.java


示例7: testEvents

import javax.xml.stream.events.Comment; //导入依赖的package包/类
@Test
public void testEvents() {
    XMLEventFactory f = XMLEventFactory.newInstance();
    final String contents = "test <some> text & more! [[]] --";
    final String prefix = "prefix";
    final String uri = "http://foo";
    final String localName = "elem";

    try {
        StartDocument sd = f.createStartDocument();
        writeAsEncodedUnicode(sd);

        Comment c = f.createComment("some comments");
        writeAsEncodedUnicode(c);

        StartElement se = f.createStartElement(prefix, uri, localName);

        ProcessingInstruction pi = f.createProcessingInstruction("target", "data");
        writeAsEncodedUnicode(pi);

        Namespace ns = f.createNamespace(prefix, uri);
        writeAsEncodedUnicode(ns);

        Characters characters = f.createCharacters(contents);
        writeAsEncodedUnicode(characters);
        // CData
        Characters cdata = f.createCData(contents);
        writeAsEncodedUnicode(cdata);

        // Attribute
        QName attrName = new QName("http://test.com", "attr", "ns");
        Attribute attr = f.createAttribute(attrName, "value");
        writeAsEncodedUnicode(attr);

        // prefix, uri, localName
        EndElement ee = f.createEndElement(prefix, uri, localName);
        writeAsEncodedUnicode(ee);

        EndDocument ed = f.createEndDocument();
        writeAsEncodedUnicode(ed);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:Issue41Test.java


示例8: createComment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
@Override
public Comment createComment(String text) {
    return defaultImpl.createComment(text);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:XMLEventFactoryWrapper.java


示例9: createComment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
@Override
public Comment createComment(String text) {
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:XMLEventFactoryImpl.java


示例10: parseInternal

import javax.xml.stream.events.Comment; //导入依赖的package包/类
@Override
protected void parseInternal() throws SAXException, XMLStreamException {
	boolean documentStarted = false;
	boolean documentEnded = false;
	int elementDepth = 0;
	while (this.reader.hasNext() && elementDepth >= 0) {
		XMLEvent event = this.reader.nextEvent();
		if (!event.isStartDocument() && !event.isEndDocument() && !documentStarted) {
			handleStartDocument(event);
			documentStarted = true;
		}
		switch (event.getEventType()) {
			case XMLStreamConstants.START_DOCUMENT:
				handleStartDocument(event);
				documentStarted = true;
				break;
			case XMLStreamConstants.START_ELEMENT:
				elementDepth++;
				handleStartElement(event.asStartElement());
				break;
			case XMLStreamConstants.END_ELEMENT:
				elementDepth--;
				if (elementDepth >= 0) {
					handleEndElement(event.asEndElement());
				}
				break;
			case XMLStreamConstants.PROCESSING_INSTRUCTION:
				handleProcessingInstruction((ProcessingInstruction) event);
				break;
			case XMLStreamConstants.CHARACTERS:
			case XMLStreamConstants.SPACE:
			case XMLStreamConstants.CDATA:
				handleCharacters(event.asCharacters());
				break;
			case XMLStreamConstants.END_DOCUMENT:
				handleEndDocument();
				documentEnded = true;
				break;
			case XMLStreamConstants.NOTATION_DECLARATION:
				handleNotationDeclaration((NotationDeclaration) event);
				break;
			case XMLStreamConstants.ENTITY_DECLARATION:
				handleEntityDeclaration((EntityDeclaration) event);
				break;
			case XMLStreamConstants.COMMENT:
				handleComment((Comment) event);
				break;
			case XMLStreamConstants.DTD:
				handleDtd((DTD) event);
				break;
			case XMLStreamConstants.ENTITY_REFERENCE:
				handleEntityReference((EntityReference) event);
				break;
		}
	}
	if (documentStarted && !documentEnded) {
		handleEndDocument();
	}

}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:61,代码来源:StaxEventXMLReader.java


示例11: handleComment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
private void handleComment(Comment comment) throws SAXException {
	if (getLexicalHandler() != null) {
		char[] ch = comment.getText().toCharArray();
		getLexicalHandler().comment(ch, 0, ch.length);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:StaxEventXMLReader.java


示例12: add

import javax.xml.stream.events.Comment; //导入依赖的package包/类
public void add(XMLEvent event)
  throws XMLStreamException
{
  QName name;
  String uri;
  switch (event.getEventType())
    {
    case XMLStreamConstants.START_ELEMENT:
      StartElement startElement = event.asStartElement();
      name = startElement.getName();
      uri = name.getNamespaceURI();
      if (uri != null && !"".equals(uri))
        writer.writeStartElement(name.getPrefix(), name.getLocalPart(), uri);
      else
        writer.writeStartElement(name.getLocalPart());
      break;
    case XMLStreamConstants.END_ELEMENT:
      writer.writeEndElement();
      break;
    case XMLStreamConstants.ATTRIBUTE:
      Attribute attribute = (Attribute) event;
      name = attribute.getName();
      uri = name.getNamespaceURI();
      if (uri != null && !"".equals(uri))
        writer.writeAttribute(name.getPrefix(), uri, name.getLocalPart(),
                              attribute.getValue());
      else
        writer.writeAttribute(name.getLocalPart(), attribute.getValue());
      break;
    case XMLStreamConstants.NAMESPACE:
      Namespace namespace = (Namespace) event;
      uri = namespace.getNamespaceURI();
      writer.writeNamespace(namespace.getPrefix(), uri);
      break;
    case XMLStreamConstants.PROCESSING_INSTRUCTION:
      ProcessingInstruction pi = (ProcessingInstruction) event;
      String data = pi.getData();
      if (data == null)
        writer.writeProcessingInstruction(pi.getTarget());
      else
        writer.writeProcessingInstruction(pi.getTarget(), data);
      break;
    case XMLStreamConstants.COMMENT:
      Comment comment = (Comment) event;
      writer.writeComment(comment.getText());
      break;
    case XMLStreamConstants.START_DOCUMENT:
      StartDocument startDocument = (StartDocument) event;
      writer.writeStartDocument(startDocument.getVersion());
      break;
    case XMLStreamConstants.END_DOCUMENT:
      writer.writeEndDocument();
      break;
    case XMLStreamConstants.DTD:
      DTD dtd = (DTD) event;
      writer.writeDTD(dtd.getDocumentTypeDeclaration());
      break;
    case XMLStreamConstants.CHARACTERS:
    case XMLStreamConstants.SPACE:
      Characters characters = event.asCharacters();
      writer.writeCharacters(characters.getData());
      break;
    case XMLStreamConstants.CDATA:
      Characters cdata = event.asCharacters();
      writer.writeCData(cdata.getData());
      break;
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:69,代码来源:XMLEventWriterImpl.java


示例13: createComment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
public Comment createComment(String text)
{
  return new CommentImpl(location, text);
}
 
开发者ID:vilie,项目名称:javify,代码行数:5,代码来源:XMLEventFactoryImpl.java


示例14: createComment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
@Override
public Comment createComment( String text )
{
    return delegate.createComment( text );
}
 
开发者ID:werval,项目名称:werval,代码行数:6,代码来源:XMLEventFactoryImpl.java


示例15: createComment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
public Comment createComment(String text) {
    return new CommentImpl(text, fLocation);
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:4,代码来源:XMLEventFactoryImpl.java


示例16: comment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
public void comment(Comment event) throws XMLStreamException {
    fEventWriter.add(event);
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:4,代码来源:StAXEventResultBuilder.java


示例17: comment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
public void comment(Comment event) throws XMLStreamException {
    fStreamWriter.writeComment(event.getText());
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:4,代码来源:StAXStreamResultBuilder.java


示例18: processComment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
private void processComment(final Comment comment, final NodeLocation location) {
	// Create and append Comment node
	final org.w3c.dom.Comment commentNode = doc.createComment(comment.getText());
	state.getCurrentParentNode().appendChild(commentNode);
	state.createdNode();
}
 
开发者ID:whummer,项目名称:scaleDOM,代码行数:7,代码来源:LoadProcess.java


示例19: createComment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
/**
 * Create a comment event.
 */
public abstract Comment createComment(String text);
 
开发者ID:vilie,项目名称:javify,代码行数:5,代码来源:XMLEventFactory.java


示例20: comment

import javax.xml.stream.events.Comment; //导入依赖的package包/类
public void comment(Comment event) throws XMLStreamException; 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:2,代码来源:StAXDocumentHandler.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java SubjectContext类代码示例发布时间:2022-05-21
下一篇:
Java LineNumber类代码示例发布时间: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