1 5 package xdoclet.modules.jboss.jmx; 6 7 import java.util.Collections ; 8 import java.util.HashMap ; 9 import java.util.Map ; 10 import java.util.Properties ; 11 12 import xdoclet.TemplateSubTask; 13 import xdoclet.XDocletException; 14 15 import xdoclet.tagshandler.ClassTagsHandler; 16 import xdoclet.tagshandler.PropertyTagsHandler; 17 18 import xdoclet.template.TemplateException; 19 20 25 public class JMXTagsHandler 26 extends ClassTagsHandler 27 { 28 private final static Map INTERNAL_TYPES; 29 static { 30 Map m = new HashMap (); 31 32 m.put(Byte.TYPE.getName(), "B"); 33 m.put(Short.TYPE.getName(), "S"); 34 m.put(Integer.TYPE.getName(), "I"); 35 m.put(Long.TYPE.getName(), "J"); 36 m.put(Float.TYPE.getName(), "F"); 37 m.put(Double.TYPE.getName(), "D"); 38 m.put(Boolean.TYPE.getName(), "Z"); 39 m.put(Character.TYPE.getName(), "C"); 40 41 INTERNAL_TYPES = Collections.unmodifiableMap(m); 42 } 43 44 45 public String managedAttributeType() 46 throws XDocletException 47 { 48 Properties attributes = new Properties (); 49 50 attributes.setProperty("tagName", "jmx.managed-attribute"); 51 52 PropertyTagsHandler pth = null; 55 56 try { 57 pth = (PropertyTagsHandler) ((TemplateSubTask) getDocletContext().getActiveSubTask()).getEngine().getTagHandlerFor("Property"); 58 } 59 catch (TemplateException te) { 60 throw new XDocletException(te, "there's some funky shiat going on!"); 61 } 62 63 String type = pth.propertyTypeWithTag(attributes); 66 67 int indexOfOpenBracket = type.indexOf('['); 71 72 if (indexOfOpenBracket != -1) { 73 String originalType = type; 74 75 type = originalType.substring(0, indexOfOpenBracket); 76 77 type = 81 INTERNAL_TYPES.containsKey(type) ? (String ) INTERNAL_TYPES.get(type) : 82 ("L" + type + ";"); 83 84 for (int index = indexOfOpenBracket; index != -1; 87 index = originalType.indexOf('[', index + 1)) { 88 type = '[' + type; 89 } 90 } 91 92 return type; 93 } 94 } 95 | Popular Tags |