longeditor.java

来自「webwork source」· Java 代码 · 共 37 行

JAVA
37
字号
/*
 * WebWork, Web Application Framework
 *
 * Distributable under Apache license.
 * See terms of license at opensource.org
 */
package webwork.util.editor;

import webwork.action.ValidationEditorSupport;

/**
 *	@see java.beans.PropertyEditorSupport
 *	@see ValidationEditorSupport
 *	@see FastPropertyEditor
 *	@see PropertyEditorException
 *	@author Matt Baldree (matt@smallleap.com)
 *	@version $Revision: 1.4 $
 */
public class LongEditor extends ValidationEditorSupport implements FastPropertyEditor {

   public void setAsText(String txt) {
      setValue(getAsValue(txt));
   }

   public Object getAsValue(String txt) {
      if (txt == null || txt.length() == 0)
         throw new PropertyEditorException(PropertyMessage.EMPTY_LONG, txt);
      try {
         return new Long(txt);
      } catch (NumberFormatException e) {
         throw new PropertyEditorException(PropertyMessage.BAD_LONG, txt);
      }
   }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?