当前位置: 首页>>代码示例>>Java>>正文


Java RiceKeyConstants.ERROR_PHONE_NUMBER属性代码示例

本文整理汇总了Java中org.kuali.rice.core.api.util.RiceKeyConstants.ERROR_PHONE_NUMBER属性的典型用法代码示例。如果您正苦于以下问题:Java RiceKeyConstants.ERROR_PHONE_NUMBER属性的具体用法?Java RiceKeyConstants.ERROR_PHONE_NUMBER怎么用?Java RiceKeyConstants.ERROR_PHONE_NUMBER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.kuali.rice.core.api.util.RiceKeyConstants的用法示例。


在下文中一共展示了RiceKeyConstants.ERROR_PHONE_NUMBER属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertToObject

/**
 * begin Kuali Foundation modification
 * Removes formatting characters from the provided phone number and returns just the digits. Very lenient about formatting, but
 * requires a ten-digit number.
 * end Kuali Foundation modification
 */
@Override
protected Object convertToObject(String target) {
    String digits = target.replaceAll("[^0-9]", "");
    if (digits.length() != NUM_DIGITS)
     {
        // begin Kuali Foundation modification
        throw new FormatException("parsing", RiceKeyConstants.ERROR_PHONE_NUMBER, target);
        // end Kuali Foundation modification
    }

    return digits;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:PhoneNumberFormatter.java

示例2: format

/**
   * Returns its argument formatted as a phone number in the style:
   * <p>
   *
   * <pre>
   *   (999) 999-9999
   * </pre>
   */
  @Override
  public Object format(Object value) {
      if (value == null) {
          return null;
      }
      if (!(value instanceof String))
       {
          // begin Kuali Foundation modification
          throw new FormatException("formatting", RiceKeyConstants.ERROR_PHONE_NUMBER, value.toString());
          // end Kuali Foundation modification
      }

// begin Kuali Foundation modification
      String digits = ((String) value).replaceAll("[^0-9]", "");

      if (digits.length() != NUM_DIGITS)
       {
          throw new FormatException("formatting", RiceKeyConstants.ERROR_PHONE_NUMBER, value.toString());
      // end Kuali Foundation modification
      }

      StringBuffer buf = new StringBuffer("(");
      buf.append(digits.substring(0, 3));
      buf.append(") ");
      buf.append(digits.substring(3, 6));
      buf.append("-");
      buf.append(digits.substring(6));

      return buf.toString();
  }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:38,代码来源:PhoneNumberFormatter.java


注:本文中的org.kuali.rice.core.api.util.RiceKeyConstants.ERROR_PHONE_NUMBER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。