1 16 17 package org.springframework.metadata.support; 18 19 import java.lang.reflect.Field ; 20 import java.lang.reflect.Method ; 21 import java.util.Arrays ; 22 import java.util.Collection ; 23 import java.util.HashMap ; 24 import java.util.LinkedList ; 25 import java.util.Map ; 26 27 28 33 public class MapAttributes extends AbstractAttributes { 34 35 private Map attMap = new HashMap (); 36 37 38 public void register(Class clazz, Object [] atts) { 39 attMap.put(clazz, atts); 40 } 41 42 public void register(Method method, Object [] atts) { 43 attMap.put(method, atts); 44 } 45 46 private Collection getAllAttributes(Object o) { 47 Object [] atts = (Object []) attMap.get(o); 48 return (atts == null) ? 49 new LinkedList () : 50 Arrays.asList(atts); 51 } 52 53 56 public Collection getAttributes(Field targetField) { 57 return getAllAttributes(targetField); 58 } 59 60 63 public Collection getAttributes(Class targetClass) { 64 return getAllAttributes(targetClass); 65 } 66 67 70 public Collection getAttributes(Method targetMethod) { 71 return getAllAttributes(targetMethod); 72 } 73 74 75 } 76 | Popular Tags |