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