2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.cadi.wsse;
24 import javax.xml.namespace.QName;
25 import javax.xml.stream.events.XMLEvent;
30 * This mechanism mimics a minimal portion of StAX "XMLEvent", enough to work with minimal XReader.
32 * We implement the same interface, as much as minimally necessary, as XMLEvent for these small usages so as to
33 * be interchangeable in the future, if so desired
38 // @SuppressWarnings("restriction")
39 public abstract class XEvent {
41 public abstract int getEventType();
43 public StartElement asStartElement() {
44 return (StartElement)this;
47 public Characters asCharacters() {
48 return (Characters)this;
51 public EndElement asEndElement() {
52 return (EndElement)this;
55 public static abstract class NamedXEvent extends XEvent {
58 public NamedXEvent(QName qname) {
62 public QName getName() {
66 public static class StartElement extends NamedXEvent {
68 public StartElement(String ns, String tag) {
69 super(new QName(ns,tag));
73 public int getEventType() {
74 return XMLEvent.START_ELEMENT;
78 public static class EndElement extends NamedXEvent {
79 public EndElement(String ns, String tag) {
80 super(new QName(ns,tag));
84 public int getEventType() {
85 return XMLEvent.END_ELEMENT;
89 public static class Characters extends XEvent {
92 public Characters(String data) {
96 public int getEventType() {
97 return XMLEvent.CHARACTERS;
100 public String getData() {
105 public static class StartDocument extends XEvent {
108 public int getEventType() {
109 return XMLEvent.START_DOCUMENT;
114 public static class EndDocument extends XEvent {
117 public int getEventType() {
118 return XMLEvent.END_DOCUMENT;
122 public static class Comment extends XEvent {
123 public final String value;
124 public Comment(String value) {
129 public int getEventType() {
130 return XMLEvent.COMMENT;