org.apache.cocoon.generation
Class SearchGenerator

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.generation.AbstractGenerator
                    |
                    +--org.apache.cocoon.generation.ComposerGenerator
                          |
                          +--org.apache.cocoon.generation.SearchGenerator
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.activity.Disposable, Generator, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, SitemapModelComponent, XMLProducer

public class SearchGenerator
extends ComposerGenerator
implements org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.activity.Disposable

Generates an XML representation of a search result.

This generator generates xml content representening an XML search. The generated xml content contains the search result, the search query information, and navigation information about the search results.

Search xml sample generated by this generator:


 <?xml version="1.0" encoding="UTF-8"?>

 <search:results date="1008437081064" query-string="cocoon"
     start-index="0" page-length="10"
     xmlns:search="http://apache.org/cocoon/search/1.0"
     xmlns:xlink="http://www.w3.org/1999/xlink">
   <search:hits total-count="125" count-of-pages="13">
     <search:hit rank="0" score="1.0"
         uri="http://localhost:8080/cocoon/documents/hosting.html">
       <search:field name="title">Document Title<search:field/>
     <search:hit/>
     ...
   </search:hits>

   <search:navigation total-count="125" count-of-pages="13"
       has-next="true" has-previous="false" next-index="10" previous-index="0">
     <search:navigation-page start-index="0"/>
     <search:navigation-page start-index="10"/>
     ...
     <search:navigation-page start-index="120"/>
   </search:navigation>
 </search:results>
 

Version:
CVS $Id: SearchGenerator.java,v 1.8.2.1 2002/09/06 03:35:33 vgritsenko Exp $
Author:
Bernhard Huber, Vadim Gritsenko

Field Summary
protected static java.lang.String CDATA
          Description of the Field
protected static java.lang.String COUNT_OF_PAGES_ATTRIBUTE
          Attribute count-of-pages of hits element.
protected static java.lang.String DATE_ATTRIBUTE
          Attribute date of results element.
protected static java.lang.String FIELD_ELEMENT
          Child element field of the hit element.
protected static java.lang.String HAS_NEXT_ATTRIBUTE
          Attribute has-next of navigation-page element.
protected static java.lang.String HAS_PREVIOUS_ATTRIBUTE
          Attribute has-next of navigation-page element.
protected static java.lang.String HIT_ELEMENT
          Child element of generated xml content, ie hit.
protected static java.lang.String HITS_ELEMENT
          Child element of generated xml content, ie hits.
protected static java.lang.String INDEX_PARAM
          Setup parameter name of index directory, ie index.
protected static java.lang.String INDEX_PARAM_DEFAULT
          Default value of setup parameter index, ie index.
protected static java.lang.String namespace
          The XML namespace for the output document.
protected static java.lang.String NAVIGATION_ELEMENT
          Child element of generated xml content, ie navigation.
protected static java.lang.String NAVIGATION_PAGE_ELEMENT
          Child element of generated xml content, ie navigation.
protected static java.lang.String NEXT_INDEX_ATTRIBUTE
          Attribute next-index of navigation-page element.
protected static java.lang.String PAGE_LENGTH_ATTRIBUTE
          Attribute page-length of results element.
protected static int PAGE_LENGTH_DEFAULT
          Description of the Field
protected static java.lang.String PAGE_LENGTH_PARAM
          Setup parameter name specifying the name of page-length query parameter, ie page-length.
protected static java.lang.String PAGE_LENGTH_PARAM_DEFAULT
          Description of the Field
protected static java.lang.String PREVIOUS_INDEX_ATTRIBUTE
          Attribute previous-index of navigation-page element.
protected static java.lang.String QUERY_STRING_ATTRIBUTE
          Attribute query-string of results element.
protected static java.lang.String QUERY_STRING_PARAM
          Setup parameter name specifying the name of query-string query parameter, ie query-string.
protected static java.lang.String QUERY_STRING_PARAM_DEFAULT
          Default value of setup parameter query-string, ie queryString.
protected static java.lang.String RANK_ATTRIBUTE
          Attribute rank of hit element.
protected static java.lang.String RESULTS_ELEMENT
          Root element of generated xml content, ie results.
protected static java.lang.String SCORE_ATTRIBUTE
          Attribute score of hit element.
protected static java.lang.String START_INDEX_ATTRIBUTE
          Attribute start-index of results element.
protected static int START_INDEX_DEFAULT
          Description of the Field
protected static java.lang.String START_INDEX_NEXT_PARAM
          Setup parameter name specifying the name of start-next-index query parameter, ie start-next-index.
protected static java.lang.String START_INDEX_NEXT_PARAM_DEFAULT
          Default value of setup parameter start-next-index, ie startNextIndex.
protected static java.lang.String START_INDEX_PARAM
          Setup parameter name specifying the name of start-index query parameter, ie start-index.
