Sure.

There is a bit of code that does the following while trying to set default
values:

if (getOption == null)
   setOption(defaultValue).

This appears in various combinations/sequences that in some cases resembled
spagetti.
I removed the spagetti and replaced with the method below.  For example,
review changes to  DefaultAxisServerFactory.java


*******************************************
Richard A. Sitze            [EMAIL PROTECTED]




                                                                                       
                          
                      Glen Daniels                                                     
                          
                      <gdaniels@macrom         To:      "'[EMAIL PROTECTED]'" 
<[EMAIL PROTECTED]>    
                      edia.com>                cc:                                     
                          
                                               Subject: RE: cvs commit:                
                          
                      05/09/2002 01:22         
xml-axis/java/src/org/apache/axis/handlers BasicH  andler.java    
                      PM                                                               
                          
                      Please respond                                                   
                          
                      to axis-dev                                                      
                          
                                                                                       
                          
                                                                                       
                          





Hi Richard!

>   +    /**
>   +     * Set a default value for the given option:
>   +     * if the option is not already set, then set it.
>   +     * if the option is already set, then do not set it.
>   +     * <p>
>   +     * If this is called multiple times, the first with a
> non-null value
>   +     * if 'value' will set the default, remaining calls
> will be ignored.
>   +     * <p>
>   +     * Returns true if value set (by this call), otherwise false;
>   +     */
>   +    public boolean setOptionDefault(String name, Object value) {
>   +        boolean val = (options == null  ||
> options.get(name) == null) && value != null;
>   +        if (val) {
>   +            setOption(name, value);
>   +        }
>   +        return val;
>   +    }

Could you explain how this would be used?

--Glen



Reply via email to