Java 类javax.xml.stream.events.Comment 实例源码

项目:xmlsec-gost    文件:XMLSecurityStreamReader.java   
@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");
    }
}
项目:xmlsec-gost    文件:XMLSecurityStreamReader.java   
@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");
    }
}
项目:xmlsec-gost    文件:XMLSecurityStreamReader.java   
@Override
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException {
    XMLSecEvent xmlSecEvent = getCurrentEvent();
    switch (xmlSecEvent.getEventType()) {
        case ENTITY_REFERENCE:
            ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText().getChars(sourceStart, sourceStart + length, target, targetStart);
            return length;
        case DTD:
            ((DTD) xmlSecEvent).getDocumentTypeDeclaration().getChars(sourceStart, sourceStart + length, target, targetStart);
            return length;
        case COMMENT:
            ((Comment) xmlSecEvent).getText().getChars(sourceStart, sourceStart + length, target, targetStart);
            return length;
        case CDATA:
        case SPACE:
        case CHARACTERS:
            xmlSecEvent.asCharacters().getData().getChars(sourceStart, sourceStart + length, target, targetStart);
            return length;
        default:
            throw new IllegalStateException("Current state not TEXT");
    }
}
项目:xmlsec-gost    文件:XMLSecurityStreamReader.java   
@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");
    }
}
项目:spring4-understanding    文件:XMLEventStreamReader.java   
@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();
    }
}
项目:spring    文件:XMLEventStreamReader.java   
@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();
    }
}
项目:bagri    文件:XmlStaxParser.java   
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;
        }
    }
}
项目:class-guard    文件:XMLEventStreamReader.java   
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();
    }
}
项目:openjdk-jdk10    文件:Issue41Test.java   
@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());
    }

}
项目:openjdk-jdk10    文件:XMLEventFactoryWrapper.java   
@Override
public Comment createComment(String text) {
    return defaultImpl.createComment(text);
}
项目:openjdk-jdk10    文件:XMLEventFactoryImpl.java   
@Override
public Comment createComment(String text) {
    return null;
}
项目:openjdk9    文件:Issue41Test.java   
@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());
    }

}
项目:openjdk9    文件:XMLEventFactoryImpl.java   
@Override
public Comment createComment(String text) {
    return null;
}
项目:spring4-understanding    文件:StaxEventXMLReader.java   
@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();
    }

}
项目:spring4-understanding    文件:StaxEventXMLReader.java   
private void handleComment(Comment comment) throws SAXException {
    if (getLexicalHandler() != null) {
        char[] ch = comment.getText().toCharArray();
        getLexicalHandler().comment(ch, 0, ch.length);
    }
}
项目:spring    文件:StaxEventXMLReader.java   
@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();
    }

}
项目:spring    文件:StaxEventXMLReader.java   
private void handleComment(Comment comment) throws SAXException {
    if (getLexicalHandler() != null) {
        char[] ch = comment.getText().toCharArray();
        getLexicalHandler().comment(ch, 0, ch.length);
    }
}
项目:javify    文件:XMLEventWriterImpl.java   
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;
    }
}
项目:javify    文件:XMLEventFactoryImpl.java   
public Comment createComment(String text)
{
  return new CommentImpl(location, text);
}
项目:jvm-stm    文件:XMLEventWriterImpl.java   
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;
    }
}
项目:jvm-stm    文件:XMLEventFactoryImpl.java   
public Comment createComment(String text)
{
  return new CommentImpl(location, text);
}
项目:class-guard    文件:StaxEventXMLReader.java   
@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();
    }

}
项目:class-guard    文件:StaxEventXMLReader.java   
private void handleComment(Comment comment) throws SAXException {
    if (getLexicalHandler() != null) {
        char[] ch = comment.getText().toCharArray();
        getLexicalHandler().comment(ch, 0, ch.length);
    }
}
项目:werval    文件:XMLEventFactoryImpl.java   
@Override
public Comment createComment( String text )
{
    return delegate.createComment( text );
}
项目:JamVM-PH    文件:XMLEventWriterImpl.java   
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;
    }
}
项目:JamVM-PH    文件:XMLEventFactoryImpl.java   
public Comment createComment(String text)
{
  return new CommentImpl(location, text);
}
项目:SplitCharater    文件:XMLEventFactoryImpl.java   
public Comment createComment(String text) {
    return new CommentImpl(text, fLocation);
}
项目:SplitCharater    文件:StAXEventResultBuilder.java   
public void comment(Comment event) throws XMLStreamException {
    fEventWriter.add(event);
}
项目:SplitCharater    文件:StAXStreamResultBuilder.java   
public void comment(Comment event) throws XMLStreamException {
    fStreamWriter.writeComment(event.getText());
}
项目:classpath    文件:XMLEventWriterImpl.java   
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;
    }
}
项目:classpath    文件:XMLEventFactoryImpl.java   
public Comment createComment(String text)
{
  return new CommentImpl(location, text);
}
项目:scaleDOM    文件:LoadProcess.java   
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();
}
项目:javify    文件:XMLEventFactory.java   
/**
 * Create a comment event.
 */
public abstract Comment createComment(String text);
项目:jvm-stm    文件:XMLEventFactory.java   
/**
 * Create a comment event.
 */
public abstract Comment createComment(String text);
项目:JamVM-PH    文件:XMLEventFactory.java   
/**
 * Create a comment event.
 */
public abstract Comment createComment(String text);
项目:classpath    文件:XMLEventFactory.java   
/**
 * Create a comment event.
 */
public abstract Comment createComment(String text);
项目:SplitCharater    文件:StAXDocumentHandler.java   
public void comment(Comment event) throws XMLStreamException;