1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * Copyright © 2017 Amdocs
\r
7 * * ===========================================================================
\r
8 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * * you may not use this file except in compliance with the License.
\r
10 * * You may obtain a copy of the License at
\r
12 * * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * * Unless required by applicable law or agreed to in writing, software
\r
15 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * * See the License for the specific language governing permissions and
\r
18 * * limitations under the License.
\r
19 * * ============LICENSE_END====================================================
\r
21 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 ******************************************************************************/
\r
24 package com.att.cadi.wsse;
\r
26 import javax.xml.namespace.QName;
\r
27 import javax.xml.stream.events.XMLEvent;
\r
32 * This mechanism mimics a minimal portion of StAX "XMLEvent", enough to work with minimal XReader.
\r
34 * We implement the same interface, as much as minimally necessary, as XMLEvent for these small usages so as to
\r
35 * be interchangeable in the future, if so desired
\r
39 // @SuppressWarnings("restriction")
\r
40 public abstract class XEvent {
\r
42 public abstract int getEventType();
\r
44 public StartElement asStartElement() {
\r
45 return (StartElement)this;
\r
48 public Characters asCharacters() {
\r
49 return (Characters)this;
\r
52 public EndElement asEndElement() {
\r
53 return (EndElement)this;
\r
56 public static abstract class NamedXEvent extends XEvent {
\r
57 private QName qname;
\r
59 public NamedXEvent(QName qname) {
\r
63 public QName getName() {
\r
67 public static class StartElement extends NamedXEvent {
\r
69 public StartElement(String ns, String tag) {
\r
70 super(new QName(ns,tag));
\r
74 public int getEventType() {
\r
75 return XMLEvent.START_ELEMENT;
\r
79 public static class EndElement extends NamedXEvent {
\r
80 public EndElement(String ns, String tag) {
\r
81 super(new QName(ns,tag));
\r
85 public int getEventType() {
\r
86 return XMLEvent.END_ELEMENT;
\r
90 public static class Characters extends XEvent {
\r
91 private String data;
\r
93 public Characters(String data) {
\r
97 public int getEventType() {
\r
98 return XMLEvent.CHARACTERS;
\r
101 public String getData() {
\r
106 public static class StartDocument extends XEvent {
\r
109 public int getEventType() {
\r
110 return XMLEvent.START_DOCUMENT;
\r
115 public static class EndDocument extends XEvent {
\r
118 public int getEventType() {
\r
119 return XMLEvent.END_DOCUMENT;
\r
123 public static class Comment extends XEvent {
\r
124 public final String value;
\r
125 public Comment(String value) {
\r
126 this.value = value;
\r
130 public int getEventType() {
\r
131 return XMLEvent.COMMENT;
\r