Python java.util.HashMap() Examples
The following are 21
code examples of java.util.HashMap().
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: SuperGluuExternalAuthenticator.py From community-edition-setup with MIT License | 6 votes |
def setRequestScopedParameters(self, identity, step): downloadMap = HashMap() if self.registrationUri != None: identity.setWorkingParameter("external_registration_uri", self.registrationUri) if self.androidUrl!= None and step == 1: downloadMap.put("android", self.androidUrl) if self.IOSUrl != None and step == 1: downloadMap.put("ios", self.IOSUrl) if self.customLabel != None: identity.setWorkingParameter("super_gluu_label", self.customLabel) identity.setWorkingParameter("download_url", downloadMap) identity.setWorkingParameter("super_gluu_qr_options", self.customQrOptions)
Example #2
Source File: casa-external_super_gluu.py From community-edition-setup with MIT License | 6 votes |
def setRequestScopedParameters(self, identity, step): downloadMap = HashMap() if self.registrationUri != None: identity.setWorkingParameter("external_registration_uri", self.registrationUri) if self.androidUrl!= None and step == 1: downloadMap.put("android", self.androidUrl) if self.IOSUrl != None and step == 1: downloadMap.put("ios", self.IOSUrl) if self.customLabel != None: identity.setWorkingParameter("super_gluu_label", self.customLabel) identity.setWorkingParameter("download_url",downloadMap) identity.setWorkingParameter("super_gluu_qr_options", self.customQrOptions)
Example #3
Source File: resource_owner_password_credentials_custom_params.py From community-edition-setup with MIT License | 6 votes |
def createNewAuthenticatedSession(self, context, customParameters={}): sessionIdService = CdiUtil.bean(SessionIdService) user = context.getUser() client = CdiUtil.bean(Identity).getSessionClient().getClient() # Add mandatory session parameters sessionAttributes = HashMap() sessionAttributes.put(Constants.AUTHENTICATED_USER, user.getUserId()) sessionAttributes.put(AuthorizeRequestParam.CLIENT_ID, client.getClientId()) sessionAttributes.put(AuthorizeRequestParam.PROMPT, "") # Add custom session parameters for key, value in customParameters.iteritems(): if StringHelper.isNotEmpty(value): sessionAttributes.put(key, value) # Generate authenticated session sessionId = sessionIdService.generateAuthenticatedSessionId(context.getHttpRequest(), user.getDn(), sessionAttributes) print "ROPC script. Generated session id. DN: '%s'" % sessionId.getDn() return sessionId
Example #4
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 #5
Source File: test_dict_jy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_hashtable_equal(self): for d in ({}, {1:2}): x = Hashtable(d) self.assertEqual(x, d) self.assertEqual(d, x) self.assertEqual(x, HashMap(d))
Example #6
Source File: test_dict_jy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_hashmap_builtin_pymethods(self): x = HashMap() x['a'] = 1 x[(1, 2)] = 'xyz' self.assertEqual({tup for tup in x.iteritems()}, {('a', 1), ((1, 2), 'xyz')}) self.assertEqual({tup for tup in x.itervalues()}, {1, 'xyz'}) self.assertEqual({tup for tup in x.iterkeys()}, {'a', (1, 2)}) self.assertEqual(str(x), repr(x)) self.assertEqual(type(str(x)), type(repr(x)))
Example #7
Source File: test_dict_jy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_hashmap(self): x = HashMap() x.put('a', 1) x.put('b', 2) x.put('c', 3) x.put((1,2), "xyz") y = dict(x) self.assertEqual(set(y.items()), set([('a', 1), ('b', 2), ('c', 3), ((1,2), "xyz")]))
Example #8
Source File: test_slots_jy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_weakref_slot(self): self.assertNotIn("__weakref__", dir(object())) self.assertIn("__weakref__", dir(self.make_class(object, "__weakref__")())) class B(object): pass self.assertIn("__weakref__", dir(B())) self.assertIn("__weakref__", dir(self.make_class(B, "__weakref__")())) self.assertNotIn("__weakref__", dir("abc")) self.assertIn("__weakref__", dir(self.make_class(str, "__weakref__")())) self.assertNotIn("__weakref__", dir(HashMap())) self.assertIn("__weakref__", dir(self.make_class(HashMap, "__weakref__")()))
Example #9
Source File: test_slots_jy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_dict_slot_subclass_java_hashmap(self): C = self.make_class(HashMap, "__dict__") # has everything in a HashMap, including Python semantic equivalence c = C({"a": 1, "b": 2}) self.assertTrue(c.containsKey("a")) self.assertEqual(sorted(c.iteritems()), [("a", 1), ("b", 2)]) # but also has a __dict__ slot for further interesting ;) possibilities self.assertIn("__dict__", dir(c)) self.assertIn("x", dir(c)) self.assertIn("y", dir(c)) self.assertEqual(c.__dict__.get("x"), 42) self.assertEqual(c.x, 42) self.assertEqual(c.y, 47) with self.assertRaisesRegexp(AttributeError, r"'C' object has no attribute 'z'"): c.z
Example #10
Source File: search.py From hoaxy-backend with GNU General Public License v3.0 | 5 votes |
def __init__(self, index_dir, search_fields=['canonical_url', 'title', 'meta', 'content'], unique_field='uq_id_str', boost=dict( canonical_url=4.0, title=8.0, meta=2.0, content=1.0), date_format='%Y-%m-%dT%H:%M:%S'): """Constructor of Searcher. Parameters ---------- index_dir : string The location of lucene index. search_fields : list A list of field names indicating fields to search on. unique_field : string The field name, on which the duplication should avoid. boost : dict This dict control the weight when computing score. date_format : string Convert the string into datetime. Should consistent with the index part. """ self.index_dir = index_dir self.search_fields = search_fields self.sort_by_recent = Sort( SortField('date_published', SortField.Type.STRING, True)) self.store = FSDirectory.open(Paths.get(index_dir)) self.reader = DirectoryReader.open(self.store) self.isearcher = IndexSearcher(self.reader) self.analyzer = StandardAnalyzer() self.boost_map = HashMap() for k, v in boost.items(): self.boost_map.put(k, Float(v)) self.mul_parser = MultiFieldQueryParser(search_fields, self.analyzer, self.boost_map) self.date_format = date_format
Example #11
Source File: test_dict_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_hashtable_equal(self): for d in ({}, {1:2}): x = Hashtable(d) self.assertEqual(x, d) self.assertEqual(d, x) self.assertEqual(x, HashMap(d))
Example #12
Source File: test_dict_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_hashmap_builtin_pymethods(self): x = HashMap() x['a'] = 1 x[(1, 2)] = 'xyz' self.assertEqual({tup for tup in x.iteritems()}, {('a', 1), ((1, 2), 'xyz')}) self.assertEqual({tup for tup in x.itervalues()}, {1, 'xyz'}) self.assertEqual({tup for tup in x.iterkeys()}, {'a', (1, 2)}) self.assertEqual(str(x), repr(x)) self.assertEqual(type(str(x)), type(repr(x)))
Example #13
Source File: test_dict_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_hashmap(self): x = HashMap() x.put('a', 1) x.put('b', 2) x.put('c', 3) x.put((1,2), "xyz") y = dict(x) self.assertEqual(set(y.items()), set([('a', 1), ('b', 2), ('c', 3), ((1,2), "xyz")]))
Example #14
Source File: test_slots_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_weakref_slot(self): self.assertNotIn("__weakref__", dir(object())) self.assertIn("__weakref__", dir(self.make_class(object, "__weakref__")())) class B(object): pass self.assertIn("__weakref__", dir(B())) self.assertIn("__weakref__", dir(self.make_class(B, "__weakref__")())) self.assertNotIn("__weakref__", dir("abc")) self.assertIn("__weakref__", dir(self.make_class(str, "__weakref__")())) self.assertNotIn("__weakref__", dir(HashMap())) self.assertIn("__weakref__", dir(self.make_class(HashMap, "__weakref__")()))
Example #15
Source File: test_slots_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_dict_slot_subclass_java_hashmap(self): C = self.make_class(HashMap, "__dict__") # has everything in a HashMap, including Python semantic equivalence c = C({"a": 1, "b": 2}) self.assertTrue(c.containsKey("a")) self.assertEqual(sorted(c.iteritems()), [("a", 1), ("b", 2)]) # but also has a __dict__ slot for further interesting ;) possibilities self.assertIn("__dict__", dir(c)) self.assertIn("x", dir(c)) self.assertIn("y", dir(c)) self.assertEqual(c.__dict__.get("x"), 42) self.assertEqual(c.x, 42) self.assertEqual(c.y, 47) with self.assertRaisesRegexp(AttributeError, r"'C' object has no attribute 'z'"): c.z
Example #16
Source File: lucene_tools.py From EntityLinkingRetrieval-ELR with MIT License | 5 votes |
def get_doc_phrase_freq(self, phrase, field, slop, ordered): """ Returns collection frequency for a given phrase and field. :param phrase: str :param field: field name :param slop: number of terms in between :param ordered: If true, term occurrences should be ordered :return: dictionary {doc: freq, ...} """ # creates span near query span_near_query = self.get_span_query(phrase.split(" "), field, slop=slop, ordered=ordered) # extracts document frequency self.open_searcher() index_reader_context = self.searcher.getTopReaderContext() term_contexts = HashMap() terms = TreeSet() span_near_query.extractTerms(terms) for term in terms: term_contexts.put(term, TermContext.build(index_reader_context, term)) leaves = index_reader_context.leaves() doc_phrase_freq = {} # iterates over all atomic readers for atomic_reader_context in leaves: bits = atomic_reader_context.reader().getLiveDocs() spans = span_near_query.getSpans(atomic_reader_context, bits, term_contexts) while spans.next(): lucene_doc_id = spans.doc() doc_id = atomic_reader_context.reader().document(lucene_doc_id).get(self.FIELDNAME_ID) if doc_id not in doc_phrase_freq: doc_phrase_freq[doc_id] = 1 else: doc_phrase_freq[doc_id] += 1 return doc_phrase_freq
Example #17
Source File: test_java_integration.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_map_delegation(self): m = HashMap() m["a"] = "b" self.assertTrue("a" in m) self.assertEquals("b", m["a"]) n = 0 for k in m: n += 1 self.assertEquals("a", k) self.assertEquals(1, n) del m["a"] self.assertEquals(0, len(m))
Example #18
Source File: example2.py From openhab-helper-libraries with Eclipse Public License 1.0 | 5 votes |
def tick_generator(): for i in xrange(10): tick = HashMap() tick.put("time", datetime.now()) tick.put("price", 5.3 + random()) tick.put("symbol", "AAPL") yield tick
Example #19
Source File: example3.py From openhab-helper-libraries with Eclipse Public License 1.0 | 5 votes |
def event_generator(): global now for i in xrange(100): runtime.sendEvent(CurrentTimeEvent(int(now.total_seconds() * 1000))) evt = HashMap() evt.put("time", int(now.total_seconds() * 1000)) evt.put("item", "TestItem") evt.put("state", "ON") yield evt, "UpdateEvent" now += timedelta(seconds=random * 0.4)
Example #20
Source File: super_gluu_ro.py From community-edition-setup with MIT License | 5 votes |
def new_unauthenticated_session(self,user,client): sessionIdService = CdiUtil.bean(SessionIdService) authDate = Date() sid_attrs = HashMap() sid_attrs.put(Constants.AUTHENTICATED_USER,user.getUserId()) sid_attrs.put(self.clientIdSessionParamName,client.getClientId()) sessionId = sessionIdService.generateUnauthenticatedSessionId(user.getDn(),authDate,SessionIdState.UNAUTHENTICATED,sid_attrs,True) print "Super-Gluu-RO. Generated session id. DN: '%s'" % sessionId.getDn() return sessionId
Example #21
Source File: Casa.py From community-edition-setup with MIT License | 5 votes |
def getConfigurationAttributes(self, acr, scriptsList): configMap = HashMap() for customScript in scriptsList: if customScript.getName() == acr and customScript.isEnabled(): for prop in customScript.getConfigurationProperties(): configMap.put(prop.getValue1(), SimpleCustomProperty(prop.getValue1(), prop.getValue2())) print "Casa. getConfigurationAttributes. %d configuration properties were found for %s" % (configMap.size(), acr) return configMap