Chinaunix首页 | 论坛 | 博客
  • 博客访问: 274336
  • 博文数量: 757
  • 博客积分: 40040
  • 博客等级: 大将
  • 技术积分: 4935
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-09 12:37
文章分类

全部博文(757)

文章存档

2011年(1)

2008年(756)

我的朋友

分类:

2008-09-09 12:43:21

public synchronized void validate( AbstractParameter param ) throws AttributeValidatorException
{
      Class clazz = param.getClass();
      Method[] methods = clazz.getMethods();

      //Cycle over all methods and call the getters!
      //Check if the getter result is null.
      //If result is null throw AttributeValidatorException.
      Iterator methodIter = Arrays.asList( methods ).iterator();
      Method method = null;
      String methodName = null;

      while ( methodIter.hasNext() )
      {
            method = (Method) methodIter.next();
            methodName = method.getName();

            if ( methodName.startsWith( "get" ) &&
            clazz.equals( method.getDeclaringClass() ) &&
                 !param.isOptionalMethod( methodName ) )
            {
                 Object methodResult = null;

                 try
                 {
                       methodResult = method.invoke( param, null );
                 }
                 catch ( IllegalArgumentException e )
                 {
                       throw new AttributeValidatorException( e.getMessage() );
                 }
                 catch ( IllegalAccessException e )
                 {
                       throw new AttributeValidatorException( e.getMessage() );
                 }
                 catch ( InvocationTargetException e )

--------------------next---------------------

阅读(58) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~