MainJavadocExample
HTMLFilter Example

The HTMLFilter is a special type of String Filter that is used for HTML pages that are imported into an application and need to be edited to work properly in the new context.

It is used in this application to synchronize the Javadoc pages generated by the Sun Javadoc utility with the Framework XML data that organizes this application - shown by the screen capture from this application below. Specifically, the filter ensures that all hyperlinks are routed back to the JSP page that adds the tab set and that an "Example" tab is added for any class that has an example page.

The HTMLFilter and its contained ModifyAttributeFilter HTML event processor are configured in this example to rewrite all hyperlinks ("a" tags) so that the tab controls are maintained and "Example" tabs are added for classes that have associated example pages. This latter function is handled by the contained LookupStringFilter.

The ModifyAttributeFilter is an HTMLEventProcessor that can alter HTML tag attributes. In this example, it is configured to use an RTI StringFilter to do the attribute modification. This is a composite filter with several elements:


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>