From e4126f4c547f5f823fbfceb4169786bc7cf98401 Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 6 Jun 2007 12:22:01 +0000 Subject: [PATCH] Use generics (what C++ programmers call templates) --- src/org/z3950/zing/cql/CQLBooleanNode.java | 9 +++++---- src/org/z3950/zing/cql/CQLNode.java | 12 ++++++------ src/org/z3950/zing/cql/CQLParser.java | 6 +++--- src/org/z3950/zing/cql/CQLPrefixNode.java | 8 ++++---- src/org/z3950/zing/cql/CQLTermNode.java | 8 ++++---- src/org/z3950/zing/cql/ModifierSet.java | 10 +++++----- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/org/z3950/zing/cql/CQLBooleanNode.java b/src/org/z3950/zing/cql/CQLBooleanNode.java index 7064784..794e2ac 100644 --- a/src/org/z3950/zing/cql/CQLBooleanNode.java +++ b/src/org/z3950/zing/cql/CQLBooleanNode.java @@ -1,4 +1,4 @@ -// $Id: CQLBooleanNode.java,v 1.13 2002-12-11 17:14:20 mike Exp $ +// $Id: CQLBooleanNode.java,v 1.14 2007-06-06 12:22:01 mike Exp $ package org.z3950.zing.cql; import java.util.Properties; @@ -8,7 +8,7 @@ import java.util.Vector; /** * Represents a boolean node in a CQL parse-tree. * - * @version $Id: CQLBooleanNode.java,v 1.13 2002-12-11 17:14:20 mike Exp $ + * @version $Id: CQLBooleanNode.java,v 1.14 2007-06-06 12:22:01 mike Exp $ */ public abstract class CQLBooleanNode extends CQLNode { CQLBooleanNode() {} // prevent javadoc from documenting this @@ -24,14 +24,15 @@ public abstract class CQLBooleanNode extends CQLNode { public CQLNode right; public String toXCQL(int level, Vector prefixes) { + // ### Should this use CQLNode.toXCQL(level+2, prefixes)? return (indent(level) + "\n" + renderPrefixes(level+1, prefixes) + opXCQL(level+1) + indent(level+1) + "\n" + - left.toXCQL(level+2, new Vector()) + + left.toXCQL(level+2) + indent(level+1) + "\n" + indent(level+1) + "\n" + - right.toXCQL(level+2, new Vector()) + + right.toXCQL(level+2) + indent(level+1) + "\n" + indent(level) + "\n"); } diff --git a/src/org/z3950/zing/cql/CQLNode.java b/src/org/z3950/zing/cql/CQLNode.java index eccc5f2..4573400 100644 --- a/src/org/z3950/zing/cql/CQLNode.java +++ b/src/org/z3950/zing/cql/CQLNode.java @@ -1,4 +1,4 @@ -// $Id: CQLNode.java,v 1.22 2002-12-12 15:03:50 mike Exp $ +// $Id: CQLNode.java,v 1.23 2007-06-06 12:22:01 mike Exp $ package org.z3950.zing.cql; import java.util.Properties; @@ -8,7 +8,7 @@ import java.util.Vector; /** * Represents a node in a CQL parse-tree. * - * @version $Id: CQLNode.java,v 1.22 2002-12-12 15:03:50 mike Exp $ + * @version $Id: CQLNode.java,v 1.23 2007-06-06 12:22:01 mike Exp $ */ public abstract class CQLNode { CQLNode() {} // prevent javadoc from documenting this @@ -38,10 +38,10 @@ public abstract class CQLNode { * parse-tree whose root is this node. */ public String toXCQL(int level) { - return toXCQL(level, new Vector()); + return toXCQL(level, new Vector()); } - abstract public String toXCQL(int level, Vector prefixes); + abstract public String toXCQL(int level, Vector prefixes); protected static String renderPrefixes(int level, Vector prefixes) { if (prefixes.size() == 0) @@ -245,8 +245,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 java.util.Hashtable madeOIDs = + new java.util.Hashtable(10); protected static final byte[] makeOID(String oid) { byte[] o; diff --git a/src/org/z3950/zing/cql/CQLParser.java b/src/org/z3950/zing/cql/CQLParser.java index 13e505e..da2af02 100644 --- a/src/org/z3950/zing/cql/CQLParser.java +++ b/src/org/z3950/zing/cql/CQLParser.java @@ -1,4 +1,4 @@ -// $Id: CQLParser.java,v 1.23 2003-09-04 21:56:46 mike Exp $ +// $Id: CQLParser.java,v 1.24 2007-06-06 12:22:01 mike Exp $ package org.z3950.zing.cql; import java.io.IOException; @@ -12,7 +12,7 @@ import java.io.FileNotFoundException; /** * Compiles CQL strings into parse trees of CQLNode subtypes. * - * @version $Id: CQLParser.java,v 1.23 2003-09-04 21:56:46 mike Exp $ + * @version $Id: CQLParser.java,v 1.24 2007-06-06 12:22:01 mike Exp $ * @see http://zing.z3950.org/cql/index.html */ @@ -368,7 +368,7 @@ public class CQLParser { char mode = 'x'; // x=XCQL, c=CQL, p=PQF String pfile = null; - Vector argv = new Vector(); + Vector argv = new Vector(); for (int i = 0; i < args.length; i++) { argv.add(args[i]); } diff --git a/src/org/z3950/zing/cql/CQLPrefixNode.java b/src/org/z3950/zing/cql/CQLPrefixNode.java index 3e2ad87..f5996ec 100644 --- a/src/org/z3950/zing/cql/CQLPrefixNode.java +++ b/src/org/z3950/zing/cql/CQLPrefixNode.java @@ -1,4 +1,4 @@ -// $Id: CQLPrefixNode.java,v 1.5 2002-12-11 17:14:20 mike Exp $ +// $Id: CQLPrefixNode.java,v 1.6 2007-06-06 12:22:01 mike Exp $ package org.z3950.zing.cql; import java.lang.String; @@ -9,7 +9,7 @@ import java.util.Vector; /** * Represents a prefix node in a CQL parse-tree. * - * @version $Id: CQLPrefixNode.java,v 1.5 2002-12-11 17:14:20 mike Exp $ + * @version $Id: CQLPrefixNode.java,v 1.6 2007-06-06 12:22:01 mike Exp $ */ public class CQLPrefixNode extends CQLNode { /** @@ -33,7 +33,7 @@ public class CQLPrefixNode extends CQLNode { this.subtree = subtree; } - public String toXCQL(int level, Vector prefixes) { + public String toXCQL(int level, Vector prefixes) { // String maybeName = ""; // if (prefix.name != null) // maybeName = indent(level+1) + "" + prefix.name + "\n"; @@ -43,7 +43,7 @@ public class CQLPrefixNode extends CQLNode { // "" + prefix.identifier + "\n" + // subtree.toXCQL(level+1, prefixes) + // indent(level) + "\n"); - Vector tmp = new Vector(prefixes); + Vector tmp = new Vector(prefixes); tmp.add(prefix); return subtree.toXCQL(level, tmp); } diff --git a/src/org/z3950/zing/cql/CQLTermNode.java b/src/org/z3950/zing/cql/CQLTermNode.java index a519215..841c139 100644 --- a/src/org/z3950/zing/cql/CQLTermNode.java +++ b/src/org/z3950/zing/cql/CQLTermNode.java @@ -1,4 +1,4 @@ -// $Id: CQLTermNode.java,v 1.22 2006-06-14 14:36:36 mike Exp $ +// $Id: CQLTermNode.java,v 1.23 2007-06-06 12:22:01 mike Exp $ package org.z3950.zing.cql; import java.util.Properties; @@ -12,7 +12,7 @@ import java.util.Vector; * these must be provided - you can't have a qualifier without a * relation or vice versa. * - * @version $Id: CQLTermNode.java,v 1.22 2006-06-14 14:36:36 mike Exp $ + * @version $Id: CQLTermNode.java,v 1.23 2007-06-06 12:22:01 mike Exp $ */ public class CQLTermNode extends CQLNode { private String qualifier; @@ -51,7 +51,7 @@ public class CQLTermNode extends CQLNode { return (indent(level) + "\n" + renderPrefixes(level+1, prefixes) + indent(level+1) + "" + xq(qualifier) + "\n" + - relation.toXCQL(level+1, new Vector()) + + relation.toXCQL(level+1, new Vector()) + indent(level+1) + "" + xq(term) + "\n" + indent(level) + "\n"); } @@ -74,7 +74,7 @@ public class CQLTermNode extends CQLNode { // 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(); + Vector attrs = new Vector(); // Do this first so that if any other truncation or // completeness attributes are generated, they "overwrite" diff --git a/src/org/z3950/zing/cql/ModifierSet.java b/src/org/z3950/zing/cql/ModifierSet.java index 66380ff..0f282e1 100644 --- a/src/org/z3950/zing/cql/ModifierSet.java +++ b/src/org/z3950/zing/cql/ModifierSet.java @@ -1,4 +1,4 @@ -// $Id: ModifierSet.java,v 1.7 2002-11-20 17:56:22 mike Exp $ +// $Id: ModifierSet.java,v 1.8 2007-06-06 12:22:01 mike Exp $ package org.z3950.zing.cql; import java.util.Vector; @@ -15,18 +15,18 @@ import java.lang.StringBuffer; * zero or more type=value pairs, where both type and * value are strings. Types may be null, values may not. * - * @version $Id: ModifierSet.java,v 1.7 2002-11-20 17:56:22 mike Exp $ + * @version $Id: ModifierSet.java,v 1.8 2007-06-06 12:22:01 mike Exp $ */ public class ModifierSet { String base; - Vector modifiers; + Vector modifiers; /** * Creates a new ModifierSet with the specified base. */ public ModifierSet(String base) { this.base = base; - modifiers = new Vector(); + modifiers = new Vector(); } /** @@ -41,7 +41,7 @@ public class ModifierSet { * value to a ModifierSet. */ public void addModifier(String type, String value) { - Vector modifier = new Vector(); + Vector modifier = new Vector(); modifier.add(type); modifier.add(value); modifiers.add(modifier); -- 1.7.10.4