1 | package com.hammurapi.extract.jxpath; |
2 | |
3 | import com.hammurapi.extract.Extractor; |
4 | import com.hammurapi.extract.ExtractorFactory; |
5 | import com.hammurapi.extract.Predicate; |
6 | |
7 | public class JXPathExtractorFactory implements ExtractorFactory { |
8 | |
9 | @SuppressWarnings("unchecked") |
10 | @Override |
11 | public <T, V, C> Extractor<T, V, C> createExtractor( |
12 | String language, |
13 | String code, |
14 | String[] parameterNames, |
15 | Class<T>[] parameterTypes, |
16 | Class<V> valueType, |
17 | Class<C> contextType, |
18 | ClassLoader classLoader) { |
19 | |
20 | if ("jxpath".equals(language)) { |
21 | if (Boolean.class.equals(valueType)) { |
22 | return (Extractor<T, V, C>) new JXPathPredicate<T, C>(code, parameterNames); |
23 | } |
24 | |
25 | return new JXPathExtractor<T, V, C>(code, parameterNames, valueType); |
26 | } |
27 | return null; |
28 | } |
29 | |
30 | @SuppressWarnings("unchecked") |
31 | @Override |
32 | public <T, C> Predicate<T, C> createPredicate( |
33 | String language, |
34 | String code, |
35 | String[] parameterNames, |
36 | Class<T>[] parameterTypes, |
37 | Class<C> contextType, |
38 | ClassLoader classLoader) { |
39 | |
40 | if ("jxpath".equals(language)) { |
41 | return new JXPathPredicate<T, C>(code, parameterNames); |
42 | } |
43 | return null; |
44 | } |
45 | |
46 | } |