jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/events/EndElementEvent.java
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/events/EndElementEvent.java Thu Dec 15 09:03:36 2016 +0100
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/events/EndElementEvent.java Thu Dec 15 13:57:04 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,8 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-package com.sun.xml.internal.stream.events ;
+package com.sun.xml.internal.stream.events;
import java.util.List;
import java.util.ArrayList;
@@ -31,35 +30,33 @@
import javax.xml.namespace.QName;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.Namespace;
-import java.io.Writer;
import java.util.Iterator;
import javax.xml.stream.events.XMLEvent;
import com.sun.xml.internal.stream.util.ReadOnlyIterator;
-/** Implementation of EndElement event.
+/**
+ * Implementation of EndElement event.
*
* @author Neeraj Bajaj Sun Microsystems,Inc.
* @author K.Venugopal Sun Microsystems,Inc.
*/
+public class EndElementEvent extends DummyEvent
+ implements EndElement {
-public class EndElementEvent extends DummyEvent
-implements EndElement {
-
- List fNamespaces = null;
- QName fQName ;
+ List<Namespace> fNamespaces = null;
+ QName fQName;
public EndElementEvent() {
init();
}
- protected void init() {
+ protected final void init() {
setEventType(XMLEvent.END_ELEMENT);
- fNamespaces = new ArrayList();
+ fNamespaces = new ArrayList<>();
}
-
- public EndElementEvent(String prefix, String uri, String localpart) {
- this(new QName(uri,localpart,prefix));
+ public EndElementEvent(String prefix, String uri, String localpart) {
+ this(new QName(uri, localpart, prefix));
}
public EndElementEvent(QName qname) {
@@ -67,6 +64,7 @@
init();
}
+ @Override
public QName getName() {
return fQName;
}
@@ -75,34 +73,36 @@
this.fQName = qname;
}
+ @Override
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
- throws java.io.IOException
- {
+ throws java.io.IOException {
writer.write("</");
String prefix = fQName.getPrefix();
if (prefix != null && prefix.length() > 0) {
writer.write(prefix);
writer.write(':');
- }
+ }
writer.write(fQName.getLocalPart());
writer.write('>');
}
- /** Returns an Iterator of namespaces that have gone out
- * of scope. Returns an empty iterator if no namespaces have gone
- * out of scope.
- * @return an Iterator over Namespace interfaces, or an
- * empty iterator
+ /**
+ * Returns an Iterator of namespaces that have gone out of scope. Returns an
+ * empty iterator if no namespaces have gone out of scope.
+ *
+ * @return an Iterator over Namespace interfaces, or an empty iterator
*/
- public Iterator getNamespaces() {
- if(fNamespaces != null)
+ @Override
+ public Iterator<Namespace> getNamespaces() {
+ if (fNamespaces != null) {
fNamespaces.iterator();
- return new ReadOnlyIterator();
+ }
+ return new ReadOnlyIterator<>();
}
- void addNamespace(Namespace attr){
- if(attr != null){
- fNamespaces.add(attr);
+ void addNamespace(Namespace ns) {
+ if (ns != null) {
+ fNamespaces.add(ns);
}
}
@@ -113,12 +113,15 @@
}
public String nameAsString() {
- if("".equals(fQName.getNamespaceURI()))
+ if ("".equals(fQName.getNamespaceURI())) {
return fQName.getLocalPart();
- if(fQName.getPrefix() != null)
+ }
+
+ if (fQName.getPrefix() != null) {
return "['" + fQName.getNamespaceURI() + "']:" + fQName.getPrefix() + ":" + fQName.getLocalPart();
- else
+ } else {
return "['" + fQName.getNamespaceURI() + "']:" + fQName.getLocalPart();
+ }
}
}