Coverage Report - org.kuali.student.core.assembly.data.QueryPath
 
Classes in this File Line Coverage Branch Coverage Complexity
QueryPath
16%
7/43
0%
0/8
1.235
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 /**
 17  
  * 
 18  
  */
 19  
 package org.kuali.student.core.assembly.data;
 20  
 
 21  
 import java.util.ArrayList;
 22  
 import java.util.Collection;
 23  
 
 24  
 import org.kuali.student.core.assembly.data.Data.Key;
 25  
 /**
 26  
  * @author wilj
 27  
  *
 28  
  */
 29  28
 public class QueryPath extends ArrayList<Key> {
 30  
         //private static final PathParser parser = GWT.create(PathParser.class);
 31  2
         private static final PathParser parser = new DefaultPathParser();
 32  
         
 33  
         private static final long serialVersionUID = 1L;
 34  
 
 35  
         public static String getWildCard() {
 36  2
                 return parser.getWildCard();
 37  
         }
 38  
         
 39  
         public static String getPathSeparator(){
 40  0
             return parser.getPathSeparator();
 41  
         }
 42  
 
 43  
         public static QueryPath parse(final String path) {
 44  1
                 return parser.parse(path);
 45  
         }
 46  
 
 47  28
         private String stringPath = null;
 48  
 
 49  
         /* (non-Javadoc)
 50  
          * @see java.util.ArrayList#add(int, java.lang.Object)
 51  
          */
 52  
         @Override
 53  
         public void add(final int index, final Key element) {
 54  0
                 stringPath = null;
 55  0
                 super.add(index, element);
 56  0
         }
 57  
 
 58  
         /* (non-Javadoc)
 59  
          * @see java.util.ArrayList#add(java.lang.Object)
 60  
          */
 61  
         @Override
 62  
         public boolean add(final Key e) {
 63  29
                 stringPath = null;
 64  29
                 return super.add(e);
 65  
         }
 66  
 
 67  
         /* (non-Javadoc)
 68  
          * @see java.util.ArrayList#addAll(java.util.Collection)
 69  
          */
 70  
         @Override
 71  
         public boolean addAll(final Collection<? extends Key> c) {
 72  0
                 stringPath = null;
 73  0
                 return super.addAll(c);
 74  
         }
 75  
 
 76  
         /* (non-Javadoc)
 77  
          * @see java.util.ArrayList#addAll(int, java.util.Collection)
 78  
          */
 79  
         @Override
 80  
         public boolean addAll(final int index, final Collection<? extends Key> c) {
 81  0
                 stringPath = null;
 82  0
                 return super.addAll(index, c);
 83  
         }
 84  
 
 85  
         /* (non-Javadoc)
 86  
          * @see java.util.ArrayList#clear()
 87  
          */
 88  
         @Override
 89  
         public void clear() {
 90  0
                 stringPath = null;
 91  0
                 super.clear();
 92  0
         }
 93  
 
 94  
         /* (non-Javadoc)
 95  
          * @see java.util.ArrayList#remove(int)
 96  
          */
 97  
         @Override
 98  
         public Key remove(final int index) {
 99  0
                 stringPath = null;
 100  0
                 return super.remove(index);
 101  
         }
 102  
 
 103  
         /* (non-Javadoc)
 104  
          * @see java.util.ArrayList#remove(java.lang.Object)
 105  
          */
 106  
         @Override
 107  
         public boolean remove(final Object o) {
 108  0
                 stringPath = null;
 109  0
                 return super.remove(o);
 110  
         }
 111  
 
 112  
         /* (non-Javadoc)
 113  
          * @see java.util.AbstractCollection#removeAll(java.util.Collection)
 114  
          */
 115  
         @Override
 116  
         public boolean removeAll(final Collection<?> c) {
 117  0
                 stringPath = null;
 118  0
                 return super.removeAll(c);
 119  
         }
 120  
 
 121  
         /* (non-Javadoc)
 122  
          * @see java.util.ArrayList#removeRange(int, int)
 123  
          */
 124  
         @Override
 125  
         protected void removeRange(final int fromIndex, final int toIndex) {
 126  0
                 stringPath = null;
 127  0
                 super.removeRange(fromIndex, toIndex);
 128  0
         }
 129  
 
 130  
         /* (non-Javadoc)
 131  
          * @see java.util.AbstractCollection#retainAll(java.util.Collection)
 132  
          */
 133  
         @Override
 134  
         public boolean retainAll(final Collection<?> c) {
 135  0
                 stringPath = null;
 136  0
                 return super.retainAll(c);
 137  
         }
 138  
 
 139  
         /* (non-Javadoc)
 140  
          * @see java.util.ArrayList#set(int, java.lang.Object)
 141  
          */
 142  
         @Override
 143  
         public Key set(final int index, final Key element) {
 144  0
                 stringPath = null;
 145  0
                 return super.set(index, element);
 146  
         }
 147  
 
 148  
         public QueryPath subPath(final int fromIndex, final int toIndex) {
 149  
                 // TODO revamp this method to use subList once GWT issue 1791 is fixed
 150  0
                 final QueryPath result = new QueryPath();
 151  0
                 for (int i = fromIndex; i < toIndex; i++) {
 152  0
                         result.add(this.get(i));
 153  
                 }
 154  0
                 return result;
 155  
         }
 156  
 
 157  
         @Override
 158  
         public String toString() {
 159  0
                 if (stringPath == null) {
 160  0
                         stringPath = parser.format(this);
 161  
                 }
 162  0
                 return stringPath;
 163  
         }
 164  
         
 165  
         public static QueryPath concat(String... paths) {
 166  0
                 QueryPath result = new QueryPath();
 167  0
                 for (String path : paths) {
 168  0
                         if (path != null) {
 169  0
                                 result.addAll(QueryPath.parse(path));
 170  
                         }
 171  
                 }
 172  0
                 return result;
 173  
         }
 174  
 }