You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Christopher Oliver <re...@verizon.net> on 2003/09/25 07:02:40 UTC

Re: cvs commit: cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation XMLFormTransformer.java

Carsten,

Please do _not_ arbitrarily change private fields and methods to 
protected. JXTemplateGenerator and JXFormsGenerator are _not_ intended 
to be extended. If you think you have a need to extend them please 
express the problem you are trying to solve before making such changes.

Thanks for your consideration,

Chris

cziegeler@apache.org wrote:

>cziegeler    2003/09/24 15:04:40
>
>  Modified:    src/java/org/apache/cocoon/generation
>                        JXTemplateGenerator.java
>               src/blocks/jxforms/java/org/apache/cocoon/generation
>                        JXFormsGenerator.java
>               src/blocks/linkrewriter/java/org/apache/cocoon/transformation
>                        VariableRewriterTransformer.java
>                        LinkRewriterTransformer.java
>               src/blocks/xmlform/java/org/apache/cocoon/transformation
>                        XMLFormTransformer.java
>  Log:
>  Removing unused imports and casts
>  
>  Revision  Changes    Path
>  1.9       +3 -3      cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
>  
>  Index: JXTemplateGenerator.java
>  ===================================================================
>  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v
>  retrieving revision 1.8
>  retrieving revision 1.9
>  diff -u -r1.8 -r1.9
>  --- JXTemplateGenerator.java	3 Sep 2003 15:00:56 -0000	1.8
>  +++ JXTemplateGenerator.java	24 Sep 2003 22:04:40 -0000	1.9
>  @@ -2235,10 +2235,10 @@
>                                       null, locator);
>                       Expression currencyCode = 
>                           compileExpr(attrs.getValue("currencyCode"),
>  -                                    null, locator);;
>  +                                    null, locator);
>                       Expression currencySymbol = 
>                           compileExpr(attrs.getValue("currencySymbol"),
>  -                                    null, locator);;          
>  +                                    null, locator);       
>                       Expression isGroupingUsed =  
>                           compileBoolean(attrs.getValue("isGroupingUsed"), 
>                                          null, locator);
>  @@ -2281,7 +2281,7 @@
>                                       null, locator);           
>                       Expression value = 
>                           compileExpr(attrs.getValue("value"),
>  -                                    null, locator);;
>  +                                    null, locator);
>                       Expression type = 
>                           compileExpr(attrs.getValue("type"),
>                                       null, locator);
>  
>  
>  
>  1.5       +8 -12     cocoon-2.1/src/blocks/jxforms/java/org/apache/cocoon/generation/JXFormsGenerator.java
>  
>  Index: JXFormsGenerator.java
>  ===================================================================
>  RCS file: /home/cvs/cocoon-2.1/src/blocks/jxforms/java/org/apache/cocoon/generation/JXFormsGenerator.java,v
>  retrieving revision 1.4
>  retrieving revision 1.5
>  diff -u -r1.4 -r1.5
>  --- JXFormsGenerator.java	5 Sep 2003 07:21:48 -0000	1.4
>  +++ JXFormsGenerator.java	24 Sep 2003 22:04:40 -0000	1.5
>  @@ -88,7 +88,7 @@
>   
>   public class JXFormsGenerator extends ServiceableGenerator {
>   
>  -    private static final JXPathContextFactory 
>  +    protected static final JXPathContextFactory 
>           jxpathContextFactory = JXPathContextFactory.newInstance();
>   
>       private static final Attributes EMPTY_ATTRS = new AttributesImpl();
>  @@ -104,7 +104,7 @@
>               }
>           };
>   
>  -    private static final Locator NULL_LOCATOR = new LocatorImpl();
>  +    protected static final Locator NULL_LOCATOR = new LocatorImpl();
>   
>       public final static String NS = 
>           "http://apache.org/cocoon/jxforms/1.0";
>  @@ -235,7 +235,7 @@
>        * Compile a single XPath expression
>        */
>   
>  -    static private XPathExpr
>  +    static protected XPathExpr
>           compileExpr(String expr, Locator location) 
>           throws SAXParseException {
>           if (expr == null) return null;
>  @@ -451,7 +451,7 @@
>           HINT, VALUE, HELP, LABEL
>       };
>   
>  -    private static boolean isInputControl(String name) {
>  +    protected static boolean isInputControl(String name) {
>           for (int i = 0; i < INPUT_CONTROLS.length; i++) {
>               if (INPUT_CONTROLS[i].equals(name)) {
>                   return true;
>  @@ -460,7 +460,7 @@
>           return false;
>       }
>   
>  -    private static boolean isReadonlyInputControl(String name) {
>  +    protected static boolean isReadonlyInputControl(String name) {
>           for (int i = 0; i < READONLY_INPUT_CONTROLS.length; i++) {
>               if (READONLY_INPUT_CONTROLS[i].equals(name)) {
>                   return true;
>  @@ -1175,10 +1175,9 @@
>       private XMLConsumer consumer;
>       private Source inputSource;
>       private WebContinuation kont;
>  -    private Object bean;
>       private Map objectModel;
>   
>  -    private XMLConsumer getConsumer() {
>  +    protected XMLConsumer getConsumer() {
>           return consumer;
>       }
>   
>  @@ -1186,7 +1185,6 @@
>           super.recycle();
>           consumer = null;
>           inputSource = null;
>  -        bean = null;
>           kont = null;
>           objectModel = null;
>       }
>  @@ -1212,7 +1210,6 @@
>                   }
>               }
>           }
>  -        bean = FlowHelper.getContextObject(objectModel);
>           kont = FlowHelper.getWebContinuation(objectModel);
>           this.objectModel = objectModel;
>       }
>  @@ -1248,7 +1245,7 @@
>                   null);
>       }
>   
>  -    private void execute(final XMLConsumer consumer,
>  +    protected void execute(final XMLConsumer consumer,
>                            Form form,
>                            String currentView,
>                            String contextPath,
>  @@ -1269,8 +1266,7 @@
>                   consumer.endDocument();
>               } else if (ev instanceof EndElement) {
>                   EndElement endElement = (EndElement)ev;
>  -                StartElement startElement = 
>  -                    (StartElement)endElement.startElement;
>  +                StartElement startElement = endElement.startElement;
>                   consumer.endElement(startElement.namespaceURI,
>                                       startElement.localName,
>                                       startElement.raw);
>  
>  
>  
>  1.4       +1 -6      cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoon/transformation/VariableRewriterTransformer.java
>  
>  Index: VariableRewriterTransformer.java
>  ===================================================================
>  RCS file: /home/cvs/cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoon/transformation/VariableRewriterTransformer.java,v
>  retrieving revision 1.3
>  retrieving revision 1.4
>  diff -u -r1.3 -r1.4
>  --- VariableRewriterTransformer.java	24 Mar 2003 14:33:56 -0000	1.3
>  +++ VariableRewriterTransformer.java	24 Sep 2003 22:04:40 -0000	1.4
>  @@ -184,9 +184,6 @@
>       private Set inSchemes;
>       private Set outSchemes;
>   
>  -    /** Links matching one of the acceptable schemes. */
>  -    private Set links;
>  -
>       /** Configuration passed to the component once through configure(). */
>       private Configuration origConf; 
>   
>  @@ -224,7 +221,6 @@
>           throws ProcessingException, SAXException, IOException
>       {
>           super.setup(resolver, objectModel, src, parameters);
>  -        this.links = new HashSet();
>           this.badLinkStr = parameters.getParameter("bad-link-str", null);
>           this.linkAttrs = split(parameters.getParameter("link-attrs", "href"), " ");
>           this.inSchemes = split(parameters.getParameter("schemes", ""), " ");
>  @@ -370,7 +366,6 @@
>       public void recycle() {
>           super.recycle();
>           this.resolver = null;
>  -        this.links = null;
>           this.linkAttrs = null;
>           this.inSchemes = null;
>           this.outSchemes = null;
>  
>  
>  
>  1.8       +1 -6      cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoon/transformation/LinkRewriterTransformer.java
>  
>  Index: LinkRewriterTransformer.java
>  ===================================================================
>  RCS file: /home/cvs/cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoon/transformation/LinkRewriterTransformer.java,v
>  retrieving revision 1.7
>  retrieving revision 1.8
>  diff -u -r1.7 -r1.8
>  --- LinkRewriterTransformer.java	19 Jun 2003 11:31:05 -0000	1.7
>  +++ LinkRewriterTransformer.java	24 Sep 2003 22:04:40 -0000	1.8
>  @@ -194,9 +194,6 @@
>       private Set inSchemes;
>       private Set outSchemes;
>   
>  -    /** Links matching one of the acceptable schemes. */
>  -    private Set links;
>  -
>       /** Configuration passed to the component once through configure(). */
>       private Configuration origConf; 
>   
>  @@ -235,7 +232,6 @@
>           throws ProcessingException, SAXException, IOException
>       {
>           super.setup(resolver, objectModel, src, parameters);
>  -        this.links = new HashSet();
>           this.badLinkStr = parameters.getParameter("bad-link-str",    // per-request config
>                   origConf.getChild("bad-link-str"). // else fall back to per-instance config
>                   getValue(null)                     // else use hardcoded default
>  @@ -277,7 +273,6 @@
>       public void recycle() {
>           super.recycle();
>           this.resolver = null;
>  -        this.links = null;
>           this.linkAttrs = null;
>           this.inSchemes = null;
>           this.outSchemes = null;
>  
>  
>  
>  1.8       +1 -2      cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation/XMLFormTransformer.java
>  
>  Index: XMLFormTransformer.java
>  ===================================================================
>  RCS file: /home/cvs/cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
>  retrieving revision 1.7
>  retrieving revision 1.8
>  diff -u -r1.7 -r1.8
>  --- XMLFormTransformer.java	4 Aug 2003 03:16:34 -0000	1.7
>  +++ XMLFormTransformer.java	24 Sep 2003 22:04:40 -0000	1.8
>  @@ -580,7 +580,6 @@
>               getLogger().error(error);
>               throw new IllegalStateException(error);
>           }
>  -        ;
>   
>           formStack.push(currentForm);
>   
>  
>  
>  
>
>  
>



Re: cvs commit: cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation XMLFormTransformer.java

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Stefano Mazzocchi dijo:
>
> On Thursday, Sep 25, 2003, at 19:31 Europe/Rome, Christopher Oliver
> wrote:
>
>>> If you don't want that someone inherits from these classes make them
>>> final.
>>>
>>> Carsten
>>>
>> I cound do that but then you (or another developer) could simply
>> remove it.
>
> True, but if something is marked final, I'm sure people will be wise
> enough to ask around before changing it.

OK. Then the short answer is:

"Add a comment on the code why it is marked as final. I think it would be
the best to avoid other people to remove the final attribute of your
class."

Best Regards,

Antonio Gallardo.




Re: cvs commit: cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation XMLFormTransformer.java

Posted by Stefano Mazzocchi <st...@apache.org>.
On Thursday, Sep 25, 2003, at 19:31 Europe/Rome, Christopher Oliver 
wrote:

>> If you don't want that someone inherits from these classes make them 
>> final.
>>
>> Carsten
>>
> I cound do that but then you (or another developer) could simply 
> remove it.

True, but if something is marked final, I'm sure people will be wise 
enough to ask around before changing it.

--
Stefano.


RE: cvs commit: cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation XMLFormTransformer.java

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Christopher Oliver wrote:
> Carsten Ziegeler wrote:
>
> >Hi Christopher,
> >
> >I did make this change because of inheritance. The private fields/methods
> >very called from an inner class. This makes the compiler to
> create accessor
> >methods for the private fields so that the inner classes can reach
> >the private fields. Changing the fields to protected avoids this
> unnecessary
> >accessor methods.
> >
> OK. But that doesn't make sense (at least to me). Why should protected
> fields be accessible to inner classes but not private ones (inner
> classes do not extend the enclosing class)? Can you point me to where
> you got this information?
>
Oh, it's something I read a long time ago somewhere. I really don't
remember. But as a small hint, the Eclipse IDE gives you some nice
warnings at these places (if configured).

> >If you don't want that someone inherits from these classes make
> them final.
> >
> I cound do that but then you (or another developer) could simply remove
> it.
>
Yes, of course :) But if someone wants to change it he will have a good
reason for it and perhaps ask beforehand. And a comment in the class
could help as well.

Now, if you think that's better the way it was before, I can simply
revert the changes and try to ignore the warnings from Eclipse. No
problem with that.

Carsten


Re: cvs commit: cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation XMLFormTransformer.java

Posted by Christopher Oliver <re...@verizon.net>.
Carsten Ziegeler wrote:

>Hi Christopher,
>
>I did make this change because of inheritance. The private fields/methods
>very called from an inner class. This makes the compiler to create accessor
>methods for the private fields so that the inner classes can reach
>the private fields. Changing the fields to protected avoids this unnecessary
>accessor methods.
>
OK. But that doesn't make sense (at least to me). Why should protected 
fields be accessible to inner classes but not private ones (inner 
classes do not extend the enclosing class)? Can you point me to where 
you got this information?

>If you don't want that someone inherits from these classes make them final.
>
>Carsten
>
I cound do that but then you (or another developer) could simply remove 
it.  

>  
>
>>-----Original Message-----
>>From: Christopher Oliver [mailto:res1cf5x@verizon.net]
>>Sent: Thursday, September 25, 2003 7:03 AM
>>To: dev@cocoon.apache.org
>>Cc: cziegler@apache.org
>>Subject: Re: cvs commit:
>>cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation
>>XMLFormTransformer.java
>>
>>
>>Carsten,
>>
>>Please do _not_ arbitrarily change private fields and methods to
>>protected. JXTemplateGenerator and JXFormsGenerator are _not_ intended
>>to be extended. If you think you have a need to extend them please
>>express the problem you are trying to solve before making such changes.
>>
>>Thanks for your consideration,
>>
>>Chris
>>
>>cziegeler@apache.org wrote:
>>
>>    
>>
>>>cziegeler    2003/09/24 15:04:40
>>>
>>> Modified:    src/java/org/apache/cocoon/generation
>>>                       JXTemplateGenerator.java
>>>              src/blocks/jxforms/java/org/apache/cocoon/generation
>>>                       JXFormsGenerator.java
>>>
>>>      
>>>
>>src/blocks/linkrewriter/java/org/apache/cocoon/transformation
>>    
>>
>>>                       VariableRewriterTransformer.java
>>>                       LinkRewriterTransformer.java
>>>              src/blocks/xmlform/java/org/apache/cocoon/transformation
>>>                       XMLFormTransformer.java
>>> Log:
>>> Removing unused imports and casts
>>>
>>> Revision  Changes    Path
>>> 1.9       +3 -3
>>>      
>>>
>>cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
>>    
>>
>>> Index: JXTemplateGenerator.java
>>> ===================================================================
>>> RCS file:
>>>      
>>>
>>/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTempl
>>ateGenerator.java,v
>>    
>>
>>> retrieving revision 1.8
>>> retrieving revision 1.9
>>> diff -u -r1.8 -r1.9
>>> --- JXTemplateGenerator.java	3 Sep 2003 15:00:56 -0000	1.8
>>> +++ JXTemplateGenerator.java	24 Sep 2003 22:04:40 -0000	1.9
>>> @@ -2235,10 +2235,10 @@
>>>                                      null, locator);
>>>                      Expression currencyCode =
>>>                          compileExpr(attrs.getValue("currencyCode"),
>>> -                                    null, locator);;
>>> +                                    null, locator);
>>>                      Expression currencySymbol =
>>>                          compileExpr(attrs.getValue("currencySymbol"),
>>> -                                    null, locator);;
>>> +                                    null, locator);
>>>                      Expression isGroupingUsed =
>>>
>>>      
>>>
>>compileBoolean(attrs.getValue("isGroupingUsed"),
>>    
>>
>>>                                         null, locator);
>>> @@ -2281,7 +2281,7 @@
>>>                                      null, locator);
>>>                      Expression value =
>>>                          compileExpr(attrs.getValue("value"),
>>> -                                    null, locator);;
>>> +                                    null, locator);
>>>                      Expression type =
>>>                          compileExpr(attrs.getValue("type"),
>>>                                      null, locator);
>>>
>>>
>>>
>>> 1.5       +8 -12
>>>      
>>>
>>cocoon-2.1/src/blocks/jxforms/java/org/apache/cocoon/generation/JX
>>FormsGenerator.java
>>    
>>
>>> Index: JXFormsGenerator.java
>>> ===================================================================
>>> RCS file:
>>>      
>>>
>>/home/cvs/cocoon-2.1/src/blocks/jxforms/java/org/apache/cocoon/gen
>>eration/JXFormsGenerator.java,v
>>    
>>
>>> retrieving revision 1.4
>>> retrieving revision 1.5
>>> diff -u -r1.4 -r1.5
>>> --- JXFormsGenerator.java	5 Sep 2003 07:21:48 -0000	1.4
>>> +++ JXFormsGenerator.java	24 Sep 2003 22:04:40 -0000	1.5
>>> @@ -88,7 +88,7 @@
>>>
>>>  public class JXFormsGenerator extends ServiceableGenerator {
>>>
>>> -    private static final JXPathContextFactory
>>> +    protected static final JXPathContextFactory
>>>          jxpathContextFactory = JXPathContextFactory.newInstance();
>>>
>>>      private static final Attributes EMPTY_ATTRS = new
>>>      
>>>
>>AttributesImpl();
>>    
>>
>>> @@ -104,7 +104,7 @@
>>>              }
>>>          };
>>>
>>> -    private static final Locator NULL_LOCATOR = new LocatorImpl();
>>> +    protected static final Locator NULL_LOCATOR = new LocatorImpl();
>>>
>>>      public final static String NS =
>>>          "http://apache.org/cocoon/jxforms/1.0";
>>> @@ -235,7 +235,7 @@
>>>       * Compile a single XPath expression
>>>       */
>>>
>>> -    static private XPathExpr
>>> +    static protected XPathExpr
>>>          compileExpr(String expr, Locator location)
>>>          throws SAXParseException {
>>>          if (expr == null) return null;
>>> @@ -451,7 +451,7 @@
>>>          HINT, VALUE, HELP, LABEL
>>>      };
>>>
>>> -    private static boolean isInputControl(String name) {
>>> +    protected static boolean isInputControl(String name) {
>>>          for (int i = 0; i < INPUT_CONTROLS.length; i++) {
>>>              if (INPUT_CONTROLS[i].equals(name)) {
>>>                  return true;
>>> @@ -460,7 +460,7 @@
>>>          return false;
>>>      }
>>>
>>> -    private static boolean isReadonlyInputControl(String name) {
>>> +    protected static boolean isReadonlyInputControl(String name) {
>>>          for (int i = 0; i < READONLY_INPUT_CONTROLS.length; i++) {
>>>              if (READONLY_INPUT_CONTROLS[i].equals(name)) {
>>>                  return true;
>>> @@ -1175,10 +1175,9 @@
>>>      private XMLConsumer consumer;
>>>      private Source inputSource;
>>>      private WebContinuation kont;
>>> -    private Object bean;
>>>      private Map objectModel;
>>>
>>> -    private XMLConsumer getConsumer() {
>>> +    protected XMLConsumer getConsumer() {
>>>          return consumer;
>>>      }
>>>
>>> @@ -1186,7 +1185,6 @@
>>>          super.recycle();
>>>          consumer = null;
>>>          inputSource = null;
>>> -        bean = null;
>>>          kont = null;
>>>          objectModel = null;
>>>      }
>>> @@ -1212,7 +1210,6 @@
>>>                  }
>>>              }
>>>          }
>>> -        bean = FlowHelper.getContextObject(objectModel);
>>>          kont = FlowHelper.getWebContinuation(objectModel);
>>>          this.objectModel = objectModel;
>>>      }
>>> @@ -1248,7 +1245,7 @@
>>>                  null);
>>>      }
>>>
>>> -    private void execute(final XMLConsumer consumer,
>>> +    protected void execute(final XMLConsumer consumer,
>>>                           Form form,
>>>                           String currentView,
>>>                           String contextPath,
>>> @@ -1269,8 +1266,7 @@
>>>                  consumer.endDocument();
>>>              } else if (ev instanceof EndElement) {
>>>                  EndElement endElement = (EndElement)ev;
>>> -                StartElement startElement =
>>> -                    (StartElement)endElement.startElement;
>>> +                StartElement startElement = endElement.startElement;
>>>                  consumer.endElement(startElement.namespaceURI,
>>>                                      startElement.localName,
>>>                                      startElement.raw);
>>>
>>>
>>>
>>> 1.4       +1 -6
>>>      
>>>
>>cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoon/transfor
>>mation/VariableRewriterTransformer.java
>>    
>>
>>> Index: VariableRewriterTransformer.java
>>> ===================================================================
>>> RCS file:
>>>      
>>>
>>/home/cvs/cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoo
>>n/transformation/VariableRewriterTransformer.java,v
>>    
>>
>>> retrieving revision 1.3
>>> retrieving revision 1.4
>>> diff -u -r1.3 -r1.4
>>> --- VariableRewriterTransformer.java	24 Mar 2003
>>>      
>>>
>>14:33:56 -0000	1.3
>>    
>>
>>> +++ VariableRewriterTransformer.java	24 Sep 2003
>>>      
>>>
>>22:04:40 -0000	1.4
>>    
>>
>>> @@ -184,9 +184,6 @@
>>>      private Set inSchemes;
>>>      private Set outSchemes;
>>>
>>> -    /** Links matching one of the acceptable schemes. */
>>> -    private Set links;
>>> -
>>>      /** Configuration passed to the component once through
>>>      
>>>
>>configure(). */
>>    
>>
>>>      private Configuration origConf;
>>>
>>> @@ -224,7 +221,6 @@
>>>          throws ProcessingException, SAXException, IOException
>>>      {
>>>          super.setup(resolver, objectModel, src, parameters);
>>> -        this.links = new HashSet();
>>>          this.badLinkStr =
>>>      
>>>
>>parameters.getParameter("bad-link-str", null);
>>    
>>
>>>          this.linkAttrs =
>>>      
>>>
>>split(parameters.getParameter("link-attrs", "href"), " ");
>>    
>>
>>>          this.inSchemes =
>>>      
>>>
>>split(parameters.getParameter("schemes", ""), " ");
>>    
>>
>>> @@ -370,7 +366,6 @@
>>>      public void recycle() {
>>>          super.recycle();
>>>          this.resolver = null;
>>> -        this.links = null;
>>>          this.linkAttrs = null;
>>>          this.inSchemes = null;
>>>          this.outSchemes = null;
>>>
>>>
>>>
>>> 1.8       +1 -6
>>>      
>>>
>>cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoon/transfor
>>mation/LinkRewriterTransformer.java
>>    
>>
>>> Index: LinkRewriterTransformer.java
>>> ===================================================================
>>> RCS file:
>>>      
>>>
>>/home/cvs/cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoo
>>n/transformation/LinkRewriterTransformer.java,v
>>    
>>
>>> retrieving revision 1.7
>>> retrieving revision 1.8
>>> diff -u -r1.7 -r1.8
>>> --- LinkRewriterTransformer.java	19 Jun 2003 11:31:05 -0000	1.7
>>> +++ LinkRewriterTransformer.java	24 Sep 2003 22:04:40 -0000	1.8
>>> @@ -194,9 +194,6 @@
>>>      private Set inSchemes;
>>>      private Set outSchemes;
>>>
>>> -    /** Links matching one of the acceptable schemes. */
>>> -    private Set links;
>>> -
>>>      /** Configuration passed to the component once through
>>>      
>>>
>>configure(). */
>>    
>>
>>>      private Configuration origConf;
>>>
>>> @@ -235,7 +232,6 @@
>>>          throws ProcessingException, SAXException, IOException
>>>      {
>>>          super.setup(resolver, objectModel, src, parameters);
>>> -        this.links = new HashSet();
>>>          this.badLinkStr =
>>>      
>>>
>>parameters.getParameter("bad-link-str",    // per-request config
>>    
>>
>>>                  origConf.getChild("bad-link-str"). // else
>>>      
>>>
>>fall back to per-instance config
>>    
>>
>>>                  getValue(null)                     // else
>>>      
>>>
>>use hardcoded default
>>    
>>
>>> @@ -277,7 +273,6 @@
>>>      public void recycle() {
>>>          super.recycle();
>>>          this.resolver = null;
>>> -        this.links = null;
>>>          this.linkAttrs = null;
>>>          this.inSchemes = null;
>>>          this.outSchemes = null;
>>>
>>>
>>>
>>> 1.8       +1 -2
>>>      
>>>
>>cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformatio
>>n/XMLFormTransformer.java
>>    
>>
>>> Index: XMLFormTransformer.java
>>> ===================================================================
>>> RCS file:
>>>      
>>>
>>/home/cvs/cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/tra
>>nsformation/XMLFormTransformer.java,v
>>    
>>
>>> retrieving revision 1.7
>>> retrieving revision 1.8
>>> diff -u -r1.7 -r1.8
>>> --- XMLFormTransformer.java	4 Aug 2003 03:16:34 -0000	1.7
>>> +++ XMLFormTransformer.java	24 Sep 2003 22:04:40 -0000	1.8
>>> @@ -580,7 +580,6 @@
>>>              getLogger().error(error);
>>>              throw new IllegalStateException(error);
>>>          }
>>> -        ;
>>>
>>>          formStack.push(currentForm);
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>      
>>>
>>    
>>
>
>
>  
>



RE: cvs commit: cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation XMLFormTransformer.java

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Hi Christopher,

I did make this change because of inheritance. The private fields/methods
very called from an inner class. This makes the compiler to create accessor
methods for the private fields so that the inner classes can reach
the private fields. Changing the fields to protected avoids this unnecessary
accessor methods.
If you don't want that someone inherits from these classes make them final.

Carsten

> -----Original Message-----
> From: Christopher Oliver [mailto:res1cf5x@verizon.net]
> Sent: Thursday, September 25, 2003 7:03 AM
> To: dev@cocoon.apache.org
> Cc: cziegler@apache.org
> Subject: Re: cvs commit:
> cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation
> XMLFormTransformer.java
>
>
> Carsten,
>
> Please do _not_ arbitrarily change private fields and methods to
> protected. JXTemplateGenerator and JXFormsGenerator are _not_ intended
> to be extended. If you think you have a need to extend them please
> express the problem you are trying to solve before making such changes.
>
> Thanks for your consideration,
>
> Chris
>
> cziegeler@apache.org wrote:
>
> >cziegeler    2003/09/24 15:04:40
> >
> >  Modified:    src/java/org/apache/cocoon/generation
> >                        JXTemplateGenerator.java
> >               src/blocks/jxforms/java/org/apache/cocoon/generation
> >                        JXFormsGenerator.java
> >
> src/blocks/linkrewriter/java/org/apache/cocoon/transformation
> >                        VariableRewriterTransformer.java
> >                        LinkRewriterTransformer.java
> >               src/blocks/xmlform/java/org/apache/cocoon/transformation
> >                        XMLFormTransformer.java
> >  Log:
> >  Removing unused imports and casts
> >
> >  Revision  Changes    Path
> >  1.9       +3 -3
> cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
> >
> >  Index: JXTemplateGenerator.java
> >  ===================================================================
> >  RCS file:
> /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTempl
> ateGenerator.java,v
> >  retrieving revision 1.8
> >  retrieving revision 1.9
> >  diff -u -r1.8 -r1.9
> >  --- JXTemplateGenerator.java	3 Sep 2003 15:00:56 -0000	1.8
> >  +++ JXTemplateGenerator.java	24 Sep 2003 22:04:40 -0000	1.9
> >  @@ -2235,10 +2235,10 @@
> >                                       null, locator);
> >                       Expression currencyCode =
> >                           compileExpr(attrs.getValue("currencyCode"),
> >  -                                    null, locator);;
> >  +                                    null, locator);
> >                       Expression currencySymbol =
> >                           compileExpr(attrs.getValue("currencySymbol"),
> >  -                                    null, locator);;
> >  +                                    null, locator);
> >                       Expression isGroupingUsed =
> >
> compileBoolean(attrs.getValue("isGroupingUsed"),
> >                                          null, locator);
> >  @@ -2281,7 +2281,7 @@
> >                                       null, locator);
> >                       Expression value =
> >                           compileExpr(attrs.getValue("value"),
> >  -                                    null, locator);;
> >  +                                    null, locator);
> >                       Expression type =
> >                           compileExpr(attrs.getValue("type"),
> >                                       null, locator);
> >
> >
> >
> >  1.5       +8 -12
> cocoon-2.1/src/blocks/jxforms/java/org/apache/cocoon/generation/JX
> FormsGenerator.java
> >
> >  Index: JXFormsGenerator.java
> >  ===================================================================
> >  RCS file:
> /home/cvs/cocoon-2.1/src/blocks/jxforms/java/org/apache/cocoon/gen
> eration/JXFormsGenerator.java,v
> >  retrieving revision 1.4
> >  retrieving revision 1.5
> >  diff -u -r1.4 -r1.5
> >  --- JXFormsGenerator.java	5 Sep 2003 07:21:48 -0000	1.4
> >  +++ JXFormsGenerator.java	24 Sep 2003 22:04:40 -0000	1.5
> >  @@ -88,7 +88,7 @@
> >
> >   public class JXFormsGenerator extends ServiceableGenerator {
> >
> >  -    private static final JXPathContextFactory
> >  +    protected static final JXPathContextFactory
> >           jxpathContextFactory = JXPathContextFactory.newInstance();
> >
> >       private static final Attributes EMPTY_ATTRS = new
> AttributesImpl();
> >  @@ -104,7 +104,7 @@
> >               }
> >           };
> >
> >  -    private static final Locator NULL_LOCATOR = new LocatorImpl();
> >  +    protected static final Locator NULL_LOCATOR = new LocatorImpl();
> >
> >       public final static String NS =
> >           "http://apache.org/cocoon/jxforms/1.0";
> >  @@ -235,7 +235,7 @@
> >        * Compile a single XPath expression
> >        */
> >
> >  -    static private XPathExpr
> >  +    static protected XPathExpr
> >           compileExpr(String expr, Locator location)
> >           throws SAXParseException {
> >           if (expr == null) return null;
> >  @@ -451,7 +451,7 @@
> >           HINT, VALUE, HELP, LABEL
> >       };
> >
> >  -    private static boolean isInputControl(String name) {
> >  +    protected static boolean isInputControl(String name) {
> >           for (int i = 0; i < INPUT_CONTROLS.length; i++) {
> >               if (INPUT_CONTROLS[i].equals(name)) {
> >                   return true;
> >  @@ -460,7 +460,7 @@
> >           return false;
> >       }
> >
> >  -    private static boolean isReadonlyInputControl(String name) {
> >  +    protected static boolean isReadonlyInputControl(String name) {
> >           for (int i = 0; i < READONLY_INPUT_CONTROLS.length; i++) {
> >               if (READONLY_INPUT_CONTROLS[i].equals(name)) {
> >                   return true;
> >  @@ -1175,10 +1175,9 @@
> >       private XMLConsumer consumer;
> >       private Source inputSource;
> >       private WebContinuation kont;
> >  -    private Object bean;
> >       private Map objectModel;
> >
> >  -    private XMLConsumer getConsumer() {
> >  +    protected XMLConsumer getConsumer() {
> >           return consumer;
> >       }
> >
> >  @@ -1186,7 +1185,6 @@
> >           super.recycle();
> >           consumer = null;
> >           inputSource = null;
> >  -        bean = null;
> >           kont = null;
> >           objectModel = null;
> >       }
> >  @@ -1212,7 +1210,6 @@
> >                   }
> >               }
> >           }
> >  -        bean = FlowHelper.getContextObject(objectModel);
> >           kont = FlowHelper.getWebContinuation(objectModel);
> >           this.objectModel = objectModel;
> >       }
> >  @@ -1248,7 +1245,7 @@
> >                   null);
> >       }
> >
> >  -    private void execute(final XMLConsumer consumer,
> >  +    protected void execute(final XMLConsumer consumer,
> >                            Form form,
> >                            String currentView,
> >                            String contextPath,
> >  @@ -1269,8 +1266,7 @@
> >                   consumer.endDocument();
> >               } else if (ev instanceof EndElement) {
> >                   EndElement endElement = (EndElement)ev;
> >  -                StartElement startElement =
> >  -                    (StartElement)endElement.startElement;
> >  +                StartElement startElement = endElement.startElement;
> >                   consumer.endElement(startElement.namespaceURI,
> >                                       startElement.localName,
> >                                       startElement.raw);
> >
> >
> >
> >  1.4       +1 -6
> cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoon/transfor
> mation/VariableRewriterTransformer.java
> >
> >  Index: VariableRewriterTransformer.java
> >  ===================================================================
> >  RCS file:
> /home/cvs/cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoo
> n/transformation/VariableRewriterTransformer.java,v
> >  retrieving revision 1.3
> >  retrieving revision 1.4
> >  diff -u -r1.3 -r1.4
> >  --- VariableRewriterTransformer.java	24 Mar 2003
> 14:33:56 -0000	1.3
> >  +++ VariableRewriterTransformer.java	24 Sep 2003
> 22:04:40 -0000	1.4
> >  @@ -184,9 +184,6 @@
> >       private Set inSchemes;
> >       private Set outSchemes;
> >
> >  -    /** Links matching one of the acceptable schemes. */
> >  -    private Set links;
> >  -
> >       /** Configuration passed to the component once through
> configure(). */
> >       private Configuration origConf;
> >
> >  @@ -224,7 +221,6 @@
> >           throws ProcessingException, SAXException, IOException
> >       {
> >           super.setup(resolver, objectModel, src, parameters);
> >  -        this.links = new HashSet();
> >           this.badLinkStr =
> parameters.getParameter("bad-link-str", null);
> >           this.linkAttrs =
> split(parameters.getParameter("link-attrs", "href"), " ");
> >           this.inSchemes =
> split(parameters.getParameter("schemes", ""), " ");
> >  @@ -370,7 +366,6 @@
> >       public void recycle() {
> >           super.recycle();
> >           this.resolver = null;
> >  -        this.links = null;
> >           this.linkAttrs = null;
> >           this.inSchemes = null;
> >           this.outSchemes = null;
> >
> >
> >
> >  1.8       +1 -6
> cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoon/transfor
> mation/LinkRewriterTransformer.java
> >
> >  Index: LinkRewriterTransformer.java
> >  ===================================================================
> >  RCS file:
> /home/cvs/cocoon-2.1/src/blocks/linkrewriter/java/org/apache/cocoo
> n/transformation/LinkRewriterTransformer.java,v
> >  retrieving revision 1.7
> >  retrieving revision 1.8
> >  diff -u -r1.7 -r1.8
> >  --- LinkRewriterTransformer.java	19 Jun 2003 11:31:05 -0000	1.7
> >  +++ LinkRewriterTransformer.java	24 Sep 2003 22:04:40 -0000	1.8
> >  @@ -194,9 +194,6 @@
> >       private Set inSchemes;
> >       private Set outSchemes;
> >
> >  -    /** Links matching one of the acceptable schemes. */
> >  -    private Set links;
> >  -
> >       /** Configuration passed to the component once through
> configure(). */
> >       private Configuration origConf;
> >
> >  @@ -235,7 +232,6 @@
> >           throws ProcessingException, SAXException, IOException
> >       {
> >           super.setup(resolver, objectModel, src, parameters);
> >  -        this.links = new HashSet();
> >           this.badLinkStr =
> parameters.getParameter("bad-link-str",    // per-request config
> >                   origConf.getChild("bad-link-str"). // else
> fall back to per-instance config
> >                   getValue(null)                     // else
> use hardcoded default
> >  @@ -277,7 +273,6 @@
> >       public void recycle() {
> >           super.recycle();
> >           this.resolver = null;
> >  -        this.links = null;
> >           this.linkAttrs = null;
> >           this.inSchemes = null;
> >           this.outSchemes = null;
> >
> >
> >
> >  1.8       +1 -2
> cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformatio
> n/XMLFormTransformer.java
> >
> >  Index: XMLFormTransformer.java
> >  ===================================================================
> >  RCS file:
> /home/cvs/cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/tra
> nsformation/XMLFormTransformer.java,v
> >  retrieving revision 1.7
> >  retrieving revision 1.8
> >  diff -u -r1.7 -r1.8
> >  --- XMLFormTransformer.java	4 Aug 2003 03:16:34 -0000	1.7
> >  +++ XMLFormTransformer.java	24 Sep 2003 22:04:40 -0000	1.8
> >  @@ -580,7 +580,6 @@
> >               getLogger().error(error);
> >               throw new IllegalStateException(error);
> >           }
> >  -        ;
> >
> >           formStack.push(currentForm);
> >
> >
> >
> >
> >
> >
> >
>
>