< prev index next >

src/java.desktop/share/classes/java/beans/EventHandler.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 354      * @see #EventHandler(Object, String, String, String)
 355      */
 356     public String getEventPropertyName()  {
 357         return eventPropertyName;
 358     }
 359 
 360     /**
 361      * Returns the name of the method that will trigger the action.
 362      * A return value of {@code null} signifies that all methods in the
 363      * listener interface trigger the action.
 364      *
 365      * @return the name of the method that will trigger the action
 366      *
 367      * @see #EventHandler(Object, String, String, String)
 368      */
 369     public String getListenerMethodName()  {
 370         return listenerMethodName;
 371     }
 372 
 373     private Object applyGetters(Object target, String getters) {
 374         if (getters == null || getters.equals("")) {
 375             return target;
 376         }
 377         int firstDot = getters.indexOf('.');
 378         if (firstDot == -1) {
 379             firstDot = getters.length();
 380         }
 381         String first = getters.substring(0, firstDot);
 382         String rest = getters.substring(Math.min(firstDot + 1, getters.length()));
 383 
 384         try {
 385             Method getter = null;
 386             if (target != null) {
 387                 getter = Statement.getMethod(target.getClass(),
 388                                       "get" + NameGenerator.capitalize(first),
 389                                       new Class<?>[]{});
 390                 if (getter == null) {
 391                     getter = Statement.getMethod(target.getClass(),
 392                                    "is" + NameGenerator.capitalize(first),
 393                                    new Class<?>[]{});
 394                 }


   1 /*
   2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 354      * @see #EventHandler(Object, String, String, String)
 355      */
 356     public String getEventPropertyName()  {
 357         return eventPropertyName;
 358     }
 359 
 360     /**
 361      * Returns the name of the method that will trigger the action.
 362      * A return value of {@code null} signifies that all methods in the
 363      * listener interface trigger the action.
 364      *
 365      * @return the name of the method that will trigger the action
 366      *
 367      * @see #EventHandler(Object, String, String, String)
 368      */
 369     public String getListenerMethodName()  {
 370         return listenerMethodName;
 371     }
 372 
 373     private Object applyGetters(Object target, String getters) {
 374         if (getters == null || getters.isEmpty()) {
 375             return target;
 376         }
 377         int firstDot = getters.indexOf('.');
 378         if (firstDot == -1) {
 379             firstDot = getters.length();
 380         }
 381         String first = getters.substring(0, firstDot);
 382         String rest = getters.substring(Math.min(firstDot + 1, getters.length()));
 383 
 384         try {
 385             Method getter = null;
 386             if (target != null) {
 387                 getter = Statement.getMethod(target.getClass(),
 388                                       "get" + NameGenerator.capitalize(first),
 389                                       new Class<?>[]{});
 390                 if (getter == null) {
 391                     getter = Statement.getMethod(target.getClass(),
 392                                    "is" + NameGenerator.capitalize(first),
 393                                    new Class<?>[]{});
 394                 }


< prev index next >