Avoid using obsolete collections

GitOrigin-RevId: e861fa282c83952bf369e36652dd0e5b506c173b
This commit is contained in:
Tagir Valeev
2021-04-07 05:41:57 +00:00
committed by intellij-monorepo-bot
parent cbca352982
commit 59a29dc891
7 changed files with 94 additions and 93 deletions
@@ -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 <code>{@link XMLOutputter}</code> and
* <code>{@link SAXOutputter}</code> 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 <code>{@link Namespace}</code>
* to those currently available.
*
* @param ns <code>Namespace</code> to add.
*/
public void push(Namespace ns) {
prefixes.push(ns.getPrefix());
uris.push(ns.getURI());
}
/**
* This will remove the topmost (most recently added)
* <code>{@link Namespace}</code>, and return its prefix.
*
* @return <code>String</code> - the popped namespace prefix.
*/
public String pop() {
String prefix = (String)prefixes.pop();
uris.pop();
return prefix;
}
/**
* This returns the number of available namespaces.
*
* @return <code>int</code> - 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 <code>String</code> namespace prefix.
* @return <code>String</code> - 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 <code>{@link Namespace}</code> to
* the "oldest," all to <code>System.out</code>.
*/
@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<NamespaceInfo> myNamespaces = new ArrayDeque<>();
/**
* This will add a new <code>{@link Namespace}</code>
* to those currently available.
*
* @param ns <code>Namespace</code> to add.
*/
public void push(Namespace ns) {
myNamespaces.push(new NamespaceInfo(ns.getPrefix(), ns.getURI()));
}
/**
* This will remove the topmost (most recently added)
* <code>{@link Namespace}</code>, and return its prefix.
*
* @return <code>String</code> - the popped namespace prefix.
*/
public String pop() {
return myNamespaces.pop().prefix;
}
/**
* This returns the number of available namespaces.
*
* @return <code>int</code> - 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 <code>String</code> namespace prefix.
* @return <code>String</code> - the namespace URI for that prefix.
*/
public String getURI(String prefix) {
Iterator<NamespaceInfo> 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 <code>{@link Namespace}</code> to
* the "oldest," all to <code>System.out</code>.
*/
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();
}
}
@@ -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<Element> 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<Object> keySet() {
Set<Object> keys = super.keySet();
List<Object> list = new ArrayList<Object>(keys);
Collections.sort(list, null);
return new LinkedHashSet(list);
return new LinkedHashSet<Object>(list);
}
}
}
@@ -1,6 +1,7 @@
package org.jetbrains.idea.maven.dom;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.Stack;
import java.math.BigInteger;
import java.util.*;
@@ -6,10 +6,10 @@ import com.intellij.uiDesigner.componentTree.ComponentPtr;
import com.intellij.uiDesigner.componentTree.ComponentSelectionListener;
import com.intellij.uiDesigner.designSurface.GuiEditor;
import com.intellij.uiDesigner.radComponents.RadComponent;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Stack;
/**
* This class implements Ctrl+W / Ctrl+Shift+W functionality in the GuiEditor
@@ -20,13 +20,13 @@ import com.intellij.uiDesigner.lw.ColorDescriptor;
import com.intellij.uiDesigner.lw.FontDescriptor;
import com.intellij.uiDesigner.lw.StringDescriptor;
import com.intellij.util.containers.BooleanStack;
import com.intellij.util.containers.Stack;
import com.intellij.xml.util.XmlStringUtil;
import org.jdom.Attribute;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import java.awt.*;
import java.util.Stack;
/**
* This is utility for serialization of component hierarchy.
@@ -12,10 +12,9 @@ import com.intellij.uiDesigner.designSurface.GuiEditor;
import com.intellij.uiDesigner.propertyInspector.DesignerToolWindowManager;
import com.intellij.uiDesigner.radComponents.RadComponent;
import com.intellij.uiDesigner.radComponents.RadContainer;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
import java.util.Stack;
/**
* For each component selects all non selected siblings (if any). If
* all component's siblings are already selected then selects component's
@@ -10,10 +10,9 @@ import com.intellij.uiDesigner.componentTree.ComponentPtr;
import com.intellij.uiDesigner.componentTree.ComponentTreeBuilder;
import com.intellij.uiDesigner.designSurface.GuiEditor;
import com.intellij.uiDesigner.propertyInspector.DesignerToolWindowManager;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
import java.util.Stack;
/**
* @author Anton Katilin
* @author Vladimir Kondratyev