1 26 27 package org.objectweb.util.browser.plugin.java.reflect; 28 29 import java.lang.reflect.Method ; 30 import java.lang.reflect.Modifier ; 31 32 import javax.swing.Icon ; 33 import javax.swing.ImageIcon ; 34 35 import org.objectweb.util.browser.api.IconProvider; 36 import org.objectweb.util.browser.core.common.ClassResolver; 37 38 46 public class MethodIconProvider 47 implements IconProvider { 48 49 55 56 protected static Icon publicMethod_, publicAbstractMethod_, publicStaticMethod_, publicFinalMethod_, publicStaticFinalMethod_; 57 58 59 protected static Icon protectedMethod_, protectedAbstractMethod_, protectedStaticMethod_, protectedFinalMethod_, protectedStaticFinalMethod_; 60 61 62 protected static Icon packageMethod_, packageAbstractMethod_, packageStaticMethod_, packageFinalMethod_, packageStaticFinalMethod_; 63 64 65 protected static Icon privateMethod_, privateFinalMethod_; 66 67 73 76 public MethodIconProvider(){ 77 publicMethod_ = new ImageIcon (ClassResolver.getResource("publicMethod.png")); 78 publicAbstractMethod_ = new ImageIcon (ClassResolver.getResource("publicAbstractMethod.png")); 79 publicStaticMethod_ = new ImageIcon (ClassResolver.getResource("publicStaticMethod.png")); 80 publicFinalMethod_ = new ImageIcon (ClassResolver.getResource("publicFinalMethod.png")); 81 publicStaticFinalMethod_ = new ImageIcon (ClassResolver.getResource("publicStaticFinalMethod.png")); 82 protectedMethod_ = new ImageIcon (ClassResolver.getResource("protectedMethod.png")); 83 protectedAbstractMethod_ = new ImageIcon (ClassResolver.getResource("protectedAbstractMethod.png")); 84 protectedStaticMethod_ = new ImageIcon (ClassResolver.getResource("protectedStaticMethod.png")); 85 protectedFinalMethod_ = new ImageIcon (ClassResolver.getResource("protectedFinalMethod.png")); 86 protectedStaticFinalMethod_ = new ImageIcon (ClassResolver.getResource("protectedStaticFinalMethod.png")); 87 privateMethod_ = new ImageIcon (ClassResolver.getResource("privateMethod.png")); 88 privateFinalMethod_ = new ImageIcon (ClassResolver.getResource("privateFinalMethod.png")); 89 packageMethod_ = new ImageIcon (ClassResolver.getResource("packageMethod.png")); 90 packageAbstractMethod_ = new ImageIcon (ClassResolver.getResource("packageAbstractMethod.png")); 91 packageStaticMethod_ = new ImageIcon (ClassResolver.getResource("packageStaticMethod.png")); 92 packageFinalMethod_ = new ImageIcon (ClassResolver.getResource("packageFinalMethod.png")); 93 packageStaticFinalMethod_ = new ImageIcon (ClassResolver.getResource("packageStaticFinalMethod.png")); 94 } 95 96 102 108 115 public Icon 116 newIcon(Object object){ 117 Method method_ = (Method )object; 118 int modifier = method_.getModifiers(); 119 if (Modifier.isPrivate(modifier)){ 120 if (Modifier.isFinal(modifier)) 121 return privateFinalMethod_; 122 else 123 return privateMethod_; 124 } else if (Modifier.isProtected(modifier)){ 125 if (Modifier.isAbstract(modifier)) 126 return protectedAbstractMethod_; 127 else if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 128 return protectedStaticFinalMethod_; 129 else if (Modifier.isStatic(modifier)) 130 return protectedStaticMethod_; 131 else if (Modifier.isFinal(modifier)) 132 return protectedFinalMethod_; 133 else 134 return protectedMethod_; 135 } else if (Modifier.isPublic(modifier)){ 136 if (Modifier.isAbstract(modifier)) 137 return publicAbstractMethod_; 138 else if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 139 return publicStaticFinalMethod_; 140 else if (Modifier.isStatic(modifier)) 141 return publicStaticMethod_; 142 else if (Modifier.isFinal(modifier)) 143 return publicFinalMethod_; 144 else 145 return publicMethod_; 146 } else if (!Modifier.isPrivate(modifier) && !Modifier.isProtected(modifier) && !Modifier.isPublic(modifier)){ 147 if (Modifier.isAbstract(modifier)) 148 return packageAbstractMethod_; 149 else if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 150 return packageStaticFinalMethod_; 151 else if (Modifier.isStatic(modifier)) 152 return packageStaticMethod_; 153 else if (Modifier.isFinal(modifier)) 154 return packageFinalMethod_; 155 else 156 return packageMethod_; 157 } else { 158 return null; 159 } 160 } 161 162 } | Popular Tags |