Package org.eweb4j.mvc.config.bean

Examples of org.eweb4j.mvc.config.bean.ValidatorConfigBean


      return null;

    Map<String, String> error = new HashMap<String, String>();
    // 启动验证器
    for (int i = valList.size() - 1; i > -1; i--) {
      ValidatorConfigBean val = valList.get(i);
      ValidatorIF validator = null;
      if (!"".equals(val.getName())) {
        // 根据name属性实例化相关的验证器,如果找不到,就根据class属性实例化
        validator = ValidatorFactory.getValidator(val.getName());
        if (validator == null)
          try {
            validator = (ValidatorIF) Class.forName(val.getClazz())
                .newInstance();
          } catch (Exception e) {
            LogFactory.getMVCLogger("VALIDATOR ERR").write(
                StringUtil.getExceptionString(e));
          }
View Full Code Here


        || "1".equals(cb.getMvc().getOpen())) {
      if (vList != null && !vList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (Iterator<ValidatorConfigBean> it = vList.iterator(); it
            .hasNext();) {
          ValidatorConfigBean v = it.next();
          if (!"".equals(v.getName())) {
            if (!ValidatorConstant.REQUIRED_VAL.equalsIgnoreCase(v
                .getName())
                && !ValidatorConstant.INT_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.EMAIL_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.DATE_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.URL_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.ID_CARD_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.ZIP_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.PHONE_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.QQ_VAL.equalsIgnoreCase(v
                    .getName())
                && !ValidatorConstant.IP_VAL
                    .equals(v.getName())
                && !ValidatorConstant.CHINESE_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.STRING_LENGTH_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.INT_SIZE_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.FORBID_VAL
                    .equalsIgnoreCase(v.getName())
                && !ValidatorConstant.ENUM_VAL
                    .equalsIgnoreCase(v.getName())) {
              sb.append("当前您填写的:( name=").append(v.getName());
              sb.append(" )是错误的!它只能填写为:required|int|");
              sb.append("email|date|url|idCard|zip|phone|qq|ip|");
              sb.append("chinese|length|size|forbid|enum|留空  中的一种 ,忽略大小写 ;\n");
            } else if (ValidatorConstant.INT_SIZE_VAL
                .equalsIgnoreCase(v.getName())) {
              int minSize = 0;
              for (FieldConfigBean f : v.getField()) {
                for (ParamConfigBean p : f.getParam()) {
                  if (ValidatorConstant.MIN_SIZE_PARAM
                      .equalsIgnoreCase(p.getName())) {
                    if (!(p.getValue()
                        .matches(RegexList.integer_regexp))) {
                      sb.append("<param>当前您填写的:( value=")
                          .append(p.getValue());
                      sb.append(" )是错误的!它应该填写为数字");

                    } else {
                      minSize = Integer.parseInt(p
                          .getValue());
                    }
                  } else if (ValidatorConstant.MAX_SIZE_PARAM
                      .equalsIgnoreCase(p.getName())) {
                    if (!(p.getValue()
                        .matches(RegexList.integer_regexp))) {
                      sb.append("<param>当前您填写的:( value=")
                          .append(p.getValue());
                      sb.append(" )是错误的!它应该填写为数字");
                    } else {
                      int maxSize = Integer.parseInt(p
                          .getValue());
                      if (minSize > maxSize) {
                        sb.append(
                            "<param>当前您填写的:( value=")
                            .append(p.getValue());
                        sb.append(" )是错误的!它不能比minSize的值");
                        sb.append(minSize).append("更小");
                      }
                    }
                  } else {
                    sb.append("<param>当前您填写的:( name=")
                        .append(p.getName());
                    sb.append(" )是错误的!它只能填写为:minSize|maxSize|");
                    sb.append("中的一种 ,忽略大小写 ;\n");
                  }
                }
              }
            } else if (ValidatorConstant.STRING_LENGTH_VAL
                .equalsIgnoreCase(v.getName())) {
              int minLength = 0;
              for (FieldConfigBean f : v.getField()) {
                for (ParamConfigBean p : f.getParam()) {
                  if (ValidatorConstant.MIN_LENGTH_PARAM
                      .equalsIgnoreCase(p.getName())) {
                    if (!(p.getValue()
                        .matches(RegexList.integer_regexp))) {
                      sb.append("<param>当前您填写的:( value=")
                          .append(p.getValue());
                      sb.append(" )是错误的!它应该填写为数字");
                    } else {
                      minLength = Integer.parseInt(p
                          .getValue());
                    }
                  } else if (ValidatorConstant.MAX_LENGTH_PARAM
                      .equalsIgnoreCase(p.getName())) {
                    if (!(p.getValue()
                        .matches(RegexList.integer_regexp))) {
                      sb.append("<param>当前您填写的:( value=")
                          .append(p.getValue());
                      sb.append(" )是错误的!它应该填写为数字");
                    } else {
                      int maxLength = Integer.parseInt(p
                          .getValue());
                      if (minLength > maxLength) {
                        sb.append(
                            "<param>当前您填写的:( value=")
                            .append(p.getValue());
                        sb.append(" )是错误的!它不能比minLength的值");
                        sb.append(minLength).append(
                            "更小");
                      }
                    }
                  } else {
                    sb.append("<param>当前您填写的:( name=")
                        .append(p.getName());
                    sb.append(" )是错误的!它只能填写为:minLength|maxLength|");
                    sb.append("中的一种 ,忽略大小写 ;\n");
                  }
                }
              }
            } else if (ValidatorConstant.FORBID_VAL
                .equalsIgnoreCase(v.getName())) {
              for (FieldConfigBean f : v.getField()) {
                for (ParamConfigBean p : f.getParam()) {
                  if (!ValidatorConstant.FORBID_WORD_PARAM
                      .equalsIgnoreCase(p.getName())) {
                    sb.append("<param>当前您填写的:( name=")
                        .append(p.getName());
                    sb.append(" )是错误的!它只能填写为:forbidWord|");
                    sb.append("忽略大小写 ;\n");
                  }
                }
              }
            } else if (ValidatorConstant.ENUM_VAL
                .equalsIgnoreCase(v.getName())) {
              for (FieldConfigBean f : v.getField()) {
                for (ParamConfigBean p : f.getParam()) {
                  if (!ValidatorConstant.ENUM_WORD_PARAM
                      .equalsIgnoreCase(p.getName())) {
                    sb.append("<param>当前您填写的:( name=")
                        .append(p.getName());
                    sb.append(" )是错误的!它只能填写为:enumWord|");
                    sb.append("忽略大小写 ;\n");
                  }
                }
              }
            }
          }

          if (!"".equals(v.getClazz())) {
            try {
              if (Class.forName(v.getClazz()) == null) {
                sb.append("当前您填写的( class=")
                    .append(v.getClazz())
                    .append(" )是错误的!它必须是一个有效的类 ;\n");
              }
            } catch (ClassNotFoundException e) {
              sb.append("当前您填写的( class=").append(v.getClazz())
                  .append(" )是错误的!它必须是一个有效的类 ;\n");
            }
          }
        }
View Full Code Here

  public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
      return null;
    if (val == null || !ValidatorConstant.URL_VAL.equals(val.getName())) {
      val = new ValidatorConfigBean();
      val.setName(ValidatorConstant.URL_VAL);
    }

    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
View Full Code Here

    if (this.ann == null)
      return null;
    Class<?> clazz = this.ann.clazz();
    String valName = clazz.getSimpleName();
    if (val == null || !valName.equals(val.getName())) {
      val = new ValidatorConfigBean();
      val.setName(valName);
      val.setClazz(clazz.getName());
    }

    FieldConfigBean fcb = new FieldConfigBean();
View Full Code Here

    List<ValidatorConfigBean> vList = new ArrayList<ValidatorConfigBean>();
    String[] name = validatorAnn.value();
    String[] clsName = validatorAnn.clazz();

    for (int a = 0; a < name.length; ++a) {
      ValidatorConfigBean v = new ValidatorConfigBean();
      if (name != null && name.length > a)
        v.setName(StringUtil.parsePropValue(name[a]));

      if (clsName != null && clsName.length > a)
        v.setClazz(StringUtil.parsePropValue(clsName[a]));

      if (valMessAnn == null || valFieldAnn == null)
        continue;

      // 验证器数组下标
      int[] valIndex = valMessAnn.validator();
      // 需要验证的属性域数组下标
      int[] fieldIndex = valMessAnn.field();

      String[] valField = valFieldAnn.value();
      String[] mess = valMessAnn.value();

      List<String> fnamelist = new ArrayList<String>();
      for (int in : fieldIndex)
        fnamelist.add(StringUtil.parsePropValue(valField[in]));

      String[] fname = fnamelist.toArray(new String[] {});

      List<FieldConfigBean> fList = new ArrayList<FieldConfigBean>();
      for (int b = 0; b < valIndex.length; ++b) {
        if (valIndex[b] == a) {
          FieldConfigBean f = new FieldConfigBean();
          fList.add(f);
          f.setName(StringUtil.parsePropValue(fname[b]));
          f.setMessage(StringUtil.parsePropValue(mess[b]));

          if (paramAnn == null || paramName == null)
            continue;

          int[] pindex = paramAnn.valMess();
          int[] pnameIndex = paramAnn.name();
          String[] pnames = paramName.value();

          List<String> pnamelist = new ArrayList<String>();
          for (int in : pnameIndex)
            pnamelist.add(StringUtil.parsePropValue(pnames[in]));

          String[] pname = pnamelist.toArray(new String[] {});
          String[] pvalue = paramAnn.value();

          List<ParamConfigBean> pList = new ArrayList<ParamConfigBean>();
          for (int c = 0; c < pindex.length; ++c) {
            if (pindex[c] == b) {
              ParamConfigBean p = new ParamConfigBean();
              p.setName(StringUtil.parsePropValue(pname[c]));
              p.setValue(StringUtil.parsePropValue(pvalue[c]));
              pList.add(p);
            }
          }

          f.setParam(pList);

        }
      }

      v.setField(fList);
      vList.add(v);
    }

    return vList;
  }
View Full Code Here

      return null;

    if (vList == null)
      vList = new ArrayList<ValidatorConfigBean>();

    ValidatorConfigBean val = null;
    for (Field f : fs) {
      Method m = ru.getGetter(f.getName());
      if (m == null)
        continue;
View Full Code Here

  public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
      return null;
    if (val == null || !ValidatorConstant.EMAIL_VAL.equals(val.getName())) {
      val = new ValidatorConfigBean();
      val.setName(ValidatorConstant.EMAIL_VAL);
    }

    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
View Full Code Here

  public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
      return null;
    if (val == null || !ValidatorConstant.ZIP_VAL.equals(val.getName())) {
      val = new ValidatorConfigBean();
      val.setName(ValidatorConstant.ZIP_VAL);
    }

    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
View Full Code Here

  public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
      return null;
    if (val == null || !ValidatorConstant.ID_CARD_VAL.equals(val.getName())) {
      val = new ValidatorConfigBean();
      val.setName(ValidatorConstant.ID_CARD_VAL);
    }

    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
View Full Code Here

  public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
      return null;
    if (val == null || !ValidatorConstant.INT_VAL.equals(val.getName())) {
      val = new ValidatorConfigBean();
      val.setName(ValidatorConstant.INT_VAL);
    }

    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
View Full Code Here

TOP

Related Classes of org.eweb4j.mvc.config.bean.ValidatorConfigBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.