This file is indexed.

/usr/share/pyshared/jpype/_jcollection.py is in python-jpype 0.5.4.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#*****************************************************************************
#   Copyright 2004-2008 Steve Menard
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#   
#*****************************************************************************
import operator
import _jclass

def _initialize() :
    _jclass.registerClassCustomizer(CollectionCustomizer())
    _jclass.registerClassCustomizer(ListCustomizer())
    _jclass.registerClassCustomizer(MapCustomizer())
    _jclass.registerClassCustomizer(IteratorCustomizer())
    _jclass.registerClassCustomizer(EnumerationCustomizer())

def isPythonSequence(v):       
    if operator.isSequenceType(v) :
        if not hasattr(v.__class__, '__metaclass__') or v.__class__.__metaclass__ is _jclass._JavaClass :
            return True
    return False

def _colLength(self) :
    return self.size()
    
def _colIter(self) :    
    return self.iterator()

def _colDelItem(self, i) :
    return self.remove(i)

def _colAddAll(self, v):
    if isPythonSequence(v) :
        r = False
        for i in v :
            r = self.add(i) or r
        return r
    else:
        return self._addAll(v)

def _colRemoveAll(self, v):
    if isPythonSequence(v) :
        r = False
        for i in v :
            r = self.remove(i) or r
        return r
    else:
        return self._removeAll(v)

def _colRetainAll(self, v):
    if isPythonSequence(v) :
        r = _jclass.JClass("java.util.ArrayList")(len(v))
        for i in v :
            r.add(i)
    else:
        r = v
                
    return self._retainAll(r)

class CollectionCustomizer(object) :
    _METHODS = {
        '__len__' : _colLength,
        '__iter__' : _colIter,
        '__delitem__' : _colDelItem,
    }
    
    def canCustomize(self, name, jc) :
        if name == 'java.util.Collection' :
            return True
        return jc.isSubclass('java.util.Collection')
        
    def customize(self, name, jc, bases, members) :
        if name == 'java.util.Collection' :
            members.update(CollectionCustomizer._METHODS)
        else:
            # AddAll is handled by List  
            if (not jc.isSubclass("java.util.List")) and 'addAll' in members :
                members['_addAll'] = members['addAll']
                members['addAll'] = _colAddAll
            if 'removeAll' in members :
                members['_removeAll'] = members['removeAll']
                members['removeAll'] = _colRemoveAll
            if 'retainAll' in members :
                members['_retainAll'] = members['retainAll']
                members['retainAll'] = _colRetainAll

def _listGetItem(self, ndx) :
    if isinstance(ndx, slice) :
        start = ndx.start
        stop = ndx.stop
        if start < 0 :
            start = self.size() + start
        if stop < 0 :
            stop = self.size() + stop
        return self.subList(start, stop)
    else:
        if ndx < 0 :
            ndx = self.size() + ndx
        return self.get(ndx)
        
def _listSetItem(self, ndx, v) :
    if isinstance(ndx, slice) :
        start = ndx.start
        stop = ndx.stop
        if start < 0 :
            start = self.size() + start
        if stop < 0 :
            stop = self.size() + stop
        for i in range(start, stop) :
            self.remove(start)
        if operator.isSequenceType(v) :
            ndx = start
            for i in v :
                self.add(ndx, i)
                ndx += 1
    else:
        if ndx < 0 :
            ndx = self.size() + ndx
        self.set(ndx, v)

def _listAddAll(self, v, v2=None):
    if isPythonSequence(v) :
        r = False
        if v2 is not None : # assume form (int, values)
            for i in range(len(v2)) :
                r = r or self.add(v+i, v2[i])
                ndx +=1
        else:    
            for i in v :
                r = self.add(i) or r
        return r
    else:
        return self._addAll(v)

class ListCustomizer(object) :
    _METHODS = {
        '__setitem__' : _listSetItem,
        '__getitem__' : _listGetItem,
    }
    
    def canCustomize(self, name, jc) :
        if name == 'java.util.List' :
            return True
        return jc.isSubclass('java.util.List')
        
    def customize(self, name, jc, bases, members) :
        if name == 'java.util.List' :
            members.update(ListCustomizer._METHODS)
        else:
            if 'addAll' in members :
                members['_addAll'] = members['addAll']
                members['addAll'] = _listAddAll            
       
def isPythonMapping(v):       
    if operator.isMappingType(v) :
        if not hasattr(v.__class__, '__metaclass__') or v.__class__.__metaclass__ is _jclass._JavaClass :
            return True
    return False
        
def _mapLength(self) :
    return self.size()
    
def _mapIter(self) :
    return self.keySet().iterator()

def _mapDelItem(self, i) :
    return self.remove(i)

def _mapGetItem(self, ndx) :
    return self.get(ndx)
        
def _mapSetItem(self, ndx, v) :
    self.put(ndx, v)

def _mapPutAll(self, v):
    if isPythonMapping(v) :
        for i in v :
            self.put(i, v[i])
    else:        
        #do the regular method ...    
        self._putAll(v)
    
class MapCustomizer(object) :
    _METHODS = {
        '__len__' : _mapLength,
        '__iter__' : _mapIter,
        '__delitem__' : _mapDelItem,
        '__getitem__' : _mapGetItem,
        '__setitem__' : _mapSetItem,
    }
    
    def canCustomize(self, name, jc) :
        if name == 'java.util.Map' :
            return True
        return jc.isSubclass('java.util.Map')
        
    def customize(self, name, jc, bases, members) :
        if name == 'java.util.Map' :
            members.update(MapCustomizer._METHODS)
        else:
            if "putAll" in members :
                   members["_putAll"] = members["putAll"]
                   members["putAll"] = _mapPutAll

def _iterNext(self) :
    if self.hasNext() :
        return self._next()
    raise StopIteration
    
def _iterIter(self) :
    return self
    
class IteratorCustomizer(object) :
    _METHODS = {
        '__iter__' : _iterIter,
    }
    
    def canCustomize(self, name, jc) :
        if name == 'java.util.Iterator' :
            return True
        return jc.isSubclass('java.util.Iterator')
        
    def customize(self, name, jc, bases, members) :
        if name == 'java.util.Iterator' :
            members.update(IteratorCustomizer._METHODS)
        elif jc.isSubclass('java.util.Iterator') and 'next' in members:
            members['_next'] = members['next']
            members['next'] = _iterNext

def _enumNext(self) :
    if self.hasMoreElements() :
        return self.nextElement()
    raise StopIteration
    
def _enumIter(self) :
    return self
    

class EnumerationCustomizer(object) :
    _METHODS = {
        'next' : _enumNext,
        '__iter__' : _enumIter,
    }
    
    def canCustomize(self, name, jc) :
        return name == 'java.util.Enumeration'
        
    def customize(self, name, jc, bases, members) :
        members.update(EnumerationCustomizer._METHODS)