コード例 #1
0
 private boolean isPropertyMethod(String name, Method method) {
   if (name.startsWith("get") || name.startsWith("is")) {
     return method.getParameterTypes().length == 0;
   } else if (name.startsWith("set")) {
     return method.getParameterTypes().length == 1;
   } else {
     return false;
   }
 }
コード例 #2
0
 private void scanMethods() {
   Method[] methods = this.javaClass.getMethods();
   int len = methods.length;
   for (int i = 0; i < len; i++) {
     Method method = methods[i];
     String name = method.getName();
     if (isPropertyMethod(name, method)) {
       this.ensurePropertyKnown(name, method);
     }
     if (isNameIndexer(name, method)) {
       this.updateNameIndexer(name, method);
     } else if (this.isIntegerIndexer(name, method)) {
       this.updateIntegerIndexer(name, method);
     } else {
       Function f = new JavaFunctionObject(name, method);
       this.functions.put(name, f);
     }
   }
 }
コード例 #3
0
 private boolean isIntegerIndexer(String name, Method method) {
   return ("item".equals(name) && method.getParameterTypes().length == 1)
       || ("setItem".equals(name) && method.getParameterTypes().length == 2);
 }