예제 #1
0
  private String getHeaders(FetchedPage page) {
    StringBuilder stringBuilder = new StringBuilder();
    Method[] declaredMethods = page.getClass().getDeclaredMethods();
    for (Method method : declaredMethods) {
      String name = method.getName();
      if (name.startsWith("get")) {
        String columnName = name.replace("get", "");

        if (columnName.toLowerCase().equals("plainText".toLowerCase())) {
          if (this.isPlainText()) {
            stringBuilder.append(columnName + ",");
          }
          continue;
        }

        if (columnName.toLowerCase().equals("html".toLowerCase())) {
          if (!this.isPlainText()) {
            stringBuilder.append(columnName + ",");
          }
          continue;
        }
        stringBuilder.append(columnName + ",");
      }
    }

    String headerStrings = stringBuilder.toString();
    return headerStrings.substring(0, headerStrings.length() - 1);
  }
예제 #2
0
 private Object callCorrespondingGetterMethod(FetchedPage page, String property) {
   Object invoke = null;
   try {
     property = "get" + property.substring(0, 1) + property.substring(1);
     Method method = page.getClass().getMethod(property);
     invoke = method.invoke(page);
   } catch (NoSuchMethodException e) {
     logger.debug("No getter method found for {}", property);
   } catch (InvocationTargetException e) {
     logger.debug("Target exception for {}", property);
   } catch (IllegalAccessException e) {
     logger.debug("Illegal access while trying to call {}", property);
   }
   return invoke;
 }