bloritsch    01/07/10 12:50:07

  Modified:    src/org/apache/cocoon/acting Tag: cocoon_20_branch
                        AbstractDatabaseAction.java
               src/org/apache/cocoon/transformation Tag: cocoon_20_branch
                        FilterTransformer.java
  Log:
  Prepare FilterTransformer to be able to be sublcassed.  Also perform some
  optimizations on configtime.  The FilterTransformer does need to support
  namespaces as well as elements....
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.7.2.2   +4 -4      
xml-cocoon2/src/org/apache/cocoon/acting/AbstractDatabaseAction.java
  
  Index: AbstractDatabaseAction.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/acting/AbstractDatabaseAction.java,v
  retrieving revision 1.7.2.1
  retrieving revision 1.7.2.2
  diff -u -r1.7.2.1 -r1.7.2.2
  --- AbstractDatabaseAction.java       2001/07/07 19:07:39     1.7.2.1
  +++ AbstractDatabaseAction.java       2001/07/10 19:49:56     1.7.2.2
  @@ -51,7 +51,7 @@
    * <pre>
    *   &lt;root&gt;
    *     &lt;connection&gt;personnel&lt;connection&gt;
  - *     &lt;table&gt;
  + *     &lt;table name="employee"&gt;
    *       &lt;keys&gt;
    *         &lt;key param="id" dbcol="id" type="int"/&gt;
    *       &lt;/keys&gt;
  @@ -158,7 +158,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Donald Ball</a>
  - * @version CVS $Revision: 1.7.2.1 $ $Date: 2001/07/07 19:07:39 $
  + * @version CVS $Revision: 1.7.2.2 $ $Date: 2001/07/10 19:49:56 $
    */
   public abstract class AbstractDatabaseAction extends 
AbstractComplementaryConfigurableAction implements Configurable, Disposable {
       protected Map files = new HashMap();
  @@ -167,7 +167,7 @@
   
       static {
           /** Initialize the map of type names to jdbc column types.
  -            Note that INTEGER, BLOB, and VARCHAR column types map to more than 
  +            Note that INTEGER, BLOB, and VARCHAR column types map to more than
               one type name. **/
           Map constants = new HashMap();
           constants.put("ascii", new Integer(Types.CLOB));
  @@ -317,7 +317,7 @@
       /**
        * Set the Statement column so that the results are mapped correctly. The
        * value of the column is retrieved from the request object. If the
  -     * named parameter exists in the request object's parameters, that value 
  +     * named parameter exists in the request object's parameters, that value
        * is used. Otherwise if the named parameter exists in the request object's
        * attributes, that value is used. Otherwise the request object is
        * retrieved using Request.get(attribute), which is documented to be the
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +15 -30    
xml-cocoon2/src/org/apache/cocoon/transformation/FilterTransformer.java
  
  Index: FilterTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/FilterTransformer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- FilterTransformer.java    2001/07/10 14:04:55     1.1.2.1
  +++ FilterTransformer.java    2001/07/10 19:50:04     1.1.2.2
  @@ -12,7 +12,7 @@
   import org.xml.sax.helpers.AttributesImpl;
   
   /**
  - * The filter transformer can be used to let only an amount of elements through in 
  + * The filter transformer can be used to let only an amount of elements through in
    * a given block.
    *
    * Usage in sitemap
  @@ -25,7 +25,7 @@
    * Only the 3th block will be shown, containing only 5 row elements.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sven Beauprez</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2001/07/10 14:04:55 $ $Author: dims $
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/07/10 19:50:04 $ $Author: 
bloritsch $
    */
   
   public class FilterTransformer extends AbstractTransformer implements Poolable {
  @@ -41,7 +41,7 @@
     private int count;
     private int blocknr;
     private int currentBlocknr;
  -  private String elementName;
  +  protected String elementName;
     private String parentName;
     boolean skip;
     boolean foundIt;
  @@ -54,35 +54,20 @@
       skip=false;
       foundIt=false;
       parentName=null;
  -    elementName = parameters.getParameter(FilterTransformer.ELEMENT,null);
  -    String tmpCount = 
parameters.getParameter(FilterTransformer.COUNT,""+FilterTransformer.DEFAULT_COUNT);
  -    String tmpBlockNr = 
parameters.getParameter(FilterTransformer.BLOCKNR,""+FilterTransformer.DEFAULT_BLOCK);
  -    if (elementName==null || tmpCount==null)  {
  -      getLogger().error("FilterTransformer: both "+ FilterTransformer.ELEMENT + " 
and " +
  -                        FilterTransformer.COUNT + " parameters need to be 
specified");
  -    }else  {
  -      try  {
  -        count = Integer.parseInt(tmpCount);
  -        getLogger().debug("FilterTransformer: " + FilterTransformer.COUNT + "=" + 
count);
  -      }  catch (NumberFormatException e)  {
  -        //set default values so we can move on
  -        count=FilterTransformer.DEFAULT_COUNT;      
  -        getLogger().error("FilterTransformer: " + FilterTransformer.COUNT + 
  -                          " not valid, using default value of 
"+FilterTransformer.DEFAULT_COUNT);
  -      }
  -      try  {
  -        blocknr = Integer.parseInt(tmpBlockNr);
  -        getLogger().debug("FilterTransformer: " + FilterTransformer.BLOCKNR + "=" + 
blocknr);
  -      } catch (NumberFormatException e)  {
  -        //set default values so we can move on
  -        blocknr=FilterTransformer.DEFAULT_BLOCK;
  -        getLogger().error("FilterTransformer: " + FilterTransformer.BLOCKNR + 
  -                          " not valid, using default value of "+ 
FilterTransformer.DEFAULT_BLOCK);
  -      }
  +    elementName = parameters.getParameter(FilterTransformer.ELEMENT, "");
  +    count = parameters.getParameterAsInteger(FilterTransformer.COUNT, 
FilterTransformer.DEFAULT_COUNT);
  +    blocknr = parameters.getParameterAsInteger(FilterTransformer.BLOCKNR, 
FilterTransformer.DEFAULT_BLOCK);
  +    if (elementName == null || count == 0)  {
  +        getLogger().warn("FilterTransformer: both "+ FilterTransformer.ELEMENT + " 
and " +
  +                          FilterTransformer.COUNT + " parameters need to be 
specified");
       }
     }
     /** END SitemapComponent methods **/
   
  +  protected boolean isSkipping() {
  +      return skip;
  +  }
  +
     /** BEGIN SAX ContentHandler handlers **/
     public void startElement(String uri, String name, String raw, Attributes 
attributes)
     throws SAXException {
  @@ -114,8 +99,8 @@
   
     public void endElement(String uri,String name,String raw)
     throws SAXException  {
  -    if (name.equalsIgnoreCase(parentName) && foundIt) {
  -      
  +    if (name.equals(parentName) && foundIt) {
  +
         
super.contentHandler.endElement(uri,FilterTransformer.BLOCK,FilterTransformer.BLOCK);
         super.contentHandler.endElement(uri,name,raw);
         foundIt=false;
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to