1 11 package org.eclipse.help.internal.webapp.data; 12 13 import java.util.*; 14 15 import javax.servlet.http.*; 16 17 import org.eclipse.help.internal.base.HelpBasePlugin; 18 import org.eclipse.help.internal.webapp.*; 19 20 24 public class ServletResources { 25 26 29 protected ServletResources() { 30 super(); 31 } 32 33 public static String getConfirmShowAllExplanation(HttpServletRequest request) { 34 String message = HelpBasePlugin.getActivitySupport().getShowAllMessage(); 35 if (message==null) 36 message = getString("confirmShowAllExplanation", request); return message; 38 } 39 40 48 public static String getString(String name, HttpServletRequest request) { 49 String property = WebappResources.getString(name, UrlUtil.getLocaleObj( 50 request, null)); 51 if (property == null || property.length() <= 0) { 52 return property; 53 } 54 int amp = property.indexOf('&'); 55 if (amp <0 || amp >= property.length() - 1) { 56 return property; 57 } 58 return property.substring(0, amp) 59 + property.substring(amp + 1, property.length()); 60 } 61 62 70 public static String getString(String name, String replace0, 71 HttpServletRequest request) { 72 String property = WebappResources.getString(name, UrlUtil.getLocaleObj( 73 request, null), replace0); 74 if (property == null || property.length() <= 0) { 75 return property; 76 } 77 int amp = property.indexOf('&'); 78 if (amp <0 || amp >= property.length() - 1) { 79 return property; 80 } 81 return property.substring(0, amp - 1) 82 + property.substring(amp + 1, property.length()); 83 } 84 94 public static String getLabel(String name, HttpServletRequest request) { 95 String property = WebappResources.getString(name, UrlUtil.getLocaleObj( 96 request, null)); 97 if (property == null || property.length() <= 0) { 98 return property; 99 } 100 int amp = property.indexOf('&'); 101 if (amp <0 || amp >= property.length() - 1) { 102 return property; 103 } 104 return property.substring(0, amp) 105 + "<u STYLE=\"ACCELERATOR:true\">" + property.charAt(amp+1) + "</u>" + property.substring(amp + 2, property.length()); 108 } 109 110 118 public static String getAccessKey(String name, HttpServletRequest request) { 119 String property = WebappResources.getString(name, UrlUtil.getLocaleObj( 120 request, null)); 121 if (property == null || property.length() <= 0) { 122 return null; 123 } 124 int amp = property.indexOf('&'); 125 if (amp <0 || amp >= property.length() - 1) { 126 return null; 127 } 128 return ("" + property.charAt(amp +1)).toLowerCase(Locale.ENGLISH); } 130 131 } 132 | Popular Tags |