/** * Context 的获取优先级,以数组的顺序来决定 * * @param contexts */ public ComboContext(IocContext... contexts) { ArrayList<IocContext> tmp = new ArrayList<IocContext>(contexts.length); for (IocContext iocContext : contexts) { if (tmp.contains(iocContext)) continue; if (iocContext instanceof ComboContext){ ComboContext comboContext = (ComboContext)iocContext; for (IocContext iocContext2 : comboContext.contexts) { if (tmp.contains(iocContext2)) continue; tmp.add(iocContext2); } } else tmp.add(iocContext); } this.contexts = tmp.toArray(new IocContext[tmp.size()]); }
private void disableExcludedCiphers(SSLEngine sslEngine) { String[] cipherSuites = sslEngine.getEnabledCipherSuites(); ArrayList<String> defaultEnabledCipherSuites = new ArrayList<String>(Arrays.asList(cipherSuites)); Iterator iterator = excludeCiphers.iterator(); while(iterator.hasNext()) { String cipherName = (String)iterator.next(); if(defaultEnabledCipherSuites.contains(cipherName)) { defaultEnabledCipherSuites.remove(cipherName); LOG.debug("Disabling cipher suite {}.", cipherName); } } cipherSuites = defaultEnabledCipherSuites.toArray( new String[defaultEnabledCipherSuites.size()]); sslEngine.setEnabledCipherSuites(cipherSuites); }
/** * Values.toArray contains all values */ public void testValuesToArray() { ConcurrentMap map = map5(); Collection v = map.values(); Object[] ar = v.toArray(); ArrayList s = new ArrayList(Arrays.asList(ar)); assertEquals(5, ar.length); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); assertTrue(s.contains("D")); assertTrue(s.contains("E")); }
private void graphTraverse(Unit startPoint, InterproceduralCFG<Unit, SootMethod> icfg) { List<Unit> currentSuccessors = icfg.getSuccsOf(startPoint); if (currentSuccessors.size() == 0) { System.out.println("Traversal complete"); return; } else { for (Unit succ : currentSuccessors) { System.out.println("Succesor: " + succ.toString()); if (!visited.contains(succ)) { dotIcfg.drawEdge(startPoint.toString(), succ.toString()); visited.add(succ); graphTraverse(succ, icfg); } else { dotIcfg.drawEdge(startPoint.toString(), succ.toString()); } } } } }
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { if (mDoTrick) { ArrayList<View> sortedScenes = mSortedScenes; if (child == mDumpView) { boolean more = false; for (int i = 0, n = sortedScenes.size(); i < n; i++) { more |= super.drawChild(canvas, sortedScenes.get(i), drawingTime); } return more; } else if (sortedScenes.contains(child)) { // Skip return false; } } return super.drawChild(canvas, child, drawingTime); } }
@Override void findResources(String name, ArrayList<URL> resources) { URL res = findResourceInOwn(name); if (res != null && !resources.contains(res)) { resources.add(res); } if (index != null) { int pos = name.lastIndexOf("/"); // only keep the directory part of the resource // as index.list only keeps track of directories and root files String indexedName = (pos > 0) ? name.substring(0, pos) : name; ArrayList<URL> urls = index.get(indexedName); if (urls != null) { urls.remove(url); for (URL url : urls) { URLHandler h = getSubHandler(url); if (h != null) { h.findResources(name, resources); } } } } }
@Test public void testListRecordSets() { EasyMock.expect(dnsRpcMock.listRecordSets(ZONE_INFO.getName(), EMPTY_RPC_OPTIONS)) .andReturn(LIST_OF_PB_DNS_RECORDS); EasyMock.replay(dnsRpcMock); dns = options.getService(); // creates DnsImpl Page<RecordSet> dnsPage = dns.listRecordSets(ZONE_INFO.getName()); assertEquals(2, Lists.newArrayList(dnsPage.getValues()).size()); assertTrue(Lists.newArrayList(dnsPage.getValues()).contains(DNS_RECORD1)); assertTrue(Lists.newArrayList(dnsPage.getValues()).contains(DNS_RECORD2)); }
public static void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { PermissionRequest requestResult = new PermissionRequest(requestCode); if (permissionRequests.contains(requestResult)) { PermissionRequest permissionRequest = permissionRequests.get(permissionRequests.indexOf(requestResult)); if (verifyPermissions(grantResults)) { //Permission has been granted permissionRequest.getPermissionCallback().permissionGranted(); } else { permissionRequest.getPermissionCallback().permissionRefused(); } permissionRequests.remove(requestResult); } refreshMonitoredList(); }
public void cancel(String taskId) { if (currentTask != null) { if (taskId.equals(currentTask.getId())) { currentTask.cancel(); currentTask.setDownloadStatus(DownloadStatus.DOWNLOAD_STATUS_CANCEL); } } if (prepareTaskList.contains(taskId)) { downTaskCount--; prepareTaskList.remove(taskId); } if (prepareTaskList.size() == 0) { currentTask = null; } downFileStore.deleteTask(taskId); upDateNotification(); sendIntent(TASKS_CHANGED); L.D(d, TAG, "cancle task = " + taskId); }
/** * Define the connection profile to execute the current statement */ String getStatementConnection() { if (exec.stmtConnList.contains(exec.conf.defaultConnection)) { return exec.conf.defaultConnection; } else if (!exec.stmtConnList.isEmpty()) { return exec.stmtConnList.get(0); } return exec.conf.defaultConnection; }
/** * Get the continent/country/city list and their corresponding sizes */ protected void getLayers() { for (String user: hierarchy.keySet()) { String continent = hierarchy.get(user).get(0); String country = hierarchy.get(user).get(1); String city = hierarchy.get(user).get(2); if (!continentList.contains(continent)) continentList.add(continent); if (!countryList.contains(country)) countryList.add(country); if (!cityList.contains(city)) cityList.add(city); } continentNum = continentList.size(); countryNum = countryList.size(); cityNum = cityList.size(); total_node = continentNum + countryNum + cityNum; non_leaf = continentNum + countryNum + 1; LOG.info("continentNum: "+ continentNum+"; countryNum: "+countryNum+"; cityNum: "+cityNum); LOG.info("total number of nodes: "+total_node + "; the number of non_leaf nodes: "+ non_leaf); }
public boolean hasImageCaptureBug() { // list of known devices that have the bug ArrayList<String> devices = new ArrayList<String>(); devices.add("android-devphone1/dream_devphone/dream"); devices.add("generic/sdk/generic"); devices.add("vodafone/vfpioneer/sapphire"); devices.add("tmobile/kila/dream"); devices.add("verizon/voles/sholes"); devices.add("google_ion/google_ion/sapphire"); return devices.contains(android.os.Build.BRAND + "/" + android.os.Build.PRODUCT + "/" + android.os.Build.DEVICE); }
@Test void testUseProfiles_withTwoDifferentValues() throws Exception { //given Vtor vtor = new Vtor(); vtor.useProfiles("testProfile1", "testProfile2"); assertEquals(2, vtor.enabledProfiles.size()); ArrayList<String> enabledProfileList = new ArrayList<>(vtor.enabledProfiles); assertTrue(enabledProfileList.contains("testProfile1"), "first element must be equal to first added profile"); assertTrue(enabledProfileList.contains("testProfile2"), "second element must be equal to second added profile"); //when vtor.useProfile(null); //then assertEquals(2, vtor.enabledProfiles.size()); }
private void onPictureSelectedChange(String path) { if (!selectedFile.contains(path)) { if (selectedFile.size() >= maxSize) { showMessage(String.format("最多只能选%d张相片", maxSize)); return; } selectedFile.add(path); } else selectedFile.remove(path); getAdapter().notifyDataSetChanged(); getActivity().invalidateOptionsMenu(); // btnCounter.setVisibility(selectedFile.size() == 0 ? View.GONE : View.VISIBLE); // txtCounter.setText(String.format("预览(%d/%d)", selectedFile.size(), maxSize)); }