Class CQLNode
java.lang.Object
org.z3950.zing.cql.CQLNode
- Direct Known Subclasses:
CQLBooleanNode, CQLPrefixNode, CQLRelation, CQLSortNode, CQLTermNode
Represents a node in a CQL parse-tree.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intstatic final bytestatic final byteprotected static final intprotected static final intstatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final byteprotected static final intprotected static final intstatic final bytestatic final byteprotected static final intstatic final byte -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetEnd()Returns the exclusive source end, suitable forquery.substring(getStart(), getEnd()).Returns the name of the result-set to which this query is a reference, if and only if the entire query consists only of a result-set reference.intgetStart()Returns the inclusive source start of this node (including its subtree and enclosing parentheses).protected static final intlenLen(int length) Get the length needed to represent the given length.protected static final byte[]static final byte[]makeQuery(CQLNode root, Properties properties) protected static final intnumLen(long num) Get the length needed to represent the given number.protected static final intputNum(long num, byte[] record, int offset) Put a number into a given bufferprotected static final intputTag(int asn1class, int fldid, int form, byte[] record, int offset) abstract StringtoCQL()Decompiles a parse-tree into a CQL query.abstract StringtoPQF(Properties config) Renders a parse-tree into a Yaz-style PQF string.toString()abstract byte[]toType1BER(Properties config) Renders a parser-tree into a BER-endoded packet representing an equivalent Z39.50 Type-1 query.toXCQL()Translates a parse-tree into an XCQL document.abstract voidtraverse(CQLNodeVisitor visitor)
-
Field Details
-
UNIVERSAL
protected static final int UNIVERSAL- See Also:
-
APPLICATION
protected static final int APPLICATION- See Also:
-
CONTEXT
protected static final int CONTEXT- See Also:
-
PRIVATE
protected static final int PRIVATE- See Also:
-
PRIMITIVE
protected static final int PRIMITIVE- See Also:
-
CONSTRUCTED
protected static final int CONSTRUCTED- See Also:
-
BOOLEAN
public static final byte BOOLEAN- See Also:
-
INTEGER
public static final byte INTEGER- See Also:
-
BITSTRING
public static final byte BITSTRING- See Also:
-
OCTETSTRING
public static final byte OCTETSTRING- See Also:
-
NULL
public static final byte NULL- See Also:
-
OBJECTIDENTIFIER
public static final byte OBJECTIDENTIFIER- See Also:
-
OBJECTDESCRIPTOR
public static final byte OBJECTDESCRIPTOR- See Also:
-
EXTERNAL
public static final byte EXTERNAL- See Also:
-
ENUMERATED
public static final byte ENUMERATED- See Also:
-
SEQUENCE
public static final byte SEQUENCE- See Also:
-
SET
public static final byte SET- See Also:
-
VISIBLESTRING
public static final byte VISIBLESTRING- See Also:
-
GENERALSTRING
public static final byte GENERALSTRING- See Also:
-
-
Constructor Details
-
CQLNode
public CQLNode()
-
-
Method Details
-
getStart
public int getStart()Returns the inclusive source start of this node (including its subtree and enclosing parentheses). Offsets are zero-based UTF-16 indexes into the original query, excluding surrounding whitespace. Manually constructed objects and implicit defaults have no source location and return -1. Locations describe the original parse and are not updated after tree modifications.- Returns:
- source start, or -1 when unavailable
-
getEnd
public int getEnd()Returns the exclusive source end, suitable forquery.substring(getStart(), getEnd()).- Returns:
- source end, or -1 when unavailable
- See Also:
-
traverse
-
getResultSetName
Returns the name of the result-set to which this query is a reference, if and only if the entire query consists only of a result-set reference. If it's anything else, including a boolean combination of a result-set reference with something else, then null is returned instead.- Returns:
- the name of the referenced result-set
-
toXCQL
Translates a parse-tree into an XCQL document.- Returns:
- A String containing an XCQL document equivalent to the parse-tree whose root is this node.
-
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
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- APropertiesobject containing configuration information that specifies the mapping from CQL indexes, 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.
- Throws:
PQFTranslationException- If the parse-tree cannot be translated into PQF, for example because it contains a CQL relation that is not supported by the PQF configuration.
-
toType1BER
Renders a parser-tree into a BER-endoded packet representing an equivalent Z39.50 Type-1 query. If you don't know what that means, then you don't need this method :-) This is useful primarily for SRW-to-Z39.50 gateways.- Parameters:
config- APropertiesobject containing configuration information that specifies the mapping from CQL indexes, 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 byte array containing the BER packet.
- Throws:
PQFTranslationException- If the parse-tree cannot be translated into PQF, for example because it contains a CQL relation that is not supported by the PQF configuration.- See Also:
-
putTag
protected static final int putTag(int asn1class, int fldid, int form, byte[] record, int offset) -
lenLen
protected static final int lenLen(int length) Get the length needed to represent the given length.- Parameters:
length- determine length needed to encode this- Returns:
- length needed to encode given length
-
numLen
protected static final int numLen(long num) Get the length needed to represent the given number.- Parameters:
num- determine length needed to encode this- Returns:
- length needed to encode given number
-
putNum
protected static final int putNum(long num, byte[] record, int offset) Put a number into a given buffer- Parameters:
num- number to put into bufferrecord- buffer to useoffset- offset into buffer- Returns:
- the new, incremented value of the offset parameter.
-
makeOID
-
makeQuery
public static final byte[] makeQuery(CQLNode root, Properties properties) throws PQFTranslationException - Throws:
PQFTranslationException
-
toString
-