protected static java.lang.String START_INDEX_PARAM_DEFAULT
          Default value of setup parameter start-index, ie startIndex.
protected static java.lang.String START_INDEX_PREVIOUS_PARAM
          Setup parameter name specifying the name of start-previous-index query parameter, ie start-previous-index.
protected static java.lang.String START_INDEX_PREVIOUS_PARAM_DEFAULT
          Default value of setup parameter start-previous-index, ie startPreviousIndex.
protected static java.lang.String TOTAL_COUNT_ATTRIBUTE
          Attribute total-count of hits element.
protected static java.lang.String URI_ATTRIBUTE
          Attribute uri of hit element.
protected static java.lang.String xlinkNamespace
          The XML namespace for xlink
 
Fields inherited from class org.apache.cocoon.generation.ComposerGenerator
manager
 
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator
objectModel, parameters, resolver, source
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.generation.Generator
ROLE
 
Constructor Summary
SearchGenerator()
           
 
Method Summary
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
          Set the current ComponentManager instance used by this Composable.
 void contextualize(org.apache.avalon.framework.context.Context context)
          Contextualize this class.
 void dispose()
          Release all resources.
 void generate()
          Generate xml content describing search results.
 void initialize()
           
 void recycle()
          Recycle the generator
 void setup(SourceResolver resolver, java.util.Map objectModel, java.lang.String src, org.apache.avalon.framework.parameters.Parameters par)
          setup all members of this generator.
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

namespace

protected static final java.lang.String namespace
The XML namespace for the output document.

xlinkNamespace

protected static final java.lang.String xlinkNamespace
The XML namespace for xlink

CDATA

protected static final java.lang.String CDATA
Description of the Field

RESULTS_ELEMENT

protected static final java.lang.String RESULTS_ELEMENT
Root element of generated xml content, ie results.

DATE_ATTRIBUTE

protected static final java.lang.String DATE_ATTRIBUTE
Attribute date of results element. It contains the date a long value, indicating when a search generated this xml content.

QUERY_STRING_ATTRIBUTE

protected static final java.lang.String QUERY_STRING_ATTRIBUTE
Attribute query-string of results element. Echos the queryString query parameter.

START_INDEX_ATTRIBUTE

protected static final java.lang.String START_INDEX_ATTRIBUTE
Attribute start-index of results element. Echos the startIndex query parameter.

PAGE_LENGTH_ATTRIBUTE

protected static final java.lang.String PAGE_LENGTH_ATTRIBUTE
Attribute page-length of results element. Echos the pageLenth query parameter.

HITS_ELEMENT

protected static final java.lang.String HITS_ELEMENT
Child element of generated xml content, ie hits. This element describes all hits.

TOTAL_COUNT_ATTRIBUTE

protected static final java.lang.String TOTAL_COUNT_ATTRIBUTE
Attribute total-count of hits element. The value describes total number of hits found by the search engine.

COUNT_OF_PAGES_ATTRIBUTE

protected static final java.lang.String COUNT_OF_PAGES_ATTRIBUTE
Attribute count-of-pages of hits element. The value describes number of pages needed for all hits.

HIT_ELEMENT

protected static final java.lang.String HIT_ELEMENT
Child element of generated xml content, ie hit. This element describes a single hit.

RANK_ATTRIBUTE

protected static final java.lang.String RANK_ATTRIBUTE
Attribute rank of hit element. The value describes the count index of this hits, ranging between 0, and total-count minus 1.

SCORE_ATTRIBUTE

protected static final java.lang.String SCORE_ATTRIBUTE
Attribute score of hit element. The value describes the score of this hits, ranging between 0, and 1.0.

URI_ATTRIBUTE

protected static final java.lang.String URI_ATTRIBUTE
Attribute uri of hit element. The value describes the uri of a document matching the search query.

FIELD_ELEMENT

protected static final java.lang.String FIELD_ELEMENT
Child element field of the hit element. This element contains value of the stored field of a hit.
Since:
2.0.4

NAVIGATION_ELEMENT

protected static final java.lang.String NAVIGATION_ELEMENT
Child element of generated xml content, ie navigation. This element describes some hints for easier navigation.

NAVIGATION_PAGE_ELEMENT

protected static final java.lang.String NAVIGATION_PAGE_ELEMENT
Child element of generated xml content, ie navigation. This element describes the start-index of page containing hits.

HAS_NEXT_ATTRIBUTE

protected static final java.lang.String HAS_NEXT_ATTRIBUTE
Attribute has-next of navigation-page element. The value is true if a next navigation control should be presented.

HAS_PREVIOUS_ATTRIBUTE

protected static final java.lang.String HAS_PREVIOUS_ATTRIBUTE
Attribute has-next of navigation-page element. The value is true if a previous navigation control should be presented.

