geirm       01/11/19 05:54:01

  Modified:    src/java/org/apache/velocity/runtime/parser/node
                        PropertyExecutor.java
  Log:
  restored the old search order to avoid breaking existing templates
  [that are broken in design, IMHO...] :)
  
  Revision  Changes    Path
  1.13      +17 -48    
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java
  
  Index: PropertyExecutor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PropertyExecutor.java     2001/11/19 04:15:09     1.12
  +++ PropertyExecutor.java     2001/11/19 13:54:01     1.13
  @@ -71,18 +71,17 @@
    */
   public class PropertyExecutor extends AbstractExecutor
   {
  -    /*
  -     *  just so we can have a safety comparison in the
  -     *  loop in the CTOR
  -     */
  -    private final static int MAX = 3;
  +    protected String methodUsed = null;
   
  -    private String methodUsed = null;
  -
       public PropertyExecutor( RuntimeServices r, Class clazz, String property)
       {
           rsvc = r;
           
  +        discover( clazz, property );
  +    }
  +
  +    protected void discover( Class clazz, String property )
  +    {
           /*
            *  this is gross and linear, but it keeps it straightforward.
            */
  @@ -96,56 +95,22 @@
               Introspector introspector = rsvc.getIntrospector();
               
               /*
  -             *  start with getFoo
  +             *  start with get<property>
  +             *  this leaves the property name 
  +             *  as is...
                */
               sb = new StringBuffer( "get" );
               sb.append( property );
   
  -            c = sb.charAt(3);
  -
  -            if(  Character.isLowerCase(c) )
  -            {
  -                sb.setCharAt( 3 ,  Character.toUpperCase(c) );
  -            }
  -
               methodUsed = sb.toString();
   
               method = introspector.getMethod( clazz, methodUsed, params);
                
               if (method != null)
                   return;
  -               
  -            /*
  -             *  now look for a boolean isFoo
  -             */
  -            
  -            sb = new StringBuffer( "is" );
  -            sb.append( property );
  -
  -            c = sb.charAt(2);
  -
  -            if(  Character.isLowerCase(c) )
  -            {
  -                sb.setCharAt( 2 ,  Character.toUpperCase(c) );
  -            }
  -
  -            methodUsed = sb.toString();
  -            method = introspector.getMethod( clazz, methodUsed, params);
  -
  -            if (method != null)
  -            {
  -                /*
  -                 *  now, this has to return a boolean
  -                 */
  -
  -                if ( method.getReturnType() == Boolean.TYPE )
  -                    return;
  -
  -                method = null;
  -            }
  -
  +        
               /*
  -             *  now the convenience, getfoo
  +             *  now the convenience, flip the 1st character
                */
            
               sb = new StringBuffer( "get" );
  @@ -153,9 +118,13 @@
   
               c = sb.charAt(3);
   
  -            if(  Character.isUpperCase(c) )
  +            if(  Character.isLowerCase( c ) )
  +            {
  +                sb.setCharAt( 3 ,  Character.toUpperCase( c ) );
  +            }
  +            else
               {
  -                sb.setCharAt( 3 ,  Character.toLowerCase(c) );
  +                sb.setCharAt( 3 ,  Character.toLowerCase( c ) );
               }
   
               methodUsed = sb.toString();
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to