1 23 package com.sun.enterprise.tools.jsfext.el; 24 25 import com.sun.enterprise.tools.jsfext.layout.descriptor.LayoutElement; 26 import com.sun.enterprise.tools.jsfext.layout.descriptor.LayoutComponent; 27 28 import com.sun.web.ui.util.ClientSniffer; 29 import com.sun.web.ui.util.ThemeUtilities; 30 31 import java.lang.reflect.Field ; 32 import java.lang.reflect.Modifier ; 33 import java.util.ArrayList ; 34 import java.util.Iterator ; 35 import java.util.HashMap ; 36 import java.util.List ; 37 import java.util.Map ; 38 import java.util.ResourceBundle ; 39 import java.util.Stack ; 40 41 import javax.faces.component.NamingContainer; 42 import javax.faces.component.UIComponent; 43 import javax.faces.component.UIViewRoot; 44 import javax.faces.context.FacesContext; 45 import javax.faces.event.ActionEvent; 46 47 48 83 public class VariableResolver { 84 85 123 public static Object resolveVariables(FacesContext ctx, 124 LayoutElement desc, UIComponent component, String string, 125 String startToken, String typeDelim, String endToken) { 126 127 int stringLen = string.length(); 128 int delimIndex; 129 int endIndex; 130 int parenSemi; 131 int startTokenLen = startToken.length(); 132 int delimLen = typeDelim.length(); 133 int endTokenLen = endToken.length(); 134 boolean expressionIsWholeString = false; 135 char firstEndChar = SUB_END.charAt(0); 136 char firstDelimChar = SUB_TYPE_DELIM.charAt(0); 137 char currChar; 138 String type; 139 Object variable; 140 141 for (int startIndex = string.lastIndexOf(startToken); startIndex != -1; 142 startIndex = string.lastIndexOf(startToken, startIndex - 1)) { 143 144 delimIndex = string.indexOf(typeDelim, startIndex + startTokenLen); 146 if (delimIndex == -1) { 147 continue; 148 } 149 150 parenSemi = 0; 152 endIndex = -1; 153 for (int curr = delimIndex + delimLen; curr < stringLen; ) { 155 currChar = string.charAt(curr); 157 if ((currChar == firstDelimChar) && typeDelim.equals( 158 string.substring(curr, curr + delimLen))) { 159 parenSemi++; 161 curr += delimLen; 162 continue; 163 } 164 if ((currChar == firstEndChar) && endToken.equals( 165 string.substring(curr, curr + endTokenLen))) { 166 parenSemi--; 167 if (parenSemi < 0) { 168 endIndex = curr; 170 break; 171 } 172 curr += endTokenLen; 174 continue; 175 } 176 curr++; 177 } 178 if (endIndex == -1) { 179 continue; 181 } 182 183 197 198 if ((startIndex == 0) && (endIndex == string.lastIndexOf(endToken)) 203 && (string.endsWith(endToken))) { 204 expressionIsWholeString = true; 206 } 207 208 type = string.substring(startIndex + startTokenLen, delimIndex); 210 DataSource ds = (DataSource) dataSourceMap.get(type); 211 if (ds == null) { 212 throw new IllegalArgumentException ("Invalid type '" + type 213 + "' in attribute value: '" + string + "'."); 214 } 215 216 variable = string.substring(delimIndex + delimLen, endIndex); 218 219 variable = ds.getValue(ctx, desc, component, (String ) variable); 221 if (expressionIsWholeString) { 222 return variable; 223 } 224 225 string = string.substring(0, startIndex) + ((variable == null) ? "" : variable.toString()) 228 + string.substring(endIndex + endTokenLen); stringLen = string.length(); 230 } 231 232 return string; 234 } 235 236 246 public static Object resolveVariables(LayoutElement desc, 247 UIComponent component, Object value) { 248 if (value == null) { 249 return null; 250 } 251 return VariableResolver.resolveVariables( 252 FacesContext.getCurrentInstance(), desc, component, value); 253 } 254 255 266 public static Object resolveVariables(FacesContext ctx, LayoutElement desc, 267 UIComponent component, Object value) { 268 if (value == null) { 269 return null; 270 } 271 if (value instanceof String ) { 272 value = VariableResolver.resolveVariables( 273 ctx, 274 desc, 275 component, 276 (String ) value, 277 VariableResolver.SUB_START, 278 VariableResolver.SUB_TYPE_DELIM, 279 VariableResolver.SUB_END); 280 } else if (value instanceof List ) { 281 List list = ((List ) value); 283 int size = list.size(); 284 List newList = new ArrayList (size); 285 Iterator it = list.iterator(); 286 while (it.hasNext()) { 287 newList.add(VariableResolver.resolveVariables( 288 ctx, desc, component, it.next())); 289 } 290 return newList; 291 } 292 return value; 293 } 294 295 304 public static VariableResolver.DataSource getDataSource(String key) { 305 return (VariableResolver.DataSource) dataSourceMap.get(key); 306 } 307 308 316 public static void setDataSource(String key, 317 VariableResolver.DataSource dataSource) { 318 dataSourceMap.put(key, dataSource); 319 } 320 321 330 public interface DataSource { 331 343 Object getValue(FacesContext ctx, LayoutElement desc, 344 UIComponent component, String key); 345 } 346 347 352 public static class AttributeDataSource implements DataSource { 353 364 public Object getValue(FacesContext ctx, LayoutElement desc, 365 UIComponent component, String key) { 366 return ctx.getExternalContext().getRequestMap().get(key); 367 } 368 } 369 370 394 395 400 public static class RequestParameterDataSource implements DataSource { 401 412 public Object getValue(FacesContext ctx, LayoutElement desc, 413 UIComponent component, String key) { 414 return ctx.getExternalContext().getRequestParameterMap().get(key); 415 } 416 } 417 418 425 public static class PropertyDataSource implements DataSource { 426 437 public Object getValue(FacesContext ctx, LayoutElement desc, 438 UIComponent component, String key) { 439 440 int idx = key.indexOf(','); 442 boolean walk = false; 443 if (idx > 0) { 444 walk = Boolean.valueOf(key.substring(idx + 1)).booleanValue(); 445 key = key.substring(0, idx); 446 } 447 448 Object value = component.getAttributes().get(key); 449 while (walk && (value == null) && (component.getParent() != null)) { 450 component = component.getParent(); 451 value = component.getAttributes().get(key); 452 } 453 460 return value; 461 } 462 } 463 464 470 public static class HasPropertyDataSource implements DataSource { 471 482 public Object getValue(FacesContext ctx, LayoutElement desc, 483 UIComponent component, String key) { 484 boolean hasKey = component.getAttributes().containsKey(key); 485 if (!hasKey) { 486 if (component.getAttributes().get(key) != null) { 488 hasKey = true; 489 } 490 } 491 if (!hasKey && (desc instanceof LayoutComponent)) { 492 return getValue( 494 ctx, desc.getParent(), component.getParent(), key); 495 } 496 return Boolean.valueOf(hasKey); 497 } 498 } 499 500 505 public static class HasFacetDataSource implements DataSource { 506 517 public Object getValue(FacesContext ctx, LayoutElement desc, 518 UIComponent component, String key) { 519 boolean hasFacet = component.getFacets().containsKey(key); 520 if (!hasFacet && (desc instanceof LayoutComponent)) { 521 return getValue( 523 ctx, desc.getParent(), component.getParent(), key); 524 } 525 return Boolean.valueOf(hasFacet); 526 } 527 } 528 529 537 public static class EscapeDataSource implements DataSource { 538 549 public Object getValue(FacesContext ctx, LayoutElement desc, 550 UIComponent component, String key) { 551 return key; 552 } 553 } 554 555 565 public static class BooleanDataSource implements DataSource { 566 577 public Object getValue(FacesContext ctx, LayoutElement desc, 578 UIComponent component, String key) { 579 return Boolean.valueOf(key); 580 } 581 } 582 583 611 public static class BrowserDataSource implements DataSource { 612 623 public Object getValue(FacesContext ctx, LayoutElement desc, 624 UIComponent component, String key) { 625 DataSource ds = (DataSource) innerDataSources.get(key); 626 if (ds == null) { 627 throw new IllegalArgumentException ("'" + key 628 + "' is not a valid key for BrowserDataSource!"); 629 } 630 return ds.getValue(ctx, desc, component, key); 631 } 632 633 637 private static Map innerDataSources = new HashMap (); 638 639 static { 640 innerDataSources.put("getUserAgent", new DataSource() { 641 public Object getValue(FacesContext ctx, LayoutElement desc, 642 UIComponent component, String key) { 643 return ClientSniffer.getInstance(ctx).getUserAgent(); 644 } 645 }); 646 innerDataSources.put("getUserAgentMajor", new DataSource() { 647 public Object getValue(FacesContext ctx, LayoutElement desc, 648 UIComponent component, String key) { 649 return new Integer ( 650 ClientSniffer.getInstance(ctx).getUserAgentMajor()); 651 } 652 }); 653 innerDataSources.put("isIe", new DataSource() { 654 public Object getValue(FacesContext ctx, LayoutElement desc, 655 UIComponent component, String key) { 656 return Boolean.valueOf( 657 ClientSniffer.getInstance(ctx).isIe()); 658 } 659 }); 660 innerDataSources.put("isNav", new DataSource() { 661 public Object getValue(FacesContext ctx, LayoutElement desc, 662 UIComponent component, String key) { 663 return Boolean.valueOf( 664 ClientSniffer.getInstance(ctx).isNav()); 665 } 666 }); 667 innerDataSources.put("isGecko", new DataSource() { 668 public Object getValue(FacesContext ctx, LayoutElement desc, 669 UIComponent component, String key) { 670 return Boolean.valueOf( 671 ClientSniffer.getInstance(ctx).isGecko()); 672 } 673 }); 674 innerDataSources.put("isSun", new DataSource() { 675 public Object getValue(FacesContext ctx, LayoutElement desc, 676 UIComponent component, String key) { 677 return Boolean.valueOf( 678 ClientSniffer.getInstance(ctx).isSun()); 679 } 680 }); 681 innerDataSources.put("isWin", new DataSource() { 682 public Object getValue(FacesContext ctx, LayoutElement desc, 683 UIComponent component, String key) { 684 return Boolean.valueOf( 685 ClientSniffer.getInstance(ctx).isWin()); 686 } 687 }); 688 innerDataSources.put("isIe5up", new DataSource() { 689 public Object getValue(FacesContext ctx, LayoutElement desc, 690 UIComponent component, String key) { 691 return Boolean.valueOf( 692 ClientSniffer.getInstance(ctx).isIe5up()); 693 } 694 }); 695 innerDataSources.put("isIe6up", new DataSource() { 696 public Object getValue(FacesContext ctx, LayoutElement desc, 697 UIComponent component, String key) { 698 return Boolean.valueOf( 699 ClientSniffer.getInstance(ctx).isIe6up()); 700 } 701 }); 702 innerDataSources.put("isNav7up", new DataSource() { 703 public Object getValue(FacesContext ctx, LayoutElement desc, 704 UIComponent component, String key) { 705 return Boolean.valueOf( 706 ClientSniffer.getInstance(ctx).isNav7up()); 707 } 708 }); 709 innerDataSources.put("isIe6", new DataSource() { 710 public Object getValue(FacesContext ctx, LayoutElement desc, 711 UIComponent component, String key) { 712 return Boolean.valueOf( 713 ClientSniffer.getInstance(ctx).isIe6()); 714 } 715 }); 716 innerDataSources.put("isIe5", new DataSource() { 717 public Object getValue(FacesContext ctx, LayoutElement desc, 718 UIComponent component, String key) { 719 return Boolean.valueOf( 720 ClientSniffer.getInstance(ctx).isIe5()); 721 } 722 }); 723 innerDataSources.put("isIe4", new DataSource() { 724 public Object getValue(FacesContext ctx, LayoutElement desc, 725 UIComponent component, String key) { 726 return Boolean.valueOf( 727 ClientSniffer.getInstance(ctx).isIe4()); 728 } 729 }); 730 innerDataSources.put("isIe3", new DataSource() { 731 public Object getValue(FacesContext ctx, LayoutElement desc, 732 UIComponent component, String key) { 733 return Boolean.valueOf( 734 ClientSniffer.getInstance(ctx).isIe3()); 735 } 736 }); 737 innerDataSources.put("isNav70", new DataSource() { 738 public Object getValue(FacesContext ctx, LayoutElement desc, 739 UIComponent component, String key) { 740 return Boolean.valueOf( 741 ClientSniffer.getInstance(ctx).isNav70()); 742 } 743 }); 744 innerDataSources.put("isNav7", new DataSource() { 745 public Object getValue(FacesContext ctx, LayoutElement desc, 746 UIComponent component, String key) { 747 return Boolean.valueOf( 748 ClientSniffer.getInstance(ctx).isNav7()); 749 } 750 }); 751 innerDataSources.put("isNav6up", new DataSource() { 752 public Object getValue(FacesContext ctx, LayoutElement desc, 753 UIComponent component, String key) { 754 return Boolean.valueOf( 755 ClientSniffer.getInstance(ctx).isNav6up()); 756 } 757 }); 758 innerDataSources.put("isNav6", new DataSource() { 759 public Object getValue(FacesContext ctx, LayoutElement desc, 760 UIComponent component, String key) { 761 return Boolean.valueOf( 762 ClientSniffer.getInstance(ctx).isNav6()); 763 } 764 }); 765 innerDataSources.put("isNav4up", new DataSource() { 766 public Object getValue(FacesContext ctx, LayoutElement desc, 767 UIComponent component, String key) { 768 return Boolean.valueOf( 769 ClientSniffer.getInstance(ctx).isNav4up()); 770 } 771 }); 772 innerDataSources.put("isNav4", new DataSource() { 773 public Object getValue(FacesContext ctx, LayoutElement desc, 774 UIComponent component, String key) { 775 return Boolean.valueOf( 776 ClientSniffer.getInstance(ctx).isNav4()); 777 } 778 }); 779 } 780 } 781 782 792 public static class IntDataSource implements DataSource { 793 804 public Object getValue(FacesContext ctx, LayoutElement desc, 805 UIComponent component, String key) { 806 return Integer.valueOf(key); 807 } 808 } 809 810 817 public static class ConstantDataSource implements DataSource { 818 829 public Object getValue(FacesContext ctx, LayoutElement desc, 830 UIComponent component, String key) { 831 Object value = constantMap.get(key); 833 if (value == null) { 834 Map map = new HashMap (constantMap); 837 value = resolveValue(map, key); 838 839 constantMap = map; 841 } 842 return value; 843 } 844 845 860 private Object resolveValue(Map map, String key) { 861 int lastDot = key.lastIndexOf('.'); 862 if (lastDot == -1) { 863 throw new IllegalArgumentException ("Unable to resolve '" + key 864 + "' in $constant{" + key + "}. '" + key + "' must be a " 865 + "fully qualified classname plus the constant name."); 866 } 867 868 String className = key.substring(0, lastDot); 870 871 try { 873 addConstants(map, Class.forName(className)); 874 } catch (ClassNotFoundException ex) { 875 RuntimeException iae = new IllegalArgumentException ("'" 876 + className + "' was not found! This must be a valid " 877 + "classname. This was found in expression $constant{" 878 + key + "}."); 879 iae.initCause(ex); 880 throw iae; 881 } 882 883 return map.get(key); 885 } 886 887 895 private void addConstants(Map map, Class cls) { 896 String className = cls.getName(); 898 899 Field [] fields = cls.getFields(); 901 902 Field field = null; 904 for (int count = 0; count < fields.length; count++) { 905 field = fields[count]; 906 if (Modifier.isStatic(field.getModifiers()) 907 && Modifier.isFinal(field.getModifiers())) { 908 try { 909 map.put(className + '.' + field.getName(), 910 field.get(null)); 911 } catch (IllegalAccessException ex) { 912 throw new RuntimeException (ex); 913 } 914 } 915 } 916 } 917 918 922 private static Map constantMap = new HashMap (); 923 } 924 925 931 public static class MethodBindingDataSource implements DataSource { 932 943 public Object getValue(FacesContext ctx, LayoutElement desc, 944 UIComponent component, String key) { 945 return ctx.getApplication().createMethodBinding(key, actionArgs); 946 } 947 } 948 949 959 public static class ResourceBundleDataSource implements DataSource { 960 971 public Object getValue(FacesContext ctx, LayoutElement desc, 972 UIComponent component, String key) { 973 int separator = key.indexOf("."); 975 if (separator == -1) { 976 throw new IllegalArgumentException ("'" + key 977 + "' is not in format: \"[bundleID].[bundleKey]\"!"); 978 } 979 String value = key.substring(0, separator); 980 981 ResourceBundle bundle = (ResourceBundle ) ctx.getExternalContext(). 983 getRequestMap().get(value); 984 985 if (bundle == null) { 987 return key; 989 } 990 991 value = bundle.getString(key.substring(separator + 1)); 993 if (value == null) { 994 value = key; 995 } 996 997 return value; 998 } 999 } 1000 1001 1006 public static class SessionDataSource implements DataSource { 1007 1018 public Object getValue(FacesContext ctx, LayoutElement desc, 1019 UIComponent component, String key) { 1020 return ctx.getExternalContext().getSessionMap().get(key); 1021 } 1022 } 1023 1024 1029 public static class StackTraceDataSource implements DataSource { 1030 1041 public Object getValue(FacesContext ctx, LayoutElement desc, 1042 UIComponent component, String key) { 1043 StackTraceElement [] trace = Thread.currentThread().getStackTrace(); 1045 int len = trace.length; 1046 1047 StringBuffer buf = new StringBuffer (key + "\n"); 1049 for (int idx = 0; idx < len; idx++) { 1050 buf.append(trace[idx] + "\n"); 1051 } 1052 1053 return buf.toString(); 1055 } 1056 } 1057 1058 1064 public static class StyleDataSource implements DataSource { 1065 1076 public Object getValue(FacesContext ctx, LayoutElement desc, 1077 UIComponent component, String key) { 1078 return ThemeUtilities.getTheme(ctx).getStyleClass(key); 1079 } 1080 } 1081 1082 1088 public static class ThemeDataSource implements DataSource { 1089 1100 public Object getValue(FacesContext ctx, LayoutElement desc, 1101 UIComponent component, String key) { 1102 return ThemeUtilities.getTheme(ctx).getMessage(key); 1103 } 1104 } 1105 1106 1113 public static class ThemeJavaScriptDataSource implements DataSource { 1114 1125 public Object getValue(FacesContext ctx, LayoutElement desc, 1126 UIComponent component, String key) { 1127 return ThemeUtilities.getTheme(ctx).getPathToJSFile(key); 1128 } 1129 } 1130 1131 1161 1162 1178 public static class ThisDataSource implements DataSource { 1179 1190 public Object getValue(FacesContext ctx, LayoutElement desc, 1191 UIComponent comp, String key) { 1192 Object value = null; 1193 1194 if ((key.equalsIgnoreCase(CLIENT_ID)) || (key.length() == 0)) { 1195 value = comp.getClientId(ctx); 1196 } else if (key.equalsIgnoreCase(ID)) { 1197 value = comp.getId(); 1198 } else if (key.equalsIgnoreCase(COMPONENT)) { 1199 value = comp; 1200 } else if (key.equalsIgnoreCase(LAYOUT_ELEMENT)) { 1201 value = desc; 1202 } else if (key.equalsIgnoreCase(PARENT_ID)) { 1203 value = comp.getParent().getId(); 1204 } else if (key.equalsIgnoreCase(PARENT_CLIENT_ID)) { 1205 value = comp.getParent().getClientId(ctx); 1206 } else if (key.equalsIgnoreCase(PARENT)) { 1207 value = comp.getParent(); 1208 } else if (key.equalsIgnoreCase(PARENT_LAYOUT_ELEMENT)) { 1209 value = desc.getParent(); 1210 } else if (key.equalsIgnoreCase(NAMING_CONTAINER)) { 1211 for (value = comp.getParent(); value != null; 1212 value = ((UIComponent) value).getParent()) { 1213 if (value instanceof NamingContainer) { 1214 break; 1215 } 1216 } 1217 } else if (key.equalsIgnoreCase(VALUE_BINDING)) { 1218 Stack stack = new Stack (); 1220 String id = null; 1221 comp = comp.getParent(); 1226 while ((comp != null) && !(comp instanceof UIViewRoot)) { 1227 id = comp.getId(); 1228 if (id == null) { 1229 id = comp.getClientId(ctx); 1231 id = id.substring(id.lastIndexOf( 1232 NamingContainer.SEPARATOR_CHAR) + 1); 1233 } 1234 stack.push(id); 1235 comp = comp.getParent(); 1236 } 1237 StringBuffer buf = new StringBuffer (); 1238 buf.append("view"); 1239 while (!stack.empty()) { 1240 buf.append("." + stack.pop()); 1241 } 1242 value = buf.toString(); 1243 } else { 1244 throw new IllegalArgumentException ("'" + key 1245 + "' is not valid in $this{" + key + "}."); 1246 } 1247 1248 return value; 1249 } 1250 1251 1255 public static final String COMPONENT = "component"; 1256 1257 1261 public static final String CLIENT_ID = "clientId"; 1262 1263 1267 public static final String ID = "id"; 1268 1269 1273 public static final String LAYOUT_ELEMENT = "layoutElement"; 1274 1275 1279 public static final String PARENT = "parent"; 1280 1281 1285 public static final String PARENT_ID = "parentId"; 1286 1287 1291 public static final String PARENT_CLIENT_ID = "parentClientId"; 1292 1293 1297 public static final String PARENT_LAYOUT_ELEMENT = 1298 "parentLayoutElement"; 1299 1300 1304 public static final String NAMING_CONTAINER = "namingContainer"; 1305 1306 1310 public static final String VALUE_BINDING = "valueBinding"; 1311 } 1312 1313 1318 public static void main(String [] args) { 1319 String test = null; 1320 String good = null; 1321 1322 test = "" + VariableResolver.resolveVariables(null, null, null, 1323 "$escape($escape(LayoutElement))", "$", "(", ")"); 1324 good = "LayoutElement"; 1325 System.out.println("Expected Result: '" + good + "'"); 1326 System.out.println(" Result: '" + test + "'"); 1327 if (!test.equals(good)) { 1328 System.out.println("FAILED!!!!"); 1329 } 1330 1331 test = "" + VariableResolver.resolveVariables(null, null, null, 1332 "$escape($escape(EEPersistenceManager))", "$", "(", ")"); 1333 good = "EEPersistenceManager"; 1334 System.out.println("Expected Result: '" + good + "'"); 1335 System.out.println(" Result: '" + test + "'"); 1336 if (!test.equals(good)) { 1337 System.out.println("FAILED!!!!"); 1338 } 1339 1340 test = "" + VariableResolver.resolveVariables(null, null, null, 1341 "$es$cape$escape(EEPersistenceManager))", "$", "(", ")"); 1342 good = "$es$capeEEPersistenceManager)"; 1343 System.out.println("Expected Result: '" + good + "'"); 1344 System.out.println(" Result: '" + test + "'"); 1345 if (!test.equals(good)) { 1346 System.out.println("FAILED!!!!"); 1347 } 1348 1349 test = "" + VariableResolver.resolveVariables(null, null, null, 1350 "$escape($escapeEEP$ersistenceManager))", "$", "(", ")"); 1351 good = "$escapeEEP$ersistenceManager)"; 1352 System.out.println("Expected Result: '" + good + "'"); 1353 System.out.println(" Result: '" + test + "'"); 1354 if (!test.equals(good)) { 1355 System.out.println("FAILED!!!!"); 1356 } 1357 1358 test = "" + VariableResolver.resolveVariables(null, null, null, 1359 "$escape($escape(EEPersistenceManager)))", "$", "(", ")"); 1360 good = "EEPersistenceManager)"; 1361 System.out.println("Expected Result: '" + good + "'"); 1362 System.out.println(" Result: '" + test + "'"); 1363 if (!test.equals(good)) { 1364 System.out.println("FAILED!!!!"); 1365 } 1366 1367 test = "" + VariableResolver.resolveVariables(null, null, null, 1368 "$escape($escape(EEPersistenceManager())", "$", "(", ")"); 1369 good = "$escape(EEPersistenceManager()"; 1370 System.out.println("Expected Result: '" + good + "'"); 1371 System.out.println(" Result: '" + test + "'"); 1372 if (!test.equals(good)) { 1373 System.out.println("FAILED!!!!"); 1374 } 1375 1376 test = "" + VariableResolver.resolveVariables(null, null, null, 1377 "$escape($escape($escape(EEPersistenceManager()))==$escape(" 1378 + "EEPersistenceManager()))", "$", "(", ")"); 1379 good = "EEPersistenceManager()==EEPersistenceManager()"; 1380 System.out.println("Expected Result: '" + good + "'"); 1381 System.out.println(" Result: '" + test + "'"); 1382 if (!test.equals(good)) { 1383 System.out.println("FAILED!!!!"); 1384 } 1385 1386 test = "" + VariableResolver.resolveVariables(null, null, null, 1387 "$escape($escape($escape(EEPersistenceManager()))==$escape(" 1388 + "EEPersistenceManager()))", "$", "(", ")"); 1389 good = "EEPersistenceManager()==EEPersistenceManager()"; 1390 System.out.println("Expected Result: '" + good + "'"); 1391 System.out.println(" Result: '" + test + "'"); 1392 if (!test.equals(good)) { 1393 System.out.println("FAILED!!!!"); 1394 } 1395 1396 1404 } 1405 1406 1407 1411 private static Map dataSourceMap = new HashMap (); 1412 1413 1417 public static final String ATTRIBUTE = "attribute"; 1418 1419 1424 1425 1429 public static final String PROPERTY = "property"; 1430 1431 1435 public static final String HAS_PROPERTY = "hasProperty"; 1436 1437 1441 public static final String HAS_FACET = "hasFacet"; 1442 1443 1447 public static final String SESSION = "session"; 1448 1449 1453 public static final String STACK_TRACE = "stackTrace"; 1454 1455 1460 public static final String STYLE = "style"; 1461 1462 1467 public static final String THEME = "theme"; 1468 1469 1474 public static final String THEME_JS = "themeScript"; 1475 1476 1481 public static final String REQUEST_PARAMETER = "requestParameter"; 1482 1483 1488 1489 1496 public static final String THIS = "this"; 1497 1498 1503 public static final String ESCAPE = "escape"; 1504 1505 1509 public static final String BOOLEAN = "boolean"; 1510 1511 1515 public static final String BROWSER = "browser"; 1516 1517 1521 public static final String INT = "int"; 1522 1523 1527 public static final String METHOD_BINDING = "methodBinding"; 1528 1529 1533 public static final String CONSTANT = "constant"; 1534 1535 1539 public static final String RESOURCE = "resource"; 1540 1541 1542 static { 1544 AttributeDataSource attrDS = new AttributeDataSource(); 1545 dataSourceMap.put(ATTRIBUTE, attrDS); 1546 dataSourceMap.put("", attrDS); 1547 dataSourceMap.put(PROPERTY, new PropertyDataSource()); 1549 dataSourceMap.put(HAS_PROPERTY, new HasPropertyDataSource()); 1550 dataSourceMap.put(HAS_FACET, new HasFacetDataSource()); 1551 dataSourceMap.put(SESSION, new SessionDataSource()); 1552 dataSourceMap.put(STACK_TRACE, new StackTraceDataSource()); 1553 dataSourceMap.put(STYLE, new StyleDataSource()); 1554 dataSourceMap.put(THEME, new ThemeDataSource()); 1555 dataSourceMap.put(THEME_JS, new ThemeJavaScriptDataSource()); 1556 dataSourceMap.put(REQUEST_PARAMETER, new RequestParameterDataSource()); 1557 dataSourceMap.put(THIS, new ThisDataSource()); 1559 dataSourceMap.put(ESCAPE, new EscapeDataSource()); 1560 dataSourceMap.put(INT, new IntDataSource()); 1561 dataSourceMap.put(BOOLEAN, new BooleanDataSource()); 1562 dataSourceMap.put(BROWSER, new BrowserDataSource()); 1563 dataSourceMap.put(CONSTANT, new ConstantDataSource()); 1564 dataSourceMap.put(RESOURCE, new ResourceBundleDataSource()); 1565 dataSourceMap.put(METHOD_BINDING, new MethodBindingDataSource()); 1566 } 1567 1568 1571 private static Class [] actionArgs = {ActionEvent.class}; 1572 1573 1576 public static final String SUB_START = "$"; 1577 1578 1579 1583 public static final String SUB_TYPE_DELIM = "{"; 1584 1585 1586 1590 public static final String SUB_END = "}"; 1591} 1592 | Popular Tags |