From 791833362f2e87616d70ffc3f1ce6b0191ff7a0f Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Fri, 22 Jul 2011 13:39:04 +0200 Subject: [PATCH] Change obsolete collections, remove redundant imports --- .../java/org/z3950/zing/cql/CQLBooleanNode.java | 8 ++++---- src/main/java/org/z3950/zing/cql/CQLLexer.java | 1 - src/main/java/org/z3950/zing/cql/CQLNode.java | 20 +++++++++++--------- .../java/org/z3950/zing/cql/CQLParseException.java | 1 - src/main/java/org/z3950/zing/cql/CQLParser.java | 5 +++-- src/main/java/org/z3950/zing/cql/CQLPrefix.java | 1 - .../java/org/z3950/zing/cql/CQLPrefixNode.java | 14 +++++++------- src/main/java/org/z3950/zing/cql/CQLRelation.java | 8 ++++---- src/main/java/org/z3950/zing/cql/CQLSortNode.java | 13 +++++++------ src/main/java/org/z3950/zing/cql/CQLTermNode.java | 17 +++++++++-------- .../z3950/zing/cql/MissingParameterException.java | 1 - src/main/java/org/z3950/zing/cql/Modifier.java | 1 - src/main/java/org/z3950/zing/cql/ModifierSet.java | 9 +++++---- .../z3950/zing/cql/PQFTranslationException.java | 1 - .../org/z3950/zing/cql/UnknownIndexException.java | 1 - .../z3950/zing/cql/UnknownPositionException.java | 1 - .../z3950/zing/cql/UnknownRelationException.java | 1 - .../zing/cql/UnknownRelationModifierException.java | 1 - 18 files changed, 50 insertions(+), 54 deletions(-) diff --git a/src/main/java/org/z3950/zing/cql/CQLBooleanNode.java b/src/main/java/org/z3950/zing/cql/CQLBooleanNode.java index a5b1772..dafb19b 100644 --- a/src/main/java/org/z3950/zing/cql/CQLBooleanNode.java +++ b/src/main/java/org/z3950/zing/cql/CQLBooleanNode.java @@ -1,8 +1,8 @@ // $Id: CQLBooleanNode.java,v 1.18 2007-07-03 16:03:00 mike Exp $ package org.z3950.zing.cql; +import java.util.List; import java.util.Properties; -import java.util.Vector; /** @@ -34,7 +34,7 @@ public abstract class CQLBooleanNode extends CQLNode { /** * The set of modifiers that are applied to this boolean. */ - public Vector getModifiers() { + public List getModifiers() { return ms.getModifiers(); } @@ -44,8 +44,8 @@ public abstract class CQLBooleanNode extends CQLNode { this.ms = ms; } - public String toXCQL(int level, Vector prefixes, - Vector sortkeys) { + public String toXCQL(int level, List prefixes, + List sortkeys) { return (indent(level) + "\n" + renderPrefixes(level+1, prefixes) + ms.toXCQL(level+1, "boolean") + diff --git a/src/main/java/org/z3950/zing/cql/CQLLexer.java b/src/main/java/org/z3950/zing/cql/CQLLexer.java index 31abebc..b0da745 100644 --- a/src/main/java/org/z3950/zing/cql/CQLLexer.java +++ b/src/main/java/org/z3950/zing/cql/CQLLexer.java @@ -3,7 +3,6 @@ package org.z3950.zing.cql; import java.io.StreamTokenizer; import java.io.StringReader; -import java.util.Hashtable; // This is a semi-trivial subclass for java.io.StreamTokenizer that: diff --git a/src/main/java/org/z3950/zing/cql/CQLNode.java b/src/main/java/org/z3950/zing/cql/CQLNode.java index d300782..34add8e 100644 --- a/src/main/java/org/z3950/zing/cql/CQLNode.java +++ b/src/main/java/org/z3950/zing/cql/CQLNode.java @@ -1,8 +1,10 @@ // $Id: CQLNode.java,v 1.26 2007-07-03 13:36:03 mike Exp $ package org.z3950.zing.cql; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Properties; -import java.util.Vector; /** @@ -41,19 +43,19 @@ public abstract class CQLNode { return toXCQL(level, null); } - public String toXCQL(int level, Vector prefixes) { + public String toXCQL(int level, List prefixes) { return toXCQL(level, prefixes, null); } - abstract public String toXCQL(int level, Vector prefixes, - Vector sortkeys); + abstract public String toXCQL(int level, List prefixes, + List sortkeys); - protected static String renderPrefixes(int level, Vector prefixes) { + protected static String renderPrefixes(int level, List prefixes) { if (prefixes == null || prefixes.size() == 0) return ""; String res = indent(level) + "\n"; for (int i = 0; i < prefixes.size(); i++) { - CQLPrefix p = (CQLPrefix) prefixes.get(i); + CQLPrefix p = prefixes.get(i); res += indent(level+1) + "\n"; if (p.name != null) res += indent(level+2) + "" + p.name + "\n"; @@ -65,7 +67,7 @@ public abstract class CQLNode { } protected static String renderSortKeys(int level, - Vector sortkeys) { + List sortkeys) { if (sortkeys == null || sortkeys.size() == 0) return ""; String res = indent(level) + "\n"; @@ -261,8 +263,8 @@ public abstract class CQLNode { } // Used only by the makeOID() method - private static final java.util.Hashtable madeOIDs = - new java.util.Hashtable(10); + private static final Map madeOIDs = + new HashMap(10); protected static final byte[] makeOID(String oid) { byte[] o; diff --git a/src/main/java/org/z3950/zing/cql/CQLParseException.java b/src/main/java/org/z3950/zing/cql/CQLParseException.java index 845dfff..ee237f5 100644 --- a/src/main/java/org/z3950/zing/cql/CQLParseException.java +++ b/src/main/java/org/z3950/zing/cql/CQLParseException.java @@ -1,7 +1,6 @@ // $Id: CQLParseException.java,v 1.2 2002-11-06 20:13:45 mike Exp $ package org.z3950.zing.cql; -import java.lang.Exception; /** diff --git a/src/main/java/org/z3950/zing/cql/CQLParser.java b/src/main/java/org/z3950/zing/cql/CQLParser.java index b8f2ef9..0503977 100644 --- a/src/main/java/org/z3950/zing/cql/CQLParser.java +++ b/src/main/java/org/z3950/zing/cql/CQLParser.java @@ -2,11 +2,12 @@ package org.z3950.zing.cql; import java.io.IOException; -import java.util.Vector; import java.util.Properties; import java.io.InputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; /** @@ -369,7 +370,7 @@ public class CQLParser { char mode = 'x'; // x=XCQL, c=CQL, p=PQF String pfile = null; - Vector argv = new Vector(); + List argv = new ArrayList(); for (int i = 0; i < args.length; i++) { argv.add(args[i]); } diff --git a/src/main/java/org/z3950/zing/cql/CQLPrefix.java b/src/main/java/org/z3950/zing/cql/CQLPrefix.java index 374535a..fac6503 100644 --- a/src/main/java/org/z3950/zing/cql/CQLPrefix.java +++ b/src/main/java/org/z3950/zing/cql/CQLPrefix.java @@ -1,7 +1,6 @@ // $Id: CQLPrefix.java,v 1.5 2007-06-27 22:39:55 mike Exp $ package org.z3950.zing.cql; -import java.lang.String; /** * Represents a CQL prefix mapping from short name to long identifier. diff --git a/src/main/java/org/z3950/zing/cql/CQLPrefixNode.java b/src/main/java/org/z3950/zing/cql/CQLPrefixNode.java index 10cff1a..84fb9a7 100644 --- a/src/main/java/org/z3950/zing/cql/CQLPrefixNode.java +++ b/src/main/java/org/z3950/zing/cql/CQLPrefixNode.java @@ -1,9 +1,9 @@ // $Id: CQLPrefixNode.java,v 1.10 2007-07-03 16:40:11 mike Exp $ package org.z3950.zing.cql; -import java.lang.String; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; -import java.util.Vector; /** @@ -41,11 +41,11 @@ public class CQLPrefixNode extends CQLNode { this.subtree = subtree; } - public String toXCQL(int level, Vector prefixes, - Vector sortkeys) { - Vector tmp = (prefixes == null ? - new Vector() : - new Vector(prefixes)); + public String toXCQL(int level, List prefixes, + List sortkeys) { + List tmp = (prefixes == null ? + new ArrayList() : + new ArrayList(prefixes)); tmp.add(prefix); return subtree.toXCQL(level, tmp, sortkeys); } diff --git a/src/main/java/org/z3950/zing/cql/CQLRelation.java b/src/main/java/org/z3950/zing/cql/CQLRelation.java index 95eb303..9e17d27 100644 --- a/src/main/java/org/z3950/zing/cql/CQLRelation.java +++ b/src/main/java/org/z3950/zing/cql/CQLRelation.java @@ -1,9 +1,8 @@ // $Id: CQLRelation.java,v 1.19 2007-07-03 13:40:58 mike Exp $ package org.z3950.zing.cql; -import java.util.Vector; +import java.util.List; import java.util.Properties; -import java.lang.StringBuffer; /** * Represents a relation between a CQL index and term. @@ -40,11 +39,12 @@ public class CQLRelation extends CQLNode { * @return * An array of Modifier objects. */ - public Vector getModifiers() { + public List getModifiers() { return ms.getModifiers(); } - public String toXCQL(int level, Vector prefixes, Vector sortkeys) { + public String toXCQL(int level, List prefixes, + List sortkeys) { if (sortkeys != null) throw new Error("CQLRelation.toXCQL() called with sortkeys"); diff --git a/src/main/java/org/z3950/zing/cql/CQLSortNode.java b/src/main/java/org/z3950/zing/cql/CQLSortNode.java index 53c7ef1..306f8c6 100644 --- a/src/main/java/org/z3950/zing/cql/CQLSortNode.java +++ b/src/main/java/org/z3950/zing/cql/CQLSortNode.java @@ -1,8 +1,9 @@ // $Id: CQLSortNode.java,v 1.2 2008-04-11 12:05:15 mike Exp $ package org.z3950.zing.cql; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; -import java.util.Vector; /** @@ -22,7 +23,7 @@ public class CQLSortNode extends CQLNode { * each expressed as an index together with zero or more * modifiers. */ - Vector keys; + List keys; public CQLNode getSubtree() { return subtree; @@ -30,19 +31,19 @@ public class CQLSortNode extends CQLNode { public CQLSortNode(CQLNode subtree) { this.subtree = subtree; - keys = new Vector(); + keys = new ArrayList(); } public void addSortIndex(ModifierSet key) { keys.add(key); } - public Vector getSortIndexes() { + public List getSortIndexes() { return keys; } - public String toXCQL(int level, Vector prefixes, - Vector sortkeys) { + public String toXCQL(int level, List prefixes, + List sortkeys) { if (sortkeys != null) throw new Error("CQLSortNode.toXCQL() called with sortkeys"); return subtree.toXCQL(level, prefixes, keys); diff --git a/src/main/java/org/z3950/zing/cql/CQLTermNode.java b/src/main/java/org/z3950/zing/cql/CQLTermNode.java index 924b6ba..1f03a4e 100644 --- a/src/main/java/org/z3950/zing/cql/CQLTermNode.java +++ b/src/main/java/org/z3950/zing/cql/CQLTermNode.java @@ -1,8 +1,9 @@ // $Id: CQLTermNode.java,v 1.28 2007-07-03 13:41:24 mike Exp $ package org.z3950.zing.cql; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; -import java.util.Vector; /** @@ -51,8 +52,8 @@ public class CQLTermNode extends CQLNode { return null; } - public String toXCQL(int level, Vector prefixes, - Vector sortkeys) { + public String toXCQL(int level, List prefixes, + List sortkeys) { return (indent(level) + "\n" + renderPrefixes(level+1, prefixes) + indent(level+1) + "" + xq(index) + "\n" + @@ -80,8 +81,8 @@ public class CQLTermNode extends CQLNode { // ### Interaction between this and its callers is not good as // regards truncation of the term and generation of truncation // attributes. Change the interface to fix this. - private Vector getAttrs(Properties config) throws PQFTranslationException { - Vector attrs = new Vector(); + private List getAttrs(Properties config) throws PQFTranslationException { + List attrs = new ArrayList(); // Do this first so that if any other truncation or // completeness attributes are generated, they "overwrite" @@ -118,7 +119,7 @@ public class CQLTermNode extends CQLNode { throw new UnknownRelationException(rel); attrs.add(attr); - Vector mods = relation.getModifiers(); + List mods = relation.getModifiers(); for (int i = 0; i < mods.size(); i++) { String type = mods.get(i).type; attr = config.getProperty("relationModifier." + type); @@ -164,7 +165,7 @@ public class CQLTermNode extends CQLNode { return "@set " + maybeQuote(term); } - Vector attrs = getAttrs(config); + List attrs = getAttrs(config); String attr, s = ""; for (int i = 0; i < attrs.size(); i++) { @@ -240,7 +241,7 @@ public class CQLTermNode extends CQLNode { offset = putTag(CONTEXT, 44, CONSTRUCTED, operand, offset); // AttributeList operand[offset++] = (byte)(0x80&0xff); // indefinite length - Vector attrs = getAttrs(config); + List attrs = getAttrs(config); for(i = 0; i < attrs.size(); i++) { attrList = (String) attrs.get(i); java.util.StringTokenizer st = diff --git a/src/main/java/org/z3950/zing/cql/MissingParameterException.java b/src/main/java/org/z3950/zing/cql/MissingParameterException.java index 3b54668..07873b8 100644 --- a/src/main/java/org/z3950/zing/cql/MissingParameterException.java +++ b/src/main/java/org/z3950/zing/cql/MissingParameterException.java @@ -1,7 +1,6 @@ // $Id: MissingParameterException.java,v 1.2 2002-11-06 20:13:45 mike Exp $ package org.z3950.zing.cql; -import java.lang.Exception; /** diff --git a/src/main/java/org/z3950/zing/cql/Modifier.java b/src/main/java/org/z3950/zing/cql/Modifier.java index 4992b25..7b9fbbe 100644 --- a/src/main/java/org/z3950/zing/cql/Modifier.java +++ b/src/main/java/org/z3950/zing/cql/Modifier.java @@ -1,7 +1,6 @@ // $Id: Modifier.java,v 1.4 2007-07-03 13:29:34 mike Exp $ package org.z3950.zing.cql; -import java.util.Vector; import java.lang.StringBuffer; /** diff --git a/src/main/java/org/z3950/zing/cql/ModifierSet.java b/src/main/java/org/z3950/zing/cql/ModifierSet.java index 835e731..31fdad1 100644 --- a/src/main/java/org/z3950/zing/cql/ModifierSet.java +++ b/src/main/java/org/z3950/zing/cql/ModifierSet.java @@ -1,8 +1,9 @@ // $Id: ModifierSet.java,v 1.13 2007-07-03 13:30:18 mike Exp $ package org.z3950.zing.cql; -import java.util.Vector; import java.lang.StringBuffer; +import java.util.ArrayList; +import java.util.List; /** * Represents a base String and a set of Modifiers. @@ -19,14 +20,14 @@ import java.lang.StringBuffer; */ public class ModifierSet { private String base; - private Vector modifiers; + private List modifiers; /** * Creates a new ModifierSet with the specified base. */ public ModifierSet(String base) { this.base = base; - modifiers = new Vector(); + modifiers = new ArrayList(); } /** @@ -73,7 +74,7 @@ public class ModifierSet { * @return * An array of Modifiers. */ - public Vector getModifiers() { + public List getModifiers() { return modifiers; } diff --git a/src/main/java/org/z3950/zing/cql/PQFTranslationException.java b/src/main/java/org/z3950/zing/cql/PQFTranslationException.java index 85ec184..0272e84 100644 --- a/src/main/java/org/z3950/zing/cql/PQFTranslationException.java +++ b/src/main/java/org/z3950/zing/cql/PQFTranslationException.java @@ -1,7 +1,6 @@ // $Id: PQFTranslationException.java,v 1.1 2002-11-06 20:13:45 mike Exp $ package org.z3950.zing.cql; -import java.lang.Exception; /** diff --git a/src/main/java/org/z3950/zing/cql/UnknownIndexException.java b/src/main/java/org/z3950/zing/cql/UnknownIndexException.java index b4201d3..7eabe75 100644 --- a/src/main/java/org/z3950/zing/cql/UnknownIndexException.java +++ b/src/main/java/org/z3950/zing/cql/UnknownIndexException.java @@ -1,7 +1,6 @@ // $Id: UnknownIndexException.java,v 1.2 2007-06-27 22:44:40 mike Exp $ package org.z3950.zing.cql; -import java.lang.Exception; /** diff --git a/src/main/java/org/z3950/zing/cql/UnknownPositionException.java b/src/main/java/org/z3950/zing/cql/UnknownPositionException.java index 5f38ab5..f1fc9f3 100644 --- a/src/main/java/org/z3950/zing/cql/UnknownPositionException.java +++ b/src/main/java/org/z3950/zing/cql/UnknownPositionException.java @@ -1,7 +1,6 @@ // $Id: UnknownPositionException.java,v 1.2 2002-11-29 16:42:54 mike Exp $ package org.z3950.zing.cql; -import java.lang.Exception; /** diff --git a/src/main/java/org/z3950/zing/cql/UnknownRelationException.java b/src/main/java/org/z3950/zing/cql/UnknownRelationException.java index 4d65e72..11cedb7 100644 --- a/src/main/java/org/z3950/zing/cql/UnknownRelationException.java +++ b/src/main/java/org/z3950/zing/cql/UnknownRelationException.java @@ -1,7 +1,6 @@ // $Id: UnknownRelationException.java,v 1.2 2002-11-06 20:13:45 mike Exp $ package org.z3950.zing.cql; -import java.lang.Exception; /** diff --git a/src/main/java/org/z3950/zing/cql/UnknownRelationModifierException.java b/src/main/java/org/z3950/zing/cql/UnknownRelationModifierException.java index 9d449b5..8025eb9 100644 --- a/src/main/java/org/z3950/zing/cql/UnknownRelationModifierException.java +++ b/src/main/java/org/z3950/zing/cql/UnknownRelationModifierException.java @@ -1,7 +1,6 @@ // $Id: UnknownRelationModifierException.java,v 1.1 2002-11-06 20:13:45 mike Exp $ package org.z3950.zing.cql; -import java.lang.Exception; /** -- 1.7.10.4