Coverage Report - org.kuali.rice.krad.uif.util.ComponentUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
ComponentUtils
0%
0/251
0%
0/206
4.548
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation Licensed under the Educational Community
 3  
  * License, Version 1.0 (the "License"); you may not use this file except in
 4  
  * compliance with the License. You may obtain a copy of the License at
 5  
  * http://www.opensource.org/licenses/ecl1.php Unless required by applicable law
 6  
  * or agreed to in writing, software distributed under the License is
 7  
  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 8  
  * KIND, either express or implied. See the License for the specific language
 9  
  * governing permissions and limitations under the License.
 10  
  */
 11  
 package org.kuali.rice.krad.uif.util;
 12  
 
 13  
 import java.beans.PropertyDescriptor;
 14  
 import java.io.Serializable;
 15  
 import java.util.ArrayList;
 16  
 import java.util.Collections;
 17  
 import java.util.HashSet;
 18  
 import java.util.List;
 19  
 import java.util.ListIterator;
 20  
 import java.util.Map;
 21  
 import java.util.Set;
 22  
 
 23  
 import org.apache.commons.lang.StringUtils;
 24  
 import org.kuali.rice.core.util.type.TypeUtils;
 25  
 import org.kuali.rice.krad.uif.UifConstants;
 26  
 import org.kuali.rice.krad.uif.container.CollectionGroup;
 27  
 import org.kuali.rice.krad.uif.container.Container;
 28  
 import org.kuali.rice.krad.uif.core.Component;
 29  
 import org.kuali.rice.krad.uif.core.DataBinding;
 30  
 import org.kuali.rice.krad.uif.core.Ordered;
 31  
 import org.kuali.rice.krad.uif.field.AttributeField;
 32  
 import org.kuali.rice.krad.uif.field.Field;
 33  
 import org.kuali.rice.krad.uif.field.GroupField;
 34  
 import org.kuali.rice.krad.uif.layout.LayoutManager;
 35  
 import org.kuali.rice.krad.util.ObjectUtils;
 36  
 import org.springframework.beans.BeanUtils;
 37  
 import org.springframework.core.OrderComparator;
 38  
 
 39  
 /**
 40  
  * Utility class providing methods to help create and modify
 41  
  * <code>Component</code> instances
 42  
  * 
 43  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 44  
  */
 45  0
 public class ComponentUtils {
 46  
     
 47  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ComponentUtils.class);
 48  
 
 49  
 
 50  
     public static <T extends Component> T copy(T component) {
 51  0
         return copy(component, null);
 52  
     }
 53  
 
 54  
     public static <T extends Component> T copy(T component, String idSuffix) {
 55  0
         T copy = copyObject(component);
 56  
 
 57  0
         if (StringUtils.isNotBlank(idSuffix)) {
 58  0
             updateIdsWithSuffixNested(copy, idSuffix);
 59  
         }
 60  
 
 61  0
         return copy;
 62  
     }
 63  
 
 64  
     public static <T extends Object> T copyObject(T object) {
 65  0
         if (object == null) {
 66  0
             return null;
 67  
         }
 68  
 
 69  0
         T copy = null;
 70  
         try {
 71  0
             copy = CloneUtils.deepClone(object);
 72  
         }
 73  0
         catch (Exception e) {
 74  0
             throw new RuntimeException(e);
 75  0
         }
 76  
 
 77  0
         return copy;
 78  
     }
 79  
 
 80  
     protected static Object getCopyPropertyValue(Set<String> propertiesForReferenceCopy, String propertyName,
 81  
             Object propertyValue) {
 82  0
         if (propertyValue == null) {
 83  0
             return null;
 84  
         }
 85  
 
 86  0
         Object copyValue = propertyValue;
 87  
 
 88  0
         Class<?> valuePropertyType = propertyValue.getClass();
 89  0
         if (propertiesForReferenceCopy.contains(propertyName) || TypeUtils.isSimpleType(valuePropertyType)
 90  
                 || TypeUtils.isClassClass(valuePropertyType)) {
 91  0
             return copyValue;
 92  
         }
 93  
 
 94  0
         if (Component.class.isAssignableFrom(valuePropertyType)
 95  
                 || LayoutManager.class.isAssignableFrom(valuePropertyType)) {
 96  0
             copyValue = copyObject(propertyValue);
 97  
         }
 98  
         else {
 99  0
             copyValue = ObjectUtils.deepCopy((Serializable) propertyValue);
 100  
         }
 101  
 
 102  0
         return copyValue;
 103  
     }
 104  
 
 105  
     @SuppressWarnings("unchecked")
 106  
     protected static <T extends Object> T getNewInstance(T object) {
 107  0
         T copy = null;
 108  
         try {
 109  0
             copy = (T) object.getClass().newInstance();
 110  
         }
 111  0
         catch (Exception e) {
 112  0
             throw new RuntimeException("Unable to create new instance of class: " + object.getClass());
 113  0
         }
 114  
 
 115  0
         return copy;
 116  
     }
 117  
 
 118  
     public static <T extends Field> List<T> copyFieldList(List<T> fields, String addBindingPrefix, String idSuffix) {
 119  0
         List<T> copiedFieldList = copyFieldList(fields, idSuffix);
 120  
 
 121  0
         prefixBindingPath(copiedFieldList, addBindingPrefix);
 122  
 
 123  0
         return copiedFieldList;
 124  
     }
 125  
 
 126  
     public static <T extends Field> List<T> copyFieldList(List<T> fields, String idSuffix) {
 127  0
         List<T> copiedFieldList = new ArrayList<T>();
 128  
 
 129  0
         for (T field : fields) {
 130  0
             T copiedField = copy(field, idSuffix);
 131  0
             copiedFieldList.add(copiedField);
 132  0
         }
 133  
 
 134  0
         return copiedFieldList;
 135  
     }
 136  
 
 137  
     public static <T extends Component> T copyComponent(T component, String addBindingPrefix, String idSuffix) {
 138  0
         T copy = copy(component, idSuffix);
 139  
 
 140  0
         prefixBindingPathNested(copy, addBindingPrefix);
 141  
 
 142  0
         return copy;
 143  
     }
 144  
 
 145  
     public static <T extends Component> List<T> copyComponentList(List<T> components, String idSuffix) {
 146  0
         List<T> copiedComponentList = new ArrayList<T>();
 147  
 
 148  0
         for (T field : components) {
 149  0
             T copiedComponent = copy(field, idSuffix);
 150  0
             copiedComponentList.add(copiedComponent);
 151  0
         }
 152  
 
 153  0
         return copiedComponentList;
 154  
     }
 155  
 
 156  
     @SuppressWarnings("unchecked")
 157  
     public static <T extends Component> List<T> getComponentsOfType(List<? extends Component> items,
 158  
             Class<T> componentType) {
 159  0
         List<T> typeComponents = new ArrayList<T>();
 160  
 
 161  0
         for (Component component : items) {
 162  0
             if (componentType.isAssignableFrom(component.getClass())) {
 163  0
                 typeComponents.add((T) component);
 164  
             }
 165  
         }
 166  
 
 167  0
         return typeComponents;
 168  
     }
 169  
     
 170  
     public static <T extends Component> List<T> getComponentsOfTypeDeep(List<? extends Component> items,
 171  
             Class<T> componentType) {
 172  0
         List<T> typeComponents = new ArrayList<T>();
 173  
 
 174  0
         for (Component component : items) {
 175  0
             typeComponents.addAll(getComponentsOfTypeDeep(component, componentType));
 176  
         }
 177  
 
 178  0
         return typeComponents;
 179  
     }
 180  
     
 181  
     @SuppressWarnings("unchecked")
 182  
     public static <T extends Component> List<T> getComponentsOfTypeDeep(Component component, Class<T> componentType) {
 183  0
         List<T> typeComponents = new ArrayList<T>();
 184  
 
 185  0
         if (component == null) {
 186  0
             return typeComponents;
 187  
         }
 188  
 
 189  0
         if (componentType.isAssignableFrom(component.getClass())) {
 190  0
             typeComponents.add((T) component);
 191  
         }
 192  
 
 193  0
         for (Component nested : component.getNestedComponents()) {
 194  0
             typeComponents.addAll(getComponentsOfTypeDeep(nested, componentType));
 195  
         }
 196  
 
 197  0
         return typeComponents;
 198  
     }   
 199  
 
 200  
     public static void prefixBindingPath(List<? extends Field> fields, String addBindingPrefix) {
 201  0
         for (Field field : fields) {
 202  0
             if (field instanceof DataBinding) {
 203  0
                 prefixBindingPath((DataBinding) field, addBindingPrefix);
 204  
             }
 205  0
             else if (field instanceof GroupField) {
 206  0
                 List<Field> groupFields = getComponentsOfType(((GroupField) field).getItems(), Field.class);
 207  0
                 prefixBindingPath(groupFields, addBindingPrefix);
 208  0
             }
 209  
         }
 210  0
     }
 211  
 
 212  
     public static void prefixBindingPathNested(Component component, String addBindingPrefix) {
 213  0
         if (component instanceof DataBinding) {
 214  0
             if (LOG.isDebugEnabled()) {
 215  0
                 LOG.info("setting nested binding prefix '"+ addBindingPrefix  +"' on " + component);
 216  
             }
 217  0
             prefixBindingPath((DataBinding) component, addBindingPrefix);
 218  
         }
 219  
 
 220  0
         for (Component nested : component.getNestedComponents()) {
 221  0
            if (nested != null) {
 222  0
               prefixBindingPathNested(nested, addBindingPrefix);
 223  
            }
 224  
         }
 225  0
     }
 226  
 
 227  
     public static void prefixBindingPath(DataBinding field, String addBindingPrefix) {
 228  0
         String bindingPrefix = addBindingPrefix;
 229  0
         if (StringUtils.isNotBlank(field.getBindingInfo().getBindByNamePrefix())) {
 230  0
             bindingPrefix += "." + field.getBindingInfo().getBindByNamePrefix();
 231  
         }
 232  0
         field.getBindingInfo().setBindByNamePrefix(bindingPrefix);
 233  
         
 234  0
         if (field instanceof AttributeField){
 235  0
                 AttributeField attrfield = (AttributeField)field;
 236  0
                 if (StringUtils.isNotBlank(attrfield.getAdditionalDisplayPropertyName())){
 237  0
                         attrfield.getAdditionalDisplayPropertyBindingInfo().setBindByNamePrefix(bindingPrefix);
 238  
                 }
 239  0
                 if (StringUtils.isNotBlank(attrfield.getAlternateDisplayPropertyName())){
 240  0
                         attrfield.getAlternateDisplayPropertyBindingInfo().setBindByNamePrefix(bindingPrefix);
 241  
                 }
 242  
         }
 243  0
     }
 244  
 
 245  
     public static void updateIdsWithSuffixNested(List<? extends Component> components, String idSuffix) {
 246  0
         for (Component component : components) {
 247  0
             updateIdsWithSuffixNested(component, idSuffix);
 248  
         }
 249  0
     }
 250  
 
 251  
     public static void updateIdsWithSuffixNested(Component component, String idSuffix) {
 252  0
         updateIdsWithSuffix(component, idSuffix);
 253  
 
 254  0
         if (Container.class.isAssignableFrom(component.getClass())) {
 255  0
             LayoutManager layoutManager = ((Container) component).getLayoutManager();
 256  0
             layoutManager.setId(layoutManager.getId() + idSuffix);
 257  
         }
 258  
 
 259  0
         for (Component nested : component.getNestedComponents()) {
 260  0
             if (nested != null) {
 261  0
                 updateIdsWithSuffixNested(nested, idSuffix);
 262  
             }
 263  
         }
 264  0
     }
 265  
 
 266  
     public static void updateIdsWithSuffix(Component component, String idSuffix) {
 267  
         // make sure id has two underscore delimiter so we can pick off original dictionary id
 268  0
         component.setId(component.getId() + idSuffix);
 269  0
     }
 270  
 
 271  
     public static void setComponentsPropertyDeep(List<? extends Component> components, String propertyPath,
 272  
             Object propertyValue) {
 273  0
         for (Component component : components) {
 274  0
             setComponentPropertyDeep(component, propertyPath, propertyValue);
 275  
         }
 276  0
     }
 277  
 
 278  
     public static void setComponentPropertyDeep(Component component, String propertyPath, Object propertyValue) {
 279  0
         ObjectPropertyUtils.setPropertyValue(component, propertyPath, propertyValue, true);
 280  
 
 281  0
         for (Component nested : component.getNestedComponents()) {
 282  0
             if (nested != null) {
 283  0
                 setComponentPropertyDeep(nested, propertyPath, propertyValue);
 284  
             }
 285  
         }
 286  0
     }
 287  
 
 288  
     public static List<String> getComponentPropertyNames(Class<? extends Component> componentClass) {
 289  0
         List<String> componentProperties = new ArrayList<String>();
 290  
 
 291  0
         PropertyDescriptor[] properties = BeanUtils.getPropertyDescriptors(componentClass);
 292  0
         for (int i = 0; i < properties.length; i++) {
 293  0
             PropertyDescriptor descriptor = properties[i];
 294  0
             if (descriptor.getReadMethod() != null) {
 295  0
                 componentProperties.add(descriptor.getName());
 296  
             }
 297  
         }
 298  
 
 299  0
         return componentProperties;
 300  
     }
 301  
 
 302  
     public static void pushObjectToContext(List<? extends Component> components, String contextName, Object contextValue) {
 303  0
         for (Component component : components) {
 304  0
             pushObjectToContext(component, contextName, contextValue);
 305  
         }
 306  0
     }
 307  
 
 308  
     public static void pushObjectToContext(Component component, String contextName, Object contextValue) {
 309  0
         if (component == null) {
 310  0
             return;
 311  
         }
 312  
 
 313  0
         component.pushObjectToContext(contextName, contextValue);
 314  
 
 315  
         // special container check so we pick up the layout manager
 316  0
         if (Container.class.isAssignableFrom(component.getClass())) {
 317  0
             LayoutManager layoutManager = ((Container) component).getLayoutManager();
 318  0
             if (layoutManager != null) {
 319  0
                 layoutManager.pushObjectToContext(contextName, contextValue);
 320  
 
 321  0
                 for (Component nestedComponent : layoutManager.getNestedComponents()) {
 322  0
                     pushObjectToContext(nestedComponent, contextName, contextValue);
 323  
                 }
 324  
             }
 325  
         }
 326  
 
 327  0
         for (Component nestedComponent : component.getNestedComponents()) {
 328  0
             pushObjectToContext(nestedComponent, contextName, contextValue);
 329  
         }
 330  0
     }
 331  
 
 332  
     public static void updateContextsForLine(List<? extends Component> components, Object collectionLine,
 333  
             int lineIndex) {
 334  0
         for (Component component : components) {
 335  0
             updateContextForLine(component, collectionLine, lineIndex);
 336  
         }
 337  0
     }
 338  
 
 339  
     public static void updateContextForLine(Component component, Object collectionLine, int lineIndex) {
 340  0
         pushObjectToContext(component, UifConstants.ContextVariableNames.LINE, collectionLine);
 341  0
         pushObjectToContext(component, UifConstants.ContextVariableNames.INDEX, new Integer(lineIndex));
 342  
         
 343  0
         boolean isAddLine = (lineIndex == -1);
 344  0
         pushObjectToContext(component, UifConstants.ContextVariableNames.IS_ADD_LINE, isAddLine);
 345  0
     }
 346  
 
 347  
     public static void processIds(Component component, Map<String, Integer> seenIds) {
 348  0
         String componentId = component.getId();
 349  0
         Integer seenCount = new Integer(0);
 350  0
         if (StringUtils.isNotBlank(componentId)) {
 351  0
             if (seenIds.containsKey(componentId)) {
 352  0
                 seenCount = seenIds.get(componentId);
 353  0
                 seenCount += 1;
 354  
 
 355  0
                 component.setId(componentId + "_" + seenCount);
 356  
             }
 357  
 
 358  0
             seenIds.put(componentId, seenCount);
 359  
         }
 360  
 
 361  0
         if (Container.class.isAssignableFrom(component.getClass())) {
 362  0
             LayoutManager layoutManager = ((Container) component).getLayoutManager();
 363  0
             if ((layoutManager != null) && StringUtils.isNotBlank(layoutManager.getId())) {
 364  0
                 seenCount = new Integer(0);
 365  0
                 if (seenIds.containsKey(layoutManager.getId())) {
 366  0
                     seenCount = seenIds.get(layoutManager.getId());
 367  0
                     seenCount += 1;
 368  
 
 369  0
                     layoutManager.setId(layoutManager.getId() + "_" + seenCount);
 370  
                 }
 371  
 
 372  0
                 seenIds.put(layoutManager.getId(), seenCount);
 373  
             }
 374  
         }
 375  
 
 376  0
         for (Component nested : component.getNestedComponents()) {
 377  0
             if (nested != null) {
 378  0
                 processIds(nested, seenIds);
 379  
             }
 380  
         }
 381  0
     }
 382  
 
 383  
     /**
 384  
      * Performs sorting logic of the given list of <code>Ordered</code>
 385  
      * instances by its order property
 386  
      * <p>
 387  
      * Items list is sorted based on its order property. Lower order values are
 388  
      * placed higher in the list. If a item does not have a value assigned for
 389  
      * the order (or is equal to the default order of 0), it will be assigned
 390  
      * the a value based on the given order sequence integer. If two or more
 391  
      * items share the same order value, all but the last item found in the list
 392  
      * will be removed.
 393  
      * </p>
 394  
      * 
 395  
      * @param items
 396  
      * @param defaultOrderSequence
 397  
      * @return List<Ordered> sorted items
 398  
      * @see org.kuali.rice.krad.uif.Component.getOrder()
 399  
      * @see @see org.springframework.core.Ordered
 400  
      */
 401  
     public static List<? extends Ordered> sort(List<? extends Ordered> items, int defaultOrderSequence) {
 402  0
         List<Ordered> orderedItems = new ArrayList<Ordered>();
 403  
 
 404  
         // do replacement for items with the same order property value
 405  0
         Set<Integer> foundOrders = new HashSet<Integer>();
 406  
 
 407  
         // reverse the list, so items later in the list win
 408  0
         Collections.reverse(items);
 409  0
         for (Ordered component : items) {
 410  0
             int order = component.getOrder();
 411  
 
 412  
             // if order not set just add to list
 413  0
             if (order == 0) {
 414  0
                 orderedItems.add(component);
 415  
             }
 416  
             // check if the order value has been used already
 417  0
             else if (!foundOrders.contains(new Integer(order))) {
 418  0
                 orderedItems.add(component);
 419  0
                 foundOrders.add(new Integer(order));
 420  
             }
 421  0
         }
 422  
 
 423  
         // now reverse the list back so we can assign defaults for items without
 424  
         // an order value
 425  0
         Collections.reverse(items);
 426  0
         for (Ordered component : items) {
 427  0
             int order = component.getOrder();
 428  
 
 429  
             // if order property not set assign default
 430  0
             if (order == 0) {
 431  0
                 defaultOrderSequence++;
 432  0
                 while (foundOrders.contains(new Integer(defaultOrderSequence))) {
 433  0
                     defaultOrderSequence++;
 434  
                 }
 435  0
                 component.setOrder(defaultOrderSequence);
 436  
             }
 437  0
         }
 438  
 
 439  
         // now sort the list by its order property
 440  0
         Collections.sort(orderedItems, new OrderComparator());
 441  
 
 442  0
         return orderedItems;
 443  
     }
 444  
     
 445  
     /**
 446  
      * This method takes in an expression and a list to be filled in with names(property names)
 447  
      * of controls found in the expression. This method returns a js expression which can
 448  
      * be executed on the client to determine if the original exp was satisfied before
 449  
      * interacting with the server - ie, this js expression is equivalent to the one passed in.
 450  
      * 
 451  
      * There are limitations on the Spring expression language that can be used as this method.
 452  
      * It is only used to parse expressions which are valid case statements for determining if
 453  
      * some action/processing should be performed.  ONLY Properties, comparison operators, booleans,
 454  
      * strings, matches expression, and boolean logic are supported.  Properties must
 455  
      * be a valid property on the form, and should have a visible control within the view.
 456  
      * 
 457  
      * Example valid exp: account.name == 'Account Name'
 458  
      * 
 459  
      * @param exp
 460  
      * @param controlNames
 461  
      * @return
 462  
      */
 463  
     public static String parseExpression(String exp, List<String> controlNames){
 464  
         //Clean up expression to ease parsing
 465  0
         exp = StringUtils.replace(exp, "!=", " != ");
 466  0
         exp = StringUtils.replace(exp, "==", " == ");
 467  0
         exp = StringUtils.replace(exp, ">", " > ");
 468  0
         exp = StringUtils.replace(exp, "<", " < ");
 469  0
         exp = StringUtils.replace(exp, "<=", " <= ");
 470  0
         exp = StringUtils.replace(exp, ">=", " >= ");
 471  0
         exp = exp.trim();
 472  
 
 473  0
         String conditionJs = exp;
 474  0
         String stack = "";
 475  0
         boolean expectingSingleQuote = false;
 476  0
         boolean ignoreNext = false;
 477  0
         for(int i = 0; i < exp.length(); i++) { 
 478  0
             char c = exp.charAt(i);
 479  0
             if(!expectingSingleQuote && !ignoreNext && (c == '(' || c == ' ' || c == ')')){
 480  0
                 evaluateCurrentStack(stack.trim(), controlNames);
 481  
                 //reset stack
 482  0
                 stack = "";
 483  0
                 continue;
 484  
             }
 485  0
             else if(!ignoreNext && c == '\''){
 486  0
                 stack = stack + c;
 487  0
                 expectingSingleQuote = !expectingSingleQuote;
 488  
             }
 489  0
             else if(c == '\\'){
 490  0
                 stack = stack + c;
 491  0
                 ignoreNext = !ignoreNext;
 492  
             }
 493  
             else{
 494  0
                 stack = stack + c;
 495  0
                 ignoreNext = false;
 496  
             }
 497  
         }
 498  
         
 499  0
         conditionJs = conditionJs
 500  
         .replaceAll("\\s(?i:ne)\\s", " != ")
 501  
         .replaceAll("\\s(?i:eq)\\s", " == ")
 502  
         .replaceAll("\\s(?i:gt)\\s", " > ")
 503  
         .replaceAll("\\s(?i:lt)\\s", " < ")
 504  
         .replaceAll("\\s(?i:lte)\\s", " <= ")
 505  
         .replaceAll("\\s(?i:gte)\\s", " >= ")
 506  
         .replaceAll("\\s(?i:and)\\s", " && ")
 507  
         .replaceAll("\\s(?i:or)\\s", " || ")
 508  
         .replaceAll("\\s(?i:not)\\s", " != ")
 509  
         .replaceAll("\\s(?i:null)\\s?", " '' ")
 510  
         .replaceAll("\\s?(?i:#empty)\\((.*?)\\)", "isValueEmpty($1)");
 511  0
         if(conditionJs.contains("matches")){
 512  0
             conditionJs = conditionJs.replaceAll("\\s+(?i:matches)\\s+'.*'", ".match(/" 
 513  
                     + "$0" + "/) != null ");
 514  0
             conditionJs = conditionJs.replaceAll("\\(/\\s+(?i:matches)\\s+'", "(/");
 515  0
             conditionJs = conditionJs.replaceAll("'\\s*/\\)", "/)");
 516  
         }
 517  0
         for(String propertyName: controlNames){
 518  0
             conditionJs = conditionJs.replace(propertyName, 
 519  
                     "coerceValue(\""+ propertyName +"\")");
 520  
         }
 521  0
         return conditionJs;
 522  
     }
 523  
     
 524  
     /**
 525  
      * Used internally by parseExpression to evalute if the current stack is a property
 526  
      * name (ie, will be a control on the form)
 527  
      * 
 528  
      * @param stack
 529  
      * @param controlNames
 530  
      */
 531  
     private static void evaluateCurrentStack(String stack, List<String> controlNames){
 532  0
        if(StringUtils.isNotBlank(stack)){
 533  0
            if(!(stack.equals("==") 
 534  
                    || stack.equals("!=")
 535  
                    || stack.equals(">")
 536  
                    || stack.equals("<")
 537  
                    || stack.equals(">=")
 538  
                    || stack.equals("<=")
 539  
                    || stack.equalsIgnoreCase("ne")
 540  
                    || stack.equalsIgnoreCase("eq")
 541  
                    || stack.equalsIgnoreCase("gt")
 542  
                    || stack.equalsIgnoreCase("lt")
 543  
                    || stack.equalsIgnoreCase("lte")
 544  
                    || stack.equalsIgnoreCase("gte")
 545  
                    || stack.equalsIgnoreCase("matches")
 546  
                    || stack.equalsIgnoreCase("null")
 547  
                    || stack.equalsIgnoreCase("false")
 548  
                    || stack.equalsIgnoreCase("true")
 549  
                    || stack.equalsIgnoreCase("and")
 550  
                    || stack.equalsIgnoreCase("or")
 551  
                    || stack.contains("#empty")
 552  
                    || stack.startsWith("'")
 553  
                    || stack.endsWith("'"))){
 554  
                
 555  0
                boolean isNumber = false;
 556  0
                if((StringUtils.isNumeric(stack.substring(0,1)) 
 557  
                        || stack.substring(0,1).equals("-"))){
 558  
                    try{
 559  0
                        Double.parseDouble(stack);
 560  0
                        isNumber = true;
 561  
                    }
 562  0
                    catch(NumberFormatException e){
 563  0
                        isNumber = false;
 564  0
                    }
 565  
                }
 566  
                
 567  0
                if(!(isNumber)){
 568  0
                    if(!controlNames.contains(stack)){
 569  0
                        controlNames.add(stack);
 570  
                    }
 571  
                }
 572  
            }
 573  
        }
 574  0
     }
 575  
 
 576  
     public static String getLinePathValue(Component component){
 577  0
         CollectionGroup collectionGroup = (CollectionGroup)(component.getContext().get(UifConstants.ContextVariableNames.COLLECTION_GROUP));
 578  0
         String linePath = "";
 579  0
         if(collectionGroup != null){
 580  0
             Object indexObj = component.getContext().get(UifConstants.ContextVariableNames.INDEX);
 581  0
             if(indexObj != null){
 582  0
                 int index = (Integer)indexObj;
 583  0
                 boolean addLine = false;
 584  0
                 Object addLineObj = component.getContext().get(UifConstants.ContextVariableNames.IS_ADD_LINE);
 585  
                 
 586  0
                 if(addLineObj != null){
 587  0
                     addLine = (Boolean)addLineObj;
 588  
                 }
 589  0
                 if (addLine) {
 590  0
                   linePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
 591  
                 }
 592  
                 else {
 593  0
                   linePath = collectionGroup.getBindingInfo().getBindingPath() + "[" + index + "]";
 594  
                 }
 595  
             }
 596  
         }
 597  0
         return linePath;
 598  
     }
 599  
     
 600  
     public static String replaceLineAttr(String statement, String replacement){
 601  0
         if (statement.contains("#line") && StringUtils.isNotEmpty(replacement)) {
 602  0
             statement = statement.replace("#line?", replacement);
 603  0
             statement = statement.replace("#line", replacement);
 604  
         }
 605  0
         return statement;
 606  
     }
 607  
 }