Wed, 27 Apr 2016 01:27:09 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17
1 /*
2 * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 *
25 * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC.
26 */
28 package com.sun.xml.internal.fastinfoset.stax.events ;
30 import java.util.ArrayList;
31 import java.util.Iterator;
32 import java.util.List;
34 import javax.xml.namespace.QName;
35 import javax.xml.stream.events.EndElement;
36 import javax.xml.stream.events.Namespace;
38 import com.sun.xml.internal.fastinfoset.stax.events.EmptyIterator;
41 public class EndElementEvent extends EventBase implements EndElement {
43 List _namespaces = null;
44 QName _qname ;
46 public void reset() {
47 if (_namespaces != null) _namespaces.clear();
48 }
50 public EndElementEvent() {
51 setEventType(END_ELEMENT);
52 }
54 public EndElementEvent(String prefix, String namespaceURI, String localpart) {
55 _qname = getQName(namespaceURI,localpart,prefix);
56 setEventType(END_ELEMENT);
57 }
59 public EndElementEvent(QName qname) {
60 _qname = qname;
61 setEventType(END_ELEMENT);
62 }
64 /**
65 * Get the name of this event
66 * @return the qualified name of this event
67 */
68 public QName getName() {
69 return _qname;
70 }
72 public void setName(QName qname) {
73 _qname = qname;
74 }
77 /** Returns an Iterator of namespaces that have gone out
78 * of scope. Returns an empty iterator if no namespaces have gone
79 * out of scope.
80 * @return an Iterator over Namespace interfaces, or an
81 * empty iterator
82 */
83 public Iterator getNamespaces() {
84 if(_namespaces != null)
85 return _namespaces.iterator();
86 return EmptyIterator.getInstance();
87 }
89 public void addNamespace(Namespace namespace){
90 if (_namespaces == null) {
91 _namespaces = new ArrayList();
92 }
93 _namespaces.add(namespace);
94 }
96 public String toString() {
97 StringBuffer sb = new StringBuffer();
98 sb.append("</").append(nameAsString());
99 Iterator namespaces = getNamespaces();
100 while(namespaces.hasNext()) {
101 sb.append(" ").append(namespaces.next().toString());
102 }
103 sb.append(">");
104 return sb.toString();
105 }
108 private String nameAsString() {
109 if("".equals(_qname.getNamespaceURI()))
110 return _qname.getLocalPart();
111 if(_qname.getPrefix() != null)
112 return "['" + _qname.getNamespaceURI() + "']:" + _qname.getPrefix() + ":" + _qname.getLocalPart();
113 else
114 return "['" + _qname.getNamespaceURI() + "']:" + _qname.getLocalPart();
115 }
116 private QName getQName(String uri, String localPart, String prefix){
117 QName qn = null;
118 if(prefix != null && uri != null)
119 qn = new QName(uri, localPart, prefix);
120 else if(prefix == null && uri != null)
121 qn = new QName(uri, localPart);
122 else if(prefix == null && uri == null)
123 qn = new QName(localPart);
124 return qn;
125 }
126 }