OSDN Git Service

srcディレクトリとdocディレクトリを作成
[xdf/git-repos.git] / src / xdf-swing / src / main / java / jp / ac / aiit / xdf / component / swing / attribute / GetterAttributeProcessor.java
1 package jp.ac.aiit.xdf.component.swing.attribute;
2
3
4 import java.lang.reflect.Method;
5
6 import jp.ac.aiit.xdf.utils.Reflections;
7
8 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory;
10
11 /**
12  * @author Pin.Yuan
13  * 
14  */
15 public class GetterAttributeProcessor implements AttributeGetProcessor {
16         private static final Logger log = LoggerFactory.getLogger(GetterAttributeProcessor.class);
17         
18         private String method;
19         
20         /**
21          * @param method
22          */
23         public GetterAttributeProcessor(String method) {
24                 this.method = method;
25         }
26         
27         @Override
28         public Object invokeGet(Object target, String name) {
29                 Class<?> clazz = target.getClass();
30                 
31                 try {
32                         Method m = clazz.getMethod(method);
33                         return Reflections.invokeMethod(target, m);
34                 } catch (SecurityException e) {
35                         log.warn("ゲッターの適用に失敗: target:"+target+", name:"+name, e);
36                 } catch (NoSuchMethodException e) {
37                         log.warn("ゲッターの適用に失敗: target:"+target+", name:"+name, e);
38                 }
39                 return null;
40         }
41 }