Hide some memebers as private, add getters
authorJakub Skoczen <jakub@indexdata.dk>
Fri, 22 Jul 2011 10:40:55 +0000 (12:40 +0200)
committerJakub Skoczen <jakub@indexdata.dk>
Fri, 22 Jul 2011 10:40:55 +0000 (12:40 +0200)
Changes
src/main/java/org/z3950/zing/cql/CQLBooleanNode.java
src/main/java/org/z3950/zing/cql/CQLGenerator.java
src/main/java/org/z3950/zing/cql/CQLNode.java
src/main/java/org/z3950/zing/cql/CQLParser.java
src/main/java/org/z3950/zing/cql/CQLPrefix.java
src/main/java/org/z3950/zing/cql/CQLPrefixNode.java
src/main/java/org/z3950/zing/cql/CQLRelation.java
src/main/java/org/z3950/zing/cql/CQLSortNode.java
src/main/java/org/z3950/zing/cql/ModifierSet.java

diff --git a/Changes b/Changes
index 69ceb31..e5159f6 100644 (file)
--- 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.
 
 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
 1.7  Tue Jul 27 17:35:25 BST 2010
        - Patch from Ralph LeVan to recognise
          "qualifier.dc.creator"-like properties as well as
index ec0608c..a5b1772 100644 (file)
@@ -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 {
  * @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.
     /**
      * 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.
 
     /**
      * 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.
      */
     /**
      * The set of modifiers that are applied to this boolean.
      */
-    public ModifierSet ms;
+    public Vector<Modifier> getModifiers() {
+        return ms.getModifiers();
+    }
 
     protected CQLBooleanNode(CQLNode left, CQLNode right, ModifierSet ms) {
        this.left = left;
 
     protected CQLBooleanNode(CQLNode left, CQLNode right, ModifierSet ms) {
        this.left = left;
index cc8ac14..8d02022 100644 (file)
@@ -27,8 +27,8 @@ import java.io.FileNotFoundException;
  *                     >http://zing.z3950.org/cql/index.html</A>
  */
 public class CQLGenerator {
  *                     >http://zing.z3950.org/cql/index.html</A>
  */
 public class CQLGenerator {
-    Properties params;
-    Random rnd;
+    private Properties params;
+    private Random rnd;
     static private boolean DEBUG = false;
 
     /**
     static private boolean DEBUG = false;
 
     /**
index 3e42e1e..d300782 100644 (file)
@@ -191,8 +191,7 @@ public abstract class CQLNode {
      * @param len length to put into record
      * @return the new, incremented value of the offset parameter.
      */
      * @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;
 
         if (len < 128)
             record[offset++] = (byte)len;
index dd69218..b8f2ef9 100644 (file)
@@ -206,7 +206,7 @@ public class CQLParser {
            relation = new CQLRelation(relstr);
            match(lexer.ttype);
            ModifierSet ms = gatherModifiers(relstr);
            relation = new CQLRelation(relstr);
            match(lexer.ttype);
            ModifierSet ms = gatherModifiers(relstr);
-           relation.setModifiers(ms);
+           relation.ms = ms;
            debug("index='" + index + ", " +
                  "relation='" + relation.toCQL() + "'");
        }
            debug("index='" + index + ", " +
                  "relation='" + relation.toCQL() + "'");
        }
index af7c906..374535a 100644 (file)
@@ -14,14 +14,22 @@ public class CQLPrefix {
      * itself, such as <TT>dc</TT>, as it might be used in an index
      * like <TT>dc.title</TT>.
      */
      * itself, such as <TT>dc</TT>, as it might be used in an index
      * like <TT>dc.title</TT>.
      */
-    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 <TT>http://zthes.z3950.org/cql/1.0<TT>.
      */
 
     /**
      * The full identifier name of the prefix mapping.  That is,
      * typically, a URI permanently allocated to a specific index
      * set, such as <TT>http://zthes.z3950.org/cql/1.0<TT>.
      */
-    public String identifier;
+    String identifier;
+
+    public String getIdentifier() {
+        return identifier;
+    }
 
     /**
      * Creates a new CQLPrefix mapping, which maps the specified name
 
     /**
      * Creates a new CQLPrefix mapping, which maps the specified name
index dd01d85..10cff1a 100644 (file)
@@ -15,13 +15,21 @@ public class CQLPrefixNode extends CQLNode {
     /**
      * The prefix definition that governs the subtree.
      */
     /**
      * 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.
      */ 
 
     /**
      * 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
 
     /**
      * Creates a new CQLPrefixNode inducing a mapping from the
index 570afff..95eb303 100644 (file)
@@ -36,17 +36,6 @@ public class CQLRelation extends CQLNode {
     }
 
     /**
     }
 
     /**
-     * Sets the modifiers of the specified CQLRelation.
-     * Typical relation modifiers include <TT>relevant</TT>,
-     * <TT>fuzzy</TT>, <TT>stem</TT> and <TT>phonetic</TT>.  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.
      * Returns an array of the modifiers associated with a CQLRelation.
      * @return
      * An array of Modifier objects.
index 6e7f21d..53c7ef1 100644 (file)
@@ -15,7 +15,7 @@ public class CQLSortNode extends CQLNode {
      * The root of a subtree representing the query whose result is to
      * be sorted.
      */ 
      * 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,
 
     /**
      * The set of sort keys by which results are to be sorted,
@@ -24,6 +24,10 @@ public class CQLSortNode extends CQLNode {
      */ 
     Vector<ModifierSet> keys;
 
      */ 
     Vector<ModifierSet> keys;
 
+    public CQLNode getSubtree() {
+        return subtree;
+    }
+
     public CQLSortNode(CQLNode subtree) {
        this.subtree = subtree;
        keys = new Vector<ModifierSet>();
     public CQLSortNode(CQLNode subtree) {
        this.subtree = subtree;
        keys = new Vector<ModifierSet>();
index 7b6991a..835e731 100644 (file)
@@ -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 {
  * @version $Id: ModifierSet.java,v 1.13 2007-07-03 13:30:18 mike Exp $
  */
 public class ModifierSet {
-    String base;
-    Vector<Modifier> modifiers;
+    private String base;
+    private Vector<Modifier> modifiers;
 
     /**
      * Creates a new ModifierSet with the specified base.
 
     /**
      * Creates a new ModifierSet with the specified base.