Ejemplo n.º 1
0
  /**
   * @Title: printUserInfos @Description: TODO
   *
   * @param @param userInfoSels
   * @return void
   * @throws
   */
  protected static void printUserInfos(ArrayList<UserInfoEntity> userInfoSels) {
    for (UserInfoEntity userInfo : userInfoSels) {
      Method[] methods = InvokeUtils.getMethods(userInfo);
      Field[] fields = InvokeUtils.getFields(userInfo);
      for (Method method : methods) {
        for (Field field : fields) {
          if (method.getName().equalsIgnoreCase("get" + field.getName())) {
            if (field.getType().equals(String.class)) {
              System.out.print(
                  InvokeUtils.execute(userInfo, method.getName(), new Object[] {}) + "\t");
            } else if (field.getType().equals(Date.class)) {
              System.out.print(
                  InvokeUtils.execute(userInfo, method.getName(), new Object[] {}) + "\t");
            }
            if (field.getType().equals(byte[].class)) {}

          } else if (method.getName().equalsIgnoreCase("get" + field.getName() + "Str")) {
            System.out.print(
                InvokeUtils.execute(userInfo, method.getName(), new Object[] {}) + "\t");
          }
        }
      }
      System.out.println();
    }
  }
Ejemplo n.º 2
0
 /**
  * @Title: createUserInfos @Description: TODO
  *
  * @param @return
  * @return ArrayList<UserInfoEntity>
  * @throws
  */
 protected static ArrayList<UserInfoEntity> createUserInfos(int count) {
   UserInfoEntity userInfoInsert = new UserInfoEntity();
   ArrayList<UserInfoEntity> userInfoInserts = new ArrayList<UserInfoEntity>();
   Field[] fields = InvokeUtils.getFields(userInfoInsert);
   Method[] methods = InvokeUtils.getMethods(userInfoInsert);
   for (int i = 0; i < count; i++) {
     userInfoInsert = new UserInfoEntity();
     for (int j = 0; j < fields.length; j++) {
       for (int k = 0; k < methods.length; k++) {
         Object[] obj = new Object[1];
         if (methods[k].getName().equalsIgnoreCase("set" + fields[j].getName())) {
           if (fields[j].getType().equals(String.class)) {
             if (!methods[k].getName().equalsIgnoreCase("setUID")
                 && !methods[k].getName().equalsIgnoreCase("setPassword")) {
               obj[0] =
                   fields[j].getName()
                       + "_"
                       + StringUtils.getStringSequence(i + 1, MathUtils.GetIndices(10, count) + 1);
               InvokeUtils.execute(userInfoInsert, methods[k].getName(), obj);
             }
           } else if (fields[j].getType().equals(Date.class)) {
             obj[0] =
                 new Date(System.currentTimeMillis() - (long) (Math.random() * 999999999999L));
             InvokeUtils.execute(userInfoInsert, methods[k].getName(), obj);
           } else if (fields[j].getType().equals(byte[].class)) {
           }
         } else if (methods[k].getName().equalsIgnoreCase("set" + fields[j].getName() + "Str")) {
           obj[0] =
               fields[j].getName()
                   + "_"
                   + StringUtils.getStringSequence(i + 1, MathUtils.GetIndices(10, count) + 1);
           InvokeUtils.execute(userInfoInsert, methods[k].getName(), obj);
         }
       }
     }
     userInfoInserts.add(userInfoInsert);
   }
   return userInfoInserts;
 }