1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.script.internal.safe

File SafeList.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
15
11
1
116
68
11
0.73
1.36
11
1

Classes

Class Line # Actions
SafeList 36 15 0% 11 26
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.script.internal.safe;
21   
22    import java.lang.reflect.Constructor;
23    import java.util.ArrayList;
24    import java.util.Collection;
25    import java.util.List;
26    import java.util.ListIterator;
27   
28    /**
29    * Provide a public script access to a list.
30    *
31    * @param <E> the type of the elements in the list
32    * @param <L> the type of the List
33    * @version $Id: a5da2e87c0c68924e6bed85a753041396897660f $
34    * @since 4.1M1
35    */
 
36    public class SafeList<E, L extends List<E>> extends SafeCollection<E, L> implements List<E>
37    {
38    /**
39    * @param list the wrapped list
40    * @param safeProvider the provider of instances safe for public scripts
41    * @param safeConstructor the cinstructor to use to create new instance of list elements
42    */
 
43  0 toggle public SafeList(L list, ScriptSafeProvider< ? > safeProvider, Constructor< ? extends E> safeConstructor)
44    {
45  0 super(list, safeProvider, safeConstructor);
46    }
47   
48    // List
49   
 
50  0 toggle @Override
51    public boolean addAll(int index, Collection< ? extends E> c)
52    {
53  0 throw new UnsupportedOperationException(FORBIDDEN);
54    }
55   
 
56  0 toggle @Override
57    public E get(int index)
58    {
59  0 return safeElement(getWrapped().get(index));
60    }
61   
 
62  0 toggle @Override
63    public E set(int index, E element)
64    {
65  0 throw new UnsupportedOperationException(FORBIDDEN);
66    }
67   
 
68  0 toggle @Override
69    public void add(int index, E element)
70    {
71  0 throw new UnsupportedOperationException(FORBIDDEN);
72    }
73   
 
74  0 toggle @Override
75    public E remove(int index)
76    {
77  0 throw new UnsupportedOperationException(FORBIDDEN);
78    }
79   
 
80  0 toggle @Override
81    public int indexOf(Object o)
82    {
83  0 return getWrapped().indexOf(o);
84    }
85   
 
86  0 toggle @Override
87    public int lastIndexOf(Object o)
88    {
89  0 return getWrapped().lastIndexOf(o);
90    }
91   
 
92  0 toggle @Override
93    public ListIterator<E> listIterator()
94    {
95  0 return new SafeListIterator<E>(getWrapped().listIterator(), this.safeProvider, this.safeConstructor);
96    }
97   
 
98  0 toggle @Override
99    public ListIterator<E> listIterator(int index)
100    {
101  0 return new SafeListIterator<E>(getWrapped().listIterator(index), this.safeProvider, this.safeConstructor);
102    }
103   
 
104  0 toggle @Override
105    public List<E> subList(int fromIndex, int toIndex)
106    {
107  0 List<E> list = getWrapped().subList(fromIndex, toIndex);
108   
109  0 List<E> safeList = new ArrayList<E>(list.size());
110  0 for (E element : list) {
111  0 safeList.add(safeElement(element));
112    }
113   
114  0 return safeList;
115    }
116    }