EMMA Coverage Report (generated Thu Jan 20 11:39:44 EST 2011)
[all classes][com.hammurapi.extract]

COVERAGE SUMMARY FOR SOURCE FILE [ExtractorFactory.java]

nameclass, %method, %block, %line, %
ExtractorFactory.java100% (1/1)100% (3/3)83%  (76/92)87%  (14.8/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExtractorFactory$1100% (1/1)100% (3/3)83%  (76/92)87%  (14.8/17)
createExtractor (String, String, String [], Class [], Class, Class, ClassLoad... 100% (1/1)74%  (32/43)86%  (6/7)
createPredicate (String, String, String [], Class [], Class, ClassLoader): Pr... 100% (1/1)88%  (36/41)82%  (5.8/7)
ExtractorFactory$1 (): void 100% (1/1)100% (8/8)100% (3/3)

1package com.hammurapi.extract;
2 
3import java.util.Iterator;
4import java.util.ServiceLoader;
5 
6import com.hammurapi.extract.scripting.ScriptingExtractorFactory;
7 
8 
9/**
10 * Extractor factory service. Creates scripted extractors and predicates.
11 * The service is discoverable using the Java Service Loader framework.
12 * @author Pavel Vlasov.
13 *
14 */
15public interface ExtractorFactory {
16        
17        /**
18         * Binding for context object.
19         */
20        String CONTEXT_BINDING = "eCtx";
21        
22        /**
23         * Binding for arguments arrray if parameter names are not provided.
24         */
25        String ARGS_BINDING = "args";
26 
27        /**
28         * This instance uses the service loading framework to discover
29         * extractor factory providers. It iterates over the providers and
30         * invokes provider's createExtractor() methods until it gets not null
31         * result which is returned from the method.
32         * If there are no providers supporting given language, then null is returned.
33         */
34        ExtractorFactory INSTANCE = new ExtractorFactory() {
35                
36                private ScriptingExtractorFactory sef = new ScriptingExtractorFactory();
37 
38                public <T, V, C> Extractor<T, V, C> createExtractor(String language, String code, String[] parameterNames, Class<T>[] parameterTypes, Class<V> valueType, Class<C> contextType, ClassLoader classLoader) {
39                        ServiceLoader<ExtractorFactory> sl = classLoader==null ? ServiceLoader.load(ExtractorFactory.class) : ServiceLoader.load(ExtractorFactory.class, classLoader);
40                        Iterator<ExtractorFactory> efi = sl.iterator();
41                        while (efi.hasNext()) {
42                                Extractor<T, V, C> ret = efi.next().createExtractor(language, code, parameterNames, parameterTypes, valueType, contextType, classLoader);
43                                if (ret!=null) {
44                                        return ret;
45                                }
46                        }
47                        return sef.createExtractor(language, code, parameterNames, parameterTypes, valueType, contextType, classLoader);
48                }
49                
50                public <T, C> Predicate<T, C> createPredicate(String language, String code, String[] parameterNames, Class<T>[] parameterTypes, Class<C> contextType, ClassLoader classLoader) {
51                        ServiceLoader<ExtractorFactory> sl = classLoader==null ? ServiceLoader.load(ExtractorFactory.class) : ServiceLoader.load(ExtractorFactory.class, classLoader);
52                        Iterator<ExtractorFactory> efi = sl.iterator();
53                        while (efi.hasNext()) {
54                                Predicate<T, C> ret = efi.next().createPredicate(language, code, parameterNames, parameterTypes, contextType, classLoader);
55                                if (ret!=null) {
56                                        return ret;
57                                }
58                        }
59                        return sef.createPredicate(language, code, parameterNames, parameterTypes, contextType, classLoader);
60                }
61                
62        };
63        
64        /**
65         * Creates extractor.
66         * @param <T> Source objects type.
67         * @param <V> Value type.
68         * @param language Extractor language.
69         * @param code Extractor code.
70         * @param parameterTypes Extractor parameter types.
71         * @param valueType Extractor value type. If this type is Boolean then the factory
72         * shall return Predicate.
73         * @param classLoader Class loader to use for script evaluation.
74         * @return Extractor or null if this factory doesn't support given language.
75         */
76        <T, V, C> Extractor<T, V, C> createExtractor(String language, String code, String[] parameterNames, Class<T>[] parameterTypes, Class<V> valueType, Class<C> contextType, ClassLoader classLoader);
77 
78        /**
79         * Creates extractor.
80         * @param <T> Source objects type.
81         * @param language Extractor language.
82         * @param code Extractor code.
83         * @param parameterTypes Extractor parameter types.
84         * @param valueType Extractor value type. If this type is Boolean then the factory
85         * shall return Predicate.
86         * @param classLoader Class loader to use for script evaluation.
87         * @return Extractor or null if this factory doesn't support given language.
88         */
89        <T, C> Predicate<T, C> createPredicate(String language, String code, String[] parameterNames, Class<T>[] parameterTypes, Class<C> contextType, ClassLoader classLoader);
90}

[all classes][com.hammurapi.extract]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov