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 void addStream(InputStream inputStream, ZipParameters parameters) throws ZipException {
if (inputStream == null) {
throw new ZipException("inputstream is null, cannot add file to zip");
}
if (parameters == null) {
throw new ZipException("zip parameters are null");
}
this.runInThread = false;
if (this.zipModel == null) {
if (Zip4jUtil.checkFileExists(file)) {
readZipInfo();
} else {
createNewZipModel();
}
}
if (this.zipModel == null) {
throw new ZipException("internal error: zip model is null");
}
if (Zip4jUtil.checkFileExists(file)) {
if (zipModel.isSplitArchive()) {
throw new ZipException("Zip file already exists. Zip file format does not allow updating split/spanned files");
}
}
ZipEngine zipEngine = new ZipEngine(zipModel);
zipEngine.addStreamToZip(inputStream, parameters);
} | public void addStream(InputStream inputStream, ZipParameters parameters) throws ZipException {
if (inputStream == null) {
throw new ZipException("inputstream is null, cannot add file to zip");
}
if (parameters == null) {
throw new ZipException("zip parameters are null");
}
this.runInThread = false;
<DeepExtract>
if (this.zipModel == null) {
if (Zip4jUtil.checkFileExists(file)) {
readZipInfo();
} else {
createNewZipModel();
}
}
</DeepExtract>
if (this.zipModel == null) {
throw new ZipException("internal error: zip model is null");
}
if (Zip4jUtil.checkFileExists(file)) {
if (zipModel.isSplitArchive()) {
throw new ZipException("Zip file already exists. Zip file format does not allow updating split/spanned files");
}
}
ZipEngine zipEngine = new ZipEngine(zipModel);
zipEngine.addStreamToZip(inputStream, parameters);
} | secure-zip-notes | positive | 1,738 |
private void successfulUse(Skill sk) {
int durDec = (int) Math.round((double) sk.getDurCost() / (buffExist(Buff.waste_not) ? 2 : 1) / (cs == CraftingStatus.Sturdy ? 2 : 1));
int cpDec = (int) Math.round((double) sk.getCPCost() / (cs == CraftingStatus.Pliant ? 2 : 1));
presentDurability -= durDec;
presentCP -= cpDec;
round++;
presentDurability = presentDurability;
lm.setDurabilityDecrease(durDec);
presentCP = presentCP;
lm.setCPDecrease(cpDec);
lm.nodeFinish();
} | private void successfulUse(Skill sk) {
int durDec = (int) Math.round((double) sk.getDurCost() / (buffExist(Buff.waste_not) ? 2 : 1) / (cs == CraftingStatus.Sturdy ? 2 : 1));
int cpDec = (int) Math.round((double) sk.getCPCost() / (cs == CraftingStatus.Pliant ? 2 : 1));
presentDurability -= durDec;
presentCP -= cpDec;
round++;
presentDurability = presentDurability;
lm.setDurabilityDecrease(durDec);
<DeepExtract>
presentCP = presentCP;
</DeepExtract>
lm.setCPDecrease(cpDec);
lm.nodeFinish();
} | FFXIVCraftingSim | positive | 1,739 |
public UnitFeature createUnitFeature() {
prefs = (prefs == null) ? abapCiPluginHelper.getPreferenceStore() : prefs;
final UnitFeature feature = new UnitFeature();
feature.setActive(prefs.getBoolean(PreferenceConstants.PREF_UNIT_RUN_ON_SAVE));
feature.setRunActivatedObjectsOnly(prefs.getBoolean(PreferenceConstants.PREF_UNIT_RUN_ACTIVATED_OBJECTS_ONLY));
return feature;
} | public UnitFeature createUnitFeature() {
<DeepExtract>
prefs = (prefs == null) ? abapCiPluginHelper.getPreferenceStore() : prefs;
</DeepExtract>
final UnitFeature feature = new UnitFeature();
feature.setActive(prefs.getBoolean(PreferenceConstants.PREF_UNIT_RUN_ON_SAVE));
feature.setRunActivatedObjectsOnly(prefs.getBoolean(PreferenceConstants.PREF_UNIT_RUN_ACTIVATED_OBJECTS_ONLY));
return feature;
} | abapCI | positive | 1,741 |
public <T> T getForObject(URI url, Class<T> responseType) throws RestClientException {
AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(responseType);
HttpMessageConverterExtractor<T> responseExtractor = new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
return doExecute(url, HttpMethod.GET, requestCallback, responseExtractor);
} | public <T> T getForObject(URI url, Class<T> responseType) throws RestClientException {
AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(responseType);
HttpMessageConverterExtractor<T> responseExtractor = new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
<DeepExtract>
return doExecute(url, HttpMethod.GET, requestCallback, responseExtractor);
</DeepExtract>
} | spring-data-document-examples | positive | 1,742 |
@Override
public void onClick(View v) {
String message = mCommentText.getText().toString();
Bundle bundle = new Bundle();
bundle.putString(GerritService.REVIEW_MESSAGE, message);
sendRequest(GerritService.DataType.Comment, bundle);
} | @Override
public void onClick(View v) {
<DeepExtract>
String message = mCommentText.getText().toString();
Bundle bundle = new Bundle();
bundle.putString(GerritService.REVIEW_MESSAGE, message);
sendRequest(GerritService.DataType.Comment, bundle);
</DeepExtract>
} | external_jbirdvegas_mGerrit | positive | 1,743 |
private void doZsort() {
double[] xyz = new double[3];
jjj[0] = 0;
xyz[0] = 0.0;
xyz[1] = 0.0;
xyz[2] = -0.5;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[0] = xyz[2];
jjj[1] = 1;
xyz[0] = 0.0;
xyz[1] = -0.5;
xyz[2] = 0.0;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[1] = xyz[2];
jjj[2] = 2;
xyz[0] = -0.5;
xyz[1] = 0.0;
xyz[2] = 0.0;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[2] = xyz[2];
jjj[3] = 3;
xyz[0] = 0.0;
xyz[1] = 0.0;
xyz[2] = +0.5;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[3] = xyz[2];
jjj[4] = 4;
xyz[0] = 0.0;
xyz[1] = +0.5;
xyz[2] = 0.0;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[4] = xyz[2];
jjj[5] = 5;
xyz[0] = +0.5;
xyz[1] = 0.0;
xyz[2] = 0.0;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[5] = xyz[2];
double dtemp;
int itemp;
for (int i = 0; i < 6 - 1; i++) {
for (int j = i + 1; j < 6; j++) if (zzz[j] < zzz[i]) {
itemp = jjj[j];
dtemp = zzz[j];
jjj[j] = jjj[i];
zzz[j] = zzz[i];
jjj[i] = itemp;
zzz[i] = dtemp;
}
}
} | private void doZsort() {
double[] xyz = new double[3];
jjj[0] = 0;
xyz[0] = 0.0;
xyz[1] = 0.0;
xyz[2] = -0.5;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[0] = xyz[2];
jjj[1] = 1;
xyz[0] = 0.0;
xyz[1] = -0.5;
xyz[2] = 0.0;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[1] = xyz[2];
jjj[2] = 2;
xyz[0] = -0.5;
xyz[1] = 0.0;
xyz[2] = 0.0;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[2] = xyz[2];
jjj[3] = 3;
xyz[0] = 0.0;
xyz[1] = 0.0;
xyz[2] = +0.5;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[3] = xyz[2];
jjj[4] = 4;
xyz[0] = 0.0;
xyz[1] = +0.5;
xyz[2] = 0.0;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[4] = xyz[2];
jjj[5] = 5;
xyz[0] = +0.5;
xyz[1] = 0.0;
xyz[2] = 0.0;
double horiz = xyz[0] * cosaz - xyz[1] * sinaz;
double vert = xyz[0] * sinel * sinaz + xyz[1] * sinel * cosaz + xyz[2] * cosel;
double outof = -xyz[0] * cosel * sinaz - xyz[1] * cosel * cosaz + xyz[2] * sinel;
xyz[0] = horiz;
xyz[1] = vert;
xyz[2] = outof;
zzz[5] = xyz[2];
<DeepExtract>
double dtemp;
int itemp;
for (int i = 0; i < 6 - 1; i++) {
for (int j = i + 1; j < 6; j++) if (zzz[j] < zzz[i]) {
itemp = jjj[j];
dtemp = zzz[j];
jjj[j] = jjj[i];
zzz[j] = zzz[i];
jjj[i] = itemp;
zzz[i] = dtemp;
}
}
</DeepExtract>
} | BeamFour | positive | 1,744 |
@Override
public String discoverTopBooksService() {
String[] topBooksServiceURLs = { "http://localhost:8080/topbooks", "http://localhost:8082/topbooks" };
for (String url : topBooksServiceURLs) {
try {
Response response = ClientBuilder.newClient().target(url).request(MediaType.APPLICATION_JSON).get();
if (response.getStatus() == Response.Status.OK.getStatusCode()) {
logger.info("OK URL : " + url);
return url;
} else {
logger.warning("KO URL : " + url + " - Status code : " + response.getStatus());
}
} catch (Exception e) {
logger.info("KO URL : " + url);
}
}
return null;
} | @Override
public String discoverTopBooksService() {
String[] topBooksServiceURLs = { "http://localhost:8080/topbooks", "http://localhost:8082/topbooks" };
<DeepExtract>
for (String url : topBooksServiceURLs) {
try {
Response response = ClientBuilder.newClient().target(url).request(MediaType.APPLICATION_JSON).get();
if (response.getStatus() == Response.Status.OK.getStatusCode()) {
logger.info("OK URL : " + url);
return url;
} else {
logger.warning("KO URL : " + url + " - Status code : " + response.getStatus());
}
} catch (Exception e) {
logger.info("KO URL : " + url);
}
}
return null;
</DeepExtract>
} | agoncal-sample-javaee | positive | 1,745 |
@Override
public boolean generate(World world, Random rand, int x, int y, int z) {
final Random random = new Random();
random.setSeed(rand.nextLong());
if (isPoorGrowthConditions(world, x, y, z, 0, getSaplingBlock()))
return false;
final Block block = world.getBlock(x, y - 1, z);
block.onPlantGrow(world, x, y - 1, z, x, y, z);
for (final ImmutablePair<Integer, Integer> branchDirection : BRANCH_DIRECTIONS) if (random.nextInt(3) == 0)
genRoot(world, random, x, y, z, branchDirection.getLeft(), branchDirection.getRight());
genRoot(world, random, x, y, z, 0, 0);
placeLog(world, x, y, z);
switch(random.nextInt(4)) {
case 0:
placeLog(world, x, y + 2, z);
placeLog(world, x - 1, y + 1, z);
largeDirect(world, random, 1, 0, x, y + 2, z, 1, 2, 0, 2);
break;
case 1:
placeLog(world, x, y + 1, z);
placeLog(world, x, y + 2, z);
placeLog(world, x, y + 1, z - 1);
largeDirect(world, random, 0, 1, x, y + 2, z, 1, 2, 0, 2);
break;
case 2:
placeLog(world, x, y + 1, z);
placeLog(world, x, y + 2, z);
placeLog(world, x + 1, y + 1, z);
largeDirect(world, random, -1, 0, x, y + 2, z, 1, 2, 0, 2);
break;
default:
placeLog(world, x, y + 1, z);
placeLog(world, x, y + 2, z);
placeLog(world, x, y + 1, z + 1);
largeDirect(world, random, 0, -1, x, y + 1, z, 1, 2, 0, 2);
}
return true;
} | @Override
public boolean generate(World world, Random rand, int x, int y, int z) {
final Random random = new Random();
random.setSeed(rand.nextLong());
if (isPoorGrowthConditions(world, x, y, z, 0, getSaplingBlock()))
return false;
final Block block = world.getBlock(x, y - 1, z);
block.onPlantGrow(world, x, y - 1, z, x, y, z);
for (final ImmutablePair<Integer, Integer> branchDirection : BRANCH_DIRECTIONS) if (random.nextInt(3) == 0)
genRoot(world, random, x, y, z, branchDirection.getLeft(), branchDirection.getRight());
genRoot(world, random, x, y, z, 0, 0);
<DeepExtract>
placeLog(world, x, y, z);
switch(random.nextInt(4)) {
case 0:
placeLog(world, x, y + 2, z);
placeLog(world, x - 1, y + 1, z);
largeDirect(world, random, 1, 0, x, y + 2, z, 1, 2, 0, 2);
break;
case 1:
placeLog(world, x, y + 1, z);
placeLog(world, x, y + 2, z);
placeLog(world, x, y + 1, z - 1);
largeDirect(world, random, 0, 1, x, y + 2, z, 1, 2, 0, 2);
break;
case 2:
placeLog(world, x, y + 1, z);
placeLog(world, x, y + 2, z);
placeLog(world, x + 1, y + 1, z);
largeDirect(world, random, -1, 0, x, y + 2, z, 1, 2, 0, 2);
break;
default:
placeLog(world, x, y + 1, z);
placeLog(world, x, y + 2, z);
placeLog(world, x, y + 1, z + 1);
largeDirect(world, random, 0, -1, x, y + 1, z, 1, 2, 0, 2);
}
</DeepExtract>
return true;
} | ancient-trees | positive | 1,746 |
@Override
@Deprecated
public void setMinScale(float minScale) {
mAttacher.setMinimumScale(minScale);
} | @Override
@Deprecated
public void setMinScale(float minScale) {
<DeepExtract>
mAttacher.setMinimumScale(minScale);
</DeepExtract>
} | WeiboClient_Biu | positive | 1,747 |
public void execute(Nation n) {
this.n = n;
this.random = new Random(n.random.nextInt());
n.races.get(0).tags.getAllStrings("priestnames").forEach(set -> names.addAll(assets.magenames.get(set)));
n.races.get(0).tags.getAllStrings("priestadjectives").forEach(set -> adjectives.addAll(assets.magenames.get(set)));
n.races.get(0).tags.getAllStrings("priestnouns").forEach(set -> nouns.addAll(assets.magenames.get(set)));
n.races.get(0).tags.getAllStrings("tieredpriestnames").forEach(set -> tieredmage.addAll(assets.magenames.get(set)));
n.races.get(0).tags.getAllStrings("priestrankedprefixes").forEach(set -> rankedprefix.addAll(assets.magenames.get(set)));
if (names.size() == 0)
names = assets.magenames.get("defaultnames");
if (adjectives.size() == 0)
adjectives = assets.magenames.get("defaultadjectives");
if (nouns.size() == 0)
nouns = assets.magenames.get("defaultnouns");
if (tieredmage.size() == 0)
tieredmage = assets.magenames.get("defaulttieredpriestnames");
if (rankedprefix.size() == 0)
rankedprefix = assets.magenames.get("defaultprefixranks");
List<Unit> priests = n.comlists.get("priests");
List<Unit> primaries = new ArrayList<Unit>();
List<Unit> secondaries = new ArrayList<Unit>();
List<Unit> tertiaries = new ArrayList<Unit>();
List<List<Unit>> all = new ArrayList<List<Unit>>();
all.add(tertiaries);
all.add(secondaries);
all.add(primaries);
int maxTier = 0;
for (Unit u : priests) {
for (int i = 1; i < 4; i++) {
if (u.tags.contains("priest", i)) {
all.get(i - 1).add(u);
if (maxTier < i)
maxTier = i;
}
}
}
boolean prefixrank = n.random.nextBoolean();
boolean suffix = n.random.nextBoolean();
for (int i = 2; i >= 0; i--) {
if (all.get(i).size() == 0)
continue;
if (i < 2 && all.get(i + 1).size() > 0) {
this.deriveNames(all.get(i + 1), all.get(i), (i + 1), prefixrank, suffix);
} else {
if (i < 2)
this.generateNewNames(all.get(i), 3, prefixrank, suffix);
else
this.generateNewNames(all.get(i), (i + 1), prefixrank, suffix);
}
}
} | public void execute(Nation n) {
this.n = n;
this.random = new Random(n.random.nextInt());
<DeepExtract>
n.races.get(0).tags.getAllStrings("priestnames").forEach(set -> names.addAll(assets.magenames.get(set)));
n.races.get(0).tags.getAllStrings("priestadjectives").forEach(set -> adjectives.addAll(assets.magenames.get(set)));
n.races.get(0).tags.getAllStrings("priestnouns").forEach(set -> nouns.addAll(assets.magenames.get(set)));
n.races.get(0).tags.getAllStrings("tieredpriestnames").forEach(set -> tieredmage.addAll(assets.magenames.get(set)));
n.races.get(0).tags.getAllStrings("priestrankedprefixes").forEach(set -> rankedprefix.addAll(assets.magenames.get(set)));
if (names.size() == 0)
names = assets.magenames.get("defaultnames");
if (adjectives.size() == 0)
adjectives = assets.magenames.get("defaultadjectives");
if (nouns.size() == 0)
nouns = assets.magenames.get("defaultnouns");
if (tieredmage.size() == 0)
tieredmage = assets.magenames.get("defaulttieredpriestnames");
if (rankedprefix.size() == 0)
rankedprefix = assets.magenames.get("defaultprefixranks");
</DeepExtract>
List<Unit> priests = n.comlists.get("priests");
List<Unit> primaries = new ArrayList<Unit>();
List<Unit> secondaries = new ArrayList<Unit>();
List<Unit> tertiaries = new ArrayList<Unit>();
List<List<Unit>> all = new ArrayList<List<Unit>>();
all.add(tertiaries);
all.add(secondaries);
all.add(primaries);
int maxTier = 0;
for (Unit u : priests) {
for (int i = 1; i < 4; i++) {
if (u.tags.contains("priest", i)) {
all.get(i - 1).add(u);
if (maxTier < i)
maxTier = i;
}
}
}
boolean prefixrank = n.random.nextBoolean();
boolean suffix = n.random.nextBoolean();
for (int i = 2; i >= 0; i--) {
if (all.get(i).size() == 0)
continue;
if (i < 2 && all.get(i + 1).size() > 0) {
this.deriveNames(all.get(i + 1), all.get(i), (i + 1), prefixrank, suffix);
} else {
if (i < 2)
this.generateNewNames(all.get(i), 3, prefixrank, suffix);
else
this.generateNewNames(all.get(i), (i + 1), prefixrank, suffix);
}
}
} | nationgen | positive | 1,748 |
@Override
protected void onLayout(boolean flag, int i, int j, int k, int l) {
int offsetHeaderY;
int offsetFooterY;
if (mPtrIndicator.isHeader()) {
offsetHeaderY = mPtrIndicator.getCurrentPosY();
offsetFooterY = 0;
} else {
offsetHeaderY = 0;
offsetFooterY = mPtrIndicator.getCurrentPosY();
}
int paddingLeft = getPaddingLeft();
int paddingTop = getPaddingTop();
int contentBottom = 0;
if (DEBUG && DEBUG_LAYOUT) {
PtrCLog.d(LOG_TAG, "onLayout offset: %s %s %s %s", offsetHeaderY, offsetFooterY, isPinContent(), mPtrIndicator.isHeader());
}
if (mHeaderView != null) {
MarginLayoutParams lp = (MarginLayoutParams) mHeaderView.getLayoutParams();
final int left = paddingLeft + lp.leftMargin;
final int top = paddingTop + lp.topMargin + offsetHeaderY - mHeaderHeight;
final int right = left + mHeaderView.getMeasuredWidth();
final int bottom = top + mHeaderView.getMeasuredHeight();
mHeaderView.layout(left, top, right, bottom);
if (DEBUG && DEBUG_LAYOUT) {
PtrCLog.d(LOG_TAG, "onLayout header: %s %s %s %s %s", left, top, right, bottom, mHeaderView.getMeasuredHeight());
}
}
if (mContent != null) {
MarginLayoutParams lp = (MarginLayoutParams) mContent.getLayoutParams();
int left;
int top;
int right;
int bottom;
if (mPtrIndicator.isHeader()) {
left = paddingLeft + lp.leftMargin;
top = paddingTop + lp.topMargin + (isPinContent() ? 0 : offsetHeaderY);
right = left + mContent.getMeasuredWidth();
bottom = top + mContent.getMeasuredHeight();
} else {
left = paddingLeft + lp.leftMargin;
top = paddingTop + lp.topMargin - (isPinContent() ? 0 : offsetFooterY);
right = left + mContent.getMeasuredWidth();
bottom = top + mContent.getMeasuredHeight();
}
contentBottom = bottom;
if (DEBUG && DEBUG_LAYOUT) {
PtrCLog.d(LOG_TAG, "onLayout content: %s %s %s %s %s", left, top, right, bottom, mContent.getMeasuredHeight());
}
mContent.layout(left, top, right, bottom);
}
if (mFooterView != null) {
MarginLayoutParams lp = (MarginLayoutParams) mFooterView.getLayoutParams();
final int left = paddingLeft + lp.leftMargin;
final int top = paddingTop + lp.topMargin + contentBottom - (isPinContent() ? offsetFooterY : 0);
final int right = left + mFooterView.getMeasuredWidth();
final int bottom = top + mFooterView.getMeasuredHeight();
mFooterView.layout(left, top, right, bottom);
if (DEBUG && DEBUG_LAYOUT) {
PtrCLog.d(LOG_TAG, "onLayout footer: %s %s %s %s %s", left, top, right, bottom, mFooterView.getMeasuredHeight());
}
}
} | @Override
protected void onLayout(boolean flag, int i, int j, int k, int l) {
<DeepExtract>
int offsetHeaderY;
int offsetFooterY;
if (mPtrIndicator.isHeader()) {
offsetHeaderY = mPtrIndicator.getCurrentPosY();
offsetFooterY = 0;
} else {
offsetHeaderY = 0;
offsetFooterY = mPtrIndicator.getCurrentPosY();
}
int paddingLeft = getPaddingLeft();
int paddingTop = getPaddingTop();
int contentBottom = 0;
if (DEBUG && DEBUG_LAYOUT) {
PtrCLog.d(LOG_TAG, "onLayout offset: %s %s %s %s", offsetHeaderY, offsetFooterY, isPinContent(), mPtrIndicator.isHeader());
}
if (mHeaderView != null) {
MarginLayoutParams lp = (MarginLayoutParams) mHeaderView.getLayoutParams();
final int left = paddingLeft + lp.leftMargin;
final int top = paddingTop + lp.topMargin + offsetHeaderY - mHeaderHeight;
final int right = left + mHeaderView.getMeasuredWidth();
final int bottom = top + mHeaderView.getMeasuredHeight();
mHeaderView.layout(left, top, right, bottom);
if (DEBUG && DEBUG_LAYOUT) {
PtrCLog.d(LOG_TAG, "onLayout header: %s %s %s %s %s", left, top, right, bottom, mHeaderView.getMeasuredHeight());
}
}
if (mContent != null) {
MarginLayoutParams lp = (MarginLayoutParams) mContent.getLayoutParams();
int left;
int top;
int right;
int bottom;
if (mPtrIndicator.isHeader()) {
left = paddingLeft + lp.leftMargin;
top = paddingTop + lp.topMargin + (isPinContent() ? 0 : offsetHeaderY);
right = left + mContent.getMeasuredWidth();
bottom = top + mContent.getMeasuredHeight();
} else {
left = paddingLeft + lp.leftMargin;
top = paddingTop + lp.topMargin - (isPinContent() ? 0 : offsetFooterY);
right = left + mContent.getMeasuredWidth();
bottom = top + mContent.getMeasuredHeight();
}
contentBottom = bottom;
if (DEBUG && DEBUG_LAYOUT) {
PtrCLog.d(LOG_TAG, "onLayout content: %s %s %s %s %s", left, top, right, bottom, mContent.getMeasuredHeight());
}
mContent.layout(left, top, right, bottom);
}
if (mFooterView != null) {
MarginLayoutParams lp = (MarginLayoutParams) mFooterView.getLayoutParams();
final int left = paddingLeft + lp.leftMargin;
final int top = paddingTop + lp.topMargin + contentBottom - (isPinContent() ? offsetFooterY : 0);
final int right = left + mFooterView.getMeasuredWidth();
final int bottom = top + mFooterView.getMeasuredHeight();
mFooterView.layout(left, top, right, bottom);
if (DEBUG && DEBUG_LAYOUT) {
PtrCLog.d(LOG_TAG, "onLayout footer: %s %s %s %s %s", left, top, right, bottom, mFooterView.getMeasuredHeight());
}
}
</DeepExtract>
} | Elephant | positive | 1,749 |
void min2NormalAndDrag2Min(boolean showImmediately, float currentY, float startY, float endY, float startLeft, float endLeft, float startWidth, float endWidth, float startHeight, float endHeight) {
if (endY == startY) {
return;
}
if (showImmediately) {
imageWrapper.setWidth(endWidth);
imageWrapper.setHeight(endHeight);
imageWrapper.setMarginLeft((int) (endLeft));
imageWrapper.setMarginTop((int) endY);
return;
}
float yPercent = (currentY - startY) / (endY - startY);
float xOffset = yPercent * (endLeft - startLeft);
float widthOffset = yPercent * (endWidth - startWidth);
float heightOffset = yPercent * (endHeight - startHeight);
params.width = Math.round(startWidth + widthOffset);
viewWrapper.setLayoutParams(params);
params.height = Math.round(startHeight + heightOffset);
viewWrapper.setLayoutParams(params);
params.leftMargin = (int) (startLeft + xOffset);
viewWrapper.setLayoutParams(params);
params.topMargin = (int) currentY;
viewWrapper.setLayoutParams(params);
} | void min2NormalAndDrag2Min(boolean showImmediately, float currentY, float startY, float endY, float startLeft, float endLeft, float startWidth, float endWidth, float startHeight, float endHeight) {
if (endY == startY) {
return;
}
if (showImmediately) {
imageWrapper.setWidth(endWidth);
imageWrapper.setHeight(endHeight);
imageWrapper.setMarginLeft((int) (endLeft));
imageWrapper.setMarginTop((int) endY);
return;
}
float yPercent = (currentY - startY) / (endY - startY);
float xOffset = yPercent * (endLeft - startLeft);
float widthOffset = yPercent * (endWidth - startWidth);
float heightOffset = yPercent * (endHeight - startHeight);
params.width = Math.round(startWidth + widthOffset);
viewWrapper.setLayoutParams(params);
params.height = Math.round(startHeight + heightOffset);
viewWrapper.setLayoutParams(params);
params.leftMargin = (int) (startLeft + xOffset);
viewWrapper.setLayoutParams(params);
<DeepExtract>
params.topMargin = (int) currentY;
viewWrapper.setLayoutParams(params);
</DeepExtract>
} | LxViewLibs | positive | 1,750 |
@Override
public Camera.CameraBuilder getCameraBuilder() {
if (mCamera == null) {
throw new IllegalStateException("camera == null");
}
return mCamera.getBuilder();
} | @Override
public Camera.CameraBuilder getCameraBuilder() {
<DeepExtract>
if (mCamera == null) {
throw new IllegalStateException("camera == null");
}
</DeepExtract>
return mCamera.getBuilder();
} | VideoRecorder | positive | 1,751 |
@Override
public ResultSet executeQuery(String sql) throws SQLException {
this.sql = sql;
return this.statement.executeQuery(sql);
} | @Override
public ResultSet executeQuery(String sql) throws SQLException {
<DeepExtract>
this.sql = sql;
</DeepExtract>
return this.statement.executeQuery(sql);
} | dts | positive | 1,752 |
public void addRawText(String content) {
cont.add(content).pad(3.5f).padLeft(tablePad).padRight(tablePad);
if (!tableMode)
cont.row();
else if (lineCol) {
cont.image().color(tableColor).fillY().growY().width(tableStroke).pad(0);
}
} | public void addRawText(String content) {
cont.add(content).pad(3.5f).padLeft(tablePad).padRight(tablePad);
<DeepExtract>
if (!tableMode)
cont.row();
else if (lineCol) {
cont.image().color(tableColor).fillY().growY().width(tableStroke).pad(0);
}
</DeepExtract>
} | BetaMindy | positive | 1,756 |
public ModelConfigOuterClass.ModelDynamicBatching getDynamicBatching() {
if (schedulingChoiceCase_ == 11) {
return (ModelConfigOuterClass.ModelDynamicBatching) schedulingChoice_;
}
return DEFAULT_INSTANCE;
} | public ModelConfigOuterClass.ModelDynamicBatching getDynamicBatching() {
if (schedulingChoiceCase_ == 11) {
return (ModelConfigOuterClass.ModelDynamicBatching) schedulingChoice_;
}
<DeepExtract>
return DEFAULT_INSTANCE;
</DeepExtract>
} | dl_inference | positive | 1,758 |
public Criteria andGmtModifiedEqualTo(Long value) {
if (value == null) {
throw new RuntimeException("Value for " + "gmtModified" + " cannot be null");
}
criteria.add(new Criterion("gmt_modified =", value));
return (Criteria) this;
} | public Criteria andGmtModifiedEqualTo(Long value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "gmtModified" + " cannot be null");
}
criteria.add(new Criterion("gmt_modified =", value));
</DeepExtract>
return (Criteria) this;
} | community | positive | 1,759 |
public void exponential(Runnable fn, int maxRetries, long retryBackoffMillis) {
int retries = 0;
while (true) {
try {
fn.run();
return;
} catch (Exception e) {
if (retries >= (maxRetries - 1)) {
throw e;
}
long timeout = !true ? retryBackoffMillis : (long) Math.pow(2, retries) * retryBackoffMillis;
sleep(timeout);
retries++;
}
}
} | public void exponential(Runnable fn, int maxRetries, long retryBackoffMillis) {
<DeepExtract>
int retries = 0;
while (true) {
try {
fn.run();
return;
} catch (Exception e) {
if (retries >= (maxRetries - 1)) {
throw e;
}
long timeout = !true ? retryBackoffMillis : (long) Math.pow(2, retries) * retryBackoffMillis;
sleep(timeout);
retries++;
}
}
</DeepExtract>
} | kayenta | positive | 1,760 |
@Override
public double distance(Point from, double toX, double toY) {
final double scale = Math.pow(10, 10);
return Math.round(delegate.distance(from, toX, toY) * scale) / scale;
} | @Override
public double distance(Point from, double toX, double toY) {
<DeepExtract>
final double scale = Math.pow(10, 10);
return Math.round(delegate.distance(from, toX, toY) * scale) / scale;
</DeepExtract>
} | spatial4j | positive | 1,761 |
public Criteria andSeqIsNull() {
if ("seq is null" == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion("seq is null"));
return (Criteria) this;
} | public Criteria andSeqIsNull() {
<DeepExtract>
if ("seq is null" == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion("seq is null"));
</DeepExtract>
return (Criteria) this;
} | einvoice | positive | 1,763 |
@Override
public void reset() {
song = loader.header[7] - 1;
nsfBanks = nsfStartBanks.clone();
setBanks();
for (int i = 0; i <= 0x7ff; ++i) {
cpuram.write(i, 0);
}
for (int i = 0x4000; i <= 0x4013; ++i) {
cpuram.write(i, 0);
}
cpuram.write(0x4015, 0x0f);
cpuram.write(0x4017, 0x40);
cpu.push(0xff);
cpu.push(0xfa);
cpu.setPC(init);
cpu.interrupt = -99999;
cpu.setRegA(song);
if (this.region == TVType.PAL) {
cpu.setRegX(0x01);
} else {
cpu.setRegX(0x00);
}
for (int i = 0; i < 32 * 24; ++i) {
pput0[i] = (Math.random() > 0.5) ? 0x2f : 0x5c;
}
for (int i = 0; i < 96; ++i) {
pput0[i + (32 * 25)] = loader.header[i + 0xe];
}
for (int i = 0; i < trackstr.length(); ++i) {
pput0[i + (32 * 28)] = trackstr.charAt(i);
}
if (!hasInitSound) {
setSoundChip();
hasInitSound = true;
}
if (!fds) {
for (int i = 0x6000; i <= 0x7fff; ++i) {
cpuram.write(i, 0);
}
}
cpu.setPC(init);
} | @Override
public void reset() {
song = loader.header[7] - 1;
<DeepExtract>
nsfBanks = nsfStartBanks.clone();
setBanks();
for (int i = 0; i <= 0x7ff; ++i) {
cpuram.write(i, 0);
}
for (int i = 0x4000; i <= 0x4013; ++i) {
cpuram.write(i, 0);
}
cpuram.write(0x4015, 0x0f);
cpuram.write(0x4017, 0x40);
cpu.push(0xff);
cpu.push(0xfa);
cpu.setPC(init);
cpu.interrupt = -99999;
cpu.setRegA(song);
if (this.region == TVType.PAL) {
cpu.setRegX(0x01);
} else {
cpu.setRegX(0x00);
}
for (int i = 0; i < 32 * 24; ++i) {
pput0[i] = (Math.random() > 0.5) ? 0x2f : 0x5c;
}
for (int i = 0; i < 96; ++i) {
pput0[i + (32 * 25)] = loader.header[i + 0xe];
}
for (int i = 0; i < trackstr.length(); ++i) {
pput0[i + (32 * 28)] = trackstr.charAt(i);
}
if (!hasInitSound) {
setSoundChip();
hasInitSound = true;
}
if (!fds) {
for (int i = 0x6000; i <= 0x7fff; ++i) {
cpuram.write(i, 0);
}
}
</DeepExtract>
cpu.setPC(init);
} | halfnes | positive | 1,764 |
@Override
public void run() {
if (null != mProgressDialog && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
} | @Override
public void run() {
<DeepExtract>
if (null != mProgressDialog && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
</DeepExtract>
} | NoWordsChat | positive | 1,765 |
@Override
protected void processSystem() {
boolean wasPaused = isPaused;
if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) {
if (isPaused)
onResume();
else
onPause();
}
if (isPaused || wasPaused) {
gameBatch.setProjectionMatrix(camera.combined);
gameBatch.begin();
gameBatch.draw(cachedBackground, 0, 0);
gameBatch.end();
if (wasPaused && !isPaused) {
cachedBackground.getTexture().dispose();
cachedBackground = null;
}
}
stage.draw();
} | @Override
protected void processSystem() {
boolean wasPaused = isPaused;
<DeepExtract>
if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) {
if (isPaused)
onResume();
else
onPause();
}
</DeepExtract>
if (isPaused || wasPaused) {
gameBatch.setProjectionMatrix(camera.combined);
gameBatch.begin();
gameBatch.draw(cachedBackground, 0, 0);
gameBatch.end();
if (wasPaused && !isPaused) {
cachedBackground.getTexture().dispose();
cachedBackground = null;
}
}
stage.draw();
} | cell-rpg | positive | 1,766 |
public static VpnProfile getAlwaysOnVPN(Context context) {
if (instance == null) {
instance = new ProfileManager();
instance.loadVPNList(context);
}
SharedPreferences prefs = Preferences.getDefaultSharedPreferences(context);
String uuid = prefs.getString("alwaysOnVpn", null);
if (tmpprofile != null && tmpprofile.getUUIDString().equals(uuid))
return tmpprofile;
if (instance == null)
return null;
return instance.profiles.get(uuid);
} | public static VpnProfile getAlwaysOnVPN(Context context) {
if (instance == null) {
instance = new ProfileManager();
instance.loadVPNList(context);
}
SharedPreferences prefs = Preferences.getDefaultSharedPreferences(context);
String uuid = prefs.getString("alwaysOnVpn", null);
<DeepExtract>
if (tmpprofile != null && tmpprofile.getUUIDString().equals(uuid))
return tmpprofile;
if (instance == null)
return null;
return instance.profiles.get(uuid);
</DeepExtract>
} | Cake-VPN | positive | 1,767 |
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent motionEvent) {
if (mViewWidth < 2) {
mViewWidth = mRecyclerView.getWidth();
}
switch(motionEvent.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
{
actionDown(motionEvent);
break;
}
case MotionEvent.ACTION_CANCEL:
{
actionCancel();
break;
}
case MotionEvent.ACTION_UP:
{
actionUp(motionEvent);
break;
}
case MotionEvent.ACTION_MOVE:
{
return actionMove(motionEvent);
}
}
return false;
} | @Override
public void onTouchEvent(RecyclerView rv, MotionEvent motionEvent) {
<DeepExtract>
if (mViewWidth < 2) {
mViewWidth = mRecyclerView.getWidth();
}
switch(motionEvent.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
{
actionDown(motionEvent);
break;
}
case MotionEvent.ACTION_CANCEL:
{
actionCancel();
break;
}
case MotionEvent.ACTION_UP:
{
actionUp(motionEvent);
break;
}
case MotionEvent.ACTION_MOVE:
{
return actionMove(motionEvent);
}
}
return false;
</DeepExtract>
} | Keep | positive | 1,768 |
@NotNull
default PagedRestAction<List<GalleryElement>> getSelfFavorites() {
return getUserGalleryFavorites("me", FavoriteSort.NEWEST);
} | @NotNull
default PagedRestAction<List<GalleryElement>> getSelfFavorites() {
<DeepExtract>
return getUserGalleryFavorites("me", FavoriteSort.NEWEST);
</DeepExtract>
} | Jmgur | positive | 1,769 |
@Override
public void release() {
mCurrentMediaPlayer.reset();
mIsInitialized = false;
mCurrentMediaPlayer.release();
if (mNextMediaPlayer != null) {
mNextMediaPlayer.release();
}
} | @Override
public void release() {
<DeepExtract>
mCurrentMediaPlayer.reset();
mIsInitialized = false;
</DeepExtract>
mCurrentMediaPlayer.release();
if (mNextMediaPlayer != null) {
mNextMediaPlayer.release();
}
} | RandomPlayer | positive | 1,770 |
private CompositeServletContextListener createCompositeListener(VaadinServletContext context) {
CompositeServletContextListener compositeListener = new CompositeServletContextListener();
listeners.add(new LookupInitializerListener());
listeners.add(new VaadinAppShellContextListener());
ApplicationRouteRegistry registry = ApplicationRouteRegistry.getInstance(context);
if (registry.getRegisteredRoutes().isEmpty()) {
compositeListener.addListener(new RouteServletContextListener());
}
listeners.add(new ErrorParameterServletContextListener());
listeners.add(new AnnotationValidatorServletContextListener());
listeners.add(new DevModeServletContextListener());
if (!WebComponentConfigurationRegistry.getInstance(context).hasConfigurations()) {
compositeListener.addListener(new WebComponentServletContextListener());
}
return compositeListener;
} | private CompositeServletContextListener createCompositeListener(VaadinServletContext context) {
CompositeServletContextListener compositeListener = new CompositeServletContextListener();
listeners.add(new LookupInitializerListener());
listeners.add(new VaadinAppShellContextListener());
ApplicationRouteRegistry registry = ApplicationRouteRegistry.getInstance(context);
if (registry.getRegisteredRoutes().isEmpty()) {
compositeListener.addListener(new RouteServletContextListener());
}
listeners.add(new ErrorParameterServletContextListener());
listeners.add(new AnnotationValidatorServletContextListener());
<DeepExtract>
listeners.add(new DevModeServletContextListener());
</DeepExtract>
if (!WebComponentConfigurationRegistry.getInstance(context).hasConfigurations()) {
compositeListener.addListener(new WebComponentServletContextListener());
}
return compositeListener;
} | spring | positive | 1,771 |
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
mCurrentItemOffset += dx;
if (mOnePageWidth <= 0)
return;
boolean pageChanged = false;
if (Math.abs(mCurrentItemOffset - mCurrentItemPos * mOnePageWidth) >= mOnePageWidth) {
pageChanged = true;
}
if (pageChanged) {
int tempPos = mCurrentItemPos;
mCurrentItemPos = mCurrentItemOffset / mOnePageWidth;
LogUtils.d(String.format("=======onCurrentItemPos Changed======= tempPos=%s, mCurrentItemPos=%s", tempPos, mCurrentItemPos));
}
LogUtils.v(String.format("dx=%s, dy=%s, mScrolledX=%s", dx, dy, mCurrentItemOffset));
int offset = mCurrentItemOffset - mCurrentItemPos * mOnePageWidth;
float percent = (float) Math.max(Math.abs(offset) * 1.0 / mOnePageWidth, 0.0001);
LogUtils.d(String.format("offset=%s, percent=%s", offset, percent));
View leftView = null;
View currentView;
View rightView = null;
if (mCurrentItemPos > 0) {
leftView = mRecyclerView.getLayoutManager().findViewByPosition(mCurrentItemPos - 1);
}
currentView = mRecyclerView.getLayoutManager().findViewByPosition(mCurrentItemPos);
if (mCurrentItemPos < mRecyclerView.getAdapter().getItemCount() - 1) {
rightView = mRecyclerView.getLayoutManager().findViewByPosition(mCurrentItemPos + 1);
}
if (leftView != null) {
leftView.setScaleY((1 - mScale) * percent + mScale);
}
if (currentView != null) {
currentView.setScaleY((mScale - 1) * percent + 1);
}
if (rightView != null) {
rightView.setScaleY((1 - mScale) * percent + mScale);
}
} | @Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
mCurrentItemOffset += dx;
if (mOnePageWidth <= 0)
return;
boolean pageChanged = false;
if (Math.abs(mCurrentItemOffset - mCurrentItemPos * mOnePageWidth) >= mOnePageWidth) {
pageChanged = true;
}
if (pageChanged) {
int tempPos = mCurrentItemPos;
mCurrentItemPos = mCurrentItemOffset / mOnePageWidth;
LogUtils.d(String.format("=======onCurrentItemPos Changed======= tempPos=%s, mCurrentItemPos=%s", tempPos, mCurrentItemPos));
}
LogUtils.v(String.format("dx=%s, dy=%s, mScrolledX=%s", dx, dy, mCurrentItemOffset));
<DeepExtract>
int offset = mCurrentItemOffset - mCurrentItemPos * mOnePageWidth;
float percent = (float) Math.max(Math.abs(offset) * 1.0 / mOnePageWidth, 0.0001);
LogUtils.d(String.format("offset=%s, percent=%s", offset, percent));
View leftView = null;
View currentView;
View rightView = null;
if (mCurrentItemPos > 0) {
leftView = mRecyclerView.getLayoutManager().findViewByPosition(mCurrentItemPos - 1);
}
currentView = mRecyclerView.getLayoutManager().findViewByPosition(mCurrentItemPos);
if (mCurrentItemPos < mRecyclerView.getAdapter().getItemCount() - 1) {
rightView = mRecyclerView.getLayoutManager().findViewByPosition(mCurrentItemPos + 1);
}
if (leftView != null) {
leftView.setScaleY((1 - mScale) * percent + mScale);
}
if (currentView != null) {
currentView.setScaleY((mScale - 1) * percent + 1);
}
if (rightView != null) {
rightView.setScaleY((1 - mScale) * percent + mScale);
}
</DeepExtract>
} | KotlinMVPRxJava2Dagger2GreenDaoRetrofitDemo | positive | 1,772 |
@Override
public FileHandle resolve(String fileName) {
switch(this) {
case CLASSPATH:
return Gdx.files.classpath(fileName);
case INTERNAL:
return Gdx.files.internal(fileName);
case LOCAL:
return Gdx.files.local(fileName);
case EXTERNAL:
return Gdx.files.external(fileName);
case ABSOLUTE:
return Gdx.files.absolute(fileName);
default:
return null;
}
} | @Override
public FileHandle resolve(String fileName) {
<DeepExtract>
switch(this) {
case CLASSPATH:
return Gdx.files.classpath(fileName);
case INTERNAL:
return Gdx.files.internal(fileName);
case LOCAL:
return Gdx.files.local(fileName);
case EXTERNAL:
return Gdx.files.external(fileName);
case ABSOLUTE:
return Gdx.files.absolute(fileName);
default:
return null;
}
</DeepExtract>
} | RuinsOfRevenge | positive | 1,773 |
@Bean
public DataSource clickHouseOnRecordDataSource(@Value("${graphouse.clickhouse.hosts}") String hostsString, @Value("${graphouse.clickhouse.port}") int port, @Value("${graphouse.clickhouse.db}") String db, @Value("${graphouse.on-record-tree.clickhouse.pool.max-life-time-seconds}") long maxLifeTimeSeconds, @Value("${graphouse.on-record-tree.clickhouse.pool.max-pool-size}") int maxPoolSize, @Value("${graphouse.on-record-tree.clickhouse.pool.minimum-idle}") int minimumIdle, @Value("${graphouse.on-record-tree.clickhouse.pool.validation-timeout-seconds}") int validationTimeoutSeconds, @Value("${graphouse.clickhouse.host-ping-rate-seconds}") int pingRateSeconds, ClickHouseProperties clickHouseProperties, Monitoring monitoring, @Qualifier("ping") Monitoring ping) {
List<String> hosts = Splitter.on(',').trimResults().omitEmptyStrings().splitToList(hostsString);
Preconditions.checkArgument(!hosts.isEmpty(), "ClickHouse host(s) not provided.");
if (hosts.size() == 1) {
String url = ClickhouseJdbcUrlParser.JDBC_CLICKHOUSE_PREFIX + "//" + hosts.get(0) + ":" + port + "/" + db;
ClickHouseDataSource ds = new ClickHouseDataSource(url, clickHouseProperties);
return createClickHouseDataSourcePool(ds, clickHouseProperties.getConnectionTimeout(), maxLifeTimeSeconds, maxPoolSize, minimumIdle, validationTimeoutSeconds);
}
return createBalancedClickhouseDataSource(hostsString, port, db, pingRateSeconds, clickHouseProperties, monitoring, ping);
} | @Bean
public DataSource clickHouseOnRecordDataSource(@Value("${graphouse.clickhouse.hosts}") String hostsString, @Value("${graphouse.clickhouse.port}") int port, @Value("${graphouse.clickhouse.db}") String db, @Value("${graphouse.on-record-tree.clickhouse.pool.max-life-time-seconds}") long maxLifeTimeSeconds, @Value("${graphouse.on-record-tree.clickhouse.pool.max-pool-size}") int maxPoolSize, @Value("${graphouse.on-record-tree.clickhouse.pool.minimum-idle}") int minimumIdle, @Value("${graphouse.on-record-tree.clickhouse.pool.validation-timeout-seconds}") int validationTimeoutSeconds, @Value("${graphouse.clickhouse.host-ping-rate-seconds}") int pingRateSeconds, ClickHouseProperties clickHouseProperties, Monitoring monitoring, @Qualifier("ping") Monitoring ping) {
<DeepExtract>
List<String> hosts = Splitter.on(',').trimResults().omitEmptyStrings().splitToList(hostsString);
Preconditions.checkArgument(!hosts.isEmpty(), "ClickHouse host(s) not provided.");
if (hosts.size() == 1) {
String url = ClickhouseJdbcUrlParser.JDBC_CLICKHOUSE_PREFIX + "//" + hosts.get(0) + ":" + port + "/" + db;
ClickHouseDataSource ds = new ClickHouseDataSource(url, clickHouseProperties);
return createClickHouseDataSourcePool(ds, clickHouseProperties.getConnectionTimeout(), maxLifeTimeSeconds, maxPoolSize, minimumIdle, validationTimeoutSeconds);
}
return createBalancedClickhouseDataSource(hostsString, port, db, pingRateSeconds, clickHouseProperties, monitoring, ping);
</DeepExtract>
} | graphouse | positive | 1,774 |
private void push(int insertKey, V insertValue, int index1, int key1, int index2, int key2, int index3, int key3) {
int[] keyTable = this.keyTable;
V[] valueTable = this.valueTable;
int mask = this.mask;
int i = 0, pushIterations = this.pushIterations;
int i = 0, pushIterations = this.pushIterations;
do {
switch(MathUtils.random(2)) {
case 0:
evictedKey = key1;
evictedValue = valueTable[index1];
keyTable[index1] = insertKey;
valueTable[index1] = insertValue;
break;
case 1:
evictedKey = key2;
evictedValue = valueTable[index2];
keyTable[index2] = insertKey;
valueTable[index2] = insertValue;
break;
default:
evictedKey = key3;
evictedValue = valueTable[index3];
keyTable[index3] = insertKey;
valueTable[index3] = insertValue;
break;
}
index1 = evictedKey & mask;
key1 = keyTable[index1];
if (key1 == EMPTY) {
keyTable[index1] = evictedKey;
valueTable[index1] = evictedValue;
if (size++ >= threshold)
resize(capacity << 1);
return;
}
index2 = hash2(evictedKey);
key2 = keyTable[index2];
if (key2 == EMPTY) {
keyTable[index2] = evictedKey;
valueTable[index2] = evictedValue;
if (size++ >= threshold)
resize(capacity << 1);
return;
}
index3 = hash3(evictedKey);
key3 = keyTable[index3];
if (key3 == EMPTY) {
keyTable[index3] = evictedKey;
valueTable[index3] = evictedValue;
if (size++ >= threshold)
resize(capacity << 1);
return;
}
if (++i == pushIterations)
break;
insertKey = evictedKey;
insertValue = evictedValue;
} while (true);
if (stashSize == stashCapacity) {
resize(capacity << 1);
put(evictedKey, evictedValue);
return;
}
int index = capacity + stashSize;
keyTable[index] = evictedKey;
valueTable[index] = evictedValue;
stashSize++;
size++;
} | private void push(int insertKey, V insertValue, int index1, int key1, int index2, int key2, int index3, int key3) {
int[] keyTable = this.keyTable;
V[] valueTable = this.valueTable;
int mask = this.mask;
int i = 0, pushIterations = this.pushIterations;
int i = 0, pushIterations = this.pushIterations;
do {
switch(MathUtils.random(2)) {
case 0:
evictedKey = key1;
evictedValue = valueTable[index1];
keyTable[index1] = insertKey;
valueTable[index1] = insertValue;
break;
case 1:
evictedKey = key2;
evictedValue = valueTable[index2];
keyTable[index2] = insertKey;
valueTable[index2] = insertValue;
break;
default:
evictedKey = key3;
evictedValue = valueTable[index3];
keyTable[index3] = insertKey;
valueTable[index3] = insertValue;
break;
}
index1 = evictedKey & mask;
key1 = keyTable[index1];
if (key1 == EMPTY) {
keyTable[index1] = evictedKey;
valueTable[index1] = evictedValue;
if (size++ >= threshold)
resize(capacity << 1);
return;
}
index2 = hash2(evictedKey);
key2 = keyTable[index2];
if (key2 == EMPTY) {
keyTable[index2] = evictedKey;
valueTable[index2] = evictedValue;
if (size++ >= threshold)
resize(capacity << 1);
return;
}
index3 = hash3(evictedKey);
key3 = keyTable[index3];
if (key3 == EMPTY) {
keyTable[index3] = evictedKey;
valueTable[index3] = evictedValue;
if (size++ >= threshold)
resize(capacity << 1);
return;
}
if (++i == pushIterations)
break;
insertKey = evictedKey;
insertValue = evictedValue;
} while (true);
<DeepExtract>
if (stashSize == stashCapacity) {
resize(capacity << 1);
put(evictedKey, evictedValue);
return;
}
int index = capacity + stashSize;
keyTable[index] = evictedKey;
valueTable[index] = evictedValue;
stashSize++;
size++;
</DeepExtract>
} | NanoUI-win32 | positive | 1,776 |
public int getCountCustomer() {
database = dbHelper.getWritableDatabase();
Cursor cursor = database.query(dbHelper.TABLE_CT_NAME, null, null, null, null, null, null);
cursor.moveToFirst();
database.close();
if (cursor.getCount() > 0) {
return cursor.getCount();
} else
return 0;
} | public int getCountCustomer() {
database = dbHelper.getWritableDatabase();
Cursor cursor = database.query(dbHelper.TABLE_CT_NAME, null, null, null, null, null, null);
cursor.moveToFirst();
<DeepExtract>
database.close();
</DeepExtract>
if (cursor.getCount() > 0) {
return cursor.getCount();
} else
return 0;
} | Android-POS | positive | 1,777 |
public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options, ImageSize targetSize, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
if (configuration == null) {
throw new IllegalStateException(ERROR_NOT_INIT);
}
if (imageAware == null) {
throw new IllegalArgumentException(ERROR_WRONG_ARGUMENTS);
}
if (listener == null) {
listener = defaultListener;
}
if (options == null) {
options = configuration.defaultDisplayImageOptions;
}
if (TextUtils.isEmpty(uri)) {
engine.cancelDisplayTaskFor(imageAware);
listener.onLoadingStarted(uri, imageAware.getWrappedView());
if (options.shouldShowImageForEmptyUri()) {
imageAware.setImageDrawable(options.getImageForEmptyUri(configuration.resources));
} else {
imageAware.setImageDrawable(null);
}
listener.onLoadingComplete(uri, imageAware.getWrappedView(), null);
return;
}
if (targetSize == null) {
targetSize = ImageSizeUtils.defineTargetSizeForView(imageAware, configuration.getMaxImageSize());
}
String memoryCacheKey = MemoryCacheUtils.generateKey(uri, targetSize);
engine.prepareDisplayTaskFor(imageAware, memoryCacheKey);
listener.onLoadingStarted(uri, imageAware.getWrappedView());
Bitmap bmp = configuration.memoryCache.get(memoryCacheKey);
if (bmp != null && !bmp.isRecycled()) {
L.d(LOG_LOAD_IMAGE_FROM_MEMORY_CACHE, memoryCacheKey);
if (options.shouldPostProcess()) {
ImageLoadingInfo imageLoadingInfo = new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey, options, listener, progressListener, engine.getLockForUri(uri));
ProcessAndDisplayImageTask displayTask = new ProcessAndDisplayImageTask(engine, bmp, imageLoadingInfo, defineHandler(options));
if (options.isSyncLoading()) {
displayTask.run();
} else {
engine.submit(displayTask);
}
} else {
options.getDisplayer().display(bmp, imageAware, LoadedFrom.MEMORY_CACHE);
listener.onLoadingComplete(uri, imageAware.getWrappedView(), bmp);
}
} else {
if (options.shouldShowImageOnLoading()) {
imageAware.setImageDrawable(options.getImageOnLoading(configuration.resources));
} else if (options.isResetViewBeforeLoading()) {
imageAware.setImageDrawable(null);
}
ImageLoadingInfo imageLoadingInfo = new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey, options, listener, progressListener, engine.getLockForUri(uri));
LoadAndDisplayImageTask displayTask = new LoadAndDisplayImageTask(engine, imageLoadingInfo, defineHandler(options));
if (options.isSyncLoading()) {
displayTask.run();
} else {
engine.submit(displayTask);
}
}
} | public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options, ImageSize targetSize, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
<DeepExtract>
if (configuration == null) {
throw new IllegalStateException(ERROR_NOT_INIT);
}
</DeepExtract>
if (imageAware == null) {
throw new IllegalArgumentException(ERROR_WRONG_ARGUMENTS);
}
if (listener == null) {
listener = defaultListener;
}
if (options == null) {
options = configuration.defaultDisplayImageOptions;
}
if (TextUtils.isEmpty(uri)) {
engine.cancelDisplayTaskFor(imageAware);
listener.onLoadingStarted(uri, imageAware.getWrappedView());
if (options.shouldShowImageForEmptyUri()) {
imageAware.setImageDrawable(options.getImageForEmptyUri(configuration.resources));
} else {
imageAware.setImageDrawable(null);
}
listener.onLoadingComplete(uri, imageAware.getWrappedView(), null);
return;
}
if (targetSize == null) {
targetSize = ImageSizeUtils.defineTargetSizeForView(imageAware, configuration.getMaxImageSize());
}
String memoryCacheKey = MemoryCacheUtils.generateKey(uri, targetSize);
engine.prepareDisplayTaskFor(imageAware, memoryCacheKey);
listener.onLoadingStarted(uri, imageAware.getWrappedView());
Bitmap bmp = configuration.memoryCache.get(memoryCacheKey);
if (bmp != null && !bmp.isRecycled()) {
L.d(LOG_LOAD_IMAGE_FROM_MEMORY_CACHE, memoryCacheKey);
if (options.shouldPostProcess()) {
ImageLoadingInfo imageLoadingInfo = new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey, options, listener, progressListener, engine.getLockForUri(uri));
ProcessAndDisplayImageTask displayTask = new ProcessAndDisplayImageTask(engine, bmp, imageLoadingInfo, defineHandler(options));
if (options.isSyncLoading()) {
displayTask.run();
} else {
engine.submit(displayTask);
}
} else {
options.getDisplayer().display(bmp, imageAware, LoadedFrom.MEMORY_CACHE);
listener.onLoadingComplete(uri, imageAware.getWrappedView(), bmp);
}
} else {
if (options.shouldShowImageOnLoading()) {
imageAware.setImageDrawable(options.getImageOnLoading(configuration.resources));
} else if (options.isResetViewBeforeLoading()) {
imageAware.setImageDrawable(null);
}
ImageLoadingInfo imageLoadingInfo = new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey, options, listener, progressListener, engine.getLockForUri(uri));
LoadAndDisplayImageTask displayTask = new LoadAndDisplayImageTask(engine, imageLoadingInfo, defineHandler(options));
if (options.isSyncLoading()) {
displayTask.run();
} else {
engine.submit(displayTask);
}
}
} | Android-Universal-Image-Loader | positive | 1,778 |
public static BigDecimal getTimestampWithMicroPrecision() {
if (TimeUtil.secondsOffset == null) {
calibrateNanosConversion();
} else {
long currentMillis1 = System.currentTimeMillis();
long currentNanos = System.nanoTime();
long currentMillis2 = System.currentTimeMillis();
BigDecimal currentTimeStamp = DecimalTimeUnit.MILLISECONDS.toSeconds(((double) (currentMillis1 + currentMillis2)) / 2.0);
if (TimeUtil._uptimeNanosToTimestamp(currentNanos).subtract(currentTimeStamp).abs().doubleValue() > TimeUtil.CLOCK_OFFSET_TOLERANCE) {
calibrateNanosConversion();
}
}
return TimeUtil._uptimeNanosToTimestamp(System.nanoTime());
} | public static BigDecimal getTimestampWithMicroPrecision() {
<DeepExtract>
if (TimeUtil.secondsOffset == null) {
calibrateNanosConversion();
} else {
long currentMillis1 = System.currentTimeMillis();
long currentNanos = System.nanoTime();
long currentMillis2 = System.currentTimeMillis();
BigDecimal currentTimeStamp = DecimalTimeUnit.MILLISECONDS.toSeconds(((double) (currentMillis1 + currentMillis2)) / 2.0);
if (TimeUtil._uptimeNanosToTimestamp(currentNanos).subtract(currentTimeStamp).abs().doubleValue() > TimeUtil.CLOCK_OFFSET_TOLERANCE) {
calibrateNanosConversion();
}
}
return TimeUtil._uptimeNanosToTimestamp(System.nanoTime());
</DeepExtract>
} | funf-core-android | positive | 1,780 |
@Override
public void onErrorResponse(VolleyError volleyError) {
if (ingreso == 0) {
cargarWebService(resultadoId, getString(R.string.ip2));
ingreso = 1;
} else {
if (ingreso == 1) {
cargarWebService(resultadoId, getString(R.string.ip3));
ingreso = 2;
} else {
txtinfo.setText("No se pudo establecer conexión con el servidor, Intente mas tarde");
obtenerListaResultados(resultadoId + "");
showProgress(false);
}
}
} | @Override
public void onErrorResponse(VolleyError volleyError) {
<DeepExtract>
if (ingreso == 0) {
cargarWebService(resultadoId, getString(R.string.ip2));
ingreso = 1;
} else {
if (ingreso == 1) {
cargarWebService(resultadoId, getString(R.string.ip3));
ingreso = 2;
} else {
txtinfo.setText("No se pudo establecer conexión con el servidor, Intente mas tarde");
obtenerListaResultados(resultadoId + "");
showProgress(false);
}
}
</DeepExtract>
} | curso-android-codejavu | positive | 1,782 |
public void setVisible(boolean isVisible) {
if (isVisible)
penColour = (int) Math.abs(penColour);
else
penColour = -(int) (Math.abs(penColour));
if (penColour < 1)
visible = false;
else
visible = true;
} | public void setVisible(boolean isVisible) {
if (isVisible)
penColour = (int) Math.abs(penColour);
else
penColour = -(int) (Math.abs(penColour));
<DeepExtract>
if (penColour < 1)
visible = false;
else
visible = true;
</DeepExtract>
} | dxf2svg | positive | 1,783 |
@Test
public void testStoreSportTypeList() throws STException {
SportTypeList sportTypes = storage.readSportTypeList("misc/testdata/sport-types-valid.xml", SPEED_MODE);
storage.storeSportTypeList(sportTypes, SPORTTYPES_WRITETEST_XML);
SportTypeList sportTypesNew = storage.readSportTypeList(SPORTTYPES_WRITETEST_XML, SPEED_MODE);
assertNotNull(sportTypesNew);
assertEquals(sportTypesNew.size(), 2);
SportType type1 = sportTypesNew.getByID(1);
assertEquals(type1.getId(), 1);
assertEquals(type1.getName(), "Cycling");
assertEquals(SpeedMode.SPEED, type1.getSpeedMode());
assertTrue(type1.isRecordDistance());
assertEquals(type1.getIcon(), "cycling.png");
java.awt.Color type1AwtColor = ColorUtils.toAwtColor(type1.getColor());
assertEquals(type1AwtColor.getRed(), 30);
assertEquals(type1AwtColor.getGreen(), 50);
assertEquals(type1AwtColor.getBlue(), 180);
assertEquals(type1.getFitId(), 2);
assertEquals(type1.getSportSubTypeList().size(), 4);
assertEquals(type1.getEquipmentList().size(), 2);
SportSubType subType1_1 = type1.getSportSubTypeList().getByID(1);
assertEquals(subType1_1.getId(), 1);
assertEquals(subType1_1.getName(), "MTB tour");
assertEquals(subType1_1.getFitId(), 8);
SportSubType subType1_2 = type1.getSportSubTypeList().getByID(2);
assertEquals(subType1_2.getId(), 2);
assertEquals(subType1_2.getName(), "MTB race");
assertEquals(subType1_2.getFitId(), 8);
SportSubType subType1_3 = type1.getSportSubTypeList().getByID(3);
assertEquals(subType1_3.getId(), 3);
assertEquals(subType1_3.getName(), "Road tour");
assertEquals(subType1_3.getFitId(), 7);
SportSubType subType1_4 = type1.getSportSubTypeList().getByID(4);
assertEquals(subType1_4.getId(), 4);
assertEquals(subType1_4.getName(), "Road race");
assertEquals(subType1_4.getFitId(), 7);
Equipment equipment1_1 = type1.getEquipmentList().getByID(1);
assertEquals(equipment1_1.getId(), 1);
assertEquals(equipment1_1.getName(), "Cannondale Jekyll");
assertFalse(equipment1_1.isNotInUse());
Equipment equipment1_2 = type1.getEquipmentList().getByID(2);
assertEquals(equipment1_2.getId(), 2);
assertEquals(equipment1_2.getName(), "Cannondale R800");
assertTrue(equipment1_2.isNotInUse());
SportType type2 = sportTypesNew.getByID(2);
assertEquals(type2.getId(), 2);
assertEquals(type2.getName(), "Running");
assertEquals(SpeedMode.PACE, type2.getSpeedMode());
assertFalse(type2.isRecordDistance());
assertEquals(type2.getIcon(), "running.png");
java.awt.Color type2AwtColor = ColorUtils.toAwtColor(type2.getColor());
assertEquals(type2AwtColor.getRed(), 210);
assertEquals(type2AwtColor.getGreen(), 60);
assertEquals(type2AwtColor.getBlue(), 0);
assertNull(type2.getFitId());
assertEquals(type2.getSportSubTypeList().size(), 2);
assertEquals(type2.getEquipmentList().size(), 0);
SportSubType subType2_1 = type2.getSportSubTypeList().getByID(1);
assertEquals(subType2_1.getId(), 1);
assertEquals(subType2_1.getName(), "Jogging");
assertNull(subType2_1.getFitId());
SportSubType subType2_2 = type2.getSportSubTypeList().getByID(2);
assertEquals(subType2_2.getId(), 2);
assertEquals(subType2_2.getName(), "Competition");
assertNull(subType2_2.getFitId());
} | @Test
public void testStoreSportTypeList() throws STException {
SportTypeList sportTypes = storage.readSportTypeList("misc/testdata/sport-types-valid.xml", SPEED_MODE);
storage.storeSportTypeList(sportTypes, SPORTTYPES_WRITETEST_XML);
SportTypeList sportTypesNew = storage.readSportTypeList(SPORTTYPES_WRITETEST_XML, SPEED_MODE);
<DeepExtract>
assertNotNull(sportTypesNew);
assertEquals(sportTypesNew.size(), 2);
SportType type1 = sportTypesNew.getByID(1);
assertEquals(type1.getId(), 1);
assertEquals(type1.getName(), "Cycling");
assertEquals(SpeedMode.SPEED, type1.getSpeedMode());
assertTrue(type1.isRecordDistance());
assertEquals(type1.getIcon(), "cycling.png");
java.awt.Color type1AwtColor = ColorUtils.toAwtColor(type1.getColor());
assertEquals(type1AwtColor.getRed(), 30);
assertEquals(type1AwtColor.getGreen(), 50);
assertEquals(type1AwtColor.getBlue(), 180);
assertEquals(type1.getFitId(), 2);
assertEquals(type1.getSportSubTypeList().size(), 4);
assertEquals(type1.getEquipmentList().size(), 2);
SportSubType subType1_1 = type1.getSportSubTypeList().getByID(1);
assertEquals(subType1_1.getId(), 1);
assertEquals(subType1_1.getName(), "MTB tour");
assertEquals(subType1_1.getFitId(), 8);
SportSubType subType1_2 = type1.getSportSubTypeList().getByID(2);
assertEquals(subType1_2.getId(), 2);
assertEquals(subType1_2.getName(), "MTB race");
assertEquals(subType1_2.getFitId(), 8);
SportSubType subType1_3 = type1.getSportSubTypeList().getByID(3);
assertEquals(subType1_3.getId(), 3);
assertEquals(subType1_3.getName(), "Road tour");
assertEquals(subType1_3.getFitId(), 7);
SportSubType subType1_4 = type1.getSportSubTypeList().getByID(4);
assertEquals(subType1_4.getId(), 4);
assertEquals(subType1_4.getName(), "Road race");
assertEquals(subType1_4.getFitId(), 7);
Equipment equipment1_1 = type1.getEquipmentList().getByID(1);
assertEquals(equipment1_1.getId(), 1);
assertEquals(equipment1_1.getName(), "Cannondale Jekyll");
assertFalse(equipment1_1.isNotInUse());
Equipment equipment1_2 = type1.getEquipmentList().getByID(2);
assertEquals(equipment1_2.getId(), 2);
assertEquals(equipment1_2.getName(), "Cannondale R800");
assertTrue(equipment1_2.isNotInUse());
SportType type2 = sportTypesNew.getByID(2);
assertEquals(type2.getId(), 2);
assertEquals(type2.getName(), "Running");
assertEquals(SpeedMode.PACE, type2.getSpeedMode());
assertFalse(type2.isRecordDistance());
assertEquals(type2.getIcon(), "running.png");
java.awt.Color type2AwtColor = ColorUtils.toAwtColor(type2.getColor());
assertEquals(type2AwtColor.getRed(), 210);
assertEquals(type2AwtColor.getGreen(), 60);
assertEquals(type2AwtColor.getBlue(), 0);
assertNull(type2.getFitId());
assertEquals(type2.getSportSubTypeList().size(), 2);
assertEquals(type2.getEquipmentList().size(), 0);
SportSubType subType2_1 = type2.getSportSubTypeList().getByID(1);
assertEquals(subType2_1.getId(), 1);
assertEquals(subType2_1.getName(), "Jogging");
assertNull(subType2_1.getFitId());
SportSubType subType2_2 = type2.getSportSubTypeList().getByID(2);
assertEquals(subType2_2.getId(), 2);
assertEquals(subType2_2.getName(), "Competition");
assertNull(subType2_2.getFitId());
</DeepExtract>
} | sportstracker | positive | 1,784 |
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
int n = iRead(br);
for (int i = 0; i < n; i++) {
unitSolution(br);
}
} catch (IOException ie) {
ie.printStackTrace();
}
} | public static void main(String[] args) {
<DeepExtract>
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
int n = iRead(br);
for (int i = 0; i < n; i++) {
unitSolution(br);
}
} catch (IOException ie) {
ie.printStackTrace();
}
</DeepExtract>
} | Study-Book | positive | 1,785 |
public Criteria andPAddressNotBetween(String value1, String value2) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + "pAddress" + " cannot be null");
}
criteria.add(new Criterion("p_address not between", value1, value2));
return (Criteria) this;
} | public Criteria andPAddressNotBetween(String value1, String value2) {
<DeepExtract>
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + "pAddress" + " cannot be null");
}
criteria.add(new Criterion("p_address not between", value1, value2));
</DeepExtract>
return (Criteria) this;
} | webike | positive | 1,786 |
@Override
synchronized public Socket accept() throws IOException {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO, "entered accept()");
Socket sock = new Socket();
implAccept(sock);
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO, "Socket connected to client: " + sock.getInetAddress().getHostAddress() + ", port: " + sock.getPort());
socket = new WolfSSLSocket(context, authStore, params, clientMode, sock, true);
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO, "entered setEnableSessionCreation()");
enableSessionCreation = enableSessionCreation;
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO, "enable session creation set to: " + enableSessionCreation);
return socket;
} | @Override
synchronized public Socket accept() throws IOException {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO, "entered accept()");
Socket sock = new Socket();
implAccept(sock);
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO, "Socket connected to client: " + sock.getInetAddress().getHostAddress() + ", port: " + sock.getPort());
socket = new WolfSSLSocket(context, authStore, params, clientMode, sock, true);
<DeepExtract>
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO, "entered setEnableSessionCreation()");
enableSessionCreation = enableSessionCreation;
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO, "enable session creation set to: " + enableSessionCreation);
</DeepExtract>
return socket;
} | wolfssljni | positive | 1,787 |
public static int getBlockSize_Log2() {
final String property = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("prism.marlin.blockSize_log2"));
int value = 5;
if (property != null) {
try {
value = Integer.decode(property);
} catch (NumberFormatException e) {
logInfo("Invalid integer value for " + "prism.marlin.blockSize_log2" + " = " + property);
}
}
if ((value < 3) || (value > 8)) {
logInfo("Invalid value for " + "prism.marlin.blockSize_log2" + " = " + value + "; expected value in range[" + 3 + ", " + 8 + "] !");
value = 5;
}
return value;
} | public static int getBlockSize_Log2() {
<DeepExtract>
final String property = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("prism.marlin.blockSize_log2"));
int value = 5;
if (property != null) {
try {
value = Integer.decode(property);
} catch (NumberFormatException e) {
logInfo("Invalid integer value for " + "prism.marlin.blockSize_log2" + " = " + property);
}
}
if ((value < 3) || (value > 8)) {
logInfo("Invalid value for " + "prism.marlin.blockSize_log2" + " = " + value + "; expected value in range[" + 3 + ", " + 8 + "] !");
value = 5;
}
return value;
</DeepExtract>
} | marlin-fx | positive | 1,788 |
public void crop(final ImagePlus in, final int channel, final ByteProcessor mask, final float[] fwdTransform) {
final ImageProcessor[] inProcessors = new ImageProcessor[in.getStackSize()];
for (int z = 0; z < inProcessors.length; z++) inProcessors[z] = in.getStack().getProcessor(z + 1);
final int wIn = in.getWidth();
final int hIn = in.getHeight();
final int dIn = in.getNSlices();
final int nC = in.getNChannels();
final ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
final int wOut = mask.getWidth();
final int hOut = mask.getHeight();
final int n = dIn;
final AtomicInteger prog = new AtomicInteger(0);
final int ic = channel;
for (int iz = 0; iz < dIn; iz++) {
final int z = iz;
final int c = ic;
final int t = in.getFrame() - 1;
final int stackIndex = in.getStackIndex(c + 1, iz + 1, t + 1);
final ImageProcessor ip = inProcessors[stackIndex - 1];
exec.submit(new Runnable() {
@Override
public void run() {
try {
float[] result = new float[3];
for (int y = 0, xy = 0; y < hIn; y++) {
for (int x = 0; x < wIn; x++, xy++) {
Transform.apply(fwdTransform, x, y, z, result);
if (result[0] < 0 || result[1] < 0 || result[0] >= wOut - 1 || result[1] >= hOut - 1 || mask.getf(Math.round(result[0]), Math.round(result[1])) == 0) {
ip.setf(xy, 0);
continue;
}
}
}
int progress = prog.incrementAndGet();
IJ.showProgress(progress, n);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
IJ.showProgress(1);
exec.shutdown();
try {
exec.awaitTermination(1, TimeUnit.DAYS);
} catch (Exception e) {
e.printStackTrace();
}
this.image = in;
int w = in.getWidth();
int h = in.getHeight();
int d = in.getNSlices();
int nChannels = in.getNChannels();
tIndex = in.getT();
if (w != wIn || h != hIn || d != dIn || nChannels != this.nChannels)
throw new IllegalArgumentException("Image dimensions must remain the same.");
int nSlices = nChannels * d;
if (in.getType() == ImagePlus.GRAY8) {
for (int c = 0, i = 0; c < nChannels; c++) {
byte[][] image = new byte[d][];
for (int z = 0; z < d; z++, i++) {
int idx = in.getStackIndex(c + 1, z + 1, in.getT());
image[z] = (byte[]) in.getStack().getPixels(idx);
if (loadingProgress != null)
loadingProgress.setProgress((double) (i + 1) / nSlices);
}
setTexture8(c, image);
}
} else if (in.getType() == ImagePlus.GRAY16) {
for (int c = 0, i = 0; c < nChannels; c++) {
short[][] image = new short[d][];
for (int z = 0; z < d; z++, i++) {
int idx = in.getStackIndex(c + 1, z + 1, in.getT());
image[z] = (short[]) in.getStack().getPixels(idx);
if (loadingProgress != null)
loadingProgress.setProgress((double) (i + 1) / nSlices);
}
setTexture16(c, image);
}
} else
throw new RuntimeException("Only 8- and 16-bit images are supported");
} | public void crop(final ImagePlus in, final int channel, final ByteProcessor mask, final float[] fwdTransform) {
final ImageProcessor[] inProcessors = new ImageProcessor[in.getStackSize()];
for (int z = 0; z < inProcessors.length; z++) inProcessors[z] = in.getStack().getProcessor(z + 1);
final int wIn = in.getWidth();
final int hIn = in.getHeight();
final int dIn = in.getNSlices();
final int nC = in.getNChannels();
final ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
final int wOut = mask.getWidth();
final int hOut = mask.getHeight();
final int n = dIn;
final AtomicInteger prog = new AtomicInteger(0);
final int ic = channel;
for (int iz = 0; iz < dIn; iz++) {
final int z = iz;
final int c = ic;
final int t = in.getFrame() - 1;
final int stackIndex = in.getStackIndex(c + 1, iz + 1, t + 1);
final ImageProcessor ip = inProcessors[stackIndex - 1];
exec.submit(new Runnable() {
@Override
public void run() {
try {
float[] result = new float[3];
for (int y = 0, xy = 0; y < hIn; y++) {
for (int x = 0; x < wIn; x++, xy++) {
Transform.apply(fwdTransform, x, y, z, result);
if (result[0] < 0 || result[1] < 0 || result[0] >= wOut - 1 || result[1] >= hOut - 1 || mask.getf(Math.round(result[0]), Math.round(result[1])) == 0) {
ip.setf(xy, 0);
continue;
}
}
}
int progress = prog.incrementAndGet();
IJ.showProgress(progress, n);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
IJ.showProgress(1);
exec.shutdown();
try {
exec.awaitTermination(1, TimeUnit.DAYS);
} catch (Exception e) {
e.printStackTrace();
}
<DeepExtract>
this.image = in;
int w = in.getWidth();
int h = in.getHeight();
int d = in.getNSlices();
int nChannels = in.getNChannels();
tIndex = in.getT();
if (w != wIn || h != hIn || d != dIn || nChannels != this.nChannels)
throw new IllegalArgumentException("Image dimensions must remain the same.");
int nSlices = nChannels * d;
if (in.getType() == ImagePlus.GRAY8) {
for (int c = 0, i = 0; c < nChannels; c++) {
byte[][] image = new byte[d][];
for (int z = 0; z < d; z++, i++) {
int idx = in.getStackIndex(c + 1, z + 1, in.getT());
image[z] = (byte[]) in.getStack().getPixels(idx);
if (loadingProgress != null)
loadingProgress.setProgress((double) (i + 1) / nSlices);
}
setTexture8(c, image);
}
} else if (in.getType() == ImagePlus.GRAY16) {
for (int c = 0, i = 0; c < nChannels; c++) {
short[][] image = new short[d][];
for (int z = 0; z < d; z++, i++) {
int idx = in.getStackIndex(c + 1, z + 1, in.getT());
image[z] = (short[]) in.getStack().getPixels(idx);
if (loadingProgress != null)
loadingProgress.setProgress((double) (i + 1) / nSlices);
}
setTexture16(c, image);
}
} else
throw new RuntimeException("Only 8- and 16-bit images are supported");
</DeepExtract>
} | 3Dscript | positive | 1,789 |
@Test
public void testDeletedJobsListException() throws IOException {
Routes.initParams();
req = mock(Request.class);
res = mock(Response.class);
qs = mock(DruidQueryService.class);
ds = mock(DetectorService.class);
jes = mock(JobExecutionService.class);
sf = mock(ServiceFactory.class);
ss = mock(SchedulerService.class);
when(sf.newJobExecutionService()).thenReturn(jes);
when(sf.newDetectorServiceInstance()).thenReturn(ds);
when(sf.newDruidQueryServiceInstance()).thenReturn(qs);
inject("serviceFactory", sf);
tte = mock(ThymeleafTemplateEngine.class);
inject("thymeleaf", tte);
dca = mock(DruidClusterAccessor.class);
inject("clusterAccessor", dca);
jma = mock(JobMetadataAccessor.class);
inject("jobAccessor", jma);
ara = mock(AnomalyReportAccessor.class);
inject("reportAccessor", ara);
ema = mock(EmailMetadataAccessor.class);
inject("emailMetadataAccessor", ema);
@SuppressWarnings("unchecked")
Map<String, Object> dp = (Map<String, Object>) mock(Map.class);
inject("defaultParams", dp);
DeletedJobMetadataAccessor dma = mock(DeletedJobMetadataAccessor.class);
CLISettingsTest.setField(CLISettingsTest.getField("deletedJobAccessor", Routes.class), dma);
when(dma.getDeletedJobMetadataList()).thenThrow(new IOException("exception"));
ModelAndView mav = Routes.viewDeletedJobsList(req, res);
assertTrue(params(mav).containsKey(Constants.ERROR));
} | @Test
public void testDeletedJobsListException() throws IOException {
Routes.initParams();
req = mock(Request.class);
res = mock(Response.class);
qs = mock(DruidQueryService.class);
ds = mock(DetectorService.class);
jes = mock(JobExecutionService.class);
sf = mock(ServiceFactory.class);
ss = mock(SchedulerService.class);
when(sf.newJobExecutionService()).thenReturn(jes);
when(sf.newDetectorServiceInstance()).thenReturn(ds);
when(sf.newDruidQueryServiceInstance()).thenReturn(qs);
inject("serviceFactory", sf);
tte = mock(ThymeleafTemplateEngine.class);
inject("thymeleaf", tte);
dca = mock(DruidClusterAccessor.class);
inject("clusterAccessor", dca);
jma = mock(JobMetadataAccessor.class);
inject("jobAccessor", jma);
ara = mock(AnomalyReportAccessor.class);
inject("reportAccessor", ara);
ema = mock(EmailMetadataAccessor.class);
inject("emailMetadataAccessor", ema);
@SuppressWarnings("unchecked")
Map<String, Object> dp = (Map<String, Object>) mock(Map.class);
inject("defaultParams", dp);
DeletedJobMetadataAccessor dma = mock(DeletedJobMetadataAccessor.class);
<DeepExtract>
CLISettingsTest.setField(CLISettingsTest.getField("deletedJobAccessor", Routes.class), dma);
</DeepExtract>
when(dma.getDeletedJobMetadataList()).thenThrow(new IOException("exception"));
ModelAndView mav = Routes.viewDeletedJobsList(req, res);
assertTrue(params(mav).containsKey(Constants.ERROR));
} | sherlock | positive | 1,790 |
@Override
public long decrementAndGet(byte[] key) {
ByteString keyByteStr = copyFrom(key);
return addAndGet(keyByteStr, -1);
} | @Override
public long decrementAndGet(byte[] key) {
<DeepExtract>
ByteString keyByteStr = copyFrom(key);
return addAndGet(keyByteStr, -1);
</DeepExtract>
} | dkv | positive | 1,791 |
public static void populateSurvey(Survey survey, String string) throws JSONException, ParseException {
JSONObject json = new JSONObject(string);
errors = false;
String name = json.getString(SURVEY_NAME_TAG);
if (!survey.getName().equals(name)) {
Log.e("This is weird; the survey name in the file is different to the filename. " + "Assuming filename is the correct name.");
}
try {
if (json.has(TRIP_TAG)) {
JSONObject tripObject = json.getJSONObject(TRIP_TAG);
Trip trip = toTrip(tripObject);
survey.setTrip(trip);
}
} catch (JSONException exception) {
Log.e("Failed to load trip: " + exception);
}
try {
JSONArray stationsArray = json.getJSONArray(STATIONS_TAG);
loadSurveyData(survey, stationsArray);
} catch (JSONException exception) {
Log.e("Failed to load stations: " + exception);
}
try {
String activeStationName = json.getString(ACTIVE_STATION_TAG);
Station activeStation = survey.getStationByName(activeStationName);
survey.setActiveStation(activeStation);
} catch (Exception ignore) {
}
if (errors) {
String message = "Partial errors encountered; survey load was incomplete";
Toast.makeText(SexyTopo.context, message, Toast.LENGTH_SHORT).show();
}
} | public static void populateSurvey(Survey survey, String string) throws JSONException, ParseException {
JSONObject json = new JSONObject(string);
<DeepExtract>
errors = false;
String name = json.getString(SURVEY_NAME_TAG);
if (!survey.getName().equals(name)) {
Log.e("This is weird; the survey name in the file is different to the filename. " + "Assuming filename is the correct name.");
}
try {
if (json.has(TRIP_TAG)) {
JSONObject tripObject = json.getJSONObject(TRIP_TAG);
Trip trip = toTrip(tripObject);
survey.setTrip(trip);
}
} catch (JSONException exception) {
Log.e("Failed to load trip: " + exception);
}
try {
JSONArray stationsArray = json.getJSONArray(STATIONS_TAG);
loadSurveyData(survey, stationsArray);
} catch (JSONException exception) {
Log.e("Failed to load stations: " + exception);
}
try {
String activeStationName = json.getString(ACTIVE_STATION_TAG);
Station activeStation = survey.getStationByName(activeStationName);
survey.setActiveStation(activeStation);
} catch (Exception ignore) {
}
if (errors) {
String message = "Partial errors encountered; survey load was incomplete";
Toast.makeText(SexyTopo.context, message, Toast.LENGTH_SHORT).show();
}
</DeepExtract>
} | sexytopo | positive | 1,792 |
public void reverseAdd(E obj) {
ListIterator<E> iter = theList.listIterator(theList.size());
while (iter.hasPrevious()) {
if (obj.compareTo(iter.previous()) > 0) {
iter.next();
iter.add(obj);
return;
}
}
ListIterator<E> iter = theList.listIterator();
while (iter.hasNext()) {
if (obj.compareTo(iter.next()) < 0) {
iter.previous();
iter.add(obj);
return;
}
}
iter.add(obj);
} | public void reverseAdd(E obj) {
ListIterator<E> iter = theList.listIterator(theList.size());
while (iter.hasPrevious()) {
if (obj.compareTo(iter.previous()) > 0) {
iter.next();
iter.add(obj);
return;
}
}
<DeepExtract>
ListIterator<E> iter = theList.listIterator();
while (iter.hasNext()) {
if (obj.compareTo(iter.next()) < 0) {
iter.previous();
iter.add(obj);
return;
}
}
iter.add(obj);
</DeepExtract>
} | Data-Structures | positive | 1,793 |
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
presenterLifeCycleLinker.initializeLifeCycle(this, this);
} | @Override
<DeepExtract>
</DeepExtract>
public void onViewCreated(View view, Bundle savedInstanceState) {
<DeepExtract>
</DeepExtract>
super.onViewCreated(view, savedInstanceState);
<DeepExtract>
</DeepExtract>
presenterLifeCycleLinker.initializeLifeCycle(this, this);
<DeepExtract>
</DeepExtract>
} | Rosie | positive | 1,794 |
public static <T extends Enum<?>> T getEnum(final Config config, final String section, final String subsection, final String setting, final T defaultValue) {
T[] all;
try {
all = (T[]) defaultValue.getClass().getMethod("values").invoke(null);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (SecurityException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
}
return getEnum(config, section, subsection, setting, all, defaultValue);
} | public static <T extends Enum<?>> T getEnum(final Config config, final String section, final String subsection, final String setting, final T defaultValue) {
<DeepExtract>
T[] all;
try {
all = (T[]) defaultValue.getClass().getMethod("values").invoke(null);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (SecurityException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
}
</DeepExtract>
return getEnum(config, section, subsection, setting, all, defaultValue);
} | mini-git-server | positive | 1,795 |
@Test
public void testCdcProcessingStatusService() {
testHelper.prepareBinlogEntryHandlerEventAssertion(binlogEntryReader, event -> {
onEventSent(event);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
testHelper.runInSeparateThread(binlogEntryReader::start);
for (int i = 0; i < 3; i++) {
testHelper.saveRandomEvent();
}
CdcProcessingStatusService pollingProcessingStatusService = binlogEntryReader.getCdcProcessingStatusService();
Assert.assertFalse(pollingProcessingStatusService.getCurrentStatus().isCdcProcessingFinished());
Eventually.eventually(60, 500, TimeUnit.MILLISECONDS, () -> Assert.assertTrue(pollingProcessingStatusService.getCurrentStatus().isCdcProcessingFinished()));
binlogEntryReader.stop();
} | @Test
public void testCdcProcessingStatusService() {
testHelper.prepareBinlogEntryHandlerEventAssertion(binlogEntryReader, event -> {
onEventSent(event);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
testHelper.runInSeparateThread(binlogEntryReader::start);
for (int i = 0; i < 3; i++) {
testHelper.saveRandomEvent();
}
CdcProcessingStatusService pollingProcessingStatusService = binlogEntryReader.getCdcProcessingStatusService();
Assert.assertFalse(pollingProcessingStatusService.getCurrentStatus().isCdcProcessingFinished());
Eventually.eventually(60, 500, TimeUnit.MILLISECONDS, () -> Assert.assertTrue(pollingProcessingStatusService.getCurrentStatus().isCdcProcessingFinished()));
<DeepExtract>
binlogEntryReader.stop();
</DeepExtract>
} | eventuate-cdc | positive | 1,796 |
public void visit(OWLSubAnnotationPropertyOfAxiom axiom) {
if (!axiom.getSubProperty().isAnonymous()) {
referencedEntities.add(axiom.getSubProperty().asOWLClass());
}
} | public void visit(OWLSubAnnotationPropertyOfAxiom axiom) {
<DeepExtract>
if (!axiom.getSubProperty().isAnonymous()) {
referencedEntities.add(axiom.getSubProperty().asOWLClass());
}
</DeepExtract>
} | protege-server | positive | 1,797 |
@CheckResult
@NonNull
public static GlideOptions placeholderOf(@Nullable Drawable drawable) {
return (GlideOptions) super.placeholder(drawable);
} | @CheckResult
@NonNull
public static GlideOptions placeholderOf(@Nullable Drawable drawable) {
<DeepExtract>
return (GlideOptions) super.placeholder(drawable);
</DeepExtract>
} | easy_mvp | positive | 1,798 |
@Override
public void saveAutofillDatasets(List<DatasetWithFilledAutofillFields> datasetsWithFilledAutofillFields) {
mAppExecutors.diskIO().execute(() -> {
for (DatasetWithFilledAutofillFields datasetWithFilledAutofillFields : datasetsWithFilledAutofillFields) {
List<FilledAutofillField> filledAutofillFields = datasetWithFilledAutofillFields.filledAutofillFields;
AutofillDataset autofillDataset = datasetWithFilledAutofillFields.autofillDataset;
mAutofillDao.insertAutofillDataset(autofillDataset);
mAutofillDao.insertFilledAutofillFields(filledAutofillFields);
}
});
mSharedPreferences.edit().putInt(DATASET_NUMBER_KEY, getDatasetNumber() + 1).apply();
} | @Override
public void saveAutofillDatasets(List<DatasetWithFilledAutofillFields> datasetsWithFilledAutofillFields) {
mAppExecutors.diskIO().execute(() -> {
for (DatasetWithFilledAutofillFields datasetWithFilledAutofillFields : datasetsWithFilledAutofillFields) {
List<FilledAutofillField> filledAutofillFields = datasetWithFilledAutofillFields.filledAutofillFields;
AutofillDataset autofillDataset = datasetWithFilledAutofillFields.autofillDataset;
mAutofillDao.insertAutofillDataset(autofillDataset);
mAutofillDao.insertFilledAutofillFields(filledAutofillFields);
}
});
<DeepExtract>
mSharedPreferences.edit().putInt(DATASET_NUMBER_KEY, getDatasetNumber() + 1).apply();
</DeepExtract>
} | input-samples | positive | 1,799 |
private void writeIndexBlock(List<SSTablePage> pageList) {
int indexPageCount = 0;
int indexRecordCount = 0;
if (this.indexPage == null) {
this.indexPage = this.indexBlock.newPage();
}
for (SSTablePage page : pageList) {
byte[] pageBytes = toPageRecord(page);
indexRecordCount++;
if (this.indexPage.write(pageBytes) == BUFFER_FULL) {
indexBlock.commit(indexPage);
indexPageCount++;
this.indexPage = this.indexBlock.newPage();
this.indexPage.write(pageBytes);
}
}
indexBlock.commit(indexPage);
indexPageCount++;
System.out.println("Index Pages " + indexPageCount + " Index Record " + indexRecordCount + " Capacity " + indexPage.capacity());
} | private void writeIndexBlock(List<SSTablePage> pageList) {
int indexPageCount = 0;
int indexRecordCount = 0;
<DeepExtract>
if (this.indexPage == null) {
this.indexPage = this.indexBlock.newPage();
}
</DeepExtract>
for (SSTablePage page : pageList) {
byte[] pageBytes = toPageRecord(page);
indexRecordCount++;
if (this.indexPage.write(pageBytes) == BUFFER_FULL) {
indexBlock.commit(indexPage);
indexPageCount++;
this.indexPage = this.indexBlock.newPage();
this.indexPage.write(pageBytes);
}
}
indexBlock.commit(indexPage);
indexPageCount++;
System.out.println("Index Pages " + indexPageCount + " Index Record " + indexRecordCount + " Capacity " + indexPage.capacity());
} | corejava | positive | 1,800 |
@Override
public void paintComponent(Graphics g) {
setOpaque(false);
super.paintComponent(g);
(Graphics2D) g.setColor(fg);
(Graphics2D) g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int wp = (int) (getWidth() * dispProgress), h = getHeight();
Polygon p = new Polygon(new int[] { 0, 0, wp, wp + 30 }, new int[] { 0, h, h, 0 }, 4);
(Graphics2D) g.fill(p);
(Graphics2D) g.setColor(accent);
p = new Polygon(new int[] { wp + 20, wp - 10, wp, wp + 30 }, new int[] { 0, h, h, 0 }, 4);
(Graphics2D) g.fill(p);
} | @Override
public void paintComponent(Graphics g) {
setOpaque(false);
super.paintComponent(g);
<DeepExtract>
(Graphics2D) g.setColor(fg);
(Graphics2D) g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int wp = (int) (getWidth() * dispProgress), h = getHeight();
Polygon p = new Polygon(new int[] { 0, 0, wp, wp + 30 }, new int[] { 0, h, h, 0 }, 4);
(Graphics2D) g.fill(p);
(Graphics2D) g.setColor(accent);
p = new Polygon(new int[] { wp + 20, wp - 10, wp, wp + 30 }, new int[] { 0, h, h, 0 }, 4);
(Graphics2D) g.fill(p);
</DeepExtract>
} | GIFKR | positive | 1,801 |
public Matrix4 toNormalMatrix() {
val[M03] = 0;
val[M13] = 0;
val[M23] = 0;
tmp[M00] = val[M00];
tmp[M01] = val[M10];
tmp[M02] = val[M20];
tmp[M03] = val[M30];
tmp[M10] = val[M01];
tmp[M11] = val[M11];
tmp[M12] = val[M21];
tmp[M13] = val[M31];
tmp[M20] = val[M02];
tmp[M21] = val[M12];
tmp[M22] = val[M22];
tmp[M23] = val[M32];
tmp[M30] = val[M03];
tmp[M31] = val[M13];
tmp[M32] = val[M23];
tmp[M33] = val[M33];
return set(tmp);
} | public Matrix4 toNormalMatrix() {
val[M03] = 0;
val[M13] = 0;
val[M23] = 0;
<DeepExtract>
tmp[M00] = val[M00];
tmp[M01] = val[M10];
tmp[M02] = val[M20];
tmp[M03] = val[M30];
tmp[M10] = val[M01];
tmp[M11] = val[M11];
tmp[M12] = val[M21];
tmp[M13] = val[M31];
tmp[M20] = val[M02];
tmp[M21] = val[M12];
tmp[M22] = val[M22];
tmp[M23] = val[M32];
tmp[M30] = val[M03];
tmp[M31] = val[M13];
tmp[M32] = val[M23];
tmp[M33] = val[M33];
return set(tmp);
</DeepExtract>
} | SCW | positive | 1,802 |
private void launch() {
Location location = player.getLocation();
for (Entity entity : targetentities.keySet()) {
double dx, dy, dz;
Location target = entity.getLocation().clone();
dx = target.getX() - location.getX();
dy = target.getY() - location.getY();
dz = target.getZ() - location.getZ();
Vector vector = new Vector(dx, dy, dz);
vector.normalize();
entity.setVelocity(vector.multiply(factor));
}
if (instances.containsKey(player)) {
instances.remove(player);
}
} | private void launch() {
Location location = player.getLocation();
for (Entity entity : targetentities.keySet()) {
double dx, dy, dz;
Location target = entity.getLocation().clone();
dx = target.getX() - location.getX();
dy = target.getY() - location.getY();
dz = target.getZ() - location.getZ();
Vector vector = new Vector(dx, dy, dz);
vector.normalize();
entity.setVelocity(vector.multiply(factor));
}
<DeepExtract>
if (instances.containsKey(player)) {
instances.remove(player);
}
</DeepExtract>
} | MinecraftTLA | positive | 1,803 |
@Override
public void handleArrowAction(Snipe snipe) {
Block targetBlock = getTargetBlock();
ToolkitProperties toolkitProperties = snipe.getToolkitProperties();
int brushSize = toolkitProperties.getBrushSize();
Painters.sphere().center(targetBlock).radius(brushSize).trueCircle(this.trueCircle).blockSetter(position -> {
Block block = clampY(position);
this.performer.perform(block);
}).paint();
Sniper sniper = snipe.getSniper();
Undo undo = this.performer.getUndo();
sniper.storeUndo(undo);
} | @Override
public void handleArrowAction(Snipe snipe) {
Block targetBlock = getTargetBlock();
<DeepExtract>
ToolkitProperties toolkitProperties = snipe.getToolkitProperties();
int brushSize = toolkitProperties.getBrushSize();
Painters.sphere().center(targetBlock).radius(brushSize).trueCircle(this.trueCircle).blockSetter(position -> {
Block block = clampY(position);
this.performer.perform(block);
}).paint();
Sniper sniper = snipe.getSniper();
Undo undo = this.performer.getUndo();
sniper.storeUndo(undo);
</DeepExtract>
} | FastAsyncVoxelSniper | positive | 1,805 |
@Override
public void setPinData(int pin, int pinMode, int data) {
DataPackage.Builder b = new DataPackage.Builder().setPin(pin).setPinMode(pinMode).setData(data);
switch(pinMode) {
case Common.DUO_PIN_MODE_DIGITAL_WRITE:
b.setCommand("T");
break;
case Common.DUO_PIN_MODE_PWM:
b.setCommand("N");
break;
case Common.DUO_PIN_MODE_SERVO:
b.setCommand("O");
break;
}
String data = gson.toJson(b.build());
Log.e("wifi", "sendData :" + data);
try {
outputStream.write(data.getBytes());
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
}
} | @Override
public void setPinData(int pin, int pinMode, int data) {
DataPackage.Builder b = new DataPackage.Builder().setPin(pin).setPinMode(pinMode).setData(data);
switch(pinMode) {
case Common.DUO_PIN_MODE_DIGITAL_WRITE:
b.setCommand("T");
break;
case Common.DUO_PIN_MODE_PWM:
b.setCommand("N");
break;
case Common.DUO_PIN_MODE_SERVO:
b.setCommand("O");
break;
}
<DeepExtract>
String data = gson.toJson(b.build());
Log.e("wifi", "sendData :" + data);
try {
outputStream.write(data.getBytes());
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
}
</DeepExtract>
} | Duo | positive | 1,806 |
public Criteria andIsLostNotEqualTo(Integer value) {
if (value == null) {
throw new RuntimeException("Value for " + "isLost" + " cannot be null");
}
criteria.add(new Criterion("is_lost <>", value));
return (Criteria) this;
} | public Criteria andIsLostNotEqualTo(Integer value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "isLost" + " cannot be null");
}
criteria.add(new Criterion("is_lost <>", value));
</DeepExtract>
return (Criteria) this;
} | BookLibrarySystem | positive | 1,808 |
public Builder<T> maxLevel(int maxLevel) {
this.maxLevel = maxLevel;
return this;
} | public Builder<T> maxLevel(int maxLevel) {
<DeepExtract>
this.maxLevel = maxLevel;
</DeepExtract>
return this;
} | Zenchantments | positive | 1,809 |
public static int getWorkExecuteMaxAtGivenTime() {
try {
return config.getInt("work.execute.maxAtGivenTime");
} catch (Exception e) {
return 10;
}
} | public static int getWorkExecuteMaxAtGivenTime() {
<DeepExtract>
try {
return config.getInt("work.execute.maxAtGivenTime");
} catch (Exception e) {
return 10;
}
</DeepExtract>
} | Sql4D | positive | 1,811 |
@Test
public void flipPolygonTest() {
Polygon polygon = Polygon.fromPoints(Vector3d.xy(1, 1), Vector3d.xy(2, 1), Vector3d.xy(1, 2));
Assert.assertEquals(Vector3d.z(1).getX(), polygon.getPlane().getNormal().getX(), EPSILON);
Assert.assertEquals(Vector3d.z(1).getY(), polygon.getPlane().getNormal().getY(), EPSILON);
Assert.assertEquals(Vector3d.z(1).getZ(), polygon.getPlane().getNormal().getZ(), EPSILON);
polygon.flip();
Assert.assertEquals(Vector3d.z(-1).getX(), polygon.getPlane().getNormal().getX(), EPSILON);
Assert.assertEquals(Vector3d.z(-1).getY(), polygon.getPlane().getNormal().getY(), EPSILON);
Assert.assertEquals(Vector3d.z(-1).getZ(), polygon.getPlane().getNormal().getZ(), EPSILON);
} | @Test
public void flipPolygonTest() {
Polygon polygon = Polygon.fromPoints(Vector3d.xy(1, 1), Vector3d.xy(2, 1), Vector3d.xy(1, 2));
Assert.assertEquals(Vector3d.z(1).getX(), polygon.getPlane().getNormal().getX(), EPSILON);
Assert.assertEquals(Vector3d.z(1).getY(), polygon.getPlane().getNormal().getY(), EPSILON);
Assert.assertEquals(Vector3d.z(1).getZ(), polygon.getPlane().getNormal().getZ(), EPSILON);
polygon.flip();
<DeepExtract>
Assert.assertEquals(Vector3d.z(-1).getX(), polygon.getPlane().getNormal().getX(), EPSILON);
Assert.assertEquals(Vector3d.z(-1).getY(), polygon.getPlane().getNormal().getY(), EPSILON);
Assert.assertEquals(Vector3d.z(-1).getZ(), polygon.getPlane().getNormal().getZ(), EPSILON);
</DeepExtract>
} | JCSG | positive | 1,812 |
private static void analysisSocial(String sampleDir, String sampleName, String networkFilename, String type, Integer granularity) {
if (TOPIC_NAME != null) {
sampleName += ("_" + TOPIC_NAME);
}
BookmarkReader trainReader = new BookmarkReader(-1, false);
trainReader.readFile(sampleName + "_train");
TRAIN_SIZE = trainReader.getBookmarks().size();
System.out.println("Train-size: " + TRAIN_SIZE);
BookmarkReader testReader = new BookmarkReader(-1, false);
testReader.readFile(sampleName + "_test");
TEST_SIZE = testReader.getBookmarks().size();
System.out.println("Test-size: " + TEST_SIZE);
HashtagRecommendationEngine calculator = new HashtagRecommendationEngine(sampleDir, sampleName, networkFilename, TRAIN_SIZE, TEST_SIZE, 0.5, null);
if (type.equals("social")) {
new ProcessFrequencyRecencySocial(sampleDir, calculator.getUserTagTimes(), calculator.getNetwork(), granularity);
} else if (type.equals("personal")) {
new ProcessFrequencyRecency().ProcessTagAnalytics(sampleDir, calculator.getUserTagTimes(), granularity);
} else if (type.equals("all")) {
new ProcessFrequencyRecency().ProcessTagAnalytics(sampleDir, calculator.getUserTagTimes(), granularity);
new ProcessFrequencyRecencySocial(sampleDir, calculator.getUserTagTimes(), calculator.getNetwork(), granularity);
}
} | private static void analysisSocial(String sampleDir, String sampleName, String networkFilename, String type, Integer granularity) {
<DeepExtract>
if (TOPIC_NAME != null) {
sampleName += ("_" + TOPIC_NAME);
}
BookmarkReader trainReader = new BookmarkReader(-1, false);
trainReader.readFile(sampleName + "_train");
TRAIN_SIZE = trainReader.getBookmarks().size();
System.out.println("Train-size: " + TRAIN_SIZE);
BookmarkReader testReader = new BookmarkReader(-1, false);
testReader.readFile(sampleName + "_test");
TEST_SIZE = testReader.getBookmarks().size();
System.out.println("Test-size: " + TEST_SIZE);
</DeepExtract>
HashtagRecommendationEngine calculator = new HashtagRecommendationEngine(sampleDir, sampleName, networkFilename, TRAIN_SIZE, TEST_SIZE, 0.5, null);
if (type.equals("social")) {
new ProcessFrequencyRecencySocial(sampleDir, calculator.getUserTagTimes(), calculator.getNetwork(), granularity);
} else if (type.equals("personal")) {
new ProcessFrequencyRecency().ProcessTagAnalytics(sampleDir, calculator.getUserTagTimes(), granularity);
} else if (type.equals("all")) {
new ProcessFrequencyRecency().ProcessTagAnalytics(sampleDir, calculator.getUserTagTimes(), granularity);
new ProcessFrequencyRecencySocial(sampleDir, calculator.getUserTagTimes(), calculator.getNetwork(), granularity);
}
} | TagRec | positive | 1,813 |
public Criteria andContentIn(List<String> values) {
if (values == null) {
throw new RuntimeException("Value for " + "content" + " cannot be null");
}
criteria.add(new Criterion("content in", values));
return (Criteria) this;
} | public Criteria andContentIn(List<String> values) {
<DeepExtract>
if (values == null) {
throw new RuntimeException("Value for " + "content" + " cannot be null");
}
criteria.add(new Criterion("content in", values));
</DeepExtract>
return (Criteria) this;
} | webim | positive | 1,814 |
protected Edge parseEdge(StringTokenizer tokenizer, int vertexId) {
int neighborId = Integer.parseInt(tokenizer.nextToken());
int neighborIdx = neighborId;
if (isEdgeLabelled) {
int edgeLabel = Integer.parseInt(tokenizer.nextToken());
edge = createEdge(vertexId, neighborIdx, edgeLabel);
} else {
edge = createEdge(vertexId, neighborIdx);
}
if (edge.getSourceId() > edge.getDestinationId()) {
return this;
}
if (edge.getEdgeId() == -1) {
edge.setEdgeId(numEdges);
}
if (edge.getEdgeId() == numEdges) {
ensureCanStoreNewEdge();
++numEdges;
} else if (edge.getEdgeId() > numEdges) {
throw new RuntimeException("Sanity check, edge with id " + edge.getEdgeId() + " added at position " + numEdges);
}
ensureCanStoreUpToVertex(Math.max(edge.getSourceId(), edge.getDestinationId()));
edgeIndexF[edge.getEdgeId()] = edge;
try {
VertexNeighbourhood vertexNeighbourhood = vertexNeighborhoods[edge.getSourceId()];
if (vertexNeighbourhood == null) {
vertexNeighbourhood = createVertexNeighbourhood();
vertexNeighborhoods[edge.getSourceId()] = vertexNeighbourhood;
}
vertexNeighbourhood.addEdge(edge.getDestinationId(), edge.getEdgeId());
} catch (ArrayIndexOutOfBoundsException e) {
LOG.error("Tried to access index " + edge.getSourceId() + " of array with size " + vertexNeighborhoods.length);
LOG.error("vertexIndexF.length=" + vertexIndexF.length);
LOG.error("vertexNeighborhoods.length=" + vertexNeighborhoods.length);
throw e;
}
try {
VertexNeighbourhood vertexNeighbourhood = vertexNeighborhoods[edge.getDestinationId()];
if (vertexNeighbourhood == null) {
vertexNeighbourhood = createVertexNeighbourhood();
vertexNeighborhoods[edge.getDestinationId()] = vertexNeighbourhood;
}
vertexNeighbourhood.addEdge(edge.getSourceId(), edge.getEdgeId());
} catch (ArrayIndexOutOfBoundsException e) {
LOG.error("Tried to access index " + edge.getDestinationId() + " of array with size " + vertexNeighborhoods.length);
LOG.error("vertexIndexF.length=" + vertexIndexF.length);
LOG.error("vertexNeighborhoods.length=" + vertexNeighborhoods.length);
throw e;
}
return this;
return edge;
} | protected Edge parseEdge(StringTokenizer tokenizer, int vertexId) {
int neighborId = Integer.parseInt(tokenizer.nextToken());
int neighborIdx = neighborId;
if (isEdgeLabelled) {
int edgeLabel = Integer.parseInt(tokenizer.nextToken());
edge = createEdge(vertexId, neighborIdx, edgeLabel);
} else {
edge = createEdge(vertexId, neighborIdx);
}
<DeepExtract>
if (edge.getSourceId() > edge.getDestinationId()) {
return this;
}
if (edge.getEdgeId() == -1) {
edge.setEdgeId(numEdges);
}
if (edge.getEdgeId() == numEdges) {
ensureCanStoreNewEdge();
++numEdges;
} else if (edge.getEdgeId() > numEdges) {
throw new RuntimeException("Sanity check, edge with id " + edge.getEdgeId() + " added at position " + numEdges);
}
ensureCanStoreUpToVertex(Math.max(edge.getSourceId(), edge.getDestinationId()));
edgeIndexF[edge.getEdgeId()] = edge;
try {
VertexNeighbourhood vertexNeighbourhood = vertexNeighborhoods[edge.getSourceId()];
if (vertexNeighbourhood == null) {
vertexNeighbourhood = createVertexNeighbourhood();
vertexNeighborhoods[edge.getSourceId()] = vertexNeighbourhood;
}
vertexNeighbourhood.addEdge(edge.getDestinationId(), edge.getEdgeId());
} catch (ArrayIndexOutOfBoundsException e) {
LOG.error("Tried to access index " + edge.getSourceId() + " of array with size " + vertexNeighborhoods.length);
LOG.error("vertexIndexF.length=" + vertexIndexF.length);
LOG.error("vertexNeighborhoods.length=" + vertexNeighborhoods.length);
throw e;
}
try {
VertexNeighbourhood vertexNeighbourhood = vertexNeighborhoods[edge.getDestinationId()];
if (vertexNeighbourhood == null) {
vertexNeighbourhood = createVertexNeighbourhood();
vertexNeighborhoods[edge.getDestinationId()] = vertexNeighbourhood;
}
vertexNeighbourhood.addEdge(edge.getSourceId(), edge.getEdgeId());
} catch (ArrayIndexOutOfBoundsException e) {
LOG.error("Tried to access index " + edge.getDestinationId() + " of array with size " + vertexNeighborhoods.length);
LOG.error("vertexIndexF.length=" + vertexIndexF.length);
LOG.error("vertexNeighborhoods.length=" + vertexNeighborhoods.length);
throw e;
}
return this;
</DeepExtract>
return edge;
} | fractal | positive | 1,815 |
private void ALU8BitXor(int value) {
reg_F = 0;
reg_A = reg_A ^ value;
if ((reg_A & 0x0080) != 0)
setS();
else
resetS();
if (reg_A == 0)
setZ();
else
resetZ();
if (PARITY_TABLE[reg_A])
setPV();
else
resetPV();
reg_A = reg_A & 0x28;
reg_F = reg_F & 0xD7;
reg_F = reg_F | reg_A;
} | private void ALU8BitXor(int value) {
reg_F = 0;
reg_A = reg_A ^ value;
if ((reg_A & 0x0080) != 0)
setS();
else
resetS();
if (reg_A == 0)
setZ();
else
resetZ();
if (PARITY_TABLE[reg_A])
setPV();
else
resetPV();
<DeepExtract>
reg_A = reg_A & 0x28;
reg_F = reg_F & 0xD7;
reg_F = reg_F | reg_A;
</DeepExtract>
} | mdlz80optimizer | positive | 1,816 |
@Override
public void initData() {
this.room = uid;
LogUtils.d("room");
anchorInfoFragment.onUpdateAnchor(uid);
viewPagerFragmentAdapter.notifyDataSetChanged();
} | @Override
public void initData() {
<DeepExtract>
this.room = uid;
LogUtils.d("room");
anchorInfoFragment.onUpdateAnchor(uid);
viewPagerFragmentAdapter.notifyDataSetChanged();
</DeepExtract>
} | KingTV | positive | 1,817 |
public List<InputMethodSubtype> getMyEnabledInputMethodSubtypeList(boolean allowsImplicitlySelectedSubtypes) {
final HashMap<InputMethodInfo, List<InputMethodSubtype>> cache = allowsImplicitlySelectedSubtypes ? mCachedSubtypeListWithImplicitlySelected : mCachedSubtypeListOnlyExplicitlySelected;
final List<InputMethodSubtype> cachedList = cache.get(getInputMethodInfoOfThisIme());
if (cachedList != null) {
return cachedList;
}
final List<InputMethodSubtype> result = mImm.getEnabledInputMethodSubtypeList(getInputMethodInfoOfThisIme(), allowsImplicitlySelectedSubtypes);
cache.put(getInputMethodInfoOfThisIme(), result);
return result;
} | public List<InputMethodSubtype> getMyEnabledInputMethodSubtypeList(boolean allowsImplicitlySelectedSubtypes) {
<DeepExtract>
final HashMap<InputMethodInfo, List<InputMethodSubtype>> cache = allowsImplicitlySelectedSubtypes ? mCachedSubtypeListWithImplicitlySelected : mCachedSubtypeListOnlyExplicitlySelected;
final List<InputMethodSubtype> cachedList = cache.get(getInputMethodInfoOfThisIme());
if (cachedList != null) {
return cachedList;
}
final List<InputMethodSubtype> result = mImm.getEnabledInputMethodSubtypeList(getInputMethodInfoOfThisIme(), allowsImplicitlySelectedSubtypes);
cache.put(getInputMethodInfoOfThisIme(), result);
return result;
</DeepExtract>
} | LokiBoard-Android-Keylogger | positive | 1,818 |
@Override
public void onClick(DialogInterface dialog, int whichButton) {
mAccountDb.delete(user);
ArrayList<String> usernames = new ArrayList<String>();
mAccountDb.getNames(usernames);
int userCount = usernames.size();
if (userCount > 0) {
boolean newListRequired = true || mUsers.length != userCount;
if (newListRequired) {
mUsers = new PinInfo[userCount];
}
for (int i = 0; i < userCount; ++i) {
String user = usernames.get(i);
try {
computeAndDisplayPin(user, i, false);
} catch (OtpSourceException ignored) {
}
}
if (newListRequired) {
mUserAdapter = new PinListAdapter(this, R.layout.user_row, mUsers);
mUserList.setAdapter(mUserAdapter);
}
mUserAdapter.notifyDataSetChanged();
if (mUserList.getVisibility() != View.VISIBLE) {
mUserList.setVisibility(View.VISIBLE);
registerForContextMenu(mUserList);
}
} else {
mUsers = new PinInfo[0];
mUserList.setVisibility(View.GONE);
}
mContentNoAccounts.setVisibility((mUsers.length > 0) ? View.GONE : View.VISIBLE);
mContentAccountsPresent.setVisibility((mUsers.length > 0) ? View.VISIBLE : View.GONE);
} | @Override
public void onClick(DialogInterface dialog, int whichButton) {
mAccountDb.delete(user);
<DeepExtract>
ArrayList<String> usernames = new ArrayList<String>();
mAccountDb.getNames(usernames);
int userCount = usernames.size();
if (userCount > 0) {
boolean newListRequired = true || mUsers.length != userCount;
if (newListRequired) {
mUsers = new PinInfo[userCount];
}
for (int i = 0; i < userCount; ++i) {
String user = usernames.get(i);
try {
computeAndDisplayPin(user, i, false);
} catch (OtpSourceException ignored) {
}
}
if (newListRequired) {
mUserAdapter = new PinListAdapter(this, R.layout.user_row, mUsers);
mUserList.setAdapter(mUserAdapter);
}
mUserAdapter.notifyDataSetChanged();
if (mUserList.getVisibility() != View.VISIBLE) {
mUserList.setVisibility(View.VISIBLE);
registerForContextMenu(mUserList);
}
} else {
mUsers = new PinInfo[0];
mUserList.setVisibility(View.GONE);
}
mContentNoAccounts.setVisibility((mUsers.length > 0) ? View.GONE : View.VISIBLE);
mContentAccountsPresent.setVisibility((mUsers.length > 0) ? View.VISIBLE : View.GONE);
</DeepExtract>
} | glassauth | positive | 1,819 |
public List<InvestmentSummary> getAllInvestments() {
Configuration configuration = new Configuration();
configuration.configure();
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
SessionFactory sessionfactory = configuration.buildSessionFactory(builder.build());
return sessionfactory;
Session session = sessionFactory.openSession();
session.beginTransaction();
Query queryResult = null;
if (accountNumber != "") {
queryResult = session.createQuery("from InvestmentSummary where accountNumber = :accNum");
queryResult.setParameter("accNum", accountNumber);
} else {
queryResult = session.createQuery("from InvestmentSummary");
}
List<InvestmentSummary> allInvestments = queryResult.list();
session.getTransaction().commit();
return allInvestments;
} | public List<InvestmentSummary> getAllInvestments() {
<DeepExtract>
Configuration configuration = new Configuration();
configuration.configure();
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
SessionFactory sessionfactory = configuration.buildSessionFactory(builder.build());
return sessionfactory;
</DeepExtract>
Session session = sessionFactory.openSession();
session.beginTransaction();
Query queryResult = null;
if (accountNumber != "") {
queryResult = session.createQuery("from InvestmentSummary where accountNumber = :accNum");
queryResult.setParameter("accNum", accountNumber);
} else {
queryResult = session.createQuery("from InvestmentSummary");
}
List<InvestmentSummary> allInvestments = queryResult.list();
session.getTransaction().commit();
return allInvestments;
} | primefaces-blueprints | positive | 1,820 |
@Override
public void onClick(View v) {
dismiss();
} | @Override
public void onClick(View v) {
<DeepExtract>
dismiss();
</DeepExtract>
} | rich-text-android | positive | 1,821 |
private void handleException(DvbException e) {
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
Collection<UsbDevice> availableDevices = manager.getDeviceList().values();
int[] productIds = new int[availableDevices.size()];
int[] vendorIds = new int[availableDevices.size()];
int id = 0;
for (UsbDevice usbDevice : availableDevices) {
productIds[id] = usbDevice.getProductId();
vendorIds[id] = usbDevice.getVendorId();
id++;
}
response.putExtra(CONTRACT_ERROR_CODE, e.getErrorCode().name());
response.putExtra(CONTRACT_RAW_TRACE, StackTraceSerializer.serialize(e));
response.putExtra(CONTRACT_USB_PRODUCT_IDS, productIds);
response.putExtra(CONTRACT_USB_VENDOR_IDS, vendorIds);
if (getParent() == null) {
setResult(RESULT_ERROR, response);
} else {
getParent().setResult(RESULT_ERROR, response);
}
finish();
} | private void handleException(DvbException e) {
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
Collection<UsbDevice> availableDevices = manager.getDeviceList().values();
int[] productIds = new int[availableDevices.size()];
int[] vendorIds = new int[availableDevices.size()];
int id = 0;
for (UsbDevice usbDevice : availableDevices) {
productIds[id] = usbDevice.getProductId();
vendorIds[id] = usbDevice.getVendorId();
id++;
}
response.putExtra(CONTRACT_ERROR_CODE, e.getErrorCode().name());
response.putExtra(CONTRACT_RAW_TRACE, StackTraceSerializer.serialize(e));
response.putExtra(CONTRACT_USB_PRODUCT_IDS, productIds);
response.putExtra(CONTRACT_USB_VENDOR_IDS, vendorIds);
<DeepExtract>
if (getParent() == null) {
setResult(RESULT_ERROR, response);
} else {
getParent().setResult(RESULT_ERROR, response);
}
finish();
</DeepExtract>
} | AndroidDvbDriver | positive | 1,822 |
public static void putWikiPage(@NonNull CloseableHttpClient httpclient, @NonNull String pagename, String content, @NonNull HashMap<String, String> formfields) throws Exception {
if (!formfields.containsKey("token")) {
throw new WikiException(R.string.wiki_error_protected);
}
HttpPost httppost = new HttpPost(WIKI_API_URL);
ArrayList<NameValuePair> nvps = new ArrayList<>();
nvps.add(new BasicNameValuePair("action", "edit"));
nvps.add(new BasicNameValuePair("title", pagename));
nvps.add(new BasicNameValuePair("text", content));
nvps.add(new BasicNameValuePair("format", "xml"));
for (String s : formfields.keySet()) {
nvps.add(new BasicNameValuePair(s, formfields.get(s)));
}
httppost.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
WikiResponse toReturn = new WikiResponse();
toReturn.document = getHttpDocument(httpclient, httppost);
toReturn.rootElem = toReturn.document.getDocumentElement();
if (doesResponseHaveError(toReturn.rootElem)) {
throw new WikiException(getErrorTextId(findErrorCode(toReturn.rootElem)));
}
return toReturn;
} | public static void putWikiPage(@NonNull CloseableHttpClient httpclient, @NonNull String pagename, String content, @NonNull HashMap<String, String> formfields) throws Exception {
if (!formfields.containsKey("token")) {
throw new WikiException(R.string.wiki_error_protected);
}
HttpPost httppost = new HttpPost(WIKI_API_URL);
ArrayList<NameValuePair> nvps = new ArrayList<>();
nvps.add(new BasicNameValuePair("action", "edit"));
nvps.add(new BasicNameValuePair("title", pagename));
nvps.add(new BasicNameValuePair("text", content));
nvps.add(new BasicNameValuePair("format", "xml"));
for (String s : formfields.keySet()) {
nvps.add(new BasicNameValuePair(s, formfields.get(s)));
}
httppost.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
<DeepExtract>
WikiResponse toReturn = new WikiResponse();
toReturn.document = getHttpDocument(httpclient, httppost);
toReturn.rootElem = toReturn.document.getDocumentElement();
if (doesResponseHaveError(toReturn.rootElem)) {
throw new WikiException(getErrorTextId(findErrorCode(toReturn.rootElem)));
}
return toReturn;
</DeepExtract>
} | geohashdroid | positive | 1,823 |
private FileVertex makeFile(final FramedGraph graph, String name) {
final VertexType vertex = graph.addFramedVertex(FileVertex.class);
vertex.setName(name);
return vertex;
} | private FileVertex makeFile(final FramedGraph graph, String name) {
<DeepExtract>
final VertexType vertex = graph.addFramedVertex(FileVertex.class);
vertex.setName(name);
return vertex;
</DeepExtract>
} | Ferma | positive | 1,824 |
public void handleControlKey(boolean down) {
if (down) {
mControlKey.onPress();
} else {
mControlKey.onRelease();
}
mCursorMode = getCursorModeHelper(mCapKey, TextRenderer.MODE_SHIFT_SHIFT) | getCursorModeHelper(mAltKey, TextRenderer.MODE_ALT_SHIFT) | getCursorModeHelper(mControlKey, TextRenderer.MODE_CTRL_SHIFT) | getCursorModeHelper(mFnKey, TextRenderer.MODE_FN_SHIFT);
} | public void handleControlKey(boolean down) {
if (down) {
mControlKey.onPress();
} else {
mControlKey.onRelease();
}
<DeepExtract>
mCursorMode = getCursorModeHelper(mCapKey, TextRenderer.MODE_SHIFT_SHIFT) | getCursorModeHelper(mAltKey, TextRenderer.MODE_ALT_SHIFT) | getCursorModeHelper(mControlKey, TextRenderer.MODE_CTRL_SHIFT) | getCursorModeHelper(mFnKey, TextRenderer.MODE_FN_SHIFT);
</DeepExtract>
} | FloatingTerminalEmulator-Android | positive | 1,825 |
@Override
public void setQueryID(String queryID) {
this.queryID = queryID;
resultPreAnnotation.put("queryId", queryID);
} | @Override
public void setQueryID(String queryID) {
this.queryID = queryID;
<DeepExtract>
resultPreAnnotation.put("queryId", queryID);
</DeepExtract>
} | BlastGraph | positive | 1,827 |
public void visit_FLOAT_FLOOR(Instruction instr, PcodeOp pcode) throws VisitorUnimplementedException {
TVLBitVector result = new TVLBitVector(new GhidraSizeAdapter(pcode.getOutput().getSize()));
AbstractState.Associate(pcode.getOutput(), result);
} | public void visit_FLOAT_FLOOR(Instruction instr, PcodeOp pcode) throws VisitorUnimplementedException {
<DeepExtract>
TVLBitVector result = new TVLBitVector(new GhidraSizeAdapter(pcode.getOutput().getSize()));
AbstractState.Associate(pcode.getOutput(), result);
</DeepExtract>
} | GhidraPAL | positive | 1,828 |
public synchronized void setRecentlyViewed(final List<? extends DictEntry> notepadItems) {
if (!prefs.edit().putString(KEY_RECENTLY_VIEWED_ITEMS, DictEntry.toExternalList(notepadItems)).commit()) {
throw new IllegalStateException("Failed to commit new SharedPreferences value");
}
} | public synchronized void setRecentlyViewed(final List<? extends DictEntry> notepadItems) {
<DeepExtract>
if (!prefs.edit().putString(KEY_RECENTLY_VIEWED_ITEMS, DictEntry.toExternalList(notepadItems)).commit()) {
throw new IllegalStateException("Failed to commit new SharedPreferences value");
}
</DeepExtract>
} | aedict | positive | 1,829 |
public Criteria andBz112GreaterThanOrEqualTo(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "bz112" + " cannot be null");
}
criteria.add(new Criterion("`bz112` >=", value));
return (Criteria) this;
} | public Criteria andBz112GreaterThanOrEqualTo(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "bz112" + " cannot be null");
}
criteria.add(new Criterion("`bz112` >=", value));
</DeepExtract>
return (Criteria) this;
} | blockhealth | positive | 1,830 |
private int readFrame(int stackMap, boolean zip, boolean unzip, Context frame) {
char[] c = frame.buffer;
Label[] labels = frame.labels;
if (zip) {
tag = b[stackMap++] & 0xFF;
} else {
tag = MethodWriter.FULL_FRAME;
frame.offset = -1;
}
frame.localDiff = 0;
if (tag < MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME) {
delta = tag;
frame.mode = Opcodes.F_SAME;
frame.stackCount = 0;
} else if (tag < MethodWriter.RESERVED) {
delta = tag - MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME;
stackMap = readFrameType(frame.stack, 0, stackMap, c, labels);
frame.mode = Opcodes.F_SAME1;
frame.stackCount = 1;
} else {
delta = readUnsignedShort(stackMap);
stackMap += 2;
if (tag == MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
stackMap = readFrameType(frame.stack, 0, stackMap, c, labels);
frame.mode = Opcodes.F_SAME1;
frame.stackCount = 1;
} else if (tag >= MethodWriter.CHOP_FRAME && tag < MethodWriter.SAME_FRAME_EXTENDED) {
frame.mode = Opcodes.F_CHOP;
frame.localDiff = MethodWriter.SAME_FRAME_EXTENDED - tag;
frame.localCount -= frame.localDiff;
frame.stackCount = 0;
} else if (tag == MethodWriter.SAME_FRAME_EXTENDED) {
frame.mode = Opcodes.F_SAME;
frame.stackCount = 0;
} else if (tag < MethodWriter.FULL_FRAME) {
int local = unzip ? frame.localCount : 0;
for (int i = tag - MethodWriter.SAME_FRAME_EXTENDED; i > 0; i--) {
stackMap = readFrameType(frame.local, local++, stackMap, c, labels);
}
frame.mode = Opcodes.F_APPEND;
frame.localDiff = tag - MethodWriter.SAME_FRAME_EXTENDED;
frame.localCount += frame.localDiff;
frame.stackCount = 0;
} else {
frame.mode = Opcodes.F_FULL;
int n = readUnsignedShort(stackMap);
stackMap += 2;
frame.localDiff = n;
frame.localCount = n;
for (int local = 0; n > 0; n--) {
stackMap = readFrameType(frame.local, local++, stackMap, c, labels);
}
n = readUnsignedShort(stackMap);
stackMap += 2;
frame.stackCount = n;
for (int stack = 0; n > 0; n--) {
stackMap = readFrameType(frame.stack, stack++, stackMap, c, labels);
}
}
}
frame.offset += delta + 1;
if (frame.offset >= labels.length) {
return new Label();
}
if (labels[frame.offset] == null) {
labels[frame.offset] = new Label();
}
return labels[frame.offset];
return stackMap;
} | private int readFrame(int stackMap, boolean zip, boolean unzip, Context frame) {
char[] c = frame.buffer;
Label[] labels = frame.labels;
if (zip) {
tag = b[stackMap++] & 0xFF;
} else {
tag = MethodWriter.FULL_FRAME;
frame.offset = -1;
}
frame.localDiff = 0;
if (tag < MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME) {
delta = tag;
frame.mode = Opcodes.F_SAME;
frame.stackCount = 0;
} else if (tag < MethodWriter.RESERVED) {
delta = tag - MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME;
stackMap = readFrameType(frame.stack, 0, stackMap, c, labels);
frame.mode = Opcodes.F_SAME1;
frame.stackCount = 1;
} else {
delta = readUnsignedShort(stackMap);
stackMap += 2;
if (tag == MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
stackMap = readFrameType(frame.stack, 0, stackMap, c, labels);
frame.mode = Opcodes.F_SAME1;
frame.stackCount = 1;
} else if (tag >= MethodWriter.CHOP_FRAME && tag < MethodWriter.SAME_FRAME_EXTENDED) {
frame.mode = Opcodes.F_CHOP;
frame.localDiff = MethodWriter.SAME_FRAME_EXTENDED - tag;
frame.localCount -= frame.localDiff;
frame.stackCount = 0;
} else if (tag == MethodWriter.SAME_FRAME_EXTENDED) {
frame.mode = Opcodes.F_SAME;
frame.stackCount = 0;
} else if (tag < MethodWriter.FULL_FRAME) {
int local = unzip ? frame.localCount : 0;
for (int i = tag - MethodWriter.SAME_FRAME_EXTENDED; i > 0; i--) {
stackMap = readFrameType(frame.local, local++, stackMap, c, labels);
}
frame.mode = Opcodes.F_APPEND;
frame.localDiff = tag - MethodWriter.SAME_FRAME_EXTENDED;
frame.localCount += frame.localDiff;
frame.stackCount = 0;
} else {
frame.mode = Opcodes.F_FULL;
int n = readUnsignedShort(stackMap);
stackMap += 2;
frame.localDiff = n;
frame.localCount = n;
for (int local = 0; n > 0; n--) {
stackMap = readFrameType(frame.local, local++, stackMap, c, labels);
}
n = readUnsignedShort(stackMap);
stackMap += 2;
frame.stackCount = n;
for (int stack = 0; n > 0; n--) {
stackMap = readFrameType(frame.stack, stack++, stackMap, c, labels);
}
}
}
frame.offset += delta + 1;
<DeepExtract>
if (frame.offset >= labels.length) {
return new Label();
}
if (labels[frame.offset] == null) {
labels[frame.offset] = new Label();
}
return labels[frame.offset];
</DeepExtract>
return stackMap;
} | qiuyj-code | positive | 1,831 |
public AuthTokenVO mapRefreshToken(RefreshTokenEntity refreshToken) {
String clientId = refreshToken.getClientId();
Long authHolderId = refreshToken.getAuthHolderId();
AuthTokenVO tokenVO = new AuthTokenVO();
BeanUtils.copyProperties(refreshToken, tokenVO);
if (clientId != null) {
tokenVO.setClientName(clientId);
}
if (authHolderId != null) {
tokenVO.setUserName(authHolderService.getUserNameByHolderId(authHolderId));
}
return tokenVO;
} | public AuthTokenVO mapRefreshToken(RefreshTokenEntity refreshToken) {
String clientId = refreshToken.getClientId();
Long authHolderId = refreshToken.getAuthHolderId();
<DeepExtract>
AuthTokenVO tokenVO = new AuthTokenVO();
BeanUtils.copyProperties(refreshToken, tokenVO);
if (clientId != null) {
tokenVO.setClientName(clientId);
}
if (authHolderId != null) {
tokenVO.setUserName(authHolderService.getUserNameByHolderId(authHolderId));
}
return tokenVO;
</DeepExtract>
} | pauth | positive | 1,832 |
public boolean accept(File k) {
if (!k.getAbsolutePath().endsWith(".html"))
return;
String s = getFile(k);
doOneFileStr(s);
return false;
} | public boolean accept(File k) {
<DeepExtract>
if (!k.getAbsolutePath().endsWith(".html"))
return;
String s = getFile(k);
doOneFileStr(s);
</DeepExtract>
return false;
} | MTX_HackerTools | positive | 1,833 |
public static void main(String[] args) {
RuntimeContext.put("name", "Value");
ExecutorService threadPool = Executors.newFixedThreadPool(3);
threadPool.submit(new CallableTask());
} | public static void main(String[] args) {
RuntimeContext.put("name", "Value");
<DeepExtract>
ExecutorService threadPool = Executors.newFixedThreadPool(3);
threadPool.submit(new CallableTask());
</DeepExtract>
} | talos | positive | 1,834 |
@Override
public Long component9() {
return (Long) get(8);
} | @Override
public Long component9() {
<DeepExtract>
return (Long) get(8);
</DeepExtract>
} | wdumper | positive | 1,835 |
public static void setFirstMsgSent(Context context, Boolean flag) {
SharedPreferences.Editor editor = sharedPreferences(context).edit();
editor.putBoolean(IS_FIRST_MSG_SENT, flag);
editor.commit();
} | public static void setFirstMsgSent(Context context, Boolean flag) {
<DeepExtract>
SharedPreferences.Editor editor = sharedPreferences(context).edit();
editor.putBoolean(IS_FIRST_MSG_SENT, flag);
editor.commit();
</DeepExtract>
} | PanicButton | positive | 1,836 |
@Test
public void modifying_an_existing_file_only_triggers_creations_for_new_warnings() throws Exception {
IMarker marker = this.preExistingTestFile.createMarker(IMarker.PROBLEM);
marker.setAttribute(IMarker.MESSAGE, "Unused import java.util.*;");
IMarker marker2 = this.preExistingTestFile.createMarker(IMarker.PROBLEM);
marker2.setAttribute(IMarker.MESSAGE, "Unused import java.*;");
this.workspace.save(true, null);
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
assertEquals(generatedEvents.size(), 2);
assertTrue(generatedEvents.stream().allMatch(TrackingEventType.SA_WARNING_CREATED::equals));
} | @Test
public void modifying_an_existing_file_only_triggers_creations_for_new_warnings() throws Exception {
IMarker marker = this.preExistingTestFile.createMarker(IMarker.PROBLEM);
marker.setAttribute(IMarker.MESSAGE, "Unused import java.util.*;");
IMarker marker2 = this.preExistingTestFile.createMarker(IMarker.PROBLEM);
marker2.setAttribute(IMarker.MESSAGE, "Unused import java.*;");
<DeepExtract>
this.workspace.save(true, null);
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
</DeepExtract>
assertEquals(generatedEvents.size(), 2);
assertTrue(generatedEvents.stream().allMatch(TrackingEventType.SA_WARNING_CREATED::equals));
} | watchdog | positive | 1,837 |
public void rumbleBlips(int count) {
RumbleEffect.Builder builder = new RumbleEffect.Builder();
for (int i = 0; i < count; i++) {
builder.addStep(1.0, 0, 250).addStep(0, 0, 100);
}
LedEffect copy = new LedEffect(builder.build().steps, builder.build().repeating);
copy.user = userForEffects;
ledQueue.offer(copy);
} | public void rumbleBlips(int count) {
RumbleEffect.Builder builder = new RumbleEffect.Builder();
for (int i = 0; i < count; i++) {
builder.addStep(1.0, 0, 250).addStep(0, 0, 100);
}
<DeepExtract>
LedEffect copy = new LedEffect(builder.build().steps, builder.build().repeating);
copy.user = userForEffects;
ledQueue.offer(copy);
</DeepExtract>
} | virtual_robot | positive | 1,839 |
private void setExpanded(boolean expanded, boolean animate, boolean force) {
return setLiftedState(!expanded);
pendingAction = (expanded ? PENDING_ACTION_EXPANDED : seslGetImmersiveScroll() ? PENDING_ACTION_COLLAPSED_IMM : PENDING_ACTION_COLLAPSED) | (animate ? PENDING_ACTION_ANIMATE_ENABLED : 0) | (force ? PENDING_ACTION_FORCE : 0);
requestLayout();
} | private void setExpanded(boolean expanded, boolean animate, boolean force) {
<DeepExtract>
return setLiftedState(!expanded);
</DeepExtract>
pendingAction = (expanded ? PENDING_ACTION_EXPANDED : seslGetImmersiveScroll() ? PENDING_ACTION_COLLAPSED_IMM : PENDING_ACTION_COLLAPSED) | (animate ? PENDING_ACTION_ANIMATE_ENABLED : 0) | (force ? PENDING_ACTION_FORCE : 0);
requestLayout();
} | SamsungOneUi | positive | 1,840 |
public void setShimmerAngle(int angle) {
if (angle < MIN_ANGLE_VALUE || MAX_ANGLE_VALUE < angle) {
throw new IllegalArgumentException(String.format("shimmerAngle value must be between %d and %d", MIN_ANGLE_VALUE, MAX_ANGLE_VALUE));
}
this.shimmerAngle = angle;
if (isAnimationStarted) {
resetShimmering();
startShimmerAnimation();
}
} | public void setShimmerAngle(int angle) {
if (angle < MIN_ANGLE_VALUE || MAX_ANGLE_VALUE < angle) {
throw new IllegalArgumentException(String.format("shimmerAngle value must be between %d and %d", MIN_ANGLE_VALUE, MAX_ANGLE_VALUE));
}
this.shimmerAngle = angle;
<DeepExtract>
if (isAnimationStarted) {
resetShimmering();
startShimmerAnimation();
}
</DeepExtract>
} | ByRecyclerView | positive | 1,841 |
public static Date add(Date date, int amount, String... pattern) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, amount);
if (pattern == null || pattern.length == 0) {
pattern = new String[] { DEFAULT_PATTERN };
}
return parseDate(parseString(calendar.getTime(), pattern[0]), pattern[0]);
} | public static Date add(Date date, int amount, String... pattern) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, amount);
if (pattern == null || pattern.length == 0) {
pattern = new String[] { DEFAULT_PATTERN };
}
<DeepExtract>
return parseDate(parseString(calendar.getTime(), pattern[0]), pattern[0]);
</DeepExtract>
} | cloud-learning-lite | positive | 1,843 |
public void setDoubleValue(Key<Double> key, double v) {
doubleRegisters.put(key, v);
if (pending) {
return;
}
pending = true;
ThreadUtils.get().schedule(() -> {
pending = false;
try {
doSave();
} catch (Exception e) {
Logger.error("saving config failed", e);
}
}, 1, TimeUnit.SECONDS);
} | public void setDoubleValue(Key<Double> key, double v) {
doubleRegisters.put(key, v);
<DeepExtract>
if (pending) {
return;
}
pending = true;
ThreadUtils.get().schedule(() -> {
pending = false;
try {
doSave();
} catch (Exception e) {
Logger.error("saving config failed", e);
}
}, 1, TimeUnit.SECONDS);
</DeepExtract>
} | Chara | positive | 1,845 |
@PUT
@Path("{nome}")
public void atualizarCerveja(@PathParam("nome") String nome, Cerveja cerveja) {
Cerveja cerveja = estoque.recuperarCervejaPeloNome(nome);
if (cerveja != null)
return cerveja;
throw new WebApplicationException(Status.NOT_FOUND);
cerveja.setNome(nome);
estoque.atualizarCerveja(cerveja);
} | @PUT
@Path("{nome}")
public void atualizarCerveja(@PathParam("nome") String nome, Cerveja cerveja) {
<DeepExtract>
Cerveja cerveja = estoque.recuperarCervejaPeloNome(nome);
if (cerveja != null)
return cerveja;
throw new WebApplicationException(Status.NOT_FOUND);
</DeepExtract>
cerveja.setNome(nome);
estoque.atualizarCerveja(cerveja);
} | rest | positive | 1,846 |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
mSettings = new Settings(getActivity());
View root = inflater.inflate(R.layout.fragment_edit_recipe, container, false);
mRootView = root;
root.findViewById(R.id.recipe_stats_layout).setOnClickListener(this);
root.findViewById(R.id.recipe_notes_layout).setOnClickListener(this);
root.findViewById(R.id.new_ingredient_view).setOnClickListener(this);
setHasOptionsMenu(true);
mStorage = new BrewStorage(getActivity());
mConverter = new UnitConverter(getActivity());
if (state != null) {
mRecipe = state.getParcelable(RECIPE);
}
if (mRecipe == null) {
Log.d(TAG, "Loading recipe from storage");
mRecipe = mFragmentHandler.getCurrentRecipe();
mStorage.retrieveRecipe(mRecipe);
}
BeerStyle style = mRecipe.getStyle();
textView = (TextView) root.findViewById(R.id.recipe_name);
textView.setText(mRecipe.getName());
ImageView iconView = (ImageView) root.findViewById(R.id.recipe_stats_icon);
iconView.setBackgroundColor(getResources().getColor(R.color.color_transparent));
iconView.setImageResource(style.getIconDrawable());
textView = (TextView) root.findViewById(R.id.recipe_style);
String styleName = style.getDisplayName();
if (styleName == null || styleName.length() == 0) {
styleName = getActivity().getResources().getString(R.string.select_style);
}
textView.setText(styleName);
textView = (TextView) root.findViewById(R.id.batch_volume);
textView.setText(mConverter.fromGallonsWithUnits(mRecipe.getBatchVolume(), 1));
textView = (TextView) root.findViewById(R.id.boil_volume);
textView.setText(mConverter.fromGallonsWithUnits(mRecipe.getBoilVolume(), 1));
textView = (TextView) root.findViewById(R.id.boil_time);
textView.setText(Util.fromDouble(mRecipe.getBoilTime(), 0) + UNIT_MINUTES);
textView = (TextView) root.findViewById(R.id.efficiency);
textView.setText(Util.fromDouble(mRecipe.getEfficiency(), 1) + UNIT_PERCENT);
TextView textView;
textView = (TextView) mRootView.findViewById(R.id.recipe_og);
switch(mSettings.getExtractUnits()) {
case SPECIFIC_GRAVITY:
textView.setText(Util.fromDouble(mRecipe.getOg(), 3, false));
break;
case DEGREES_PLATO:
textView.setText(Util.fromDouble(mRecipe.getOgPlato(), 1, false) + UNIT_PLATO);
break;
}
textView = (TextView) mRootView.findViewById(R.id.recipe_srm);
textView.setText(Util.fromDouble(mRecipe.getSrm(), 1));
textView = (TextView) mRootView.findViewById(R.id.recipe_ibu);
textView.setText(Util.fromDouble(mRecipe.getTotalIbu(), 1));
textView = (TextView) mRootView.findViewById(R.id.recipe_fg);
if (mRecipe.hasYeast()) {
switch(mSettings.getExtractUnits()) {
case SPECIFIC_GRAVITY:
textView.setText(Util.fromDouble(mRecipe.getFg(), 3, false));
break;
case DEGREES_PLATO:
textView.setText(Util.fromDouble(mRecipe.getFgPlato(), 1, false) + UNIT_PLATO);
break;
}
textView.setTextColor(getResources().getColor(R.color.text_dark_primary));
} else {
textView.setText(getResources().getString(R.string.add_yeast));
textView.setTextColor(getResources().getColor(R.color.text_dark_secondary));
}
textView = (TextView) mRootView.findViewById(R.id.recipe_abv);
if (mRecipe.hasYeast()) {
textView.setText(Util.fromDouble(mRecipe.getAbv(), 1) + UNIT_PERCENT);
textView.setTextColor(getResources().getColor(R.color.text_dark_primary));
} else {
textView.setText("-");
textView.setTextColor(getResources().getColor(R.color.text_dark_secondary));
}
textView = (TextView) mRootView.findViewById(R.id.calories_label);
switch(mSettings.getUnits()) {
case IMPERIAL:
textView.setText(R.string.imperial_calories);
break;
case METRIC:
textView.setText(R.string.metric_calories);
break;
}
textView = (TextView) mRootView.findViewById(R.id.recipe_calories);
if (mRecipe.hasYeast()) {
textView.setText(mConverter.fromCaloriesPerOz(mRecipe.getCaloriesPerOz(), 1));
textView.setTextColor(getResources().getColor(R.color.text_dark_primary));
} else {
textView.setText("-");
textView.setTextColor(getResources().getColor(R.color.text_dark_secondary));
}
textView = (TextView) root.findViewById(R.id.style_og);
if (style.getOgMin() < 0) {
textView.setText(getResources().getString(R.string.varies));
} else {
String og = Util.fromDouble(style.getOgMin(), 3, false);
if (style.getOgMax() - style.getOgMin() >= 0.001) {
og += " - " + Util.fromDouble(style.getOgMax(), 3, false);
}
textView.setText(og);
}
textView = (TextView) root.findViewById(R.id.style_ibu);
if (style.getIbuMin() < 0) {
textView.setText(getResources().getString(R.string.varies));
} else {
String ibu = Util.fromDouble(style.getIbuMin(), 1);
if (style.getIbuMax() - style.getIbuMin() >= 0.1) {
ibu += " - " + Util.fromDouble(style.getIbuMax(), 1);
}
textView.setText(ibu);
}
textView = (TextView) root.findViewById(R.id.style_srm);
if (style.getSrmMin() < 0) {
textView.setText(getResources().getString(R.string.varies));
} else {
String srm = Util.fromDouble(style.getSrmMin(), 1);
if (style.getSrmMax() - style.getSrmMin() > 0.1) {
srm += " - " + Util.fromDouble(style.getSrmMax(), 1);
}
textView.setText(srm);
}
textView = (TextView) root.findViewById(R.id.style_fg);
if (style.getFgMin() < 0) {
textView.setText(getResources().getString(R.string.varies));
} else {
String fg = Util.fromDouble(style.getFgMin(), 3, false);
if (style.getFgMax() - style.getFgMin() >= 0.001) {
fg += " - " + Util.fromDouble(style.getFgMax(), 3, false);
}
textView.setText(fg);
}
textView = (TextView) root.findViewById(R.id.style_abv);
if (style.getAbvMin() < 0) {
textView.setText(getResources().getString(R.string.varies));
} else {
String abv = Util.fromDouble(style.getAbvMin(), 1);
if (style.getAbvMax() - style.getAbvMin() >= 0.1) {
abv += " - " + Util.fromDouble(style.getAbvMax(), 1);
}
textView.setText(abv + UNIT_PERCENT);
}
mIngredientView = new IngredientListView(getActivity(), root, mRecipe, this);
mIngredientView.getAdapter().showInventory(mSettings.getShowInventoryInRecipe());
mIngredientView.drawList();
mIngredientView.drawList();
textView = (TextView) root.findViewById(R.id.recipe_notes);
textView.setText(mRecipe.getNotes());
if (state != null) {
if (state.getBoolean(ACTION_MODE)) {
int[] selected = state.getIntArray(SELECTED_INDEXES);
startActionMode(selected);
}
}
mFragmentHandler.setTitle(findString(R.string.edit_recipe));
return root;
} | @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
mSettings = new Settings(getActivity());
View root = inflater.inflate(R.layout.fragment_edit_recipe, container, false);
mRootView = root;
root.findViewById(R.id.recipe_stats_layout).setOnClickListener(this);
root.findViewById(R.id.recipe_notes_layout).setOnClickListener(this);
root.findViewById(R.id.new_ingredient_view).setOnClickListener(this);
setHasOptionsMenu(true);
mStorage = new BrewStorage(getActivity());
mConverter = new UnitConverter(getActivity());
if (state != null) {
mRecipe = state.getParcelable(RECIPE);
}
if (mRecipe == null) {
Log.d(TAG, "Loading recipe from storage");
mRecipe = mFragmentHandler.getCurrentRecipe();
mStorage.retrieveRecipe(mRecipe);
}
BeerStyle style = mRecipe.getStyle();
textView = (TextView) root.findViewById(R.id.recipe_name);
textView.setText(mRecipe.getName());
ImageView iconView = (ImageView) root.findViewById(R.id.recipe_stats_icon);
iconView.setBackgroundColor(getResources().getColor(R.color.color_transparent));
iconView.setImageResource(style.getIconDrawable());
textView = (TextView) root.findViewById(R.id.recipe_style);
String styleName = style.getDisplayName();
if (styleName == null || styleName.length() == 0) {
styleName = getActivity().getResources().getString(R.string.select_style);
}
textView.setText(styleName);
textView = (TextView) root.findViewById(R.id.batch_volume);
textView.setText(mConverter.fromGallonsWithUnits(mRecipe.getBatchVolume(), 1));
textView = (TextView) root.findViewById(R.id.boil_volume);
textView.setText(mConverter.fromGallonsWithUnits(mRecipe.getBoilVolume(), 1));
textView = (TextView) root.findViewById(R.id.boil_time);
textView.setText(Util.fromDouble(mRecipe.getBoilTime(), 0) + UNIT_MINUTES);
textView = (TextView) root.findViewById(R.id.efficiency);
textView.setText(Util.fromDouble(mRecipe.getEfficiency(), 1) + UNIT_PERCENT);
TextView textView;
textView = (TextView) mRootView.findViewById(R.id.recipe_og);
switch(mSettings.getExtractUnits()) {
case SPECIFIC_GRAVITY:
textView.setText(Util.fromDouble(mRecipe.getOg(), 3, false));
break;
case DEGREES_PLATO:
textView.setText(Util.fromDouble(mRecipe.getOgPlato(), 1, false) + UNIT_PLATO);
break;
}
textView = (TextView) mRootView.findViewById(R.id.recipe_srm);
textView.setText(Util.fromDouble(mRecipe.getSrm(), 1));
textView = (TextView) mRootView.findViewById(R.id.recipe_ibu);
textView.setText(Util.fromDouble(mRecipe.getTotalIbu(), 1));
textView = (TextView) mRootView.findViewById(R.id.recipe_fg);
if (mRecipe.hasYeast()) {
switch(mSettings.getExtractUnits()) {
case SPECIFIC_GRAVITY:
textView.setText(Util.fromDouble(mRecipe.getFg(), 3, false));
break;
case DEGREES_PLATO:
textView.setText(Util.fromDouble(mRecipe.getFgPlato(), 1, false) + UNIT_PLATO);
break;
}
textView.setTextColor(getResources().getColor(R.color.text_dark_primary));
} else {
textView.setText(getResources().getString(R.string.add_yeast));
textView.setTextColor(getResources().getColor(R.color.text_dark_secondary));
}
textView = (TextView) mRootView.findViewById(R.id.recipe_abv);
if (mRecipe.hasYeast()) {
textView.setText(Util.fromDouble(mRecipe.getAbv(), 1) + UNIT_PERCENT);
textView.setTextColor(getResources().getColor(R.color.text_dark_primary));
} else {
textView.setText("-");
textView.setTextColor(getResources().getColor(R.color.text_dark_secondary));
}
textView = (TextView) mRootView.findViewById(R.id.calories_label);
switch(mSettings.getUnits()) {
case IMPERIAL:
textView.setText(R.string.imperial_calories);
break;
case METRIC:
textView.setText(R.string.metric_calories);
break;
}
textView = (TextView) mRootView.findViewById(R.id.recipe_calories);
if (mRecipe.hasYeast()) {
textView.setText(mConverter.fromCaloriesPerOz(mRecipe.getCaloriesPerOz(), 1));
textView.setTextColor(getResources().getColor(R.color.text_dark_primary));
} else {
textView.setText("-");
textView.setTextColor(getResources().getColor(R.color.text_dark_secondary));
}
textView = (TextView) root.findViewById(R.id.style_og);
if (style.getOgMin() < 0) {
textView.setText(getResources().getString(R.string.varies));
} else {
String og = Util.fromDouble(style.getOgMin(), 3, false);
if (style.getOgMax() - style.getOgMin() >= 0.001) {
og += " - " + Util.fromDouble(style.getOgMax(), 3, false);
}
textView.setText(og);
}
textView = (TextView) root.findViewById(R.id.style_ibu);
if (style.getIbuMin() < 0) {
textView.setText(getResources().getString(R.string.varies));
} else {
String ibu = Util.fromDouble(style.getIbuMin(), 1);
if (style.getIbuMax() - style.getIbuMin() >= 0.1) {
ibu += " - " + Util.fromDouble(style.getIbuMax(), 1);
}
textView.setText(ibu);
}
textView = (TextView) root.findViewById(R.id.style_srm);
if (style.getSrmMin() < 0) {
textView.setText(getResources().getString(R.string.varies));
} else {
String srm = Util.fromDouble(style.getSrmMin(), 1);
if (style.getSrmMax() - style.getSrmMin() > 0.1) {
srm += " - " + Util.fromDouble(style.getSrmMax(), 1);
}
textView.setText(srm);
}
textView = (TextView) root.findViewById(R.id.style_fg);
if (style.getFgMin() < 0) {
textView.setText(getResources().getString(R.string.varies));
} else {
String fg = Util.fromDouble(style.getFgMin(), 3, false);
if (style.getFgMax() - style.getFgMin() >= 0.001) {
fg += " - " + Util.fromDouble(style.getFgMax(), 3, false);
}
textView.setText(fg);
}
textView = (TextView) root.findViewById(R.id.style_abv);
if (style.getAbvMin() < 0) {
textView.setText(getResources().getString(R.string.varies));
} else {
String abv = Util.fromDouble(style.getAbvMin(), 1);
if (style.getAbvMax() - style.getAbvMin() >= 0.1) {
abv += " - " + Util.fromDouble(style.getAbvMax(), 1);
}
textView.setText(abv + UNIT_PERCENT);
}
mIngredientView = new IngredientListView(getActivity(), root, mRecipe, this);
mIngredientView.getAdapter().showInventory(mSettings.getShowInventoryInRecipe());
mIngredientView.drawList();
mIngredientView.drawList();
textView = (TextView) root.findViewById(R.id.recipe_notes);
textView.setText(mRecipe.getNotes());
<DeepExtract>
if (state != null) {
if (state.getBoolean(ACTION_MODE)) {
int[] selected = state.getIntArray(SELECTED_INDEXES);
startActionMode(selected);
}
}
</DeepExtract>
mFragmentHandler.setTitle(findString(R.string.edit_recipe));
return root;
} | BrewShopApp | positive | 1,847 |
public Criteria andFIELD_UPPER_UNDERSCOREGreaterThan(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "FIELD_UPPER_UNDERSCORE" + " cannot be null");
}
criteria.add(new Criterion("FIELD_UPPER_UNDERSCORE >", value));
return (Criteria) this;
} | public Criteria andFIELD_UPPER_UNDERSCOREGreaterThan(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "FIELD_UPPER_UNDERSCORE" + " cannot be null");
}
criteria.add(new Criterion("FIELD_UPPER_UNDERSCORE >", value));
</DeepExtract>
return (Criteria) this;
} | mybatis-generator-gui-extension | positive | 1,848 |
public ResCode findValueByNumber(int number) {
switch(number) {
case 0:
return RES_CODE_SUCCESS;
case 1:
return RES_CODE_FAIL;
default:
return null;
}
} | public ResCode findValueByNumber(int number) {
<DeepExtract>
switch(number) {
case 0:
return RES_CODE_SUCCESS;
case 1:
return RES_CODE_FAIL;
default:
return null;
}
</DeepExtract>
} | distmq | positive | 1,849 |
@Override
public void writeBytecode(MethodVisitor methodVisitor) {
loadResultHandle(methodVisitor, resolvedLength, BytecodeCreatorImpl.this, "I", false);
methodVisitor.visitTypeInsn(Opcodes.ANEWARRAY, arrayType);
if (ret.getResultType() == ResultHandle.ResultType.UNUSED) {
if (ret.getType().equals("J") || ret.getType().equals("D")) {
methodVisitor.visitInsn(Opcodes.POP2);
} else {
methodVisitor.visitInsn(Opcodes.POP);
}
} else if (ret.getResultType() == ResultHandle.ResultType.LOCAL_VARIABLE) {
if (ret.getType().equals("S") || ret.getType().equals("Z") || ret.getType().equals("I") || ret.getType().equals("B") || ret.getType().equals("C")) {
methodVisitor.visitVarInsn(Opcodes.ISTORE, ret.getNo());
} else if (ret.getType().equals("J")) {
methodVisitor.visitVarInsn(Opcodes.LSTORE, ret.getNo());
} else if (ret.getType().equals("F")) {
methodVisitor.visitVarInsn(Opcodes.FSTORE, ret.getNo());
} else if (ret.getType().equals("D")) {
methodVisitor.visitVarInsn(Opcodes.DSTORE, ret.getNo());
} else {
methodVisitor.visitVarInsn(Opcodes.ASTORE, ret.getNo());
}
}
} | @Override
public void writeBytecode(MethodVisitor methodVisitor) {
loadResultHandle(methodVisitor, resolvedLength, BytecodeCreatorImpl.this, "I", false);
methodVisitor.visitTypeInsn(Opcodes.ANEWARRAY, arrayType);
<DeepExtract>
if (ret.getResultType() == ResultHandle.ResultType.UNUSED) {
if (ret.getType().equals("J") || ret.getType().equals("D")) {
methodVisitor.visitInsn(Opcodes.POP2);
} else {
methodVisitor.visitInsn(Opcodes.POP);
}
} else if (ret.getResultType() == ResultHandle.ResultType.LOCAL_VARIABLE) {
if (ret.getType().equals("S") || ret.getType().equals("Z") || ret.getType().equals("I") || ret.getType().equals("B") || ret.getType().equals("C")) {
methodVisitor.visitVarInsn(Opcodes.ISTORE, ret.getNo());
} else if (ret.getType().equals("J")) {
methodVisitor.visitVarInsn(Opcodes.LSTORE, ret.getNo());
} else if (ret.getType().equals("F")) {
methodVisitor.visitVarInsn(Opcodes.FSTORE, ret.getNo());
} else if (ret.getType().equals("D")) {
methodVisitor.visitVarInsn(Opcodes.DSTORE, ret.getNo());
} else {
methodVisitor.visitVarInsn(Opcodes.ASTORE, ret.getNo());
}
}
</DeepExtract>
} | gizmo | positive | 1,850 |
@Override
public boolean addFixedChest(Location loc, String fixedChest) {
if (loc == null || fixedChest == null || fixedChest.equalsIgnoreCase(""))
return false;
if (fixedChests.keySet().contains(loc))
return false;
blacklistedChests.remove(loc);
if (!(loc.getBlock().getState() instanceof Chest))
return false;
Block b = loc.getBlock();
Location ad = null;
if (b.getRelative(BlockFace.NORTH).getState() instanceof Chest)
ad = b.getRelative(BlockFace.NORTH).getLocation();
else if (b.getRelative(BlockFace.SOUTH).getState() instanceof Chest)
ad = b.getRelative(BlockFace.SOUTH).getLocation();
else if (b.getRelative(BlockFace.EAST).getState() instanceof Chest)
ad = b.getRelative(BlockFace.EAST).getLocation();
else if (b.getRelative(BlockFace.WEST).getState() instanceof Chest)
ad = b.getRelative(BlockFace.WEST).getLocation();
if (ad != null) {
if (chests.remove(ad) == null & fixedChests.remove(ad) == null) {
blacklistedChests.add(ad);
}
}
if (chests.remove(loc) == null & fixedChests.remove(loc) == null) {
blacklistedChests.add(loc);
return true;
}
return true;
fixedChests.put(loc, fixedChest);
Block b = loc.getBlock();
if (b.getRelative(BlockFace.NORTH).getState() instanceof Chest)
fixedChests.put(b.getRelative(BlockFace.NORTH).getLocation(), fixedChest);
else if (b.getRelative(BlockFace.SOUTH).getState() instanceof Chest)
fixedChests.put(b.getRelative(BlockFace.SOUTH).getLocation(), fixedChest);
else if (b.getRelative(BlockFace.EAST).getState() instanceof Chest)
fixedChests.put(b.getRelative(BlockFace.EAST).getLocation(), fixedChest);
else if (b.getRelative(BlockFace.WEST).getState() instanceof Chest)
fixedChests.put(b.getRelative(BlockFace.WEST).getLocation(), fixedChest);
return true;
} | @Override
public boolean addFixedChest(Location loc, String fixedChest) {
if (loc == null || fixedChest == null || fixedChest.equalsIgnoreCase(""))
return false;
if (fixedChests.keySet().contains(loc))
return false;
blacklistedChests.remove(loc);
if (!(loc.getBlock().getState() instanceof Chest))
return false;
<DeepExtract>
Block b = loc.getBlock();
Location ad = null;
if (b.getRelative(BlockFace.NORTH).getState() instanceof Chest)
ad = b.getRelative(BlockFace.NORTH).getLocation();
else if (b.getRelative(BlockFace.SOUTH).getState() instanceof Chest)
ad = b.getRelative(BlockFace.SOUTH).getLocation();
else if (b.getRelative(BlockFace.EAST).getState() instanceof Chest)
ad = b.getRelative(BlockFace.EAST).getLocation();
else if (b.getRelative(BlockFace.WEST).getState() instanceof Chest)
ad = b.getRelative(BlockFace.WEST).getLocation();
if (ad != null) {
if (chests.remove(ad) == null & fixedChests.remove(ad) == null) {
blacklistedChests.add(ad);
}
}
if (chests.remove(loc) == null & fixedChests.remove(loc) == null) {
blacklistedChests.add(loc);
return true;
}
return true;
</DeepExtract>
fixedChests.put(loc, fixedChest);
Block b = loc.getBlock();
if (b.getRelative(BlockFace.NORTH).getState() instanceof Chest)
fixedChests.put(b.getRelative(BlockFace.NORTH).getLocation(), fixedChest);
else if (b.getRelative(BlockFace.SOUTH).getState() instanceof Chest)
fixedChests.put(b.getRelative(BlockFace.SOUTH).getLocation(), fixedChest);
else if (b.getRelative(BlockFace.EAST).getState() instanceof Chest)
fixedChests.put(b.getRelative(BlockFace.EAST).getLocation(), fixedChest);
else if (b.getRelative(BlockFace.WEST).getState() instanceof Chest)
fixedChests.put(b.getRelative(BlockFace.WEST).getLocation(), fixedChest);
return true;
} | MyHungerGames | positive | 1,851 |
private void sortComparingByIndicesIfEqualImpl(int from, int until) {
for (int i = from; i < until; ++i) {
scratch[i] = points[indices[i]][coordinate];
}
sortImplInside(from, until);
int last = from;
double lastX = scratch[from];
for (int i = from + 1; i < until; ++i) {
double currX = scratch[i];
if (currX != lastX) {
if (last + 1 < i) {
Arrays.sort(indices, last, i);
}
last = i;
lastX = currX;
}
}
if (last + 1 < until) {
Arrays.sort(indices, last, until);
}
} | private void sortComparingByIndicesIfEqualImpl(int from, int until) {
<DeepExtract>
for (int i = from; i < until; ++i) {
scratch[i] = points[indices[i]][coordinate];
}
sortImplInside(from, until);
</DeepExtract>
int last = from;
double lastX = scratch[from];
for (int i = from + 1; i < until; ++i) {
double currX = scratch[i];
if (currX != lastX) {
if (last + 1 < i) {
Arrays.sort(indices, last, i);
}
last = i;
lastX = currX;
}
}
if (last + 1 < until) {
Arrays.sort(indices, last, until);
}
} | non-dominated-sorting | positive | 1,852 |
public boolean storeSellDetails(SellsDatabaseModel sell) {
database = dbHelper.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(dbHelper.COL_SELL_SELLS_CODE, sell.getSellsCode());
contentValues.put(dbHelper.COL_SELL_CUSTOMER_ID, sell.getCustomerId());
contentValues.put(dbHelper.COL_SELL_AMOUNT, sell.getTotalAmount());
contentValues.put(dbHelper.COL_SELL_DISCOUNT, sell.getDiscount());
contentValues.put(dbHelper.COL_SELL_PAY_AMOUNT, sell.getPayAmount());
contentValues.put(dbHelper.COL_SELL_PAYMENT_TYPE, sell.getPaymentType());
contentValues.put(dbHelper.COL_SELL_SELL_DATE, sell.getSellDate());
contentValues.put(dbHelper.COL_SELL_PAYMENT_STATUS, sell.getPaymentStatus());
contentValues.put(dbHelper.COL_SELL_SELL_BY, sell.getSellBy());
long id = database.insert(dbHelper.TABLE_SELL_NAME, null, contentValues);
database.close();
if (id > 0) {
Log.d(TAG, "Sell: ------------ new Sell info inserted");
return true;
} else {
Log.d(TAG, "Sell: ------------ new Sell insertion failed");
return false;
}
} | public boolean storeSellDetails(SellsDatabaseModel sell) {
database = dbHelper.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(dbHelper.COL_SELL_SELLS_CODE, sell.getSellsCode());
contentValues.put(dbHelper.COL_SELL_CUSTOMER_ID, sell.getCustomerId());
contentValues.put(dbHelper.COL_SELL_AMOUNT, sell.getTotalAmount());
contentValues.put(dbHelper.COL_SELL_DISCOUNT, sell.getDiscount());
contentValues.put(dbHelper.COL_SELL_PAY_AMOUNT, sell.getPayAmount());
contentValues.put(dbHelper.COL_SELL_PAYMENT_TYPE, sell.getPaymentType());
contentValues.put(dbHelper.COL_SELL_SELL_DATE, sell.getSellDate());
contentValues.put(dbHelper.COL_SELL_PAYMENT_STATUS, sell.getPaymentStatus());
contentValues.put(dbHelper.COL_SELL_SELL_BY, sell.getSellBy());
long id = database.insert(dbHelper.TABLE_SELL_NAME, null, contentValues);
<DeepExtract>
database.close();
</DeepExtract>
if (id > 0) {
Log.d(TAG, "Sell: ------------ new Sell info inserted");
return true;
} else {
Log.d(TAG, "Sell: ------------ new Sell insertion failed");
return false;
}
} | Android-POS | positive | 1,853 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.