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