MainJavadocExample
LookupStringFilter Demo

The LookupStringFilter can be used to replace an input string with a value that is obtained from some search source by using the input string as a query value.

In this example, The LookupStringFilter is part of the HTMLFilter configuration that is used to provide class-specific "Example" tabs (like the one seen above) for the class Javadocs in this application for which Example pages have been written. It uses the LookupSearchSource configured to detect the framework Tree nodes that have "Example" links. This enables Example links to be configured once and then automatically detected when the class name occurs in a javadoc page (in the subclass section or due to an explicit link coded in the comments). So that when the user clicks on the class javadoc link, the "Example" tab will be added to the tab set on the target javadoc page.


XML Configuration for this example.

  <!-- ============================================================================= -->
  <!--   HTMLFilter used to synchronize the Javadoc pages with the navigation tabs   -->
  <!--   and Example jsp pages. The filter uses data contained in the Framework      -->
  <!--   Framework Tree XML to determine which classes have associated example       -->
  <!--   pages by querying the LookupSearchSource (ExampleTreeSource) built from the -->
  <!--   XML configuration data.                                                     -->
  <!-- ============================================================================= -->              
  <SystemObject type="StringFilter" name="FixJavadocFilter"
                configurableClass="com.raritantechnologies.HTML.filter.HTMLFilter" >

    <EventProcessor class="com.raritantechnologies.HTML.filter.ModifyAttributeFilter"
                    tagName="a"
                    attributeName="href" >

     <StringFilter class="com.raritantechnologies.utils.filter.SequentialStringFilter" >

        <StringFilter class="com.raritantechnologies.utils.filter.RegExprStringFilter"
                      inPattern="(.*)/com/raritantechnologies(.*)"
                      outPattern="/FrameworkDocumentation/JavadocPage.jsp?javadoc=/doc/com/raritantechnologies$2" />

        <StringFilter class="com.raritantechnologies.utils.filter.ConcatenateFilter" >

          <!-- ======================================================================= -->
          <!--   The LookupStringFilter uses the ExampleTreeSource to determine which  -->
          <!--   class links in a Javadoc page have associated Example pages. (The     -->
          <!--   RegExprStringFilter is used to extract the class name from the input  -->
          <!--   href path to be used as a query value to the LookupSearchSource).  If -->
          <!--   the result has an ExampleLink/href attribute, this link will          -->
          <!--   be appended to the final output of the composite string filter with   -->
          <!--   the appropriate http request parameter prepended.                     -->
          <!-- ======================================================================= -->
          <AppendFilter class="com.raritantechnologies.utils.filter.LookupStringFilter"
                        searchSource="ExampleTreeSource"
                        queryField="name"
                        outputField="ExampleLink/href"
                        returnOnNull="EMPTY" >

            <InputFilter class="com.raritantechnologies.utils.filter.RegExprStringFilter"
                         inPattern="(.*)/([A-Za-z]*)\.html"
                         outPattern="$2" />

            <OutputFilter class="com.raritantechnologies.utils.filter.ConcatenateFilter"
                          prependString="&example=" />
          </AppendFilter>

        </StringFilter>
      </StringFilter>

    </EventProcessor>
  </SystemObject>


The LookupStringFilter is also used in the HTMLScraperPageImportRenderer Demo. In this case, an HTMLSearchSource is used to convert a drug name into a chemical "SMILES" string by executing a search on the NIH PubChem site:

XML Configuration for the LookupStringFilter:
    <!-- =========================================================== -->
    <!-- LookupStringFilter is used to Convert drug to SMILES String -->
    <!-- by executing a search against the PubChem site.             -->
    <!-- =========================================================== -->
    <Field ID="drug"    xPath="/SearchProcess/Step/params/param[@formName='simple_searchdata']/@value" >
      <StringFilter class="com.raritantechnologies.utils.filter.LookupStringFilter"
                    searchSource="PubChemSmilesFinder"
                    queryField="drug"
                    outputField="Smiles" />
    </Field>