Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2011 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.callbackparams.internal.template;
 
 import java.util.List;
 import java.util.Map;
Wraps (by copying) an array of all combined values that are to be used for a single test-run. This array is also referred to as a callback-record throughout the callback-params documentation - hence the name of this class.

Author(s):
Henrik Kaipe
 
 public class CallbackRecord {
 
     private final List callbackRecord;
     private final Map latestCallbackResults = new IdentityHashMap();
     private final CallbackControlPanel ccp = new CallbackControlPanel() {
         public List getCurrentCallbackRecord() {
             return ;
         }
         public Map getLatestCallbackResults() {
             return ;
         }
     };
 
     public CallbackRecord(List callbackRecord) {
         this. = callbackRecord;
     }
 
 //    public CallbackRecord(ClassLoader cl, Map/*Method,Object[]*/ valuesCache,
 //            Collection/*Combined*/ initialCallbackRecord) {
 //        this.callbackRecord = new ArrayList(initialCallbackRecord.size());
 //        for (Iterator i = initialCallbackRecord.iterator(); i.hasNext();) {
 //            final Combined combined = asCombined(i.next());
 //            Object callback = combined.getCoreValue(cl, valuesCache);
 //            if (null != callback) {
 //                callbackRecord.add(callback);
 //            }
 //        }
 //    }
 
         return ;
     }
 
     public InvocationHandler newCallbackInvoker(final CallbackRef callbackRef) {
         return new InvocationHandler() {
             
             public Object invoke(Object oMethod mObject[] args)
             throws Throwable {
                 if (false == m.isAccessible()) {
                     m.setAccessible(true);
                 }
                 try {
                     .clear();
 
                     for (Iterator i = .iterator(); i.hasNext();) {
                         final Object callbackParameter = i.next();
                         if (null == callbackParameter) {
                             continue;
                         }
                         
                         final Object targetCallbackInstance =
                                 callbackRef.asCallback(callbackParameter);
                         if (null != targetCallbackInstance) {
                             .put(
                                     callbackParameter,
                                     m.invoke(targetCallbackInstanceargs));
                         }
                     }
                     return DefaultValue.forType(m.getReturnType());
                     
                 } catch (final InvocationTargetException ite) {
                     throw ite.getTargetException();
                 }
            }
        };
    }
    private Combined asCombined(Object callbackRecordElement) {
        if (callbackRecordElement instanceof Combined) {
            return (CombinedcallbackRecordElement;
        } else {
            return Combined.resurrectFromOtherClassLoader(callbackRecordElement);
        }
    }
    static class DefaultValue {
        private static final Map map = new HashMap();
        static {
            .put(int.classnew Integer(0));
            .put(boolean.class.);
            .put(long.classnew Long(0));
            .put(char.classnew Character((char)0));
            .put(double.classnew Double(0.0));
            .put(byte.classnew Byte((byte)0));
            .put(float.classnew Float(0.0F));
            .put(short.classnew Short((short)0));
        }
        static Object forType(final Class type) {
            return .get(type);
        } 
    }
New to GrepCode? Check out our FAQ X