org.z3950.zing.cql
Class CQLNode

java.lang.Object
  |
  +--org.z3950.zing.cql.CQLNode
Direct Known Subclasses:
CQLBooleanNode, CQLPrefixNode, CQLRelation, CQLTermNode

public abstract class CQLNode
extends java.lang.Object

Represents a node in a CQL parse-tree.

Version:
$Id: CQLNode.java,v 1.15 2002/11/20 01:15:15 mike Exp $

Method Summary
protected static java.lang.String indent(int level)
          Returns a String of spaces for indenting to the specified level.
protected static java.lang.String renderPrefixes(int level, java.util.Vector prefixes)
           
abstract  java.lang.String toCQL()
          Decompiles a parse-tree into a CQL query.
abstract  java.lang.String toPQF(java.util.Properties config)
          Renders a parse-tree into a Yaz-style PQF string.
 java.lang.String toXCQL(int level)
          Translates a parse-tree into an XCQL document.
abstract  java.lang.String toXCQL(int level, java.util.Vector prefixes)
           
protected static java.lang.String xq(java.lang.String str)
          Returns the argument String quoted for XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toXCQL

public java.lang.String toXCQL(int level)
Translates a parse-tree into an XCQL document.

Parameters:
level - The number of levels to indent the top element of the XCQL document. This will typically be 0 when invoked by an application; it takes higher values when this method is invoked recursively for nodes further down the tree.
Returns:
A String containing an XCQL document equivalent to the parse-tree whose root is this node.

toXCQL

public abstract java.lang.String toXCQL(int level,
                                        java.util.Vector prefixes)

renderPrefixes

protected static java.lang.String renderPrefixes(int level,
                                                 java.util.Vector prefixes)

toCQL

public abstract java.lang.String toCQL()
Decompiles a parse-tree into a CQL query.

Returns:
A String containing a CQL query equivalent to the parse-tree whose root is this node, so that compiling that query will yield an identical tree.

toPQF

public abstract java.lang.String toPQF(java.util.Properties config)
                                throws PQFTranslationException
Renders a parse-tree into a Yaz-style PQF string. PQF, or Prefix Query Format, is a cryptic but powerful notation that can be trivially mapped, one-to-one, int Z39.50 Type-1 and Type-101 queries. A specification for the format can be found in Chapter 7 (Supporting Tools) of the YAZ manual.

Parameters:
config - A Properties object containing configuration information that specifies the mapping from CQL qualifiers, relations, etc. to Type-1 attributes. The mapping specification is described in the cql-java distribution's sample PQF-mapping configuration file, etc/pqf.properties, which see.
Returns:
A String containing a PQF query equivalent to the parse-tree whose root is this node. This may be fed into the tool of your choice to obtain a BER-encoded packet.

indent

protected static java.lang.String indent(int level)
Returns a String of spaces for indenting to the specified level.

xq

protected static java.lang.String xq(java.lang.String str)
Returns the argument String quoted for XML. For example, each occurrence of < is translated to &lt;.