Package javax.xml.stream.events

Examples of javax.xml.stream.events.Comment


                getContentHandler().characters(characters.getData().toCharArray(), 0, characters.getData().length());
                break;
            }
            case XMLEvent.COMMENT: {
                if(null != lexicalHandler) {
                    Comment comment = (Comment)xmlEvent;
                    lexicalHandler.comment(comment.getText().toCharArray(), 0, comment.getText().length());
                }
                break;
            }
            case XMLEvent.DTD: {
                break;
View Full Code Here


    /* (non-Javadoc)
     * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
     */
    @Override
    public void comment(char[] ch, int start, int length) throws SAXException {
        final Comment event = eventFactory.createComment(new String(ch, start, length));
        try {
            this.consumeEvent(event);
        }
        catch (XMLStreamException ex) {
            throw new SAXException("Could not create Comment: " + ex.getMessage(), ex);
View Full Code Here

    if (o == null)
      return false;
    if (this == o)
      return true;

    Comment comment = (Comment) o;

    return getText().equals(comment.getText());
  }
View Full Code Here

                }
            }

            XMLEvent nextEvent = StaxParserUtil.peek(xmlEventReader);
            if (nextEvent instanceof Comment) {
                Comment commentEvent = (Comment) nextEvent;
                Node commentNode = doc.createComment(commentEvent.getText());
                commentNode = doc.importNode(commentNode, true);
                el.appendChild(commentNode);
            } else if (nextEvent.getEventType() == XMLEvent.CHARACTERS) {
                Characters characterEvent = (Characters) nextEvent;
                String trimmedData = characterEvent.getData().trim();
View Full Code Here

  }

  @Test
  public void testComment() throws XMLStreamException {
    XMLStreamReader reader = createXmlStreamReader("<!-- james -->");
    Comment comment = (Comment)eventAllocator.allocate(reader);
    verify(comment, XMLStreamConstants.COMMENT, "<!-- james -->");
    Assert.assertEquals(" james ", comment.getText());
  }
View Full Code Here

    verify(event, XMLStreamConstants.ENTITY_REFERENCE, "&foo;");
  }

  @Test
  public void testCreateComment() throws XMLStreamException {
    Comment event = factory.createComment("foo");
    verify(event, XMLStreamConstants.COMMENT, "<!--foo-->");
  }
View Full Code Here

    if (o == null)
      return false;
    if (this == o)
      return true;

    Comment comment = (Comment) o;

    return getText().equals(comment.getText());
  }
View Full Code Here

    {
        if (o == this) return true;
        if (o == null) return false;
        if (!(o instanceof Comment)) return false;

        Comment other = (Comment) o;
        return mContent.equals(other.getText());
    }
View Full Code Here

TOP

Related Classes of javax.xml.stream.events.Comment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.