1 26 27 package org.objectweb.util.browser.plugin.java.reflect; 28 29 import java.lang.reflect.Field ; 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 FieldIconProvider 47 implements IconProvider { 48 49 55 56 protected static Icon publicField_, publicStaticField_, publicFinalField_, publicStaticFinalField_; 57 58 59 protected static Icon protectedField_, protectedStaticField_, protectedFinalField_, protectedStaticFinalField_; 60 61 62 protected static Icon packageField_, packageStaticField_, packageFinalField_, packageStaticFinalField_; 63 64 65 protected static Icon privateField_, privateFinalField_; 66 67 73 76 public FieldIconProvider(){ 77 publicField_ = new ImageIcon (ClassResolver.getResource("publicField.png")); 78 publicStaticField_ = new ImageIcon (ClassResolver.getResource("publicStaticField.png")); 79 publicFinalField_ = new ImageIcon (ClassResolver.getResource("publicFinalField.png")); 80 publicStaticFinalField_ = new ImageIcon (ClassResolver.getResource("publicStaticFinalField.png")); 81 protectedField_ = new ImageIcon (ClassResolver.getResource("protectedField.png")); 82 protectedStaticField_ = new ImageIcon (ClassResolver.getResource("protectedStaticField.png")); 83 protectedFinalField_ = new ImageIcon (ClassResolver.getResource("protectedFinalField.png")); 84 protectedStaticFinalField_ = new ImageIcon (ClassResolver.getResource("protectedStaticFinalField.png")); 85 privateField_ = new ImageIcon (ClassResolver.getResource("privateField.png")); 86 privateFinalField_ = new ImageIcon (ClassResolver.getResource("privateFinalField.png")); 87 packageField_ = new ImageIcon (ClassResolver.getResource("packageField.png")); 88 packageStaticField_ = new ImageIcon (ClassResolver.getResource("packageStaticField.png")); 89 packageFinalField_ = new ImageIcon (ClassResolver.getResource("packageFinalField.png")); 90 packageStaticFinalField_ = new ImageIcon (ClassResolver.getResource("packageStaticFinalField.png")); 91 } 92 93 99 105 112 public Icon 113 newIcon(Object object){ 114 Field field_ = (Field )object; 115 int modifier = field_.getModifiers(); 116 if (Modifier.isPrivate(modifier)){ 117 if (Modifier.isFinal(modifier)) 118 return privateFinalField_; 119 else 120 return privateField_; 121 } else if (Modifier.isProtected(modifier)){ 122 if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 123 return protectedStaticFinalField_; 124 else if (Modifier.isStatic(modifier)) 125 return protectedStaticField_; 126 else if (Modifier.isFinal(modifier)) 127 return protectedFinalField_; 128 else 129 return protectedField_; 130 } else if (Modifier.isPublic(modifier)){ 131 if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 132 return publicStaticFinalField_; 133 else if (Modifier.isStatic(modifier)) 134 return publicStaticField_; 135 else if (Modifier.isFinal(modifier)) 136 return publicFinalField_; 137 else 138 return publicField_; 139 } else if (!Modifier.isPrivate(modifier) && !Modifier.isProtected(modifier) && !Modifier.isPublic(modifier)) { 140 if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 141 return packageStaticFinalField_; 142 else if (Modifier.isStatic(modifier)) 143 return packageStaticField_; 144 else if (Modifier.isFinal(modifier)) 145 return packageFinalField_; 146 else 147 return packageField_; 148 } else { 149 return null; 150 } 151 } 152 153 } | Popular Tags |