NEXT_INDEX_ATTRIBUTE

protected static final java.lang.String NEXT_INDEX_ATTRIBUTE
Attribute next-index of navigation-page element. The value describes the start-index of the next-to-be-presented page.

PREVIOUS_INDEX_ATTRIBUTE

protected static final java.lang.String PREVIOUS_INDEX_ATTRIBUTE
Attribute previous-index of navigation-page element. The value describes the start-index of the previous-to-be-presented page.

INDEX_PARAM

protected static final java.lang.String INDEX_PARAM
Setup parameter name of index directory, ie index.

INDEX_PARAM_DEFAULT

protected static final java.lang.String INDEX_PARAM_DEFAULT
Default value of setup parameter index, ie index.

QUERY_STRING_PARAM

protected static final java.lang.String QUERY_STRING_PARAM
Setup parameter name specifying the name of query-string query parameter, ie query-string.

QUERY_STRING_PARAM_DEFAULT

protected static final java.lang.String QUERY_STRING_PARAM_DEFAULT
Default value of setup parameter query-string, ie queryString.

START_INDEX_PARAM

protected static final java.lang.String START_INDEX_PARAM
Setup parameter name specifying the name of start-index query parameter, ie start-index.

START_INDEX_PARAM_DEFAULT

protected static final java.lang.String START_INDEX_PARAM_DEFAULT
Default value of setup parameter start-index, ie startIndex.

START_INDEX_NEXT_PARAM

protected static final java.lang.String START_INDEX_NEXT_PARAM
Setup parameter name specifying the name of start-next-index query parameter, ie start-next-index.

START_INDEX_NEXT_PARAM_DEFAULT

protected static final java.lang.String START_INDEX_NEXT_PARAM_DEFAULT
Default value of setup parameter start-next-index, ie startNextIndex.

START_INDEX_PREVIOUS_PARAM

protected static final java.lang.String START_INDEX_PREVIOUS_PARAM
Setup parameter name specifying the name of start-previous-index query parameter, ie start-previous-index.

START_INDEX_PREVIOUS_PARAM_DEFAULT

protected static final java.lang.String START_INDEX_PREVIOUS_PARAM_DEFAULT
Default value of setup parameter start-previous-index, ie startPreviousIndex.

START_INDEX_DEFAULT

protected static final int START_INDEX_DEFAULT
Description of the Field
Since:
 

PAGE_LENGTH_PARAM

protected static final java.lang.String PAGE_LENGTH_PARAM
Setup parameter name specifying the name of page-length query parameter, ie page-length.

PAGE_LENGTH_PARAM_DEFAULT

protected static final java.lang.String PAGE_LENGTH_PARAM_DEFAULT
Description of the Field
Since:
 

PAGE_LENGTH_DEFAULT

protected static final int PAGE_LENGTH_DEFAULT
Description of the Field
Since:
 
Constructor Detail

SearchGenerator

public SearchGenerator()
Method Detail

compose

public void compose(org.apache.avalon.framework.component.ComponentManager manager)
             throws org.apache.avalon.framework.component.ComponentException
Set the current ComponentManager instance used by this Composable.
Overrides:
compose in class ComposerGenerator

setup

public void setup(SourceResolver resolver,
                  java.util.Map objectModel,
                  java.lang.String src,
                  org.apache.avalon.framework.parameters.Parameters par)
           throws ProcessingException,
                  org.xml.sax.SAXException,
                  java.io.IOException
setup all members of this generator.
Overrides:
setup in class AbstractGenerator
Since:
 

contextualize

public void contextualize(org.apache.avalon.framework.context.Context context)
                   throws org.apache.avalon.framework.context.ContextException
Contextualize this class.

Especially retrieve the work directory. If the index directory is specified relativly, the working directory is used as home directory of the index directory.

Specified by:
contextualize in interface org.apache.avalon.framework.context.Contextualizable
Parameters:
context - Context to use
Throws:
org.apache.avalon.framework.context.ContextException - If contextualizing fails.
Since:
 

initialize

public void initialize()
                throws java.io.IOException
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable

generate

public void generate()
              throws java.io.IOException,
                     org.xml.sax.SAXException,
                     ProcessingException
Generate xml content describing search results. Entry point of the ComposerGenerator. The xml content is generated from the hits object.
Throws:
java.io.IOException - when there is a problem reading the from file system.
org.xml.sax.SAXException - when there is a problem creating the output SAX events.
ProcessingException - when there is a problem obtaining the hits
Since:
 

recycle

public void recycle()
Recycle the generator
Overrides:
recycle in class AbstractGenerator

dispose

public void dispose()
Description copied from class: ComposerGenerator
Release all resources.
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable
Overrides:
dispose in class ComposerGenerator


Copyright � 1999-2002 Apache Software Foundation. All Rights Reserved.