Python java.util.ArrayList() Examples
The following are 30
code examples of java.util.ArrayList().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
java.util
, or try the search function
.
Example #1
Source File: test_java_integration.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_list_delegation(self): for c in ArrayList, Vector: a = c() self.assertRaises(IndexError, a.__getitem__, 0) a.add("blah") self.assertTrue("blah" in a) self.assertEquals(1, len(a)) n = 0 for i in a: n += 1 self.assertEquals("blah", i) self.assertEquals(1, n) self.assertEquals("blah", a[0]) a[0] = "bleh" del a[0] self.assertEquals(0, len(a))
Example #2
Source File: test_java_integration.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_list_delegation(self): for c in ArrayList, Vector: a = c() self.assertRaises(IndexError, a.__getitem__, 0) a.add("blah") self.assertTrue("blah" in a) self.assertEquals(1, len(a)) n = 0 for i in a: n += 1 self.assertEquals("blah", i) self.assertEquals(1, n) self.assertEquals("blah", a[0]) a[0] = "bleh" del a[0] self.assertEquals(0, len(a))
Example #3
Source File: test_list_jy.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_setget_override(self): if not test_support.is_jython: return # http://bugs.jython.org/issue600790 class GoofyListMapThing(ArrayList): def __init__(self): self.silly = "Nothing" def __setitem__(self, key, element): self.silly = "spam" def __getitem__(self, key): self.silly = "eggs" glmt = GoofyListMapThing() glmt['my-key'] = String('el1') self.assertEquals(glmt.silly, "spam") glmt['my-key'] self.assertEquals(glmt.silly, "eggs")
Example #4
Source File: test_java_list_delegate.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_set_slice(self): initial_value = range(0, 5) def make_op_func(i, j, k, v): def _f(xs): xs[i:j:k] = v return _f for i in [None] + range(-7, 7): for j in [None] + range(-7, 7): for k in [None] + range(-7, 7): self._list_op_test(initial_value, make_op_func(i, j, k, []), 'set_slice [%s:%s:%s]=[]' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, range(0,2)), 'set_slice [%s:%s:%s]=range(0,2)' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, range(0,4)), 'set_slice [%s:%s:%s]=range(0,4)' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, xrange(0,2)), 'set_slice [%s:%s:%s]=xrange(0,2)' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, self._arraylist_of(range(0,2))), 'set_slice [%s:%s:%s]=ArrayList(range(0,2))' % (i,j,k)) self._list_op_test([1,2,3,4,5], make_op_func(1, None, None, [1,2,3,4,5]), 'set_slice [1:]=[1,2,3,4,5]')
Example #5
Source File: burp_wp.py From burp_wp with MIT License | 6 votes |
def initialize_variables(self): self.is_burp_pro = True if "Professional" in self.callbacks.getBurpVersion()[0] else False self.regexp_version_number = re.compile("ver=([0-9.]+)", re.IGNORECASE) self.regexp_stable_tag = re.compile(r"(?:stable tag|version):\s*(?!trunk)([0-9a-z.-]+)", re.IGNORECASE) self.regexp_version_from_changelog = re.compile( r"[=]+\s+(?:v(?:ersion)?\s*)?([0-9.-]+)[ \ta-z0-9().\-,]*[=]+", re.IGNORECASE) self.list_issues = ArrayList() self.lock_issues = Lock() self.lock_update_database = Lock() self.lock_update_burp_wp = Lock() self.api_errors = 0 self.database = {'plugins': collections.OrderedDict(), 'themes': collections.OrderedDict(), 'admin_ajax': {}} self.list_plugins_on_website = defaultdict(list)
Example #6
Source File: test_java_list_delegate.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_set_slice(self): initial_value = range(0, 5) def make_op_func(i, j, k, v): def _f(xs): xs[i:j:k] = v return _f for i in [None] + range(-7, 7): for j in [None] + range(-7, 7): for k in [None] + range(-7, 7): self._list_op_test(initial_value, make_op_func(i, j, k, []), 'set_slice [%s:%s:%s]=[]' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, range(0,2)), 'set_slice [%s:%s:%s]=range(0,2)' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, range(0,4)), 'set_slice [%s:%s:%s]=range(0,4)' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, xrange(0,2)), 'set_slice [%s:%s:%s]=xrange(0,2)' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, self._arraylist_of(range(0,2))), 'set_slice [%s:%s:%s]=ArrayList(range(0,2))' % (i,j,k)) self._list_op_test([1,2,3,4,5], make_op_func(1, None, None, [1,2,3,4,5]), 'set_slice [1:]=[1,2,3,4,5]')
Example #7
Source File: test_java_list_delegate.py From medicare-demo with Apache License 2.0 | 6 votes |
def _list_op_test(self, initial_value, op_func, test_name): """ Tests a list operation Ensures that performing an operation on: - a python list - a java.util.List instance gives the same result in both cases """ lists = [list(initial_value), ArrayList(initial_value), Vector(initial_value)] list_type_names = ['list', 'ArrayList', 'Vector'] results = [self._perform_op(l, op_func) for l in lists] self.check_list(lists[0], lists[1:], list_type_names[1:], initial_value, test_name) if not isinstance(results[0], list): for r,n in zip(results[1:], list_type_names[1:]): self.assertEquals(results[0], r, '%s: result for list does not match result for java type %s' % (test_name,n) ) else: self.check_list(results[0], results[1:], list_type_names[1:], initial_value, test_name)
Example #8
Source File: test_list_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_setget_override(self): if not test_support.is_jython: return # http://bugs.jython.org/issue600790 class GoofyListMapThing(ArrayList): def __init__(self): self.silly = "Nothing" def __setitem__(self, key, element): self.silly = "spam" def __getitem__(self, key): self.silly = "eggs" glmt = GoofyListMapThing() glmt['my-key'] = String('el1') self.assertEquals(glmt.silly, "spam") glmt['my-key'] self.assertEquals(glmt.silly, "eggs")
Example #9
Source File: test_list_jy.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_remove(self): # Verifies that overloaded java.util.List#remove(int) method can still be used, but with Python index semantics # http://bugs.jython.org/issue2456 jl = ArrayList(xrange(10, -1, -1)) # 10 .. 0, inclusive jl.remove(0) # removes jl[-1] (=0) self.assertEqual(jl, range(10, 0, -1)) # 10 .. 1 self.assertRaises(ValueError, jl.remove, Integer(0)) # j.l.Integer does not support __index__ - maybe it should! jl.remove(0) # removes jl[0] (=10) self.assertEqual(jl, range(9, 0, -1)) # 9 .. 1 jl.remove(-1) # removes jl[-1] (=1) - support same index calculations as Python (= del jl[-1]) self.assertEqual(jl, range(9, 1, -1)) # 9 .. 2 jl.remove(3) jl.remove(5) self.assertEqual(jl, [9, 8, 7, 6, 4, 2]) a_to_z = list(chr(i) for i in xrange(ord('a'), ord('z') + 1)) b_to_z_by_2 = list(chr(i) for i in xrange(ord('b'), ord('z') + 1, 2)) jl = ArrayList(a_to_z) for i in xrange(13): jl.remove(i) self.assertEqual(jl, b_to_z_by_2)
Example #10
Source File: test_list_jy.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_setget_override(self): if not test_support.is_jython: return # http://bugs.jython.org/issue600790 class GoofyListMapThing(ArrayList): def __init__(self): self.silly = "Nothing" def __setitem__(self, key, element): self.silly = "spam" def __getitem__(self, key): self.silly = "eggs" glmt = GoofyListMapThing() glmt['my-key'] = String('el1') self.assertEquals(glmt.silly, "spam") glmt['my-key'] self.assertEquals(glmt.silly, "eggs")
Example #11
Source File: FransLinkfinder.py From BurpJSLinkFinder with MIT License | 6 votes |
def doPassiveScan(self, ihrr): try: urlReq = ihrr.getUrl() testString = str(urlReq) linkA = linkAnalyse(ihrr,self.helpers) # check if JS file if ".js" in str(urlReq): # Exclude casual JS files if any(x in testString for x in JSExclusionList): print("\n" + "[-] URL excluded " + str(urlReq)) else: self.outputTxtArea.append("\n" + "[+] Valid URL found: " + str(urlReq)) issueText = linkA.analyseURL() for counter, issueText in enumerate(issueText): #print("TEST Value returned SUCCESS") self.outputTxtArea.append("\n" + "\t" + str(counter)+' - ' +issueText['link']) issues = ArrayList() issues.add(SRI(ihrr, self.helpers)) return issues except UnicodeEncodeError: print ("Error in URL decode.") return None
Example #12
Source File: burp_git_bridge.py From burp-git-bridge with MIT License | 6 votes |
def createMenuItems(self, invocation): ''' Invoked by Burp when a right-click menu is created; adds Git Bridge's options to the menu. ''' context = invocation.getInvocationContext() tool = invocation.getToolFlag() if tool == self.callbacks.TOOL_REPEATER: if context in [invocation.CONTEXT_MESSAGE_EDITOR_REQUEST, invocation.CONTEXT_MESSAGE_VIEWER_RESPONSE]: item = JMenuItem("Send to Git Bridge") item.addActionListener(self.RepeaterHandler(self.callbacks, invocation, self.log)) items = ArrayList() items.add(item) return items elif tool == self.callbacks.TOOL_SCANNER: if context in [invocation.CONTEXT_SCANNER_RESULTS]: item = JMenuItem("Send to Git Bridge") item.addActionListener(self.ScannerHandler(self.callbacks, invocation, self.log)) items = ArrayList() items.add(item) return items else: # TODO: add support for other tools pass
Example #13
Source File: test_java_integration.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_equals(self): # Test for bug #1338 a = range(5) x = ArrayList() x.addAll(a) y = Vector() y.addAll(a) z = ArrayList() z.addAll(range(1, 6)) self.assertTrue(x.equals(y)) self.assertEquals(x, y) self.assertTrue(not (x != y)) self.assertTrue(not x.equals(z)) self.assertNotEquals(x, z) self.assertTrue(not (x == z))
Example #14
Source File: test_list_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_remove(self): # Verifies that overloaded java.util.List#remove(int) method can still be used, but with Python index semantics # http://bugs.jython.org/issue2456 jl = ArrayList(xrange(10, -1, -1)) # 10 .. 0, inclusive jl.remove(0) # removes jl[-1] (=0) self.assertEqual(jl, range(10, 0, -1)) # 10 .. 1 self.assertRaises(ValueError, jl.remove, Integer(0)) # j.l.Integer does not support __index__ - maybe it should! jl.remove(0) # removes jl[0] (=10) self.assertEqual(jl, range(9, 0, -1)) # 9 .. 1 jl.remove(-1) # removes jl[-1] (=1) - support same index calculations as Python (= del jl[-1]) self.assertEqual(jl, range(9, 1, -1)) # 9 .. 2 jl.remove(3) jl.remove(5) self.assertEqual(jl, [9, 8, 7, 6, 4, 2]) a_to_z = list(chr(i) for i in xrange(ord('a'), ord('z') + 1)) b_to_z_by_2 = list(chr(i) for i in xrange(ord('b'), ord('z') + 1, 2)) jl = ArrayList(a_to_z) for i in xrange(13): jl.remove(i) self.assertEqual(jl, b_to_z_by_2)
Example #15
Source File: models.py From lightbulb-framework with MIT License | 6 votes |
def __init__(self): """ The constructor of BurpDatabaseModels object defines a number of class variables tracking the number of deleted records, and maintaining the references to the arrays of records. Args: None Returns: None """ self.STATIC_MESSAGE_TABLE_COLUMN_COUNT = 6 self.lock = Lock() self.arrayOfMessages = ArrayList() self.arrayOfCampaigns = ArrayList() self.arrayOfSettings = ArrayList() self.deletedCampaignCount = 0 self.deletedRoleCount = 0 self.deletedMessageCount = 0 self.deletedSettingCount = 0 self.selfExtender = None
Example #16
Source File: Casa.py From community-edition-setup with MIT License | 6 votes |
def getExtraParametersForStep(self, configurationAttributes, step): print "Casa. getExtraParametersForStep %s" % str(step) list = ArrayList() if step > 1: acr = CdiUtil.bean(Identity).getWorkingParameter("ACR") if acr in self.authenticators: module = self.authenticators[acr] params = module.getExtraParametersForStep(module.configAttrs, step) if params != None: list.addAll(params) list.addAll(Arrays.asList("ACR", "methods", "trustedDevicesInfo")) list.addAll(Arrays.asList("casa_contextPath", "casa_prefix", "casa_faviconUrl", "casa_extraCss", "casa_logoUrl")) print "extras are %s" % list return list
Example #17
Source File: test_java_list_delegate.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_set_slice(self): initial_value = range(0, 5) def make_op_func(i, j, k, v): def _f(xs): xs[i:j:k] = v return _f for i in [None] + range(-7, 7): for j in [None] + range(-7, 7): for k in [None] + range(-7, 7): self._list_op_test(initial_value, make_op_func(i, j, k, []), 'set_slice [%s:%s:%s]=[]' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, range(0,2)), 'set_slice [%s:%s:%s]=range(0,2)' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, range(0,4)), 'set_slice [%s:%s:%s]=range(0,4)' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, xrange(0,2)), 'set_slice [%s:%s:%s]=xrange(0,2)' % (i,j,k)) self._list_op_test(initial_value, make_op_func(i, j, k, self._arraylist_of(range(0,2))), 'set_slice [%s:%s:%s]=ArrayList(range(0,2))' % (i,j,k)) self._list_op_test([1,2,3,4,5], make_op_func(1, None, None, [1,2,3,4,5]), 'set_slice [1:]=[1,2,3,4,5]')
Example #18
Source File: SamlPassportAuthenticator.py From community-edition-setup with MIT License | 6 votes |
def getUserByExternalUid(self, uid, provider, userService): newFormat = "passport-%s:%s:%s" % ("saml", provider, uid) user = userService.getUserByAttribute("oxExternalUid", newFormat) if user == None: oldFormat = "passport-%s:%s" % ("saml", uid) user = userService.getUserByAttribute("oxExternalUid", oldFormat) if user != None: # Migrate to newer format list = HashSet(user.getAttributeValues("oxExternalUid")) list.remove(oldFormat) list.add(newFormat) user.setAttribute("oxExternalUid", ArrayList(list)) print "Migrating user's oxExternalUid to newer format 'passport-saml:provider:uid'" userService.updateUser(user) return user
Example #19
Source File: test_java_integration.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_equals(self): # Test for bug #1338 a = range(5) x = ArrayList() x.addAll(a) y = Vector() y.addAll(a) z = ArrayList() z.addAll(range(1, 6)) self.assertTrue(x.equals(y)) self.assertEquals(x, y) self.assertTrue(not (x != y)) self.assertTrue(not x.equals(z)) self.assertNotEquals(x, z) self.assertTrue(not (x == z))
Example #20
Source File: test_java_integration.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_list_delegation(self): for c in ArrayList, Vector: a = c() self.assertRaises(IndexError, a.__getitem__, 0) a.add("blah") self.assertTrue("blah" in a) self.assertEquals(1, len(a)) n = 0 for i in a: n += 1 self.assertEquals("blah", i) self.assertEquals(1, n) self.assertEquals("blah", a[0]) a[0] = "bleh" del a[0] self.assertEquals(0, len(a))
Example #21
Source File: gremthon.py From gremlin-python with MIT License | 5 votes |
def map_gremthon_type(obj): if isinstance(obj, Edge): return GremthonEdge(obj) elif isinstance(obj, Vertex): return GremthonVertex(obj) elif isinstance(obj, HashMap): return dict(obj) elif isinstance(obj, ArrayList): return list(obj) else: return obj
Example #22
Source File: test_java_integration.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_immutable(self): abc = String("abc") abc_copy = copy.copy(abc) self.assertEqual(id(abc), id(abc_copy)) fruits = ArrayList([String("apple"), String("banana")]) fruits_copy = copy.copy(fruits) self.assertEqual(fruits, fruits_copy) self.assertNotEqual(id(fruits), id(fruits_copy))
Example #23
Source File: test_joverload.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_lists(self): t = Reflection.ListVarargs() self.assertEqual(t.test(ArrayList([1,2,3]), ArrayList([4,5,6])), "List...:[[1, 2, 3], [4, 5, 6]]") self.assertEqual(t.test(ArrayList([1,2,3])), "List...:[[1, 2, 3]]") self.assertEqual(t.test(), "List...:[]") self.assertEqual(t.test([ArrayList([1,2,3]), ArrayList([4,5,6])]), "List...:[[1, 2, 3], [4, 5, 6]]") self.assertEqual(t.test([ArrayList([1,2,3])]), "List...:[[1, 2, 3]]") self.assertEqual(t.test([]), "List...:[]")
Example #24
Source File: test_list_jy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_extend_java_ArrayList(self): jl = ArrayList([]) jl.extend([1,2]) self.assertEqual(jl, ArrayList([1,2])) jl.extend(ArrayList([3,4])) self.assertEqual(jl, [1,2,3,4])
Example #25
Source File: test_java_list_delegate.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_iter(self): jlist = ArrayList() jlist.addAll(range(0, 10)) i = iter(jlist) x = list(i) self.assert_(x == range(0, 10))
Example #26
Source File: test_joverload.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_lists(self): t = Reflection.ListVarargs() self.assertEqual(t.test(ArrayList([1,2,3]), ArrayList([4,5,6])), "List...:[[1, 2, 3], [4, 5, 6]]") self.assertEqual(t.test(ArrayList([1,2,3])), "List...:[[1, 2, 3]]") self.assertEqual(t.test(), "List...:[]") self.assertEqual(t.test([ArrayList([1,2,3]), ArrayList([4,5,6])]), "List...:[[1, 2, 3], [4, 5, 6]]") self.assertEqual(t.test([ArrayList([1,2,3])]), "List...:[[1, 2, 3]]") self.assertEqual(t.test([]), "List...:[]")
Example #27
Source File: test_java_integration.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_immutable(self): abc = String("abc") abc_copy = copy.copy(abc) self.assertEqual(id(abc), id(abc_copy)) fruits = ArrayList([String("apple"), String("banana")]) fruits_copy = copy.copy(fruits) self.assertEqual(fruits, fruits_copy) self.assertNotEqual(id(fruits), id(fruits_copy))
Example #28
Source File: test_java_integration.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_deepcopy(self): items = ArrayList([ArrayList(["apple", "banana"]), ArrayList(["trs80", "vic20"])]) items_copy = copy.deepcopy(items) self.assertEqual(items, items_copy) self.assertNotEqual(id(items), id(items_copy)) self.assertNotEqual(id(items[0]), id(items_copy[0])) self.assertNotEqual(id(items[1]), id(items_copy[1]))
Example #29
Source File: test_java_integration.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_copy(self): fruits = ArrayList(["apple", "banana"]) fruits_copy = copy.copy(fruits) self.assertEqual(fruits, fruits_copy) self.assertNotEqual(id(fruits), id(fruits_copy))
Example #30
Source File: test_java_list_delegate.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_override_iter(self): class MyList (ArrayList): def __iter__(self): return iter(self.subList(0, self.size() - 1)); m = MyList() m.addAll(range(0,10)) i = iter(m) x = list(i) self.assert_(x == range(0, 9))