CQL::Node - base class for nodes in a CQL parse tree


CQL-Parser documentation Contained in the CQL-Parser distribution.

Index


Code Index:

NAME

Top

CQL::Node - base class for nodes in a CQL parse tree

SYNOPSIS

Top

    n/a

DESCRIPTION

Top

All the CQL node classes inherit from CQL::Node. CQL::Node essentially gurantees that its children implements some methods.

toCQL()

toXCQL()

toSwish()

toLucene()

clone()

Creates a copy of a node, and it's children. Useful if you want to modify the tree but keep a copy of the original.


CQL-Parser documentation Contained in the CQL-Parser distribution.
package CQL::Node;

use strict;
use warnings;
use base qw( Clone );
use Carp qw( croak );

sub toCQL {
    my $self = shift;
    ## poor mans interface
    croak( ref($self) . " forgot to implement toCQL()!!!" );
}

sub toXCQL {
    my $self = shift;
    croak( ref($self) . " forgot to implement toXCQL()!!!" );
}

sub toSwish {
    my $self = shift;
    ## poor mans interface
    croak( ref($self) . " forgot to implement toSwish()!!!" );
}

sub toLucene {
    my $self = shift;
    croak( ref($self) . " forgot to implement toLucene()!!!" );
}

# internal method for adding namespace information to top level 
# elements in XCQL generated by children.

sub addNamespace {
    my ($self,$level,$xml) = @_;
    # only add namespace to top level element
    return $xml if $level != 0;
    # kind of hackish way of adding namespace to the first
    # open tag we see
    $xml =~ s{^<([^ ]*?)>}{<$1 xmlns="http://www.loc.gov/zing/cql/xcql/">};
    return $xml;
}

1;