From 41fcd9c3be17618728c4f175e4cb65ed61421447 Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Fri, 22 Jul 2011 12:40:55 +0200 Subject: [PATCH] Hide some memebers as private, add getters --- Changes | 5 +++++ .../java/org/z3950/zing/cql/CQLBooleanNode.java | 22 +++++++++++++++----- src/main/java/org/z3950/zing/cql/CQLGenerator.java | 4 ++-- src/main/java/org/z3950/zing/cql/CQLNode.java | 3 +-- src/main/java/org/z3950/zing/cql/CQLParser.java | 2 +- src/main/java/org/z3950/zing/cql/CQLPrefix.java | 12 +++++++++-- .../java/org/z3950/zing/cql/CQLPrefixNode.java | 12 +++++++++-- src/main/java/org/z3950/zing/cql/CQLRelation.java | 11 ---------- src/main/java/org/z3950/zing/cql/CQLSortNode.java | 6 +++++- src/main/java/org/z3950/zing/cql/ModifierSet.java | 4 ++-- 10 files changed, 53 insertions(+), 28 deletions(-) diff --git a/Changes b/Changes index 69ceb31..e5159f6 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,11 @@ See the bottom of this file for a list of things still to do. The work for releases 1.0, 1.2 and 1.2.1 was sponsored by the National Library of Australia, whose help we gratefully acknowledge. +1.8 IN PROGRESS + - API changes: more information hiding, introduce getters + - make some contants read-only + + 1.7 Tue Jul 27 17:35:25 BST 2010 - Patch from Ralph LeVan to recognise "qualifier.dc.creator"-like properties as well as diff --git a/src/main/java/org/z3950/zing/cql/CQLBooleanNode.java b/src/main/java/org/z3950/zing/cql/CQLBooleanNode.java index ec0608c..a5b1772 100644 --- a/src/main/java/org/z3950/zing/cql/CQLBooleanNode.java +++ b/src/main/java/org/z3950/zing/cql/CQLBooleanNode.java @@ -11,20 +11,32 @@ import java.util.Vector; * @version $Id: CQLBooleanNode.java,v 1.18 2007-07-03 16:03:00 mike Exp $ */ public abstract class CQLBooleanNode extends CQLNode { + + private CQLNode left; + /** * The root of a parse-tree representing the left-hand side. - */ - public CQLNode left; + */ + public CQLNode getLeft() { + return left; + } + + private CQLNode right; /** * The root of a parse-tree representing the right-hand side. - */ - public CQLNode right; + */ + public CQLNode getRight() { + return right; + } + ModifierSet ms; /** * The set of modifiers that are applied to this boolean. */ - public ModifierSet ms; + public Vector getModifiers() { + return ms.getModifiers(); + } protected CQLBooleanNode(CQLNode left, CQLNode right, ModifierSet ms) { this.left = left; diff --git a/src/main/java/org/z3950/zing/cql/CQLGenerator.java b/src/main/java/org/z3950/zing/cql/CQLGenerator.java index cc8ac14..8d02022 100644 --- a/src/main/java/org/z3950/zing/cql/CQLGenerator.java +++ b/src/main/java/org/z3950/zing/cql/CQLGenerator.java @@ -27,8 +27,8 @@ import java.io.FileNotFoundException; * >http://zing.z3950.org/cql/index.html */ public class CQLGenerator { - Properties params; - Random rnd; + private Properties params; + private Random rnd; static private boolean DEBUG = false; /** diff --git a/src/main/java/org/z3950/zing/cql/CQLNode.java b/src/main/java/org/z3950/zing/cql/CQLNode.java index 3e42e1e..d300782 100644 --- a/src/main/java/org/z3950/zing/cql/CQLNode.java +++ b/src/main/java/org/z3950/zing/cql/CQLNode.java @@ -191,8 +191,7 @@ public abstract class CQLNode { * @param len length to put into record * @return the new, incremented value of the offset parameter. */ - public // ### shouldn't this be protected? - static final int putLen(int len, byte[] record, int offset) { + static final int putLen(int len, byte[] record, int offset) { if (len < 128) record[offset++] = (byte)len; diff --git a/src/main/java/org/z3950/zing/cql/CQLParser.java b/src/main/java/org/z3950/zing/cql/CQLParser.java index dd69218..b8f2ef9 100644 --- a/src/main/java/org/z3950/zing/cql/CQLParser.java +++ b/src/main/java/org/z3950/zing/cql/CQLParser.java @@ -206,7 +206,7 @@ public class CQLParser { relation = new CQLRelation(relstr); match(lexer.ttype); ModifierSet ms = gatherModifiers(relstr); - relation.setModifiers(ms); + relation.ms = ms; debug("index='" + index + ", " + "relation='" + relation.toCQL() + "'"); } diff --git a/src/main/java/org/z3950/zing/cql/CQLPrefix.java b/src/main/java/org/z3950/zing/cql/CQLPrefix.java index af7c906..374535a 100644 --- a/src/main/java/org/z3950/zing/cql/CQLPrefix.java +++ b/src/main/java/org/z3950/zing/cql/CQLPrefix.java @@ -14,14 +14,22 @@ public class CQLPrefix { * itself, such as dc, as it might be used in an index * like dc.title. */ - public String name; + String name; + + public String getName() { + return name; + } /** * The full identifier name of the prefix mapping. That is, * typically, a URI permanently allocated to a specific index * set, such as http://zthes.z3950.org/cql/1.0. */ - public String identifier; + String identifier; + + public String getIdentifier() { + return identifier; + } /** * Creates a new CQLPrefix mapping, which maps the specified name diff --git a/src/main/java/org/z3950/zing/cql/CQLPrefixNode.java b/src/main/java/org/z3950/zing/cql/CQLPrefixNode.java index dd01d85..10cff1a 100644 --- a/src/main/java/org/z3950/zing/cql/CQLPrefixNode.java +++ b/src/main/java/org/z3950/zing/cql/CQLPrefixNode.java @@ -15,13 +15,21 @@ public class CQLPrefixNode extends CQLNode { /** * The prefix definition that governs the subtree. */ - public CQLPrefix prefix; + private CQLPrefix prefix; + + public CQLPrefix getPrefix() { + return prefix; + } /** * The root of a parse-tree representing the part of the query * that is governed by this prefix definition. */ - public CQLNode subtree; + private CQLNode subtree; + + public CQLNode getSubtree() { + return subtree; + } /** * Creates a new CQLPrefixNode inducing a mapping from the diff --git a/src/main/java/org/z3950/zing/cql/CQLRelation.java b/src/main/java/org/z3950/zing/cql/CQLRelation.java index 570afff..95eb303 100644 --- a/src/main/java/org/z3950/zing/cql/CQLRelation.java +++ b/src/main/java/org/z3950/zing/cql/CQLRelation.java @@ -36,17 +36,6 @@ public class CQLRelation extends CQLNode { } /** - * Sets the modifiers of the specified CQLRelation. - * Typical relation modifiers include relevant, - * fuzzy, stem and phonetic. On the - * whole, these modifiers have a meaningful interpretation only - * for the text relations. - */ - public void setModifiers(ModifierSet ms) { - this.ms = ms; - } - - /** * Returns an array of the modifiers associated with a CQLRelation. * @return * An array of Modifier objects. diff --git a/src/main/java/org/z3950/zing/cql/CQLSortNode.java b/src/main/java/org/z3950/zing/cql/CQLSortNode.java index 6e7f21d..53c7ef1 100644 --- a/src/main/java/org/z3950/zing/cql/CQLSortNode.java +++ b/src/main/java/org/z3950/zing/cql/CQLSortNode.java @@ -15,7 +15,7 @@ public class CQLSortNode extends CQLNode { * The root of a subtree representing the query whose result is to * be sorted. */ - public CQLNode subtree; + private CQLNode subtree; /** * The set of sort keys by which results are to be sorted, @@ -24,6 +24,10 @@ public class CQLSortNode extends CQLNode { */ Vector keys; + public CQLNode getSubtree() { + return subtree; + } + public CQLSortNode(CQLNode subtree) { this.subtree = subtree; keys = new Vector(); diff --git a/src/main/java/org/z3950/zing/cql/ModifierSet.java b/src/main/java/org/z3950/zing/cql/ModifierSet.java index 7b6991a..835e731 100644 --- a/src/main/java/org/z3950/zing/cql/ModifierSet.java +++ b/src/main/java/org/z3950/zing/cql/ModifierSet.java @@ -18,8 +18,8 @@ import java.lang.StringBuffer; * @version $Id: ModifierSet.java,v 1.13 2007-07-03 13:30:18 mike Exp $ */ public class ModifierSet { - String base; - Vector modifiers; + private String base; + private Vector modifiers; /** * Creates a new ModifierSet with the specified base. -- 1.7.10.4