1 /* Copyright 2004 BEA Systems, Inc.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package com.bea.xml.stream.events;
16 import javax.xml.stream.events.XMLEvent;
17 import javax.xml.stream.events.Comment;
18 public class CommentEvent
19 extends CharactersEvent
20 implements Comment
21 {
22 public CommentEvent() {init();}
23 public CommentEvent(String data) {
24 init();
25 setData(data);
26 }
27
28 protected void init() {setEventType(XMLEvent.COMMENT); }
29 public String getText() {
30 return getData();
31 }
32 public String toString() {
33 if (getText().length() ==0) return "<!---->";
34 else
35 return ("<!--"+getText()+"-->");
36 }
37
38 }