Chinaunix首页 | 论坛 | 博客
  • 博客访问: 739357
  • 博文数量: 771
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 5005
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-11 14:24
文章分类

全部博文(771)

文章存档

2011年(1)

2008年(770)

我的朋友

分类:

2008-09-11 14:33:02

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---------------------

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