1 package org.apache.beehive.controls.runtime.bean; 2 19 20 import java.util.Locale ; 21 import java.util.MissingResourceException ; 22 import java.util.ResourceBundle ; 23 24 29 abstract public class ControlBeanInfo extends java.beans.SimpleBeanInfo 30 { 31 35 protected ControlBeanInfo(Class beanClass) 36 { 37 super(); 38 _beanClass = beanClass; 39 } 40 41 50 final protected String localizeString(String input) 51 { 52 if (input == null || !input.startsWith("%") || !input.endsWith("%")) 53 return input; 54 String bundleName = input.substring(1, input.length()-1); 55 String resourceName = null; 56 String output = input; 57 int lastDot = bundleName.lastIndexOf('.'); 58 while (lastDot != -1 && lastDot != 0 && (lastDot+1 < bundleName.length())) 59 { 60 if (resourceName == null) 63 resourceName = bundleName.substring(lastDot+1); 64 else 65 resourceName = bundleName.substring(lastDot+1) + '.' + resourceName; 66 bundleName = bundleName.substring(0, lastDot); 67 68 try 69 { 70 ResourceBundle bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault(), 71 _beanClass.getClassLoader()); 72 if (bundle != null) 73 { 74 String lookup = bundle.getString(resourceName); 75 if (lookup != null) 76 return lookup; 77 } 78 } 79 catch (MissingResourceException mre) 80 { } 81 82 lastDot = bundleName.lastIndexOf('.'); 83 84 } 85 86 return input; 87 } 88 89 Class _beanClass; 90 } 91 | Popular Tags |