325N/A/*
325N/A * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A *
325N/A * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC.
325N/A */
325N/A
325N/Apackage com.sun.xml.internal.fastinfoset.stax.events ;
325N/A
325N/Aimport java.util.ArrayList;
325N/Aimport java.util.Iterator;
325N/Aimport java.util.List;
325N/A
325N/Aimport javax.xml.namespace.QName;
325N/Aimport javax.xml.stream.events.EndElement;
325N/Aimport javax.xml.stream.events.Namespace;
325N/A
325N/Aimport com.sun.xml.internal.fastinfoset.stax.events.EmptyIterator;
325N/A
325N/A
325N/Apublic class EndElementEvent extends EventBase implements EndElement {
325N/A
325N/A List _namespaces = null;
325N/A QName _qname ;
325N/A
325N/A public void reset() {
325N/A if (_namespaces != null) _namespaces.clear();
325N/A }
325N/A
325N/A public EndElementEvent() {
325N/A setEventType(END_ELEMENT);
325N/A }
325N/A
325N/A public EndElementEvent(String prefix, String namespaceURI, String localpart) {
325N/A _qname = getQName(namespaceURI,localpart,prefix);
325N/A setEventType(END_ELEMENT);
325N/A }
325N/A
325N/A public EndElementEvent(QName qname) {
325N/A _qname = qname;
325N/A setEventType(END_ELEMENT);
325N/A }
325N/A
325N/A /**
325N/A * Get the name of this event
325N/A * @return the qualified name of this event
325N/A */
325N/A public QName getName() {
325N/A return _qname;
325N/A }
325N/A
325N/A public void setName(QName qname) {
325N/A _qname = qname;
325N/A }
325N/A
325N/A
325N/A /** Returns an Iterator of namespaces that have gone out
325N/A * of scope. Returns an empty iterator if no namespaces have gone
325N/A * out of scope.
325N/A * @return an Iterator over Namespace interfaces, or an
325N/A * empty iterator
325N/A */
325N/A public Iterator getNamespaces() {
325N/A if(_namespaces != null)
325N/A return _namespaces.iterator();
325N/A return EmptyIterator.getInstance();
325N/A }
325N/A
325N/A public void addNamespace(Namespace namespace){
325N/A if (_namespaces == null) {
325N/A _namespaces = new ArrayList();
325N/A }
325N/A _namespaces.add(namespace);
325N/A }
325N/A
325N/A public String toString() {
325N/A StringBuffer sb = new StringBuffer();
325N/A sb.append("</").append(nameAsString());
325N/A Iterator namespaces = getNamespaces();
325N/A while(namespaces.hasNext()) {
325N/A sb.append(" ").append(namespaces.next().toString());
325N/A }
325N/A sb.append(">");
325N/A return sb.toString();
325N/A }
325N/A
325N/A
325N/A private String nameAsString() {
325N/A if("".equals(_qname.getNamespaceURI()))
325N/A return _qname.getLocalPart();
325N/A if(_qname.getPrefix() != null)
325N/A return "['" + _qname.getNamespaceURI() + "']:" + _qname.getPrefix() + ":" + _qname.getLocalPart();
325N/A else
325N/A return "['" + _qname.getNamespaceURI() + "']:" + _qname.getLocalPart();
325N/A }
325N/A private QName getQName(String uri, String localPart, String prefix){
325N/A QName qn = null;
325N/A if(prefix != null && uri != null)
325N/A qn = new QName(uri, localPart, prefix);
325N/A else if(prefix == null && uri != null)
325N/A qn = new QName(uri, localPart);
325N/A else if(prefix == null && uri == null)
325N/A qn = new QName(localPart);
325N/A return qn;
325N/A }
325N/A}