before stringlengths 33 3.21M | after stringlengths 63 3.21M | repo stringlengths 1 56 | type stringclasses 1
value | __index_level_0__ int64 0 442k |
|---|---|---|---|---|
private void parseExpressionList() throws ParsingException {
int type = lookahead().getType();
while (type == SchemeToken.COMMENT || type == SchemeToken.WSPACE) {
consume();
type = lookahead().getType();
}
while (lookahead() != SchemeToken.EOF && lookahead().getType() != SchemeToken.RPAREN) {
parseExpression();
skipWhitespaces();
}
} | private void parseExpressionList() throws ParsingException {
<DeepExtract>
int type = lookahead().getType();
while (type == SchemeToken.COMMENT || type == SchemeToken.WSPACE) {
consume();
type = lookahead().getType();
}
</DeepExtract>
while (lookahead() != SchemeToken.EOF && lookahead().getType() != SchemeToken.RPAREN) {
parseExpression();
skipWhitespaces();
}
} | SchemeScript | positive | 1,620 |
public void removeFirstRow() {
return numOfElements;
rows.remove(0);
} | public void removeFirstRow() {
<DeepExtract>
return numOfElements;
</DeepExtract>
rows.remove(0);
} | TrajectoryClustering | positive | 1,621 |
@Benchmark
public void defaultRTreeSearchOf1000PointsMaxChildren128(Blackhole bh) {
smallDefaultTreeM128.search(Geometries.rectangle(500, 500, 630, 630)).subscribe(consumeWith(bh));
} | @Benchmark
public void defaultRTreeSearchOf1000PointsMaxChildren128(Blackhole bh) {
<DeepExtract>
smallDefaultTreeM128.search(Geometries.rectangle(500, 500, 630, 630)).subscribe(consumeWith(bh));
</DeepExtract>
} | rtree | positive | 1,622 |
public void insert(final InsnList insns) {
if (insns.size == 0) {
return;
}
size += insns.size;
if (first == null) {
first = insns.first;
last = insns.last;
} else {
AbstractInsnNode elem = insns.last;
first.prev = elem;
elem.next = first;
first = insns.first;
}
cache = null;
if (false) {
AbstractInsnNode insn = first;
while (insn != null) {
AbstractInsnNode next = insn.next;
insn.index = -1;
insn.prev = null;
insn.next = null;
insn = next;
}
}
size = 0;
first = null;
last = null;
cache = null;
} | public void insert(final InsnList insns) {
if (insns.size == 0) {
return;
}
size += insns.size;
if (first == null) {
first = insns.first;
last = insns.last;
} else {
AbstractInsnNode elem = insns.last;
first.prev = elem;
elem.next = first;
first = insns.first;
}
cache = null;
<DeepExtract>
if (false) {
AbstractInsnNode insn = first;
while (insn != null) {
AbstractInsnNode next = insn.next;
insn.index = -1;
insn.prev = null;
insn.next = null;
insn = next;
}
}
size = 0;
first = null;
last = null;
cache = null;
</DeepExtract>
} | bearded-octo-nemesis | positive | 1,623 |
@Override
public void setV2c(Tuple2<Byte> v) {
byte[] data = new byte[] { v._0, v._1 };
int t = type();
if (data == null || data.length % CvType.channels(t) != 0)
throw new UnsupportedOperationException("Provided data element number (" + (data == null ? 0 : data.length) + ") should be multiple of the Mat channels count (" + CvType.channels(t) + ")");
if (indices.length != dims())
throw new IllegalArgumentException("Incorrect number of indices");
return nPutDIdx(nativeObj, indices, data.length, data);
} | @Override
public void setV2c(Tuple2<Byte> v) {
byte[] data = new byte[] { v._0, v._1 };
<DeepExtract>
int t = type();
if (data == null || data.length % CvType.channels(t) != 0)
throw new UnsupportedOperationException("Provided data element number (" + (data == null ? 0 : data.length) + ") should be multiple of the Mat channels count (" + CvType.channels(t) + ")");
if (indices.length != dims())
throw new IllegalArgumentException("Incorrect number of indices");
return nPutDIdx(nativeObj, indices, data.length, data);
</DeepExtract>
} | virtual_robot | positive | 1,624 |
public Criteria andTrademarkLessThanOrEqualTo(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "trademark" + " cannot be null");
}
criteria.add(new Criterion("trademark <=", value));
return (Criteria) this;
} | public Criteria andTrademarkLessThanOrEqualTo(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "trademark" + " cannot be null");
}
criteria.add(new Criterion("trademark <=", value));
</DeepExtract>
return (Criteria) this;
} | uccn | positive | 1,625 |
public int getUpperZ() {
if (this.center != null) {
if (this.size > 0) {
if (this.world == null) {
this.world = Bukkit.getWorld("world");
}
if (this.world != null) {
int lx = this.center.getBlockX() + this.size;
int lz = this.center.getBlockZ() + this.size;
int px = this.center.getBlockX() - this.size;
int pz = this.center.getBlockZ() - this.size;
Vector l = new Vector(lx, 0, lz);
Vector p = new Vector(px, this.height, pz);
this.l = l.toLocation(this.world);
this.p = p.toLocation(this.world);
}
}
}
if (this.l == null || this.p == null) {
return 0;
}
int x = this.l.getBlockZ();
int y = this.p.getBlockZ();
if (y < x) {
return x;
}
return y;
} | public int getUpperZ() {
<DeepExtract>
if (this.center != null) {
if (this.size > 0) {
if (this.world == null) {
this.world = Bukkit.getWorld("world");
}
if (this.world != null) {
int lx = this.center.getBlockX() + this.size;
int lz = this.center.getBlockZ() + this.size;
int px = this.center.getBlockX() - this.size;
int pz = this.center.getBlockZ() - this.size;
Vector l = new Vector(lx, 0, lz);
Vector p = new Vector(px, this.height, pz);
this.l = l.toLocation(this.world);
this.p = p.toLocation(this.world);
}
}
}
</DeepExtract>
if (this.l == null || this.p == null) {
return 0;
}
int x = this.l.getBlockZ();
int y = this.p.getBlockZ();
if (y < x) {
return x;
}
return y;
} | wildskript | positive | 1,626 |
private void solve() {
Scanner sc = new Scanner(System.in);
String words = sc.nextLine();
String[] nodes = words.split("\\? | : ");
Tree tree = new Tree(nodes[0], null, null);
makeTree(tree, nodes, 1, nodes.length - 1);
if (tree.value.split(" ").length > 1) {
if (oper(tree.value)) {
oper(tree.left);
} else {
oper(tree.right);
}
} else {
System.out.println(tree.value);
}
} | private void solve() {
Scanner sc = new Scanner(System.in);
String words = sc.nextLine();
String[] nodes = words.split("\\? | : ");
Tree tree = new Tree(nodes[0], null, null);
makeTree(tree, nodes, 1, nodes.length - 1);
<DeepExtract>
if (tree.value.split(" ").length > 1) {
if (oper(tree.value)) {
oper(tree.left);
} else {
oper(tree.right);
}
} else {
System.out.println(tree.value);
}
</DeepExtract>
} | Study-Book | positive | 1,627 |
public static void hideNotificationBar(Context context) {
String methodName = (Build.VERSION.SDK_INT <= 16) ? "collapse" : "collapsePanels";
try {
Object service = context.getSystemService("statusbar");
Class<?> statusBarManager = Class.forName("android.app.StatusBarManager");
Method expand = statusBarManager.getMethod(methodName);
expand.invoke(service);
} catch (Exception e) {
e.printStackTrace();
}
} | public static void hideNotificationBar(Context context) {
String methodName = (Build.VERSION.SDK_INT <= 16) ? "collapse" : "collapsePanels";
<DeepExtract>
try {
Object service = context.getSystemService("statusbar");
Class<?> statusBarManager = Class.forName("android.app.StatusBarManager");
Method expand = statusBarManager.getMethod(methodName);
expand.invoke(service);
} catch (Exception e) {
e.printStackTrace();
}
</DeepExtract>
} | RxCore | positive | 1,628 |
public static RectF rectFTake() {
if (mQueue.size() == 0) {
return newInstance();
} else {
return resetInstance(mQueue.poll());
}
} | public static RectF rectFTake() {
<DeepExtract>
if (mQueue.size() == 0) {
return newInstance();
} else {
return resetInstance(mQueue.poll());
}
</DeepExtract>
} | android-frame | positive | 1,630 |
public void deleteElementsFromRectangle(Vector2F startPoint, Vector2F endPoint) {
Rectangle rec = new Rectangle(startPoint, endPoint);
for (int i = 0; i < list.size(); i++) {
Figure fig = list.get(i);
if (rec.isFigureCrossOrIsInsideRectangle(fig)) {
if (fig instanceof Node)
nodeAmount--;
else
linkAmount--;
list.remove(i);
i--;
}
}
clearCanvas();
for (Figure fig : list) fig.draw(canvas.getGraphicsContext2D());
if (selectedFigure != null)
selectedFigure.drawOutline(canvas.getGraphicsContext2D());
} | public void deleteElementsFromRectangle(Vector2F startPoint, Vector2F endPoint) {
Rectangle rec = new Rectangle(startPoint, endPoint);
for (int i = 0; i < list.size(); i++) {
Figure fig = list.get(i);
if (rec.isFigureCrossOrIsInsideRectangle(fig)) {
if (fig instanceof Node)
nodeAmount--;
else
linkAmount--;
list.remove(i);
i--;
}
}
<DeepExtract>
clearCanvas();
for (Figure fig : list) fig.draw(canvas.getGraphicsContext2D());
if (selectedFigure != null)
selectedFigure.drawOutline(canvas.getGraphicsContext2D());
</DeepExtract>
} | ceons | positive | 1,631 |
public void readParams(AbstractSerializedData stream, boolean exception) {
id = stream.readInt64(exception);
access_hash = stream.readInt64(exception);
user_id = stream.readInt32(exception);
date = stream.readInt32(exception);
caption = stream.readString(exception);
Photo result = null;
switch(stream.readInt32(exception)) {
case 0x22b56751:
result = new TL_photo_old();
break;
case 0xcded42fe:
result = new TL_photo();
break;
case 0xc3838076:
result = new TL_photo_old2();
break;
case 0x2331b22d:
result = new TL_photoEmpty();
break;
}
if (result == null && exception) {
throw new RuntimeException(String.format("can't parse magic %x in Photo", stream.readInt32(exception)));
}
if (result != null) {
result.readParams(stream, exception);
}
return result;
int magic = stream.readInt32(exception);
if (magic != 0x1cb5c415) {
if (exception) {
throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
}
return;
}
int count = stream.readInt32(exception);
for (int a = 0; a < count; a++) {
PhotoSize object = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception);
if (object == null) {
return;
}
sizes.add(object);
}
} | public void readParams(AbstractSerializedData stream, boolean exception) {
id = stream.readInt64(exception);
access_hash = stream.readInt64(exception);
user_id = stream.readInt32(exception);
date = stream.readInt32(exception);
caption = stream.readString(exception);
<DeepExtract>
Photo result = null;
switch(stream.readInt32(exception)) {
case 0x22b56751:
result = new TL_photo_old();
break;
case 0xcded42fe:
result = new TL_photo();
break;
case 0xc3838076:
result = new TL_photo_old2();
break;
case 0x2331b22d:
result = new TL_photoEmpty();
break;
}
if (result == null && exception) {
throw new RuntimeException(String.format("can't parse magic %x in Photo", stream.readInt32(exception)));
}
if (result != null) {
result.readParams(stream, exception);
}
return result;
</DeepExtract>
int magic = stream.readInt32(exception);
if (magic != 0x1cb5c415) {
if (exception) {
throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
}
return;
}
int count = stream.readInt32(exception);
for (int a = 0; a < count; a++) {
PhotoSize object = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception);
if (object == null) {
return;
}
sizes.add(object);
}
} | TelegramGallery | positive | 1,632 |
public void render(Graphics g, boolean useoffsets, int offsetx, int offsety, Color color) {
Drawable i = this;
if (i.sprite == null || i.sprite.equals(""))
return;
int xoff = i.offsetx + offsetx;
int yoff = i.offsety + offsety;
if (!useoffsets) {
xoff = 0;
yoff = 0;
}
BufferedImage image = FileUtil.readImage(i.sprite);
if (this.tags.containsName("convert_to_alpha"))
image = Drawing.convertToAlpha(image);
g.drawImage(image, xoff, yoff, null);
if (!this.mask.equals("")) {
if (this.mask.equals("self"))
this.mask = this.sprite;
BufferedImage image = FileUtil.readImage(this.mask);
BufferedImageOp colorizeFilter;
if (this.tags.containsName("convert_to_alpha"))
image = Drawing.convertToAlpha(image);
if (this.tags.containsName("alternaterecolor"))
colorizeFilter = Drawing.createColorizeOp_alt(color);
else
colorizeFilter = Drawing.createColorizeOp(color);
BufferedImage targetImage = colorizeFilter.filter(image, image);
g.drawImage(targetImage, xoff, yoff, null);
}
} | public void render(Graphics g, boolean useoffsets, int offsetx, int offsety, Color color) {
Drawable i = this;
if (i.sprite == null || i.sprite.equals(""))
return;
int xoff = i.offsetx + offsetx;
int yoff = i.offsety + offsety;
if (!useoffsets) {
xoff = 0;
yoff = 0;
}
BufferedImage image = FileUtil.readImage(i.sprite);
if (this.tags.containsName("convert_to_alpha"))
image = Drawing.convertToAlpha(image);
g.drawImage(image, xoff, yoff, null);
<DeepExtract>
if (!this.mask.equals("")) {
if (this.mask.equals("self"))
this.mask = this.sprite;
BufferedImage image = FileUtil.readImage(this.mask);
BufferedImageOp colorizeFilter;
if (this.tags.containsName("convert_to_alpha"))
image = Drawing.convertToAlpha(image);
if (this.tags.containsName("alternaterecolor"))
colorizeFilter = Drawing.createColorizeOp_alt(color);
else
colorizeFilter = Drawing.createColorizeOp(color);
BufferedImage targetImage = colorizeFilter.filter(image, image);
g.drawImage(targetImage, xoff, yoff, null);
}
</DeepExtract>
} | nationgen | positive | 1,633 |
@Test
public void transactionModes() throws Exception {
File tmpFile = File.createTempFile("test-trans", ".db");
Field transactionMode = CoreConnection.class.getDeclaredField("transactionMode");
transactionMode.setAccessible(true);
Field beginCommandMap = CoreConnection.class.getDeclaredField("beginCommandMap");
beginCommandMap.setAccessible(true);
SQLiteDataSource ds = new SQLiteDataSource();
ds.setUrl("jdbc:sqlite:" + tmpFile.getAbsolutePath());
SQLiteConnection con = (SQLiteConnection) ds.getConnection();
assertEquals(TransactionMode.DEFFERED, transactionMode.get(con));
assertEquals("begin;", ((Map<?, ?>) beginCommandMap.get(con)).get(TransactionMode.DEFFERED));
Statement stat = con.createStatement();
con.setAutoCommit(false);
stat.execute("create table " + "tbl1" + "(id)");
stat.executeUpdate("insert into " + "tbl1" + " values(1)");
stat.executeUpdate("insert into " + "tbl1" + " values(2)");
con.commit();
ResultSet rs = stat.executeQuery("select * from " + "tbl1");
rs.next();
assertEquals(1, rs.getInt(1));
rs.next();
assertEquals(2, rs.getInt(1));
rs.close();
con.close();
ds.setTransactionMode(TransactionMode.DEFFERED.name());
con = (SQLiteConnection) ds.getConnection();
assertEquals(TransactionMode.DEFFERED, transactionMode.get(con));
assertEquals("begin;", ((Map<?, ?>) beginCommandMap.get(con)).get(TransactionMode.DEFFERED));
ds.setTransactionMode(TransactionMode.IMMEDIATE.name());
con = (SQLiteConnection) ds.getConnection();
assertEquals(TransactionMode.IMMEDIATE, transactionMode.get(con));
assertEquals("begin immediate;", ((Map<?, ?>) beginCommandMap.get(con)).get(TransactionMode.IMMEDIATE));
Statement stat = con.createStatement();
con.setAutoCommit(false);
stat.execute("create table " + "tbl2" + "(id)");
stat.executeUpdate("insert into " + "tbl2" + " values(1)");
stat.executeUpdate("insert into " + "tbl2" + " values(2)");
con.commit();
ResultSet rs = stat.executeQuery("select * from " + "tbl2");
rs.next();
assertEquals(1, rs.getInt(1));
rs.next();
assertEquals(2, rs.getInt(1));
rs.close();
con.close();
ds.setTransactionMode(TransactionMode.EXCLUSIVE.name());
con = (SQLiteConnection) ds.getConnection();
assertEquals(TransactionMode.EXCLUSIVE, transactionMode.get(con));
assertEquals("begin exclusive;", ((Map<?, ?>) beginCommandMap.get(con)).get(TransactionMode.EXCLUSIVE));
Statement stat = con.createStatement();
con.setAutoCommit(false);
stat.execute("create table " + "tbl3" + "(id)");
stat.executeUpdate("insert into " + "tbl3" + " values(1)");
stat.executeUpdate("insert into " + "tbl3" + " values(2)");
con.commit();
ResultSet rs = stat.executeQuery("select * from " + "tbl3");
rs.next();
assertEquals(1, rs.getInt(1));
rs.next();
assertEquals(2, rs.getInt(1));
rs.close();
con.close();
tmpFile.delete();
} | @Test
public void transactionModes() throws Exception {
File tmpFile = File.createTempFile("test-trans", ".db");
Field transactionMode = CoreConnection.class.getDeclaredField("transactionMode");
transactionMode.setAccessible(true);
Field beginCommandMap = CoreConnection.class.getDeclaredField("beginCommandMap");
beginCommandMap.setAccessible(true);
SQLiteDataSource ds = new SQLiteDataSource();
ds.setUrl("jdbc:sqlite:" + tmpFile.getAbsolutePath());
SQLiteConnection con = (SQLiteConnection) ds.getConnection();
assertEquals(TransactionMode.DEFFERED, transactionMode.get(con));
assertEquals("begin;", ((Map<?, ?>) beginCommandMap.get(con)).get(TransactionMode.DEFFERED));
Statement stat = con.createStatement();
con.setAutoCommit(false);
stat.execute("create table " + "tbl1" + "(id)");
stat.executeUpdate("insert into " + "tbl1" + " values(1)");
stat.executeUpdate("insert into " + "tbl1" + " values(2)");
con.commit();
ResultSet rs = stat.executeQuery("select * from " + "tbl1");
rs.next();
assertEquals(1, rs.getInt(1));
rs.next();
assertEquals(2, rs.getInt(1));
rs.close();
con.close();
ds.setTransactionMode(TransactionMode.DEFFERED.name());
con = (SQLiteConnection) ds.getConnection();
assertEquals(TransactionMode.DEFFERED, transactionMode.get(con));
assertEquals("begin;", ((Map<?, ?>) beginCommandMap.get(con)).get(TransactionMode.DEFFERED));
ds.setTransactionMode(TransactionMode.IMMEDIATE.name());
con = (SQLiteConnection) ds.getConnection();
assertEquals(TransactionMode.IMMEDIATE, transactionMode.get(con));
assertEquals("begin immediate;", ((Map<?, ?>) beginCommandMap.get(con)).get(TransactionMode.IMMEDIATE));
Statement stat = con.createStatement();
con.setAutoCommit(false);
stat.execute("create table " + "tbl2" + "(id)");
stat.executeUpdate("insert into " + "tbl2" + " values(1)");
stat.executeUpdate("insert into " + "tbl2" + " values(2)");
con.commit();
ResultSet rs = stat.executeQuery("select * from " + "tbl2");
rs.next();
assertEquals(1, rs.getInt(1));
rs.next();
assertEquals(2, rs.getInt(1));
rs.close();
con.close();
ds.setTransactionMode(TransactionMode.EXCLUSIVE.name());
con = (SQLiteConnection) ds.getConnection();
assertEquals(TransactionMode.EXCLUSIVE, transactionMode.get(con));
assertEquals("begin exclusive;", ((Map<?, ?>) beginCommandMap.get(con)).get(TransactionMode.EXCLUSIVE));
<DeepExtract>
Statement stat = con.createStatement();
con.setAutoCommit(false);
stat.execute("create table " + "tbl3" + "(id)");
stat.executeUpdate("insert into " + "tbl3" + " values(1)");
stat.executeUpdate("insert into " + "tbl3" + " values(2)");
con.commit();
ResultSet rs = stat.executeQuery("select * from " + "tbl3");
rs.next();
assertEquals(1, rs.getInt(1));
rs.next();
assertEquals(2, rs.getInt(1));
rs.close();
con.close();
</DeepExtract>
tmpFile.delete();
} | sqlcipher-jdbc | positive | 1,634 |
public static byte[] buildSpeexHeader(int sampleRate, int mode, int channels, boolean vbr, int nframes) {
byte[] data = new byte[80];
writeString(data, 0, "Speex ");
writeString(data, 0 + 8, "speex-1.2rc");
System.arraycopy(new byte[11], 0, data, 0 + 17, 11);
writeInt(data, 0 + 28, 1);
writeInt(data, 0 + 32, 80);
writeInt(data, 0 + 36, sampleRate);
writeInt(data, 0 + 40, mode);
writeInt(data, 0 + 44, 4);
writeInt(data, 0 + 48, channels);
writeInt(data, 0 + 52, -1);
writeInt(data, 0 + 56, 160 << mode);
writeInt(data, 0 + 60, vbr ? 1 : 0);
writeInt(data, 0 + 64, nframes);
writeInt(data, 0 + 68, 0);
writeInt(data, 0 + 72, 0);
writeInt(data, 0 + 76, 0);
return 80;
return data;
} | public static byte[] buildSpeexHeader(int sampleRate, int mode, int channels, boolean vbr, int nframes) {
byte[] data = new byte[80];
<DeepExtract>
writeString(data, 0, "Speex ");
writeString(data, 0 + 8, "speex-1.2rc");
System.arraycopy(new byte[11], 0, data, 0 + 17, 11);
writeInt(data, 0 + 28, 1);
writeInt(data, 0 + 32, 80);
writeInt(data, 0 + 36, sampleRate);
writeInt(data, 0 + 40, mode);
writeInt(data, 0 + 44, 4);
writeInt(data, 0 + 48, channels);
writeInt(data, 0 + 52, -1);
writeInt(data, 0 + 56, 160 << mode);
writeInt(data, 0 + 60, vbr ? 1 : 0);
writeInt(data, 0 + 64, nframes);
writeInt(data, 0 + 68, 0);
writeInt(data, 0 + 72, 0);
writeInt(data, 0 + 76, 0);
return 80;
</DeepExtract>
return data;
} | LEHomeMobile_android | positive | 1,635 |
@Test
public void testUpdateSuccess() {
createAdminUser();
String token = authAdminGetToken();
return createMap("username", "user1", "displayName", "User 1", "password", "abcABC12", "enabled", true, "allowAppTokens", true, "allowChannels", true, "allowTemplates", true, "allowSystemConfig", true);
response = validateSetUserResponse(token, null, params, "error", equalTo(ErrorCode.OK), "id", not(isEmptyOrNullString()));
id = response.getString("id");
return validateGetUserResponse(token, id, "error", equalTo(ErrorCode.OK), "users.size()", is(1), "users[0].id", equalTo(id), "users[0].username", equalTo("user1"), "users[0].displayName", equalTo("User 1"));
params = createMap("username", "user1.1", "displayName", "User 1.1", "password", "123ABCabc", "enabled", true, "allowAppTokens", false, "allowChannels", false, "allowTemplates", false, "allowSystemConfig", false);
validateSetUserResponse(token, id, params, "error", equalTo(ErrorCode.OK), "id", not(isEmptyOrNullString()), "id", equalTo(id));
return validateGetUserResponse(token, id, "error", equalTo(ErrorCode.OK), "users.size()", is(1), "users[0].id", equalTo(id), "users[0].username", equalTo("user1.1"), "users[0].displayName", equalTo("User 1.1"));
} | @Test
public void testUpdateSuccess() {
createAdminUser();
String token = authAdminGetToken();
return createMap("username", "user1", "displayName", "User 1", "password", "abcABC12", "enabled", true, "allowAppTokens", true, "allowChannels", true, "allowTemplates", true, "allowSystemConfig", true);
response = validateSetUserResponse(token, null, params, "error", equalTo(ErrorCode.OK), "id", not(isEmptyOrNullString()));
id = response.getString("id");
return validateGetUserResponse(token, id, "error", equalTo(ErrorCode.OK), "users.size()", is(1), "users[0].id", equalTo(id), "users[0].username", equalTo("user1"), "users[0].displayName", equalTo("User 1"));
params = createMap("username", "user1.1", "displayName", "User 1.1", "password", "123ABCabc", "enabled", true, "allowAppTokens", false, "allowChannels", false, "allowTemplates", false, "allowSystemConfig", false);
validateSetUserResponse(token, id, params, "error", equalTo(ErrorCode.OK), "id", not(isEmptyOrNullString()), "id", equalTo(id));
<DeepExtract>
return validateGetUserResponse(token, id, "error", equalTo(ErrorCode.OK), "users.size()", is(1), "users[0].id", equalTo(id), "users[0].username", equalTo("user1.1"), "users[0].displayName", equalTo("User 1.1"));
</DeepExtract>
} | tubewarder | positive | 1,637 |
@Override
public final void bind(@NonNull final T viewModel) {
this.viewModel = get(viewModel);
get(viewModel).bindToDataModel();
getViewDataBinder().bind(disposables);
} | @Override
public final void bind(@NonNull final T viewModel) {
this.viewModel = get(viewModel);
get(viewModel).bindToDataModel();
<DeepExtract>
getViewDataBinder().bind(disposables);
</DeepExtract>
} | freesound-android | positive | 1,638 |
public static boolean equalLong(Long first, Long second) {
if (first == null || second == null) {
return first == null && second == null;
}
return first.equals(second);
} | public static boolean equalLong(Long first, Long second) {
<DeepExtract>
if (first == null || second == null) {
return first == null && second == null;
}
return first.equals(second);
</DeepExtract>
} | adobe_air_sdk | positive | 1,639 |
@Override
public void setTitle(int resId) {
if (!reflected) {
reflected = reflectTitle();
}
super.setTitle(resId);
if (title != null)
title.setSelected(true);
} | @Override
public void setTitle(int resId) {
if (!reflected) {
reflected = reflectTitle();
}
super.setTitle(resId);
<DeepExtract>
if (title != null)
title.setSelected(true);
</DeepExtract>
} | MangaViewAndroid | positive | 1,641 |
@Override
public void onFailure(final Throwable caught) {
super.onFailure(caught);
c.setStarred(prior);
final ImageResource star;
if (c.isStarred()) {
star = Gerrit.RESOURCES.starFilled();
} else {
star = Gerrit.RESOURCES.starOpen();
}
final Widget i = table.getWidget(row, C_STAR);
if (i instanceof Image) {
((Image) i).setResource(star);
} else {
table.setWidget(row, C_STAR, new Image(star));
}
} | @Override
public void onFailure(final Throwable caught) {
super.onFailure(caught);
c.setStarred(prior);
<DeepExtract>
final ImageResource star;
if (c.isStarred()) {
star = Gerrit.RESOURCES.starFilled();
} else {
star = Gerrit.RESOURCES.starOpen();
}
final Widget i = table.getWidget(row, C_STAR);
if (i instanceof Image) {
((Image) i).setResource(star);
} else {
table.setWidget(row, C_STAR, new Image(star));
}
</DeepExtract>
} | mini-git-server | positive | 1,642 |
private void updateCriteria(CriteriaQuery<?> crit, CriteriaBuilder criteriaBuilder, IEntityType entityType, EntityQuery entityQuery) {
_entityType = entityType;
_entityQuery = entityQuery;
_cb = criteriaBuilder;
_root = crit.from(crit.getResultType());
if (entityQuery.getWherePredicate() == null)
return;
BinaryPredicate breezePred = (BinaryPredicate) entityQuery.getWherePredicate();
Operator op = breezePred.getOperator();
String symbol = op.getName();
Expression expr1 = breezePred.getExpr1();
Expression expr2 = breezePred.getExpr2();
String contextAlias = null;
javax.persistence.criteria.Predicate xpred;
if (expr1 instanceof PropExpression) {
PropExpression pexpr1 = (PropExpression) expr1;
String propPath = pexpr1.getPropertyPath();
String propName;
if (pexpr1.getProperty().getParentType().isComplexType()) {
propName = propPath;
} else {
propName = propPath;
}
propName = (contextAlias == null) ? propName : contextAlias + "." + propName;
Path path = _root.get(propName);
if (expr2 instanceof LitExpression) {
Object value = ((LitExpression) expr2).getValue();
if (value == null) {
if (op == Operator.Equals) {
xpred = _cb.isNull(path);
} else if (op == Operator.NotEquals) {
xpred = _cb.isNotNull(path);
} else {
throw new RuntimeException("Binary Predicate with a null value and the " + op.getName() + "operator is not supported .");
}
} else if (op == Operator.Equals) {
xpred = _cb.equal(path, value);
} else if (op == Operator.NotEquals) {
xpred = _cb.notEqual(path, value);
} else if (op == Operator.GreaterThan) {
xpred = _cb.greaterThan(_root.<Comparable>get(propName), (Comparable) value);
} else if (op == Operator.GreaterThanOrEqual) {
xpred = _cb.greaterThanOrEqualTo(_root.<Comparable>get(propName), (Comparable) value);
} else if (op == Operator.LessThan) {
xpred = _cb.lessThan(_root.<Comparable>get(propName), (Comparable) value);
} else if (op == Operator.LessThanOrEqual) {
xpred = _cb.lessThanOrEqualTo(_root.<Comparable>get(propName), (Comparable) value);
} else if (op == Operator.In) {
xpred = path.in((List) value);
} else if (op == Operator.StartsWith) {
xpred = _cb.like(path, "" + value + "%");
} else if (op == Operator.EndsWith) {
xpred = _cb.like(path, "%" + value);
} else if (op == Operator.Contains) {
xpred = _cb.like(path, "%" + value + "%");
} else {
throw new RuntimeException("Binary Predicate with the " + op.getName() + "operator is not yet supported.");
}
} else {
String otherPropPath = ((PropExpression) expr2).getPropertyPath();
Path otherPath = _root.get(otherPropPath);
if (op == Operator.Equals) {
xpred = _cb.equal(path, otherPath);
} else if (op == Operator.NotEquals) {
xpred = _cb.notEqual(path, otherPath);
} else if (op == Operator.GreaterThan) {
xpred = _cb.greaterThan(_root.<Comparable>get(propName), _root.<Comparable>get(otherPropPath));
} else if (op == Operator.GreaterThanOrEqual) {
xpred = _cb.greaterThanOrEqualTo(_root.<Comparable>get(propName), _root.<Comparable>get(otherPropPath));
} else if (op == Operator.LessThan) {
xpred = _cb.lessThan(_root.<Comparable>get(propName), _root.<Comparable>get(otherPropPath));
} else if (op == Operator.LessThanOrEqual) {
xpred = _cb.lessThanOrEqualTo(_root.<Comparable>get(propName), _root.<Comparable>get(otherPropPath));
} else if (op == Operator.StartsWith) {
xpred = _cb.like(path, _cb.concat(otherPath, "%"));
} else if (op == Operator.EndsWith) {
xpred = _cb.like(path, _cb.concat("%", otherPath));
} else if (op == Operator.Contains) {
xpred = _cb.like(path, _cb.concat(_cb.concat("%", otherPath), "%"));
} else {
throw new RuntimeException("Property comparison with the " + op.getName() + "operator is not yet supported.");
}
}
crit.where(xpred);
return;
} else {
throw new RuntimeException("Function expressions not yet supported.");
}
} | private void updateCriteria(CriteriaQuery<?> crit, CriteriaBuilder criteriaBuilder, IEntityType entityType, EntityQuery entityQuery) {
_entityType = entityType;
_entityQuery = entityQuery;
_cb = criteriaBuilder;
_root = crit.from(crit.getResultType());
<DeepExtract>
if (entityQuery.getWherePredicate() == null)
return;
BinaryPredicate breezePred = (BinaryPredicate) entityQuery.getWherePredicate();
Operator op = breezePred.getOperator();
String symbol = op.getName();
Expression expr1 = breezePred.getExpr1();
Expression expr2 = breezePred.getExpr2();
String contextAlias = null;
javax.persistence.criteria.Predicate xpred;
if (expr1 instanceof PropExpression) {
PropExpression pexpr1 = (PropExpression) expr1;
String propPath = pexpr1.getPropertyPath();
String propName;
if (pexpr1.getProperty().getParentType().isComplexType()) {
propName = propPath;
} else {
propName = propPath;
}
propName = (contextAlias == null) ? propName : contextAlias + "." + propName;
Path path = _root.get(propName);
if (expr2 instanceof LitExpression) {
Object value = ((LitExpression) expr2).getValue();
if (value == null) {
if (op == Operator.Equals) {
xpred = _cb.isNull(path);
} else if (op == Operator.NotEquals) {
xpred = _cb.isNotNull(path);
} else {
throw new RuntimeException("Binary Predicate with a null value and the " + op.getName() + "operator is not supported .");
}
} else if (op == Operator.Equals) {
xpred = _cb.equal(path, value);
} else if (op == Operator.NotEquals) {
xpred = _cb.notEqual(path, value);
} else if (op == Operator.GreaterThan) {
xpred = _cb.greaterThan(_root.<Comparable>get(propName), (Comparable) value);
} else if (op == Operator.GreaterThanOrEqual) {
xpred = _cb.greaterThanOrEqualTo(_root.<Comparable>get(propName), (Comparable) value);
} else if (op == Operator.LessThan) {
xpred = _cb.lessThan(_root.<Comparable>get(propName), (Comparable) value);
} else if (op == Operator.LessThanOrEqual) {
xpred = _cb.lessThanOrEqualTo(_root.<Comparable>get(propName), (Comparable) value);
} else if (op == Operator.In) {
xpred = path.in((List) value);
} else if (op == Operator.StartsWith) {
xpred = _cb.like(path, "" + value + "%");
} else if (op == Operator.EndsWith) {
xpred = _cb.like(path, "%" + value);
} else if (op == Operator.Contains) {
xpred = _cb.like(path, "%" + value + "%");
} else {
throw new RuntimeException("Binary Predicate with the " + op.getName() + "operator is not yet supported.");
}
} else {
String otherPropPath = ((PropExpression) expr2).getPropertyPath();
Path otherPath = _root.get(otherPropPath);
if (op == Operator.Equals) {
xpred = _cb.equal(path, otherPath);
} else if (op == Operator.NotEquals) {
xpred = _cb.notEqual(path, otherPath);
} else if (op == Operator.GreaterThan) {
xpred = _cb.greaterThan(_root.<Comparable>get(propName), _root.<Comparable>get(otherPropPath));
} else if (op == Operator.GreaterThanOrEqual) {
xpred = _cb.greaterThanOrEqualTo(_root.<Comparable>get(propName), _root.<Comparable>get(otherPropPath));
} else if (op == Operator.LessThan) {
xpred = _cb.lessThan(_root.<Comparable>get(propName), _root.<Comparable>get(otherPropPath));
} else if (op == Operator.LessThanOrEqual) {
xpred = _cb.lessThanOrEqualTo(_root.<Comparable>get(propName), _root.<Comparable>get(otherPropPath));
} else if (op == Operator.StartsWith) {
xpred = _cb.like(path, _cb.concat(otherPath, "%"));
} else if (op == Operator.EndsWith) {
xpred = _cb.like(path, _cb.concat("%", otherPath));
} else if (op == Operator.Contains) {
xpred = _cb.like(path, _cb.concat(_cb.concat("%", otherPath), "%"));
} else {
throw new RuntimeException("Property comparison with the " + op.getName() + "operator is not yet supported.");
}
}
crit.where(xpred);
return;
} else {
throw new RuntimeException("Function expressions not yet supported.");
}
</DeepExtract>
} | breeze.server.java | positive | 1,643 |
private void removeEntry(String key) {
CacheHeader entry;
CacheHeader entry = mEntries.get(key);
if (entry == null) {
entry = null;
}
File file = getFileForKey(key);
CountingInputStream cis = null;
try {
cis = new CountingInputStream(new BufferedInputStream(new FileInputStream(file)));
CacheHeader.readHeader(cis);
byte[] data = streamToBytes(cis, (int) (file.length() - cis.bytesRead));
entry = entry.toCacheEntry(data);
} catch (IOException e) {
VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString());
remove(key);
entry = null;
} catch (NegativeArraySizeException e) {
VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString());
remove(key);
entry = null;
} finally {
if (cis != null) {
try {
cis.close();
} catch (IOException ioe) {
entry = null;
}
}
}
if (entry != null) {
mTotalSize -= entry.size;
mEntries.remove(key);
}
} | private void removeEntry(String key) {
<DeepExtract>
CacheHeader entry;
CacheHeader entry = mEntries.get(key);
if (entry == null) {
entry = null;
}
File file = getFileForKey(key);
CountingInputStream cis = null;
try {
cis = new CountingInputStream(new BufferedInputStream(new FileInputStream(file)));
CacheHeader.readHeader(cis);
byte[] data = streamToBytes(cis, (int) (file.length() - cis.bytesRead));
entry = entry.toCacheEntry(data);
} catch (IOException e) {
VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString());
remove(key);
entry = null;
} catch (NegativeArraySizeException e) {
VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString());
remove(key);
entry = null;
} finally {
if (cis != null) {
try {
cis.close();
} catch (IOException ioe) {
entry = null;
}
}
}
</DeepExtract>
if (entry != null) {
mTotalSize -= entry.size;
mEntries.remove(key);
}
} | MoviePlayerPlus | positive | 1,644 |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String uuid = request.getParameter("uuid");
long newStart = Long.parseLong(request.getParameter("start"));
List<ScheduleEntry> schedule = DataProvider.getSchedule();
for (ScheduleEntry e : schedule) {
if (e.uuid.equals(uuid)) {
if (e.start == newStart) {
response.getWriter().write("no-op");
return;
}
e.start = newStart;
}
}
DataProvider.updateSchedule(schedule);
DataProvider.writeScheduleToClient(response);
} | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
<DeepExtract>
String uuid = request.getParameter("uuid");
long newStart = Long.parseLong(request.getParameter("start"));
List<ScheduleEntry> schedule = DataProvider.getSchedule();
for (ScheduleEntry e : schedule) {
if (e.uuid.equals(uuid)) {
if (e.start == newStart) {
response.getWriter().write("no-op");
return;
}
e.start = newStart;
}
}
DataProvider.updateSchedule(schedule);
DataProvider.writeScheduleToClient(response);
</DeepExtract>
} | obs-video-scheduler | positive | 1,645 |
public Criteria andNameIn(List<String> values) {
if (values == null) {
throw new RuntimeException("Value for " + "name" + " cannot be null");
}
criteria.add(new Criterion("name in", values));
return (Criteria) this;
} | public Criteria andNameIn(List<String> values) {
<DeepExtract>
if (values == null) {
throw new RuntimeException("Value for " + "name" + " cannot be null");
}
criteria.add(new Criterion("name in", values));
</DeepExtract>
return (Criteria) this;
} | community | positive | 1,646 |
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (startAngleRotate != null) {
startAngleRotate.cancel();
startAngleRotate = null;
}
if (progressAnimator != null) {
progressAnimator.cancel();
progressAnimator = null;
}
if (indeterminateAnimator != null) {
indeterminateAnimator.cancel();
indeterminateAnimator = null;
}
} | @Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
<DeepExtract>
if (startAngleRotate != null) {
startAngleRotate.cancel();
startAngleRotate = null;
}
if (progressAnimator != null) {
progressAnimator.cancel();
progressAnimator = null;
}
if (indeterminateAnimator != null) {
indeterminateAnimator.cancel();
indeterminateAnimator = null;
}
</DeepExtract>
} | ZhiHu-Daily | positive | 1,647 |
private void documentSizeShowRelativeCheckBoxMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
documentSizeFormat.setShowRelative(documentSizeShowRelativeCheckBoxMenuItem.isSelected());
if (documentSize == -1) {
documentSizeLabel.setText(documentSizeFormat.isShowRelative() ? "0 (0)" : "0");
} else {
StringBuilder labelBuilder = new StringBuilder();
if (selectionRange != null && !selectionRange.isEmpty()) {
labelBuilder.append(numberToPosition(selectionRange.getLength(), documentSizeFormat.getCodeType()));
labelBuilder.append(" of ");
labelBuilder.append(numberToPosition(documentSize, documentSizeFormat.getCodeType()));
} else {
labelBuilder.append(numberToPosition(documentSize, documentSizeFormat.getCodeType()));
if (documentSizeFormat.isShowRelative()) {
long difference = documentSize - initialDocumentSize;
labelBuilder.append(difference > 0 ? " (+" : " (");
labelBuilder.append(numberToPosition(difference, documentSizeFormat.getCodeType()));
labelBuilder.append(")");
}
}
documentSizeLabel.setText(labelBuilder.toString());
}
StringBuilder builder = new StringBuilder();
builder.append("<html>");
if (selectionRange != null && !selectionRange.isEmpty()) {
long length = selectionRange.getLength();
builder.append("Selection length<br>");
builder.append(OCTAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(length, PositionCodeType.OCTAL)).append("<br>");
builder.append(DECIMAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(length, PositionCodeType.DECIMAL)).append("<br>");
builder.append(HEXADECIMAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(length, PositionCodeType.HEXADECIMAL)).append("<br>");
builder.append("<br>");
}
builder.append("Document size<br>");
builder.append(OCTAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(documentSize, PositionCodeType.OCTAL)).append("<br>");
builder.append(DECIMAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(documentSize, PositionCodeType.DECIMAL)).append("<br>");
builder.append(HEXADECIMAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(documentSize, PositionCodeType.HEXADECIMAL));
builder.append("</html>");
documentSizeLabel.setToolTipText(builder.toString());
} | private void documentSizeShowRelativeCheckBoxMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
documentSizeFormat.setShowRelative(documentSizeShowRelativeCheckBoxMenuItem.isSelected());
if (documentSize == -1) {
documentSizeLabel.setText(documentSizeFormat.isShowRelative() ? "0 (0)" : "0");
} else {
StringBuilder labelBuilder = new StringBuilder();
if (selectionRange != null && !selectionRange.isEmpty()) {
labelBuilder.append(numberToPosition(selectionRange.getLength(), documentSizeFormat.getCodeType()));
labelBuilder.append(" of ");
labelBuilder.append(numberToPosition(documentSize, documentSizeFormat.getCodeType()));
} else {
labelBuilder.append(numberToPosition(documentSize, documentSizeFormat.getCodeType()));
if (documentSizeFormat.isShowRelative()) {
long difference = documentSize - initialDocumentSize;
labelBuilder.append(difference > 0 ? " (+" : " (");
labelBuilder.append(numberToPosition(difference, documentSizeFormat.getCodeType()));
labelBuilder.append(")");
}
}
documentSizeLabel.setText(labelBuilder.toString());
}
<DeepExtract>
StringBuilder builder = new StringBuilder();
builder.append("<html>");
if (selectionRange != null && !selectionRange.isEmpty()) {
long length = selectionRange.getLength();
builder.append("Selection length<br>");
builder.append(OCTAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(length, PositionCodeType.OCTAL)).append("<br>");
builder.append(DECIMAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(length, PositionCodeType.DECIMAL)).append("<br>");
builder.append(HEXADECIMAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(length, PositionCodeType.HEXADECIMAL)).append("<br>");
builder.append("<br>");
}
builder.append("Document size<br>");
builder.append(OCTAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(documentSize, PositionCodeType.OCTAL)).append("<br>");
builder.append(DECIMAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(documentSize, PositionCodeType.DECIMAL)).append("<br>");
builder.append(HEXADECIMAL_CODE_TYPE_LABEL + ": ").append(numberToPosition(documentSize, PositionCodeType.HEXADECIMAL));
builder.append("</html>");
documentSizeLabel.setToolTipText(builder.toString());
</DeepExtract>
} | bytecode-viewer | positive | 1,648 |
@Override
public CreditSessionBankIncomeStatus read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
for (CreditSessionBankIncomeStatus b : CreditSessionBankIncomeStatus.values()) {
if (b.value.equals(value)) {
return b;
}
}
return CreditSessionBankIncomeStatus.ENUM_UNKNOWN;
} | @Override
public CreditSessionBankIncomeStatus read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
<DeepExtract>
for (CreditSessionBankIncomeStatus b : CreditSessionBankIncomeStatus.values()) {
if (b.value.equals(value)) {
return b;
}
}
return CreditSessionBankIncomeStatus.ENUM_UNKNOWN;
</DeepExtract>
} | plaid-java | positive | 1,649 |
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("ch06/job/job-db-paging-jpa.xml");
JobLauncher launcher = (JobLauncher) context.getBean("jobLauncher");
Job job = (Job) context.getBean("jpaPagingReadJob");
try {
JobExecution result = launcher.run(job, new JobParametersBuilder().addDate("date", new Date()).addString("id_begin", "1").addString("id_end", "4").toJobParameters());
System.out.println(result.toString());
} catch (Exception e) {
e.printStackTrace();
}
} | public static void main(String[] args) {
<DeepExtract>
ApplicationContext context = new ClassPathXmlApplicationContext("ch06/job/job-db-paging-jpa.xml");
JobLauncher launcher = (JobLauncher) context.getBean("jobLauncher");
Job job = (Job) context.getBean("jpaPagingReadJob");
try {
JobExecution result = launcher.run(job, new JobParametersBuilder().addDate("date", new Date()).addString("id_begin", "1").addString("id_end", "4").toJobParameters());
System.out.println(result.toString());
} catch (Exception e) {
e.printStackTrace();
}
</DeepExtract>
} | SpringBatchSample | positive | 1,650 |
@Test
public void shouldApplySetCommandAndTriggerFutureOnRaftCallback() throws Exception {
String key = "KEY";
String value = "VALUE";
SetValue setValue = new SetValue();
setValue.setNewValue(value);
when(raftAgent.submitCommand(any(KayVeeCommand.class))).thenReturn(SettableFuture.<Void>create());
when(localStore.set(anyLong(), eq(key), eq(value))).thenReturn(new KeyValue(key, value));
distributedStore.initialize();
distributedStore.start();
ListenableFuture<KeyValue> setFuture = distributedStore.set(key, setValue);
assertThat(setFuture.isDone(), equalTo(false));
ArgumentCaptor<Command> captor = ArgumentCaptor.forClass(Command.class);
verify(raftAgent).submitCommand(captor.capture());
distributedStore.applyCommitted(new TestCommittedCommand(1, captor.getValue()));
verify(localStore).set(1, key, value);
assertThat(setFuture.isDone(), equalTo(true));
assertThat(setFuture.get().getKey(), equalTo(key));
assertThat(setFuture.get().getValue(), equalTo(value));
distributedStore.stop();
} | @Test
public void shouldApplySetCommandAndTriggerFutureOnRaftCallback() throws Exception {
String key = "KEY";
String value = "VALUE";
SetValue setValue = new SetValue();
setValue.setNewValue(value);
when(raftAgent.submitCommand(any(KayVeeCommand.class))).thenReturn(SettableFuture.<Void>create());
when(localStore.set(anyLong(), eq(key), eq(value))).thenReturn(new KeyValue(key, value));
<DeepExtract>
distributedStore.initialize();
distributedStore.start();
</DeepExtract>
ListenableFuture<KeyValue> setFuture = distributedStore.set(key, setValue);
assertThat(setFuture.isDone(), equalTo(false));
ArgumentCaptor<Command> captor = ArgumentCaptor.forClass(Command.class);
verify(raftAgent).submitCommand(captor.capture());
distributedStore.applyCommitted(new TestCommittedCommand(1, captor.getValue()));
verify(localStore).set(1, key, value);
assertThat(setFuture.isDone(), equalTo(true));
assertThat(setFuture.get().getKey(), equalTo(key));
assertThat(setFuture.get().getValue(), equalTo(value));
distributedStore.stop();
} | libraft | positive | 1,651 |
@Override
public void translateTo(TradeTransaction event, long sequence) {
event.setPrice(random.nextDouble() * 9999);
return event;
} | @Override
public void translateTo(TradeTransaction event, long sequence) {
<DeepExtract>
event.setPrice(random.nextDouble() * 9999);
return event;
</DeepExtract>
} | dht | positive | 1,652 |
@Override
public Set<String> getDeferredCriticalHeaderParams() {
return critPolicy.getProcessedCriticalHeaderParams();
} | @Override
public Set<String> getDeferredCriticalHeaderParams() {
<DeepExtract>
return critPolicy.getProcessedCriticalHeaderParams();
</DeepExtract>
} | cord3c-project | positive | 1,653 |
public void setUpViewViewPager(ViewPager viewPager) {
mViewPager = viewPager;
mViewPager.setAdapter(this);
mViewPager.getAdapter().notifyDataSetChanged();
int currentItem = canLoop ? getStartSelectItem() : 0;
try {
mViewPager.setCurrentItem(currentItem, false);
} catch (IllegalStateException e) {
e.printStackTrace();
}
} | public void setUpViewViewPager(ViewPager viewPager) {
mViewPager = viewPager;
mViewPager.setAdapter(this);
mViewPager.getAdapter().notifyDataSetChanged();
int currentItem = canLoop ? getStartSelectItem() : 0;
<DeepExtract>
try {
mViewPager.setCurrentItem(currentItem, false);
} catch (IllegalStateException e) {
e.printStackTrace();
}
</DeepExtract>
} | wanAndroid | positive | 1,654 |
@Override
protected void onWindowVisibilityChanged(int visibility) {
super.onWindowVisibilityChanged(visibility);
if (mDrawable == null) {
return;
}
if (visibility == VISIBLE) {
if (mNeedRun) {
start();
}
} else {
if (mDrawable.isRunning()) {
mNeedRun = true;
mDrawable.stop();
}
}
} | @Override
protected void onWindowVisibilityChanged(int visibility) {
super.onWindowVisibilityChanged(visibility);
<DeepExtract>
if (mDrawable == null) {
return;
}
if (visibility == VISIBLE) {
if (mNeedRun) {
start();
}
} else {
if (mDrawable.isRunning()) {
mNeedRun = true;
mDrawable.stop();
}
}
</DeepExtract>
} | Akit-Reader | positive | 1,655 |
@Test
public void testVar() {
ELProcessor elp = new ELProcessor();
elp.setVariable("v", "x->x+1");
System.out.println("=== Test Lambda Expression:" + "assignment to variable" + " ===");
System.out.println(" ** " + "v(10)");
Object result = elp.eval("v(10)");
System.out.println(" returns " + result);
assertEquals(11L, result);
} | @Test
public void testVar() {
ELProcessor elp = new ELProcessor();
elp.setVariable("v", "x->x+1");
<DeepExtract>
System.out.println("=== Test Lambda Expression:" + "assignment to variable" + " ===");
System.out.println(" ** " + "v(10)");
Object result = elp.eval("v(10)");
System.out.println(" returns " + result);
assertEquals(11L, result);
</DeepExtract>
} | uel-ri | positive | 1,656 |
private boolean isSettingFor(String setting) {
if (!isType(LineType.SETTING_TABLE_LINE)) {
return false;
}
if (arguments.size() < 2) {
return false;
}
ParsedString firstArgument = arguments.get(0);
if (firstArgument.getType() != ArgumentType.SETTING_KEY) {
return false;
}
if (this == setting)
return true;
if (setting == null)
return false;
if (getClass() != setting.getClass())
return false;
RobotLine other = (RobotLine) setting;
if (arguments == null) {
if (other.arguments != null)
return false;
} else if (!arguments.equals(other.arguments))
return false;
if (lineCharPos != other.lineCharPos)
return false;
if (lineNo != other.lineNo)
return false;
if (type != other.type)
return false;
return true;
} | private boolean isSettingFor(String setting) {
if (!isType(LineType.SETTING_TABLE_LINE)) {
return false;
}
if (arguments.size() < 2) {
return false;
}
ParsedString firstArgument = arguments.get(0);
if (firstArgument.getType() != ArgumentType.SETTING_KEY) {
return false;
}
<DeepExtract>
if (this == setting)
return true;
if (setting == null)
return false;
if (getClass() != setting.getClass())
return false;
RobotLine other = (RobotLine) setting;
if (arguments == null) {
if (other.arguments != null)
return false;
} else if (!arguments.equals(other.arguments))
return false;
if (lineCharPos != other.lineCharPos)
return false;
if (lineNo != other.lineNo)
return false;
if (type != other.type)
return false;
return true;
</DeepExtract>
} | RobotFramework-EclipseIDE | positive | 1,657 |
protected final Object rateLimit(final ProceedingJoinPoint joinPoint, final UserPrincipal userPrincipal) throws Throwable {
if (getRateLimit() == NO_RATE_LIMIT || getBucketSize() == NO_RATE_LIMIT) {
return joinPoint.proceed();
}
Optional<UserDetails> dbUser = Optional.empty();
if (userPrincipal != null) {
dbUser = userDetailsService.findByUserGuid(userPrincipal.getUserGuid());
}
if (dbUser.isEmpty()) {
return joinPoint.proceed();
}
LocalDateTime requestCalculationTime = LocalDateTime.now(systemClock);
RateLimit rateLimit = rateLimitBucketCalculator.calculate(requestCalculationTime, rateLimitService.findRateLimitByUserAndType(dbUser.get(), getRateLimitType()), getBucketSize(), ChronoUnit.SECONDS);
if (rateLimit.getBucketCount() > getRateLimit()) {
throw new RateLimitTimeoutException(ChronoUnit.SECONDS.between(requestCalculationTime, rateLimit.getLastUpdateTime()));
}
Object result = joinPoint.proceed();
rateLimitService.save(rateLimit);
return result;
} | protected final Object rateLimit(final ProceedingJoinPoint joinPoint, final UserPrincipal userPrincipal) throws Throwable {
if (getRateLimit() == NO_RATE_LIMIT || getBucketSize() == NO_RATE_LIMIT) {
return joinPoint.proceed();
}
Optional<UserDetails> dbUser = Optional.empty();
if (userPrincipal != null) {
dbUser = userDetailsService.findByUserGuid(userPrincipal.getUserGuid());
}
if (dbUser.isEmpty()) {
return joinPoint.proceed();
}
LocalDateTime requestCalculationTime = LocalDateTime.now(systemClock);
RateLimit rateLimit = rateLimitBucketCalculator.calculate(requestCalculationTime, rateLimitService.findRateLimitByUserAndType(dbUser.get(), getRateLimitType()), getBucketSize(), ChronoUnit.SECONDS);
if (rateLimit.getBucketCount() > getRateLimit()) {
throw new RateLimitTimeoutException(ChronoUnit.SECONDS.between(requestCalculationTime, rateLimit.getLastUpdateTime()));
}
Object result = joinPoint.proceed();
<DeepExtract>
rateLimitService.save(rateLimit);
</DeepExtract>
return result;
} | virusafe-backend | positive | 1,658 |
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (!mReady) {
mSetupPending = true;
return;
}
if (getWidth() == 0 && getHeight() == 0) {
return;
}
if (mBitmap == null) {
invalidate();
return;
}
mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mBitmapPaint.setAntiAlias(true);
mBitmapPaint.setShader(mBitmapShader);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setAntiAlias(true);
mBorderPaint.setColor(mBorderColor);
mBorderPaint.setStrokeWidth(mBorderWidth);
mFillPaint.setStyle(Paint.Style.FILL);
mFillPaint.setAntiAlias(true);
mFillPaint.setColor(mFillColor);
mBitmapHeight = mBitmap.getHeight();
mBitmapWidth = mBitmap.getWidth();
mBorderRect.set(calculateBounds());
mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2.0f, (mBorderRect.width() - mBorderWidth) / 2.0f);
mDrawableRect.set(mBorderRect);
if (!mBorderOverlay && mBorderWidth > 0) {
mDrawableRect.inset(mBorderWidth - 1.0f, mBorderWidth - 1.0f);
}
mDrawableRadius = Math.min(mDrawableRect.height() / 2.0f, mDrawableRect.width() / 2.0f);
applyColorFilter();
updateShaderMatrix();
invalidate();
} | @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
<DeepExtract>
if (!mReady) {
mSetupPending = true;
return;
}
if (getWidth() == 0 && getHeight() == 0) {
return;
}
if (mBitmap == null) {
invalidate();
return;
}
mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mBitmapPaint.setAntiAlias(true);
mBitmapPaint.setShader(mBitmapShader);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setAntiAlias(true);
mBorderPaint.setColor(mBorderColor);
mBorderPaint.setStrokeWidth(mBorderWidth);
mFillPaint.setStyle(Paint.Style.FILL);
mFillPaint.setAntiAlias(true);
mFillPaint.setColor(mFillColor);
mBitmapHeight = mBitmap.getHeight();
mBitmapWidth = mBitmap.getWidth();
mBorderRect.set(calculateBounds());
mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2.0f, (mBorderRect.width() - mBorderWidth) / 2.0f);
mDrawableRect.set(mBorderRect);
if (!mBorderOverlay && mBorderWidth > 0) {
mDrawableRect.inset(mBorderWidth - 1.0f, mBorderWidth - 1.0f);
}
mDrawableRadius = Math.min(mDrawableRect.height() / 2.0f, mDrawableRect.width() / 2.0f);
applyColorFilter();
updateShaderMatrix();
invalidate();
</DeepExtract>
} | Silisili | positive | 1,660 |
@Override
public JsonElement serialize(ApiCall apiCall, Type type, JsonSerializationContext jsonSerializationContext) {
JsonObject obj = new JsonObject();
obj.addProperty(KEY_SEQUENCE_ID, this.sequenceId);
obj.addProperty(KEY_METHOD, this.method);
JsonArray paramsArray = new JsonArray();
paramsArray.add(this.apiId);
paramsArray.add(this.methodToCall);
JsonArray methodParams = new JsonArray();
if (this.params != null) {
for (int i = 0; i < this.params.size(); i++) {
if (this.params.get(i) instanceof JsonSerializable) {
methodParams.add(((JsonSerializable) this.params.get(i)).toJsonObject());
} else if (Number.class.isInstance(this.params.get(i))) {
methodParams.add((Number) this.params.get(i));
} else if (this.params.get(i) instanceof String || this.params.get(i) == null) {
methodParams.add((String) this.params.get(i));
} else if (this.params.get(i) instanceof ArrayList) {
JsonArray array = new JsonArray();
ArrayList<Serializable> listArgument = (ArrayList<Serializable>) this.params.get(i);
for (int l = 0; l < listArgument.size(); l++) {
Serializable element = listArgument.get(l);
if (element instanceof JsonSerializable)
array.add(((JsonSerializable) element).toJsonObject());
else if (element instanceof String) {
array.add((String) element);
} else if (element instanceof Long) {
array.add((Long) element);
} else if (element instanceof Integer) {
array.add((Integer) element);
}
}
methodParams.add(array);
} else if (this.params.get(i) instanceof Boolean) {
methodParams.add((boolean) this.params.get(i));
} else {
System.out.println("Skipping parameter of type: " + this.params.get(i).getClass());
}
}
}
paramsArray.add(methodParams);
obj.add(KEY_PARAMS, paramsArray);
obj.addProperty(KEY_JSON_RPC, this.jsonrpc);
return obj;
} | @Override
public JsonElement serialize(ApiCall apiCall, Type type, JsonSerializationContext jsonSerializationContext) {
<DeepExtract>
JsonObject obj = new JsonObject();
obj.addProperty(KEY_SEQUENCE_ID, this.sequenceId);
obj.addProperty(KEY_METHOD, this.method);
JsonArray paramsArray = new JsonArray();
paramsArray.add(this.apiId);
paramsArray.add(this.methodToCall);
JsonArray methodParams = new JsonArray();
if (this.params != null) {
for (int i = 0; i < this.params.size(); i++) {
if (this.params.get(i) instanceof JsonSerializable) {
methodParams.add(((JsonSerializable) this.params.get(i)).toJsonObject());
} else if (Number.class.isInstance(this.params.get(i))) {
methodParams.add((Number) this.params.get(i));
} else if (this.params.get(i) instanceof String || this.params.get(i) == null) {
methodParams.add((String) this.params.get(i));
} else if (this.params.get(i) instanceof ArrayList) {
JsonArray array = new JsonArray();
ArrayList<Serializable> listArgument = (ArrayList<Serializable>) this.params.get(i);
for (int l = 0; l < listArgument.size(); l++) {
Serializable element = listArgument.get(l);
if (element instanceof JsonSerializable)
array.add(((JsonSerializable) element).toJsonObject());
else if (element instanceof String) {
array.add((String) element);
} else if (element instanceof Long) {
array.add((Long) element);
} else if (element instanceof Integer) {
array.add((Integer) element);
}
}
methodParams.add(array);
} else if (this.params.get(i) instanceof Boolean) {
methodParams.add((boolean) this.params.get(i));
} else {
System.out.println("Skipping parameter of type: " + this.params.get(i).getClass());
}
}
}
paramsArray.add(methodParams);
obj.add(KEY_PARAMS, paramsArray);
obj.addProperty(KEY_JSON_RPC, this.jsonrpc);
return obj;
</DeepExtract>
} | graphenej | positive | 1,661 |
public static String getRandomStringOnlyLowerCase(int length) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < length; i++) {
builder.append((char) getRandomInteger(97, 122));
}
return builder.toString();
} | public static String getRandomStringOnlyLowerCase(int length) {
<DeepExtract>
StringBuilder builder = new StringBuilder();
for (int i = 0; i < length; i++) {
builder.append((char) getRandomInteger(97, 122));
}
return builder.toString();
</DeepExtract>
} | util | positive | 1,662 |
public static void main(String[] args) throws Exception {
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
try {
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100).childHandler(new HttpPipelineInitializer().addRequestHandler(buildRequestHandler()));
ChannelFuture f = b.bind(8022).sync();
f.channel().closeFuture().sync();
} finally {
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
} | public static void main(String[] args) throws Exception {
<DeepExtract>
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
try {
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100).childHandler(new HttpPipelineInitializer().addRequestHandler(buildRequestHandler()));
ChannelFuture f = b.bind(8022).sync();
f.channel().closeFuture().sync();
} finally {
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
</DeepExtract>
} | java-learn | positive | 1,663 |
public Criteria andConfIdBetween(String value1, String value2) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + "confId" + " cannot be null");
}
criteria.add(new Criterion("conf_id between", value1, value2));
return (Criteria) this;
} | public Criteria andConfIdBetween(String value1, String value2) {
<DeepExtract>
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + "confId" + " cannot be null");
}
criteria.add(new Criterion("conf_id between", value1, value2));
</DeepExtract>
return (Criteria) this;
} | lightconf | positive | 1,664 |
public static void copyDirectoryToDirectory(File srcDir, File destDir) throws IOException {
if (srcDir == null) {
throw new NullPointerException("Source must not be null");
}
if (srcDir.exists() && srcDir.isDirectory() == false) {
throw new IllegalArgumentException("Source '" + destDir + "' is not a directory");
}
if (destDir == null) {
throw new NullPointerException("Destination must not be null");
}
if (destDir.exists() && destDir.isDirectory() == false) {
throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory");
}
copyDirectory(srcDir, new File(destDir, srcDir.getName()), null, true);
} | public static void copyDirectoryToDirectory(File srcDir, File destDir) throws IOException {
if (srcDir == null) {
throw new NullPointerException("Source must not be null");
}
if (srcDir.exists() && srcDir.isDirectory() == false) {
throw new IllegalArgumentException("Source '" + destDir + "' is not a directory");
}
if (destDir == null) {
throw new NullPointerException("Destination must not be null");
}
if (destDir.exists() && destDir.isDirectory() == false) {
throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory");
}
<DeepExtract>
copyDirectory(srcDir, new File(destDir, srcDir.getName()), null, true);
</DeepExtract>
} | ToolsFinal | positive | 1,665 |
public Where<T> lt(JoinAlias joinAlias, String columnFieldName, Object value) throws SQLException {
if (clause != null)
throw new SQLException("Clause already defined. Must use and/or for multiple conditions");
clause = queryFactory.lt(joinAlias, columnFieldName, value);
return this;
} | public Where<T> lt(JoinAlias joinAlias, String columnFieldName, Object value) throws SQLException {
<DeepExtract>
if (clause != null)
throw new SQLException("Clause already defined. Must use and/or for multiple conditions");
</DeepExtract>
clause = queryFactory.lt(joinAlias, columnFieldName, value);
return this;
} | Squeaky | positive | 1,666 |
public void redo() {
for (StateTransition transition : node.getOutputs()) {
transition.getTarget().removeInput(transition);
}
for (StateTransition transition : node.getInputs()) {
transition.getSource().removeOutput(transition);
}
stateMachine.removeNode(node);
} | public void redo() {
<DeepExtract>
for (StateTransition transition : node.getOutputs()) {
transition.getTarget().removeInput(transition);
}
for (StateTransition transition : node.getInputs()) {
transition.getSource().removeOutput(transition);
}
stateMachine.removeNode(node);
</DeepExtract>
} | xState | positive | 1,667 |
public OnDisconnectListener addOnDisconnectListener(OnDisconnectListener listener) {
mOnDisconnectListeners.add(listener);
return listener;
} | public OnDisconnectListener addOnDisconnectListener(OnDisconnectListener listener) {
<DeepExtract>
mOnDisconnectListeners.add(listener);
return listener;
</DeepExtract>
} | autobahn-java | positive | 1,668 |
void readProperties(java.util.Properties p) {
String version = p.getProperty("version");
if (!"1.0".equals(version)) {
LOG.warning("Unknown version for TopComponent properties");
}
String connector = p.getProperty("connector");
String repository = p.getProperty("repository");
String issueId = p.getProperty("issue");
if (connector != null && repository != null && issueId != null) {
RepositoryManager.getInstance().getRepository(connector, repository);
RedmineRepository rr = RedmineRepository.getInstanceyById(repository);
if (rr != null) {
RedmineIssue ri = rr.getIssue(issueId);
if (ri != null) {
this.setIssue(ri);
}
String time = p.getProperty("time", "0");
try {
this.savedTime = Long.parseLong(time);
} catch (NumberFormatException ex) {
}
}
}
long timeInMS = currentTime();
if (issue == null) {
repositoryOutputLabel.setText(Bundle.MSG_NoIssue());
issueOutputLabel.setText(Bundle.MSG_NoIssue());
issueOutputLabel.setEnabled(false);
timeOutputLabel.setText(Bundle.MSG_Time(TimeUtil.millisecondsToDecimalHours(0l)));
saveButton.setEnabled(false);
resetButton.setEnabled(false);
startButton.setEnabled(false);
} else {
repositoryOutputLabel.setText(issue.getRepository().getDisplayName());
issueOutputLabel.setText(Bundle.MSG_Issue(issue.getID(), issue.getSummary()));
issueOutputLabel.setEnabled(true);
startButton.setEnabled(true);
if (running) {
resetButton.setEnabled(false);
saveButton.setEnabled(false);
startButton.setText(Bundle.BTN_StopTracking());
timeOutputLabel.setText(Bundle.MSG_Time_Running(TimeUtil.millisecondsToDecimalHours(timeInMS)));
} else {
startButton.setText(Bundle.BTN_StartTracking());
if (savedTime > 0) {
saveButton.setEnabled(true);
resetButton.setEnabled(true);
} else {
saveButton.setEnabled(false);
resetButton.setEnabled(false);
}
timeOutputLabel.setText(Bundle.MSG_Time(TimeUtil.millisecondsToDecimalHours(timeInMS)));
}
}
} | void readProperties(java.util.Properties p) {
String version = p.getProperty("version");
if (!"1.0".equals(version)) {
LOG.warning("Unknown version for TopComponent properties");
}
String connector = p.getProperty("connector");
String repository = p.getProperty("repository");
String issueId = p.getProperty("issue");
if (connector != null && repository != null && issueId != null) {
RepositoryManager.getInstance().getRepository(connector, repository);
RedmineRepository rr = RedmineRepository.getInstanceyById(repository);
if (rr != null) {
RedmineIssue ri = rr.getIssue(issueId);
if (ri != null) {
this.setIssue(ri);
}
String time = p.getProperty("time", "0");
try {
this.savedTime = Long.parseLong(time);
} catch (NumberFormatException ex) {
}
}
}
<DeepExtract>
long timeInMS = currentTime();
if (issue == null) {
repositoryOutputLabel.setText(Bundle.MSG_NoIssue());
issueOutputLabel.setText(Bundle.MSG_NoIssue());
issueOutputLabel.setEnabled(false);
timeOutputLabel.setText(Bundle.MSG_Time(TimeUtil.millisecondsToDecimalHours(0l)));
saveButton.setEnabled(false);
resetButton.setEnabled(false);
startButton.setEnabled(false);
} else {
repositoryOutputLabel.setText(issue.getRepository().getDisplayName());
issueOutputLabel.setText(Bundle.MSG_Issue(issue.getID(), issue.getSummary()));
issueOutputLabel.setEnabled(true);
startButton.setEnabled(true);
if (running) {
resetButton.setEnabled(false);
saveButton.setEnabled(false);
startButton.setText(Bundle.BTN_StopTracking());
timeOutputLabel.setText(Bundle.MSG_Time_Running(TimeUtil.millisecondsToDecimalHours(timeInMS)));
} else {
startButton.setText(Bundle.BTN_StartTracking());
if (savedTime > 0) {
saveButton.setEnabled(true);
resetButton.setEnabled(true);
} else {
saveButton.setEnabled(false);
resetButton.setEnabled(false);
}
timeOutputLabel.setText(Bundle.MSG_Time(TimeUtil.millisecondsToDecimalHours(timeInMS)));
}
}
</DeepExtract>
} | redminenb | positive | 1,669 |
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if (text != null) {
try {
if (leftDrawable != null) {
width - getPaddingLeft() - getPaddingRight() -= leftDrawable.getIntrinsicWidth();
width - getPaddingLeft() - getPaddingRight() -= drawablePadding;
}
if (rightDrawable != null) {
width - getPaddingLeft() - getPaddingRight() -= rightDrawable.getIntrinsicWidth();
width - getPaddingLeft() - getPaddingRight() -= drawablePadding;
}
width - getPaddingLeft() - getPaddingRight() -= getPaddingLeft() + getPaddingRight();
CharSequence string = TextUtils.ellipsize(text, textPaint, width - getPaddingLeft() - getPaddingRight(), TextUtils.TruncateAt.END);
if (layout != null && TextUtils.equals(layout.getText(), string)) {
return false;
}
layout = new StaticLayout(string, 0, string.length(), textPaint, width - getPaddingLeft() - getPaddingRight() + AndroidUtilities.dp(8), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (layout.getLineCount() > 0) {
textWidth = (int) Math.ceil(layout.getLineWidth(0));
textHeight = layout.getLineBottom(0);
if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT) {
offsetX = -(int) layout.getLineLeft(0);
} else if (layout.getLineLeft(0) == 0) {
offsetX = width - getPaddingLeft() - getPaddingRight() - textWidth;
} else {
offsetX = -AndroidUtilities.dp(8);
}
}
} catch (Exception e) {
}
} else {
layout = null;
textWidth = 0;
textHeight = 0;
}
invalidate();
return true;
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY) {
finalHeight = height;
} else {
finalHeight = textHeight;
}
setMeasuredDimension(width, finalHeight);
} | @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
<DeepExtract>
if (text != null) {
try {
if (leftDrawable != null) {
width - getPaddingLeft() - getPaddingRight() -= leftDrawable.getIntrinsicWidth();
width - getPaddingLeft() - getPaddingRight() -= drawablePadding;
}
if (rightDrawable != null) {
width - getPaddingLeft() - getPaddingRight() -= rightDrawable.getIntrinsicWidth();
width - getPaddingLeft() - getPaddingRight() -= drawablePadding;
}
width - getPaddingLeft() - getPaddingRight() -= getPaddingLeft() + getPaddingRight();
CharSequence string = TextUtils.ellipsize(text, textPaint, width - getPaddingLeft() - getPaddingRight(), TextUtils.TruncateAt.END);
if (layout != null && TextUtils.equals(layout.getText(), string)) {
return false;
}
layout = new StaticLayout(string, 0, string.length(), textPaint, width - getPaddingLeft() - getPaddingRight() + AndroidUtilities.dp(8), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (layout.getLineCount() > 0) {
textWidth = (int) Math.ceil(layout.getLineWidth(0));
textHeight = layout.getLineBottom(0);
if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT) {
offsetX = -(int) layout.getLineLeft(0);
} else if (layout.getLineLeft(0) == 0) {
offsetX = width - getPaddingLeft() - getPaddingRight() - textWidth;
} else {
offsetX = -AndroidUtilities.dp(8);
}
}
} catch (Exception e) {
}
} else {
layout = null;
textWidth = 0;
textHeight = 0;
}
invalidate();
return true;
</DeepExtract>
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY) {
finalHeight = height;
} else {
finalHeight = textHeight;
}
setMeasuredDimension(width, finalHeight);
} | TelegramGallery | positive | 1,670 |
public void setScaleType(ScaleType scaleType) {
mScaleType = scaleType;
mRenderer.setScaleType(scaleType);
mRenderer.deleteImage();
mCurrentBitmap = null;
requestRender();
mCurrentBitmap = null;
if (mGlSurfaceView != null) {
mGlSurfaceView.requestRender();
}
} | public void setScaleType(ScaleType scaleType) {
mScaleType = scaleType;
mRenderer.setScaleType(scaleType);
mRenderer.deleteImage();
mCurrentBitmap = null;
requestRender();
mCurrentBitmap = null;
<DeepExtract>
if (mGlSurfaceView != null) {
mGlSurfaceView.requestRender();
}
</DeepExtract>
} | android-instagram-image-filter | positive | 1,671 |
public static cvg.sfmPipeline.main.PipelineOutMessage.CameraBodyTransProto parseFrom(java.io.InputStream input) throws java.io.IOException {
cvg.sfmPipeline.main.PipelineOutMessage.CvMatDimProto result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result).asInvalidProtocolBufferException();
}
return result;
} | public static cvg.sfmPipeline.main.PipelineOutMessage.CameraBodyTransProto parseFrom(java.io.InputStream input) throws java.io.IOException {
<DeepExtract>
cvg.sfmPipeline.main.PipelineOutMessage.CvMatDimProto result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result).asInvalidProtocolBufferException();
}
return result;
</DeepExtract>
} | Android-SfM-client | positive | 1,673 |
public void addLast(E e) {
if (size < 0 || size > size) {
throw new IllegalArgumentException("Add failed. Require index >= 0 and index <= size");
}
if (size == data.length) {
resize(2 * data.length);
}
for (int i = size - 1; i >= size; i--) {
data[i + 1] = data[i];
}
data[size] = e;
size++;
} | public void addLast(E e) {
<DeepExtract>
if (size < 0 || size > size) {
throw new IllegalArgumentException("Add failed. Require index >= 0 and index <= size");
}
if (size == data.length) {
resize(2 * data.length);
}
for (int i = size - 1; i >= size; i--) {
data[i + 1] = data[i];
}
data[size] = e;
size++;
</DeepExtract>
} | Play-with-Data-Structures-Ronglexie | positive | 1,674 |
private static void graficoVazio(AnchorPane box) {
Label info = new Label("Dados não encontrados ou vazios para geração dos relátorios !");
info.getStyleClass().add("conteudo-vazio");
box.getChildren().clear();
Resize.margin(info, 0);
box.getChildren().add(info);
} | private static void graficoVazio(AnchorPane box) {
Label info = new Label("Dados não encontrados ou vazios para geração dos relátorios !");
info.getStyleClass().add("conteudo-vazio");
<DeepExtract>
box.getChildren().clear();
Resize.margin(info, 0);
box.getChildren().add(info);
</DeepExtract>
} | museuid | positive | 1,675 |
public Criteria andGoodsPriceNotIn(List<Double> values) {
if (values == null) {
throw new RuntimeException("Value for " + "goodsPrice" + " cannot be null");
}
criteria.add(new Criterion("goods_price not in", values));
return (Criteria) this;
} | public Criteria andGoodsPriceNotIn(List<Double> values) {
<DeepExtract>
if (values == null) {
throw new RuntimeException("Value for " + "goodsPrice" + " cannot be null");
}
criteria.add(new Criterion("goods_price not in", values));
</DeepExtract>
return (Criteria) this;
} | ssmxiaomi | positive | 1,677 |
@Override
public FileSystemException createSetModificationTimeException(String file, SftpException exception) {
final FileSystemException exception;
switch(exception.id) {
case ChannelSftp.SSH_FX_NO_SUCH_FILE:
exception = new NoSuchFileException(file, null, exception.getMessage());
break;
case ChannelSftp.SSH_FX_PERMISSION_DENIED:
exception = new AccessDeniedException(file, null, exception.getMessage());
break;
default:
exception = new FileSystemException(file, null, exception.getMessage());
break;
}
exception.initCause(exception);
return exception;
} | @Override
public FileSystemException createSetModificationTimeException(String file, SftpException exception) {
<DeepExtract>
final FileSystemException exception;
switch(exception.id) {
case ChannelSftp.SSH_FX_NO_SUCH_FILE:
exception = new NoSuchFileException(file, null, exception.getMessage());
break;
case ChannelSftp.SSH_FX_PERMISSION_DENIED:
exception = new AccessDeniedException(file, null, exception.getMessage());
break;
default:
exception = new FileSystemException(file, null, exception.getMessage());
break;
}
exception.initCause(exception);
return exception;
</DeepExtract>
} | sftp-fs | positive | 1,678 |
@Bean
public JavaMailSender mailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
this.host = mailProperties().getHost();
if (mailProperties().getPort() != null) {
mailSender.setPort(mailProperties().getPort());
}
this.username = mailProperties().getUsername();
this.password = mailProperties().getPassword();
return mailSender;
} | @Bean
public JavaMailSender mailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
this.host = mailProperties().getHost();
if (mailProperties().getPort() != null) {
mailSender.setPort(mailProperties().getPort());
}
this.username = mailProperties().getUsername();
<DeepExtract>
this.password = mailProperties().getPassword();
</DeepExtract>
return mailSender;
} | PAAS-TA-PORTAL-COMMON-API | positive | 1,681 |
public void pollBluetoothDevices() {
try {
if (null != null) {
String payloadClassName = null.getClass().getSimpleName();
spineCodec = (SpineCodec) htInstance.get(payloadClassName);
if (spineCodec == null) {
Class p = Class.forName(SPINEDATACODEC_PACKAGE + payloadClassName + "_codec");
spineCodec = (SpineCodec) p.newInstance();
htInstance.put(null.getClass().getSimpleName(), spineCodec);
}
}
Class c = (Class) htInstance.get(MESSAGE_CLASSNAME);
if (c == null) {
c = Class.forName(MESSAGE_CLASSNAME);
htInstance.put(MESSAGE_CLASSNAME, c);
}
com.tilab.gal.Message msg = (com.tilab.gal.Message) c.newInstance();
msg.setDestinationURL(URL_PREFIX + new Address("" + SPINEPacketsConstants.SPINE_BROADCAST).getAsInt());
msg.setClusterId(SPINEPacketsConstants.POLL_BLUETOOTH_DEVICES);
msg.setProfileId(MY_GROUP_ID);
if (null != null) {
try {
byte[] payloadArray = spineCodec.encode(null);
short[] payloadShort = new short[payloadArray.length];
for (int i = 0; i < payloadShort.length; i++) payloadShort[i] = payloadArray[i];
msg.setPayload(payloadShort);
} catch (MethodNotSupportedException e) {
e.printStackTrace();
if (SPINEManager.getLogger().isLoggable(Logger.SEVERE))
SPINEManager.getLogger().log(Logger.SEVERE, e.getMessage());
}
}
connection.send(msg);
} catch (InstantiationException e) {
e.printStackTrace();
if (l.isLoggable(Logger.SEVERE))
l.log(Logger.SEVERE, "InstantiationException" + e.getMessage());
} catch (IllegalAccessException e) {
e.printStackTrace();
if (l.isLoggable(Logger.SEVERE))
l.log(Logger.SEVERE, "IllegalAccessException" + e.getMessage());
} catch (ClassNotFoundException e) {
e.printStackTrace();
if (l.isLoggable(Logger.SEVERE))
l.log(Logger.SEVERE, "ClassNotFoundException" + e.getMessage());
} catch (InterruptedIOException e) {
e.printStackTrace();
if (l.isLoggable(Logger.SEVERE))
l.log(Logger.SEVERE, "InterruptedIOException" + e.getMessage());
} catch (UnsupportedOperationException e) {
e.printStackTrace();
if (l.isLoggable(Logger.SEVERE))
l.log(Logger.SEVERE, "UnsupportedOperationException" + e.getMessage());
}
} | public void pollBluetoothDevices() {
<DeepExtract>
try {
if (null != null) {
String payloadClassName = null.getClass().getSimpleName();
spineCodec = (SpineCodec) htInstance.get(payloadClassName);
if (spineCodec == null) {
Class p = Class.forName(SPINEDATACODEC_PACKAGE + payloadClassName + "_codec");
spineCodec = (SpineCodec) p.newInstance();
htInstance.put(null.getClass().getSimpleName(), spineCodec);
}
}
Class c = (Class) htInstance.get(MESSAGE_CLASSNAME);
if (c == null) {
c = Class.forName(MESSAGE_CLASSNAME);
htInstance.put(MESSAGE_CLASSNAME, c);
}
com.tilab.gal.Message msg = (com.tilab.gal.Message) c.newInstance();
msg.setDestinationURL(URL_PREFIX + new Address("" + SPINEPacketsConstants.SPINE_BROADCAST).getAsInt());
msg.setClusterId(SPINEPacketsConstants.POLL_BLUETOOTH_DEVICES);
msg.setProfileId(MY_GROUP_ID);
if (null != null) {
try {
byte[] payloadArray = spineCodec.encode(null);
short[] payloadShort = new short[payloadArray.length];
for (int i = 0; i < payloadShort.length; i++) payloadShort[i] = payloadArray[i];
msg.setPayload(payloadShort);
} catch (MethodNotSupportedException e) {
e.printStackTrace();
if (SPINEManager.getLogger().isLoggable(Logger.SEVERE))
SPINEManager.getLogger().log(Logger.SEVERE, e.getMessage());
}
}
connection.send(msg);
} catch (InstantiationException e) {
e.printStackTrace();
if (l.isLoggable(Logger.SEVERE))
l.log(Logger.SEVERE, "InstantiationException" + e.getMessage());
} catch (IllegalAccessException e) {
e.printStackTrace();
if (l.isLoggable(Logger.SEVERE))
l.log(Logger.SEVERE, "IllegalAccessException" + e.getMessage());
} catch (ClassNotFoundException e) {
e.printStackTrace();
if (l.isLoggable(Logger.SEVERE))
l.log(Logger.SEVERE, "ClassNotFoundException" + e.getMessage());
} catch (InterruptedIOException e) {
e.printStackTrace();
if (l.isLoggable(Logger.SEVERE))
l.log(Logger.SEVERE, "InterruptedIOException" + e.getMessage());
} catch (UnsupportedOperationException e) {
e.printStackTrace();
if (l.isLoggable(Logger.SEVERE))
l.log(Logger.SEVERE, "UnsupportedOperationException" + e.getMessage());
}
</DeepExtract>
} | BSPAN---Bluetooth-Sensor-Processing-for-Android | positive | 1,683 |
public static Map<String, URI> getContentMap(String packageName) {
Map<String, URI> out = new HashMap<>();
packageName = packageName.replace(".", "/");
ClassLoader cl = JPypeContext.getInstance().getClassLoader();
try {
String path = packageName.replace('.', '/');
Enumeration<URL> resources = cl.getResources(path);
while (resources.hasMoreElements()) {
URI resource = resources.nextElement().toURI();
String schemePart = resource.getSchemeSpecificPart();
int index = schemePart.indexOf("!");
if (index != -1) {
if (schemePart.substring(index + 1).startsWith("/META-INF/versions/")) {
int index2 = schemePart.indexOf('/', index + 20);
schemePart = schemePart.substring(0, index + 1) + schemePart.substring(index2);
URI resource2 = new URI(resource.getScheme() + ":" + schemePart);
Path path3 = getPath(resource2);
collectContents(out, path3);
}
}
Path path2 = getPath(resource);
collectContents(out, path2);
}
} catch (IOException | URISyntaxException ex) {
}
for (FileSystem b : bases) {
collectContents(out, b.getPath(packageName));
}
if (modules.isEmpty())
return;
String[] split = packageName.split("/");
String search = packageName;
if (split.length > 3)
search = String.join("/", Arrays.copyOfRange(split, 0, 3));
for (ModuleDirectory module : modules) {
if (module.contains(search)) {
Path path2 = module.modulePath.resolve(packageName);
if (Files.isDirectory(path2))
collectContents(out, path2);
}
}
return out;
} | public static Map<String, URI> getContentMap(String packageName) {
Map<String, URI> out = new HashMap<>();
packageName = packageName.replace(".", "/");
ClassLoader cl = JPypeContext.getInstance().getClassLoader();
try {
String path = packageName.replace('.', '/');
Enumeration<URL> resources = cl.getResources(path);
while (resources.hasMoreElements()) {
URI resource = resources.nextElement().toURI();
String schemePart = resource.getSchemeSpecificPart();
int index = schemePart.indexOf("!");
if (index != -1) {
if (schemePart.substring(index + 1).startsWith("/META-INF/versions/")) {
int index2 = schemePart.indexOf('/', index + 20);
schemePart = schemePart.substring(0, index + 1) + schemePart.substring(index2);
URI resource2 = new URI(resource.getScheme() + ":" + schemePart);
Path path3 = getPath(resource2);
collectContents(out, path3);
}
}
Path path2 = getPath(resource);
collectContents(out, path2);
}
} catch (IOException | URISyntaxException ex) {
}
for (FileSystem b : bases) {
collectContents(out, b.getPath(packageName));
}
<DeepExtract>
if (modules.isEmpty())
return;
String[] split = packageName.split("/");
String search = packageName;
if (split.length > 3)
search = String.join("/", Arrays.copyOfRange(split, 0, 3));
for (ModuleDirectory module : modules) {
if (module.contains(search)) {
Path path2 = module.modulePath.resolve(packageName);
if (Files.isDirectory(path2))
collectContents(out, path2);
}
}
</DeepExtract>
return out;
} | jpype | positive | 1,684 |
public synchronized int oap_receive_byte(byte b) {
PodEmuLog.debugVerbose("OAPM: Line " + line + ": len=" + line_cmd_len + " cnt=" + line_cmd_pos + " " + String.format(": %s: %02X", (READ == READ ? "RCV" : "WRITE"), b));
if (line_cmd_pos == 2) {
line_cmd_len = (b & 0xff) + 4;
PodEmuLog.debug(String.format("OAPM: Line " + line + ": MSG LEN: %d TOTAL LEN: %d", (b & 0xff), line_cmd_len));
if (b == (byte) 0x00) {
if (!(SerialInterfaceBuilder.getSerialInterface() instanceof SerialInterface_BLE))
is_extended_image = true;
line_ext_pos = 2;
}
}
if (is_extended_image) {
if (line_ext_pos <= 8)
PodEmuLog.debugVerbose(String.format("OAPM: EXT MSG check - pos:%d, byte: 0x%02X", line_ext_pos, b));
if (line_ext_pos == 3 || line_ext_pos == 4) {
ext_image_buf[line_ext_pos] = b;
} else if (line_ext_pos == 5 && b != (byte) 0x04)
is_extended_image = false;
else if (line_ext_pos == 6 && b != (byte) 0x00)
is_extended_image = false;
else if (line_ext_pos == 7 && b != (byte) 0x32)
is_extended_image = false;
else if (line_ext_pos == 8) {
(line_cmd_len) = (((ext_image_buf[3] & 0xff) << 8) | (ext_image_buf[4] & 0xff)) + 6;
(line_cmd_pos) = 8;
line_buf[0] = (byte) 0xff;
line_buf[1] = (byte) 0x55;
line_buf[2] = (byte) 0x00;
line_buf[3] = ext_image_buf[3];
line_buf[4] = ext_image_buf[4];
line_buf[5] = (byte) 0x04;
line_buf[6] = (byte) 0x00;
line_buf[7] = (byte) 0x32;
PodEmuLog.debug(String.format("OAPM: Line %d: Extended image message detected!!!", line));
}
line_ext_pos++;
}
if (line_cmd_pos == 0 && b != (byte) 0xff) {
PodEmuLog.debug("OAPM: Line " + line + ": ERROR: first byte is not 0xFF. Received 0x" + String.format("%02X", b));
return -1;
}
if (line_cmd_pos == 1 && b != (byte) 0x55) {
PodEmuLog.debug("OAPM: Line " + line + ": ERROR: second byte is not 0x55. Received 0x" + String.format("%02X", b));
return -1;
}
if (!is_extended_image && line_cmd_len > 259) {
PodEmuLog.debug("OAPM: Line " + line + ": ERROR: message duration cannot exceed 259 bytes");
return -1;
}
if (is_extended_image && line_cmd_len > 65025 + 6) {
PodEmuLog.debug("OAPM: Line " + line + ": ERROR: extended message duration cannot exceed 65031 bytes");
return -1;
}
line_buf[line_cmd_pos] = b;
line_cmd_pos++;
if (line_cmd_pos == line_cmd_len) {
int msg_len;
byte checksum;
PodEmuLog.debug("OAPM: Line " + line + ": RAW MSG IN: " + oap_hex_to_str(line_buf, line_cmd_len));
oap_print_podmsg(line_buf, true, (line_cmd_len > 7 && is_extended_image));
checksum = oap_calc_checksum(line_buf, line_cmd_len);
if (line_buf[line_cmd_len - 1] != checksum) {
PodEmuLog.error("OAPM: Line " + line + String.format(": ERROR: checksum error. Received: %02X Should be: %02X", line_buf[line_cmd_len - 1], checksum));
} else {
PodEmuLog.debugVerbose("OAPM: Line " + line + String.format(": Checksum OK. Received: %02X Should be: %02X", line_buf[line_cmd_len - 1], checksum));
PodEmuLog.debugVerbose("OAPM: Line " + line + ": Checksum OK");
oap_process_msg(line_buf, line_cmd_len, (line_cmd_len > 7 && is_extended_image));
}
msg_len = line_cmd_len;
line_cmd_pos = 0;
line_cmd_len = 0;
if (line_ext_pos > 7)
is_extended_image = false;
return msg_len;
}
return 0;
} | public synchronized int oap_receive_byte(byte b) {
<DeepExtract>
PodEmuLog.debugVerbose("OAPM: Line " + line + ": len=" + line_cmd_len + " cnt=" + line_cmd_pos + " " + String.format(": %s: %02X", (READ == READ ? "RCV" : "WRITE"), b));
</DeepExtract>
if (line_cmd_pos == 2) {
line_cmd_len = (b & 0xff) + 4;
PodEmuLog.debug(String.format("OAPM: Line " + line + ": MSG LEN: %d TOTAL LEN: %d", (b & 0xff), line_cmd_len));
if (b == (byte) 0x00) {
if (!(SerialInterfaceBuilder.getSerialInterface() instanceof SerialInterface_BLE))
is_extended_image = true;
line_ext_pos = 2;
}
}
if (is_extended_image) {
if (line_ext_pos <= 8)
PodEmuLog.debugVerbose(String.format("OAPM: EXT MSG check - pos:%d, byte: 0x%02X", line_ext_pos, b));
if (line_ext_pos == 3 || line_ext_pos == 4) {
ext_image_buf[line_ext_pos] = b;
} else if (line_ext_pos == 5 && b != (byte) 0x04)
is_extended_image = false;
else if (line_ext_pos == 6 && b != (byte) 0x00)
is_extended_image = false;
else if (line_ext_pos == 7 && b != (byte) 0x32)
is_extended_image = false;
else if (line_ext_pos == 8) {
(line_cmd_len) = (((ext_image_buf[3] & 0xff) << 8) | (ext_image_buf[4] & 0xff)) + 6;
(line_cmd_pos) = 8;
line_buf[0] = (byte) 0xff;
line_buf[1] = (byte) 0x55;
line_buf[2] = (byte) 0x00;
line_buf[3] = ext_image_buf[3];
line_buf[4] = ext_image_buf[4];
line_buf[5] = (byte) 0x04;
line_buf[6] = (byte) 0x00;
line_buf[7] = (byte) 0x32;
PodEmuLog.debug(String.format("OAPM: Line %d: Extended image message detected!!!", line));
}
line_ext_pos++;
}
if (line_cmd_pos == 0 && b != (byte) 0xff) {
PodEmuLog.debug("OAPM: Line " + line + ": ERROR: first byte is not 0xFF. Received 0x" + String.format("%02X", b));
return -1;
}
if (line_cmd_pos == 1 && b != (byte) 0x55) {
PodEmuLog.debug("OAPM: Line " + line + ": ERROR: second byte is not 0x55. Received 0x" + String.format("%02X", b));
return -1;
}
if (!is_extended_image && line_cmd_len > 259) {
PodEmuLog.debug("OAPM: Line " + line + ": ERROR: message duration cannot exceed 259 bytes");
return -1;
}
if (is_extended_image && line_cmd_len > 65025 + 6) {
PodEmuLog.debug("OAPM: Line " + line + ": ERROR: extended message duration cannot exceed 65031 bytes");
return -1;
}
line_buf[line_cmd_pos] = b;
line_cmd_pos++;
if (line_cmd_pos == line_cmd_len) {
int msg_len;
byte checksum;
PodEmuLog.debug("OAPM: Line " + line + ": RAW MSG IN: " + oap_hex_to_str(line_buf, line_cmd_len));
oap_print_podmsg(line_buf, true, (line_cmd_len > 7 && is_extended_image));
checksum = oap_calc_checksum(line_buf, line_cmd_len);
if (line_buf[line_cmd_len - 1] != checksum) {
PodEmuLog.error("OAPM: Line " + line + String.format(": ERROR: checksum error. Received: %02X Should be: %02X", line_buf[line_cmd_len - 1], checksum));
} else {
PodEmuLog.debugVerbose("OAPM: Line " + line + String.format(": Checksum OK. Received: %02X Should be: %02X", line_buf[line_cmd_len - 1], checksum));
PodEmuLog.debugVerbose("OAPM: Line " + line + ": Checksum OK");
oap_process_msg(line_buf, line_cmd_len, (line_cmd_len > 7 && is_extended_image));
}
msg_len = line_cmd_len;
line_cmd_pos = 0;
line_cmd_len = 0;
if (line_ext_pos > 7)
is_extended_image = false;
return msg_len;
}
return 0;
} | PodEmu | positive | 1,686 |
@Override
public ByteBuf skipBytes(final int n) {
if (this.buffer.readableBytes() < n) {
throw EOF;
}
this.buffer.skipBytes(n);
return this;
} | @Override
public ByteBuf skipBytes(final int n) {
<DeepExtract>
if (this.buffer.readableBytes() < n) {
throw EOF;
}
</DeepExtract>
this.buffer.skipBytes(n);
return this;
} | ProtocolSupportBungee | positive | 1,687 |
public void OnCancelSearchButtonClick(View v) {
if (mTopBarMode == TopBarMode.Search) {
mTopBarMode = TopBarMode.Main;
hideKeyboard();
mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
SearchTaskResult.set(null);
mDocView.resetupChildren();
}
} | public void OnCancelSearchButtonClick(View v) {
<DeepExtract>
if (mTopBarMode == TopBarMode.Search) {
mTopBarMode = TopBarMode.Main;
hideKeyboard();
mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
SearchTaskResult.set(null);
mDocView.resetupChildren();
}
</DeepExtract>
} | mupdf-android | positive | 1,688 |
public LongFraction abs() {
if (1 == 0 || isZero(this))
return LongFraction.ZERO;
int thisSignum = signum();
if ((thisSignum < 0 && 1 > 0) || (thisSignum > 0 && 1 < 0))
return new LongFraction(negateAndCheck(numerator), denominator, Reduced.YES);
return this;
} | public LongFraction abs() {
<DeepExtract>
if (1 == 0 || isZero(this))
return LongFraction.ZERO;
int thisSignum = signum();
if ((thisSignum < 0 && 1 > 0) || (thisSignum > 0 && 1 < 0))
return new LongFraction(negateAndCheck(numerator), denominator, Reduced.YES);
return this;
</DeepExtract>
} | BigFraction | positive | 1,690 |
public static void main(String[] args) {
Jogo jogo = new Jogo();
tanque = new Tanque();
tanque.setVel(3);
tanque.setAtivo(true);
tanque.setPx(tela.getWidth() / 2 - tanque.getLargura() / 2);
tanque.setPy(tela.getHeight() - tanque.getAltura() - linhaBase);
tiroTanque = new Tiro();
tiroTanque.setVel(-15);
chefe = new Invader(Invader.Tipos.CHEFE);
tiroChefe = new Tiro(true);
tiroChefe.setVel(20);
tiroChefe.setAltura(15);
for (int i = 0; i < tiros.length; i++) {
tiros[i] = new Tiro(true);
}
for (int i = 0; i < invasores.length; i++) {
for (int j = 0; j < invasores[i].length; j++) {
Invader e = new Invader(tipoPorLinha[j]);
e.setAtivo(true);
e.setPx(i * e.getLargura() + (i + 1) * espacamento);
e.setPy(j * e.getAltura() + j * espacamento + linhaBase);
invasores[i][j] = e;
}
}
dir = 1;
totalInimigos = invasores.length * invasores[0].length;
contadorEspera = totalInimigos / level;
long prxAtualizacao = 0;
while (true) {
if (System.currentTimeMillis() >= prxAtualizacao) {
g2d.setColor(Color.BLACK);
g2d.fillRect(0, 0, JANELA_LARGURA, JANELA_ALTURA);
if (destruidos == totalInimigos) {
destruidos = 0;
level++;
carregarJogo();
continue;
}
if (contador > contadorEspera) {
moverInimigos = true;
contador = 0;
contadorEspera = totalInimigos - destruidos - level * level;
} else {
contador++;
}
if (tanque.isAtivo()) {
if (controleTecla[2]) {
tanque.setPx(tanque.getPx() - tanque.getVel());
} else if (controleTecla[3]) {
tanque.setPx(tanque.getPx() + tanque.getVel());
}
}
if (controleTecla[4] && !tiroTanque.isAtivo()) {
tiroTanque.setPx(tanque.getPx() + tanque.getLargura() / 2 - tiroTanque.getLargura() / 2);
tiroTanque.setPy(tanque.getPy() - tiroTanque.getAltura());
tiroTanque.setAtivo(true);
}
if (chefe.isAtivo()) {
chefe.incPx(tanque.getVel() - 1);
if (!tiroChefe.isAtivo() && Util.colideX(chefe, tanque)) {
addTiroInimigo(chefe, tiroChefe);
}
if (chefe.getPx() > tela.getWidth()) {
chefe.setAtivo(false);
}
}
boolean colideBordas = false;
for (int j = invasores[0].length - 1; j >= 0; j--) {
for (int i = 0; i < invasores.length; i++) {
Invader inv = invasores[i][j];
if (!inv.isAtivo()) {
continue;
}
if (Util.colide(tiroTanque, inv)) {
inv.setAtivo(false);
tiroTanque.setAtivo(false);
destruidos++;
pontos = pontos + inv.getPremio() * level;
continue;
}
if (moverInimigos) {
inv.atualiza();
if (novaLinha) {
inv.setPy(inv.getPy() + inv.getAltura() + espacamento);
} else {
inv.incPx(espacamento * dir);
}
if (!novaLinha && !colideBordas) {
int pxEsq = inv.getPx() - espacamento;
int pxDir = inv.getPx() + inv.getLargura() + espacamento;
if (pxEsq <= 0 || pxDir >= tela.getWidth())
colideBordas = true;
}
if (!tiros[0].isAtivo() && inv.getPx() < tanque.getPx()) {
addTiroInimigo(inv, tiros[0]);
} else if (!tiros[1].isAtivo() && inv.getPx() > tanque.getPx() && inv.getPx() < tanque.getPx() + tanque.getLargura()) {
addTiroInimigo(inv, tiros[1]);
} else if (!tiros[2].isAtivo() && inv.getPx() > tanque.getPx()) {
addTiroInimigo(inv, tiros[2]);
}
if (!chefe.isAtivo() && rand.nextInt(500) == destruidos) {
chefe.setPx(0);
chefe.setAtivo(true);
}
}
}
}
if (moverInimigos && novaLinha) {
dir *= -1;
novaLinha = false;
} else if (moverInimigos && colideBordas) {
novaLinha = true;
}
moverInimigos = false;
if (tiroTanque.isAtivo()) {
tiroTanque.incPy(tiroTanque.getVel());
if (Util.colide(tiroTanque, chefe)) {
pontos = pontos + chefe.getPremio() * level;
chefe.setAtivo(false);
tiroTanque.setAtivo(false);
} else if (tiroTanque.getPy() < 0) {
tiroTanque.setAtivo(false);
}
tiroTanque.desenha(g2d);
}
if (tiroChefe.isAtivo()) {
tiroChefe.incPy(tiroChefe.getVel());
if (Util.colide(tiroChefe, tanque)) {
vidas--;
tiroChefe.setAtivo(false);
} else if (tiroChefe.getPy() > tela.getHeight() - linhaBase - tiroChefe.getAltura()) {
tiroChefe.setAtivo(false);
} else
tiroChefe.desenha(g2d);
}
for (int i = 0; i < tiros.length; i++) {
if (tiros[i].isAtivo()) {
tiros[i].incPy(+10);
if (Util.colide(tiros[i], tanque)) {
vidas--;
tiros[i].setAtivo(false);
} else if (tiros[i].getPy() > tela.getHeight() - linhaBase - tiros[i].getAltura())
tiros[i].setAtivo(false);
tiros[i].desenha(g2d);
}
}
for (int i = 0; i < invasores.length; i++) {
for (int j = 0; j < invasores[i].length; j++) {
Invader e = invasores[i][j];
e.desenha(g2d);
}
}
tanque.atualiza();
tanque.desenha(g2d);
chefe.atualiza();
chefe.desenha(g2d);
g2d.setColor(Color.WHITE);
texto.desenha(g2d, String.valueOf(pontos), 10, 20);
texto.desenha(g2d, "Level " + level, tela.getWidth() - 100, 20);
texto.desenha(g2d, String.valueOf(vidas), 10, tela.getHeight() - 10);
g2d.setColor(Color.GREEN);
g2d.drawLine(0, tela.getHeight() - linhaBase, tela.getWidth(), tela.getHeight() - linhaBase);
for (int i = 1; i < vidas; i++) {
vida.setPx(i * vida.getLargura() + i * espacamento);
vida.setPy(tela.getHeight() - vida.getAltura());
vida.desenha(g2d);
}
tela.repaint();
prxAtualizacao = System.currentTimeMillis() + FPS;
}
}
} | public static void main(String[] args) {
Jogo jogo = new Jogo();
tanque = new Tanque();
tanque.setVel(3);
tanque.setAtivo(true);
tanque.setPx(tela.getWidth() / 2 - tanque.getLargura() / 2);
tanque.setPy(tela.getHeight() - tanque.getAltura() - linhaBase);
tiroTanque = new Tiro();
tiroTanque.setVel(-15);
chefe = new Invader(Invader.Tipos.CHEFE);
tiroChefe = new Tiro(true);
tiroChefe.setVel(20);
tiroChefe.setAltura(15);
for (int i = 0; i < tiros.length; i++) {
tiros[i] = new Tiro(true);
}
for (int i = 0; i < invasores.length; i++) {
for (int j = 0; j < invasores[i].length; j++) {
Invader e = new Invader(tipoPorLinha[j]);
e.setAtivo(true);
e.setPx(i * e.getLargura() + (i + 1) * espacamento);
e.setPy(j * e.getAltura() + j * espacamento + linhaBase);
invasores[i][j] = e;
}
}
dir = 1;
totalInimigos = invasores.length * invasores[0].length;
contadorEspera = totalInimigos / level;
<DeepExtract>
long prxAtualizacao = 0;
while (true) {
if (System.currentTimeMillis() >= prxAtualizacao) {
g2d.setColor(Color.BLACK);
g2d.fillRect(0, 0, JANELA_LARGURA, JANELA_ALTURA);
if (destruidos == totalInimigos) {
destruidos = 0;
level++;
carregarJogo();
continue;
}
if (contador > contadorEspera) {
moverInimigos = true;
contador = 0;
contadorEspera = totalInimigos - destruidos - level * level;
} else {
contador++;
}
if (tanque.isAtivo()) {
if (controleTecla[2]) {
tanque.setPx(tanque.getPx() - tanque.getVel());
} else if (controleTecla[3]) {
tanque.setPx(tanque.getPx() + tanque.getVel());
}
}
if (controleTecla[4] && !tiroTanque.isAtivo()) {
tiroTanque.setPx(tanque.getPx() + tanque.getLargura() / 2 - tiroTanque.getLargura() / 2);
tiroTanque.setPy(tanque.getPy() - tiroTanque.getAltura());
tiroTanque.setAtivo(true);
}
if (chefe.isAtivo()) {
chefe.incPx(tanque.getVel() - 1);
if (!tiroChefe.isAtivo() && Util.colideX(chefe, tanque)) {
addTiroInimigo(chefe, tiroChefe);
}
if (chefe.getPx() > tela.getWidth()) {
chefe.setAtivo(false);
}
}
boolean colideBordas = false;
for (int j = invasores[0].length - 1; j >= 0; j--) {
for (int i = 0; i < invasores.length; i++) {
Invader inv = invasores[i][j];
if (!inv.isAtivo()) {
continue;
}
if (Util.colide(tiroTanque, inv)) {
inv.setAtivo(false);
tiroTanque.setAtivo(false);
destruidos++;
pontos = pontos + inv.getPremio() * level;
continue;
}
if (moverInimigos) {
inv.atualiza();
if (novaLinha) {
inv.setPy(inv.getPy() + inv.getAltura() + espacamento);
} else {
inv.incPx(espacamento * dir);
}
if (!novaLinha && !colideBordas) {
int pxEsq = inv.getPx() - espacamento;
int pxDir = inv.getPx() + inv.getLargura() + espacamento;
if (pxEsq <= 0 || pxDir >= tela.getWidth())
colideBordas = true;
}
if (!tiros[0].isAtivo() && inv.getPx() < tanque.getPx()) {
addTiroInimigo(inv, tiros[0]);
} else if (!tiros[1].isAtivo() && inv.getPx() > tanque.getPx() && inv.getPx() < tanque.getPx() + tanque.getLargura()) {
addTiroInimigo(inv, tiros[1]);
} else if (!tiros[2].isAtivo() && inv.getPx() > tanque.getPx()) {
addTiroInimigo(inv, tiros[2]);
}
if (!chefe.isAtivo() && rand.nextInt(500) == destruidos) {
chefe.setPx(0);
chefe.setAtivo(true);
}
}
}
}
if (moverInimigos && novaLinha) {
dir *= -1;
novaLinha = false;
} else if (moverInimigos && colideBordas) {
novaLinha = true;
}
moverInimigos = false;
if (tiroTanque.isAtivo()) {
tiroTanque.incPy(tiroTanque.getVel());
if (Util.colide(tiroTanque, chefe)) {
pontos = pontos + chefe.getPremio() * level;
chefe.setAtivo(false);
tiroTanque.setAtivo(false);
} else if (tiroTanque.getPy() < 0) {
tiroTanque.setAtivo(false);
}
tiroTanque.desenha(g2d);
}
if (tiroChefe.isAtivo()) {
tiroChefe.incPy(tiroChefe.getVel());
if (Util.colide(tiroChefe, tanque)) {
vidas--;
tiroChefe.setAtivo(false);
} else if (tiroChefe.getPy() > tela.getHeight() - linhaBase - tiroChefe.getAltura()) {
tiroChefe.setAtivo(false);
} else
tiroChefe.desenha(g2d);
}
for (int i = 0; i < tiros.length; i++) {
if (tiros[i].isAtivo()) {
tiros[i].incPy(+10);
if (Util.colide(tiros[i], tanque)) {
vidas--;
tiros[i].setAtivo(false);
} else if (tiros[i].getPy() > tela.getHeight() - linhaBase - tiros[i].getAltura())
tiros[i].setAtivo(false);
tiros[i].desenha(g2d);
}
}
for (int i = 0; i < invasores.length; i++) {
for (int j = 0; j < invasores[i].length; j++) {
Invader e = invasores[i][j];
e.desenha(g2d);
}
}
tanque.atualiza();
tanque.desenha(g2d);
chefe.atualiza();
chefe.desenha(g2d);
g2d.setColor(Color.WHITE);
texto.desenha(g2d, String.valueOf(pontos), 10, 20);
texto.desenha(g2d, "Level " + level, tela.getWidth() - 100, 20);
texto.desenha(g2d, String.valueOf(vidas), 10, tela.getHeight() - 10);
g2d.setColor(Color.GREEN);
g2d.drawLine(0, tela.getHeight() - linhaBase, tela.getWidth(), tela.getHeight() - linhaBase);
for (int i = 1; i < vidas; i++) {
vida.setPx(i * vida.getLargura() + i * espacamento);
vida.setPy(tela.getHeight() - vida.getAltura());
vida.desenha(g2d);
}
tela.repaint();
prxAtualizacao = System.currentTimeMillis() + FPS;
}
}
</DeepExtract>
} | fontes | positive | 1,691 |
public static String getPassword(Context context) {
if (prefs == null)
prefs = context.getSharedPreferences(PREFS_NAME, 0);
return prefs.getString(PASSWORD, "123");
} | public static String getPassword(Context context) {
<DeepExtract>
if (prefs == null)
prefs = context.getSharedPreferences(PREFS_NAME, 0);
</DeepExtract>
return prefs.getString(PASSWORD, "123");
} | Webkiosk | positive | 1,692 |
void construct() {
GlassPane aPane = GlassPane.mount(getAComponent(), true);
setGlassPane(aPane);
if (getGlassPane() != null) {
getGlassPane().setVisible(true);
}
try {
doNonUILogic();
} catch (RuntimeException e) {
}
} | void construct() {
<DeepExtract>
GlassPane aPane = GlassPane.mount(getAComponent(), true);
setGlassPane(aPane);
if (getGlassPane() != null) {
getGlassPane().setVisible(true);
}
</DeepExtract>
try {
doNonUILogic();
} catch (RuntimeException e) {
}
} | yoshikoder | positive | 1,694 |
@Override
public void onStopTrackingTouch(SeekBar arg0) {
applyEffect(selected_effect, false, true);
} | @Override
public void onStopTrackingTouch(SeekBar arg0) {
<DeepExtract>
applyEffect(selected_effect, false, true);
</DeepExtract>
} | Dali-Doodle | positive | 1,695 |
@SuppressWarnings("deprecation")
public void setEffect(PotionEffectType value) {
handle.getBytes().write(1, (byte) value.getId());
} | @SuppressWarnings("deprecation")
public void setEffect(PotionEffectType value) {
<DeepExtract>
handle.getBytes().write(1, (byte) value.getId());
</DeepExtract>
} | PacketWrapper | positive | 1,697 |
public static Properties getDefaultProperties() {
try {
if (propMap.get(DEFAULT_PROPERTIES_FILE) == null) {
Properties prop = new Properties();
prop.load(PropertiesUtil.class.getClassLoader().getResourceAsStream(DEFAULT_PROPERTIES_FILE));
propMap.put(DEFAULT_PROPERTIES_FILE, prop);
return prop;
} else {
return propMap.get(DEFAULT_PROPERTIES_FILE);
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
} | public static Properties getDefaultProperties() {
<DeepExtract>
try {
if (propMap.get(DEFAULT_PROPERTIES_FILE) == null) {
Properties prop = new Properties();
prop.load(PropertiesUtil.class.getClassLoader().getResourceAsStream(DEFAULT_PROPERTIES_FILE));
propMap.put(DEFAULT_PROPERTIES_FILE, prop);
return prop;
} else {
return propMap.get(DEFAULT_PROPERTIES_FILE);
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
</DeepExtract>
} | ocProject | positive | 1,698 |
void validate() {
List<String> validationErrors = new ArrayList<String>();
if (this.commandForStartFileManager == null || this.commandForStartFileManager.trim().equals("")) {
validationErrors.add("Command for custom definition " + "commandForStartFileManager" + " has not been set.");
}
if (this.commandForStartFileManagerAndSelectFile == null || this.commandForStartFileManagerAndSelectFile.trim().equals("")) {
validationErrors.add("Command for custom definition " + "commandForStartFileManagerAndSelectFile" + " has not been set.");
}
if (this.workingDirectoryModeForStartFileManager == null) {
validationErrors.add("Working directory for custom definition " + "workingDirectoryModeForStartFileManager" + " has not been set.");
}
if (this.commandForStartShell == null || this.commandForStartShell.trim().equals("")) {
validationErrors.add("Command for custom definition " + "commandForStartShell" + " has not been set.");
}
if (this.workingDirectoryModeForStartShell == null) {
validationErrors.add("Working directory for custom definition " + "workingDirectoryModeForStartShell" + " has not been set.");
}
if (this.commandForStartSystemApplication == null || this.commandForStartSystemApplication.trim().equals("")) {
validationErrors.add("Command for custom definition " + "commandForStartSystemApplication" + " has not been set.");
}
if (this.workingDirectoryModeForStartSystemApplication == null) {
validationErrors.add("Working directory for custom definition " + "workingDirectoryModeForStartSystemApplication" + " has not been set.");
}
if (this.workingDirectoryModeForCustomCommands == null) {
validationErrors.add("Working directory for custom definition " + "workingDirectoryModeForCustomCommands" + " has not been set.");
}
for (String validationError : validationErrors) {
getLogFacility().logWarning(validationError);
}
} | void validate() {
List<String> validationErrors = new ArrayList<String>();
if (this.commandForStartFileManager == null || this.commandForStartFileManager.trim().equals("")) {
validationErrors.add("Command for custom definition " + "commandForStartFileManager" + " has not been set.");
}
if (this.commandForStartFileManagerAndSelectFile == null || this.commandForStartFileManagerAndSelectFile.trim().equals("")) {
validationErrors.add("Command for custom definition " + "commandForStartFileManagerAndSelectFile" + " has not been set.");
}
if (this.workingDirectoryModeForStartFileManager == null) {
validationErrors.add("Working directory for custom definition " + "workingDirectoryModeForStartFileManager" + " has not been set.");
}
if (this.commandForStartShell == null || this.commandForStartShell.trim().equals("")) {
validationErrors.add("Command for custom definition " + "commandForStartShell" + " has not been set.");
}
if (this.workingDirectoryModeForStartShell == null) {
validationErrors.add("Working directory for custom definition " + "workingDirectoryModeForStartShell" + " has not been set.");
}
if (this.commandForStartSystemApplication == null || this.commandForStartSystemApplication.trim().equals("")) {
validationErrors.add("Command for custom definition " + "commandForStartSystemApplication" + " has not been set.");
}
if (this.workingDirectoryModeForStartSystemApplication == null) {
validationErrors.add("Working directory for custom definition " + "workingDirectoryModeForStartSystemApplication" + " has not been set.");
}
<DeepExtract>
if (this.workingDirectoryModeForCustomCommands == null) {
validationErrors.add("Working directory for custom definition " + "workingDirectoryModeForCustomCommands" + " has not been set.");
}
</DeepExtract>
for (String validationError : validationErrors) {
getLogFacility().logWarning(validationError);
}
} | startexplorer | positive | 1,699 |
@Test
public void setValue() {
entity = new BConfiguration();
assertEntityValidity(entity);
entity.setValue(value);
assertEquals(value, String.valueOf(ReflectionTestUtils.getField(entity, "value")));
} | @Test
public void setValue() {
<DeepExtract>
entity = new BConfiguration();
assertEntityValidity(entity);
</DeepExtract>
entity.setValue(value);
assertEquals(value, String.valueOf(ReflectionTestUtils.getField(entity, "value")));
} | gms | positive | 1,700 |
void placeGroupReset() {
placeGroup.clear();
placeGroupBoxEnd = placeGroupBoxStart = null;
} | void placeGroupReset() {
placeGroup.clear();
<DeepExtract>
placeGroupBoxEnd = placeGroupBoxStart = null;
</DeepExtract>
} | mudmap2 | positive | 1,701 |
@REGISTER
public void onRegister(BridgeEvent be, EventBus eb) {
String type = be.type().toString();
eb.send(type, type);
be.complete(true);
} | @REGISTER
public void onRegister(BridgeEvent be, EventBus eb) {
<DeepExtract>
String type = be.type().toString();
eb.send(type, type);
be.complete(true);
</DeepExtract>
} | nubes | positive | 1,702 |
@MonkeyRunnerExported(doc = "get script compatible screen", args = { "x", "y" }, argDocs = { "x coordinate in pixels", "y coordinate in pixels" }, returns = "no")
public boolean pressDPadLeft(PyObject[] args, String[] kws) {
ArgParser ap = JythonUtils.createArgParser(args, kws);
Preconditions.checkNotNull(ap);
Element element = new Element();
element.setElement(UIElement.TASK_PROGRESS_BAR);
element.setSN(sn);
element.setTaskName(taskName);
element.setScriptName(scriptName);
UIPool.offer(element);
if (sn == null || sn.equals(""))
return;
Logger.getLogger(AndroidDriver.class).info("[" + sn + "]" + "pressDPadLeft");
Log.getLoger(sn).logInfo.addRunLog("pressDPadLeft");
this.setInfo(DisplayUtil.Show.Info, "pressDPadLeft", sn);
return this.uiAutomatorClient.pressDPadLeft();
} | @MonkeyRunnerExported(doc = "get script compatible screen", args = { "x", "y" }, argDocs = { "x coordinate in pixels", "y coordinate in pixels" }, returns = "no")
public boolean pressDPadLeft(PyObject[] args, String[] kws) {
ArgParser ap = JythonUtils.createArgParser(args, kws);
Preconditions.checkNotNull(ap);
Element element = new Element();
element.setElement(UIElement.TASK_PROGRESS_BAR);
element.setSN(sn);
element.setTaskName(taskName);
element.setScriptName(scriptName);
UIPool.offer(element);
<DeepExtract>
if (sn == null || sn.equals(""))
return;
Logger.getLogger(AndroidDriver.class).info("[" + sn + "]" + "pressDPadLeft");
Log.getLoger(sn).logInfo.addRunLog("pressDPadLeft");
this.setInfo(DisplayUtil.Show.Info, "pressDPadLeft", sn);
</DeepExtract>
return this.uiAutomatorClient.pressDPadLeft();
} | AndroidRobot | positive | 1,703 |
@Deprecated
public static ShowcaseView insertShowcaseView(View viewToShowcase, Activity activity, String title, String detailText, ConfigOptions options) {
ShowcaseView sv = new ShowcaseView(activity);
if (options != null) {
sv.setConfigOptions(options);
}
if (sv.getConfigOptions().insert == INSERT_TO_DECOR) {
((ViewGroup) activity.getWindow().getDecorView()).addView(sv);
} else {
((ViewGroup) activity.findViewById(android.R.id.content)).addView(sv);
}
if (isRedundant || viewToShowcase == null) {
isRedundant = true;
return;
}
isRedundant = false;
viewToShowcase.post(new Runnable() {
@Override
public void run() {
Point viewPoint = Calculator.getShowcasePointFromView(viewToShowcase, getConfigOptions());
setShowcasePosition(viewPoint);
invalidate();
}
});
String titleText = getContext().getResources().getString(title);
String subText = getContext().getResources().getString(detailText);
setText(titleText, subText);
return sv;
} | @Deprecated
public static ShowcaseView insertShowcaseView(View viewToShowcase, Activity activity, String title, String detailText, ConfigOptions options) {
ShowcaseView sv = new ShowcaseView(activity);
if (options != null) {
sv.setConfigOptions(options);
}
if (sv.getConfigOptions().insert == INSERT_TO_DECOR) {
((ViewGroup) activity.getWindow().getDecorView()).addView(sv);
} else {
((ViewGroup) activity.findViewById(android.R.id.content)).addView(sv);
}
if (isRedundant || viewToShowcase == null) {
isRedundant = true;
return;
}
isRedundant = false;
viewToShowcase.post(new Runnable() {
@Override
public void run() {
Point viewPoint = Calculator.getShowcasePointFromView(viewToShowcase, getConfigOptions());
setShowcasePosition(viewPoint);
invalidate();
}
});
<DeepExtract>
String titleText = getContext().getResources().getString(title);
String subText = getContext().getResources().getString(detailText);
setText(titleText, subText);
</DeepExtract>
return sv;
} | tinfoil-sms | positive | 1,704 |
public JSONWriter value(long l) throws JSONException {
if (Long.toString(l) == null) {
throw new JSONException("Null pointer");
}
if (this.mode == 'o' || this.mode == 'a') {
try {
if (this.comma && this.mode == 'a') {
this.writer.write(',');
}
this.writer.write(Long.toString(l));
} catch (IOException e) {
throw new JSONException(e);
}
if (this.mode == 'o') {
this.mode = 'k';
}
this.comma = true;
return this;
}
throw new JSONException("Value out of sequence.");
} | public JSONWriter value(long l) throws JSONException {
<DeepExtract>
if (Long.toString(l) == null) {
throw new JSONException("Null pointer");
}
if (this.mode == 'o' || this.mode == 'a') {
try {
if (this.comma && this.mode == 'a') {
this.writer.write(',');
}
this.writer.write(Long.toString(l));
} catch (IOException e) {
throw new JSONException(e);
}
if (this.mode == 'o') {
this.mode = 'k';
}
this.comma = true;
return this;
}
throw new JSONException("Value out of sequence.");
</DeepExtract>
} | jcseg | positive | 1,705 |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_conferir, container, false);
fiscalizacaoAdapter = new FiscalizacaoAdapter(getActivity(), imageFetcher, voceFiscalDatabase);
ListView listView = (ListView) rootView.findViewById(R.id.listview);
listView.setAdapter(fiscalizacaoAdapter);
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView absListView, int scrollState) {
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
imageFetcher.setPauseWork(true);
} else {
imageFetcher.setPauseWork(false);
}
}
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
this.listaDeFiscalizacoes = listaDeFiscalizacoes;
fiscalizacaoAdapter.setResultItemList(listaDeFiscalizacoes);
fiscalizacaoAdapter.notifyDataSetChanged();
return rootView;
} | @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_conferir, container, false);
fiscalizacaoAdapter = new FiscalizacaoAdapter(getActivity(), imageFetcher, voceFiscalDatabase);
ListView listView = (ListView) rootView.findViewById(R.id.listview);
listView.setAdapter(fiscalizacaoAdapter);
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView absListView, int scrollState) {
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
imageFetcher.setPauseWork(true);
} else {
imageFetcher.setPauseWork(false);
}
}
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
<DeepExtract>
this.listaDeFiscalizacoes = listaDeFiscalizacoes;
fiscalizacaoAdapter.setResultItemList(listaDeFiscalizacoes);
fiscalizacaoAdapter.notifyDataSetChanged();
</DeepExtract>
return rootView;
} | vocefiscal-android | positive | 1,706 |
@Override
public void actionPerformed(ActionEvent e) {
if (!DialogMethods.connect(services)) {
return;
}
Label label;
String message = "Enter the name for this network";
CyNetwork currentNetwork = services.getCyApplicationManager().getCurrentNetwork();
String initialValue = currentNetwork.getRow(currentNetwork).get(CyNetwork.NAME, String.class);
while (true) {
String label = JOptionPane.showInputDialog(services.getCySwingApplication().getJFrame(), message, initialValue);
if (label != null) {
try {
label = NodeLabel.create(label);
} catch (Exception e) {
message = "Error in network name ([A-Za-z0-9])";
}
} else {
label = null;
}
}
ExportNetworkConfiguration exportNetworkConfiguration = ExportNetworkConfiguration.create(label, "shared name", "refid", CYCOLUMN_NEO4J_LABELS, "_neo4j_properties");
if (label != null) {
ExportNetworkToNeo4jTask task = services.getTaskFactory().createExportNetworkToNeo4jTask(exportNetworkConfiguration);
services.getTaskExecutor().execute(task);
}
} | @Override
public void actionPerformed(ActionEvent e) {
if (!DialogMethods.connect(services)) {
return;
}
<DeepExtract>
Label label;
String message = "Enter the name for this network";
CyNetwork currentNetwork = services.getCyApplicationManager().getCurrentNetwork();
String initialValue = currentNetwork.getRow(currentNetwork).get(CyNetwork.NAME, String.class);
while (true) {
String label = JOptionPane.showInputDialog(services.getCySwingApplication().getJFrame(), message, initialValue);
if (label != null) {
try {
label = NodeLabel.create(label);
} catch (Exception e) {
message = "Error in network name ([A-Za-z0-9])";
}
} else {
label = null;
}
}
</DeepExtract>
ExportNetworkConfiguration exportNetworkConfiguration = ExportNetworkConfiguration.create(label, "shared name", "refid", CYCOLUMN_NEO4J_LABELS, "_neo4j_properties");
if (label != null) {
ExportNetworkToNeo4jTask task = services.getTaskFactory().createExportNetworkToNeo4jTask(exportNetworkConfiguration);
services.getTaskExecutor().execute(task);
}
} | cytoscapeneo4j | positive | 1,707 |
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
final Calendar calendar = Calendar.getInstance();
calendar.set(year, monthOfYear, dayOfMonth);
availability.setStart(calendar.getTimeInMillis());
} | @Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
final Calendar calendar = Calendar.getInstance();
calendar.set(year, monthOfYear, dayOfMonth);
<DeepExtract>
availability.setStart(calendar.getTimeInMillis());
</DeepExtract>
} | artcodes-android | positive | 1,708 |
public void addAll(@NonNull T[] items, boolean mayModifyInput) {
if (mOldData != null) {
throw new IllegalStateException("Data cannot be mutated in the middle of a batch update operation such as addAll or replaceAll.");
}
if (items.length == 0) {
return;
}
if (mayModifyInput) {
addAllInternal(items);
} else {
addAllInternal(copyArray(items));
}
} | public void addAll(@NonNull T[] items, boolean mayModifyInput) {
<DeepExtract>
if (mOldData != null) {
throw new IllegalStateException("Data cannot be mutated in the middle of a batch update operation such as addAll or replaceAll.");
}
</DeepExtract>
if (items.length == 0) {
return;
}
if (mayModifyInput) {
addAllInternal(items);
} else {
addAllInternal(copyArray(items));
}
} | SamsungOneUi | positive | 1,709 |
@Override
public String getSelectedValue() throws WidgetException {
List<WebElement> elements = findElements();
for (WebElement we : elements) {
if (we.getAttribute("checked") != null && we.getAttribute("checked").equalsIgnoreCase("true")) {
return we.getAttribute("value");
}
}
throw new WidgetException("Error while finding selected option on radio group", getLocator());
} | @Override
public String getSelectedValue() throws WidgetException {
<DeepExtract>
List<WebElement> elements = findElements();
for (WebElement we : elements) {
if (we.getAttribute("checked") != null && we.getAttribute("checked").equalsIgnoreCase("true")) {
return we.getAttribute("value");
}
}
throw new WidgetException("Error while finding selected option on radio group", getLocator());
</DeepExtract>
} | JTAF-ExtWebDriver | positive | 1,710 |
public void stop() {
if (mediaPlayer == null) {
return;
}
if (mediaPlayer.isPlaying()) {
mediaPlayer.stop();
}
mediaPlayer.release();
mediaPlayer = null;
wasPlaying = false;
if (updater != null) {
updater.stopped = true;
}
stopForeground(true);
Intent playPauselistIntent = new Intent(EVENT_PLAY_PAUSE);
this.sendBroadcast(playPauselistIntent);
} | public void stop() {
if (mediaPlayer == null) {
return;
}
if (mediaPlayer.isPlaying()) {
mediaPlayer.stop();
}
mediaPlayer.release();
mediaPlayer = null;
wasPlaying = false;
if (updater != null) {
updater.stopped = true;
}
stopForeground(true);
<DeepExtract>
Intent playPauselistIntent = new Intent(EVENT_PLAY_PAUSE);
this.sendBroadcast(playPauselistIntent);
</DeepExtract>
} | SGU | positive | 1,713 |
private static byte[] egcd32(byte[] x, byte[] y, byte[] a, byte[] b) {
int an, bn = 32, qn, i;
for (i = 0; i < 32; i++) x[i] = y[i] = 0;
x[0] = 1;
while (32-- != 0 && a[32] == 0) ;
return 32 + 1;
if (an == 0)
return y;
byte[] temp = new byte[32];
while (true) {
qn = bn - an + 1;
divmod(temp, b, bn, a, an);
bn = numsize(b, bn);
if (bn == 0)
return x;
mula32(y, x, temp, qn, -1);
qn = an - bn + 1;
divmod(temp, a, an, b, bn);
an = numsize(a, an);
if (an == 0)
return y;
mula32(x, y, temp, qn, -1);
}
} | private static byte[] egcd32(byte[] x, byte[] y, byte[] a, byte[] b) {
int an, bn = 32, qn, i;
for (i = 0; i < 32; i++) x[i] = y[i] = 0;
x[0] = 1;
<DeepExtract>
while (32-- != 0 && a[32] == 0) ;
return 32 + 1;
</DeepExtract>
if (an == 0)
return y;
byte[] temp = new byte[32];
while (true) {
qn = bn - an + 1;
divmod(temp, b, bn, a, an);
bn = numsize(b, bn);
if (bn == 0)
return x;
mula32(y, x, temp, qn, -1);
qn = an - bn + 1;
divmod(temp, a, an, b, bn);
an = numsize(a, an);
if (an == 0)
return y;
mula32(x, y, temp, qn, -1);
}
} | signumj | positive | 1,714 |
@Test
@DisplayName("test CDC handling")
void testCDCHandling() {
MongoProcessedSinkRecordData processedData = new MongoProcessedSinkRecordData(SINK_RECORD, createSinkConfig(CHANGE_DATA_CAPTURE_HANDLER_CONFIG, MongoDbHandler.class.getCanonicalName()));
assertEquals(new MongoNamespace("myDB.topic"), processedData.getNamespace());
assertNull(processedData.getException());
ReplaceOneModel<BsonDocument> writeModel = (ReplaceOneModel<BsonDocument>) processedData.getWriteModel();
assertEquals(CDC_EXPECTED_WRITE_MODEL.getFilter(), writeModel.getFilter());
assertEquals(CDC_EXPECTED_WRITE_MODEL.getReplacement(), writeModel.getReplacement());
assertEquals(CDC_EXPECTED_WRITE_MODEL.getReplaceOptions().isUpsert(), writeModel.getReplaceOptions().isUpsert());
} | @Test
@DisplayName("test CDC handling")
void testCDCHandling() {
MongoProcessedSinkRecordData processedData = new MongoProcessedSinkRecordData(SINK_RECORD, createSinkConfig(CHANGE_DATA_CAPTURE_HANDLER_CONFIG, MongoDbHandler.class.getCanonicalName()));
assertEquals(new MongoNamespace("myDB.topic"), processedData.getNamespace());
<DeepExtract>
assertNull(processedData.getException());
ReplaceOneModel<BsonDocument> writeModel = (ReplaceOneModel<BsonDocument>) processedData.getWriteModel();
assertEquals(CDC_EXPECTED_WRITE_MODEL.getFilter(), writeModel.getFilter());
assertEquals(CDC_EXPECTED_WRITE_MODEL.getReplacement(), writeModel.getReplacement());
assertEquals(CDC_EXPECTED_WRITE_MODEL.getReplaceOptions().isUpsert(), writeModel.getReplaceOptions().isUpsert());
</DeepExtract>
} | mongo-kafka | positive | 1,715 |
@RequestMapping(params = "resume", method = RequestMethod.GET)
public String resumeGame(Model model) {
timerService.resume();
AdminSettings settings = new AdminSettings();
model.addAttribute("adminSettings", settings);
checkGameStatus(model);
buildGameLevelsOptions(model, settings);
buildProtocolsOptions(model, settings);
prepareList(model, settings);
return "admin";
} | @RequestMapping(params = "resume", method = RequestMethod.GET)
public String resumeGame(Model model) {
timerService.resume();
<DeepExtract>
AdminSettings settings = new AdminSettings();
model.addAttribute("adminSettings", settings);
checkGameStatus(model);
buildGameLevelsOptions(model, settings);
buildProtocolsOptions(model, settings);
prepareList(model, settings);
return "admin";
</DeepExtract>
} | tetris | positive | 1,716 |
public Criteria andUserIdIsNull() {
if ("user_id is null" == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion("user_id is null"));
return (Criteria) this;
} | public Criteria andUserIdIsNull() {
<DeepExtract>
if ("user_id is null" == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion("user_id is null"));
</DeepExtract>
return (Criteria) this;
} | emotional_analysis | positive | 1,717 |
@Override
public void updateEntry(Entry entry) {
IPersistableObject<Entry> persistence = new PersistableEntries(entry.getCategoryId(), entry.getFeedId(), entry.getId(), null);
List<E> result = new ArrayList<>();
result.add(entry);
persistence.store(result);
} | @Override
public void updateEntry(Entry entry) {
IPersistableObject<Entry> persistence = new PersistableEntries(entry.getCategoryId(), entry.getFeedId(), entry.getId(), null);
<DeepExtract>
List<E> result = new ArrayList<>();
result.add(entry);
persistence.store(result);
</DeepExtract>
} | SimpleNews | positive | 1,718 |
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("ch06/job/job-flatfile-multiline.xml");
JobLauncher launcher = (JobLauncher) context.getBean("jobLauncher");
Job job = (Job) context.getBean("multiLineBillJob");
try {
JobExecution result = launcher.run(job, new JobParametersBuilder().addDate("date", new Date()).toJobParameters());
System.out.println(result.toString());
} catch (Exception e) {
e.printStackTrace();
}
} | public static void main(String[] args) {
<DeepExtract>
ApplicationContext context = new ClassPathXmlApplicationContext("ch06/job/job-flatfile-multiline.xml");
JobLauncher launcher = (JobLauncher) context.getBean("jobLauncher");
Job job = (Job) context.getBean("multiLineBillJob");
try {
JobExecution result = launcher.run(job, new JobParametersBuilder().addDate("date", new Date()).toJobParameters());
System.out.println(result.toString());
} catch (Exception e) {
e.printStackTrace();
}
</DeepExtract>
} | SpringBatchSample | positive | 1,719 |
public void rollback() throws SQLException {
if (this.closed) {
throw new SQLException("Connection is closed");
}
if (this.autoCommit) {
throw new SQLException("Auto-commit is enabled");
}
handler.getResourceHandler().whenRollbackTransaction(this);
} | public void rollback() throws SQLException {
<DeepExtract>
if (this.closed) {
throw new SQLException("Connection is closed");
}
</DeepExtract>
if (this.autoCommit) {
throw new SQLException("Auto-commit is enabled");
}
handler.getResourceHandler().whenRollbackTransaction(this);
} | acolyte | positive | 1,720 |
@Nonnull
public static Class<?> getInnerNMSClass(@NonNull String name, @NonNull String subname) throws ClassNotFoundException {
return Class.forName("net.minecraft.server." + (MAJOR_VERSION <= 16 ? getVersion() + '.' : "") + name + '$' + subname);
} | @Nonnull
public static Class<?> getInnerNMSClass(@NonNull String name, @NonNull String subname) throws ClassNotFoundException {
<DeepExtract>
return Class.forName("net.minecraft.server." + (MAJOR_VERSION <= 16 ? getVersion() + '.' : "") + name + '$' + subname);
</DeepExtract>
} | CS-CoreLib2 | positive | 1,721 |
private void prepareSummaries() {
Date now = new Date();
FileNameModel[] originalArr = mApplication.getOriginalFileNamePattern();
String newFileName = mApplication.getFileNameFormatted(originalArr[0].getAfter(), now);
String label = mApplication.getApplicationContext().getString(R.string.define_file_name_pattern_desc, originalArr[0].getDemoBefore());
mDefineFileNamePatterns.setSummary(label);
label = "" + newFileName;
label += mApplication.getFormattedFileNameSuffix(0);
label += "." + originalArr[0].getDemoExtension();
label += ", " + newFileName;
label += mApplication.getFormattedFileNameSuffix(1);
label += "." + originalArr[0].getDemoExtension();
label = mApplication.getApplicationContext().getString(R.string.file_name_suffix_format_desc, label);
mFileNameSuffixFormat.setSummary(label);
switch(mApplication.getServiceType()) {
case DSCApplication.SERVICE_TYPE_CAMERA:
mServiceTypeList.setSummary(R.string.service_choice_1);
break;
case DSCApplication.SERVICE_TYPE_CONTENT:
mServiceTypeList.setSummary(R.string.service_choice_2);
break;
case DSCApplication.SERVICE_TYPE_FILE_OBSERVER:
mServiceTypeList.setSummary(R.string.service_choice_3);
break;
case DSCApplication.SERVICE_TYPE_CAMERA_SERVICE:
mServiceTypeList.setSummary(R.string.service_choice_4);
break;
default:
mServiceTypeList.setSummary(R.string.service_choice_0);
break;
}
label = mApplication.getApplicationContext().getString(R.string.change_language_title_param, getSelectedLanguage());
mAppLanguage.setTitle(label);
label = mApplication.getApplicationContext().getString(R.string.app_theme_title_param, getSelectedThemeLabel());
mAppTheme.setTitle(label);
if (mApplication.getDelayUnit() == 60) {
label = mApplication.getApplicationContext().getString(R.string.minutes_unit);
}
return mApplication.getApplicationContext().getString(R.string.seconds_unit);
mRenameServiceStartDelay.setUnits(label);
mDelayUnit.setTitle(mApplication.getApplicationContext().getString(R.string.choose_units_title_param, label));
if (mApplication.getSdkInt() >= 21) {
mEnabledFolderScanning.setSummary(R.string.enable_filter_folder_desc_v21);
}
updateShortcutFields();
String summary, temp;
SelectedFolderModel[] folders = mApplication.getSelectedFolders();
if (folders.length > 0) {
summary = folders[0].getFullPath();
if (folders.length > 1) {
summary += ", ";
temp = folders[1].getFullPath();
summary += temp.substring(0, 10 < temp.length() ? 10 : temp.length());
summary += "...";
}
mFolderScanningPref.setSummary(summary);
}
mEnableScanForFiles.setChecked(mApplication.isEnabledFolderScanningForFiles());
String[] arr = mApplication.getResources().getStringArray(R.array.rename_file_using_labels);
mRenameFileDateType.setSummary(arr[mApplication.getRenameFileDateType()]);
label = getString(R.string.append_original_name_desc, newFileName);
mAppendOriginalName.setSummary(label);
mFileRenameCount.setTitle(mApplication.getString(R.string.file_rename_count_title, mApplication.getFileRenameCount()));
mBuildVersion.setSummary(mApplication.getVersionName());
} | private void prepareSummaries() {
Date now = new Date();
FileNameModel[] originalArr = mApplication.getOriginalFileNamePattern();
String newFileName = mApplication.getFileNameFormatted(originalArr[0].getAfter(), now);
String label = mApplication.getApplicationContext().getString(R.string.define_file_name_pattern_desc, originalArr[0].getDemoBefore());
mDefineFileNamePatterns.setSummary(label);
label = "" + newFileName;
label += mApplication.getFormattedFileNameSuffix(0);
label += "." + originalArr[0].getDemoExtension();
label += ", " + newFileName;
label += mApplication.getFormattedFileNameSuffix(1);
label += "." + originalArr[0].getDemoExtension();
label = mApplication.getApplicationContext().getString(R.string.file_name_suffix_format_desc, label);
mFileNameSuffixFormat.setSummary(label);
switch(mApplication.getServiceType()) {
case DSCApplication.SERVICE_TYPE_CAMERA:
mServiceTypeList.setSummary(R.string.service_choice_1);
break;
case DSCApplication.SERVICE_TYPE_CONTENT:
mServiceTypeList.setSummary(R.string.service_choice_2);
break;
case DSCApplication.SERVICE_TYPE_FILE_OBSERVER:
mServiceTypeList.setSummary(R.string.service_choice_3);
break;
case DSCApplication.SERVICE_TYPE_CAMERA_SERVICE:
mServiceTypeList.setSummary(R.string.service_choice_4);
break;
default:
mServiceTypeList.setSummary(R.string.service_choice_0);
break;
}
label = mApplication.getApplicationContext().getString(R.string.change_language_title_param, getSelectedLanguage());
mAppLanguage.setTitle(label);
label = mApplication.getApplicationContext().getString(R.string.app_theme_title_param, getSelectedThemeLabel());
mAppTheme.setTitle(label);
if (mApplication.getDelayUnit() == 60) {
label = mApplication.getApplicationContext().getString(R.string.minutes_unit);
}
return mApplication.getApplicationContext().getString(R.string.seconds_unit);
mRenameServiceStartDelay.setUnits(label);
mDelayUnit.setTitle(mApplication.getApplicationContext().getString(R.string.choose_units_title_param, label));
if (mApplication.getSdkInt() >= 21) {
mEnabledFolderScanning.setSummary(R.string.enable_filter_folder_desc_v21);
}
updateShortcutFields();
String summary, temp;
SelectedFolderModel[] folders = mApplication.getSelectedFolders();
if (folders.length > 0) {
summary = folders[0].getFullPath();
if (folders.length > 1) {
summary += ", ";
temp = folders[1].getFullPath();
summary += temp.substring(0, 10 < temp.length() ? 10 : temp.length());
summary += "...";
}
mFolderScanningPref.setSummary(summary);
}
<DeepExtract>
mEnableScanForFiles.setChecked(mApplication.isEnabledFolderScanningForFiles());
</DeepExtract>
String[] arr = mApplication.getResources().getStringArray(R.array.rename_file_using_labels);
mRenameFileDateType.setSummary(arr[mApplication.getRenameFileDateType()]);
label = getString(R.string.append_original_name_desc, newFileName);
mAppendOriginalName.setSummary(label);
mFileRenameCount.setTitle(mApplication.getString(R.string.file_rename_count_title, mApplication.getFileRenameCount()));
mBuildVersion.setSummary(mApplication.getVersionName());
} | dscautorename | positive | 1,722 |
public static void setTranslucentForImageViewInFragment(Activity activity, int statusBarAlpha, View needOffsetView) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
setTransparentForWindow(activity);
addTranslucentView(activity, statusBarAlpha);
if (needOffsetView != null) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams();
layoutParams.setMargins(0, getStatusBarHeight(activity), 0, 0);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
clearPreviousSetting(activity);
}
} | public static void setTranslucentForImageViewInFragment(Activity activity, int statusBarAlpha, View needOffsetView) {
<DeepExtract>
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
setTransparentForWindow(activity);
addTranslucentView(activity, statusBarAlpha);
if (needOffsetView != null) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams();
layoutParams.setMargins(0, getStatusBarHeight(activity), 0, 0);
}
</DeepExtract>
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
clearPreviousSetting(activity);
}
} | EasyAndroid | positive | 1,724 |
public void screenshot(String type, int sourceX, int sourceY) {
Point point = new Point(sourceX, sourceY);
ICanvasHandler handler = new PointCanvasHandler(point);
if (TextUtils.isEmpty(type))
type = TYPE_LOG_INFO;
switch(type) {
case TYPE_LOG_INFO:
LogUtils.getInstance().infoScreenshot(handler);
break;
case TYPE_LOG_SUCCESS:
LogUtils.getInstance().successScreenshot(handler);
break;
case TYPE_LOG_ERROR:
LogUtils.getInstance().errorScreenshot(handler);
break;
}
} | public void screenshot(String type, int sourceX, int sourceY) {
Point point = new Point(sourceX, sourceY);
ICanvasHandler handler = new PointCanvasHandler(point);
<DeepExtract>
if (TextUtils.isEmpty(type))
type = TYPE_LOG_INFO;
switch(type) {
case TYPE_LOG_INFO:
LogUtils.getInstance().infoScreenshot(handler);
break;
case TYPE_LOG_SUCCESS:
LogUtils.getInstance().successScreenshot(handler);
break;
case TYPE_LOG_ERROR:
LogUtils.getInstance().errorScreenshot(handler);
break;
}
</DeepExtract>
} | za-Farmer | positive | 1,725 |
public void approveSubscription(String to) throws SmackInvocationException {
if (to != null) {
new Presence(Presence.Type.subscribed).setTo(to);
}
try {
con.sendPacket(new Presence(Presence.Type.subscribed));
} catch (NotConnectedException e) {
throw new SmackInvocationException(e);
}
} | public void approveSubscription(String to) throws SmackInvocationException {
<DeepExtract>
if (to != null) {
new Presence(Presence.Type.subscribed).setTo(to);
}
try {
con.sendPacket(new Presence(Presence.Type.subscribed));
} catch (NotConnectedException e) {
throw new SmackInvocationException(e);
}
</DeepExtract>
} | LetsChat | positive | 1,726 |
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
localSongsList = MediaUtils.getLocalSongs(Ting.getInstance());
if (localSongsList.size() == 0) {
view = inflater.inflate(R.layout.fragment_not_songs, container, false);
return view;
}
view = inflater.inflate(R.layout.fragment_local_songs, container, false);
localListView = (ListView) view.findViewById(R.id.local_songs_list);
slidingUpPanelLayout = (SlidingUpPanelLayout) view.findViewById(R.id.local_sliding_panel);
songImage = (ImageView) view.findViewById(R.id.song_image);
songLargeImage = (ImageView) view.findViewById(R.id.song_image_large);
songTitle = (TextView) view.findViewById(R.id.song_title);
songArtist = (TextView) view.findViewById(R.id.song_artist);
playImage = (ImageView) view.findViewById(R.id.play);
repeatImage = (ImageView) view.findViewById(R.id.repeat);
playBtnImage = (ImageView) view.findViewById(R.id.play_btn);
fwdImage = (ImageView) view.findViewById(R.id.fwd);
rewImage = (ImageView) view.findViewById(R.id.rew);
shuffleImage = (ImageView) view.findViewById(R.id.shuffle);
tvTimeElapsed = (TextView) view.findViewById(R.id.current_position);
tvDuration = (TextView) view.findViewById(R.id.current_max);
songSeekBar = (SeekBar) view.findViewById(R.id.seekBar);
songSeekBar.setOnSeekBarChangeListener(new SongSeekBarListener());
ViewOnclickListener viewOnclickListener = new ViewOnclickListener();
playImage.setOnClickListener(viewOnclickListener);
playBtnImage.setOnClickListener(viewOnclickListener);
fwdImage.setOnClickListener(viewOnclickListener);
repeatImage.setOnClickListener(viewOnclickListener);
shuffleImage.setOnClickListener(viewOnclickListener);
rewImage.setOnClickListener(viewOnclickListener);
localSongsList = MediaUtils.getLocalSongs(view.getContext());
Intent intent = new Intent(view.getContext(), MusicService.class);
getActivity().bindService(intent, serviceConnection, Service.BIND_AUTO_CREATE);
localListView.setAdapter(new LocalSongsAdapter(view.getContext(), R.layout.item_songs_list, localSongsList));
localListView.setOnScrollListener(new ListViewOnScrollListener());
localListView.setOnItemClickListener(new ListViewOnItemClickListener());
Bitmap bitmap = MediaUtils.getArtwork(view.getContext(), localSongsList.get(0).getId(), localSongsList.get(0).getAlbumId(), true, true);
songImage.setImageBitmap(bitmap);
songTitle.setText(localSongsList.get(0).getTitle());
songArtist.setText(localSongsList.get(0).getArtist());
songLargeImage.setImageBitmap(bitmap);
slidingUpPanelLayout.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View view, float v) {
}
@Override
public void onPanelCollapsed(View view) {
playImage.setVisibility(View.VISIBLE);
}
@Override
public void onPanelExpanded(View view) {
playImage.setVisibility(View.INVISIBLE);
}
@Override
public void onPanelAnchored(View view) {
}
@Override
public void onPanelHidden(View view) {
}
});
TelephonyManager telManager = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
telManager.listen(new MobliePhoneStateListener(), PhoneStateListener.LISTEN_CALL_STATE);
return view;
} | @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
localSongsList = MediaUtils.getLocalSongs(Ting.getInstance());
if (localSongsList.size() == 0) {
view = inflater.inflate(R.layout.fragment_not_songs, container, false);
return view;
}
view = inflater.inflate(R.layout.fragment_local_songs, container, false);
localListView = (ListView) view.findViewById(R.id.local_songs_list);
slidingUpPanelLayout = (SlidingUpPanelLayout) view.findViewById(R.id.local_sliding_panel);
songImage = (ImageView) view.findViewById(R.id.song_image);
songLargeImage = (ImageView) view.findViewById(R.id.song_image_large);
songTitle = (TextView) view.findViewById(R.id.song_title);
songArtist = (TextView) view.findViewById(R.id.song_artist);
playImage = (ImageView) view.findViewById(R.id.play);
repeatImage = (ImageView) view.findViewById(R.id.repeat);
playBtnImage = (ImageView) view.findViewById(R.id.play_btn);
fwdImage = (ImageView) view.findViewById(R.id.fwd);
rewImage = (ImageView) view.findViewById(R.id.rew);
shuffleImage = (ImageView) view.findViewById(R.id.shuffle);
tvTimeElapsed = (TextView) view.findViewById(R.id.current_position);
tvDuration = (TextView) view.findViewById(R.id.current_max);
songSeekBar = (SeekBar) view.findViewById(R.id.seekBar);
songSeekBar.setOnSeekBarChangeListener(new SongSeekBarListener());
ViewOnclickListener viewOnclickListener = new ViewOnclickListener();
playImage.setOnClickListener(viewOnclickListener);
playBtnImage.setOnClickListener(viewOnclickListener);
fwdImage.setOnClickListener(viewOnclickListener);
repeatImage.setOnClickListener(viewOnclickListener);
shuffleImage.setOnClickListener(viewOnclickListener);
rewImage.setOnClickListener(viewOnclickListener);
localSongsList = MediaUtils.getLocalSongs(view.getContext());
<DeepExtract>
Intent intent = new Intent(view.getContext(), MusicService.class);
getActivity().bindService(intent, serviceConnection, Service.BIND_AUTO_CREATE);
</DeepExtract>
localListView.setAdapter(new LocalSongsAdapter(view.getContext(), R.layout.item_songs_list, localSongsList));
localListView.setOnScrollListener(new ListViewOnScrollListener());
localListView.setOnItemClickListener(new ListViewOnItemClickListener());
Bitmap bitmap = MediaUtils.getArtwork(view.getContext(), localSongsList.get(0).getId(), localSongsList.get(0).getAlbumId(), true, true);
songImage.setImageBitmap(bitmap);
songTitle.setText(localSongsList.get(0).getTitle());
songArtist.setText(localSongsList.get(0).getArtist());
songLargeImage.setImageBitmap(bitmap);
slidingUpPanelLayout.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View view, float v) {
}
@Override
public void onPanelCollapsed(View view) {
playImage.setVisibility(View.VISIBLE);
}
@Override
public void onPanelExpanded(View view) {
playImage.setVisibility(View.INVISIBLE);
}
@Override
public void onPanelAnchored(View view) {
}
@Override
public void onPanelHidden(View view) {
}
});
TelephonyManager telManager = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
telManager.listen(new MobliePhoneStateListener(), PhoneStateListener.LISTEN_CALL_STATE);
return view;
} | ting | positive | 1,727 |
public Criteria andCollegeidEqualTo(Integer value) {
if (value == null) {
throw new RuntimeException("Value for " + "collegeid" + " cannot be null");
}
criteria.add(new Criterion("collegeID =", value));
return (Criteria) this;
} | public Criteria andCollegeidEqualTo(Integer value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "collegeid" + " cannot be null");
}
criteria.add(new Criterion("collegeID =", value));
</DeepExtract>
return (Criteria) this;
} | Examination_System | positive | 1,728 |
public EasyTime blur(final int blurMinutes) {
int minuteShift = rand.nextInt(blurMinutes) - (blurMinutes / 2);
this.hour += 0;
this.minute += minuteShift;
normalize();
return this;
return this;
} | public EasyTime blur(final int blurMinutes) {
int minuteShift = rand.nextInt(blurMinutes) - (blurMinutes / 2);
<DeepExtract>
this.hour += 0;
this.minute += minuteShift;
normalize();
return this;
</DeepExtract>
return this;
} | Siafu | positive | 1,729 |
public void resetCurrentTable() {
reset();
currentTable = currentTable;
boolean success = false;
try {
stmt = conn.createStatement();
this.res = stmt.executeQuery("select * from " + currentTable);
parseResultSet();
success = true;
} catch (SQLException ex) {
System.out.println("getdatafromtable");
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
if (this.res != null) {
try {
this.res.close();
} catch (SQLException sqlEx) {
}
this.res = null;
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException sqlEx) {
}
stmt = null;
}
return success;
} | public void resetCurrentTable() {
<DeepExtract>
reset();
currentTable = currentTable;
boolean success = false;
try {
stmt = conn.createStatement();
this.res = stmt.executeQuery("select * from " + currentTable);
parseResultSet();
success = true;
} catch (SQLException ex) {
System.out.println("getdatafromtable");
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
if (this.res != null) {
try {
this.res.close();
} catch (SQLException sqlEx) {
}
this.res = null;
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException sqlEx) {
}
stmt = null;
}
return success;
</DeepExtract>
} | Topiary-Explorer | positive | 1,731 |
@Override
public void updateChallenge(@Nullable String tablePrefix, @NotNull String id, @NotNull String data) throws IOException {
File file = new File(dataFolder, id + ".json");
if (file.exists())
file.delete();
Files.write(Paths.get(file.getPath()), data.getBytes(StandardCharsets.UTF_8));
} | @Override
public void updateChallenge(@Nullable String tablePrefix, @NotNull String id, @NotNull String data) throws IOException {
File file = new File(dataFolder, id + ".json");
if (file.exists())
file.delete();
<DeepExtract>
Files.write(Paths.get(file.getPath()), data.getBytes(StandardCharsets.UTF_8));
</DeepExtract>
} | Guilds | positive | 1,732 |
public long toMilliseconds() {
switch(this.intervalId) {
case YEAR_CALENDAR_UNIT:
return YEAR_CALENDAR_UNIT_MS;
case MONTH_CALENDAR_UNIT:
return MONTH_CALENDAR_UNIT_MS;
case DAY_CALENDAR_UNIT:
return DAY_CALENDAR_UNIT_MS;
case HOUR_CALENDAR_UNIT:
return HOUR_CALENDAR_UNIT_MS;
case MINUTE_CALENDAR_UNIT:
return MINUTE_CALENDAR_UNIT_MS;
case SECOND_CALENDAR_UNIT:
return SECOND_CALENDAR_UNIT_MS;
case MILLISECOND_CALENDAR_UNIT:
return 1;
case WEEK_CALENDAR_UNIT:
return WEEK_CALENDAR_UNIT_MS;
case QUARTER_CALENDAR_UNIT:
return QUARTER_CALENDAR_UNIT_MS;
default:
return 0;
}
} | public long toMilliseconds() {
<DeepExtract>
switch(this.intervalId) {
case YEAR_CALENDAR_UNIT:
return YEAR_CALENDAR_UNIT_MS;
case MONTH_CALENDAR_UNIT:
return MONTH_CALENDAR_UNIT_MS;
case DAY_CALENDAR_UNIT:
return DAY_CALENDAR_UNIT_MS;
case HOUR_CALENDAR_UNIT:
return HOUR_CALENDAR_UNIT_MS;
case MINUTE_CALENDAR_UNIT:
return MINUTE_CALENDAR_UNIT_MS;
case SECOND_CALENDAR_UNIT:
return SECOND_CALENDAR_UNIT_MS;
case MILLISECOND_CALENDAR_UNIT:
return 1;
case WEEK_CALENDAR_UNIT:
return WEEK_CALENDAR_UNIT_MS;
case QUARTER_CALENDAR_UNIT:
return QUARTER_CALENDAR_UNIT_MS;
default:
return 0;
}
</DeepExtract>
} | JKLocalNotifications-ANE | positive | 1,734 |
public String convertDBCursorToString(EDataType eDataType, Object instanceValue) {
switch(eDataType.getClassifierID()) {
case ModelPackage.DB_OBJECT:
return convertDBObjectToString(eDataType, instanceValue);
case ModelPackage.DB_CURSOR:
return convertDBCursorToString(eDataType, instanceValue);
case ModelPackage.DB_COLLECTION:
return convertDBCollectionToString(eDataType, instanceValue);
case ModelPackage.EOBJECT_BUILDER:
return convertEObjectBuilderToString(eDataType, instanceValue);
case ModelPackage.ITERATOR:
return convertIteratorToString(eDataType, instanceValue);
default:
throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
}
} | public String convertDBCursorToString(EDataType eDataType, Object instanceValue) {
<DeepExtract>
switch(eDataType.getClassifierID()) {
case ModelPackage.DB_OBJECT:
return convertDBObjectToString(eDataType, instanceValue);
case ModelPackage.DB_CURSOR:
return convertDBCursorToString(eDataType, instanceValue);
case ModelPackage.DB_COLLECTION:
return convertDBCollectionToString(eDataType, instanceValue);
case ModelPackage.EOBJECT_BUILDER:
return convertEObjectBuilderToString(eDataType, instanceValue);
case ModelPackage.ITERATOR:
return convertIteratorToString(eDataType, instanceValue);
default:
throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
}
</DeepExtract>
} | mongo-emf | positive | 1,735 |
public Criteria andCommentCountNotEqualTo(Integer value) {
if (value == null) {
throw new RuntimeException("Value for " + "commentCount" + " cannot be null");
}
criteria.add(new Criterion("comment_count <>", value));
return (Criteria) this;
} | public Criteria andCommentCountNotEqualTo(Integer value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "commentCount" + " cannot be null");
}
criteria.add(new Criterion("comment_count <>", value));
</DeepExtract>
return (Criteria) this;
} | community | positive | 1,736 |
@Test
public void testGreaterThanOrEq() throws DbException, TransactionAbortedException, IOException {
HeapFile f = createTable(2, 42);
Predicate predicate = new Predicate(2, Predicate.Op.GREATER_THAN_OR_EQ, new IntField(42));
assertEquals(ROWS, runTransactionForPredicate(f, predicate));
f = Utility.openHeapFile(COLUMNS, f.getFile());
validateAfter(f);
f = createTable(2, 42);
predicate = new Predicate(2, Predicate.Op.GREATER_THAN_OR_EQ, new IntField(43));
assertEquals(0, runTransactionForPredicate(f, predicate));
f = Utility.openHeapFile(COLUMNS, f.getFile());
validateAfter(f);
} | @Test
public void testGreaterThanOrEq() throws DbException, TransactionAbortedException, IOException {
<DeepExtract>
HeapFile f = createTable(2, 42);
Predicate predicate = new Predicate(2, Predicate.Op.GREATER_THAN_OR_EQ, new IntField(42));
assertEquals(ROWS, runTransactionForPredicate(f, predicate));
f = Utility.openHeapFile(COLUMNS, f.getFile());
validateAfter(f);
f = createTable(2, 42);
predicate = new Predicate(2, Predicate.Op.GREATER_THAN_OR_EQ, new IntField(43));
assertEquals(0, runTransactionForPredicate(f, predicate));
f = Utility.openHeapFile(COLUMNS, f.getFile());
validateAfter(f);
</DeepExtract>
} | ToyDB | positive | 1,737 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.