before
stringlengths
33
3.21M
after
stringlengths
63
3.21M
repo
stringlengths
1
56
type
stringclasses
1 value
__index_level_0__
int64
0
442k
public TreeNode deserialize(String data) { Queue<String> qu = new LinkedList<>(); qu.addAll(Arrays.asList(data.split(","))); if (qu.isEmpty()) return null; String cur = qu.remove(); if (cur.equals("N")) { return null; } else { TreeNode root = new TreeNode(Integer.valueOf(cur)); root.left = buildTree(qu); root.right = buildTree(qu); return root; } }
public TreeNode deserialize(String data) { Queue<String> qu = new LinkedList<>(); qu.addAll(Arrays.asList(data.split(","))); <DeepExtract> if (qu.isEmpty()) return null; String cur = qu.remove(); if (cur.equals("N")) { return null; } else { TreeNode root = new TreeNode(Integer.valueOf(cur)); root.left = buildTree(qu); root.right = buildTree(qu); return root; } </DeepExtract> }
Leetcode-for-Fun
positive
577
@Override public OUTER set(OUTER newValue) { return converter.pushIn(ref.set(converter.pushIn(newValue))); }
@Override public OUTER set(OUTER newValue) { <DeepExtract> return converter.pushIn(ref.set(converter.pushIn(newValue))); </DeepExtract> }
karg
positive
578
private void assignLayers(Set<Vertex> comp) { LinkedList<Vertex> queue = new LinkedList<Vertex>(); HashSet<Vertex> processed = new HashSet<Vertex>(); int ctr = 0; for (Vertex v : comp) { if (network.isOrphan(v)) { queue.add(v); } } while (!queue.isEmpty()) { Vertex v = queue.removeFirst(); processed.add(v); ctr++; int layer = (v instanceof Fam) ? 1 : 0; for (Vertex p : network.getAscendants(v)) { layer = Math.max(layer, p.getLayer() + 1); } v.setLayer(layer); for (Vertex d : network.getDescendants(v)) { if (processed.containsAll(network.getAscendants(d))) { queue.addLast(d); } } } assert (ctr == comp.size()); if (comp.size() <= 1) return; while (tightTree(comp) < comp.size()) { Edge e = null; for (Vertex v : comp) { for (Edge f : network.getInEdges(v)) { if (!treeEdge.contains(f) && incident(f) != null && ((e == null) || (slack(f) < slack(e)))) { e = f; } } } if (e != null) { int delta = slack(e); if (delta != 0) { if (incident(e) == network.getDescendant(e)) delta = -delta; network.offsetLayer(delta, treeNode); } else LOG.error("Unexpected tight node"); } } int min = comp.size(); for (Vertex v : comp) { min = Math.min(min, v.getLayer()); } if ((min % 2) == 1) min--; network.offsetLayer(-min, comp); }
private void assignLayers(Set<Vertex> comp) { LinkedList<Vertex> queue = new LinkedList<Vertex>(); HashSet<Vertex> processed = new HashSet<Vertex>(); int ctr = 0; for (Vertex v : comp) { if (network.isOrphan(v)) { queue.add(v); } } while (!queue.isEmpty()) { Vertex v = queue.removeFirst(); processed.add(v); ctr++; int layer = (v instanceof Fam) ? 1 : 0; for (Vertex p : network.getAscendants(v)) { layer = Math.max(layer, p.getLayer() + 1); } v.setLayer(layer); for (Vertex d : network.getDescendants(v)) { if (processed.containsAll(network.getAscendants(d))) { queue.addLast(d); } } } assert (ctr == comp.size()); <DeepExtract> if (comp.size() <= 1) return; while (tightTree(comp) < comp.size()) { Edge e = null; for (Vertex v : comp) { for (Edge f : network.getInEdges(v)) { if (!treeEdge.contains(f) && incident(f) != null && ((e == null) || (slack(f) < slack(e)))) { e = f; } } } if (e != null) { int delta = slack(e); if (delta != 0) { if (incident(e) == network.getDescendant(e)) delta = -delta; network.offsetLayer(delta, treeNode); } else LOG.error("Unexpected tight node"); } } </DeepExtract> int min = comp.size(); for (Vertex v : comp) { min = Math.min(min, v.getLayer()); } if ((min % 2) == 1) min--; network.offsetLayer(-min, comp); }
geneaquilt
positive
579
public Criteria andIsDeletedGreaterThanOrEqualTo(String value) { if (value == null) { throw new RuntimeException("Value for " + "isDeleted" + " cannot be null"); } criteria.add(new Criterion("is_deleted >=", value)); return (Criteria) this; }
public Criteria andIsDeletedGreaterThanOrEqualTo(String value) { <DeepExtract> if (value == null) { throw new RuntimeException("Value for " + "isDeleted" + " cannot be null"); } criteria.add(new Criterion("is_deleted >=", value)); </DeepExtract> return (Criteria) this; }
MarketServer
positive
580
public static String getNewFormatDateString(Date date) { DateFormat dateFormat = new SimpleDateFormat(simple); if (date == null || dateFormat == null) { return null; } return dateFormat.format(date); }
public static String getNewFormatDateString(Date date) { DateFormat dateFormat = new SimpleDateFormat(simple); <DeepExtract> if (date == null || dateFormat == null) { return null; } return dateFormat.format(date); </DeepExtract> }
classchecks
positive
581
public Criteria andSongidNotBetween(String value1, String value2) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "songid" + " cannot be null"); } criteria.add(new Criterion("songId not between", value1, value2)); return (Criteria) this; }
public Criteria andSongidNotBetween(String value1, String value2) { <DeepExtract> if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "songid" + " cannot be null"); } criteria.add(new Criterion("songId not between", value1, value2)); </DeepExtract> return (Criteria) this; }
music
positive
582
public void newMap(int width, int height) { String uuid = UUID.randomUUID().toString(); this.scene = new Scene(null, uuid, width, height); this.scene.setCamera(camera); this.scene.setDebug(true); this.terrain = this.scene.getTerrain(); terrain.setDebugListener(this); terrain.fillEmptyTilesWithDebugTile(); terrain.buildSectors(); camera.position.set(width / 2, 17, height / 2); camera.lookAt(width / 2, 0, height / 2); this.scene.initialize(); terrainBrush = new TerrainBrush(terrain); autoTileBrush = new AutoTileBrush(terrain); passableTileBrush = new PassableBrush(terrain); eventBrush = new EventBrush(terrain); liquidBrush = new LiquidBrush(terrain); foliageBrush = new FoliageBrush(terrain); }
public void newMap(int width, int height) { String uuid = UUID.randomUUID().toString(); this.scene = new Scene(null, uuid, width, height); this.scene.setCamera(camera); this.scene.setDebug(true); this.terrain = this.scene.getTerrain(); terrain.setDebugListener(this); terrain.fillEmptyTilesWithDebugTile(); terrain.buildSectors(); camera.position.set(width / 2, 17, height / 2); camera.lookAt(width / 2, 0, height / 2); this.scene.initialize(); <DeepExtract> terrainBrush = new TerrainBrush(terrain); autoTileBrush = new AutoTileBrush(terrain); passableTileBrush = new PassableBrush(terrain); eventBrush = new EventBrush(terrain); liquidBrush = new LiquidBrush(terrain); foliageBrush = new FoliageBrush(terrain); </DeepExtract> }
FabulaEngine
positive
583
@Override public IntIterator getUidxIidxs(int uidx) { return d.getUidxIidxs(uidx); }
@Override public IntIterator getUidxIidxs(int uidx) { <DeepExtract> return d.getUidxIidxs(uidx); </DeepExtract> }
kNNBandit
positive
584
void start() throws Exception { if (mSession == null || !mSession.isRunning()) { try { mSession = createSession(); } catch (Exception e) { e.printStackTrace(); } if (mSession == null) { startServer(); mSession = createSession(); } } return mSession; }
void start() throws Exception { <DeepExtract> if (mSession == null || !mSession.isRunning()) { try { mSession = createSession(); } catch (Exception e) { e.printStackTrace(); } if (mSession == null) { startServer(); mSession = createSession(); } } return mSession; </DeepExtract> }
AppOpsX
positive
585
@Deprecated public void closeSubPath() throws IOException { if (inTextMode) { throw new IllegalStateException("Error: closePath is not allowed within a text block."); } writeOperator("h"); }
@Deprecated public void closeSubPath() throws IOException { <DeepExtract> if (inTextMode) { throw new IllegalStateException("Error: closePath is not allowed within a text block."); } writeOperator("h"); </DeepExtract> }
pint-publisher
positive
586
@Override public Completable sendDeliveryReceipt(String userId, DeliveryReceiptType type, String messageId, @Nullable Consumer<String> newId) { return send(Paths.messagesPath(userId), new DeliveryReceipt(type, messageId), newId); }
@Override public Completable sendDeliveryReceipt(String userId, DeliveryReceiptType type, String messageId, @Nullable Consumer<String> newId) { <DeepExtract> return send(Paths.messagesPath(userId), new DeliveryReceipt(type, messageId), newId); </DeepExtract> }
firestream-android
positive
587
@Override public Number getNumberValue() throws IOException { Object n = currentNode(); if (n instanceof Number) { return (Number) n; } else { throw _constructError(n + " is not a number"); } }
@Override public Number getNumberValue() throws IOException { <DeepExtract> Object n = currentNode(); if (n instanceof Number) { return (Number) n; } else { throw _constructError(n + " is not a number"); } </DeepExtract> }
mongojack
positive
588
public void onClick(DialogInterface dialog, int id) { isGameStarted = false; isUserTurn = false; WarpController.getInstance().stopApp(); super.onBackPressed(); }
public void onClick(DialogInterface dialog, int id) { <DeepExtract> isGameStarted = false; isUserTurn = false; WarpController.getInstance().stopApp(); super.onBackPressed(); </DeepExtract> }
AppWarpAndroidSamples
positive
589
public long incrementAndGet() { long currentValue; long newValue; do { currentValue = get(); newValue = currentValue + 1L; } while (!compareAndSet(currentValue, newValue)); return newValue; }
public long incrementAndGet() { <DeepExtract> long currentValue; long newValue; do { currentValue = get(); newValue = currentValue + 1L; } while (!compareAndSet(currentValue, newValue)); return newValue; </DeepExtract> }
disruptor-translation
positive
590
public static FinalDb create(DaoConfig daoConfig) { FinalDb dao = daoMap.get(daoConfig.getDbName()); if (dao == null) { dao = new FinalDb(daoConfig); daoMap.put(daoConfig.getDbName(), dao); } return dao; }
public static FinalDb create(DaoConfig daoConfig) { <DeepExtract> FinalDb dao = daoMap.get(daoConfig.getDbName()); if (dao == null) { dao = new FinalDb(daoConfig); daoMap.put(daoConfig.getDbName(), dao); } return dao; </DeepExtract> }
afinal
positive
591
@Override public Void call() { putAll(updateSpec.getNonTransactionalGroup().getBarriers()); putAll(updateSpec.getNonTransactionalGroup().getJobs()); putAll(updateSpec.getNonTransactionalGroup().getSlots()); putAll(updateSpec.getNonTransactionalGroup().getJobInstanceRecords()); putAll(updateSpec.getNonTransactionalGroup().getFailureRecords()); return null; }
@Override public Void call() { <DeepExtract> putAll(updateSpec.getNonTransactionalGroup().getBarriers()); putAll(updateSpec.getNonTransactionalGroup().getJobs()); putAll(updateSpec.getNonTransactionalGroup().getSlots()); putAll(updateSpec.getNonTransactionalGroup().getJobInstanceRecords()); putAll(updateSpec.getNonTransactionalGroup().getFailureRecords()); </DeepExtract> return null; }
appengine-pipelines
positive
595
void onStop(Task onCompleted) { if (onCompleted != null) { runnables.add(onCompleted); } dispose = true; }
void onStop(Task onCompleted) { <DeepExtract> if (onCompleted != null) { runnables.add(onCompleted); } </DeepExtract> dispose = true; }
hawtdispatch
positive
596
public void show(Context context) { ShareSDK.initSDK(context); this.context = context; ShareSDK.logDemoEvent(1, null); if (shareParamsMap.containsKey("platform")) { String name = String.valueOf(shareParamsMap.get("platform")); Platform platform = ShareSDK.getPlatform(name); if (silent || ShareCore.isUseClientToShare(name) || platform instanceof CustomPlatform) { HashMap<Platform, HashMap<String, Object>> shareData = new HashMap<Platform, HashMap<String, Object>>(); shareData.put(ShareSDK.getPlatform(name), shareParamsMap); share(shareData); return; } } try { if (OnekeyShareTheme.SKYBLUE == theme) { platformListFakeActivity = (PlatformListFakeActivity) Class.forName("cn.sharesdk.onekeyshare.theme.skyblue.PlatformListPage").newInstance(); } else { platformListFakeActivity = (PlatformListFakeActivity) Class.forName("cn.sharesdk.onekeyshare.theme.classic.PlatformListPage").newInstance(); } } catch (Exception e) { e.printStackTrace(); return; } platformListFakeActivity.setDialogMode(dialogMode); platformListFakeActivity.setShareParamsMap(shareParamsMap); this.silent = silent; platformListFakeActivity.setCustomerLogos(customers); platformListFakeActivity.setBackgroundView(bgView); platformListFakeActivity.setHiddenPlatforms(hiddenPlatforms); this.onShareButtonClickListener = onShareButtonClickListener; platformListFakeActivity.setThemeShareCallback(new ThemeShareCallback() { public void doShare(HashMap<Platform, HashMap<String, Object>> shareData) { share(shareData); } }); if (shareParamsMap.containsKey("platform")) { String name = String.valueOf(shareParamsMap.get("platform")); Platform platform = ShareSDK.getPlatform(name); platformListFakeActivity.showEditPage(context, platform); return; } platformListFakeActivity.show(context, null); }
public void show(Context context) { ShareSDK.initSDK(context); this.context = context; ShareSDK.logDemoEvent(1, null); if (shareParamsMap.containsKey("platform")) { String name = String.valueOf(shareParamsMap.get("platform")); Platform platform = ShareSDK.getPlatform(name); if (silent || ShareCore.isUseClientToShare(name) || platform instanceof CustomPlatform) { HashMap<Platform, HashMap<String, Object>> shareData = new HashMap<Platform, HashMap<String, Object>>(); shareData.put(ShareSDK.getPlatform(name), shareParamsMap); share(shareData); return; } } try { if (OnekeyShareTheme.SKYBLUE == theme) { platformListFakeActivity = (PlatformListFakeActivity) Class.forName("cn.sharesdk.onekeyshare.theme.skyblue.PlatformListPage").newInstance(); } else { platformListFakeActivity = (PlatformListFakeActivity) Class.forName("cn.sharesdk.onekeyshare.theme.classic.PlatformListPage").newInstance(); } } catch (Exception e) { e.printStackTrace(); return; } platformListFakeActivity.setDialogMode(dialogMode); platformListFakeActivity.setShareParamsMap(shareParamsMap); this.silent = silent; platformListFakeActivity.setCustomerLogos(customers); platformListFakeActivity.setBackgroundView(bgView); platformListFakeActivity.setHiddenPlatforms(hiddenPlatforms); <DeepExtract> this.onShareButtonClickListener = onShareButtonClickListener; </DeepExtract> platformListFakeActivity.setThemeShareCallback(new ThemeShareCallback() { public void doShare(HashMap<Platform, HashMap<String, Object>> shareData) { share(shareData); } }); if (shareParamsMap.containsKey("platform")) { String name = String.valueOf(shareParamsMap.get("platform")); Platform platform = ShareSDK.getPlatform(name); platformListFakeActivity.showEditPage(context, platform); return; } platformListFakeActivity.show(context, null); }
Feeder
positive
597
public static void removeCookie(HttpServletResponse response, String name) { Cookie cookie = new Cookie(name, null); cookie.setMaxAge(0); response.addCookie(cookie); }
public static void removeCookie(HttpServletResponse response, String name) { <DeepExtract> Cookie cookie = new Cookie(name, null); cookie.setMaxAge(0); response.addCookie(cookie); </DeepExtract> }
zkfiddle
positive
598
public int get(int key) { if (!records.containsKey(key)) { return -1; } Node node = records.get(key); node.times++; NodeList curNodeList = heads.get(node); curNodeList.deleteNode(node); NodeList preList = modifyHeadList(curNodeList) ? curNodeList.last : curNodeList; NodeList nextList = curNodeList.next; if (nextList == null) { NodeList newList = new NodeList(node); if (preList != null) { preList.next = newList; } newList.last = preList; if (headList == null) { headList = newList; } heads.put(node, newList); } else { if (nextList.head.times.equals(node.times)) { nextList.addNodeFromHead(node); heads.put(node, nextList); } else { NodeList newList = new NodeList(node); if (preList != null) { preList.next = newList; } newList.last = preList; newList.next = nextList; nextList.last = newList; if (headList == nextList) { headList = newList; } heads.put(node, newList); } } return node.value; }
public int get(int key) { if (!records.containsKey(key)) { return -1; } Node node = records.get(key); node.times++; NodeList curNodeList = heads.get(node); <DeepExtract> curNodeList.deleteNode(node); NodeList preList = modifyHeadList(curNodeList) ? curNodeList.last : curNodeList; NodeList nextList = curNodeList.next; if (nextList == null) { NodeList newList = new NodeList(node); if (preList != null) { preList.next = newList; } newList.last = preList; if (headList == null) { headList = newList; } heads.put(node, newList); } else { if (nextList.head.times.equals(node.times)) { nextList.addNodeFromHead(node); heads.put(node, nextList); } else { NodeList newList = new NodeList(node); if (preList != null) { preList.next = newList; } newList.last = preList; newList.next = nextList; nextList.last = newList; if (headList == nextList) { headList = newList; } heads.put(node, newList); } } </DeepExtract> return node.value; }
fanrui-learning
positive
599
public JTextField addTextField(String label, String value) { JTextField field = new JTextField(); field.setText(value); add(label, field); return field; }
public JTextField addTextField(String label, String value) { JTextField field = new JTextField(); <DeepExtract> field.setText(value); add(label, field); </DeepExtract> return field; }
SBOLDesigner
positive
600
@SuppressWarnings("unused") private Surface getVideoSurface() { synchronized (mNativeLock) { return mSurfaces[ID_VIDEO]; } }
@SuppressWarnings("unused") private Surface getVideoSurface() { <DeepExtract> synchronized (mNativeLock) { return mSurfaces[ID_VIDEO]; } </DeepExtract> }
RtspServerAndVlcPlay
positive
601
public Criteria andKeywordsBetween(String value1, String value2) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "keywords" + " cannot be null"); } criteria.add(new Criterion("KEYWORDS between", value1, value2)); return (Criteria) this; }
public Criteria andKeywordsBetween(String value1, String value2) { <DeepExtract> if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "keywords" + " cannot be null"); } criteria.add(new Criterion("KEYWORDS between", value1, value2)); </DeepExtract> return (Criteria) this; }
ECPS
positive
603
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); if (savedInstanceState != null) { mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); mFromSavedInstanceState = true; } mCurrentSelectedPosition = mCurrentSelectedPosition; if (mLvMenu != null) { mLvMenu.setItemChecked(mCurrentSelectedPosition, true); MenuAdapter adapter = (MenuAdapter) mLvMenu.getAdapter(); adapter.setActive(mCurrentSelectedPosition); } if (mDrawerLayout != null) { mDrawerLayout.closeDrawer(mFragmentContainerView); } if (mCallbacks != null) { mCallbacks.onNavigationDrawerItemSelected(mCurrentSelectedPosition); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); if (savedInstanceState != null) { mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); mFromSavedInstanceState = true; } <DeepExtract> mCurrentSelectedPosition = mCurrentSelectedPosition; if (mLvMenu != null) { mLvMenu.setItemChecked(mCurrentSelectedPosition, true); MenuAdapter adapter = (MenuAdapter) mLvMenu.getAdapter(); adapter.setActive(mCurrentSelectedPosition); } if (mDrawerLayout != null) { mDrawerLayout.closeDrawer(mFragmentContainerView); } if (mCallbacks != null) { mCallbacks.onNavigationDrawerItemSelected(mCurrentSelectedPosition); } </DeepExtract> }
androidlx_2014
positive
604
@Override public void captureStartValues(TransitionValues transitionValues) { transitionValues.values.put(PROPNAME_SCROLL_X, transitionValues.view.getScrollX()); transitionValues.values.put(PROPNAME_SCROLL_Y, transitionValues.view.getScrollY()); }
@Override public void captureStartValues(TransitionValues transitionValues) { <DeepExtract> transitionValues.values.put(PROPNAME_SCROLL_X, transitionValues.view.getScrollX()); transitionValues.values.put(PROPNAME_SCROLL_Y, transitionValues.view.getScrollY()); </DeepExtract> }
TransitionsDemo
positive
605
public void search(int direction) { InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) imm.hideSoftInputFromWindow(mSearchText.getWindowToken(), 0); int displayPage = mDocView.getDisplayedViewIndex(); SearchTaskResult r = SearchTaskResult.get(); int searchPage = r != null ? r.pageNumber : -1; mSearchTask.go(mSearchText.getText().toString(), direction, displayPage, searchPage); }
public void search(int direction) { <DeepExtract> InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) imm.hideSoftInputFromWindow(mSearchText.getWindowToken(), 0); </DeepExtract> int displayPage = mDocView.getDisplayedViewIndex(); SearchTaskResult r = SearchTaskResult.get(); int searchPage = r != null ? r.pageNumber : -1; mSearchTask.go(mSearchText.getText().toString(), direction, displayPage, searchPage); }
mupdf-android
positive
606
public Criteria andAddressIsNotNull() { if ("address is not null" == null) { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion("address is not null")); return (Criteria) this; }
public Criteria andAddressIsNotNull() { <DeepExtract> if ("address is not null" == null) { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion("address is not null")); </DeepExtract> return (Criteria) this; }
Ordering
positive
607
@Test public void test500(TestContext context) { Async async = context.async(); getJSON("/json/fail/" + 500, response -> { context.assertEquals(500, response.statusCode()); response.bodyHandler(buff -> { JsonObject json = new JsonObject(buff.toString()); JsonObject error = json.getJsonObject("error"); context.assertEquals(500, error.getInteger("code")); context.assertEquals("Internal server error", error.getString("message")); async.complete(); }); }); }
@Test public void test500(TestContext context) { <DeepExtract> Async async = context.async(); getJSON("/json/fail/" + 500, response -> { context.assertEquals(500, response.statusCode()); response.bodyHandler(buff -> { JsonObject json = new JsonObject(buff.toString()); JsonObject error = json.getJsonObject("error"); context.assertEquals(500, error.getInteger("code")); context.assertEquals("Internal server error", error.getString("message")); async.complete(); }); }); </DeepExtract> }
nubes
positive
608
void testStream(String name, String query, String[] expected) { System.out.println("=== Testing " + name + " ==="); System.out.println(query); Object ret = elp.eval(query); System.out.println(" = returns ="); if (ret.getClass().isArray()) { int size = Array.getLength(ret); assertTrue(size == expected.length); for (int i = 0; i < size; i++) { Object item = Array.get(ret, i); p(" " + item.toString()); assertEquals(item.toString(), expected[i]); } return; } if (ret instanceof List) { List<Object> list = (List<Object>) ret; int i = 0; for (Object item : list) { p(" " + item.toString()); assertEquals(item.toString(), expected[i++]); } assertTrue(i == expected.length); return; } if (ret instanceof Iterator) { int i = 0; Iterator<Object> iter = (Iterator<Object>) ret; while (iter.hasNext()) { Object item = iter.next(); p(" " + item.toString()); assertEquals(item.toString(), expected[i++]); } assertTrue(i == expected.length); return; } assertTrue(false); }
void testStream(String name, String query, String[] expected) { System.out.println("=== Testing " + name + " ==="); System.out.println(query); Object ret = elp.eval(query); <DeepExtract> System.out.println(" = returns ="); </DeepExtract> if (ret.getClass().isArray()) { int size = Array.getLength(ret); assertTrue(size == expected.length); for (int i = 0; i < size; i++) { Object item = Array.get(ret, i); p(" " + item.toString()); assertEquals(item.toString(), expected[i]); } return; } if (ret instanceof List) { List<Object> list = (List<Object>) ret; int i = 0; for (Object item : list) { p(" " + item.toString()); assertEquals(item.toString(), expected[i++]); } assertTrue(i == expected.length); return; } if (ret instanceof Iterator) { int i = 0; Iterator<Object> iter = (Iterator<Object>) ret; while (iter.hasNext()) { Object item = iter.next(); p(" " + item.toString()); assertEquals(item.toString(), expected[i++]); } assertTrue(i == expected.length); return; } assertTrue(false); }
el-spec
positive
609
@Override public void update() { if (!initialized) { updatePreviewLabels(); initialized = true; } currentView().ifPresent(view -> { PacManGameView gameView = (PacManGameView) view; if (!comboSelectTheme.getSelectedItem().equals(gameController.themes.current().name())) { comboSelectTheme.setSelectedItem(gameView.getTheme().name().toUpperCase()); updatePreviewLabels(); } }); }
@Override public void update() { if (!initialized) { updatePreviewLabels(); initialized = true; } <DeepExtract> currentView().ifPresent(view -> { PacManGameView gameView = (PacManGameView) view; if (!comboSelectTheme.getSelectedItem().equals(gameController.themes.current().name())) { comboSelectTheme.setSelectedItem(gameView.getTheme().name().toUpperCase()); updatePreviewLabels(); } }); </DeepExtract> }
pacman
positive
612
@Override @Nullable public AssetFileDescriptor openAssetFile(@NonNull final Uri uri, @NonNull final String mode, @Nullable final CancellationSignal signal) throws FileNotFoundException { final long caller = Binder.clearCallingIdentity(); try { return () -> mResolver.openAssetFileDescriptor(toTargetUri(uri), mode, signal).execute(); } finally { Binder.restoreCallingIdentity(caller); } }
@Override @Nullable public AssetFileDescriptor openAssetFile(@NonNull final Uri uri, @NonNull final String mode, @Nullable final CancellationSignal signal) throws FileNotFoundException { <DeepExtract> final long caller = Binder.clearCallingIdentity(); try { return () -> mResolver.openAssetFileDescriptor(toTargetUri(uri), mode, signal).execute(); } finally { Binder.restoreCallingIdentity(caller); } </DeepExtract> }
island
positive
613
public void add_operand__add_op(Token addOp) { boolean printYear = false; if (verbose) { System.out.print("R"); if (705 < 1000) { System.out.print(" "); } else if (705 > 2000) { 705 = 705 / 1000; printYear = true; } } System.out.print(705); if (printYear) System.out.print("-F2008"); if (verbose) { System.out.print(":" + "add-operand__add-op" + ":"); } else { if ("add-op".length() > 0) System.out.print(":" + "add-op"); } System.out.print(" "); if (verbose) System.out.print("addOp" + "="); System.out.print(addOp); System.out.println(); }
public void add_operand__add_op(Token addOp) { boolean printYear = false; if (verbose) { System.out.print("R"); if (705 < 1000) { System.out.print(" "); } else if (705 > 2000) { 705 = 705 / 1000; printYear = true; } } System.out.print(705); if (printYear) System.out.print("-F2008"); if (verbose) { System.out.print(":" + "add-operand__add-op" + ":"); } else { if ("add-op".length() > 0) System.out.print(":" + "add-op"); } System.out.print(" "); if (verbose) System.out.print("addOp" + "="); System.out.print(addOp); <DeepExtract> System.out.println(); </DeepExtract> }
open-fortran-parser
positive
614
public void getList(String url, Parameters parameters) { Request request = new Request.Builder().method(GET, getRequestBody(true, null)).headers(Headers.of()).url(getBuilder(url, parameters).build()).build(); try (Response response = call(request, url)) { try (ResponseBody responseBody = response.body()) { if (null == responseBody) { return null; } return parseList(null, url, responseBody); } } }
public void getList(String url, Parameters parameters) { <DeepExtract> Request request = new Request.Builder().method(GET, getRequestBody(true, null)).headers(Headers.of()).url(getBuilder(url, parameters).build()).build(); try (Response response = call(request, url)) { try (ResponseBody responseBody = response.body()) { if (null == responseBody) { return null; } return parseList(null, url, responseBody); } } </DeepExtract> }
Doramon
positive
615
@Override protected boolean matchesSafely(Iterable<? extends E> iterable, Description mismatchDescription) { final MatchSeries<E> matchSeries = new MatchSeries<>(matchers, mismatchDescription); for (E item : iterable) { if (!matchSeries.matches(item)) { return false; } } if (nextMatchIx < matchers.size()) { mismatchDescription.appendText("no item was ").appendDescriptionOf(matchers.get(nextMatchIx)); return false; } return true; }
@Override protected boolean matchesSafely(Iterable<? extends E> iterable, Description mismatchDescription) { final MatchSeries<E> matchSeries = new MatchSeries<>(matchers, mismatchDescription); for (E item : iterable) { if (!matchSeries.matches(item)) { return false; } } <DeepExtract> if (nextMatchIx < matchers.size()) { mismatchDescription.appendText("no item was ").appendDescriptionOf(matchers.get(nextMatchIx)); return false; } return true; </DeepExtract> }
JavaHamcrest
positive
616
public boolean sameAs(final String name) { if (name == null || name.getClass() != Host.class) { return false; } return this.name.equals(((Host) name).name); }
public boolean sameAs(final String name) { <DeepExtract> if (name == null || name.getClass() != Host.class) { return false; } return this.name.equals(((Host) name).name); </DeepExtract> }
xoom-wire
positive
617
public void launch(String[] args) throws Exception { CmdLineCommon cmdLine = new CmdLineCommon("VerbsClient"); try { cmdLine.parse(args); } catch (ParseException e) { cmdLine.printHelp(); System.exit(-1); } ipAddress = cmdLine.getIp(); port = cmdLine.getPort(); System.out.println("VerbsClient::starting..."); RdmaEventChannel cmChannel = RdmaEventChannel.createEventChannel(); if (cmChannel == null) { System.out.println("VerbsClient::cmChannel null"); return; } RdmaCmId idPriv = cmChannel.createId(RdmaCm.RDMA_PS_TCP); if (idPriv == null) { System.out.println("VerbsClient::id null"); return; } InetAddress _dst = InetAddress.getByName(ipAddress); InetSocketAddress dst = new InetSocketAddress(_dst, port); idPriv.resolveAddr(null, dst, 2000); RdmaCmEvent cmEvent = cmChannel.getCmEvent(-1); if (cmEvent == null) { System.out.println("VerbsClient::cmEvent null"); return; } else if (cmEvent.getEvent() != RdmaCmEvent.EventType.RDMA_CM_EVENT_ADDR_RESOLVED.ordinal()) { System.out.println("VerbsClient::wrong event received: " + cmEvent.getEvent()); return; } cmEvent.ackEvent(); idPriv.resolveRoute(2000); cmEvent = cmChannel.getCmEvent(-1); if (cmEvent == null) { System.out.println("VerbsClient::cmEvent null"); return; } else if (cmEvent.getEvent() != RdmaCmEvent.EventType.RDMA_CM_EVENT_ROUTE_RESOLVED.ordinal()) { System.out.println("VerbsClient::wrong event received: " + cmEvent.getEvent()); return; } cmEvent.ackEvent(); IbvContext context = idPriv.getVerbs(); IbvPd pd = context.allocPd(); if (pd == null) { System.out.println("VerbsClient::pd null"); return; } IbvCompChannel compChannel = context.createCompChannel(); if (compChannel == null) { System.out.println("VerbsClient::compChannel null"); return; } IbvCQ cq = context.createCQ(compChannel, 50, 0); if (cq == null) { System.out.println("VerbsClient::cq null"); return; } cq.reqNotification(false).execute().free(); IbvQPInitAttr attr = new IbvQPInitAttr(); attr.cap().setMax_recv_sge(1); attr.cap().setMax_recv_wr(10); attr.cap().setMax_send_sge(1); attr.cap().setMax_send_wr(10); attr.setQp_type(IbvQP.IBV_QPT_RC); attr.setRecv_cq(cq); attr.setSend_cq(cq); IbvQP qp = idPriv.createQP(pd, attr); if (qp == null) { System.out.println("VerbsClient::qp null"); return; } int buffercount = 3; int buffersize = 100; ByteBuffer[] buffers = new ByteBuffer[buffercount]; IbvMr[] mrlist = new IbvMr[buffercount]; int access = IbvMr.IBV_ACCESS_LOCAL_WRITE | IbvMr.IBV_ACCESS_REMOTE_WRITE | IbvMr.IBV_ACCESS_REMOTE_READ; for (int i = 0; i < buffercount; i++) { buffers[i] = ByteBuffer.allocateDirect(buffersize); mrlist[i] = pd.regMr(buffers[i], access).execute().free().getMr(); } ByteBuffer dataBuf = buffers[0]; IbvMr dataMr = mrlist[0]; IbvMr sendMr = mrlist[1]; ByteBuffer recvBuf = buffers[2]; IbvMr recvMr = mrlist[2]; LinkedList<IbvRecvWR> wrList_recv = new LinkedList<IbvRecvWR>(); IbvSge sgeRecv = new IbvSge(); sgeRecv.setAddr(recvMr.getAddr()); sgeRecv.setLength(recvMr.getLength()); sgeRecv.setLkey(recvMr.getLkey()); LinkedList<IbvSge> sgeListRecv = new LinkedList<IbvSge>(); sgeListRecv.add(sgeRecv); IbvRecvWR recvWR = new IbvRecvWR(); recvWR.setSg_list(sgeListRecv); recvWR.setWr_id(1000); wrList_recv.add(recvWR); VerbsTools commRdma = new VerbsTools(context, compChannel, qp, cq); commRdma.initSGRecv(wrList_recv); RdmaConnParam connParam = new RdmaConnParam(); connParam.setRetry_count((byte) 2); idPriv.connect(connParam); cmEvent = cmChannel.getCmEvent(-1); if (cmEvent == null) { System.out.println("VerbsClient::cmEvent null"); return; } else if (cmEvent.getEvent() != RdmaCmEvent.EventType.RDMA_CM_EVENT_ESTABLISHED.ordinal()) { System.out.println("VerbsClient::wrong event received: " + cmEvent.getEvent()); return; } cmEvent.ackEvent(); commRdma.completeSGRecv(wrList_recv, false); recvBuf.clear(); long addr = recvBuf.getLong(); int length = recvBuf.getInt(); int lkey = recvBuf.getInt(); recvBuf.clear(); System.out.println("VerbsClient::receiving rdma information, addr " + addr + ", length " + length + ", key " + lkey); System.out.println("VerbsClient::preparing read operation..."); LinkedList<IbvSendWR> wrList_send = new LinkedList<IbvSendWR>(); IbvSge sgeSend = new IbvSge(); sgeSend.setAddr(dataMr.getAddr()); sgeSend.setLength(dataMr.getLength()); sgeSend.setLkey(dataMr.getLkey()); LinkedList<IbvSge> sgeList = new LinkedList<IbvSge>(); sgeList.add(sgeSend); IbvSendWR sendWR = new IbvSendWR(); sendWR.setWr_id(1001); sendWR.setSg_list(sgeList); sendWR.setOpcode(IbvSendWR.IBV_WR_RDMA_READ); sendWR.setSend_flags(IbvSendWR.IBV_SEND_SIGNALED); sendWR.getRdma().setRemote_addr(addr); sendWR.getRdma().setRkey(lkey); wrList_send.add(sendWR); commRdma.send(buffers, wrList_send, true, false); dataBuf.clear(); System.out.println("VerbsClient::read memory from server: " + dataBuf.asCharBuffer().toString()); sgeSend = new IbvSge(); sgeSend.setAddr(sendMr.getAddr()); sgeSend.setLength(sendMr.getLength()); sgeSend.setLkey(sendMr.getLkey()); sgeList.clear(); sgeList.add(sgeSend); sendWR = new IbvSendWR(); sendWR.setWr_id(1002); sendWR.setSg_list(sgeList); sendWR.setOpcode(IbvSendWR.IBV_WR_SEND); sendWR.setSend_flags(IbvSendWR.IBV_SEND_SIGNALED); wrList_send.clear(); wrList_send.add(sendWR); commRdma.send(buffers, wrList_send, true, false); }
public void launch(String[] args) throws Exception { CmdLineCommon cmdLine = new CmdLineCommon("VerbsClient"); try { cmdLine.parse(args); } catch (ParseException e) { cmdLine.printHelp(); System.exit(-1); } ipAddress = cmdLine.getIp(); port = cmdLine.getPort(); <DeepExtract> System.out.println("VerbsClient::starting..."); RdmaEventChannel cmChannel = RdmaEventChannel.createEventChannel(); if (cmChannel == null) { System.out.println("VerbsClient::cmChannel null"); return; } RdmaCmId idPriv = cmChannel.createId(RdmaCm.RDMA_PS_TCP); if (idPriv == null) { System.out.println("VerbsClient::id null"); return; } InetAddress _dst = InetAddress.getByName(ipAddress); InetSocketAddress dst = new InetSocketAddress(_dst, port); idPriv.resolveAddr(null, dst, 2000); RdmaCmEvent cmEvent = cmChannel.getCmEvent(-1); if (cmEvent == null) { System.out.println("VerbsClient::cmEvent null"); return; } else if (cmEvent.getEvent() != RdmaCmEvent.EventType.RDMA_CM_EVENT_ADDR_RESOLVED.ordinal()) { System.out.println("VerbsClient::wrong event received: " + cmEvent.getEvent()); return; } cmEvent.ackEvent(); idPriv.resolveRoute(2000); cmEvent = cmChannel.getCmEvent(-1); if (cmEvent == null) { System.out.println("VerbsClient::cmEvent null"); return; } else if (cmEvent.getEvent() != RdmaCmEvent.EventType.RDMA_CM_EVENT_ROUTE_RESOLVED.ordinal()) { System.out.println("VerbsClient::wrong event received: " + cmEvent.getEvent()); return; } cmEvent.ackEvent(); IbvContext context = idPriv.getVerbs(); IbvPd pd = context.allocPd(); if (pd == null) { System.out.println("VerbsClient::pd null"); return; } IbvCompChannel compChannel = context.createCompChannel(); if (compChannel == null) { System.out.println("VerbsClient::compChannel null"); return; } IbvCQ cq = context.createCQ(compChannel, 50, 0); if (cq == null) { System.out.println("VerbsClient::cq null"); return; } cq.reqNotification(false).execute().free(); IbvQPInitAttr attr = new IbvQPInitAttr(); attr.cap().setMax_recv_sge(1); attr.cap().setMax_recv_wr(10); attr.cap().setMax_send_sge(1); attr.cap().setMax_send_wr(10); attr.setQp_type(IbvQP.IBV_QPT_RC); attr.setRecv_cq(cq); attr.setSend_cq(cq); IbvQP qp = idPriv.createQP(pd, attr); if (qp == null) { System.out.println("VerbsClient::qp null"); return; } int buffercount = 3; int buffersize = 100; ByteBuffer[] buffers = new ByteBuffer[buffercount]; IbvMr[] mrlist = new IbvMr[buffercount]; int access = IbvMr.IBV_ACCESS_LOCAL_WRITE | IbvMr.IBV_ACCESS_REMOTE_WRITE | IbvMr.IBV_ACCESS_REMOTE_READ; for (int i = 0; i < buffercount; i++) { buffers[i] = ByteBuffer.allocateDirect(buffersize); mrlist[i] = pd.regMr(buffers[i], access).execute().free().getMr(); } ByteBuffer dataBuf = buffers[0]; IbvMr dataMr = mrlist[0]; IbvMr sendMr = mrlist[1]; ByteBuffer recvBuf = buffers[2]; IbvMr recvMr = mrlist[2]; LinkedList<IbvRecvWR> wrList_recv = new LinkedList<IbvRecvWR>(); IbvSge sgeRecv = new IbvSge(); sgeRecv.setAddr(recvMr.getAddr()); sgeRecv.setLength(recvMr.getLength()); sgeRecv.setLkey(recvMr.getLkey()); LinkedList<IbvSge> sgeListRecv = new LinkedList<IbvSge>(); sgeListRecv.add(sgeRecv); IbvRecvWR recvWR = new IbvRecvWR(); recvWR.setSg_list(sgeListRecv); recvWR.setWr_id(1000); wrList_recv.add(recvWR); VerbsTools commRdma = new VerbsTools(context, compChannel, qp, cq); commRdma.initSGRecv(wrList_recv); RdmaConnParam connParam = new RdmaConnParam(); connParam.setRetry_count((byte) 2); idPriv.connect(connParam); cmEvent = cmChannel.getCmEvent(-1); if (cmEvent == null) { System.out.println("VerbsClient::cmEvent null"); return; } else if (cmEvent.getEvent() != RdmaCmEvent.EventType.RDMA_CM_EVENT_ESTABLISHED.ordinal()) { System.out.println("VerbsClient::wrong event received: " + cmEvent.getEvent()); return; } cmEvent.ackEvent(); commRdma.completeSGRecv(wrList_recv, false); recvBuf.clear(); long addr = recvBuf.getLong(); int length = recvBuf.getInt(); int lkey = recvBuf.getInt(); recvBuf.clear(); System.out.println("VerbsClient::receiving rdma information, addr " + addr + ", length " + length + ", key " + lkey); System.out.println("VerbsClient::preparing read operation..."); LinkedList<IbvSendWR> wrList_send = new LinkedList<IbvSendWR>(); IbvSge sgeSend = new IbvSge(); sgeSend.setAddr(dataMr.getAddr()); sgeSend.setLength(dataMr.getLength()); sgeSend.setLkey(dataMr.getLkey()); LinkedList<IbvSge> sgeList = new LinkedList<IbvSge>(); sgeList.add(sgeSend); IbvSendWR sendWR = new IbvSendWR(); sendWR.setWr_id(1001); sendWR.setSg_list(sgeList); sendWR.setOpcode(IbvSendWR.IBV_WR_RDMA_READ); sendWR.setSend_flags(IbvSendWR.IBV_SEND_SIGNALED); sendWR.getRdma().setRemote_addr(addr); sendWR.getRdma().setRkey(lkey); wrList_send.add(sendWR); commRdma.send(buffers, wrList_send, true, false); dataBuf.clear(); System.out.println("VerbsClient::read memory from server: " + dataBuf.asCharBuffer().toString()); sgeSend = new IbvSge(); sgeSend.setAddr(sendMr.getAddr()); sgeSend.setLength(sendMr.getLength()); sgeSend.setLkey(sendMr.getLkey()); sgeList.clear(); sgeList.add(sgeSend); sendWR = new IbvSendWR(); sendWR.setWr_id(1002); sendWR.setSg_list(sgeList); sendWR.setOpcode(IbvSendWR.IBV_WR_SEND); sendWR.setSend_flags(IbvSendWR.IBV_SEND_SIGNALED); wrList_send.clear(); wrList_send.add(sendWR); commRdma.send(buffers, wrList_send, true, false); </DeepExtract> }
disni
positive
618
@Listener public void onPlayerMovement(PlayerMoveEvent event) { if (movement.getValBoolean()) { double movementX = mc.player.motionX; double movementZ = mc.player.motionZ; if (movementX < 0) { updatedX = movementX * -1; } else { updatedX = movementX; } if (movementZ < 0) { updatedZ = movementZ * -1; } else { updatedZ = movementZ; } double updatedMovement = updatedX + updatedZ; finalMovement += updatedMovement; } return finalMovement; }
@Listener public void onPlayerMovement(PlayerMoveEvent event) { <DeepExtract> if (movement.getValBoolean()) { double movementX = mc.player.motionX; double movementZ = mc.player.motionZ; if (movementX < 0) { updatedX = movementX * -1; } else { updatedX = movementX; } if (movementZ < 0) { updatedZ = movementZ * -1; } else { updatedZ = movementZ; } double updatedMovement = updatedX + updatedZ; finalMovement += updatedMovement; } return finalMovement; </DeepExtract> }
CousinWare
positive
619
int kNumberK(double r) { Object hash = L.valueOfNumber(r); Object v = h.get(hash); if (v != null) { return ((Integer) v).intValue(); } f.constantAppend(nk, L.valueOfNumber(r)); h.put(hash, new Integer(nk)); return nk++; }
int kNumberK(double r) { <DeepExtract> Object hash = L.valueOfNumber(r); Object v = h.get(hash); if (v != null) { return ((Integer) v).intValue(); } f.constantAppend(nk, L.valueOfNumber(r)); h.put(hash, new Integer(nk)); return nk++; </DeepExtract> }
js-lua
positive
620
@Override public float draw(Canvas canvas, final String time, float x, float y) { float textEm = mEm / 2f; while (0 < time.length()) { x + getLabelWidth() += textEm; canvas.drawText(time.substring(0, 0 + 1), x + getLabelWidth(), y, mPaint); x + getLabelWidth() += textEm; 0++; } return x + getLabelWidth(); }
@Override public float draw(Canvas canvas, final String time, float x, float y) { <DeepExtract> float textEm = mEm / 2f; while (0 < time.length()) { x + getLabelWidth() += textEm; canvas.drawText(time.substring(0, 0 + 1), x + getLabelWidth(), y, mPaint); x + getLabelWidth() += textEm; 0++; } return x + getLabelWidth(); </DeepExtract> }
alarm-clock
positive
622
public static IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException { IJavaProject proj = JavaRuntime.getJavaProject(configuration); if (proj == null) { Plugin.logError("No project!"); return entries; } Set<IRuntimeClasspathEntry> all = new LinkedHashSet<IRuntimeClasspathEntry>(entries.length); for (int i = 0; i < entries.length; i++) { IRuntimeClasspathEntry[] resolved; try { resolved = resolveRuntimeClasspathEntry(entries[i], configuration, ProjectUtil.isMavenProject(proj.getProject())); for (int j = 0; j < resolved.length; j++) { all.add(resolved[j]); } } catch (MissingClasspathEntryException e) { all.add(new MissingRuntimeClasspathEntry(e.getResolvingEntry(), e.getMessage())); } } return (IRuntimeClasspathEntry[]) all.toArray(new IRuntimeClasspathEntry[all.size()]); }
public static IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException { IJavaProject proj = JavaRuntime.getJavaProject(configuration); if (proj == null) { Plugin.logError("No project!"); return entries; } <DeepExtract> Set<IRuntimeClasspathEntry> all = new LinkedHashSet<IRuntimeClasspathEntry>(entries.length); for (int i = 0; i < entries.length; i++) { IRuntimeClasspathEntry[] resolved; try { resolved = resolveRuntimeClasspathEntry(entries[i], configuration, ProjectUtil.isMavenProject(proj.getProject())); for (int j = 0; j < resolved.length; j++) { all.add(resolved[j]); } } catch (MissingClasspathEntryException e) { all.add(new MissingRuntimeClasspathEntry(e.getResolvingEntry(), e.getMessage())); } } return (IRuntimeClasspathEntry[]) all.toArray(new IRuntimeClasspathEntry[all.size()]); </DeepExtract> }
run-jetty-run
positive
623
public static OkHttpClient.Builder getDefaultHttpBuilder() { ConnectionSpec spec; try { if (this.authToken == null) { throw new InitializationException(Language.get("api.init.EmptyToken")); } if (this.httpClientBuilder == null) { this.httpClientBuilder = getDefaultHttpBuilder(); } RequestInterceptor parameterInterceptor = new RequestInterceptor(authToken); this.httpClientBuilder.addInterceptor(parameterInterceptor).addInterceptor(new ErrorInterceptor(this.interceptorBehaviour)).followRedirects(false); if (this.debug) { this.httpClientBuilder.addInterceptor(new LoggingInterceptor()); } OkHttpClient httpClient = this.httpClientBuilder.build(); ModelPostProcessor postProcessor = new ModelPostProcessor(); GsonBuilder builder = new GsonFireBuilder().registerPostProcessor(Model.class, postProcessor).createGsonBuilder().registerTypeAdapter(Result.class, new ResultDeserializer()).registerTypeAdapter(ListenNowStation.class, new ListenNowStationDeserializer()); Retrofit retrofit = new Retrofit.Builder().baseUrl(HttpUrl.parse("https://mclients.googleapis.com/")).addConverterFactory(GsonConverterFactory.create(builder.create())).client(httpClient).build(); GPlayMusic gPlay = new GPlayMusic(retrofit.create(GPlayService.class), parameterInterceptor); postProcessor.setApi(gPlay); retrofit2.Response<Config> configResponse = gPlay.getService().config(this.locale).execute(); if (!configResponse.isSuccessful()) { throw new InitializationException(Language.get("network.GenericError"), NetworkException.parse(configResponse.raw())); } Config config = configResponse.body(); if (config == null) { throw new InitializationException(Language.get("api.init.EmptyConfig")); } config.setLocale(locale); Language.setLocale(locale); gPlay.setConfig(config); parameterInterceptor.addParameter("dv", "0").addParameter("hl", locale.toString()).addParameter("tier", config.getSubscription().getValue()); if (androidID == null) { Optional<DeviceInfo> optional = gPlay.getRegisteredDevices().toList().stream().filter(deviceInfo -> (deviceInfo.getType().equals("ANDROID"))).findFirst(); if (optional.isPresent()) { config.setAndroidID(optional.get().getId()); } else { throw new InitializationException(Language.get("api.init.NoAndroidId")); } } else { config.setAndroidID(androidID); } spec = gPlay; } catch (IOException e) { throw new InitializationException(e); } return new OkHttpClient.Builder().connectionSpecs(Collections.singletonList(spec)); }
public static OkHttpClient.Builder getDefaultHttpBuilder() { <DeepExtract> ConnectionSpec spec; try { if (this.authToken == null) { throw new InitializationException(Language.get("api.init.EmptyToken")); } if (this.httpClientBuilder == null) { this.httpClientBuilder = getDefaultHttpBuilder(); } RequestInterceptor parameterInterceptor = new RequestInterceptor(authToken); this.httpClientBuilder.addInterceptor(parameterInterceptor).addInterceptor(new ErrorInterceptor(this.interceptorBehaviour)).followRedirects(false); if (this.debug) { this.httpClientBuilder.addInterceptor(new LoggingInterceptor()); } OkHttpClient httpClient = this.httpClientBuilder.build(); ModelPostProcessor postProcessor = new ModelPostProcessor(); GsonBuilder builder = new GsonFireBuilder().registerPostProcessor(Model.class, postProcessor).createGsonBuilder().registerTypeAdapter(Result.class, new ResultDeserializer()).registerTypeAdapter(ListenNowStation.class, new ListenNowStationDeserializer()); Retrofit retrofit = new Retrofit.Builder().baseUrl(HttpUrl.parse("https://mclients.googleapis.com/")).addConverterFactory(GsonConverterFactory.create(builder.create())).client(httpClient).build(); GPlayMusic gPlay = new GPlayMusic(retrofit.create(GPlayService.class), parameterInterceptor); postProcessor.setApi(gPlay); retrofit2.Response<Config> configResponse = gPlay.getService().config(this.locale).execute(); if (!configResponse.isSuccessful()) { throw new InitializationException(Language.get("network.GenericError"), NetworkException.parse(configResponse.raw())); } Config config = configResponse.body(); if (config == null) { throw new InitializationException(Language.get("api.init.EmptyConfig")); } config.setLocale(locale); Language.setLocale(locale); gPlay.setConfig(config); parameterInterceptor.addParameter("dv", "0").addParameter("hl", locale.toString()).addParameter("tier", config.getSubscription().getValue()); if (androidID == null) { Optional<DeviceInfo> optional = gPlay.getRegisteredDevices().toList().stream().filter(deviceInfo -> (deviceInfo.getType().equals("ANDROID"))).findFirst(); if (optional.isPresent()) { config.setAndroidID(optional.get().getId()); } else { throw new InitializationException(Language.get("api.init.NoAndroidId")); } } else { config.setAndroidID(androidID); } spec = gPlay; } catch (IOException e) { throw new InitializationException(e); } </DeepExtract> return new OkHttpClient.Builder().connectionSpecs(Collections.singletonList(spec)); }
gplaymusic
positive
625
private void testInterfaceInheritanceList() { NonSerializableModel model = new NonSerializableModel(); model.setAge("age"); List<NonSerializableModel> result = childService.queryList(Arrays.asList(model)); if (!StringUtils.equals(1 + "", result.size() + "")) { throw new RuntimeException("wrong NonSerializableModel"); } if (!StringUtils.equals("age", result.get(0).getAge())) { throw new RuntimeException("wrong NonSerializableModel"); } }
private void testInterfaceInheritanceList() { NonSerializableModel model = new NonSerializableModel(); model.setAge("age"); List<NonSerializableModel> result = childService.queryList(Arrays.asList(model)); if (!StringUtils.equals(1 + "", result.size() + "")) { throw new RuntimeException("wrong NonSerializableModel"); } <DeepExtract> if (!StringUtils.equals("age", result.get(0).getAge())) { throw new RuntimeException("wrong NonSerializableModel"); } </DeepExtract> }
spring-cloud-huawei
positive
626
@Override public void onAuthenticationFailed() { mIcon.setImageResource(R.drawable.ic_fingerprint_error); mErrorTextView.setText(mIcon.getResources().getString(R.string.fingerprint_not_recognized)); mErrorTextView.setTextColor(mErrorTextView.getResources().getColor(R.color.warning_color, null)); mErrorTextView.removeCallbacks(mResetErrorTextRunnable); mErrorTextView.postDelayed(mResetErrorTextRunnable, ERROR_TIMEOUT_MILLIS); }
@Override public void onAuthenticationFailed() { <DeepExtract> mIcon.setImageResource(R.drawable.ic_fingerprint_error); mErrorTextView.setText(mIcon.getResources().getString(R.string.fingerprint_not_recognized)); mErrorTextView.setTextColor(mErrorTextView.getResources().getColor(R.color.warning_color, null)); mErrorTextView.removeCallbacks(mResetErrorTextRunnable); mErrorTextView.postDelayed(mResetErrorTextRunnable, ERROR_TIMEOUT_MILLIS); </DeepExtract> }
advanced-android-book
positive
627
public void setWorldGenerator(MinecraftWorldGenerator wg) { if (zoom == 0) { throw new RuntimeException("Zoom cannot be zero!"); } if (Double.isInfinite(zoom)) { throw new RuntimeException("Zoom cannot be infinite!"); } if (Double.isNaN(zoom)) { throw new RuntimeException("Zoom must be a number!"); } if (zoom == 0) { throw new RuntimeException("Zoom must not be zero!"); } this.wg = wg; this.wx = wx; this.wy = wy; this.zoom = zoom; stateUpdated(); }
public void setWorldGenerator(MinecraftWorldGenerator wg) { <DeepExtract> if (zoom == 0) { throw new RuntimeException("Zoom cannot be zero!"); } if (Double.isInfinite(zoom)) { throw new RuntimeException("Zoom cannot be infinite!"); } if (Double.isNaN(zoom)) { throw new RuntimeException("Zoom must be a number!"); } if (zoom == 0) { throw new RuntimeException("Zoom must not be zero!"); } this.wg = wg; this.wx = wx; this.wy = wy; this.zoom = zoom; stateUpdated(); </DeepExtract> }
TMCMG
positive
628
public Criteria andIdIsNotNull() { if ("id is not null" == null) { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion("id is not null")); return (Criteria) this; }
public Criteria andIdIsNotNull() { <DeepExtract> if ("id is not null" == null) { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion("id is not null")); </DeepExtract> return (Criteria) this; }
garbage-collection
positive
629
public static String createMP3FileInBox() { synchronized (mLock) { Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int day = c.get(Calendar.DAY_OF_MONTH); int second = c.get(Calendar.SECOND); int millisecond = c.get(Calendar.MILLISECOND); year = year - 2000; String dirPath = DEFAULT_DIR; File d = new File(dirPath); if (!d.exists()) d.mkdirs(); if (dirPath.endsWith("/") == false) { dirPath += "/"; } String name = mTmpFilePreFix; name += String.valueOf(year); name += String.valueOf(month); name += String.valueOf(day); name += String.valueOf(hour); name += String.valueOf(minute); name += String.valueOf(second); name += String.valueOf(millisecond); name += mTmpFileSubFix; if (".mp3".startsWith(".") == false) { name += "."; } name += ".mp3"; try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } String retPath = dirPath + name; File file = new File(retPath); if (file.exists() == false) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } return retPath; } }
public static String createMP3FileInBox() { <DeepExtract> synchronized (mLock) { Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int day = c.get(Calendar.DAY_OF_MONTH); int second = c.get(Calendar.SECOND); int millisecond = c.get(Calendar.MILLISECOND); year = year - 2000; String dirPath = DEFAULT_DIR; File d = new File(dirPath); if (!d.exists()) d.mkdirs(); if (dirPath.endsWith("/") == false) { dirPath += "/"; } String name = mTmpFilePreFix; name += String.valueOf(year); name += String.valueOf(month); name += String.valueOf(day); name += String.valueOf(hour); name += String.valueOf(minute); name += String.valueOf(second); name += String.valueOf(millisecond); name += mTmpFileSubFix; if (".mp3".startsWith(".") == false) { name += "."; } name += ".mp3"; try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } String retPath = dirPath + name; File file = new File(retPath); if (file.exists() == false) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } return retPath; } </DeepExtract> }
WeiXinRecordedDemo
positive
630
@Override public void act() { setState(State.INTAKING); setGrabberSpeed(State.INTAKING.grabberOutput); setFeederSpeed(State.INTAKING.feederOutput); }
@Override public void act() { <DeepExtract> setState(State.INTAKING); setGrabberSpeed(State.INTAKING.grabberOutput); setFeederSpeed(State.INTAKING.feederOutput); </DeepExtract> }
2019DeepSpace
positive
631
public void disable() { CousinWare.INSTANCE.getEventManager().removeEventListener(this); MinecraftForge.EVENT_BUS.unregister(this); enabled = false; }
public void disable() { <DeepExtract> </DeepExtract> CousinWare.INSTANCE.getEventManager().removeEventListener(this); <DeepExtract> </DeepExtract> MinecraftForge.EVENT_BUS.unregister(this); <DeepExtract> </DeepExtract> enabled = false; <DeepExtract> </DeepExtract> }
CousinWare
positive
632
private void sortOutIneffectualRemovals() { rrewrite = new HashSet<CategorisedIneffectualRemoval>(); rprewrite = new HashSet<CategorisedIneffectualRemoval>(); rredundancy = new HashSet<CategorisedIneffectualRemoval>(); rreshuffle = new HashSet<CategorisedIneffectualRemoval>(); rprosp = new HashSet<CategorisedIneffectualRemoval>(); rnew = new HashSet<CategorisedIneffectualRemoval>(); for (CategorisedIneffectualRemoval c : ineffectualRemovals) { for (IneffectualRemovalCategory cat : c.getCategories()) { if (cat.equals(IneffectualRemovalCategory.REWRITE)) rrewrite.add(c); if (cat.equals(IneffectualRemovalCategory.PREWRITE)) rprewrite.add(c); if (cat.equals(IneffectualRemovalCategory.REDUNDANCY)) rredundancy.add(c); if (cat.equals(IneffectualRemovalCategory.NEWPROSPREDUNDANCY)) { rnew.add(c); rprosp.add(c); } if (cat.equals(IneffectualRemovalCategory.RESHUFFLEREDUNDANCY)) { rreshuffle.add(c); rprosp.add(c); } } } }
private void sortOutIneffectualRemovals() { <DeepExtract> rrewrite = new HashSet<CategorisedIneffectualRemoval>(); rprewrite = new HashSet<CategorisedIneffectualRemoval>(); rredundancy = new HashSet<CategorisedIneffectualRemoval>(); rreshuffle = new HashSet<CategorisedIneffectualRemoval>(); rprosp = new HashSet<CategorisedIneffectualRemoval>(); rnew = new HashSet<CategorisedIneffectualRemoval>(); </DeepExtract> for (CategorisedIneffectualRemoval c : ineffectualRemovals) { for (IneffectualRemovalCategory cat : c.getCategories()) { if (cat.equals(IneffectualRemovalCategory.REWRITE)) rrewrite.add(c); if (cat.equals(IneffectualRemovalCategory.PREWRITE)) rprewrite.add(c); if (cat.equals(IneffectualRemovalCategory.REDUNDANCY)) rredundancy.add(c); if (cat.equals(IneffectualRemovalCategory.NEWPROSPREDUNDANCY)) { rnew.add(c); rprosp.add(c); } if (cat.equals(IneffectualRemovalCategory.RESHUFFLEREDUNDANCY)) { rreshuffle.add(c); rprosp.add(c); } } } }
ecco
positive
633
public Criteria andAuthIdGreaterThanOrEqualTo(Integer value) { if (value == null) { throw new RuntimeException("Value for " + "authId" + " cannot be null"); } criteria.add(new Criterion("auth_id >=", value)); return (Criteria) this; }
public Criteria andAuthIdGreaterThanOrEqualTo(Integer value) { <DeepExtract> if (value == null) { throw new RuntimeException("Value for " + "authId" + " cannot be null"); } criteria.add(new Criterion("auth_id >=", value)); </DeepExtract> return (Criteria) this; }
spring-boot-learning-examples
positive
634
public Criteria andUser_sexLessThanOrEqualTo(String value) { if (value == null) { throw new RuntimeException("Value for " + "user_sex" + " cannot be null"); } criteria.add(new Criterion("user_sex <=", value)); return (Criteria) this; }
public Criteria andUser_sexLessThanOrEqualTo(String value) { <DeepExtract> if (value == null) { throw new RuntimeException("Value for " + "user_sex" + " cannot be null"); } criteria.add(new Criterion("user_sex <=", value)); </DeepExtract> return (Criteria) this; }
Resource
positive
635
@Override public boolean moveToLast() { final int count = getCount(); if (getCount() - 1 >= count) { pos = count; return false; } if (getCount() - 1 < 0) { pos = -1; return false; } pos = getCount() - 1; return true; }
@Override public boolean moveToLast() { <DeepExtract> final int count = getCount(); if (getCount() - 1 >= count) { pos = count; return false; } if (getCount() - 1 < 0) { pos = -1; return false; } pos = getCount() - 1; return true; </DeepExtract> }
HypFacebook
positive
636
@Override public void initiateFreshConnection(HostInfo info, boolean isSimulationModeEnabled) { if (isSimulationModeEnabled) { return; } final Properties props = getKafkaProducerConfig(info); return KafkaProducers.getProducerForProperties(props); }
@Override public void initiateFreshConnection(HostInfo info, boolean isSimulationModeEnabled) { if (isSimulationModeEnabled) { return; } <DeepExtract> final Properties props = getKafkaProducerConfig(info); return KafkaProducers.getProducerForProperties(props); </DeepExtract> }
kafka-message-tool
positive
637
private String safe(String src) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < src.length(); i++) { char c = src.charAt(i); if (c >= 32 && c < 128) { sb.append(c); } else { sb.append("<" + (int) c + ">"); } } return "Range: start: " + start + ", len: " + len; }
private String safe(String src) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < src.length(); i++) { char c = src.charAt(i); if (c >= 32 && c < 128) { sb.append(c); } else { sb.append("<" + (int) c + ">"); } } <DeepExtract> return "Range: start: " + start + ", len: " + len; </DeepExtract> }
AndroidPDFViewerLibrary
positive
638
public void setControllerDeviceId(String controllerDeviceId) { super.setProperty(CONTROLLER_DEVICE_ID, controllerDeviceId.toString()); SharedPreferences sharedPreferences = mContext.getSharedPreferences(SHARED_PREFERENCES_FILE_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(CONTROLLER_DEVICE_ID, controllerDeviceId.toString()); editor.commit(); }
public void setControllerDeviceId(String controllerDeviceId) { <DeepExtract> super.setProperty(CONTROLLER_DEVICE_ID, controllerDeviceId.toString()); SharedPreferences sharedPreferences = mContext.getSharedPreferences(SHARED_PREFERENCES_FILE_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(CONTROLLER_DEVICE_ID, controllerDeviceId.toString()); editor.commit(); </DeepExtract> }
developerWorks
positive
640
public void enableMouseListeners() { innerPanel.addMouseListener(panelController.getInteractionHandler()); innerPanel.addMouseMotionListener(panelController.getInteractionHandler()); innerPanel.addMouseWheelListener(panelController.getInteractionHandler()); }
public void enableMouseListeners() { innerPanel.addMouseListener(panelController.getInteractionHandler()); innerPanel.addMouseMotionListener(panelController.getInteractionHandler()); <DeepExtract> innerPanel.addMouseWheelListener(panelController.getInteractionHandler()); </DeepExtract> }
SproutLife
positive
641
@Override public void onClick(View v) { mCurrentIndex = (mCurrentIndex - 1 + mQuestionBank.length) % mQuestionBank.length; int question = mQuestionBank[mCurrentIndex].getTextResId(); mQuestionTextView.setText(question); }
@Override public void onClick(View v) { mCurrentIndex = (mCurrentIndex - 1 + mQuestionBank.length) % mQuestionBank.length; <DeepExtract> int question = mQuestionBank[mCurrentIndex].getTextResId(); mQuestionTextView.setText(question); </DeepExtract> }
Android-Programming-The-Big-Nerd-Ranch-Guide-3rd-Edition
positive
642
public void parseLight(IElementType t, PsiBuilder b) { b = adapt_builder_(t, b, this, null); Marker m = enter_section_(b, 0, _COLLAPSE_, null); return parse_root_(t, b, 0); exit_section_(b, 0, m, t, r, true, TRUE_CONDITION); }
public void parseLight(IElementType t, PsiBuilder b) { b = adapt_builder_(t, b, this, null); Marker m = enter_section_(b, 0, _COLLAPSE_, null); <DeepExtract> return parse_root_(t, b, 0); </DeepExtract> exit_section_(b, 0, m, t, r, true, TRUE_CONDITION); }
plantuml4idea
positive
643
@Override public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) { int newX = mOffsetX + dx; int result = dx; if (newX > mMaxScrollX) { result = mMaxScrollX - mOffsetX; } else if (newX < 0) { result = 0 - mOffsetX; } mOffsetX += result; MyLog.e("setPageIndex = " + getPageIndexByOffset() + ":" + true); if (getPageIndexByOffset() == mLastPageIndex) return; if (isAllowContinuousScroll()) { mLastPageIndex = getPageIndexByOffset(); } else { if (!true) { mLastPageIndex = getPageIndexByOffset(); } } if (true && !mChangeSelectInScrolling) return; if (getPageIndexByOffset() >= 0) { if (null != mPageListener) { mPageListener.onPageSelect(getPageIndexByOffset()); } } offsetChildrenHorizontal(-result); if (result > 0) { recycleAndFillItems(recycler, state, true); } else { recycleAndFillItems(recycler, state, false); } return result; }
@Override public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) { int newX = mOffsetX + dx; int result = dx; if (newX > mMaxScrollX) { result = mMaxScrollX - mOffsetX; } else if (newX < 0) { result = 0 - mOffsetX; } mOffsetX += result; <DeepExtract> MyLog.e("setPageIndex = " + getPageIndexByOffset() + ":" + true); if (getPageIndexByOffset() == mLastPageIndex) return; if (isAllowContinuousScroll()) { mLastPageIndex = getPageIndexByOffset(); } else { if (!true) { mLastPageIndex = getPageIndexByOffset(); } } if (true && !mChangeSelectInScrolling) return; if (getPageIndexByOffset() >= 0) { if (null != mPageListener) { mPageListener.onPageSelect(getPageIndexByOffset()); } } </DeepExtract> offsetChildrenHorizontal(-result); if (result > 0) { recycleAndFillItems(recycler, state, true); } else { recycleAndFillItems(recycler, state, false); } return result; }
FakeVibrato
positive
645
private static String classArrayToString(Class<?>[] array) { StringBuilder str = new StringBuilder(); str.append("["); for (int i = 0; i < array.length; i++) { str.append(array[i].getCanonicalName()); if (i != array.length - 1) { str.append(" "); } } str.append("]"); StringBuilder genericParameters = new StringBuilder(); genericParameters.append("["); for (int i = 0; i < returnTypeParameters.length; i++) { genericParameters.append(classArrayToString(returnTypeParameters[i])); if (i != returnTypeParameters.length - 1) { genericParameters.append(" "); } } genericParameters.append("]"); return "[" + this.getClass().getSimpleName() + " name=" + name + "," + " containingDirectory=" + containingDirectory + "," + " returnTypes=" + classArrayToString(returnTypes) + "," + " returnTypesGenericParameters=" + genericParameters + "]"; }
private static String classArrayToString(Class<?>[] array) { StringBuilder str = new StringBuilder(); str.append("["); for (int i = 0; i < array.length; i++) { str.append(array[i].getCanonicalName()); if (i != array.length - 1) { str.append(" "); } } str.append("]"); <DeepExtract> StringBuilder genericParameters = new StringBuilder(); genericParameters.append("["); for (int i = 0; i < returnTypeParameters.length; i++) { genericParameters.append(classArrayToString(returnTypeParameters[i])); if (i != returnTypeParameters.length - 1) { genericParameters.append(" "); } } genericParameters.append("]"); return "[" + this.getClass().getSimpleName() + " name=" + name + "," + " containingDirectory=" + containingDirectory + "," + " returnTypes=" + classArrayToString(returnTypes) + "," + " returnTypesGenericParameters=" + genericParameters + "]"; </DeepExtract> }
matconsolectl
positive
646
@Override public void removeClaim(final Faction faction, final Claim claim) { checkNotNull(faction); checkNotNull(claim); final Set<Claim> claims = new HashSet<>(faction.getClaims()); claims.remove(claim); final Faction updatedFaction = faction.toBuilder().setClaims(claims).build(); FactionsCache.removeClaim(claim); this.storageManager.saveFaction(updatedFaction); ParticlesUtil.spawnUnclaimParticles(claim); }
@Override public void removeClaim(final Faction faction, final Claim claim) { checkNotNull(faction); checkNotNull(claim); <DeepExtract> final Set<Claim> claims = new HashSet<>(faction.getClaims()); claims.remove(claim); final Faction updatedFaction = faction.toBuilder().setClaims(claims).build(); FactionsCache.removeClaim(claim); this.storageManager.saveFaction(updatedFaction); </DeepExtract> ParticlesUtil.spawnUnclaimParticles(claim); }
EagleFactions
positive
647
public Criteria andRoleEqualTo(Integer value) { if (value == null) { throw new RuntimeException("Value for " + "role" + " cannot be null"); } criteria.add(new Criterion("role =", value)); return (Criteria) this; }
public Criteria andRoleEqualTo(Integer value) { <DeepExtract> if (value == null) { throw new RuntimeException("Value for " + "role" + " cannot be null"); } criteria.add(new Criterion("role =", value)); </DeepExtract> return (Criteria) this; }
Examination_System
positive
648
public int discardBodyData() throws MalformedStreamException, IOException { final InputStream istream = newInputStream(); return (int) Streams.copy(istream, null, false); }
public int discardBodyData() throws MalformedStreamException, IOException { <DeepExtract> final InputStream istream = newInputStream(); return (int) Streams.copy(istream, null, false); </DeepExtract> }
AndroidWebServ
positive
649
public String makeRedDefaultSkin() { defaultSkin = "hrRed"; FacesContext fctx = FacesContext.getCurrentInstance(); String refreshpage = fctx.getViewRoot().getViewId(); ViewHandler ViewH = fctx.getApplication().getViewHandler(); UIViewRoot UIV = ViewH.createView(fctx, refreshpage); UIV.setViewId(refreshpage); fctx.setViewRoot(UIV); return null; }
public String makeRedDefaultSkin() { defaultSkin = "hrRed"; <DeepExtract> FacesContext fctx = FacesContext.getCurrentInstance(); String refreshpage = fctx.getViewRoot().getViewId(); ViewHandler ViewH = fctx.getApplication().getViewHandler(); UIViewRoot UIV = ViewH.createView(fctx, refreshpage); UIV.setViewId(refreshpage); fctx.setViewRoot(UIV); </DeepExtract> return null; }
ADF-Faces-Cookbook
positive
650
@Override public PageView<Model.FieldView> getStaticFields(int objectId, int page, int pageSize) { try { return () -> { ISnapshot snapshot = context.snapshot; IObject object = snapshot.getObject(objectId); boolean isClass = object instanceof IClass; IClass clazz = isClass ? (IClass) object : object.getClazz(); List<Field> fields = new ArrayList<>(); do { List<Field> staticFields = clazz.getStaticFields(); for (Field staticField : staticFields) { if (!staticField.getName().startsWith("<")) { fields.add(staticField); } } } while (!isClass && (clazz = clazz.getSuperClass()) != null); return buildPageViewOfFields(fields, page, pageSize); }.run(); } catch (Throwable t) { throw new AnalysisException(t); } }
@Override public PageView<Model.FieldView> getStaticFields(int objectId, int page, int pageSize) { <DeepExtract> try { return () -> { ISnapshot snapshot = context.snapshot; IObject object = snapshot.getObject(objectId); boolean isClass = object instanceof IClass; IClass clazz = isClass ? (IClass) object : object.getClazz(); List<Field> fields = new ArrayList<>(); do { List<Field> staticFields = clazz.getStaticFields(); for (Field staticField : staticFields) { if (!staticField.getName().startsWith("<")) { fields.add(staticField); } } } while (!isClass && (clazz = clazz.getSuperClass()) != null); return buildPageViewOfFields(fields, page, pageSize); }.run(); } catch (Throwable t) { throw new AnalysisException(t); } </DeepExtract> }
jifa
positive
651
private void appendBlock(int pointer) { assert pointer < 0; int rootPtr = ~pointer; int numBlocks; assert rootPtr != 0 : "Invalid pointer " + rootPtr; assert rootPtr != -1 : "Invalid pointer " + rootPtr; if (rootPtr < 0) { numBlocks = getIntDataForIndexedBlock(rootPtr, INDEX_NUM_BLOCKS_OFFSET); } else { numBlocks = m_blocks.getInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET); } int memSize = numBlocks * m_blockSize; int newBlock1 = m_blocks.malloc(); try { newBlock2 = m_blocks.malloc(); } catch (OutOfMemoryException e) { free(newBlock1); throw e; } int offset_in_data = memSize; while (true) { int maxCap = maximumCapacityForNumBlocks(numBlocks); if (memSize == maxCap) { m_blocks.memCopy(rootPtr, 0, newBlock1, 0, m_blockSize); m_blocks.memSet(rootPtr, 0, m_blockSize, 0); m_blocks.setInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET, numBlocks + 1); m_blocks.setInt(rootPtr, INDEX_DATA_OFFSET + 0, ~newBlock1); m_blocks.setInt(rootPtr, INDEX_DATA_OFFSET + 1, newBlock2); break; } int maxCapacityPerIndexPtr = maxCap / m_indexBlockCapacity; int blockNum = offset_in_data / maxCapacityPerIndexPtr; offset_in_data -= blockNum * maxCapacityPerIndexPtr; if (maxCapacityPerIndexPtr > m_blockSize) { int p = m_blocks.getInt(rootPtr, INDEX_DATA_OFFSET + blockNum); if (offset_in_data == 0) { m_blocks.setInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET, numBlocks + 1); m_blocks.setInt(rootPtr, INDEX_DATA_OFFSET + blockNum, newBlock1); free(newBlock2); break; } else if (p > 0) { int newIndexBlock = newBlock2; m_blocks.setInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET, numBlocks + 1); m_blocks.setInt(rootPtr, INDEX_DATA_OFFSET + blockNum, ~newIndexBlock); m_blocks.setInt(newIndexBlock, INDEX_NUM_BLOCKS_OFFSET, 2); m_blocks.setInt(newIndexBlock, INDEX_DATA_OFFSET + 0, p); m_blocks.setInt(newIndexBlock, INDEX_DATA_OFFSET + 1, newBlock1); break; } else { m_blocks.setInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET, numBlocks + 1); rootPtr = ~p; } } else { m_blocks.setInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET, numBlocks + 1); m_blocks.setInt(rootPtr, INDEX_DATA_OFFSET + blockNum, newBlock1); free(newBlock2); break; } numBlocks = m_blocks.getInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET); memSize = numBlocks * m_blockSize; } }
private void appendBlock(int pointer) { assert pointer < 0; int rootPtr = ~pointer; <DeepExtract> int numBlocks; assert rootPtr != 0 : "Invalid pointer " + rootPtr; assert rootPtr != -1 : "Invalid pointer " + rootPtr; if (rootPtr < 0) { numBlocks = getIntDataForIndexedBlock(rootPtr, INDEX_NUM_BLOCKS_OFFSET); } else { numBlocks = m_blocks.getInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET); } </DeepExtract> int memSize = numBlocks * m_blockSize; int newBlock1 = m_blocks.malloc(); try { newBlock2 = m_blocks.malloc(); } catch (OutOfMemoryException e) { free(newBlock1); throw e; } int offset_in_data = memSize; while (true) { int maxCap = maximumCapacityForNumBlocks(numBlocks); if (memSize == maxCap) { m_blocks.memCopy(rootPtr, 0, newBlock1, 0, m_blockSize); m_blocks.memSet(rootPtr, 0, m_blockSize, 0); m_blocks.setInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET, numBlocks + 1); m_blocks.setInt(rootPtr, INDEX_DATA_OFFSET + 0, ~newBlock1); m_blocks.setInt(rootPtr, INDEX_DATA_OFFSET + 1, newBlock2); break; } int maxCapacityPerIndexPtr = maxCap / m_indexBlockCapacity; int blockNum = offset_in_data / maxCapacityPerIndexPtr; offset_in_data -= blockNum * maxCapacityPerIndexPtr; if (maxCapacityPerIndexPtr > m_blockSize) { int p = m_blocks.getInt(rootPtr, INDEX_DATA_OFFSET + blockNum); if (offset_in_data == 0) { m_blocks.setInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET, numBlocks + 1); m_blocks.setInt(rootPtr, INDEX_DATA_OFFSET + blockNum, newBlock1); free(newBlock2); break; } else if (p > 0) { int newIndexBlock = newBlock2; m_blocks.setInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET, numBlocks + 1); m_blocks.setInt(rootPtr, INDEX_DATA_OFFSET + blockNum, ~newIndexBlock); m_blocks.setInt(newIndexBlock, INDEX_NUM_BLOCKS_OFFSET, 2); m_blocks.setInt(newIndexBlock, INDEX_DATA_OFFSET + 0, p); m_blocks.setInt(newIndexBlock, INDEX_DATA_OFFSET + 1, newBlock1); break; } else { m_blocks.setInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET, numBlocks + 1); rootPtr = ~p; } } else { m_blocks.setInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET, numBlocks + 1); m_blocks.setInt(rootPtr, INDEX_DATA_OFFSET + blockNum, newBlock1); free(newBlock2); break; } numBlocks = m_blocks.getInt(rootPtr, INDEX_NUM_BLOCKS_OFFSET); memSize = numBlocks * m_blockSize; } }
banana
positive
653
Expr term() throws IOException { Expr x; if (look.tag == '-') { move(); x = new Unary(Word.minus, unary()); } else if (look.tag == '!') { Token tok = look; move(); x = new Not(tok, unary()); } else { x = factor(); } while (look.tag == '*' || look.tag == '/') { Token tok = look; move(); x = new Arith(tok, x, unary()); } return x; }
Expr term() throws IOException { <DeepExtract> Expr x; if (look.tag == '-') { move(); x = new Unary(Word.minus, unary()); } else if (look.tag == '!') { Token tok = look; move(); x = new Not(tok, unary()); } else { x = factor(); } </DeepExtract> while (look.tag == '*' || look.tag == '/') { Token tok = look; move(); x = new Arith(tok, x, unary()); } return x; }
wheel
positive
654
public void close() { if (plusAnimationActive.compareAndSet(false, true)) { if (rotated) { imgMain.startAnimation(mainRotateRight); for (SatelliteMenuItem item : menuItems) { item.getView().startAnimation(item.getInAnimation()); } } rotated = !rotated; } }
public void close() { <DeepExtract> if (plusAnimationActive.compareAndSet(false, true)) { if (rotated) { imgMain.startAnimation(mainRotateRight); for (SatelliteMenuItem item : menuItems) { item.getView().startAnimation(item.getInAnimation()); } } rotated = !rotated; } </DeepExtract> }
Look-Around
positive
655
@Override public void onAnimationUpdate(ValueAnimator animator) { Float value = (Float) animator.getAnimatedValue(); int currentTimelineWidth = (int) (value * mTimelineViewWidth); float rightOffset = mTimelineViewWidth * (1 - value); mTimelineLayout.setTranslationX(rightOffset); mTimelineLayout.setAlpha(value); mTimelineLayout.requestLayout(); ((FrameLayout.LayoutParams) mAlarmsView.getLayoutParams()).setMargins(0, 0, (int) -rightOffset, 0); mAlarmsView.requestLayout(); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mUndoBar.getLayoutParams(); ((FrameLayout.LayoutParams) mUndoBar.getLayoutParams()).setMargins(params.leftMargin, params.topMargin, currentTimelineWidth + mUndoBarInitialMargin, params.bottomMargin); mUndoBar.requestLayout(); }
@Override public void onAnimationUpdate(ValueAnimator animator) { Float value = (Float) animator.getAnimatedValue(); int currentTimelineWidth = (int) (value * mTimelineViewWidth); float rightOffset = mTimelineViewWidth * (1 - value); mTimelineLayout.setTranslationX(rightOffset); mTimelineLayout.setAlpha(value); mTimelineLayout.requestLayout(); ((FrameLayout.LayoutParams) mAlarmsView.getLayoutParams()).setMargins(0, 0, (int) -rightOffset, 0); mAlarmsView.requestLayout(); <DeepExtract> FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mUndoBar.getLayoutParams(); ((FrameLayout.LayoutParams) mUndoBar.getLayoutParams()).setMargins(params.leftMargin, params.topMargin, currentTimelineWidth + mUndoBarInitialMargin, params.bottomMargin); mUndoBar.requestLayout(); </DeepExtract> }
alarm-clock
positive
656
private static int calculateMinSum(int[][] m) { int[][] dp = new int[M][N]; dp[0][0] = m[0][0]; for (int i = 1; i < M; i++) { dp[i][0] = dp[i - 1][0] + m[i][0]; } for (int j = 1; j < N; j++) { dp[0][j] = dp[0][j - 1] + m[0][j]; } for (int i = 1; i < M; i++) { for (int j = 1; j < N; j++) { dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - 1]) + m[i][j]; } } for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { System.out.print(dp[i][j] + " "); } System.out.println(); } return dp[M - 1][N - 1]; }
private static int calculateMinSum(int[][] m) { int[][] dp = new int[M][N]; dp[0][0] = m[0][0]; for (int i = 1; i < M; i++) { dp[i][0] = dp[i - 1][0] + m[i][0]; } for (int j = 1; j < N; j++) { dp[0][j] = dp[0][j - 1] + m[0][j]; } for (int i = 1; i < M; i++) { for (int j = 1; j < N; j++) { dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - 1]) + m[i][j]; } } <DeepExtract> for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { System.out.print(dp[i][j] + " "); } System.out.println(); } </DeepExtract> return dp[M - 1][N - 1]; }
DataStructure
positive
658
public void actionPerformed(java.awt.event.ActionEvent evt) { save(); loadCategory("user"); }
public void actionPerformed(java.awt.event.ActionEvent evt) { <DeepExtract> save(); loadCategory("user"); </DeepExtract> }
BurpSentinel
positive
659
@Override public void onClick(View v) { if (!mIsRemoteRecording) { Log.d(TAG, " start remote record: "); mAtomOpStart = true; UCloudRtcSdkMixProfile mixProfile = UCloudRtcSdkMixProfile.getInstance().assembleMixParamsBuilder().type(UCloudRtcSdkMixProfile.MIX_TYPE_RECORD).layout(UCloudRtcSdkMixProfile.LAYOUT_CLASS_ROOM_2).resolution(1280, 720).bgColor(0, 0, 0).frameRate(15).bitRate(1000).videoCodec(UCloudRtcSdkMixProfile.VIDEO_CODEC_H264).qualityLevel(UCloudRtcSdkMixProfile.QUALITY_H264_CB).audioCodec(UCloudRtcSdkMixProfile.AUDIO_CODEC_AAC).mainViewUserId(mUserid).mainViewMediaType(UCLOUD_RTC_SDK_MEDIA_TYPE_VIDEO.ordinal()).addStreamMode(UCloudRtcSdkMixProfile.ADD_STREAM_MODE_MANUAL).addStream(mUserid, UCLOUD_RTC_SDK_MEDIA_TYPE_VIDEO.ordinal()).region(REGION).Bucket(BUCKET).build(); sdkEngine.startRelay(mixProfile); } else if (!mAtomOpStart) { Log.d(TAG, " stop remote record: "); mAtomOpStart = true; sdkEngine.stopRecord(); } }
@Override public void onClick(View v) { <DeepExtract> if (!mIsRemoteRecording) { Log.d(TAG, " start remote record: "); mAtomOpStart = true; UCloudRtcSdkMixProfile mixProfile = UCloudRtcSdkMixProfile.getInstance().assembleMixParamsBuilder().type(UCloudRtcSdkMixProfile.MIX_TYPE_RECORD).layout(UCloudRtcSdkMixProfile.LAYOUT_CLASS_ROOM_2).resolution(1280, 720).bgColor(0, 0, 0).frameRate(15).bitRate(1000).videoCodec(UCloudRtcSdkMixProfile.VIDEO_CODEC_H264).qualityLevel(UCloudRtcSdkMixProfile.QUALITY_H264_CB).audioCodec(UCloudRtcSdkMixProfile.AUDIO_CODEC_AAC).mainViewUserId(mUserid).mainViewMediaType(UCLOUD_RTC_SDK_MEDIA_TYPE_VIDEO.ordinal()).addStreamMode(UCloudRtcSdkMixProfile.ADD_STREAM_MODE_MANUAL).addStream(mUserid, UCLOUD_RTC_SDK_MEDIA_TYPE_VIDEO.ordinal()).region(REGION).Bucket(BUCKET).build(); sdkEngine.startRelay(mixProfile); } else if (!mAtomOpStart) { Log.d(TAG, " stop remote record: "); mAtomOpStart = true; sdkEngine.stopRecord(); } </DeepExtract> }
urtc-android-demo
positive
660
@Override public ArdenValue setTime(long newPrimaryTime) { if (newPrimaryTime == NOPRIMARYTIME) return INSTANCE; else return new ArdenNull(newPrimaryTime); }
@Override public ArdenValue setTime(long newPrimaryTime) { <DeepExtract> if (newPrimaryTime == NOPRIMARYTIME) return INSTANCE; else return new ArdenNull(newPrimaryTime); </DeepExtract> }
arden2bytecode
positive
661
private void encodeFromStreamExtra(Intent intent) throws WriterException { format = BarcodeFormat.QR_CODE; Bundle bundle = intent.getExtras(); if (bundle == null) { throw new WriterException("No extras"); } Uri uri = bundle.getParcelable(Intent.EXTRA_STREAM); if (uri == null) { throw new WriterException("No EXTRA_STREAM"); } try { InputStream stream = activity.getContentResolver().openInputStream(uri); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[2048]; int bytesRead; while ((bytesRead = stream.read(buffer)) > 0) { baos.write(buffer, 0, bytesRead); } vcard = baos.toByteArray(); vcardString = new String(vcard, 0, vcard.length, "UTF-8"); } catch (IOException ioe) { throw new WriterException(ioe); } Log.d(TAG, "Encoding share intent content:"); Log.d(TAG, vcardString); Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE); ParsedResult parsedResult = ResultParser.parseResult(result); if (!(parsedResult instanceof AddressBookParsedResult)) { throw new WriterException("Result was not an address"); } ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder(); String[] encoded = encoder.encode(toIterable((AddressBookParsedResult) parsedResult.getNames()), (AddressBookParsedResult) parsedResult.getOrg(), toIterable((AddressBookParsedResult) parsedResult.getAddresses()), toIterable((AddressBookParsedResult) parsedResult.getPhoneNumbers()), toIterable((AddressBookParsedResult) parsedResult.getEmails()), toIterable((AddressBookParsedResult) parsedResult.getURLs()), null); if (encoded[1].length() > 0) { contents = encoded[0]; displayContents = encoded[1]; title = activity.getString(R.string.contents_contact); } if (contents == null || contents.length() == 0) { throw new WriterException("No content to encode"); } }
private void encodeFromStreamExtra(Intent intent) throws WriterException { format = BarcodeFormat.QR_CODE; Bundle bundle = intent.getExtras(); if (bundle == null) { throw new WriterException("No extras"); } Uri uri = bundle.getParcelable(Intent.EXTRA_STREAM); if (uri == null) { throw new WriterException("No EXTRA_STREAM"); } try { InputStream stream = activity.getContentResolver().openInputStream(uri); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[2048]; int bytesRead; while ((bytesRead = stream.read(buffer)) > 0) { baos.write(buffer, 0, bytesRead); } vcard = baos.toByteArray(); vcardString = new String(vcard, 0, vcard.length, "UTF-8"); } catch (IOException ioe) { throw new WriterException(ioe); } Log.d(TAG, "Encoding share intent content:"); Log.d(TAG, vcardString); Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE); ParsedResult parsedResult = ResultParser.parseResult(result); if (!(parsedResult instanceof AddressBookParsedResult)) { throw new WriterException("Result was not an address"); } <DeepExtract> ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder(); String[] encoded = encoder.encode(toIterable((AddressBookParsedResult) parsedResult.getNames()), (AddressBookParsedResult) parsedResult.getOrg(), toIterable((AddressBookParsedResult) parsedResult.getAddresses()), toIterable((AddressBookParsedResult) parsedResult.getPhoneNumbers()), toIterable((AddressBookParsedResult) parsedResult.getEmails()), toIterable((AddressBookParsedResult) parsedResult.getURLs()), null); if (encoded[1].length() > 0) { contents = encoded[0]; displayContents = encoded[1]; title = activity.getString(R.string.contents_contact); } </DeepExtract> if (contents == null || contents.length() == 0) { throw new WriterException("No content to encode"); } }
AndroidWebServ
positive
662
@Override public void start() { isStarted.set(true); queue.add(group, activity, timePeriodMs.get(), TimeUnit.MILLISECONDS); }
@Override public void start() { isStarted.set(true); <DeepExtract> queue.add(group, activity, timePeriodMs.get(), TimeUnit.MILLISECONDS); </DeepExtract> }
exhibitor
positive
663
@Override protected void onDraw(Canvas canvas) { this.color = borderColor; invalidate(); this.color = color; invalidate(); if (shape == ColorShape.SQUARE) { if (borderWidthPx > 0) { canvas.drawRect(drawingRect, borderPaint); } if (alphaPattern != null) { alphaPattern.draw(canvas); } canvas.drawRect(colorRect, colorPaint); } else if (shape == ColorShape.CIRCLE) { final int outerRadius = getMeasuredWidth() / 2; if (borderWidthPx > 0) { canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, outerRadius, borderPaint); } if (Color.alpha(color) < 255) { canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, outerRadius - borderWidthPx, alphaPaint); } if (showOldColor) { canvas.drawArc(centerRect, 90, 180, true, originalPaint); canvas.drawArc(centerRect, 270, 180, true, colorPaint); } else { canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, outerRadius - borderWidthPx, colorPaint); } } }
@Override protected void onDraw(Canvas canvas) { this.color = borderColor; invalidate(); <DeepExtract> this.color = color; invalidate(); </DeepExtract> if (shape == ColorShape.SQUARE) { if (borderWidthPx > 0) { canvas.drawRect(drawingRect, borderPaint); } if (alphaPattern != null) { alphaPattern.draw(canvas); } canvas.drawRect(colorRect, colorPaint); } else if (shape == ColorShape.CIRCLE) { final int outerRadius = getMeasuredWidth() / 2; if (borderWidthPx > 0) { canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, outerRadius, borderPaint); } if (Color.alpha(color) < 255) { canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, outerRadius - borderWidthPx, alphaPaint); } if (showOldColor) { canvas.drawArc(centerRect, 90, 180, true, originalPaint); canvas.drawArc(centerRect, 270, 180, true, colorPaint); } else { canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, outerRadius - borderWidthPx, colorPaint); } } }
MDWechat
positive
664
public void insertUpdate(DocumentEvent e) { if (target.getText().length() > 0) { target.setColumns(0); } else { target.setColumns(1); } if (target.getParent() != null) { JPanel layer = (JPanel) target.getParent(); layer.revalidate(); } }
public void insertUpdate(DocumentEvent e) { <DeepExtract> if (target.getText().length() > 0) { target.setColumns(0); } else { target.setColumns(1); } if (target.getParent() != null) { JPanel layer = (JPanel) target.getParent(); layer.revalidate(); } </DeepExtract> }
dragmath
positive
665
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int parentWidth = MeasureSpec.getSize(widthMeasureSpec); int parentHeight = MeasureSpec.getSize(heightMeasureSpec); this.setMeasuredDimension(parentWidth, parentHeight); width = parentWidth; height = parentHeight; super.onMeasure(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(width, height); BITMAP_MEMORY_BUDGET = (int) (2 * width * height * 5.0f); if (is_inited) return; updater_thread.start(); bmpworker_thread.start(); layout(); is_inited = true; if (need_load_state) { loadState(this.bundle); need_load_state = false; this.bundle = null; } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int parentWidth = MeasureSpec.getSize(widthMeasureSpec); int parentHeight = MeasureSpec.getSize(heightMeasureSpec); this.setMeasuredDimension(parentWidth, parentHeight); width = parentWidth; height = parentHeight; super.onMeasure(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(width, height); BITMAP_MEMORY_BUDGET = (int) (2 * width * height * 5.0f); <DeepExtract> if (is_inited) return; updater_thread.start(); bmpworker_thread.start(); layout(); is_inited = true; </DeepExtract> if (need_load_state) { loadState(this.bundle); need_load_state = false; this.bundle = null; } }
midisheetmusicmemo
positive
667
public Symbol parse() throws java.lang.Exception { Symbol lhs_sym = null; production_tab = production_table(); action_tab = action_table(); reduce_tab = reduce_table(); init_actions(); Symbol sym = getScanner().next_token(); return (sym != null) ? sym : getSymbolFactory().newSymbol("END_OF_FILE", EOF_sym()); stack.removeAllElements(); stack.push(getSymbolFactory().startSymbol("START", 0, start_state())); tos = 0; for (_done_parsing = false; !_done_parsing; ) { if (cur_token.used_by_parser) throw new Error("Symbol recycling detected (fix your scanner)."); act = get_action(((Symbol) stack.peek()).parse_state, cur_token.sym); if (act > 0) { cur_token.parse_state = act - 1; cur_token.used_by_parser = true; stack.push(cur_token); tos++; cur_token = scan(); } else if (act < 0) { lhs_sym = do_action((-act) - 1, this, stack, tos); lhs_sym_num = production_tab[(-act) - 1][0]; handle_size = production_tab[(-act) - 1][1]; for (int i = 0; i < handle_size; i++) { stack.pop(); tos--; } act = get_reduce(((Symbol) stack.peek()).parse_state, lhs_sym_num); lhs_sym.parse_state = act; lhs_sym.used_by_parser = true; stack.push(lhs_sym); tos++; } else if (act == 0) { syntax_error(cur_token); if (!error_recovery(false)) { unrecovered_syntax_error(cur_token); done_parsing(); } else { lhs_sym = (Symbol) stack.peek(); } } } return lhs_sym; }
public Symbol parse() throws java.lang.Exception { Symbol lhs_sym = null; production_tab = production_table(); action_tab = action_table(); reduce_tab = reduce_table(); init_actions(); <DeepExtract> Symbol sym = getScanner().next_token(); return (sym != null) ? sym : getSymbolFactory().newSymbol("END_OF_FILE", EOF_sym()); </DeepExtract> stack.removeAllElements(); stack.push(getSymbolFactory().startSymbol("START", 0, start_state())); tos = 0; for (_done_parsing = false; !_done_parsing; ) { if (cur_token.used_by_parser) throw new Error("Symbol recycling detected (fix your scanner)."); act = get_action(((Symbol) stack.peek()).parse_state, cur_token.sym); if (act > 0) { cur_token.parse_state = act - 1; cur_token.used_by_parser = true; stack.push(cur_token); tos++; cur_token = scan(); } else if (act < 0) { lhs_sym = do_action((-act) - 1, this, stack, tos); lhs_sym_num = production_tab[(-act) - 1][0]; handle_size = production_tab[(-act) - 1][1]; for (int i = 0; i < handle_size; i++) { stack.pop(); tos--; } act = get_reduce(((Symbol) stack.peek()).parse_state, lhs_sym_num); lhs_sym.parse_state = act; lhs_sym.used_by_parser = true; stack.push(lhs_sym); tos++; } else if (act == 0) { syntax_error(cur_token); if (!error_recovery(false)) { unrecovered_syntax_error(cur_token); done_parsing(); } else { lhs_sym = (Symbol) stack.peek(); } } } return lhs_sym; }
phantm
positive
668
@Override public CompletableFuture<Subscription> subscribe(String topic, BiConsumer<List<Object>, EventDetails> handler) { throwIfNotConnected(); CompletableFuture<Subscription> future = new CompletableFuture<>(); long requestID = mIDGenerator.next(); mSubscribeRequests.put(requestID, new SubscribeRequest(requestID, topic, future, null, null, handler)); send(new Subscribe(requestID, null, topic)); return future; }
@Override public CompletableFuture<Subscription> subscribe(String topic, BiConsumer<List<Object>, EventDetails> handler) { <DeepExtract> throwIfNotConnected(); CompletableFuture<Subscription> future = new CompletableFuture<>(); long requestID = mIDGenerator.next(); mSubscribeRequests.put(requestID, new SubscribeRequest(requestID, topic, future, null, null, handler)); send(new Subscribe(requestID, null, topic)); return future; </DeepExtract> }
autobahn-java
positive
673
@Test @SmallTest public void testSetLocalOfferMakesVideoFlowLocally() throws InterruptedException { Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally"); MockSink localRenderer = new MockSink(EXPECTED_VIDEO_FRAMES, LOCAL_RENDERER_NAME); List<PeerConnection.IceServer> iceServers = new ArrayList<>(); SignalingParameters signalingParameters = new SignalingParameters(iceServers, true, null, null, null, null, null); final EglBase eglBase = EglBase.create(); PeerConnectionClient client = new PeerConnectionClient(InstrumentationRegistry.getTargetContext(), eglBase, createParametersForVideoCall(VIDEO_CODEC_VP8), this); PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); options.networkIgnoreMask = 0; options.disableNetworkMonitor = true; client.createPeerConnectionFactory(options); client.createPeerConnection(localRenderer, new MockRenderer(0, null), createCameraCapturer(false), signalingParameters); client.createOffer(); return client; assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); assertTrue("ICE candidates were not generated.", waitForIceCandidates(WAIT_TIMEOUT)); assertTrue("Local video frames were not rendered.", localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); pcClient.close(); assertTrue("PeerConnection close event was not received.", waitForPeerConnectionClosed(WAIT_TIMEOUT)); Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally Done."); }
@Test @SmallTest public void testSetLocalOfferMakesVideoFlowLocally() throws InterruptedException { Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally"); MockSink localRenderer = new MockSink(EXPECTED_VIDEO_FRAMES, LOCAL_RENDERER_NAME); <DeepExtract> List<PeerConnection.IceServer> iceServers = new ArrayList<>(); SignalingParameters signalingParameters = new SignalingParameters(iceServers, true, null, null, null, null, null); final EglBase eglBase = EglBase.create(); PeerConnectionClient client = new PeerConnectionClient(InstrumentationRegistry.getTargetContext(), eglBase, createParametersForVideoCall(VIDEO_CODEC_VP8), this); PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); options.networkIgnoreMask = 0; options.disableNetworkMonitor = true; client.createPeerConnectionFactory(options); client.createPeerConnection(localRenderer, new MockRenderer(0, null), createCameraCapturer(false), signalingParameters); client.createOffer(); return client; </DeepExtract> assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); assertTrue("ICE candidates were not generated.", waitForIceCandidates(WAIT_TIMEOUT)); assertTrue("Local video frames were not rendered.", localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); pcClient.close(); assertTrue("PeerConnection close event was not received.", waitForPeerConnectionClosed(WAIT_TIMEOUT)); Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally Done."); }
glass-enterprise-samples
positive
674
public void mouseClicked(java.awt.event.MouseEvent evt) { if (curPetDetail != null) { String u1 = curPetDetail.u_name + " (Fire)"; String p2 = SwManager.petFamily.get(u1); if (p2 != null) { LoadPetDetail(p2); } } }
public void mouseClicked(java.awt.event.MouseEvent evt) { <DeepExtract> if (curPetDetail != null) { String u1 = curPetDetail.u_name + " (Fire)"; String p2 = SwManager.petFamily.get(u1); if (p2 != null) { LoadPetDetail(p2); } } </DeepExtract> }
sw_optimize
positive
675
@Override protected final void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); onSetContentView(); mToolBar = onFindToolBarView(); setSupportActionBar(mToolBar); mActionBar = getSupportActionBar(); onFindViews(); onBindContent(); }
@Override <DeepExtract> </DeepExtract> protected final void onCreate(Bundle savedInstanceState) { <DeepExtract> </DeepExtract> super.onCreate(savedInstanceState); <DeepExtract> </DeepExtract> onSetContentView(); <DeepExtract> </DeepExtract> mToolBar = onFindToolBarView(); <DeepExtract> </DeepExtract> setSupportActionBar(mToolBar); <DeepExtract> </DeepExtract> mActionBar = getSupportActionBar(); <DeepExtract> </DeepExtract> onFindViews(); <DeepExtract> </DeepExtract> onBindContent(); <DeepExtract> </DeepExtract> }
LightUtils
positive
676
@Test public void selection() throws Exception { Iterable<Integer> it = () -> new Iterator<Integer>() { private int[] a = new int[] { 1, 2, 3 }; private int index = 0; @Override public boolean hasNext() { return index < a.length; } @Override public Integer next() { return a[index++]; } }; Tmp tmp = new Tmp(); o = it; StandardEvaluationContext context = new StandardEvaluationContext(tmp); ArrayList<Integer> list = parser.parseExpression("o.?[true]").getValue(context, ArrayList.class); Assert.assertEquals(list, Lists.newArrayList(1, 2, 3)); }
@Test public void selection() throws Exception { Iterable<Integer> it = () -> new Iterator<Integer>() { private int[] a = new int[] { 1, 2, 3 }; private int index = 0; @Override public boolean hasNext() { return index < a.length; } @Override public Integer next() { return a[index++]; } }; Tmp tmp = new Tmp(); <DeepExtract> o = it; </DeepExtract> StandardEvaluationContext context = new StandardEvaluationContext(tmp); ArrayList<Integer> list = parser.parseExpression("o.?[true]").getValue(context, ArrayList.class); Assert.assertEquals(list, Lists.newArrayList(1, 2, 3)); }
syncer
positive
677
public void errorSave(Order newOrder) throws HibernateException { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.save(newOrder); session.flush(); return newOrder; session.flush(); throw new HibernateException("error save"); }
public void errorSave(Order newOrder) throws HibernateException { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); <DeepExtract> Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.save(newOrder); session.flush(); return newOrder; </DeepExtract> session.flush(); throw new HibernateException("error save"); }
zkbooks
positive
678
public void print(char c, int width, int fill) { int oldw = width; width = width; return oldw; int oldf = fill; fill = fill; return oldf; print(c); width = 0; precision = 4; fill = ' '; jstyle = Format.STANDARD; }
public void print(char c, int width, int fill) { int oldw = width; width = width; return oldw; int oldf = fill; fill = fill; return oldf; print(c); <DeepExtract> width = 0; precision = 4; fill = ' '; jstyle = Format.STANDARD; </DeepExtract> }
programmingIT
positive
679
@Override public ZSetEntry next() { return map.get(min++); }
@Override public ZSetEntry next() { <DeepExtract> return map.get(min++); </DeepExtract> }
redis-protocol
positive
680
public Criteria andAddressBetween(String value1, String value2) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "address" + " cannot be null"); } criteria.add(new Criterion("address between", value1, value2)); return (Criteria) this; }
public Criteria andAddressBetween(String value1, String value2) { <DeepExtract> if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "address" + " cannot be null"); } criteria.add(new Criterion("address between", value1, value2)); </DeepExtract> return (Criteria) this; }
Whome
positive
681
@Override public View getView(int arg0, View convertView, ViewGroup arg2) { if (convertView == null) { convertView = (RelativeLayout) MainActivity.inflater.inflate(R.layout.bookmark_item, null); holder = new ViewHolder(); holder.title = ((TextView) (convertView.findViewById(R.id.bookmark_title))); holder.url = ((TextView) (convertView.findViewById(R.id.bookmark_url_title))); holder.icon = ((ImageView) convertView.findViewById(R.id.bookmark_icon)); holder.url.setTag(holder); } else { holder = (ViewHolder) ((TextView) (convertView.findViewById(R.id.bookmark_url_title))).getTag(); if (((Boolean) holder.icon.getTag()) != null && holder.url.getText() != null && ((Boolean) holder.icon.getTag()) == true && holder.url.getText().equals(bookmarks.get(arg0).getUrl()) && holder.title.getText().toString().equals(bookmarks.get(arg0).getDisplayName())) { return convertView; } } if (Properties.appProp.darkTheme) { holder.title.setTextColor(Color.WHITE); holder.url.setTextColor(Color.WHITE); } else { } Bookmark bookmark = bookmarks.get(arg0); String bookmarkTitle = bookmark.getDisplayName(); String bookmarkURL = bookmark.getUrl(); boolean hasFavicon; if (bookmark.getPathToFavicon() == null) { hasFavicon = false; } else { hasFavicon = true; } holder.title.setText(bookmarkTitle); if (bookmarkURL.equals(Properties.webpageProp.assetHomePage)) { holder.title.setText("about:home"); if (!Properties.appProp.darkTheme) holder.icon.setColorFilter(Color.BLACK); holder.icon.setImageResource(R.drawable.ic_collections_view_as_list); } else { ((TextView) convertView.findViewById(R.id.bookmark_url_title)).setText(bookmarkURL); if (hasFavicon) { try { holder.icon.setColorFilter(null); holder.icon.setTag(true); holder.icon.setImageBitmap(bookmark.getIconBitmap()); } catch (Exception e) { } } else { if (!Properties.appProp.darkTheme) holder.icon.setColorFilter(Color.BLACK); holder.icon.setTag(false); holder.icon.setImageResource(R.drawable.ic_collections_view_as_list); } } convertView.setTag(bookmark); return convertView; }
@Override public View getView(int arg0, View convertView, ViewGroup arg2) { if (convertView == null) { convertView = (RelativeLayout) MainActivity.inflater.inflate(R.layout.bookmark_item, null); holder = new ViewHolder(); holder.title = ((TextView) (convertView.findViewById(R.id.bookmark_title))); holder.url = ((TextView) (convertView.findViewById(R.id.bookmark_url_title))); holder.icon = ((ImageView) convertView.findViewById(R.id.bookmark_icon)); holder.url.setTag(holder); } else { holder = (ViewHolder) ((TextView) (convertView.findViewById(R.id.bookmark_url_title))).getTag(); if (((Boolean) holder.icon.getTag()) != null && holder.url.getText() != null && ((Boolean) holder.icon.getTag()) == true && holder.url.getText().equals(bookmarks.get(arg0).getUrl()) && holder.title.getText().toString().equals(bookmarks.get(arg0).getDisplayName())) { return convertView; } } if (Properties.appProp.darkTheme) { holder.title.setTextColor(Color.WHITE); holder.url.setTextColor(Color.WHITE); } else { } Bookmark bookmark = bookmarks.get(arg0); String bookmarkTitle = bookmark.getDisplayName(); String bookmarkURL = bookmark.getUrl(); <DeepExtract> boolean hasFavicon; if (bookmark.getPathToFavicon() == null) { hasFavicon = false; } else { hasFavicon = true; } </DeepExtract> holder.title.setText(bookmarkTitle); if (bookmarkURL.equals(Properties.webpageProp.assetHomePage)) { holder.title.setText("about:home"); if (!Properties.appProp.darkTheme) holder.icon.setColorFilter(Color.BLACK); holder.icon.setImageResource(R.drawable.ic_collections_view_as_list); } else { ((TextView) convertView.findViewById(R.id.bookmark_url_title)).setText(bookmarkURL); if (hasFavicon) { try { holder.icon.setColorFilter(null); holder.icon.setTag(true); holder.icon.setImageBitmap(bookmark.getIconBitmap()); } catch (Exception e) { } } else { if (!Properties.appProp.darkTheme) holder.icon.setColorFilter(Color.BLACK); holder.icon.setTag(false); holder.icon.setImageResource(R.drawable.ic_collections_view_as_list); } } convertView.setTag(bookmark); return convertView; }
Lucid-Browser
positive
684
public void restoreState() { if (false) setup_progress_bar_limit.setVisibility(View.VISIBLE); else setup_progress_bar_limit.setVisibility(View.GONE); getBtnForward().setEnabled(true); Utils.setImageWithTint(getBtnForward(), R.drawable.ic_chevron_left_black_24dp, Color.DKGRAY); getBtnNext().setEnabled(true); getBtnNext().setTextColor(Color.DKGRAY); getBtnNext().setCompoundDrawablesRelative(null, null, Utils.getTintedDrawable(this, R.drawable.ic_chevron_right_black_24dp, Color.DKGRAY), null); }
public void restoreState() { <DeepExtract> if (false) setup_progress_bar_limit.setVisibility(View.VISIBLE); else setup_progress_bar_limit.setVisibility(View.GONE); </DeepExtract> getBtnForward().setEnabled(true); Utils.setImageWithTint(getBtnForward(), R.drawable.ic_chevron_left_black_24dp, Color.DKGRAY); getBtnNext().setEnabled(true); getBtnNext().setTextColor(Color.DKGRAY); getBtnNext().setCompoundDrawablesRelative(null, null, Utils.getTintedDrawable(this, R.drawable.ic_chevron_right_black_24dp, Color.DKGRAY), null); }
audiohq_md2
positive
686
@Override public void done(Object response) { callback.done(response); if (RpcResult.class.isInstance(response)) { RpcResult rpcResult = (RpcResult) response; Map<String, String> ns = rpcResult.getNotifications(); if (ns != null && ns.size() > 0) { Notifications.set(ns); } if (CompileConfig.isDebug) { if (ns != null) { StringBuilder sb = new StringBuilder("got async notifications ----> "); for (Map.Entry<String, String> entry : ns.entrySet()) { sb.append(entry.getKey()).append(":").append(entry.getValue()).append("; "); } logger.info(sb.toString()); } else { logger.info("got async notificaion: null"); } } } }
@Override public void done(Object response) { callback.done(response); <DeepExtract> if (RpcResult.class.isInstance(response)) { RpcResult rpcResult = (RpcResult) response; Map<String, String> ns = rpcResult.getNotifications(); if (ns != null && ns.size() > 0) { Notifications.set(ns); } if (CompileConfig.isDebug) { if (ns != null) { StringBuilder sb = new StringBuilder("got async notifications ----> "); for (Map.Entry<String, String> entry : ns.entrySet()) { sb.append(entry.getKey()).append(":").append(entry.getValue()).append("; "); } logger.info(sb.toString()); } else { logger.info("got async notificaion: null"); } } } </DeepExtract> }
net.pocrd.core
positive
687
private static int[] parseIds(String url) throws Exception { int[] ids = new int[2]; String dest = ""; if (url.split(new String("&image="))[0] != null) { dest = url.split(new String("&image="))[0].replaceAll("[^0-9]", ""); } return Integer.valueOf(dest); String dest = ""; if (url.split(new String("&image="))[1] != null) { dest = url.split(new String("&image="))[1].replaceAll("[^0-9]", ""); } return Integer.valueOf(dest); return ids; }
private static int[] parseIds(String url) throws Exception { int[] ids = new int[2]; String dest = ""; if (url.split(new String("&image="))[0] != null) { dest = url.split(new String("&image="))[0].replaceAll("[^0-9]", ""); } return Integer.valueOf(dest); <DeepExtract> String dest = ""; if (url.split(new String("&image="))[1] != null) { dest = url.split(new String("&image="))[1].replaceAll("[^0-9]", ""); } return Integer.valueOf(dest); </DeepExtract> return ids; }
FingerColoring-Android
positive
688
@Override public List<SysRelation> getRelationListByObjectId(String objectId) { LambdaQueryWrapper<SysRelation> lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(SysRelation::getObjectId, objectId); if (ObjectUtil.isNotEmpty(null)) { lambdaQueryWrapper.eq(SysRelation::getCategory, null); } return this.list(lambdaQueryWrapper); }
@Override public List<SysRelation> getRelationListByObjectId(String objectId) { <DeepExtract> LambdaQueryWrapper<SysRelation> lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(SysRelation::getObjectId, objectId); if (ObjectUtil.isNotEmpty(null)) { lambdaQueryWrapper.eq(SysRelation::getCategory, null); } return this.list(lambdaQueryWrapper); </DeepExtract> }
xiaonuo-vue
positive
689
public double Frechet(List<T> t1, List<T> t2) { double[][] ca = new double[t2.size()][t1.size()]; for (int i = 0; i < t2.size(); ++i) { for (int j = 0; j < t1.size(); ++j) { ca[i][j] = -1.0D; } } if (ca[t2.size() - 1][t1.size() - 1] > -1.0D) return ca[t2.size() - 1][t1.size() - 1]; if (t2.size() - 1 == 0 && t1.size() - 1 == 0) { ca[t2.size() - 1][t1.size() - 1] = distFunc.apply(t1.get(0), t2.get(0)); } else if (t1.size() - 1 == 0) { ca[t2.size() - 1][t1.size() - 1] = Math.max(c(t2.size() - 1 - 1, 0, ca, t1, t2), distFunc.apply(t2.get(t2.size() - 1), t1.get(0))); } else if (t2.size() - 1 == 0) { ca[t2.size() - 1][t1.size() - 1] = Math.max(c(0, t1.size() - 1 - 1, ca, t1, t2), distFunc.apply(t2.get(0), t1.get(t1.size() - 1))); } else { ca[t2.size() - 1][t1.size() - 1] = Math.max(Math.min(Math.min(c(t2.size() - 1 - 1, t1.size() - 1, ca, t1, t2), c(t2.size() - 1 - 1, t1.size() - 1 - 1, ca, t1, t2)), c(t2.size() - 1, t1.size() - 1 - 1, ca, t1, t2)), distFunc.apply(t2.get(t2.size() - 1), t1.get(t1.size() - 1))); } return ca[t2.size() - 1][t1.size() - 1]; }
public double Frechet(List<T> t1, List<T> t2) { double[][] ca = new double[t2.size()][t1.size()]; for (int i = 0; i < t2.size(); ++i) { for (int j = 0; j < t1.size(); ++j) { ca[i][j] = -1.0D; } } <DeepExtract> if (ca[t2.size() - 1][t1.size() - 1] > -1.0D) return ca[t2.size() - 1][t1.size() - 1]; if (t2.size() - 1 == 0 && t1.size() - 1 == 0) { ca[t2.size() - 1][t1.size() - 1] = distFunc.apply(t1.get(0), t2.get(0)); } else if (t1.size() - 1 == 0) { ca[t2.size() - 1][t1.size() - 1] = Math.max(c(t2.size() - 1 - 1, 0, ca, t1, t2), distFunc.apply(t2.get(t2.size() - 1), t1.get(0))); } else if (t2.size() - 1 == 0) { ca[t2.size() - 1][t1.size() - 1] = Math.max(c(0, t1.size() - 1 - 1, ca, t1, t2), distFunc.apply(t2.get(0), t1.get(t1.size() - 1))); } else { ca[t2.size() - 1][t1.size() - 1] = Math.max(Math.min(Math.min(c(t2.size() - 1 - 1, t1.size() - 1, ca, t1, t2), c(t2.size() - 1 - 1, t1.size() - 1 - 1, ca, t1, t2)), c(t2.size() - 1, t1.size() - 1 - 1, ca, t1, t2)), distFunc.apply(t2.get(t2.size() - 1), t1.get(t1.size() - 1))); } return ca[t2.size() - 1][t1.size() - 1]; </DeepExtract> }
torchtrajectory
positive
690
private void init() { CharSequence t = getTitle(); if (t == null || t.length() <= 0) setTitle(R.string.filter_cat); sum = getSummary(); if (sum == null || sum.length() <= 0) sum = A.s(R.string.filter_sum); setSummary(sum + " (" + A.s(A.is(filterKey()) ? R.string.active : R.string.inactive) + ')'); setPersistent(false); setWidgetLayoutResource(R.layout.img_call); setOnPreferenceClickListener(this); }
private void init() { CharSequence t = getTitle(); if (t == null || t.length() <= 0) setTitle(R.string.filter_cat); sum = getSummary(); if (sum == null || sum.length() <= 0) sum = A.s(R.string.filter_sum); <DeepExtract> setSummary(sum + " (" + A.s(A.is(filterKey()) ? R.string.active : R.string.inactive) + ')'); </DeepExtract> setPersistent(false); setWidgetLayoutResource(R.layout.img_call); setOnPreferenceClickListener(this); }
sanity
positive
691
public void setPositionAndScaleMatrix(Matrix matrix) { final float[] values = new float[9]; matrix.getValues(values); float scale = values[Matrix.MSCALE_X]; horizontalScrollRange = (int) (mapScheme.getWidth() * scale); verticalScrollRange = (int) (mapScheme.getHeight() * scale); horizontalScrollOffset = (int) -values[Matrix.MTRANS_X]; verticalScrollOffset = (int) -values[Matrix.MTRANS_Y]; awakeScrollBars(); renderer.setMatrix(matrix); viewportChangedListener.onViewportChanged(matrix); }
public void setPositionAndScaleMatrix(Matrix matrix) { <DeepExtract> final float[] values = new float[9]; matrix.getValues(values); float scale = values[Matrix.MSCALE_X]; horizontalScrollRange = (int) (mapScheme.getWidth() * scale); verticalScrollRange = (int) (mapScheme.getHeight() * scale); horizontalScrollOffset = (int) -values[Matrix.MTRANS_X]; verticalScrollOffset = (int) -values[Matrix.MTRANS_Y]; awakeScrollBars(); </DeepExtract> renderer.setMatrix(matrix); viewportChangedListener.onViewportChanged(matrix); }
ametro
positive
692
@Override protected void writeMonkeyRunnerCommand() { int oldVal = target.getValue(); int max = target.getMax(); if (targetVal == -1 || targetVal >= max || targetVal < 0) { targetVal = ACInstrumentation.getSelf().random.nextInt(max); } if (touchX == -1) { GetLocationRunnable glr = new GetLocationRunnable(target); instrumenter.runOnMainSync(glr); if (glr.visible) { touchX = glr.pos_x + glr.paddingLeft + (glr.width - glr.paddingLeft - glr.paddingRight) * targetVal / target.getMax(); touchY = glr.pos_y; } } GetLocationRunnable glr = new GetLocationRunnable(target); instrumenter.runOnMainSync(glr); if (glr.visible) { int step = (android.os.Build.VERSION.SDK_INT <= 15) ? 1 : -1; for (int i = oldVal; (i - targetVal) * step < 0; i += step) { monkeyRunnerGenerator.touch(glr.pos_x, glr.pos_y, monkeyRunnerGenerator.DOWN_AND_UP, 1); } for (int i = oldVal; (i - targetVal) * step > 0; i -= step) { monkeyRunnerGenerator.touch(glr.pos_x, glr.pos_y + glr.height - 2, monkeyRunnerGenerator.DOWN_AND_UP, 1); } } else { monkeyRunnerGenerator.prompt(String.format("Please set the number picker to %d, and then press Enter to continue...", targetVal)); } }
@Override protected void writeMonkeyRunnerCommand() { int oldVal = target.getValue(); <DeepExtract> int max = target.getMax(); if (targetVal == -1 || targetVal >= max || targetVal < 0) { targetVal = ACInstrumentation.getSelf().random.nextInt(max); } if (touchX == -1) { GetLocationRunnable glr = new GetLocationRunnable(target); instrumenter.runOnMainSync(glr); if (glr.visible) { touchX = glr.pos_x + glr.paddingLeft + (glr.width - glr.paddingLeft - glr.paddingRight) * targetVal / target.getMax(); touchY = glr.pos_y; } } </DeepExtract> GetLocationRunnable glr = new GetLocationRunnable(target); instrumenter.runOnMainSync(glr); if (glr.visible) { int step = (android.os.Build.VERSION.SDK_INT <= 15) ? 1 : -1; for (int i = oldVal; (i - targetVal) * step < 0; i += step) { monkeyRunnerGenerator.touch(glr.pos_x, glr.pos_y, monkeyRunnerGenerator.DOWN_AND_UP, 1); } for (int i = oldVal; (i - targetVal) * step > 0; i -= step) { monkeyRunnerGenerator.touch(glr.pos_x, glr.pos_y + glr.height - 2, monkeyRunnerGenerator.DOWN_AND_UP, 1); } } else { monkeyRunnerGenerator.prompt(String.format("Please set the number picker to %d, and then press Enter to continue...", targetVal)); } }
appdoctor
positive
693
public String flushQiniuToken(String spaceName) throws Exception { String currentToken = null; if (ValidationUtil.isEmpty(currentToken)) { currentToken = this.getAuth().uploadToken(spaceName); } return currentToken; }
public String flushQiniuToken(String spaceName) throws Exception { <DeepExtract> String currentToken = null; if (ValidationUtil.isEmpty(currentToken)) { currentToken = this.getAuth().uploadToken(spaceName); } return currentToken; </DeepExtract> }
tyboot
positive
694
public Jar addEntry(String path, byte[] content) throws IOException { verifyNotSealed(); if (jos != null) return; if (os == null) this.os = new ByteArrayOutputStream(); writePrefix(os); if (getAttribute(ATTR_MANIFEST_VERSION) == null) setAttribute(ATTR_MANIFEST_VERSION, "1.0"); jos = new JarOutputStream(os, manifest); if (jis != null) addEntries(null, jis); addEntry(jos, path, content); return this; }
public Jar addEntry(String path, byte[] content) throws IOException { <DeepExtract> verifyNotSealed(); if (jos != null) return; if (os == null) this.os = new ByteArrayOutputStream(); writePrefix(os); if (getAttribute(ATTR_MANIFEST_VERSION) == null) setAttribute(ATTR_MANIFEST_VERSION, "1.0"); jos = new JarOutputStream(os, manifest); if (jis != null) addEntries(null, jis); </DeepExtract> addEntry(jos, path, content); return this; }
capsule
positive
695
private void initializeStreamIfNeeded() { if (null != parser) { return; } time = min.minusHours(1); Path file; do { time = time.plusHours(1); if (time.compareTo(max) > 0) { throw new NoSuchElementException(); } file = Paths.get(historyFolder, fileName(client, pair, time)); } while (!file.toFile().exists()); parser = new CSVParser(new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(file.toFile())))), CSVFormat.MYSQL.withFirstRecordAsHeader()); recordIterator = parser.iterator(); }
private void initializeStreamIfNeeded() { if (null != parser) { return; } time = min.minusHours(1); <DeepExtract> Path file; do { time = time.plusHours(1); if (time.compareTo(max) > 0) { throw new NoSuchElementException(); } file = Paths.get(historyFolder, fileName(client, pair, time)); } while (!file.toFile().exists()); parser = new CSVParser(new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(file.toFile())))), CSVFormat.MYSQL.withFirstRecordAsHeader()); recordIterator = parser.iterator(); </DeepExtract> }
GTC-all-repo
positive
697