cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation EffectPipe.java EffectWidgetReplacingPipe.java WoodyTemplateTransformer.java
Date Mon, 05 Jan 2004 16:59:39 GMT
vgritsenko    2004/01/05 08:59:39

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/transformation
                        EffectPipe.java EffectWidgetReplacingPipe.java
                        WoodyTemplateTransformer.java
  Log:
  Make handlers final. Other minor tweaks.
  
  Revision  Changes    Path
  1.5       +4 -2      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation/EffectPipe.java
  
  Index: EffectPipe.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation/EffectPipe.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EffectPipe.java	1 Jan 2004 15:11:22 -0000	1.4
  +++ EffectPipe.java	5 Jan 2004 16:59:39 -0000	1.5
  @@ -239,7 +239,9 @@
           public void attributes() throws SAXException { attributes(input.attrs); }
   
           public void startElement() throws SAXException {
  -            if (element.attrs == null) element.attrs = Constants.EMPTY_ATTRS;
  +            if (element.attrs == null) {
  +                element.attrs = Constants.EMPTY_ATTRS;
  +            }
               super.startElement(element.uri, element.loc, element.raw, element.attrs);
               elements.addFirst(element);
               element = null;
  
  
  
  1.4       +50 -41    cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation/EffectWidgetReplacingPipe.java
  
  Index: EffectWidgetReplacingPipe.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation/EffectWidgetReplacingPipe.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EffectWidgetReplacingPipe.java	29 Dec 2003 17:52:12 -0000	1.3
  +++ EffectWidgetReplacingPipe.java	5 Jan 2004 16:59:39 -0000	1.4
  @@ -111,37 +111,27 @@
       protected Widget widget;
       protected Map classes;
   
  -    private DocHandler            docHandler            = new DocHandler();
  -    private FormHandler           formHandler           = new FormHandler();
  -    private NestedHandler         nestedHandler         = new NestedHandler();
  -    private WidgetLabelHandler    widgetLabelHandler    = new WidgetLabelHandler();
  -    private WidgetHandler         widgetHandler         = new WidgetHandler();
  -    private RepeaterSizeHandler   repeaterSizeHandler   = new RepeaterSizeHandler();
  -    private RepeaterWidgetLabelHandler repeaterWidgetLabelHandler = new RepeaterWidgetLabelHandler();
  -    private RepeaterWidgetHandler repeaterWidgetHandler = new RepeaterWidgetHandler();
  -    private StructHandler         structHandler         = new StructHandler();
  -    private UnionHandler          unionHandler          = new UnionHandler();
  -    private UnionPassThruHandler  unionPassThruHandler  = new UnionPassThruHandler();
  -    private NewHandler            newHandler            = new NewHandler();
  -    private ClassHandler          classHandler          = new ClassHandler();
  -    private ContinuationIdHandler continuationIdHandler = new ContinuationIdHandler();
  -
  -    private Map templates = new HashMap(10,1);
  -    // Use an instance initializer to setup map of templates.
  -    {
  -        templates.put(WIDGET, widgetHandler);
  -        templates.put(WIDGET_LABEL, widgetLabelHandler);
  -        templates.put(REPEATER_WIDGET, repeaterWidgetHandler);
  -        templates.put(REPEATER_SIZE, repeaterSizeHandler);
  -        templates.put(REPEATER_WIDGET_LABEL, repeaterWidgetLabelHandler);
  -        templates.put(STRUCT, structHandler);
  -        templates.put(UNION, unionHandler);
  -        templates.put(NEW, newHandler);
  -        templates.put(CLASS, classHandler);
  -        templates.put(CONTINUATION_ID, continuationIdHandler);
  -    }
  +    private final DocHandler                  docHandler            = new DocHandler();
  +    private final FormHandler                 formHandler           = new FormHandler();
  +    private final NestedHandler               nestedHandler         = new NestedHandler();
  +    private final WidgetLabelHandler          widgetLabelHandler    = new WidgetLabelHandler();
  +    private final WidgetHandler               widgetHandler         = new WidgetHandler();
  +    private final RepeaterSizeHandler         repeaterSizeHandler   = new RepeaterSizeHandler();
  +    private final RepeaterWidgetLabelHandler  repeaterWidgetLabelHandler = new RepeaterWidgetLabelHandler();
  +    private final RepeaterWidgetHandler       repeaterWidgetHandler = new RepeaterWidgetHandler();
  +    private final StructHandler               structHandler         = new StructHandler();
  +    private final UnionHandler                unionHandler          = new UnionHandler();
  +    private final UnionPassThruHandler        unionPassThruHandler  = new UnionPassThruHandler();
  +    private final NewHandler                  newHandler            = new NewHandler();
  +    private final ClassHandler                classHandler          = new ClassHandler();
  +    private final ContinuationIdHandler       continuationIdHandler = new ContinuationIdHandler();
  +    private final InsertStylingContentHandler stylingHandler        = new InsertStylingContentHandler();
  +
  +    /**
  +     * Map containing all handlers
  +     */
  +    private final Map templates = new HashMap(10, 1);
   
  -    protected InsertStylingContentHandler stylingHandler = new InsertStylingContentHandler();
       protected WoodyPipelineConfig pipeContext;
   
       /**
  @@ -149,18 +139,33 @@
        */
       protected boolean gotStylingElement;
   
  -    /** 
  +    /**
        * Namespace prefix used for the namespace <code>Constants.WT_NS</code>.
        */
       protected String namespacePrefix;
   
  +
  +    public EffectWidgetReplacingPipe() {
  +        // Setup map of templates.
  +        templates.put(WIDGET, widgetHandler);
  +        templates.put(WIDGET_LABEL, widgetLabelHandler);
  +        templates.put(REPEATER_WIDGET, repeaterWidgetHandler);
  +        templates.put(REPEATER_SIZE, repeaterSizeHandler);
  +        templates.put(REPEATER_WIDGET_LABEL, repeaterWidgetLabelHandler);
  +        templates.put(STRUCT, structHandler);
  +        templates.put(UNION, unionHandler);
  +        templates.put(NEW, newHandler);
  +        templates.put(CLASS, classHandler);
  +        templates.put(CONTINUATION_ID, continuationIdHandler);
  +    }
  +
       private void throwSAXException(String message) throws SAXException{
           throw new SAXException("EffectWoodyTemplateTransformer: " + message);
       }
   
  -    public void init(Widget newContextWidget, WoodyPipelineConfig newPipeContext) {
  +    public void init(Widget contextWidget, WoodyPipelineConfig pipeContext) {
           super.init();
  -        pipeContext = newPipeContext;
  +        this.pipeContext = pipeContext;
   
           // Attach document handler
           handler = docHandler;
  @@ -172,28 +177,31 @@
   
       protected String getWidgetId(Attributes attributes) throws SAXException {
           String widgetId = attributes.getValue("id");
  -        if (widgetId == null || widgetId.equals(""))
  +        if (widgetId == null || widgetId.equals("")) {
               throwSAXException("Missing required widget \"id\" attribute.");
  +        }
           return widgetId;
       }
   
       protected Widget getWidget(String widgetId) throws SAXException {
           Widget widget = contextWidget.getWidget(widgetId);
  -        if (widget == null)
  +        if (widget == null) {
               if (contextWidget.getFullyQualifiedId() == null) {
                   throwSAXException("Widget with id \"" + widgetId + "\" does not exist in
the form container.");
               } else {
                   throwSAXException("Widget with id \"" + widgetId + "\" does not exist in
the container \"" +
  -                    contextWidget.getFullyQualifiedId() + "\"");
  +                                  contextWidget.getFullyQualifiedId() + "\"");
               }
  +        }
           return widget;
       }
   
       protected void getRepeaterWidget(String handler) throws SAXException {
           widgetId = getWidgetId(input.attrs);
           widget = getWidget(widgetId);
  -        if (!(widget instanceof Repeater))
  +        if (!(widget instanceof Repeater)) {
               throwWrongWidgetType("RepeaterWidgetLabelHandler", input.loc, "repeater");
  +        }
       }
   
       public void throwWrongWidgetType(String pipeName, String element, String widget) throws
SAXException {
  @@ -202,7 +210,7 @@
   
       public Handler nestedTemplate() throws SAXException {
           if (Constants.WT_NS.equals(input.uri)) {
  -            // Element in woody namespace.
  +            // Element in woody template namespace.
               Handler handler = (Handler)templates.get(input.loc);
               if (handler != null) {
                   return handler;
  @@ -458,8 +466,9 @@
               case EVENT_START_ELEMENT:
                   widgetId = getWidgetId(input.attrs);
                   widget = getWidget(widgetId);
  -                if (!(widget instanceof Struct))
  +                if (!(widget instanceof Struct)) {
                       throwWrongWidgetType("StructHandler", input.loc, "struct");
  +                }
                   contextWidgets.addFirst(contextWidget);
                   contextWidget = widget;
                   out.element(Constants.WI_PREFIX, Constants.WI_NS, "struct");
  @@ -527,7 +536,7 @@
               case EVENT_ELEMENT:
                   if (Constants.WT_NS.equals(input.uri)) {
                       if ("case".equals(input.loc)) {
  -                        if (((String)((Union)contextWidget).getValue()).equals(input.attrs.getValue("id")))
{
  +                        if (((Union)contextWidget).getValue().equals(input.attrs.getValue("id")))
{
                               return nestedHandler;
                           } else {
                               return nullHandler;
  
  
  
  1.10      +10 -21    cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation/WoodyTemplateTransformer.java
  
  Index: WoodyTemplateTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation/WoodyTemplateTransformer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- WoodyTemplateTransformer.java	29 Dec 2003 06:14:49 -0000	1.9
  +++ WoodyTemplateTransformer.java	5 Jan 2004 16:59:39 -0000	1.10
  @@ -50,18 +50,17 @@
   */
   package org.apache.cocoon.woody.transformation;
   
  -import java.io.IOException;
  -import java.util.Locale;
  -import java.util.Map;
  -
  -import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.transformation.Transformer;
  -import org.apache.commons.jxpath.JXPathContext;
  +
  +import org.apache.avalon.framework.parameters.Parameters;
  +
   import org.xml.sax.SAXException;
   
  +import java.io.IOException;
  +import java.util.Map;
  +
   /**
    * See description of {@link WidgetReplacingPipe}.
    * 
  @@ -69,20 +68,10 @@
    */
   public class WoodyTemplateTransformer extends EffectWidgetReplacingPipe implements Transformer
{
   
  -    /** Name of the request attribute under which the Woody form is stored (optional).
*/
  -    private String attributeName;
  -    private Request request;
  -    private JXPathContext jxpathContext;
  -    /** Containts locale specified as a parameter to the transformer, if any. */
  -    private Locale localeParameter;
  -    /** The locale currently used by the transformer. */
  -    private Locale locale;
  -
       public void setup(SourceResolver resolver, Map objectModel, String src, Parameters
parameters)
  -            throws ProcessingException, SAXException, IOException {
  +    throws ProcessingException, SAXException, IOException {
   
  -        // FIXME: Duplicate code above and in createConfig
  -        WoodyPipelineConfig pipeContext = WoodyPipelineConfig.createConfig(objectModel,
parameters); 
  -        init(null, pipeContext);
  +        WoodyPipelineConfig pipeContext = WoodyPipelineConfig.createConfig(objectModel,
parameters);
  +        super.init(null, pipeContext);
       }
   }
  
  
  

Mime
View raw message