def test_ArrayList(self): """create ArrayList in JVM (from the JavaSet) """ arrayList = ArrayList(self.javaList) # print "created ArrayList:", arrayList, type(arrayList) self.assertEqual(self.javaList.size(), arrayList.size(), "ArrayList has same size") elem0 = arrayList.get(0) elem1 = arrayList.get(1) self.assertEqual(0, arrayList.indexOf(elem0), "same index position") self.assertEqual(1, arrayList.indexOf(elem1), "same index position") listElem0 = self.testList[0] listElem1 = self.testList[1] _type = self._primitive_types.get(elem0.getClass()) if _type is not None: elem0 = _type.class_.cast(elem0) elem1 = _type.class_.cast(elem1) self.assertEqual(elem0, listElem0, "should be equal: %s (%s) <-> %s (%s)" % ( elem0, type(elem0), listElem0, type(listElem0))) self.assertEqual(elem1, listElem1, "should be equal: %s (%s) <-> %s (%s)" % ( elem1, type(elem1), listElem1, type(listElem1))) self.assertEqual(type(elem0), type(listElem0), "should have same type: %s <-> %s" % ( type(elem0), type(listElem0))) self.assertNotEqual(elem0, elem1, "ArrayList: first element must NOT equal second element")
def main(cls, args): """ generated source for method main """ GamerLogger.setSpilloverLogfile("spilloverLog") GamerLogger.log("Proxy", "Starting the ProxyGamePlayerClient program.") if not (len(args)): GamerLogger.logError("Proxy", "Usage is: \n\tProxyGamePlayerClient gamer port") return port = 9147 gamer = None try: port = Integer.valueOf(args[1]) except Exception as e: GamerLogger.logError("Proxy", args[1] + " is not a valid port.") return gamers = Lists.newArrayList(ProjectSearcher.GAMERS.getConcreteClasses()) gamerNames = ArrayList() if len(gamerNames) != len(gamers): for c in gamers: gamerNames.add(c.__name__.replaceAll("^.*\\.", "")) idx = gamerNames.indexOf(args[0]) if idx == -1: GamerLogger.logError("Proxy", args[0] + " is not a subclass of gamer. Valid options are:") for s in gamerNames: GamerLogger.logError("Proxy", "\t" + s) return try: gamer = (gamers.get(idx).newInstance()) except Exception as ex: GamerLogger.logError("Proxy", "Cannot create instance of " + args[0]) return try: theClient.start() except IOException as e: GamerLogger.logStackTrace("Proxy", e)
def create(cls, conjunct, functionInfo, rightmostVar, varOrder, preassignment): """ generated source for method create """ # We have to set up the things mentioned above... internalFunctions = ArrayList() # We can traverse the conjunct for the list of variables/constants... terms = ArrayList() gatherVars(conjunct.getBody(), terms) # Note that we assume here that the var of interest only # appears once in the relation... varIndex = terms.indexOf(rightmostVar) if varIndex == -1: print "conjunct is: " + conjunct print "terms are: " + terms print "righmostVar is: " + rightmostVar terms.remove(rightmostVar) function_ = functionInfo.getValueMap(varIndex) # Set up inputs and such, using terms querySize = len(terms) isInputConstant = ArrayList(len(terms)) queryConstants = Maps.newHashMap() queryInputIndices = ArrayList(len(terms)) i = 0 while i < len(terms): if isinstance(term, (GdlConstant, )): isInputConstant.add(True) queryConstants.put(i, term) queryInputIndices.add(-1) elif isinstance(term, (GdlVariable, )): # Is it in the head assignment? if preassignment.containsKey(term): isInputConstant.add(True) queryConstants.put(i, preassignment.get(term)) queryInputIndices.add(-1) else: isInputConstant.add(False) # queryConstants.add(null); # What value do we put here? # We want to grab some value out of the # input tuple, which uses functional ordering # Index of the relevant variable, by the # assignment's ordering queryInputIndices.add(varOrder.indexOf(term)) i += 1 return AssignmentFunction(ImmutableList.copyOf(internalFunctions), querySize, ImmutableList.copyOf(isInputConstant), ImmutableMap.copyOf(queryConstants), ImmutableList.copyOf(queryInputIndices), ImmutableMap.copyOf(function_))