diff --git a/plugins/eclipse/src/org/jdom/output/EclipseNamespaceStack.java b/plugins/eclipse/src/org/jdom/output/EclipseNamespaceStack.java
index b320ffd83106..65f03f655867 100644
--- a/plugins/eclipse/src/org/jdom/output/EclipseNamespaceStack.java
+++ b/plugins/eclipse/src/org/jdom/output/EclipseNamespaceStack.java
@@ -57,95 +57,97 @@ package org.jdom.output;
import org.jdom.Namespace;
-import java.util.Stack;
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.Iterator;
/**
* A non-public utility class used by both {@link XMLOutputter} and
* {@link SAXOutputter} to manage namespaces in a JDOM Document
* during output.
*
+ * @author Elliotte Rusty Harolde
+ * @author Fred Trimble
+ * @author Brett McLaughlin
* @version $Revision: 1.13 $, $Date: 2004/02/06 09:28:32 $
- * @author Elliotte Rusty Harolde
- * @author Fred Trimble
- * @author Brett McLaughlin
*/
public class EclipseNamespaceStack {
+ static class NamespaceInfo {
+ final String prefix;
+ final String uri;
- /** The prefixes available */
- private final Stack prefixes;
-
- /** The URIs available */
- private final Stack uris;
-
- /**
- * This creates the needed storage.
- */
- EclipseNamespaceStack() {
- prefixes = new Stack();
- uris = new Stack();
+ NamespaceInfo(String prefix, String uri) {
+ this.prefix = prefix;
+ this.uri = uri;
}
- /**
- * This will add a new {@link Namespace}
- * to those currently available.
- *
- * @param ns Namespace to add.
- */
- public void push(Namespace ns) {
- prefixes.push(ns.getPrefix());
- uris.push(ns.getURI());
- }
-
- /**
- * This will remove the topmost (most recently added)
- * {@link Namespace}, and return its prefix.
- *
- * @return String - the popped namespace prefix.
- */
- public String pop() {
- String prefix = (String)prefixes.pop();
- uris.pop();
-
- return prefix;
- }
-
- /**
- * This returns the number of available namespaces.
- *
- * @return int - size of the namespace stack.
- */
- public int size() {
- return prefixes.size();
- }
-
- /**
- * Given a prefix, this will return the namespace URI most
- * rencently (topmost) associated with that prefix.
- *
- * @param prefix String namespace prefix.
- * @return String - the namespace URI for that prefix.
- */
- public String getURI(String prefix) {
- int index = prefixes.lastIndexOf(prefix);
- if (index == -1) {
- return null;
- }
- String uri = (String)uris.elementAt(index);
- return uri;
- }
-
- /**
- * This will print out the size and current stack, from the
- * most recently added {@link Namespace} to
- * the "oldest," all to System.out.
- */
+ @Override
public String toString() {
- StringBuilder buf = new StringBuilder();
- String sep = System.lineSeparator();
- buf.append("Stack: ").append(prefixes.size()).append(sep);
- for (int i = 0; i < prefixes.size(); i++) {
- buf.append(prefixes.elementAt(i)).append('&').append(uris.elementAt(i)).append(sep);
- }
- return buf.toString();
+ return prefix + "&" + uri;
}
+ }
+
+ private final Deque myNamespaces = new ArrayDeque<>();
+
+ /**
+ * This will add a new {@link Namespace}
+ * to those currently available.
+ *
+ * @param ns Namespace to add.
+ */
+ public void push(Namespace ns) {
+ myNamespaces.push(new NamespaceInfo(ns.getPrefix(), ns.getURI()));
+ }
+
+ /**
+ * This will remove the topmost (most recently added)
+ * {@link Namespace}, and return its prefix.
+ *
+ * @return String - the popped namespace prefix.
+ */
+ public String pop() {
+ return myNamespaces.pop().prefix;
+ }
+
+ /**
+ * This returns the number of available namespaces.
+ *
+ * @return int - size of the namespace stack.
+ */
+ public int size() {
+ return myNamespaces.size();
+ }
+
+ /**
+ * Given a prefix, this will return the namespace URI most
+ * recently (topmost) associated with that prefix.
+ *
+ * @param prefix String namespace prefix.
+ * @return String - the namespace URI for that prefix.
+ */
+ public String getURI(String prefix) {
+ Iterator iterator = myNamespaces.descendingIterator();
+ while (iterator.hasNext()) {
+ NamespaceInfo ns = iterator.next();
+ if (ns.prefix.equals(prefix)) {
+ return ns.uri;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * This will print out the size and current stack, from the
+ * most recently added {@link Namespace} to
+ * the "oldest," all to System.out.
+ */
+ public String toString() {
+ StringBuilder buf = new StringBuilder();
+ String sep = System.lineSeparator();
+ buf.append("Stack: ").append(myNamespaces.size()).append(sep);
+ for (NamespaceInfo info : myNamespaces) {
+ buf.append(info).append(sep);
+ }
+ return buf.toString();
+ }
}
diff --git a/plugins/maven/maven3-server-common/src/org/jetbrains/idea/maven/server/MavenEffectivePomDumper.java b/plugins/maven/maven3-server-common/src/org/jetbrains/idea/maven/server/MavenEffectivePomDumper.java
index 221455596c5a..432a2db711d2 100644
--- a/plugins/maven/maven3-server-common/src/org/jetbrains/idea/maven/server/MavenEffectivePomDumper.java
+++ b/plugins/maven/maven3-server-common/src/org/jetbrains/idea/maven/server/MavenEffectivePomDumper.java
@@ -34,7 +34,7 @@ public final class MavenEffectivePomDumper {
/**
* The POM XSD URL
*/
- private static final String POM_XSD_URL = "http://maven.apache.org/maven-v4_0_0.xsd";
+ private static final String POM_XSD_URL = "https://maven.apache.org/maven-v4_0_0.xsd";
/**
* The Settings XSD URL
@@ -123,7 +123,7 @@ public final class MavenEffectivePomDumper {
/**
* Copy/pasted from org.apache.maven.plugins.help.AbstractEffectiveMojo#writeHeader
*/
- protected static void writeHeader(XMLWriter writer) {
+ private static void writeHeader(XMLWriter writer) {
XmlWriterUtil.writeCommentLineBreak(writer);
XmlWriterUtil.writeComment(writer, " ");
// Use ISO8601-format for date and time
@@ -138,7 +138,7 @@ public final class MavenEffectivePomDumper {
/**
* Copy/pasted from org.apache.maven.plugins.help.AbstractEffectiveMojo
*/
- protected static void writeComment(XMLWriter writer, String comment) {
+ private static void writeComment(XMLWriter writer, String comment) {
XmlWriterUtil.writeCommentLineBreak(writer);
XmlWriterUtil.writeComment(writer, " ");
XmlWriterUtil.writeComment(writer, comment);
@@ -206,8 +206,8 @@ public final class MavenEffectivePomDumper {
}
ElementFilter elementFilter = new ElementFilter(Namespace.getNamespace(""));
- for (Iterator i = rootElement.getDescendants(elementFilter); i.hasNext(); ) {
- Element e = (Element)i.next();
+ for (Iterator i = rootElement.getDescendants(elementFilter); i.hasNext(); ) {
+ Element e = i.next();
e.setNamespace(pomNamespace);
}
@@ -242,12 +242,12 @@ public final class MavenEffectivePomDumper {
* {@inheritDoc}
*/
@Override
- public Set keySet() {
- Set keynames = super.keySet();
- Vector list = new Vector(keynames);
- Collections.sort(list);
+ public Set