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 synchronized ObjectName register(Object obj) throws JMException {
if (mbeanServer == null) {
throw new JMException("JmxServer has not be started");
}
ObjectName objectName = ObjectNameUtil.makeObjectName(obj);
try {
mbean = new ReflectionMbean(obj, getObjectDescription(obj));
} catch (Exception e) {
throw createJmException("Could not build MBean object for: " + obj, e);
}
try {
mbeanServer.registerMBean(mbean, objectName);
registeredCount++;
} catch (Exception e) {
throw createJmException("Registering JMX object " + objectName + " failed", e);
}
return objectName;
} | public synchronized ObjectName register(Object obj) throws JMException {
if (mbeanServer == null) {
throw new JMException("JmxServer has not be started");
}
ObjectName objectName = ObjectNameUtil.makeObjectName(obj);
try {
mbean = new ReflectionMbean(obj, getObjectDescription(obj));
} catch (Exception e) {
throw createJmException("Could not build MBean object for: " + obj, e);
}
<DeepExtract>
try {
mbeanServer.registerMBean(mbean, objectName);
registeredCount++;
} catch (Exception e) {
throw createJmException("Registering JMX object " + objectName + " failed", e);
}
</DeepExtract>
return objectName;
} | simplejmx | positive | 2,430 |
public String getRandomRelationship() {
String k;
Random ran = new Random();
int x, i, j;
JSONArray a;
while (getRandom(relationships).indexOf("{{") >= 0) {
i = getRandom(relationships).indexOf("{{");
j = getRandom(relationships).indexOf("}}");
k = getRandom(relationships).substring(i + 2, j);
a = parseMap.get(k);
if (a == null) {
getRandom(relationships) = getRandom(relationships).substring(0, i) + " ... " + getRandom(relationships).substring(j + 2);
}
x = ran.nextInt(a.length());
try {
getRandom(relationships) = getRandom(relationships).substring(0, i) + a.get(x) + getRandom(relationships).substring(j + 2);
} catch (JSONException e) {
getRandom(relationships) = getRandom(relationships).substring(0, i) + " ... " + getRandom(relationships).substring(j + 2);
Log.e("NPCData", e.getMessage());
e.printStackTrace();
}
}
return getRandom(relationships);
} | public String getRandomRelationship() {
<DeepExtract>
String k;
Random ran = new Random();
int x, i, j;
JSONArray a;
while (getRandom(relationships).indexOf("{{") >= 0) {
i = getRandom(relationships).indexOf("{{");
j = getRandom(relationships).indexOf("}}");
k = getRandom(relationships).substring(i + 2, j);
a = parseMap.get(k);
if (a == null) {
getRandom(relationships) = getRandom(relationships).substring(0, i) + " ... " + getRandom(relationships).substring(j + 2);
}
x = ran.nextInt(a.length());
try {
getRandom(relationships) = getRandom(relationships).substring(0, i) + a.get(x) + getRandom(relationships).substring(j + 2);
} catch (JSONException e) {
getRandom(relationships) = getRandom(relationships).substring(0, i) + " ... " + getRandom(relationships).substring(j + 2);
Log.e("NPCData", e.getMessage());
e.printStackTrace();
}
}
return getRandom(relationships);
</DeepExtract>
} | RPGCompanion | positive | 2,431 |
public void finished() {
double nowSec = nowSec();
prevStartSec = nowSec;
setStatus(String.format("Completed %d events in %1.2f secs", totalCount, prevStartSec - startTimeSec));
} | public void finished() {
<DeepExtract>
double nowSec = nowSec();
prevStartSec = nowSec;
setStatus(String.format("Completed %d events in %1.2f secs", totalCount, prevStartSec - startTimeSec));
</DeepExtract>
} | gchisto | positive | 2,432 |
@Override
public void onCancel(DialogInterface dialogInterface) {
cancelled = true;
if (thread != null) {
thread.interrupt();
}
if (finishActivityOnCancel) {
getActivity().finish();
}
} | @Override
public void onCancel(DialogInterface dialogInterface) {
<DeepExtract>
cancelled = true;
if (thread != null) {
thread.interrupt();
}
if (finishActivityOnCancel) {
getActivity().finish();
}
</DeepExtract>
} | Subsonic-Android | positive | 2,433 |
@ParameterizedTest
@MethodSource("versions")
void testFailNativePortBusy(Version version) throws Throwable {
this.builder.version(version);
Cassandra cassandra = this.builder.build();
try {
try {
cassandra.start();
} catch (Throwable ex) {
(cassandra, throwable) -> {
assertThat(throwable).doesNotThrowAnyException();
this.builder.addSystemProperty("cassandra.jmx.local.port", 0).addSystemProperty("cassandra.storage_port", 0).configure(new SimpleSeedProviderConfigurator("localhost:0"));
this.runner.run((cassandra2, throwable2) -> assertThat(throwable2).isNotNull().hasStackTraceContaining("Failed to bind port "));
}.accept(cassandra, ex);
return;
}
(cassandra, throwable) -> {
assertThat(throwable).doesNotThrowAnyException();
this.builder.addSystemProperty("cassandra.jmx.local.port", 0).addSystemProperty("cassandra.storage_port", 0).configure(new SimpleSeedProviderConfigurator("localhost:0"));
this.runner.run((cassandra2, throwable2) -> assertThat(throwable2).isNotNull().hasStackTraceContaining("Failed to bind port "));
}.accept(cassandra, null);
} catch (Throwable ex) {
try {
cassandra.stop();
} catch (Throwable suppressed) {
ex.addSuppressed(suppressed);
}
throw ex;
} finally {
cassandra.stop();
}
} | @ParameterizedTest
@MethodSource("versions")
void testFailNativePortBusy(Version version) throws Throwable {
this.builder.version(version);
<DeepExtract>
Cassandra cassandra = this.builder.build();
try {
try {
cassandra.start();
} catch (Throwable ex) {
(cassandra, throwable) -> {
assertThat(throwable).doesNotThrowAnyException();
this.builder.addSystemProperty("cassandra.jmx.local.port", 0).addSystemProperty("cassandra.storage_port", 0).configure(new SimpleSeedProviderConfigurator("localhost:0"));
this.runner.run((cassandra2, throwable2) -> assertThat(throwable2).isNotNull().hasStackTraceContaining("Failed to bind port "));
}.accept(cassandra, ex);
return;
}
(cassandra, throwable) -> {
assertThat(throwable).doesNotThrowAnyException();
this.builder.addSystemProperty("cassandra.jmx.local.port", 0).addSystemProperty("cassandra.storage_port", 0).configure(new SimpleSeedProviderConfigurator("localhost:0"));
this.runner.run((cassandra2, throwable2) -> assertThat(throwable2).isNotNull().hasStackTraceContaining("Failed to bind port "));
}.accept(cassandra, null);
} catch (Throwable ex) {
try {
cassandra.stop();
} catch (Throwable suppressed) {
ex.addSuppressed(suppressed);
}
throw ex;
} finally {
cassandra.stop();
}
</DeepExtract>
} | embedded-cassandra | positive | 2,434 |
private Reader readStreamItemIds(long syncTime, IItemIdListHandler handler) throws IOException, ReaderException, RemoteException {
final Context context = mContext == null ? getApplicationContext() : mContext;
this.auth = Prefs.getGoogleAuth(context);
long authTime = Prefs.getGoogleAuthTime(context);
if (this.auth != null) {
long diff = System.currentTimeMillis() - authTime;
if (diff < AUTH_EXPIRE_TIME)
return this.auth;
}
if (TextUtils.isEmpty(this.loginId))
this.loginId = Prefs.getGoogleId(context);
if (TextUtils.isEmpty(this.password))
this.password = Prefs.getGooglePasswd(context);
if (this.loginId == null || this.password == null)
throw new ReaderLoginException("No Login Data");
List<NameValuePair> params = new ArrayList<NameValuePair>(4);
params.add(new BasicNameValuePair("Email", this.loginId));
params.add(new BasicNameValuePair("Passwd", this.password));
BufferedReader in = new BufferedReader(doPostReader(URL_LOGIN, params));
try {
String line;
while ((line = in.readLine()) != null) {
if (line.indexOf("Auth=") == 0) {
this.auth = line.substring("Auth=".length());
break;
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
in.close();
}
if (this.auth == null)
throw new ReaderException("Login Failure");
Prefs.setGoogleAuth(context, this.auth);
return this.auth;
StringBuilder buff = new StringBuilder(URL_API_STREAM_ITEM_IDS.length() + 128);
buff.append(URL_API_STREAM_ITEM_IDS);
buff.append("?output=json");
String stream = handler.stream();
if (stream == null || stream.equals(STATE_READING_LIST))
stream = STATE_GOOGLE_READING_LIST;
else if (stream.equals(STATE_STARRED))
stream = STATE_GOOGLE_STARRED;
buff.append("&s=").append(Utils.encode(stream));
if (handler.excludeRead()) {
buff.append("&xt=").append(STATE_GOOGLE_READ);
}
int limit = handler.limit();
if (limit > 0) {
buff.append("&n=").append(limit);
}
buff.append("&r=").append(handler.newestFirst() ? "n" : "o");
InputStream in = doGetInputStream(buff.toString());
if (in == null) {
return null;
}
return new InputStreamReader(in, HTTP.UTF_8);
} | private Reader readStreamItemIds(long syncTime, IItemIdListHandler handler) throws IOException, ReaderException, RemoteException {
final Context context = mContext == null ? getApplicationContext() : mContext;
this.auth = Prefs.getGoogleAuth(context);
long authTime = Prefs.getGoogleAuthTime(context);
if (this.auth != null) {
long diff = System.currentTimeMillis() - authTime;
if (diff < AUTH_EXPIRE_TIME)
return this.auth;
}
if (TextUtils.isEmpty(this.loginId))
this.loginId = Prefs.getGoogleId(context);
if (TextUtils.isEmpty(this.password))
this.password = Prefs.getGooglePasswd(context);
if (this.loginId == null || this.password == null)
throw new ReaderLoginException("No Login Data");
List<NameValuePair> params = new ArrayList<NameValuePair>(4);
params.add(new BasicNameValuePair("Email", this.loginId));
params.add(new BasicNameValuePair("Passwd", this.password));
BufferedReader in = new BufferedReader(doPostReader(URL_LOGIN, params));
try {
String line;
while ((line = in.readLine()) != null) {
if (line.indexOf("Auth=") == 0) {
this.auth = line.substring("Auth=".length());
break;
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
in.close();
}
if (this.auth == null)
throw new ReaderException("Login Failure");
Prefs.setGoogleAuth(context, this.auth);
return this.auth;
StringBuilder buff = new StringBuilder(URL_API_STREAM_ITEM_IDS.length() + 128);
buff.append(URL_API_STREAM_ITEM_IDS);
buff.append("?output=json");
String stream = handler.stream();
if (stream == null || stream.equals(STATE_READING_LIST))
stream = STATE_GOOGLE_READING_LIST;
else if (stream.equals(STATE_STARRED))
stream = STATE_GOOGLE_STARRED;
buff.append("&s=").append(Utils.encode(stream));
if (handler.excludeRead()) {
buff.append("&xt=").append(STATE_GOOGLE_READ);
}
int limit = handler.limit();
if (limit > 0) {
buff.append("&n=").append(limit);
}
buff.append("&r=").append(handler.newestFirst() ? "n" : "o");
<DeepExtract>
InputStream in = doGetInputStream(buff.toString());
if (in == null) {
return null;
}
return new InputStreamReader(in, HTTP.UTF_8);
</DeepExtract>
} | newsplus | positive | 2,435 |
@Test
public void diff() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit master = repo.branch("refs/heads/master").commit().parent(parent).create();
TestViewFilter.Result result = TestViewFilter.service(repo, "/repo/+diff/master^..master");
FakeHttpServletResponse resp = result.getResponse();
assertWithMessage("expected non-redirect status, got " + resp.getStatus()).that(resp.getStatus() < 300 || resp.getStatus() >= 400).isTrue();
return result.getView();
assertThat(view.getType()).isEqualTo(Type.DIFF);
assertThat(view.getRevision().getName()).isEqualTo("master");
assertThat(view.getRevision().getId()).isEqualTo(master);
assertThat(view.getOldRevision().getName()).isEqualTo("master^");
assertThat(view.getOldRevision().getId()).isEqualTo(parent);
assertThat(view.getPathPart()).isEqualTo("");
TestViewFilter.Result result = TestViewFilter.service(repo, "/repo/+diff/master^..master/");
FakeHttpServletResponse resp = result.getResponse();
assertWithMessage("expected non-redirect status, got " + resp.getStatus()).that(resp.getStatus() < 300 || resp.getStatus() >= 400).isTrue();
return result.getView();
assertThat(view.getType()).isEqualTo(Type.DIFF);
assertThat(view.getRevision().getName()).isEqualTo("master");
assertThat(view.getRevision().getId()).isEqualTo(master);
assertThat(view.getOldRevision().getName()).isEqualTo("master^");
assertThat(view.getOldRevision().getId()).isEqualTo(parent);
assertThat(view.getPathPart()).isEqualTo("");
TestViewFilter.Result result = TestViewFilter.service(repo, "/repo/+diff/master^..master/foo");
FakeHttpServletResponse resp = result.getResponse();
assertWithMessage("expected non-redirect status, got " + resp.getStatus()).that(resp.getStatus() < 300 || resp.getStatus() >= 400).isTrue();
return result.getView();
assertThat(view.getType()).isEqualTo(Type.DIFF);
assertThat(view.getRevision().getName()).isEqualTo("master");
assertThat(view.getRevision().getId()).isEqualTo(master);
assertThat(view.getOldRevision().getName()).isEqualTo("master^");
assertThat(view.getOldRevision().getId()).isEqualTo(parent);
assertThat(view.getPathPart()).isEqualTo("foo");
TestViewFilter.Result result = TestViewFilter.service(repo, "/repo/+diff/refs/heads/master^..refs/heads/master");
FakeHttpServletResponse resp = result.getResponse();
assertWithMessage("expected non-redirect status, got " + resp.getStatus()).that(resp.getStatus() < 300 || resp.getStatus() >= 400).isTrue();
return result.getView();
assertThat(view.getType()).isEqualTo(Type.DIFF);
assertThat(view.getRevision().getName()).isEqualTo("refs/heads/master");
assertThat(view.getRevision().getId()).isEqualTo(master);
assertThat(view.getOldRevision().getName()).isEqualTo("refs/heads/master^");
assertThat(view.getOldRevision().getId()).isEqualTo(parent);
assertThat(view.getPathPart()).isEqualTo("");
} | @Test
public void diff() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit master = repo.branch("refs/heads/master").commit().parent(parent).create();
TestViewFilter.Result result = TestViewFilter.service(repo, "/repo/+diff/master^..master");
FakeHttpServletResponse resp = result.getResponse();
assertWithMessage("expected non-redirect status, got " + resp.getStatus()).that(resp.getStatus() < 300 || resp.getStatus() >= 400).isTrue();
return result.getView();
assertThat(view.getType()).isEqualTo(Type.DIFF);
assertThat(view.getRevision().getName()).isEqualTo("master");
assertThat(view.getRevision().getId()).isEqualTo(master);
assertThat(view.getOldRevision().getName()).isEqualTo("master^");
assertThat(view.getOldRevision().getId()).isEqualTo(parent);
assertThat(view.getPathPart()).isEqualTo("");
TestViewFilter.Result result = TestViewFilter.service(repo, "/repo/+diff/master^..master/");
FakeHttpServletResponse resp = result.getResponse();
assertWithMessage("expected non-redirect status, got " + resp.getStatus()).that(resp.getStatus() < 300 || resp.getStatus() >= 400).isTrue();
return result.getView();
assertThat(view.getType()).isEqualTo(Type.DIFF);
assertThat(view.getRevision().getName()).isEqualTo("master");
assertThat(view.getRevision().getId()).isEqualTo(master);
assertThat(view.getOldRevision().getName()).isEqualTo("master^");
assertThat(view.getOldRevision().getId()).isEqualTo(parent);
assertThat(view.getPathPart()).isEqualTo("");
TestViewFilter.Result result = TestViewFilter.service(repo, "/repo/+diff/master^..master/foo");
FakeHttpServletResponse resp = result.getResponse();
assertWithMessage("expected non-redirect status, got " + resp.getStatus()).that(resp.getStatus() < 300 || resp.getStatus() >= 400).isTrue();
return result.getView();
assertThat(view.getType()).isEqualTo(Type.DIFF);
assertThat(view.getRevision().getName()).isEqualTo("master");
assertThat(view.getRevision().getId()).isEqualTo(master);
assertThat(view.getOldRevision().getName()).isEqualTo("master^");
assertThat(view.getOldRevision().getId()).isEqualTo(parent);
assertThat(view.getPathPart()).isEqualTo("foo");
<DeepExtract>
TestViewFilter.Result result = TestViewFilter.service(repo, "/repo/+diff/refs/heads/master^..refs/heads/master");
FakeHttpServletResponse resp = result.getResponse();
assertWithMessage("expected non-redirect status, got " + resp.getStatus()).that(resp.getStatus() < 300 || resp.getStatus() >= 400).isTrue();
return result.getView();
</DeepExtract>
assertThat(view.getType()).isEqualTo(Type.DIFF);
assertThat(view.getRevision().getName()).isEqualTo("refs/heads/master");
assertThat(view.getRevision().getId()).isEqualTo(master);
assertThat(view.getOldRevision().getName()).isEqualTo("refs/heads/master^");
assertThat(view.getOldRevision().getId()).isEqualTo(parent);
assertThat(view.getPathPart()).isEqualTo("");
} | gitiles | positive | 2,436 |
public static void main(String[] args) {
DoubleLinkList doubleLinkList = new DoubleLinkList();
Node head = null;
if (head == null) {
head = new Node(1);
head = head;
}
Node newNode = new Node(1);
Node current = head;
while (current != null) {
current = current.next;
}
current.next = newNode;
newNode.prev = current;
return head;
if (head == null) {
head = new Node(2);
head = head;
}
Node newNode = new Node(2);
Node current = head;
while (current != null) {
current = current.next;
}
current.next = newNode;
newNode.prev = current;
return head;
if (head == null) {
head = new Node(3);
head = head;
}
Node newNode = new Node(3);
Node current = head;
while (current != null) {
current = current.next;
}
current.next = newNode;
newNode.prev = current;
return head;
if (head == null) {
head = new Node(4);
head = head;
}
Node newNode = new Node(4);
Node current = head;
while (current != null) {
current = current.next;
}
current.next = newNode;
newNode.prev = current;
return head;
if (head == null) {
head = new Node(5);
head = head;
}
Node newNode = new Node(5);
Node current = head;
while (current != null) {
current = current.next;
}
current.next = newNode;
newNode.prev = current;
return head;
} | public static void main(String[] args) {
DoubleLinkList doubleLinkList = new DoubleLinkList();
Node head = null;
if (head == null) {
head = new Node(1);
head = head;
}
Node newNode = new Node(1);
Node current = head;
while (current != null) {
current = current.next;
}
current.next = newNode;
newNode.prev = current;
return head;
if (head == null) {
head = new Node(2);
head = head;
}
Node newNode = new Node(2);
Node current = head;
while (current != null) {
current = current.next;
}
current.next = newNode;
newNode.prev = current;
return head;
if (head == null) {
head = new Node(3);
head = head;
}
Node newNode = new Node(3);
Node current = head;
while (current != null) {
current = current.next;
}
current.next = newNode;
newNode.prev = current;
return head;
if (head == null) {
head = new Node(4);
head = head;
}
Node newNode = new Node(4);
Node current = head;
while (current != null) {
current = current.next;
}
current.next = newNode;
newNode.prev = current;
return head;
<DeepExtract>
if (head == null) {
head = new Node(5);
head = head;
}
Node newNode = new Node(5);
Node current = head;
while (current != null) {
current = current.next;
}
current.next = newNode;
newNode.prev = current;
return head;
</DeepExtract>
} | Data-Structures-Algorithms | positive | 2,437 |
public void write(byte data) {
buffer[yOffset][xOffset++] = data;
if (xOffset >= buffer[yOffset].length) {
yOffset++;
xOffset = 0;
}
if (!invalidated.get()) {
invalidated.set(true);
invalidated();
}
} | public void write(byte data) {
buffer[yOffset][xOffset++] = data;
if (xOffset >= buffer[yOffset].length) {
yOffset++;
xOffset = 0;
}
<DeepExtract>
if (!invalidated.get()) {
invalidated.set(true);
invalidated();
}
</DeepExtract>
} | glcd-emulator | positive | 2,438 |
public static void onCreateInfo(Activity activity, long startTime) {
startType = isFirst ? ActivityInfo.COLD_START : ActivityInfo.HOT_START;
activity.getWindow().getDecorView().post(new FirstFrameRunnable(activity, startType, startTime));
long curTime = System.currentTimeMillis();
if (activity == null) {
if (DEBUG) {
LogX.d(TAG, SUB_TAG, "saveActivityInfo activity == null");
}
return;
}
if (curTime - startTime < ArgusApmConfigManager.getInstance().getArgusApmConfigData().funcControl.activityLifecycleMinTime) {
return;
}
String pluginName = ExtraInfoHelper.getPluginName(activity);
String activityName = activity.getClass().getCanonicalName();
activityInfo.resetData();
activityInfo.activityName = activityName;
activityInfo.startType = startType;
activityInfo.time = curTime - startTime;
activityInfo.lifeCycle = ActivityInfo.TYPE_CREATE;
activityInfo.pluginName = pluginName;
activityInfo.pluginVer = ExtraInfoHelper.getPluginVersion(pluginName);
if (DEBUG) {
LogX.d(TAG, SUB_TAG, "apmins saveActivityInfo activity:" + activity.getClass().getCanonicalName() + " | lifecycle : " + activityInfo.getLifeCycleString() + " | time : " + curTime - startTime);
}
ITask task = Manager.getInstance().getTaskManager().getTask(ApmTask.TASK_ACTIVITY);
boolean result = false;
if (task != null) {
result = task.save(activityInfo);
} else {
if (DEBUG) {
LogX.d(TAG, SUB_TAG, "saveActivityInfo task == null");
}
}
if (DEBUG) {
LogX.d(TAG, SUB_TAG, "activity info:" + activityInfo.toString());
}
if (AnalyzeManager.getInstance().isDebugMode()) {
AnalyzeManager.getInstance().getActivityTask().parse(activityInfo);
}
if (Env.DEBUG) {
LogX.d(TAG, SUB_TAG, "saveActivityInfo result:" + result);
}
} | public static void onCreateInfo(Activity activity, long startTime) {
startType = isFirst ? ActivityInfo.COLD_START : ActivityInfo.HOT_START;
activity.getWindow().getDecorView().post(new FirstFrameRunnable(activity, startType, startTime));
long curTime = System.currentTimeMillis();
<DeepExtract>
if (activity == null) {
if (DEBUG) {
LogX.d(TAG, SUB_TAG, "saveActivityInfo activity == null");
}
return;
}
if (curTime - startTime < ArgusApmConfigManager.getInstance().getArgusApmConfigData().funcControl.activityLifecycleMinTime) {
return;
}
String pluginName = ExtraInfoHelper.getPluginName(activity);
String activityName = activity.getClass().getCanonicalName();
activityInfo.resetData();
activityInfo.activityName = activityName;
activityInfo.startType = startType;
activityInfo.time = curTime - startTime;
activityInfo.lifeCycle = ActivityInfo.TYPE_CREATE;
activityInfo.pluginName = pluginName;
activityInfo.pluginVer = ExtraInfoHelper.getPluginVersion(pluginName);
if (DEBUG) {
LogX.d(TAG, SUB_TAG, "apmins saveActivityInfo activity:" + activity.getClass().getCanonicalName() + " | lifecycle : " + activityInfo.getLifeCycleString() + " | time : " + curTime - startTime);
}
ITask task = Manager.getInstance().getTaskManager().getTask(ApmTask.TASK_ACTIVITY);
boolean result = false;
if (task != null) {
result = task.save(activityInfo);
} else {
if (DEBUG) {
LogX.d(TAG, SUB_TAG, "saveActivityInfo task == null");
}
}
if (DEBUG) {
LogX.d(TAG, SUB_TAG, "activity info:" + activityInfo.toString());
}
if (AnalyzeManager.getInstance().isDebugMode()) {
AnalyzeManager.getInstance().getActivityTask().parse(activityInfo);
}
if (Env.DEBUG) {
LogX.d(TAG, SUB_TAG, "saveActivityInfo result:" + result);
}
</DeepExtract>
} | ArgusAPM | positive | 2,439 |
private void init() {
int k = 0, i = 1, j = 1;
do {
while (j <= L[i]) {
huffsize[k] = i;
k++;
j++;
}
i++;
j = 1;
} while (i <= 16);
huffsize[k] = 0;
int k = 0, code = 0, si = huffsize[0];
for (; ; ) {
do {
huffcode[k] = code;
code++;
k++;
} while (huffsize[k] == si);
if (huffsize[k] == 0) {
break;
}
do {
code = code << 1;
si++;
} while (huffsize[k] != si);
}
int i = 0, j = 0;
int i = 0, j = 0;
for (; ; ) {
i++;
if (i > 16) {
break;
}
if (L[i] == 0) {
maxcode[i] = -1;
continue;
} else {
valptr[i] = j;
mincode[i] = huffcode[j];
j = j + L[i] - 1;
maxcode[i] = huffcode[j];
j++;
}
}
maxcode[17] = 0xFFFFFF;
} | private void init() {
int k = 0, i = 1, j = 1;
do {
while (j <= L[i]) {
huffsize[k] = i;
k++;
j++;
}
i++;
j = 1;
} while (i <= 16);
huffsize[k] = 0;
<DeepExtract>
int k = 0, code = 0, si = huffsize[0];
for (; ; ) {
do {
huffcode[k] = code;
code++;
k++;
} while (huffsize[k] == si);
if (huffsize[k] == 0) {
break;
}
do {
code = code << 1;
si++;
} while (huffsize[k] != si);
}
</DeepExtract>
int i = 0, j = 0;
int i = 0, j = 0;
for (; ; ) {
i++;
if (i > 16) {
break;
}
if (L[i] == 0) {
maxcode[i] = -1;
continue;
} else {
valptr[i] = j;
mincode[i] = huffcode[j];
j = j + L[i] - 1;
maxcode[i] = huffcode[j];
j++;
}
}
maxcode[17] = 0xFFFFFF;
} | simpleimage | positive | 2,440 |
@Override
protected boolean setFrame(int l, int t, int r, int b) {
mWidth = r - l;
mHeight = b - t;
mMatrix.reset();
int r_norm = r - l;
mScale = (float) r_norm / (float) mIntrinsicWidth;
int paddingHeight = 0;
int paddingWidth = 0;
if (mScale * mIntrinsicHeight > mHeight) {
mScale = (float) mHeight / (float) mIntrinsicHeight;
mMatrix.postScale(mScale, mScale);
paddingWidth = (r - mWidth) / 2;
paddingHeight = 0;
} else {
mMatrix.postScale(mScale, mScale);
paddingHeight = (b - mHeight) / 2;
paddingWidth = 0;
}
mMatrix.postTranslate(paddingWidth, paddingHeight);
setImageMatrix(mMatrix);
mMinScale = mScale;
if (getScale() * mScale < mMinScale) {
return;
}
if (mScale >= 1 && getScale() * mScale > MAX_SCALE) {
return;
}
mMatrix.postScale(mScale, mScale);
mMatrix.postTranslate(-(mWidth * mScale - mWidth) / 2, -(mHeight * mScale - mHeight) / 2);
mMatrix.postTranslate(-(mWidth / 2 - (mWidth / 2)) * mScale, 0);
mMatrix.postTranslate(0, -(mHeight / 2 - (mHeight / 2)) * mScale);
setImageMatrix(mMatrix);
int width = (int) (mIntrinsicWidth * getScale());
int height = (int) (mIntrinsicHeight * getScale());
if (getTranslateX() < -(width - mWidth)) {
mMatrix.postTranslate(-(getTranslateX() + width - mWidth), 0);
}
if (getTranslateX() > 0) {
mMatrix.postTranslate(-getTranslateX(), 0);
}
if (getTranslateY() < -(height - mHeight)) {
mMatrix.postTranslate(0, -(getTranslateY() + height - mHeight));
}
if (getTranslateY() > 0) {
mMatrix.postTranslate(0, -getTranslateY());
}
if (width < mWidth) {
mMatrix.postTranslate((mWidth - width) / 2, 0);
}
if (height < mHeight) {
mMatrix.postTranslate(0, (mHeight - height) / 2);
}
setImageMatrix(mMatrix);
return super.setFrame(l, t, r, b);
} | @Override
protected boolean setFrame(int l, int t, int r, int b) {
mWidth = r - l;
mHeight = b - t;
mMatrix.reset();
int r_norm = r - l;
mScale = (float) r_norm / (float) mIntrinsicWidth;
int paddingHeight = 0;
int paddingWidth = 0;
if (mScale * mIntrinsicHeight > mHeight) {
mScale = (float) mHeight / (float) mIntrinsicHeight;
mMatrix.postScale(mScale, mScale);
paddingWidth = (r - mWidth) / 2;
paddingHeight = 0;
} else {
mMatrix.postScale(mScale, mScale);
paddingHeight = (b - mHeight) / 2;
paddingWidth = 0;
}
mMatrix.postTranslate(paddingWidth, paddingHeight);
setImageMatrix(mMatrix);
mMinScale = mScale;
if (getScale() * mScale < mMinScale) {
return;
}
if (mScale >= 1 && getScale() * mScale > MAX_SCALE) {
return;
}
mMatrix.postScale(mScale, mScale);
mMatrix.postTranslate(-(mWidth * mScale - mWidth) / 2, -(mHeight * mScale - mHeight) / 2);
mMatrix.postTranslate(-(mWidth / 2 - (mWidth / 2)) * mScale, 0);
mMatrix.postTranslate(0, -(mHeight / 2 - (mHeight / 2)) * mScale);
setImageMatrix(mMatrix);
<DeepExtract>
int width = (int) (mIntrinsicWidth * getScale());
int height = (int) (mIntrinsicHeight * getScale());
if (getTranslateX() < -(width - mWidth)) {
mMatrix.postTranslate(-(getTranslateX() + width - mWidth), 0);
}
if (getTranslateX() > 0) {
mMatrix.postTranslate(-getTranslateX(), 0);
}
if (getTranslateY() < -(height - mHeight)) {
mMatrix.postTranslate(0, -(getTranslateY() + height - mHeight));
}
if (getTranslateY() > 0) {
mMatrix.postTranslate(0, -getTranslateY());
}
if (width < mWidth) {
mMatrix.postTranslate((mWidth - width) / 2, 0);
}
if (height < mHeight) {
mMatrix.postTranslate(0, (mHeight - height) / 2);
}
setImageMatrix(mMatrix);
</DeepExtract>
return super.setFrame(l, t, r, b);
} | Mae | positive | 2,441 |
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
TelinkLog.d("service connected --> " + name.getShortClassName());
serviceConnected = true;
dispatchEvent(ServiceEvent.newInstance(this, ServiceEvent.SERVICE_CONNECTED, service));
} | @Override
public void onServiceConnected(ComponentName name, IBinder service) {
<DeepExtract>
TelinkLog.d("service connected --> " + name.getShortClassName());
serviceConnected = true;
dispatchEvent(ServiceEvent.newInstance(this, ServiceEvent.SERVICE_CONNECTED, service));
</DeepExtract>
} | BleMeshLib | positive | 2,442 |
public int clockSequence() {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
} | public int clockSequence() {
<DeepExtract>
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
</DeepExtract>
return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
} | DimpleBlog | positive | 2,443 |
@Override
public void unwhitelist(String id) throws ConnectionException {
this.whitelistedIds.remove(id);
JsonValue whitelistedUserList = JsonValue.valueOf(whitelistedIds.stream().collect(Collectors.joining(",")));
putOption("alloweduserlist", whitelistedUserList, true);
} | @Override
public void unwhitelist(String id) throws ConnectionException {
this.whitelistedIds.remove(id);
<DeepExtract>
JsonValue whitelistedUserList = JsonValue.valueOf(whitelistedIds.stream().collect(Collectors.joining(",")));
putOption("alloweduserlist", whitelistedUserList, true);
</DeepExtract>
} | Skype4J | positive | 2,444 |
@Override
public void onClick(View v) {
if (mLatestLoadedSections == null || mAudioPlayer == null)
return;
int currentElapsed = mAudioPlayer.elapsed();
for (Section section : mLatestLoadedSections) {
final int seek = section.start * 1000;
if (seek > currentElapsed) {
mAudioPlayer.seekAndPlay(seek);
return;
}
}
} | @Override
public void onClick(View v) {
<DeepExtract>
if (mLatestLoadedSections == null || mAudioPlayer == null)
return;
int currentElapsed = mAudioPlayer.elapsed();
for (Section section : mLatestLoadedSections) {
final int seek = section.start * 1000;
if (seek > currentElapsed) {
mAudioPlayer.seekAndPlay(seek);
return;
}
}
</DeepExtract>
} | SGU | positive | 2,445 |
@Override
public void decode(HexData input) {
if (input.getSize() < MethodId.SIZE_BYTES) {
throw new IllegalArgumentException("Empty or short methodId");
}
MethodId methodId = MethodId.fromInput(input);
if (!methodId.equals(getMethod().getMethodId())) {
throw new IllegalArgumentException("Invalid method id: " + methodId + " != " + getMethod().getMethodId());
}
} | @Override
public void decode(HexData input) {
<DeepExtract>
if (input.getSize() < MethodId.SIZE_BYTES) {
throw new IllegalArgumentException("Empty or short methodId");
}
MethodId methodId = MethodId.fromInput(input);
if (!methodId.equals(getMethod().getMethodId())) {
throw new IllegalArgumentException("Invalid method id: " + methodId + " != " + getMethod().getMethodId());
}
</DeepExtract>
} | etherjar | positive | 2,446 |
public static CameraCalibrationCoefficients getLaptop() {
try {
return new ObjectMapper().readValue((Path.of(getCalibrationPath(true).toString(), "laptop.json").toFile()), CameraCalibrationCoefficients.class);
} catch (IOException e) {
e.printStackTrace();
return null;
}
} | public static CameraCalibrationCoefficients getLaptop() {
<DeepExtract>
try {
return new ObjectMapper().readValue((Path.of(getCalibrationPath(true).toString(), "laptop.json").toFile()), CameraCalibrationCoefficients.class);
} catch (IOException e) {
e.printStackTrace();
return null;
}
</DeepExtract>
} | photonvision | positive | 2,447 |
public AccountEnt createNew(AccountEnt account) {
GameContext.getPlayerService().addAccountProfile(account);
GameContext.getAysncDbService().saveToDb(account);
return account;
} | public AccountEnt createNew(AccountEnt account) {
<DeepExtract>
GameContext.getPlayerService().addAccountProfile(account);
GameContext.getAysncDbService().saveToDb(account);
return account;
</DeepExtract>
} | mmorpg | positive | 2,448 |
@Override
public LicenseWizardState nextState() {
final LicenseWizardState nextState = this.nextState;
return null != nextState ? nextState : (this.nextState = super.nextState());
} | @Override
public LicenseWizardState nextState() {
<DeepExtract>
final LicenseWizardState nextState = this.nextState;
return null != nextState ? nextState : (this.nextState = super.nextState());
</DeepExtract>
} | truelicense | positive | 2,449 |
@Override
protected void initView() {
mHomeFragment = new HomeFragment();
mRedPacketFragment = new OnSellFragment();
mSelectedFragment = new SelectedFragment();
mSearchFragment = new SearchFragment();
mFm = getSupportFragmentManager();
switchFragment(mHomeFragment);
} | @Override
protected void initView() {
<DeepExtract>
mHomeFragment = new HomeFragment();
mRedPacketFragment = new OnSellFragment();
mSelectedFragment = new SelectedFragment();
mSearchFragment = new SearchFragment();
mFm = getSupportFragmentManager();
switchFragment(mHomeFragment);
</DeepExtract>
} | TaobaoUnion | positive | 2,450 |
public String getExcludes() {
final String value = options.get(EXCLUDES);
return value == null ? "" : value;
} | public String getExcludes() {
<DeepExtract>
final String value = options.get(EXCLUDES);
return value == null ? "" : value;
</DeepExtract>
} | mangosteen | positive | 2,451 |
@Override
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder, int fromX, int fromY, int toX, int toY) {
if (oldHolder == newHolder) {
return animateMove(oldHolder, fromX, fromY, toX, toY);
}
final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
final View view = oldHolder.itemView;
ViewCompat.animate(view).cancel();
resetView(view);
for (int i = mPendingMoves.size() - 1; i >= 0; i--) {
MoveInfo moveInfo = mPendingMoves.get(i);
if (moveInfo.holder == oldHolder) {
dispatchMoveFinished(oldHolder);
mPendingMoves.remove(i);
}
}
endChangeAnimation(mPendingChanges, oldHolder);
if (mPendingRemovals.remove(oldHolder)) {
dispatchRemoveFinished(oldHolder);
}
if (mPendingAdditions.remove(oldHolder)) {
dispatchAddFinished(oldHolder);
}
for (int i = mChangesList.size() - 1; i >= 0; i--) {
ArrayList<ChangeInfo> changes = mChangesList.get(i);
endChangeAnimation(changes, oldHolder);
if (changes.isEmpty()) {
mChangesList.remove(i);
}
}
for (int i = mMovesList.size() - 1; i >= 0; i--) {
ArrayList<MoveInfo> moves = mMovesList.get(i);
for (int j = moves.size() - 1; j >= 0; j--) {
MoveInfo moveInfo = moves.get(j);
if (moveInfo.holder == oldHolder) {
dispatchMoveFinished(oldHolder);
moves.remove(j);
if (moves.isEmpty()) {
mMovesList.remove(i);
}
break;
}
}
}
for (int i = mAdditionsList.size() - 1; i >= 0; i--) {
ArrayList<ViewHolder> additions = mAdditionsList.get(i);
if (additions.remove(oldHolder)) {
dispatchAddFinished(oldHolder);
if (additions.isEmpty()) {
mAdditionsList.remove(i);
}
}
}
if (mRemoveAnimations.remove(oldHolder) && DEBUG) {
Log.e("after animation is cancelled, item should not be in " + "mRemoveAnimations list");
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mRemoveAnimations list");
}
if (mAddAnimations.remove(oldHolder) && DEBUG) {
Log.e("after animation is cancelled, item should not be in " + "mAddAnimations list");
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mAddAnimations list");
}
if (mChangeAnimations.remove(oldHolder) && DEBUG) {
Log.e("after animation is cancelled, item should not be in " + "mAddAnimations list");
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mChangeAnimations list");
}
if (mMoveAnimations.remove(oldHolder) && DEBUG) {
Log.e("after animation is cancelled, item should not be in " + "mAddAnimations list");
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mMoveAnimations list");
}
dispatchFinishedWhenDone();
int deltaX = (int) (toX - fromX - prevTranslationX);
int deltaY = (int) (toY - fromY - prevTranslationY);
ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
ViewCompat.setAlpha(oldHolder.itemView, prevAlpha);
if (newHolder != null && newHolder.itemView != null) {
endAnimation(newHolder);
ViewCompat.setTranslationX(newHolder.itemView, -deltaX);
ViewCompat.setTranslationY(newHolder.itemView, -deltaY);
ViewCompat.setAlpha(newHolder.itemView, 0);
}
mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
return true;
} | @Override
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder, int fromX, int fromY, int toX, int toY) {
if (oldHolder == newHolder) {
return animateMove(oldHolder, fromX, fromY, toX, toY);
}
final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
<DeepExtract>
final View view = oldHolder.itemView;
ViewCompat.animate(view).cancel();
resetView(view);
for (int i = mPendingMoves.size() - 1; i >= 0; i--) {
MoveInfo moveInfo = mPendingMoves.get(i);
if (moveInfo.holder == oldHolder) {
dispatchMoveFinished(oldHolder);
mPendingMoves.remove(i);
}
}
endChangeAnimation(mPendingChanges, oldHolder);
if (mPendingRemovals.remove(oldHolder)) {
dispatchRemoveFinished(oldHolder);
}
if (mPendingAdditions.remove(oldHolder)) {
dispatchAddFinished(oldHolder);
}
for (int i = mChangesList.size() - 1; i >= 0; i--) {
ArrayList<ChangeInfo> changes = mChangesList.get(i);
endChangeAnimation(changes, oldHolder);
if (changes.isEmpty()) {
mChangesList.remove(i);
}
}
for (int i = mMovesList.size() - 1; i >= 0; i--) {
ArrayList<MoveInfo> moves = mMovesList.get(i);
for (int j = moves.size() - 1; j >= 0; j--) {
MoveInfo moveInfo = moves.get(j);
if (moveInfo.holder == oldHolder) {
dispatchMoveFinished(oldHolder);
moves.remove(j);
if (moves.isEmpty()) {
mMovesList.remove(i);
}
break;
}
}
}
for (int i = mAdditionsList.size() - 1; i >= 0; i--) {
ArrayList<ViewHolder> additions = mAdditionsList.get(i);
if (additions.remove(oldHolder)) {
dispatchAddFinished(oldHolder);
if (additions.isEmpty()) {
mAdditionsList.remove(i);
}
}
}
if (mRemoveAnimations.remove(oldHolder) && DEBUG) {
Log.e("after animation is cancelled, item should not be in " + "mRemoveAnimations list");
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mRemoveAnimations list");
}
if (mAddAnimations.remove(oldHolder) && DEBUG) {
Log.e("after animation is cancelled, item should not be in " + "mAddAnimations list");
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mAddAnimations list");
}
if (mChangeAnimations.remove(oldHolder) && DEBUG) {
Log.e("after animation is cancelled, item should not be in " + "mAddAnimations list");
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mChangeAnimations list");
}
if (mMoveAnimations.remove(oldHolder) && DEBUG) {
Log.e("after animation is cancelled, item should not be in " + "mAddAnimations list");
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mMoveAnimations list");
}
dispatchFinishedWhenDone();
</DeepExtract>
int deltaX = (int) (toX - fromX - prevTranslationX);
int deltaY = (int) (toY - fromY - prevTranslationY);
ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
ViewCompat.setAlpha(oldHolder.itemView, prevAlpha);
if (newHolder != null && newHolder.itemView != null) {
endAnimation(newHolder);
ViewCompat.setTranslationX(newHolder.itemView, -deltaX);
ViewCompat.setTranslationY(newHolder.itemView, -deltaY);
ViewCompat.setAlpha(newHolder.itemView, 0);
}
mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
return true;
} | MultiView | positive | 2,452 |
public synchronized <T> T toJavaObject(int index, Class<T> type) {
if (!isOpenInternal()) {
throw new IllegalStateException("Lua state is closed");
}
LuaValueProxyRef luaValueProxyRef;
while ((luaValueProxyRef = (LuaValueProxyRef) proxyQueue.poll()) != null) {
proxySet.remove(luaValueProxyRef);
lua_unref(REGISTRYINDEX, luaValueProxyRef.getReference());
}
return converter.convertLuaValue(this, index, type);
} | public synchronized <T> T toJavaObject(int index, Class<T> type) {
<DeepExtract>
if (!isOpenInternal()) {
throw new IllegalStateException("Lua state is closed");
}
LuaValueProxyRef luaValueProxyRef;
while ((luaValueProxyRef = (LuaValueProxyRef) proxyQueue.poll()) != null) {
proxySet.remove(luaValueProxyRef);
lua_unref(REGISTRYINDEX, luaValueProxyRef.getReference());
}
</DeepExtract>
return converter.convertLuaValue(this, index, type);
} | jnlua | positive | 2,453 |
protected void clearPrefixes() {
textPanel.clear();
textPanel.clear();
prefixPanel.setVisible(false);
} | protected void clearPrefixes() {
<DeepExtract>
textPanel.clear();
</DeepExtract>
textPanel.clear();
prefixPanel.setVisible(false);
} | GF | positive | 2,454 |
public ByteBuffer encodeWindowUpdateFrame(int streamId, int deltaWindowSize) {
byte flags = 0;
int length = 8;
ByteBuffer frame = ByteBuffer.allocateDirect(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN);
frame.putShort((short) (version | 0x8000));
frame.putShort((short) SPDY_WINDOW_UPDATE_FRAME);
frame.put(flags);
writeMedium(frame, length);
frame.putInt(streamId);
frame.putInt(deltaWindowSize);
frame.flip();
return frame;
} | public ByteBuffer encodeWindowUpdateFrame(int streamId, int deltaWindowSize) {
byte flags = 0;
int length = 8;
ByteBuffer frame = ByteBuffer.allocateDirect(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN);
<DeepExtract>
frame.putShort((short) (version | 0x8000));
frame.putShort((short) SPDY_WINDOW_UPDATE_FRAME);
frame.put(flags);
writeMedium(frame, length);
</DeepExtract>
frame.putInt(streamId);
frame.putInt(deltaWindowSize);
frame.flip();
return frame;
} | whiskey | positive | 2,455 |
@Override
public void destroyCache(String cacheName) {
if (closed) {
throw new IllegalStateException("CacheManager " + uri + " is already closed");
}
if (cacheName == null) {
throw new NullPointerException("cacheName is null");
}
synchronized (factoryLock) {
int index = 0;
for (Cache<?, ?> registeredCache : CacheInstances) {
if (registeredCache.id().equals(cacheName)) {
registeredCache.close0(false);
CacheInstances.remove(index);
break;
}
index++;
}
}
} | @Override
public void destroyCache(String cacheName) {
<DeepExtract>
if (closed) {
throw new IllegalStateException("CacheManager " + uri + " is already closed");
}
</DeepExtract>
if (cacheName == null) {
throw new NullPointerException("cacheName is null");
}
synchronized (factoryLock) {
int index = 0;
for (Cache<?, ?> registeredCache : CacheInstances) {
if (registeredCache.id().equals(cacheName)) {
registeredCache.close0(false);
CacheInstances.remove(index);
break;
}
index++;
}
}
} | triava | positive | 2,456 |
public String[][] fetchHeartsArray(NetApp netApp) {
String sql = "select * from " + TABLENAME_HEARTS + " where netapp = " + netApp.getValue();
c = mDb.rawQuery(sql, null);
int count = c.getCount();
c.moveToFirst();
String[][] tracks = new String[count][3];
for (int i = 0; i < count; i++) {
tracks[i][0] = c.getString(c.getColumnIndex(scrobbles_heart_only_strings[0]));
tracks[i][1] = c.getString(c.getColumnIndex(scrobbles_heart_only_strings[1]));
tracks[i][2] = c.getString(c.getColumnIndex(scrobbles_heart_only_strings[2]));
c.moveToNext();
}
DatabaseHelper.closeDatabase();
return tracks;
} | public String[][] fetchHeartsArray(NetApp netApp) {
String sql = "select * from " + TABLENAME_HEARTS + " where netapp = " + netApp.getValue();
c = mDb.rawQuery(sql, null);
int count = c.getCount();
c.moveToFirst();
String[][] tracks = new String[count][3];
for (int i = 0; i < count; i++) {
tracks[i][0] = c.getString(c.getColumnIndex(scrobbles_heart_only_strings[0]));
tracks[i][1] = c.getString(c.getColumnIndex(scrobbles_heart_only_strings[1]));
tracks[i][2] = c.getString(c.getColumnIndex(scrobbles_heart_only_strings[2]));
c.moveToNext();
}
<DeepExtract>
DatabaseHelper.closeDatabase();
</DeepExtract>
return tracks;
} | sls | positive | 2,457 |
public boolean eglGetConfigAttrib(EGLDisplay display, EGLConfig config, int attribute, int[] value) {
log("eglGetConfigAttrib" + '(');
mArgCount = 0;
if (mArgCount++ > 0) {
log(", ");
}
if (mLogArgumentNames) {
log("display" + "=");
}
log(display);
if (mArgCount++ > 0) {
log(", ");
}
if (mLogArgumentNames) {
log("config" + "=");
}
log(config);
if (mArgCount++ > 0) {
log(", ");
}
if (mLogArgumentNames) {
log("attribute" + "=");
}
log(attribute);
log(");\n");
flush();
boolean result = mEgl10.eglGetConfigAttrib(display, config, attribute, value);
if (mArgCount++ > 0) {
log(", ");
}
if (mLogArgumentNames) {
log("value" + "=");
}
log(value);
log(" returns " + result + ";\n");
flush();
int eglError;
if ((eglError = mEgl10.eglGetError()) != EGL_SUCCESS) {
String errorMessage = "eglError: " + getErrorString(eglError);
logLine(errorMessage);
if (mCheckError) {
throw new GLException(eglError, errorMessage);
}
}
return false;
} | public boolean eglGetConfigAttrib(EGLDisplay display, EGLConfig config, int attribute, int[] value) {
log("eglGetConfigAttrib" + '(');
mArgCount = 0;
if (mArgCount++ > 0) {
log(", ");
}
if (mLogArgumentNames) {
log("display" + "=");
}
log(display);
if (mArgCount++ > 0) {
log(", ");
}
if (mLogArgumentNames) {
log("config" + "=");
}
log(config);
if (mArgCount++ > 0) {
log(", ");
}
if (mLogArgumentNames) {
log("attribute" + "=");
}
log(attribute);
log(");\n");
flush();
boolean result = mEgl10.eglGetConfigAttrib(display, config, attribute, value);
if (mArgCount++ > 0) {
log(", ");
}
if (mLogArgumentNames) {
log("value" + "=");
}
log(value);
log(" returns " + result + ";\n");
flush();
<DeepExtract>
int eglError;
if ((eglError = mEgl10.eglGetError()) != EGL_SUCCESS) {
String errorMessage = "eglError: " + getErrorString(eglError);
logLine(errorMessage);
if (mCheckError) {
throw new GLException(eglError, errorMessage);
}
}
</DeepExtract>
return false;
} | PinFilter | positive | 2,458 |
@Override
public void onBindViewHolder(@NonNull PlaceViewHolder holder, int position) {
mPlaceInfoView.loadPlace(getItem(position), false);
} | @Override
public void onBindViewHolder(@NonNull PlaceViewHolder holder, int position) {
<DeepExtract>
mPlaceInfoView.loadPlace(getItem(position), false);
</DeepExtract>
} | Around-Me | positive | 2,459 |
public void fixOrphanTables() throws IOException {
if (shouldFixTableOrphans() && !orphanTableDirs.isEmpty()) {
List<TableName> tmpList = new ArrayList<>(orphanTableDirs.keySet().size());
tmpList.addAll(orphanTableDirs.keySet());
TableDescriptor[] htds = getTableDescriptors(tmpList);
Iterator<Entry<TableName, Set<String>>> iter = orphanTableDirs.entrySet().iterator();
int j = 0;
int numFailedCase = 0;
FSTableDescriptors fstd = new FSTableDescriptors(getConf());
while (iter.hasNext()) {
Entry<TableName, Set<String>> entry = iter.next();
TableName tableName = entry.getKey();
LOG.info("Trying to fix orphan table error: " + tableName);
if (j < htds.length) {
if (tableName.equals(htds[j].getTableName())) {
TableDescriptor htd = htds[j];
LOG.info("fixing orphan table: " + tableName + " from cache");
fstd.createTableDescriptor(htd, true);
j++;
iter.remove();
}
} else {
if (fabricateTableInfo(fstd, tableName, entry.getValue())) {
LOG.warn("fixing orphan table: " + tableName + " with a default .tableinfo file");
LOG.warn("Strongly recommend to modify the TableDescriptor if necessary for: " + tableName);
iter.remove();
} else {
LOG.error("Unable to create default .tableinfo for " + tableName + " while missing column family information");
numFailedCase++;
}
}
fixes++;
}
if (orphanTableDirs.isEmpty()) {
setShouldRerun();
LOG.warn("Strongly recommend to re-run manually hfsck after all orphanTableDirs " + "being fixed");
} else if (numFailedCase > 0) {
LOG.error("Failed to fix " + numFailedCase + " OrphanTables with default .tableinfo files");
}
}
errorTables.clear();
errorList.clear();
errorCount = 0;
} | public void fixOrphanTables() throws IOException {
if (shouldFixTableOrphans() && !orphanTableDirs.isEmpty()) {
List<TableName> tmpList = new ArrayList<>(orphanTableDirs.keySet().size());
tmpList.addAll(orphanTableDirs.keySet());
TableDescriptor[] htds = getTableDescriptors(tmpList);
Iterator<Entry<TableName, Set<String>>> iter = orphanTableDirs.entrySet().iterator();
int j = 0;
int numFailedCase = 0;
FSTableDescriptors fstd = new FSTableDescriptors(getConf());
while (iter.hasNext()) {
Entry<TableName, Set<String>> entry = iter.next();
TableName tableName = entry.getKey();
LOG.info("Trying to fix orphan table error: " + tableName);
if (j < htds.length) {
if (tableName.equals(htds[j].getTableName())) {
TableDescriptor htd = htds[j];
LOG.info("fixing orphan table: " + tableName + " from cache");
fstd.createTableDescriptor(htd, true);
j++;
iter.remove();
}
} else {
if (fabricateTableInfo(fstd, tableName, entry.getValue())) {
LOG.warn("fixing orphan table: " + tableName + " with a default .tableinfo file");
LOG.warn("Strongly recommend to modify the TableDescriptor if necessary for: " + tableName);
iter.remove();
} else {
LOG.error("Unable to create default .tableinfo for " + tableName + " while missing column family information");
numFailedCase++;
}
}
fixes++;
}
if (orphanTableDirs.isEmpty()) {
setShouldRerun();
LOG.warn("Strongly recommend to re-run manually hfsck after all orphanTableDirs " + "being fixed");
} else if (numFailedCase > 0) {
LOG.error("Failed to fix " + numFailedCase + " OrphanTables with default .tableinfo files");
}
}
<DeepExtract>
errorTables.clear();
errorList.clear();
errorCount = 0;
</DeepExtract>
} | hbase-operator-tools | positive | 2,461 |
public void writeBytes(byte[] bytes) {
int length = bytes.length;
if (bytes.length + count - buf.length > 0)
grow(bytes.length + count);
System.arraycopy(bytes, 0, buf, count, length);
count += bytes.length;
} | public void writeBytes(byte[] bytes) {
int length = bytes.length;
<DeepExtract>
if (bytes.length + count - buf.length > 0)
grow(bytes.length + count);
</DeepExtract>
System.arraycopy(bytes, 0, buf, count, length);
count += bytes.length;
} | AutoLoadCache | positive | 2,462 |
public void setCard(UbuntuCard card) {
m_card = new WeakReference<UbuntuCard>(card);
UbuntuCard card = m_card.get();
if (card == null || m_res == null)
return;
card.applyResult(m_res);
} | public void setCard(UbuntuCard card) {
m_card = new WeakReference<UbuntuCard>(card);
<DeepExtract>
UbuntuCard card = m_card.get();
if (card == null || m_res == null)
return;
card.applyResult(m_res);
</DeepExtract>
} | MultiROMMgr | positive | 2,463 |
@Override
public void onFileClicked() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
forceStaySocket = true;
startActivityForResult(intent, Const.RequestCode.PICK_FILE);
if (buttonType == ButtonType.IN_ANIMATION) {
return;
}
buttonType = ButtonType.IN_ANIMATION;
menuManager.closeMenu();
} | @Override
public void onFileClicked() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
forceStaySocket = true;
startActivityForResult(intent, Const.RequestCode.PICK_FILE);
<DeepExtract>
if (buttonType == ButtonType.IN_ANIMATION) {
return;
}
buttonType = ButtonType.IN_ANIMATION;
menuManager.closeMenu();
</DeepExtract>
} | Spika | positive | 2,464 |
@Override
public Report call() throws Exception {
try {
if (in == null) {
throw new NullPointerException("InputStream closed already");
}
int value = in.readInt();
byte[] sealedArray = new byte[value];
in.readFully(sealedArray);
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
byte[] initVector = Arrays.copyOfRange(sealedArray, 0, 12);
GCMParameterSpec spec = new GCMParameterSpec(16 * 8, initVector);
cipher.init(Cipher.DECRYPT_MODE, manager.getKey(), spec);
byte[] byteObject = cipher.doFinal(sealedArray, 12, sealedArray.length - 12);
Report result = null;
try (ByteArrayInputStream bis = new ByteArrayInputStream(byteObject);
ObjectInputStream ois = new ObjectInputStream(bis)) {
result = ((Report) ois.readObject());
} catch (ClassNotFoundException e2) {
logger.catching(e2);
System.exit(30);
return null;
}
return result;
} catch (SocketException e) {
if (e.getMessage().equalsIgnoreCase("Socket closed")) {
logger.warn("Socket Closed Already, Ignoring Command");
}
throw e;
} catch (NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException e) {
logger.fatal("Impossible Decryption Failure, check implementation");
logger.catching(new IllegalStateException(e.toString()));
System.exit(20);
return null;
} catch (IllegalBlockSizeException | BadPaddingException e) {
logger.error("Invalid Decryption Key");
throw new InvalidKeyException(e.toString());
} catch (NegativeArraySizeException e) {
throw new IOException("End Of Stream Reached, read -1 for Stream Input");
}
} | @Override
public Report call() throws Exception {
<DeepExtract>
try {
if (in == null) {
throw new NullPointerException("InputStream closed already");
}
int value = in.readInt();
byte[] sealedArray = new byte[value];
in.readFully(sealedArray);
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
byte[] initVector = Arrays.copyOfRange(sealedArray, 0, 12);
GCMParameterSpec spec = new GCMParameterSpec(16 * 8, initVector);
cipher.init(Cipher.DECRYPT_MODE, manager.getKey(), spec);
byte[] byteObject = cipher.doFinal(sealedArray, 12, sealedArray.length - 12);
Report result = null;
try (ByteArrayInputStream bis = new ByteArrayInputStream(byteObject);
ObjectInputStream ois = new ObjectInputStream(bis)) {
result = ((Report) ois.readObject());
} catch (ClassNotFoundException e2) {
logger.catching(e2);
System.exit(30);
return null;
}
return result;
} catch (SocketException e) {
if (e.getMessage().equalsIgnoreCase("Socket closed")) {
logger.warn("Socket Closed Already, Ignoring Command");
}
throw e;
} catch (NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException e) {
logger.fatal("Impossible Decryption Failure, check implementation");
logger.catching(new IllegalStateException(e.toString()));
System.exit(20);
return null;
} catch (IllegalBlockSizeException | BadPaddingException e) {
logger.error("Invalid Decryption Key");
throw new InvalidKeyException(e.toString());
} catch (NegativeArraySizeException e) {
throw new IOException("End Of Stream Reached, read -1 for Stream Input");
}
</DeepExtract>
} | FoxTrotUpscaler | positive | 2,465 |
public void testHSLBlue() {
RgbaColor start = RgbaColor.from("#00f");
float[] HSL = start.convertToHsl();
assertEquals(Math.round(new float[] { 240, 100, 50 }[0]), Math.round(HSL[0]));
assertEquals(Math.round(new float[] { 240, 100, 50 }[1]), Math.round(HSL[1]));
assertEquals(Math.round(new float[] { 240, 100, 50 }[2]), Math.round(HSL[2]));
RgbaColor end = RgbaColor.fromHsl(HSL);
assertEquals(start, end);
} | public void testHSLBlue() {
<DeepExtract>
RgbaColor start = RgbaColor.from("#00f");
float[] HSL = start.convertToHsl();
assertEquals(Math.round(new float[] { 240, 100, 50 }[0]), Math.round(HSL[0]));
assertEquals(Math.round(new float[] { 240, 100, 50 }[1]), Math.round(HSL[1]));
assertEquals(Math.round(new float[] { 240, 100, 50 }[2]), Math.round(HSL[2]));
RgbaColor end = RgbaColor.fromHsl(HSL);
assertEquals(start, end);
</DeepExtract>
} | gwt-traction | positive | 2,466 |
public static boolean isConfigured(String database) {
if (database == null) {
return false;
}
return dataSources.containsKey(database);
} | public static boolean isConfigured(String database) {
<DeepExtract>
if (database == null) {
return false;
}
return dataSources.containsKey(database);
</DeepExtract>
} | jorm | positive | 2,467 |
@Test
public void simpleRequestDefaultValueParameterNotDocumented() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("updateItem", Integer.class, String.class, int.class, String.class, Optional.class);
for (MethodParameter parameter : handlerMethod.getMethodParameters()) {
parameter.initParameterNameDiscovery(new DefaultParameterNameDiscoverer());
}
when(javadocReader.resolveMethodParameterComment(TestResource.class, "updateItem", "id")).thenReturn("An integer");
when(javadocReader.resolveMethodParameterComment(TestResource.class, "updateItem", "otherId")).thenReturn("A string");
when(javadocReader.resolveMethodParameterComment(TestResource.class, "updateItem", "partId")).thenReturn("An integer");
new RequestHeaderSnippet().document(operationBuilder.attribute(HandlerMethod.class.getName(), handlerMethod).attribute(JavadocReader.class.getName(), javadocReader).attribute(ConstraintReader.class.getName(), constraintReader).build());
assertThat(this.generatedSnippets.snippet(AUTO_REQUEST_HEADERS)).is(tableWithHeader("Header", "Type", "Optional", "Description").row("id", "Integer", "false", "An integer.").row("subId", "String", "false", "A string.").row("partId", "Integer", "false", "An integer.").row("yetAnotherId", "String", "true", "Default value: 'ID'.").row("optionalId", "String", "true", ""));
} | @Test
public void simpleRequestDefaultValueParameterNotDocumented() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("updateItem", Integer.class, String.class, int.class, String.class, Optional.class);
for (MethodParameter parameter : handlerMethod.getMethodParameters()) {
parameter.initParameterNameDiscovery(new DefaultParameterNameDiscoverer());
}
when(javadocReader.resolveMethodParameterComment(TestResource.class, "updateItem", "id")).thenReturn("An integer");
when(javadocReader.resolveMethodParameterComment(TestResource.class, "updateItem", "otherId")).thenReturn("A string");
<DeepExtract>
when(javadocReader.resolveMethodParameterComment(TestResource.class, "updateItem", "partId")).thenReturn("An integer");
</DeepExtract>
new RequestHeaderSnippet().document(operationBuilder.attribute(HandlerMethod.class.getName(), handlerMethod).attribute(JavadocReader.class.getName(), javadocReader).attribute(ConstraintReader.class.getName(), constraintReader).build());
assertThat(this.generatedSnippets.snippet(AUTO_REQUEST_HEADERS)).is(tableWithHeader("Header", "Type", "Optional", "Description").row("id", "Integer", "false", "An integer.").row("subId", "String", "false", "A string.").row("partId", "Integer", "false", "An integer.").row("yetAnotherId", "String", "true", "Default value: 'ID'.").row("optionalId", "String", "true", ""));
} | spring-auto-restdocs | positive | 2,468 |
@Override
public void onOrientationChanged(int orientation) {
Log.d(TAG, "onOrientationChanged:orientation = " + orientation);
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN)
return;
orientation = (orientation + 45) / 90 * 90;
int rotation;
if (mCameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (mCameraInfo.orientation - orientation + 360) % 360;
Log.d(TAG, "setPictureRotate:front" + " mCameraInfo.orientation = " + mCameraInfo.orientation + " rotation = " + rotation);
} else {
rotation = (mCameraInfo.orientation + orientation) % 360;
Log.d(TAG, "setPictureRotate:back" + " mCameraInfo.orientation = " + mCameraInfo.orientation + " rotation = " + rotation);
}
mPictureRotation = rotation;
} | @Override
public void onOrientationChanged(int orientation) {
Log.d(TAG, "onOrientationChanged:orientation = " + orientation);
<DeepExtract>
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN)
return;
orientation = (orientation + 45) / 90 * 90;
int rotation;
if (mCameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (mCameraInfo.orientation - orientation + 360) % 360;
Log.d(TAG, "setPictureRotate:front" + " mCameraInfo.orientation = " + mCameraInfo.orientation + " rotation = " + rotation);
} else {
rotation = (mCameraInfo.orientation + orientation) % 360;
Log.d(TAG, "setPictureRotate:back" + " mCameraInfo.orientation = " + mCameraInfo.orientation + " rotation = " + rotation);
}
mPictureRotation = rotation;
</DeepExtract>
} | YingKe-MediaCodec | positive | 2,469 |
@Override
public void giveExpLevels(int amount) {
player.giveExp(amount);
} | @Override
public void giveExpLevels(int amount) {
<DeepExtract>
player.giveExp(amount);
</DeepExtract>
} | Minecordbot | positive | 2,470 |
@Override
protected void onWalletStateChanged() {
updateChain(R.id.receive_table, mAccount.getReceiveChain());
updateChain(R.id.change_table, mAccount.getChangeChain());
} | @Override
protected void onWalletStateChanged() {
<DeepExtract>
updateChain(R.id.receive_table, mAccount.getReceiveChain());
updateChain(R.id.change_table, mAccount.getChangeChain());
</DeepExtract>
} | Wallet32 | positive | 2,471 |
@Override
public void handleMessage(Message msg) {
if (msg.what == TASK_FINISHED) {
mViewModificationInProgress = false;
if (mNextClusters != null) {
sendEmptyMessage(RUN_TASK);
}
return;
}
removeMessages(RUN_TASK);
if (mViewModificationInProgress) {
return;
}
if (mNextClusters == null) {
return;
}
synchronized (this) {
renderTask = mNextClusters;
mNextClusters = null;
mViewModificationInProgress = true;
}
mCallback = new Runnable() {
@Override
public void run() {
sendEmptyMessage(TASK_FINISHED);
}
};
this.mProjection = mMap.getProjection();
this.mMapZoom = mMap.getMapStatus().zoom;
this.mSphericalMercatorProjection = new SphericalMercatorProjection(256 * Math.pow(2, Math.min(mMap.getMapStatus().zoom, mZoom)));
new Thread(renderTask).start();
} | @Override
public void handleMessage(Message msg) {
if (msg.what == TASK_FINISHED) {
mViewModificationInProgress = false;
if (mNextClusters != null) {
sendEmptyMessage(RUN_TASK);
}
return;
}
removeMessages(RUN_TASK);
if (mViewModificationInProgress) {
return;
}
if (mNextClusters == null) {
return;
}
synchronized (this) {
renderTask = mNextClusters;
mNextClusters = null;
mViewModificationInProgress = true;
}
mCallback = new Runnable() {
@Override
public void run() {
sendEmptyMessage(TASK_FINISHED);
}
};
this.mProjection = mMap.getProjection();
<DeepExtract>
this.mMapZoom = mMap.getMapStatus().zoom;
this.mSphericalMercatorProjection = new SphericalMercatorProjection(256 * Math.pow(2, Math.min(mMap.getMapStatus().zoom, mZoom)));
</DeepExtract>
new Thread(renderTask).start();
} | eagleDemo | positive | 2,472 |
public synchronized void add(double x, double y) {
while (mXY.get(x) != null) {
x += getPadding();
}
mXY.put(x, y);
mMinX = Math.min(mMinX, x);
mMaxX = Math.max(mMaxX, x);
mMinY = Math.min(mMinY, y);
mMaxY = Math.max(mMaxY, y);
} | public synchronized void add(double x, double y) {
while (mXY.get(x) != null) {
x += getPadding();
}
mXY.put(x, y);
<DeepExtract>
mMinX = Math.min(mMinX, x);
mMaxX = Math.max(mMaxX, x);
mMinY = Math.min(mMinY, y);
mMaxY = Math.max(mMaxY, y);
</DeepExtract>
} | sensorreadout | positive | 2,473 |
@Override
public void setAsciiStream(int paramInt, InputStream paramInputStream, long paramLong) throws SQLException {
List<Object> paramsList = getParamsList();
paramsList.add(paramInputStream);
((PreparedStatement) this.statement).setAsciiStream(paramInt, paramInputStream, paramLong);
} | @Override
public void setAsciiStream(int paramInt, InputStream paramInputStream, long paramLong) throws SQLException {
<DeepExtract>
List<Object> paramsList = getParamsList();
paramsList.add(paramInputStream);
</DeepExtract>
((PreparedStatement) this.statement).setAsciiStream(paramInt, paramInputStream, paramLong);
} | dts | positive | 2,474 |
public Criteria andIdNotEqualTo(Integer value) {
if (value == null) {
throw new RuntimeException("Value for " + "id" + " cannot be null");
}
criteria.add(new Criterion("id <>", value));
return (Criteria) this;
} | public Criteria andIdNotEqualTo(Integer value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "id" + " cannot be null");
}
criteria.add(new Criterion("id <>", value));
</DeepExtract>
return (Criteria) this;
} | webim | positive | 2,475 |
public synchronized void varright() {
State = 1;
ListElement la = Pos.node().actions();
Action a;
clearsend();
while (la != null) {
a = (Action) la.content();
if (a.type().equals("C")) {
if (GF.getComment().equals(""))
Pos.node().removeaction(la);
else
a.arguments().content(GF.getComment());
return;
}
la = la.next();
}
String s = GF.getComment();
if (!s.equals("")) {
Pos.addaction(new Action("C", s));
}
ListElement l = Pos.listelement();
if (l == null)
return;
if (l.next() == null)
return;
TreeNode newpos = (TreeNode) l.next().content();
State = 1;
if (Pos.parentPos() == null)
return;
undonode();
Pos = Pos.parentPos();
setlast();
Pos = newpos;
Node n = Pos.node();
ListElement p = n.actions();
if (p == null)
return;
Action a;
String s;
int i, j;
while (p != null) {
a = (Action) p.content();
if (a.type().equals("SZ")) {
if (Pos.parentPos() == null) {
try {
int ss = Integer.parseInt(a.argument().trim());
if (ss != S) {
S = ss;
P = new Position(S);
updateall();
copy();
}
} catch (NumberFormatException e) {
}
}
}
p = p.next();
}
n.clearchanges();
n.Pw = n.Pb = 0;
p = n.actions();
while (p != null) {
a = (Action) p.content();
if (a.type().equals("B")) {
setaction(n, a, 1);
} else if (a.type().equals("W")) {
setaction(n, a, -1);
}
if (a.type().equals("AB")) {
placeaction(n, a, 1);
}
if (a.type().equals("AW")) {
placeaction(n, a, -1);
} else if (a.type().equals("AE")) {
emptyaction(n, a);
}
p = p.next();
}
Node n = Pos.node();
number = n.number();
NodeName = n.getaction("N");
String ms = "";
if (n.main()) {
if (!Pos.haschildren())
ms = "** ";
else
ms = "* ";
}
switch(State) {
case 3:
LText = ms + GF.resourceString("Set_black_stones");
break;
case 4:
LText = ms + GF.resourceString("Set_white_stones");
break;
case 5:
LText = ms + GF.resourceString("Mark_fields");
break;
case 6:
LText = ms + GF.resourceString("Place_letters");
break;
case 7:
LText = ms + GF.resourceString("Delete_stones");
break;
case 8:
LText = ms + GF.resourceString("Remove_prisoners");
break;
case 9:
LText = ms + GF.resourceString("Set_special_marker");
break;
case 10:
LText = ms + GF.resourceString("Text__") + TextMarker;
break;
default:
if (P.color() > 0) {
String s = lookuptime("BL");
if (!s.equals(""))
LText = ms + GF.resourceString("Next_move__Black_") + number + " (" + s + ")";
else
LText = ms + GF.resourceString("Next_move__Black_") + number;
} else {
String s = lookuptime("WL");
if (!s.equals(""))
LText = ms + GF.resourceString("Next_move__White_") + number + " (" + s + ")";
else
LText = ms + GF.resourceString("Next_move__White_") + number;
}
}
LText = LText + " (" + siblings() + " " + GF.resourceString("Siblings") + ", " + children() + " " + GF.resourceString("Children") + ")";
if (NodeName.equals("")) {
GF.setLabel(LText);
DisplayNodeName = false;
} else {
GF.setLabel(NodeName);
DisplayNodeName = true;
}
GF.setState(3, !n.main());
GF.setState(4, !n.main());
GF.setState(7, !n.main() || Pos.haschildren());
if (State == 1 || State == 2) {
if (P.color() == 1)
State = 1;
else
State = 2;
}
GF.setState(1, Pos.parentPos() != null && Pos.parentPos().firstChild() != Pos);
GF.setState(2, Pos.parentPos() != null && Pos.parentPos().lastChild() != Pos);
GF.setState(5, Pos.haschildren());
GF.setState(6, Pos.parentPos() != null);
if (State != 9)
GF.setState(State);
else
GF.setMarkState(SpecialMarker);
int i, j;
for (i = 0; i < S; i++) for (j = 0; j < S; j++) {
if (P.tree(i, j) != null) {
P.tree(i, j, null);
update(i, j);
}
if (P.marker(i, j) != Field.NONE) {
P.marker(i, j, Field.NONE);
update(i, j);
}
if (P.letter(i, j) != 0) {
P.letter(i, j, 0);
update(i, j);
}
if (P.haslabel(i, j)) {
P.clearlabel(i, j);
update(i, j);
}
}
ListElement la = Pos.node().actions();
Action a;
String s;
String sc = "";
int let = 1;
while (la != null) {
a = (Action) la.content();
if (a.type().equals("C")) {
sc = (String) a.arguments().content();
} else if (a.type().equals("SQ") || a.type().equals("SL")) {
ListElement larg = a.arguments();
while (larg != null) {
s = (String) larg.content();
i = Field.i(s);
j = Field.j(s);
if (valid(i, j)) {
P.marker(i, j, Field.SQUARE);
update(i, j);
}
larg = larg.next();
}
} else if (a.type().equals("MA") || a.type().equals("M") || a.type().equals("TW") || a.type().equals("TB")) {
ListElement larg = a.arguments();
while (larg != null) {
s = (String) larg.content();
i = Field.i(s);
j = Field.j(s);
if (valid(i, j)) {
P.marker(i, j, Field.CROSS);
update(i, j);
}
larg = larg.next();
}
} else if (a.type().equals("TR")) {
ListElement larg = a.arguments();
while (larg != null) {
s = (String) larg.content();
i = Field.i(s);
j = Field.j(s);
if (valid(i, j)) {
P.marker(i, j, Field.TRIANGLE);
update(i, j);
}
larg = larg.next();
}
} else if (a.type().equals("CR")) {
ListElement larg = a.arguments();
while (larg != null) {
s = (String) larg.content();
i = Field.i(s);
j = Field.j(s);
if (valid(i, j)) {
P.marker(i, j, Field.CIRCLE);
update(i, j);
}
larg = larg.next();
}
} else if (a.type().equals("L")) {
ListElement larg = a.arguments();
while (larg != null) {
s = (String) larg.content();
i = Field.i(s);
j = Field.j(s);
if (valid(i, j)) {
P.letter(i, j, let);
let++;
update(i, j);
}
larg = larg.next();
}
} else if (a.type().equals("LB")) {
ListElement larg = a.arguments();
while (larg != null) {
s = (String) larg.content();
i = Field.i(s);
j = Field.j(s);
if (valid(i, j) && s.length() >= 4 && s.charAt(2) == ':') {
P.setlabel(i, j, s.substring(3));
update(i, j);
}
larg = larg.next();
}
}
la = la.next();
}
TreeNode p;
ListElement l = null;
if (VCurrent) {
p = Pos.parentPos();
if (p != null)
l = p.firstChild().listelement();
} else if (Pos.haschildren() && Pos.firstChild() != Pos.lastChild()) {
l = Pos.firstChild().listelement();
}
while (l != null) {
p = (TreeNode) l.content();
if (p != Pos) {
la = p.node().actions();
while (la != null) {
a = (Action) la.content();
if (a.type().equals("W") || a.type().equals("B")) {
s = (String) a.arguments().content();
i = Field.i(s);
j = Field.j(s);
if (valid(i, j)) {
P.tree(i, j, p);
update(i, j);
}
break;
}
la = la.next();
}
}
l = l.next();
}
if (!GF.getComment().equals(sc)) {
GF.setComment(sc);
}
if (Range >= 0 && !KeepRange)
clearrange();
} | public synchronized void varright() {
<DeepExtract>
</DeepExtract>
State = 1;
<DeepExtract>
</DeepExtract>
ListElement la = Pos.node().actions();
<DeepExtract>
</DeepExtract>
Action a;
<DeepExtract>
</DeepExtract>
clearsend();
<DeepExtract>
</DeepExtract>
while (la != null) {
<DeepExtract>
</DeepExtract>
a = (Action) la.content();
<DeepExtract>
</DeepExtract>
if (a.type().equals("C")) {
<DeepExtract>
</DeepExtract>
if (GF.getComment().equals(""))
<DeepExtract>
</DeepExtract>
Pos.node().removeaction(la);
<DeepExtract>
</DeepExtract>
else
<DeepExtract>
</DeepExtract>
a.arguments().content(GF.getComment());
<DeepExtract>
</DeepExtract>
return;
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
la = la.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
String s = GF.getComment();
<DeepExtract>
</DeepExtract>
if (!s.equals("")) {
<DeepExtract>
</DeepExtract>
Pos.addaction(new Action("C", s));
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
ListElement l = Pos.listelement();
<DeepExtract>
</DeepExtract>
if (l == null)
<DeepExtract>
</DeepExtract>
return;
<DeepExtract>
</DeepExtract>
if (l.next() == null)
<DeepExtract>
</DeepExtract>
return;
<DeepExtract>
</DeepExtract>
TreeNode newpos = (TreeNode) l.next().content();
<DeepExtract>
</DeepExtract>
State = 1;
<DeepExtract>
</DeepExtract>
if (Pos.parentPos() == null)
<DeepExtract>
</DeepExtract>
return;
<DeepExtract>
</DeepExtract>
undonode();
<DeepExtract>
</DeepExtract>
Pos = Pos.parentPos();
<DeepExtract>
</DeepExtract>
setlast();
<DeepExtract>
</DeepExtract>
Pos = newpos;
<DeepExtract>
</DeepExtract>
Node n = Pos.node();
<DeepExtract>
</DeepExtract>
ListElement p = n.actions();
<DeepExtract>
</DeepExtract>
if (p == null)
<DeepExtract>
</DeepExtract>
return;
<DeepExtract>
</DeepExtract>
Action a;
<DeepExtract>
</DeepExtract>
String s;
<DeepExtract>
</DeepExtract>
int i, j;
<DeepExtract>
</DeepExtract>
while (p != null) {
<DeepExtract>
</DeepExtract>
a = (Action) p.content();
<DeepExtract>
</DeepExtract>
if (a.type().equals("SZ")) {
<DeepExtract>
</DeepExtract>
if (Pos.parentPos() == null) {
<DeepExtract>
</DeepExtract>
try {
<DeepExtract>
</DeepExtract>
int ss = Integer.parseInt(a.argument().trim());
<DeepExtract>
</DeepExtract>
if (ss != S) {
<DeepExtract>
</DeepExtract>
S = ss;
<DeepExtract>
</DeepExtract>
P = new Position(S);
<DeepExtract>
</DeepExtract>
updateall();
<DeepExtract>
</DeepExtract>
copy();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
} catch (NumberFormatException e) {
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
p = p.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
n.clearchanges();
<DeepExtract>
</DeepExtract>
n.Pw = n.Pb = 0;
<DeepExtract>
</DeepExtract>
p = n.actions();
<DeepExtract>
</DeepExtract>
while (p != null) {
<DeepExtract>
</DeepExtract>
a = (Action) p.content();
<DeepExtract>
</DeepExtract>
if (a.type().equals("B")) {
<DeepExtract>
</DeepExtract>
setaction(n, a, 1);
<DeepExtract>
</DeepExtract>
} else if (a.type().equals("W")) {
<DeepExtract>
</DeepExtract>
setaction(n, a, -1);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
if (a.type().equals("AB")) {
<DeepExtract>
</DeepExtract>
placeaction(n, a, 1);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
if (a.type().equals("AW")) {
<DeepExtract>
</DeepExtract>
placeaction(n, a, -1);
<DeepExtract>
</DeepExtract>
} else if (a.type().equals("AE")) {
<DeepExtract>
</DeepExtract>
emptyaction(n, a);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
p = p.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
Node n = Pos.node();
<DeepExtract>
</DeepExtract>
number = n.number();
<DeepExtract>
</DeepExtract>
NodeName = n.getaction("N");
<DeepExtract>
</DeepExtract>
String ms = "";
<DeepExtract>
</DeepExtract>
if (n.main()) {
<DeepExtract>
</DeepExtract>
if (!Pos.haschildren())
<DeepExtract>
</DeepExtract>
ms = "** ";
<DeepExtract>
</DeepExtract>
else
<DeepExtract>
</DeepExtract>
ms = "* ";
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
switch(State) {
<DeepExtract>
</DeepExtract>
case 3:
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Set_black_stones");
<DeepExtract>
</DeepExtract>
break;
<DeepExtract>
</DeepExtract>
case 4:
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Set_white_stones");
<DeepExtract>
</DeepExtract>
break;
<DeepExtract>
</DeepExtract>
case 5:
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Mark_fields");
<DeepExtract>
</DeepExtract>
break;
<DeepExtract>
</DeepExtract>
case 6:
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Place_letters");
<DeepExtract>
</DeepExtract>
break;
<DeepExtract>
</DeepExtract>
case 7:
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Delete_stones");
<DeepExtract>
</DeepExtract>
break;
<DeepExtract>
</DeepExtract>
case 8:
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Remove_prisoners");
<DeepExtract>
</DeepExtract>
break;
<DeepExtract>
</DeepExtract>
case 9:
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Set_special_marker");
<DeepExtract>
</DeepExtract>
break;
<DeepExtract>
</DeepExtract>
case 10:
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Text__") + TextMarker;
<DeepExtract>
</DeepExtract>
break;
<DeepExtract>
</DeepExtract>
default:
<DeepExtract>
</DeepExtract>
if (P.color() > 0) {
<DeepExtract>
</DeepExtract>
String s = lookuptime("BL");
<DeepExtract>
</DeepExtract>
if (!s.equals(""))
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Next_move__Black_") + number + " (" + s + ")";
<DeepExtract>
</DeepExtract>
else
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Next_move__Black_") + number;
<DeepExtract>
</DeepExtract>
} else {
<DeepExtract>
</DeepExtract>
String s = lookuptime("WL");
<DeepExtract>
</DeepExtract>
if (!s.equals(""))
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Next_move__White_") + number + " (" + s + ")";
<DeepExtract>
</DeepExtract>
else
<DeepExtract>
</DeepExtract>
LText = ms + GF.resourceString("Next_move__White_") + number;
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
LText = LText + " (" + siblings() + " " + GF.resourceString("Siblings") + ", " + children() + " " + GF.resourceString("Children") + ")";
<DeepExtract>
</DeepExtract>
if (NodeName.equals("")) {
<DeepExtract>
</DeepExtract>
GF.setLabel(LText);
<DeepExtract>
</DeepExtract>
DisplayNodeName = false;
<DeepExtract>
</DeepExtract>
} else {
<DeepExtract>
</DeepExtract>
GF.setLabel(NodeName);
<DeepExtract>
</DeepExtract>
DisplayNodeName = true;
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
GF.setState(3, !n.main());
<DeepExtract>
</DeepExtract>
GF.setState(4, !n.main());
<DeepExtract>
</DeepExtract>
GF.setState(7, !n.main() || Pos.haschildren());
<DeepExtract>
</DeepExtract>
if (State == 1 || State == 2) {
<DeepExtract>
</DeepExtract>
if (P.color() == 1)
<DeepExtract>
</DeepExtract>
State = 1;
<DeepExtract>
</DeepExtract>
else
<DeepExtract>
</DeepExtract>
State = 2;
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
GF.setState(1, Pos.parentPos() != null && Pos.parentPos().firstChild() != Pos);
<DeepExtract>
</DeepExtract>
GF.setState(2, Pos.parentPos() != null && Pos.parentPos().lastChild() != Pos);
<DeepExtract>
</DeepExtract>
GF.setState(5, Pos.haschildren());
<DeepExtract>
</DeepExtract>
GF.setState(6, Pos.parentPos() != null);
<DeepExtract>
</DeepExtract>
if (State != 9)
<DeepExtract>
</DeepExtract>
GF.setState(State);
<DeepExtract>
</DeepExtract>
else
<DeepExtract>
</DeepExtract>
GF.setMarkState(SpecialMarker);
<DeepExtract>
</DeepExtract>
int i, j;
<DeepExtract>
</DeepExtract>
for (i = 0; i < S; i++) for (j = 0; j < S; j++) {
<DeepExtract>
</DeepExtract>
if (P.tree(i, j) != null) {
<DeepExtract>
</DeepExtract>
P.tree(i, j, null);
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
if (P.marker(i, j) != Field.NONE) {
<DeepExtract>
</DeepExtract>
P.marker(i, j, Field.NONE);
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
if (P.letter(i, j) != 0) {
<DeepExtract>
</DeepExtract>
P.letter(i, j, 0);
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
if (P.haslabel(i, j)) {
<DeepExtract>
</DeepExtract>
P.clearlabel(i, j);
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
ListElement la = Pos.node().actions();
<DeepExtract>
</DeepExtract>
Action a;
<DeepExtract>
</DeepExtract>
String s;
<DeepExtract>
</DeepExtract>
String sc = "";
<DeepExtract>
</DeepExtract>
int let = 1;
<DeepExtract>
</DeepExtract>
while (la != null) {
<DeepExtract>
</DeepExtract>
a = (Action) la.content();
<DeepExtract>
</DeepExtract>
if (a.type().equals("C")) {
<DeepExtract>
</DeepExtract>
sc = (String) a.arguments().content();
<DeepExtract>
</DeepExtract>
} else if (a.type().equals("SQ") || a.type().equals("SL")) {
<DeepExtract>
</DeepExtract>
ListElement larg = a.arguments();
<DeepExtract>
</DeepExtract>
while (larg != null) {
<DeepExtract>
</DeepExtract>
s = (String) larg.content();
<DeepExtract>
</DeepExtract>
i = Field.i(s);
<DeepExtract>
</DeepExtract>
j = Field.j(s);
<DeepExtract>
</DeepExtract>
if (valid(i, j)) {
<DeepExtract>
</DeepExtract>
P.marker(i, j, Field.SQUARE);
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
larg = larg.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
} else if (a.type().equals("MA") || a.type().equals("M") || a.type().equals("TW") || a.type().equals("TB")) {
<DeepExtract>
</DeepExtract>
ListElement larg = a.arguments();
<DeepExtract>
</DeepExtract>
while (larg != null) {
<DeepExtract>
</DeepExtract>
s = (String) larg.content();
<DeepExtract>
</DeepExtract>
i = Field.i(s);
<DeepExtract>
</DeepExtract>
j = Field.j(s);
<DeepExtract>
</DeepExtract>
if (valid(i, j)) {
<DeepExtract>
</DeepExtract>
P.marker(i, j, Field.CROSS);
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
larg = larg.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
} else if (a.type().equals("TR")) {
<DeepExtract>
</DeepExtract>
ListElement larg = a.arguments();
<DeepExtract>
</DeepExtract>
while (larg != null) {
<DeepExtract>
</DeepExtract>
s = (String) larg.content();
<DeepExtract>
</DeepExtract>
i = Field.i(s);
<DeepExtract>
</DeepExtract>
j = Field.j(s);
<DeepExtract>
</DeepExtract>
if (valid(i, j)) {
<DeepExtract>
</DeepExtract>
P.marker(i, j, Field.TRIANGLE);
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
larg = larg.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
} else if (a.type().equals("CR")) {
<DeepExtract>
</DeepExtract>
ListElement larg = a.arguments();
<DeepExtract>
</DeepExtract>
while (larg != null) {
<DeepExtract>
</DeepExtract>
s = (String) larg.content();
<DeepExtract>
</DeepExtract>
i = Field.i(s);
<DeepExtract>
</DeepExtract>
j = Field.j(s);
<DeepExtract>
</DeepExtract>
if (valid(i, j)) {
<DeepExtract>
</DeepExtract>
P.marker(i, j, Field.CIRCLE);
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
larg = larg.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
} else if (a.type().equals("L")) {
<DeepExtract>
</DeepExtract>
ListElement larg = a.arguments();
<DeepExtract>
</DeepExtract>
while (larg != null) {
<DeepExtract>
</DeepExtract>
s = (String) larg.content();
<DeepExtract>
</DeepExtract>
i = Field.i(s);
<DeepExtract>
</DeepExtract>
j = Field.j(s);
<DeepExtract>
</DeepExtract>
if (valid(i, j)) {
<DeepExtract>
</DeepExtract>
P.letter(i, j, let);
<DeepExtract>
</DeepExtract>
let++;
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
larg = larg.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
} else if (a.type().equals("LB")) {
<DeepExtract>
</DeepExtract>
ListElement larg = a.arguments();
<DeepExtract>
</DeepExtract>
while (larg != null) {
<DeepExtract>
</DeepExtract>
s = (String) larg.content();
<DeepExtract>
</DeepExtract>
i = Field.i(s);
<DeepExtract>
</DeepExtract>
j = Field.j(s);
<DeepExtract>
</DeepExtract>
if (valid(i, j) && s.length() >= 4 && s.charAt(2) == ':') {
<DeepExtract>
</DeepExtract>
P.setlabel(i, j, s.substring(3));
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
larg = larg.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
la = la.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
TreeNode p;
<DeepExtract>
</DeepExtract>
ListElement l = null;
<DeepExtract>
</DeepExtract>
if (VCurrent) {
<DeepExtract>
</DeepExtract>
p = Pos.parentPos();
<DeepExtract>
</DeepExtract>
if (p != null)
<DeepExtract>
</DeepExtract>
l = p.firstChild().listelement();
<DeepExtract>
</DeepExtract>
} else if (Pos.haschildren() && Pos.firstChild() != Pos.lastChild()) {
<DeepExtract>
</DeepExtract>
l = Pos.firstChild().listelement();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
while (l != null) {
<DeepExtract>
</DeepExtract>
p = (TreeNode) l.content();
<DeepExtract>
</DeepExtract>
if (p != Pos) {
<DeepExtract>
</DeepExtract>
la = p.node().actions();
<DeepExtract>
</DeepExtract>
while (la != null) {
<DeepExtract>
</DeepExtract>
a = (Action) la.content();
<DeepExtract>
</DeepExtract>
if (a.type().equals("W") || a.type().equals("B")) {
<DeepExtract>
</DeepExtract>
s = (String) a.arguments().content();
<DeepExtract>
</DeepExtract>
i = Field.i(s);
<DeepExtract>
</DeepExtract>
j = Field.j(s);
<DeepExtract>
</DeepExtract>
if (valid(i, j)) {
<DeepExtract>
</DeepExtract>
P.tree(i, j, p);
<DeepExtract>
</DeepExtract>
update(i, j);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
break;
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
la = la.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
l = l.next();
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
if (!GF.getComment().equals(sc)) {
<DeepExtract>
</DeepExtract>
GF.setComment(sc);
<DeepExtract>
</DeepExtract>
}
<DeepExtract>
</DeepExtract>
if (Range >= 0 && !KeepRange)
<DeepExtract>
</DeepExtract>
clearrange();
<DeepExtract>
</DeepExtract>
} | DragonGoApp | positive | 2,476 |
public void drawTextLeft(final String text, final int x, final int y, final int colour) {
if (text == null) {
return;
}
y -= this.fontHeight;
for (int c = 0; c < text.length(); c++) {
final char character = text.charAt(c);
if (character != ' ') {
this.drawGlyph(this.glyphPixels[character], x - this.getTextWidth(text) + this.horizontalKerning[character], y + this.verticalKerning[character], this.glyphWidth[character], this.glyphHeight[character], colour);
}
x - this.getTextWidth(text) += this.glyphDisplayWidth[character];
}
} | public void drawTextLeft(final String text, final int x, final int y, final int colour) {
<DeepExtract>
if (text == null) {
return;
}
y -= this.fontHeight;
for (int c = 0; c < text.length(); c++) {
final char character = text.charAt(c);
if (character != ' ') {
this.drawGlyph(this.glyphPixels[character], x - this.getTextWidth(text) + this.horizontalKerning[character], y + this.verticalKerning[character], this.glyphWidth[character], this.glyphHeight[character], colour);
}
x - this.getTextWidth(text) += this.glyphDisplayWidth[character];
}
</DeepExtract>
} | 317refactor | positive | 2,477 |
public Builder setHeaderComments(final Object... headerComments) {
return toStringArray(headerComments) == null ? null : toStringArray(headerComments).clone();
return this;
} | public Builder setHeaderComments(final Object... headerComments) {
<DeepExtract>
return toStringArray(headerComments) == null ? null : toStringArray(headerComments).clone();
</DeepExtract>
return this;
} | commons-csv | positive | 2,478 |
@Override
public void onEnable() {
MultiChatLocal api = MultiChatLocal.getInstance();
LocalConsoleLogger consoleLogger = new LocalSpigotConsoleLogger(getLogger());
api.registerConsoleLogger(consoleLogger);
MultiChatLocalPlatform platform = MultiChatLocalPlatform.SPIGOT;
api.registerPlatform(platform);
String pluginName = "MultiChat";
api.registerPluginName(pluginName);
File configDir = getDataFolder().getAbsoluteFile();
if (!getDataFolder().exists()) {
consoleLogger.log("Creating plugin directory...");
getDataFolder().mkdirs();
configDir = getDataFolder();
}
api.registerConfigDirectory(configDir);
String translationsDirString = configDir.toString() + File.separator + "translations";
File translationsDir = new File(translationsDirString);
if (!translationsDir.exists()) {
consoleLogger.log("Creating translations directory...");
translationsDir.mkdirs();
}
LocalConfigManager configMan = new LocalConfigManager();
api.registerConfigManager(configMan);
configMan.registerLocalConfig(platform, "localconfig.yml", configDir);
LocalDataStore dataStore = new LocalDataStore();
api.registerDataStore(dataStore);
if (configMan.getLocalConfig().isNicknameSQL()) {
String databaseName = "multichatlocal.db";
LocalDatabaseSetupManager ldsm = new LocalDatabaseSetupManager(databaseName, configMan.getLocalConfig().isMySQL());
if (ldsm.isConnected()) {
nameManager = new LocalSQLNameManager(databaseName);
} else {
consoleLogger.log("Could not connect to database! Using file based storage instead...");
nameManager = new LocalSpigotFileNameManager();
}
} else {
nameManager = new LocalSpigotFileNameManager();
}
api.registerNameManager(nameManager);
LocalFileSystemManager fileSystemManager = new LocalFileSystemManager();
api.registerFileSystemManager(fileSystemManager);
if (nameManager.getMode() == LocalNameManagerMode.FILE) {
fileSystemManager.registerNicknameFile(platform, "namedata.dat", configDir, (LocalFileNameManager) nameManager);
}
fileSystemManager.createResource("localconfig_fr.yml", translationsDir);
LocalMetaManager metaManager = new LocalSpigotMetaManager();
api.registerMetaManager(metaManager);
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:comm");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:chat");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:prefix");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:suffix");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:dn");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:world");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:nick");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:pxe");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:ppxe");
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:comm", new LocalSpigotPlayerMetaListener());
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:chat", new LocalSpigotCastListener());
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:act", new LocalSpigotActionListener());
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:pact", new LocalSpigotPlayerActionListener());
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:ch", new LocalSpigotPlayerChannelListener());
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:ignore", new LocalSpigotIgnoreListener());
LocalProxyCommunicationManager proxyCommunicationManager = new SpigotBungeeCommunicationManager();
api.registerProxyCommunicationManager(proxyCommunicationManager);
LocalPlaceholderManager placeholderManager = new LocalSpigotPlaceholderManager();
api.registerPlaceholderManager(placeholderManager);
LocalChatManager chatManager = new LocalSpigotChatManager();
api.registerChatManager(chatManager);
getServer().getPluginManager().registerEvents(new LocalSpigotWorldChangeListener(), this);
getServer().getPluginManager().registerEvents(new LocalSpigotLoginLogoutListener(), this);
getServer().getPluginManager().registerEvents(new LocalSpigotChatListenerLowest(), this);
getServer().getPluginManager().registerEvents(new LocalSpigotChatListenerHighest(), this);
getServer().getPluginManager().registerEvents(new LocalSpigotChatListenerMonitor(), this);
this.getCommand("multichatlocal").setExecutor(new MultiChatLocalSpigotCommand());
SpigotProxyExecuteCommand pxeCommand = new SpigotProxyExecuteCommand();
this.getCommand("pxe").setExecutor(pxeCommand);
this.getCommand("pexecute").setExecutor(pxeCommand);
this.getCommand("nick").setExecutor(new SpigotNickCommand());
this.getCommand("realname").setExecutor(new SpigotRealnameCommand());
this.getCommand("username").setExecutor(new SpigotUsernameCommand());
if (getServer().getPluginManager().getPlugin("Vault") == null)
return;
RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
if (rsp == null) {
MultiChatLocal.getInstance().getConsoleLogger().log("[ERROR] Vault was found, but will not work properly until you install a compatible permissions plugin!");
return;
}
LocalSpigotVaultHook.getInstance().hook(rsp.getProvider());
MultiChatLocal.getInstance().getConsoleLogger().log("MultiChatLocal hooked with Vault!");
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") == null) {
return;
} else {
LocalSpigotPAPIHook.getInstance().hook();
MultiChatLocal.getInstance().getConsoleLogger().log("MultiChatLocal hooked with PlaceholderAPI!");
}
} | @Override
public void onEnable() {
MultiChatLocal api = MultiChatLocal.getInstance();
LocalConsoleLogger consoleLogger = new LocalSpigotConsoleLogger(getLogger());
api.registerConsoleLogger(consoleLogger);
MultiChatLocalPlatform platform = MultiChatLocalPlatform.SPIGOT;
api.registerPlatform(platform);
String pluginName = "MultiChat";
api.registerPluginName(pluginName);
File configDir = getDataFolder().getAbsoluteFile();
if (!getDataFolder().exists()) {
consoleLogger.log("Creating plugin directory...");
getDataFolder().mkdirs();
configDir = getDataFolder();
}
api.registerConfigDirectory(configDir);
String translationsDirString = configDir.toString() + File.separator + "translations";
File translationsDir = new File(translationsDirString);
if (!translationsDir.exists()) {
consoleLogger.log("Creating translations directory...");
translationsDir.mkdirs();
}
LocalConfigManager configMan = new LocalConfigManager();
api.registerConfigManager(configMan);
configMan.registerLocalConfig(platform, "localconfig.yml", configDir);
LocalDataStore dataStore = new LocalDataStore();
api.registerDataStore(dataStore);
if (configMan.getLocalConfig().isNicknameSQL()) {
String databaseName = "multichatlocal.db";
LocalDatabaseSetupManager ldsm = new LocalDatabaseSetupManager(databaseName, configMan.getLocalConfig().isMySQL());
if (ldsm.isConnected()) {
nameManager = new LocalSQLNameManager(databaseName);
} else {
consoleLogger.log("Could not connect to database! Using file based storage instead...");
nameManager = new LocalSpigotFileNameManager();
}
} else {
nameManager = new LocalSpigotFileNameManager();
}
api.registerNameManager(nameManager);
LocalFileSystemManager fileSystemManager = new LocalFileSystemManager();
api.registerFileSystemManager(fileSystemManager);
if (nameManager.getMode() == LocalNameManagerMode.FILE) {
fileSystemManager.registerNicknameFile(platform, "namedata.dat", configDir, (LocalFileNameManager) nameManager);
}
fileSystemManager.createResource("localconfig_fr.yml", translationsDir);
LocalMetaManager metaManager = new LocalSpigotMetaManager();
api.registerMetaManager(metaManager);
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:comm");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:chat");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:prefix");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:suffix");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:dn");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:world");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:nick");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:pxe");
getServer().getMessenger().registerOutgoingPluginChannel(this, "multichat:ppxe");
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:comm", new LocalSpigotPlayerMetaListener());
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:chat", new LocalSpigotCastListener());
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:act", new LocalSpigotActionListener());
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:pact", new LocalSpigotPlayerActionListener());
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:ch", new LocalSpigotPlayerChannelListener());
getServer().getMessenger().registerIncomingPluginChannel(this, "multichat:ignore", new LocalSpigotIgnoreListener());
LocalProxyCommunicationManager proxyCommunicationManager = new SpigotBungeeCommunicationManager();
api.registerProxyCommunicationManager(proxyCommunicationManager);
LocalPlaceholderManager placeholderManager = new LocalSpigotPlaceholderManager();
api.registerPlaceholderManager(placeholderManager);
LocalChatManager chatManager = new LocalSpigotChatManager();
api.registerChatManager(chatManager);
getServer().getPluginManager().registerEvents(new LocalSpigotWorldChangeListener(), this);
getServer().getPluginManager().registerEvents(new LocalSpigotLoginLogoutListener(), this);
getServer().getPluginManager().registerEvents(new LocalSpigotChatListenerLowest(), this);
getServer().getPluginManager().registerEvents(new LocalSpigotChatListenerHighest(), this);
getServer().getPluginManager().registerEvents(new LocalSpigotChatListenerMonitor(), this);
this.getCommand("multichatlocal").setExecutor(new MultiChatLocalSpigotCommand());
SpigotProxyExecuteCommand pxeCommand = new SpigotProxyExecuteCommand();
this.getCommand("pxe").setExecutor(pxeCommand);
this.getCommand("pexecute").setExecutor(pxeCommand);
this.getCommand("nick").setExecutor(new SpigotNickCommand());
this.getCommand("realname").setExecutor(new SpigotRealnameCommand());
this.getCommand("username").setExecutor(new SpigotUsernameCommand());
if (getServer().getPluginManager().getPlugin("Vault") == null)
return;
RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
if (rsp == null) {
MultiChatLocal.getInstance().getConsoleLogger().log("[ERROR] Vault was found, but will not work properly until you install a compatible permissions plugin!");
return;
}
LocalSpigotVaultHook.getInstance().hook(rsp.getProvider());
MultiChatLocal.getInstance().getConsoleLogger().log("MultiChatLocal hooked with Vault!");
<DeepExtract>
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") == null) {
return;
} else {
LocalSpigotPAPIHook.getInstance().hook();
MultiChatLocal.getInstance().getConsoleLogger().log("MultiChatLocal hooked with PlaceholderAPI!");
}
</DeepExtract>
} | Development | positive | 2,479 |
public void invokeAsyn(ResultCallback callback) {
requestBody = buildRequestBody();
requestBody = wrapRequestBody(requestBody, callback);
request = buildRequest();
mOkHttpClientManager.execute(request, callback);
} | public void invokeAsyn(ResultCallback callback) {
<DeepExtract>
requestBody = buildRequestBody();
requestBody = wrapRequestBody(requestBody, callback);
request = buildRequest();
</DeepExtract>
mOkHttpClientManager.execute(request, callback);
} | meiShi | positive | 2,480 |
public static void setChartData(LineChart chart, List<Entry> values) {
chart.getDescription().setEnabled(false);
chart.setScaleEnabled(false);
chart.getLegend().setEnabled(false);
chart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
chart.getAxisRight().setDrawAxisLine(false);
YAxis yAxis = chart.getAxisLeft();
yAxis.setDrawAxisLine(false);
yAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
yAxis.setDrawGridLines(false);
yAxis.setTextColor(Color.WHITE);
yAxis.setTextSize(15);
yAxis.setAxisMinimum(0);
chart.animateX(2500);
if (chart.getData() != null && chart.getData().getDataSetCount() > 0) {
lineDataSet = (LineDataSet) chart.getData().getDataSetByIndex(0);
lineDataSet.setValues(values);
chart.getData().notifyDataChanged();
chart.notifyDataSetChanged();
} else {
lineDataSet = new LineDataSet(values, "");
lineDataSet.setColor(Color.GREEN);
lineDataSet.setDrawValues(true);
lineDataSet.setDrawCircles(true);
lineDataSet.setDrawValues(false);
lineDataSet.setHighlightEnabled(false);
lineDataSet.setCircleColor(Color.BLACK);
LineData data = new LineData(lineDataSet);
chart.setData(data);
chart.invalidate();
}
} | public static void setChartData(LineChart chart, List<Entry> values) {
<DeepExtract>
chart.getDescription().setEnabled(false);
chart.setScaleEnabled(false);
chart.getLegend().setEnabled(false);
chart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
chart.getAxisRight().setDrawAxisLine(false);
YAxis yAxis = chart.getAxisLeft();
yAxis.setDrawAxisLine(false);
yAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
yAxis.setDrawGridLines(false);
yAxis.setTextColor(Color.WHITE);
yAxis.setTextSize(15);
yAxis.setAxisMinimum(0);
chart.animateX(2500);
</DeepExtract>
if (chart.getData() != null && chart.getData().getDataSetCount() > 0) {
lineDataSet = (LineDataSet) chart.getData().getDataSetByIndex(0);
lineDataSet.setValues(values);
chart.getData().notifyDataChanged();
chart.notifyDataSetChanged();
} else {
lineDataSet = new LineDataSet(values, "");
lineDataSet.setColor(Color.GREEN);
lineDataSet.setDrawValues(true);
lineDataSet.setDrawCircles(true);
lineDataSet.setDrawValues(false);
lineDataSet.setHighlightEnabled(false);
lineDataSet.setCircleColor(Color.BLACK);
LineData data = new LineData(lineDataSet);
chart.setData(data);
chart.invalidate();
}
} | bill | positive | 2,482 |
public void startRandomMotion(String name, int priority) {
int max = modelSetting.getMotionNum(name);
int no = (int) (Math.random() * max);
String motionName = modelSetting.getMotionFile(name, no);
if (motionName == null || motionName.equals("")) {
if (LAppDefine.DEBUG_LOG) {
Log.d(TAG, "Failed to motion.");
}
return;
}
AMotion motion;
if (priority == LAppDefine.PRIORITY_FORCE) {
mainMotionManager.setReservePriority(priority);
} else if (!mainMotionManager.reserveMotion(priority)) {
if (LAppDefine.DEBUG_LOG) {
Log.d(TAG, "Failed to motion.");
}
return;
}
String motionPath = modelHomeDir + motionName;
motion = loadMotion(null, motionPath);
if (motion == null) {
Log.w(TAG, "Failed to load motion.");
mainMotionManager.setReservePriority(0);
return;
}
motion.setFadeIn(modelSetting.getMotionFadeIn(name, no));
motion.setFadeOut(modelSetting.getMotionFadeOut(name, no));
if (LAppDefine.DEBUG_LOG)
Log.d(TAG, "Start motion : " + motionName);
if (modelSetting.getMotionSound(name, no) == null) {
mainMotionManager.startMotionPrio(motion, priority);
} else {
String soundName = modelSetting.getMotionSound(name, no);
String soundPath = modelHomeDir + soundName;
if (LAppDefine.DEBUG_LOG)
Log.d(TAG, "sound : " + soundName);
SoundManager.play(soundPath);
mainMotionManager.startMotionPrio(motion, priority);
}
} | public void startRandomMotion(String name, int priority) {
int max = modelSetting.getMotionNum(name);
int no = (int) (Math.random() * max);
<DeepExtract>
String motionName = modelSetting.getMotionFile(name, no);
if (motionName == null || motionName.equals("")) {
if (LAppDefine.DEBUG_LOG) {
Log.d(TAG, "Failed to motion.");
}
return;
}
AMotion motion;
if (priority == LAppDefine.PRIORITY_FORCE) {
mainMotionManager.setReservePriority(priority);
} else if (!mainMotionManager.reserveMotion(priority)) {
if (LAppDefine.DEBUG_LOG) {
Log.d(TAG, "Failed to motion.");
}
return;
}
String motionPath = modelHomeDir + motionName;
motion = loadMotion(null, motionPath);
if (motion == null) {
Log.w(TAG, "Failed to load motion.");
mainMotionManager.setReservePriority(0);
return;
}
motion.setFadeIn(modelSetting.getMotionFadeIn(name, no));
motion.setFadeOut(modelSetting.getMotionFadeOut(name, no));
if (LAppDefine.DEBUG_LOG)
Log.d(TAG, "Start motion : " + motionName);
if (modelSetting.getMotionSound(name, no) == null) {
mainMotionManager.startMotionPrio(motion, priority);
} else {
String soundName = modelSetting.getMotionSound(name, no);
String soundPath = modelHomeDir + soundName;
if (LAppDefine.DEBUG_LOG)
Log.d(TAG, "sound : " + soundName);
SoundManager.play(soundPath);
mainMotionManager.startMotionPrio(motion, priority);
}
</DeepExtract>
} | Live2D-Launcher | positive | 2,483 |
public Criteria andIsDeletedLike(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "isDeleted" + " cannot be null");
}
criteria.add(new Criterion("is_deleted like", value));
return (Criteria) this;
} | public Criteria andIsDeletedLike(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "isDeleted" + " cannot be null");
}
criteria.add(new Criterion("is_deleted like", value));
</DeepExtract>
return (Criteria) this;
} | MarketServer | positive | 2,484 |
@Override
public String apply(Uri<?> uri) {
StringBuilder builder = new StringBuilder().append(scheme);
if (fragment.length() > 0) {
builder.append(":").append(fragment);
}
if (!params.isEmpty()) {
builder.append("?");
List<String> parts = Lists.newArrayList();
for (Map.Entry<String, Collection<String>> entry : params.entrySet()) {
for (String value : entry.getValue()) {
parts.add(entry.getKey() + "=" + value);
}
}
builder.append(Joiner.on("&").join(parts));
}
return builder.toString();
} | @Override
public String apply(Uri<?> uri) {
<DeepExtract>
StringBuilder builder = new StringBuilder().append(scheme);
if (fragment.length() > 0) {
builder.append(":").append(fragment);
}
if (!params.isEmpty()) {
builder.append("?");
List<String> parts = Lists.newArrayList();
for (Map.Entry<String, Collection<String>> entry : params.entrySet()) {
for (String value : entry.getValue()) {
parts.add(entry.getKey() + "=" + value);
}
}
builder.append(Joiner.on("&").join(parts));
}
return builder.toString();
</DeepExtract>
} | atlas | positive | 2,485 |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
mLocationPermissionGranted = true;
} else {
ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION }, PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
}
if (checkMapServices() && mLocationPermissionGranted) {
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_maps_container, new MapsFragment()).commit();
mapsFragVisible = true;
}
} | @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
<DeepExtract>
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
mLocationPermissionGranted = true;
} else {
ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION }, PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
}
</DeepExtract>
if (checkMapServices() && mLocationPermissionGranted) {
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_maps_container, new MapsFragment()).commit();
mapsFragVisible = true;
}
} | APPetit | positive | 2,487 |
public ArrayList<ChartSet> prepareEnterAnimation(ChartView chartView) {
mEasing.setState(BaseEasingMethod.ENTER);
final ArrayList<ChartSet> sets = chartView.getData();
float x;
if (mStartXFactor != -1)
x = chartView.getInnerChartLeft() + (chartView.getInnerChartRight() - chartView.getInnerChartLeft()) * mStartXFactor;
else
x = chartView.getZeroPosition();
float y;
if (mStartYFactor != -1)
y = chartView.getInnerChartBottom() - (chartView.getInnerChartBottom() - chartView.getInnerChartTop()) * mStartYFactor;
else
y = chartView.getZeroPosition();
final int nSets = sets.size();
final int nEntries = sets.get(0).size();
mSetsAlpha = new float[nSets];
ArrayList<float[][]> startValues = new ArrayList<>(nSets);
ArrayList<float[][]> endValues = new ArrayList<>(nSets);
float[][] startSet;
float[][] endSet;
for (int i = 0; i < nSets; i++) {
mSetsAlpha[i] = sets.get(i).getAlpha();
startSet = new float[nEntries][2];
endSet = new float[nEntries][2];
for (int j = 0; j < nEntries; j++) {
if (mStartXFactor == -1 && chartView.getOrientation() == ChartView.Orientation.VERTICAL)
startSet[j][0] = sets.get(i).getEntry(j).getX();
else
startSet[j][0] = x;
if (mStartYFactor == -1 && chartView.getOrientation() == ChartView.Orientation.HORIZONTAL)
startSet[j][1] = sets.get(i).getEntry(j).getY();
else
startSet[j][1] = y;
endSet[j][0] = sets.get(i).getEntry(j).getX();
endSet[j][1] = sets.get(i).getEntry(j).getY();
}
startValues.add(startSet);
endValues.add(endSet);
}
if (mEasing.getState() == BaseEasingMethod.ENTER)
return prepareAnimation(chartView, startValues, endValues);
else
return prepareAnimation(chartView, endValues, startValues);
} | public ArrayList<ChartSet> prepareEnterAnimation(ChartView chartView) {
mEasing.setState(BaseEasingMethod.ENTER);
<DeepExtract>
final ArrayList<ChartSet> sets = chartView.getData();
float x;
if (mStartXFactor != -1)
x = chartView.getInnerChartLeft() + (chartView.getInnerChartRight() - chartView.getInnerChartLeft()) * mStartXFactor;
else
x = chartView.getZeroPosition();
float y;
if (mStartYFactor != -1)
y = chartView.getInnerChartBottom() - (chartView.getInnerChartBottom() - chartView.getInnerChartTop()) * mStartYFactor;
else
y = chartView.getZeroPosition();
final int nSets = sets.size();
final int nEntries = sets.get(0).size();
mSetsAlpha = new float[nSets];
ArrayList<float[][]> startValues = new ArrayList<>(nSets);
ArrayList<float[][]> endValues = new ArrayList<>(nSets);
float[][] startSet;
float[][] endSet;
for (int i = 0; i < nSets; i++) {
mSetsAlpha[i] = sets.get(i).getAlpha();
startSet = new float[nEntries][2];
endSet = new float[nEntries][2];
for (int j = 0; j < nEntries; j++) {
if (mStartXFactor == -1 && chartView.getOrientation() == ChartView.Orientation.VERTICAL)
startSet[j][0] = sets.get(i).getEntry(j).getX();
else
startSet[j][0] = x;
if (mStartYFactor == -1 && chartView.getOrientation() == ChartView.Orientation.HORIZONTAL)
startSet[j][1] = sets.get(i).getEntry(j).getY();
else
startSet[j][1] = y;
endSet[j][0] = sets.get(i).getEntry(j).getX();
endSet[j][1] = sets.get(i).getEntry(j).getY();
}
startValues.add(startSet);
endValues.add(endSet);
}
if (mEasing.getState() == BaseEasingMethod.ENTER)
return prepareAnimation(chartView, startValues, endValues);
else
return prepareAnimation(chartView, endValues, startValues);
</DeepExtract>
} | NBAPlus | positive | 2,488 |
@Override
protected void onDestroy() {
super.onDestroy();
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
unregisterReceiver(finishReceiver);
} | @Override
protected void onDestroy() {
super.onDestroy();
<DeepExtract>
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
</DeepExtract>
unregisterReceiver(finishReceiver);
} | Upchain-wallet | positive | 2,489 |
@Override
public int executeUpdate(String sql) throws SQLException {
this.sql = sql;
return this.execute();
return 0;
} | @Override
public int executeUpdate(String sql) throws SQLException {
<DeepExtract>
this.sql = sql;
return this.execute();
</DeepExtract>
return 0;
} | jdbc-redis | positive | 2,491 |
public void setGraphicsStateParameters(final PDExtendedGraphicsState state) throws IOException {
final int byteCount = NumberFormatUtil.formatFloatFast(m_aResources.add(state), m_aFormatDecimal.getMaximumFractionDigits(), m_aFormatBuffer);
if (byteCount == -1) {
write(m_aFormatDecimal.format(m_aResources.add(state)));
} else {
m_aOS.write(m_aFormatBuffer, 0, byteCount);
}
m_aOS.write(' ');
writeOperator((byte) 'g', (byte) 's');
} | public void setGraphicsStateParameters(final PDExtendedGraphicsState state) throws IOException {
<DeepExtract>
final int byteCount = NumberFormatUtil.formatFloatFast(m_aResources.add(state), m_aFormatDecimal.getMaximumFractionDigits(), m_aFormatBuffer);
if (byteCount == -1) {
write(m_aFormatDecimal.format(m_aResources.add(state)));
} else {
m_aOS.write(m_aFormatBuffer, 0, byteCount);
}
m_aOS.write(' ');
</DeepExtract>
writeOperator((byte) 'g', (byte) 's');
} | ph-pdf-layout | positive | 2,492 |
@Override
public void beforeTestClass(TestContext testContext) {
ApplicationContext appContext = testContext.getApplicationContext();
JdbcOperations jdbcOper = appContext.getBean(JdbcOperations.class);
jdbcOper.update("DROP ALL OBJECTS DELETE FILES");
} | @Override
public void beforeTestClass(TestContext testContext) {
<DeepExtract>
ApplicationContext appContext = testContext.getApplicationContext();
JdbcOperations jdbcOper = appContext.getBean(JdbcOperations.class);
jdbcOper.update("DROP ALL OBJECTS DELETE FILES");
</DeepExtract>
} | secure-token-service | positive | 2,493 |
public Criteria andAddressGreaterThan(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "address" + " cannot be null");
}
criteria.add(new Criterion("address >", value));
return (Criteria) this;
} | public Criteria andAddressGreaterThan(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "address" + " cannot be null");
}
criteria.add(new Criterion("address >", value));
</DeepExtract>
return (Criteria) this;
} | spring-boot-all | positive | 2,494 |
public static Class<?> forName(String className) throws ClassNotFoundException {
if (null == className || "".equals(className)) {
throw new ClassNotFoundException("class name: " + className);
}
Class<?> clz = nameToClassCache.get(className);
if (clz != null) {
return clz;
}
if (!className.endsWith("[]")) {
clz = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
}
int dimensionSiz = 0;
while (className.endsWith("[]")) {
dimensionSiz++;
className = className.substring(0, className.length() - 2);
}
int[] dimensions = new int[dimensionSiz];
Class<?> clz = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
return Array.newInstance(clz, dimensions).getClass();
nameToClassCache.putIfAbsent(className, clz);
return clz;
} | public static Class<?> forName(String className) throws ClassNotFoundException {
if (null == className || "".equals(className)) {
throw new ClassNotFoundException("class name: " + className);
}
Class<?> clz = nameToClassCache.get(className);
if (clz != null) {
return clz;
}
<DeepExtract>
if (!className.endsWith("[]")) {
clz = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
}
int dimensionSiz = 0;
while (className.endsWith("[]")) {
dimensionSiz++;
className = className.substring(0, className.length() - 2);
}
int[] dimensions = new int[dimensionSiz];
Class<?> clz = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
return Array.newInstance(clz, dimensions).getClass();
</DeepExtract>
nameToClassCache.putIfAbsent(className, clz);
return clz;
} | catty | positive | 2,495 |
public Criteria andDateBetween(Date value1, Date value2) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + "date" + " cannot be null");
}
criteria.add(new Criterion("date between", value1, value2));
return (Criteria) this;
} | public Criteria andDateBetween(Date value1, Date value2) {
<DeepExtract>
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + "date" + " cannot be null");
}
criteria.add(new Criterion("date between", value1, value2));
</DeepExtract>
return (Criteria) this;
} | CuitJavaEEPractice | positive | 2,496 |
public Criteria andStockEqualTo(Integer value) {
if (value == null) {
throw new RuntimeException("Value for " + "stock" + " cannot be null");
}
criteria.add(new Criterion("stock =", value));
return (Criteria) this;
} | public Criteria andStockEqualTo(Integer value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "stock" + " cannot be null");
}
criteria.add(new Criterion("stock =", value));
</DeepExtract>
return (Criteria) this;
} | ssmxiaomi | positive | 2,497 |
protected String buildConditionString() {
StringBuilder query = new StringBuilder(120);
if (!TextUtils.isEmpty(where)) {
query.append(" WHERE ");
query.append(where);
}
if (!TextUtils.isEmpty(groupBy)) {
query.append(" GROUP BY ");
query.append(groupBy);
}
if (!TextUtils.isEmpty(having)) {
query.append(" HAVING ");
query.append(having);
}
if (!TextUtils.isEmpty(orderBy)) {
query.append(" ORDER BY ");
query.append(orderBy);
}
if (!TextUtils.isEmpty(limit)) {
query.append(" LIMIT ");
query.append(limit);
}
return query.toString();
} | protected String buildConditionString() {
StringBuilder query = new StringBuilder(120);
if (!TextUtils.isEmpty(where)) {
query.append(" WHERE ");
query.append(where);
}
if (!TextUtils.isEmpty(groupBy)) {
query.append(" GROUP BY ");
query.append(groupBy);
}
if (!TextUtils.isEmpty(having)) {
query.append(" HAVING ");
query.append(having);
}
if (!TextUtils.isEmpty(orderBy)) {
query.append(" ORDER BY ");
query.append(orderBy);
}
<DeepExtract>
if (!TextUtils.isEmpty(limit)) {
query.append(" LIMIT ");
query.append(limit);
}
</DeepExtract>
return query.toString();
} | BlueskyAndroid | positive | 2,498 |
public static Node exists(PLUSObject obj) {
if (db == null)
initialize();
try (Transaction tx = db.beginTx()) {
Node n = db.index().getNodeAutoIndexer().getAutoIndex().get(PROP_PLUSOBJECT_ID, obj.getId()).getSingle();
tx.success();
return n;
}
} | public static Node exists(PLUSObject obj) {
<DeepExtract>
if (db == null)
initialize();
try (Transaction tx = db.beginTx()) {
Node n = db.index().getNodeAutoIndexer().getAutoIndex().get(PROP_PLUSOBJECT_ID, obj.getId()).getSingle();
tx.success();
return n;
}
</DeepExtract>
} | plus | positive | 2,500 |
@Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
if (mBitmapPaint != null) {
mBitmapPaint.setColorFilter(mColorFilter);
}
invalidate();
} | @Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
<DeepExtract>
if (mBitmapPaint != null) {
mBitmapPaint.setColorFilter(mColorFilter);
}
</DeepExtract>
invalidate();
} | HeadLine | positive | 2,501 |
public LMDBStoreBackend buildAndInitReadOnly() {
if (_storeConfig == null)
throw new IllegalStateException("Missing StoreConfig");
if (_lmdbConfig == null)
throw new IllegalStateException("Missing LMDBConfig");
File dbRoot = _lmdbConfig.dataRoot;
if (dbRoot == null) {
throw new IllegalStateException("Missing LevelDBConfig.dataRoot");
}
_verifyDir(dbRoot, false);
StorableConverter storableConv = _storeConfig.createStorableConverter();
Env env = new Env();
env.setMapSize(_lmdbConfig.mapSize);
env.addFlags(NOSYNC | NOMETASYNC);
Database dataDB;
int flags = false ? Constants.CREATE : 0;
if (!false) {
flags |= Constants.RDONLY;
}
try {
dataDB = env.openDatabase(NAME_DATA, flags);
} catch (Exception e) {
throw new IllegalStateException("Failed to open main data LMDB: " + e.getMessage(), e);
}
Database indexDB;
try {
indexDB = env.openDatabase(NAME_LAST_MOD, flags);
} catch (Exception e) {
throw new IllegalStateException("Failed to open last-mod index LevelDB: " + e.getMessage(), e);
}
return new LMDBStoreBackend(storableConv, dbRoot, env, dataDB, indexDB);
} | public LMDBStoreBackend buildAndInitReadOnly() {
<DeepExtract>
if (_storeConfig == null)
throw new IllegalStateException("Missing StoreConfig");
if (_lmdbConfig == null)
throw new IllegalStateException("Missing LMDBConfig");
File dbRoot = _lmdbConfig.dataRoot;
if (dbRoot == null) {
throw new IllegalStateException("Missing LevelDBConfig.dataRoot");
}
_verifyDir(dbRoot, false);
StorableConverter storableConv = _storeConfig.createStorableConverter();
Env env = new Env();
env.setMapSize(_lmdbConfig.mapSize);
env.addFlags(NOSYNC | NOMETASYNC);
Database dataDB;
int flags = false ? Constants.CREATE : 0;
if (!false) {
flags |= Constants.RDONLY;
}
try {
dataDB = env.openDatabase(NAME_DATA, flags);
} catch (Exception e) {
throw new IllegalStateException("Failed to open main data LMDB: " + e.getMessage(), e);
}
Database indexDB;
try {
indexDB = env.openDatabase(NAME_LAST_MOD, flags);
} catch (Exception e) {
throw new IllegalStateException("Failed to open last-mod index LevelDB: " + e.getMessage(), e);
}
return new LMDBStoreBackend(storableConv, dbRoot, env, dataDB, indexDB);
</DeepExtract>
} | StoreMate | positive | 2,502 |
@Override
public void onItemAccepted(CharSequence charSequence, int i) {
workingPlaylist = playlists.get(i);
listener.OnWorkingPlaylistSet();
} | @Override
public void onItemAccepted(CharSequence charSequence, int i) {
<DeepExtract>
workingPlaylist = playlists.get(i);
</DeepExtract>
listener.OnWorkingPlaylistSet();
} | IdealMedia | positive | 2,503 |
public static ScalingUtils.ScaleType getGridViewImageScaleType() {
switch(App.getInstance().getPreferencesService().getGridViewImageScaleType()) {
case "FIT_XY":
return ScalingUtils.ScaleType.FIT_XY;
case "FIT_X":
return ScalingUtils.ScaleType.FIT_X;
case "FIT_Y":
return ScalingUtils.ScaleType.FIT_Y;
case "FIT_START":
return ScalingUtils.ScaleType.FIT_START;
case "FIT_END":
return ScalingUtils.ScaleType.FIT_END;
case "CENTER":
return ScalingUtils.ScaleType.CENTER;
case "CENTER_INSIDE":
return ScalingUtils.ScaleType.CENTER_INSIDE;
case "CENTER_CROP":
return ScalingUtils.ScaleType.CENTER_CROP;
case "FOCUS_CROP":
return ScalingUtils.ScaleType.FOCUS_CROP;
case "FIT_BOTTOM_START":
return ScalingUtils.ScaleType.FIT_BOTTOM_START;
case "FIT_CENTER":
default:
return ScalingUtils.ScaleType.FIT_CENTER;
}
} | public static ScalingUtils.ScaleType getGridViewImageScaleType() {
<DeepExtract>
switch(App.getInstance().getPreferencesService().getGridViewImageScaleType()) {
case "FIT_XY":
return ScalingUtils.ScaleType.FIT_XY;
case "FIT_X":
return ScalingUtils.ScaleType.FIT_X;
case "FIT_Y":
return ScalingUtils.ScaleType.FIT_Y;
case "FIT_START":
return ScalingUtils.ScaleType.FIT_START;
case "FIT_END":
return ScalingUtils.ScaleType.FIT_END;
case "CENTER":
return ScalingUtils.ScaleType.CENTER;
case "CENTER_INSIDE":
return ScalingUtils.ScaleType.CENTER_INSIDE;
case "CENTER_CROP":
return ScalingUtils.ScaleType.CENTER_CROP;
case "FOCUS_CROP":
return ScalingUtils.ScaleType.FOCUS_CROP;
case "FIT_BOTTOM_START":
return ScalingUtils.ScaleType.FIT_BOTTOM_START;
case "FIT_CENTER":
default:
return ScalingUtils.ScaleType.FIT_CENTER;
}
</DeepExtract>
} | ImgurViewer | positive | 2,504 |
@Test
public void testExtractFromOdt() throws IOException, ElasticsearchClientException {
logger.info(" -> Testing if file [{}] has been indexed correctly{}.", "test.odt", "sample" == null ? "" : " and contains [" + "sample" + "]");
ESBoolQuery query = new ESBoolQuery().addMust(new ESTermQuery("file.filename", "test.odt"));
if ("sample" != null) {
query.addMust(new ESMatchQuery("content", "sample"));
}
ESSearchResponse response = documentService.search(new ESSearchRequest().withIndex("fscrawler_test_all_documents").withESQuery(query));
assertThat(response.getTotalHits(), is(1L));
return response;
} | @Test
public void testExtractFromOdt() throws IOException, ElasticsearchClientException {
<DeepExtract>
logger.info(" -> Testing if file [{}] has been indexed correctly{}.", "test.odt", "sample" == null ? "" : " and contains [" + "sample" + "]");
ESBoolQuery query = new ESBoolQuery().addMust(new ESTermQuery("file.filename", "test.odt"));
if ("sample" != null) {
query.addMust(new ESMatchQuery("content", "sample"));
}
ESSearchResponse response = documentService.search(new ESSearchRequest().withIndex("fscrawler_test_all_documents").withESQuery(query));
assertThat(response.getTotalHits(), is(1L));
return response;
</DeepExtract>
} | fscrawler | positive | 2,505 |
private static <A> void checkCommentError(A expected, A actual, String message, ParserImpl p) {
assertEquals(list(_UnexpectedToken(message, COMMENT_ERROR_MESSAGE, 1)), p.errors());
assertEquals(expected.toString(), actual.toString());
} | private static <A> void checkCommentError(A expected, A actual, String message, ParserImpl p) {
<DeepExtract>
assertEquals(list(_UnexpectedToken(message, COMMENT_ERROR_MESSAGE, 1)), p.errors());
assertEquals(expected.toString(), actual.toString());
</DeepExtract>
} | jADT | positive | 2,506 |
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float currentTopMargin = (float) animation.getAnimatedValue();
MarginLayoutParams params = (MarginLayoutParams) mLoadView.getLayoutParams();
if ((int) currentTopMargin < 0) {
(int) currentTopMargin = 0;
}
params.bottomMargin = (int) currentTopMargin;
mLoadView.setLayoutParams(params);
} | @Override
public void onAnimationUpdate(ValueAnimator animation) {
float currentTopMargin = (float) animation.getAnimatedValue();
<DeepExtract>
MarginLayoutParams params = (MarginLayoutParams) mLoadView.getLayoutParams();
if ((int) currentTopMargin < 0) {
(int) currentTopMargin = 0;
}
params.bottomMargin = (int) currentTopMargin;
mLoadView.setLayoutParams(params);
</DeepExtract>
} | ReadMark | positive | 2,507 |
@Test
public void testCase8() {
c1 = new Classroom();
c1.setName("Computer room");
s1 = new Student();
s1.setName("Tom");
s2 = new Student();
s2.setName("Lily");
s1.setClassroom(c1);
s2.setClassroom(c1);
Set<Student> ss = new HashSet<>();
ss.add(s1);
ss.add(s2);
c1.setStudentCollection(ss);
s1.save();
s2.save();
c1.save();
assertTrue(isFKInsertCorrect(getTableName(c1), getTableName(s1), c1.get_id(), s1.getId()));
assertTrue(isFKInsertCorrect(getTableName(c1), getTableName(s2), c1.get_id(), s2.getId()));
} | @Test
public void testCase8() {
c1 = new Classroom();
c1.setName("Computer room");
s1 = new Student();
s1.setName("Tom");
s2 = new Student();
s2.setName("Lily");
s1.setClassroom(c1);
s2.setClassroom(c1);
Set<Student> ss = new HashSet<>();
ss.add(s1);
ss.add(s2);
c1.setStudentCollection(ss);
s1.save();
s2.save();
c1.save();
<DeepExtract>
assertTrue(isFKInsertCorrect(getTableName(c1), getTableName(s1), c1.get_id(), s1.getId()));
assertTrue(isFKInsertCorrect(getTableName(c1), getTableName(s2), c1.get_id(), s2.getId()));
</DeepExtract>
} | LitePal | positive | 2,508 |
public void reset() {
for (String c : resourceDb.keySet()) {
resourceDb.get(c).clear();
}
resourceDb.clear();
counter = 0;
if (new Resource("<resource>\n <name>a funky name</name>\n <data>an important message</data>" + "\n <nstag xmlns:ns1='http://smartrics/ns1'>\n <ns1:number>3</ns1:number>\n </nstag>" + "\n</resource>").getId() == null) {
new Resource("<resource>\n <name>a funky name</name>\n <data>an important message</data>" + "\n <nstag xmlns:ns1='http://smartrics/ns1'>\n <ns1:number>3</ns1:number>\n </nstag>" + "\n</resource>").setId(Integer.toString(newCounter()));
}
Map<String, Resource> m = getMapForContext("/resources");
m.put(new Resource("<resource>\n <name>a funky name</name>\n <data>an important message</data>" + "\n <nstag xmlns:ns1='http://smartrics/ns1'>\n <ns1:number>3</ns1:number>\n </nstag>" + "\n</resource>").getId(), new Resource("<resource>\n <name>a funky name</name>\n <data>an important message</data>" + "\n <nstag xmlns:ns1='http://smartrics/ns1'>\n <ns1:number>3</ns1:number>\n </nstag>" + "\n</resource>"));
if (new Resource("{ \"resource\" : { \"name\" : \"a funky name\", " + "\"data\" : \"an important message\" } }").getId() == null) {
new Resource("{ \"resource\" : { \"name\" : \"a funky name\", " + "\"data\" : \"an important message\" } }").setId(Integer.toString(newCounter()));
}
Map<String, Resource> m = getMapForContext("/resources");
m.put(new Resource("{ \"resource\" : { \"name\" : \"a funky name\", " + "\"data\" : \"an important message\" } }").getId(), new Resource("{ \"resource\" : { \"name\" : \"a funky name\", " + "\"data\" : \"an important message\" } }"));
StringBuffer sb = new StringBuffer();
sb.append("<resource>\n");
sb.append(" <name>giant bob</name>\n");
sb.append(" <type>large content</type>\n");
sb.append(" <address>\n");
sb.append(" <street>\n");
sb.append(" Regent Street\n");
sb.append(" </street>\n");
sb.append(" <number>\n");
sb.append(" 12345\n");
sb.append(" </number>\n");
sb.append(" </address>\n");
sb.append(" <data>\n");
sb.append(" <part id='0'>\n");
sb.append(" <source href='http://en.wikipedia.org/wiki/Inferno_(Dante)' />\n");
sb.append(" <content>\n");
sb.append("Inferno (Italian for 'Hell') is the first part of Dante Alighieri's 14th-century epic poem Divine Comedy. \n");
sb.append("It is followed by Purgatorio and Paradiso. It is an allegory telling of the journey of Dante through what is \n");
sb.append("largely the medieval concept of Hell, guided by the Roman poet Virgil. In the poem, Hell is depicted as nine \n");
sb.append("circles of suffering located within the Earth. Allegorically, the Divine Comedy represents the journey of the soul");
sb.append("towards God, with the Inferno describing the recognition and rejection of sin.\n");
sb.append(" </content>\n");
sb.append(" </part>\n");
sb.append(" </data>\n");
sb.append("</resource>\n");
if (new Resource("100", sb.toString()).getId() == null) {
new Resource("100", sb.toString()).setId(Integer.toString(newCounter()));
}
Map<String, Resource> m = getMapForContext("/resources");
m.put(new Resource("100", sb.toString()).getId(), new Resource("100", sb.toString()));
} | public void reset() {
for (String c : resourceDb.keySet()) {
resourceDb.get(c).clear();
}
resourceDb.clear();
counter = 0;
if (new Resource("<resource>\n <name>a funky name</name>\n <data>an important message</data>" + "\n <nstag xmlns:ns1='http://smartrics/ns1'>\n <ns1:number>3</ns1:number>\n </nstag>" + "\n</resource>").getId() == null) {
new Resource("<resource>\n <name>a funky name</name>\n <data>an important message</data>" + "\n <nstag xmlns:ns1='http://smartrics/ns1'>\n <ns1:number>3</ns1:number>\n </nstag>" + "\n</resource>").setId(Integer.toString(newCounter()));
}
Map<String, Resource> m = getMapForContext("/resources");
m.put(new Resource("<resource>\n <name>a funky name</name>\n <data>an important message</data>" + "\n <nstag xmlns:ns1='http://smartrics/ns1'>\n <ns1:number>3</ns1:number>\n </nstag>" + "\n</resource>").getId(), new Resource("<resource>\n <name>a funky name</name>\n <data>an important message</data>" + "\n <nstag xmlns:ns1='http://smartrics/ns1'>\n <ns1:number>3</ns1:number>\n </nstag>" + "\n</resource>"));
if (new Resource("{ \"resource\" : { \"name\" : \"a funky name\", " + "\"data\" : \"an important message\" } }").getId() == null) {
new Resource("{ \"resource\" : { \"name\" : \"a funky name\", " + "\"data\" : \"an important message\" } }").setId(Integer.toString(newCounter()));
}
Map<String, Resource> m = getMapForContext("/resources");
m.put(new Resource("{ \"resource\" : { \"name\" : \"a funky name\", " + "\"data\" : \"an important message\" } }").getId(), new Resource("{ \"resource\" : { \"name\" : \"a funky name\", " + "\"data\" : \"an important message\" } }"));
StringBuffer sb = new StringBuffer();
sb.append("<resource>\n");
sb.append(" <name>giant bob</name>\n");
sb.append(" <type>large content</type>\n");
sb.append(" <address>\n");
sb.append(" <street>\n");
sb.append(" Regent Street\n");
sb.append(" </street>\n");
sb.append(" <number>\n");
sb.append(" 12345\n");
sb.append(" </number>\n");
sb.append(" </address>\n");
sb.append(" <data>\n");
sb.append(" <part id='0'>\n");
sb.append(" <source href='http://en.wikipedia.org/wiki/Inferno_(Dante)' />\n");
sb.append(" <content>\n");
sb.append("Inferno (Italian for 'Hell') is the first part of Dante Alighieri's 14th-century epic poem Divine Comedy. \n");
sb.append("It is followed by Purgatorio and Paradiso. It is an allegory telling of the journey of Dante through what is \n");
sb.append("largely the medieval concept of Hell, guided by the Roman poet Virgil. In the poem, Hell is depicted as nine \n");
sb.append("circles of suffering located within the Earth. Allegorically, the Divine Comedy represents the journey of the soul");
sb.append("towards God, with the Inferno describing the recognition and rejection of sin.\n");
sb.append(" </content>\n");
sb.append(" </part>\n");
sb.append(" </data>\n");
sb.append("</resource>\n");
<DeepExtract>
if (new Resource("100", sb.toString()).getId() == null) {
new Resource("100", sb.toString()).setId(Integer.toString(newCounter()));
}
Map<String, Resource> m = getMapForContext("/resources");
m.put(new Resource("100", sb.toString()).getId(), new Resource("100", sb.toString()));
</DeepExtract>
} | RestFixture | positive | 2,510 |
private File setResourceToDelegate() throws IOException {
String path = resource.getFile().getAbsolutePath() + suffixCreator.getSuffix(resourceIndex);
File file = new File(path);
this.resource = new FileSystemResource(file);
return file;
} | private File setResourceToDelegate() throws IOException {
String path = resource.getFile().getAbsolutePath() + suffixCreator.getSuffix(resourceIndex);
File file = new File(path);
<DeepExtract>
this.resource = new FileSystemResource(file);
</DeepExtract>
return file;
} | SpringBatchSample | positive | 2,511 |
public Criteria andMarksIn(List<String> values) {
if (values == null) {
throw new RuntimeException("Value for " + "marks" + " cannot be null");
}
criteria.add(new Criterion("marks in", values));
return (Criteria) this;
} | public Criteria andMarksIn(List<String> values) {
<DeepExtract>
if (values == null) {
throw new RuntimeException("Value for " + "marks" + " cannot be null");
}
criteria.add(new Criterion("marks in", values));
</DeepExtract>
return (Criteria) this;
} | health_online | positive | 2,512 |
public void onResponseReceived(Request request, Response response) {
ConsoleLog.debug("SID: " + response.getText());
ConsoleLog.debug("Cookies: " + Cookies.getCookieNames());
final String sid = response.getText();
auth = new Authentication(config, sid, URLBuilder.getInstance().getUserInRoleURL(KNOWN_ROLES));
auth.setCallback(new Authentication.AuthCallback() {
public void onLoginSuccess(Request request, Response response) {
usernameInput.setText("");
passwordInput.setText("");
window.hide();
DeferredCommand.addCommand(new Command() {
public void execute() {
DOM.getElementById("splash").getStyle().setProperty("zIndex", "1000");
DOM.getElementById("ui_loading").getStyle().setProperty("visibility", "visible");
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable throwable) {
GWT.log("Code splitting failed", throwable);
MessageBox.error("Code splitting failed", throwable.getMessage());
}
public void onSuccess() {
List<String> roles = auth.getRolesAssigned();
StringBuilder roleString = new StringBuilder();
int index = 1;
for (String s : roles) {
roleString.append(s);
if (index < roles.size())
roleString.append(",");
index++;
}
Registry.get(SecurityService.class).setDeferredNotification(false);
MessageBuilder.createMessage().toSubject("AuthorizationListener").signalling().with(SecurityParts.Name, auth.getUsername()).with(SecurityParts.Roles, roleString.toString()).noErrorHandling().sendNowWith(ErraiBus.get());
Timer t = new Timer() {
public void run() {
DeferredCommand.addCommand(new Command() {
public void execute() {
DOM.getElementById("ui_loading").getStyle().setProperty("visibility", "hidden");
DOM.getElementById("splash").getStyle().setProperty("visibility", "hidden");
}
});
}
};
t.schedule(2000);
}
});
}
});
window = null;
}
public void onLoginFailed(Request request, Throwable t) {
usernameInput.setText("");
passwordInput.setText("");
messagePanel.setHTML("<div style='color:#CC0000;'>Authentication failed. Please try again:</div>");
}
});
Registry.set(Authentication.class, auth);
window = new WindowPanel(config.getProfileName(), false);
Widget closeBtn = window.getHeader().getWidget(0, Caption.CaptionRegion.RIGHT);
closeBtn.setVisible(false);
window.setAnimationEnabled(false);
MosaicPanel panel = new MosaicPanel();
panel.addStyleName("bpm-login");
createLayoutContent(panel);
window.setWidget(panel);
window.pack();
window.center();
usernameInput.setFocus(true);
} | public void onResponseReceived(Request request, Response response) {
ConsoleLog.debug("SID: " + response.getText());
ConsoleLog.debug("Cookies: " + Cookies.getCookieNames());
final String sid = response.getText();
auth = new Authentication(config, sid, URLBuilder.getInstance().getUserInRoleURL(KNOWN_ROLES));
auth.setCallback(new Authentication.AuthCallback() {
public void onLoginSuccess(Request request, Response response) {
usernameInput.setText("");
passwordInput.setText("");
window.hide();
DeferredCommand.addCommand(new Command() {
public void execute() {
DOM.getElementById("splash").getStyle().setProperty("zIndex", "1000");
DOM.getElementById("ui_loading").getStyle().setProperty("visibility", "visible");
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable throwable) {
GWT.log("Code splitting failed", throwable);
MessageBox.error("Code splitting failed", throwable.getMessage());
}
public void onSuccess() {
List<String> roles = auth.getRolesAssigned();
StringBuilder roleString = new StringBuilder();
int index = 1;
for (String s : roles) {
roleString.append(s);
if (index < roles.size())
roleString.append(",");
index++;
}
Registry.get(SecurityService.class).setDeferredNotification(false);
MessageBuilder.createMessage().toSubject("AuthorizationListener").signalling().with(SecurityParts.Name, auth.getUsername()).with(SecurityParts.Roles, roleString.toString()).noErrorHandling().sendNowWith(ErraiBus.get());
Timer t = new Timer() {
public void run() {
DeferredCommand.addCommand(new Command() {
public void execute() {
DOM.getElementById("ui_loading").getStyle().setProperty("visibility", "hidden");
DOM.getElementById("splash").getStyle().setProperty("visibility", "hidden");
}
});
}
};
t.schedule(2000);
}
});
}
});
window = null;
}
public void onLoginFailed(Request request, Throwable t) {
usernameInput.setText("");
passwordInput.setText("");
messagePanel.setHTML("<div style='color:#CC0000;'>Authentication failed. Please try again:</div>");
}
});
Registry.set(Authentication.class, auth);
<DeepExtract>
window = new WindowPanel(config.getProfileName(), false);
Widget closeBtn = window.getHeader().getWidget(0, Caption.CaptionRegion.RIGHT);
closeBtn.setVisible(false);
window.setAnimationEnabled(false);
MosaicPanel panel = new MosaicPanel();
panel.addStyleName("bpm-login");
createLayoutContent(panel);
window.setWidget(panel);
</DeepExtract>
window.pack();
window.center();
usernameInput.setFocus(true);
} | bpm-console | positive | 2,513 |
public static void main(String[] args) {
if ("A man, a plan, a canal: Panama" == null || "A man, a plan, a canal: Panama".length() == 0)
return true;
int start = 0;
int end = "A man, a plan, a canal: Panama".length() - 1;
while (start <= end) {
while (start <= end && !Character.isLetterOrDigit("A man, a plan, a canal: Panama".charAt(start))) {
start++;
}
while (start <= end && !Character.isLetterOrDigit("A man, a plan, a canal: Panama".charAt(end))) {
end--;
}
if (start <= end && Character.toUpperCase("A man, a plan, a canal: Panama".charAt(start)) != Character.toUpperCase("A man, a plan, a canal: Panama".charAt(end)))
return false;
start++;
end--;
}
return true;
} | public static void main(String[] args) {
<DeepExtract>
if ("A man, a plan, a canal: Panama" == null || "A man, a plan, a canal: Panama".length() == 0)
return true;
int start = 0;
int end = "A man, a plan, a canal: Panama".length() - 1;
while (start <= end) {
while (start <= end && !Character.isLetterOrDigit("A man, a plan, a canal: Panama".charAt(start))) {
start++;
}
while (start <= end && !Character.isLetterOrDigit("A man, a plan, a canal: Panama".charAt(end))) {
end--;
}
if (start <= end && Character.toUpperCase("A man, a plan, a canal: Panama".charAt(start)) != Character.toUpperCase("A man, a plan, a canal: Panama".charAt(end)))
return false;
start++;
end--;
}
return true;
</DeepExtract>
} | Java-Note | positive | 2,515 |
@Override
public Object visit(ASTTrue node, Object data) throws VisitorException {
node.jjtReplaceWith(ASTVarGenerator.getASTVar("content"));
return super.visit(node, data);
} | @Override
public Object visit(ASTTrue node, Object data) throws VisitorException {
<DeepExtract>
node.jjtReplaceWith(ASTVarGenerator.getASTVar("content"));
</DeepExtract>
return super.visit(node, data);
} | sparqled | positive | 2,516 |
public Criteria andTempurlidGreaterThanOrEqualTo(Integer value) {
if (value == null) {
throw new RuntimeException("Value for " + "tempurlid" + " cannot be null");
}
criteria.add(new Criterion("tempUrlID >=", value));
return (Criteria) this;
} | public Criteria andTempurlidGreaterThanOrEqualTo(Integer value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "tempurlid" + " cannot be null");
}
criteria.add(new Criterion("tempUrlID >=", value));
</DeepExtract>
return (Criteria) this;
} | answerWeb | positive | 2,517 |
public MethodDescriptor[] getMethodDescriptors() {
MethodDescriptor[] methods = new MethodDescriptor[17];
try {
methods[METHOD_addPvChangeListener0] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("addPvChangeListener", com.fr3ts0n.pvs.PvChangeListener.class, Integer.TYPE));
methods[METHOD_addPvChangeListener0].setDisplayName("");
methods[METHOD_clear1] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("clear"));
methods[METHOD_clear1].setDisplayName("");
methods[METHOD_clone2] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("clone"));
methods[METHOD_clone2].setDisplayName("");
methods[METHOD_containsKey3] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("containsKey", Object.class));
methods[METHOD_containsKey3].setDisplayName("");
methods[METHOD_containsValue4] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("containsValue", Object.class));
methods[METHOD_containsValue4].setDisplayName("");
methods[METHOD_entrySet5] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("entrySet"));
methods[METHOD_entrySet5].setDisplayName("");
methods[METHOD_equals6] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("equals", Object.class));
methods[METHOD_equals6].setDisplayName("");
methods[METHOD_get7] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("get", Object.class));
methods[METHOD_get7].setDisplayName("");
methods[METHOD_hashCode8] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("hashCode"));
methods[METHOD_hashCode8].setDisplayName("");
methods[METHOD_keySet9] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("keySet"));
methods[METHOD_keySet9].setDisplayName("");
methods[METHOD_put10] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("put", Object.class, Object.class, Integer.TYPE));
methods[METHOD_put10].setDisplayName("");
methods[METHOD_putAll11] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("putAll", java.util.Map.class, Integer.TYPE, Boolean.TYPE));
methods[METHOD_putAll11].setDisplayName("");
methods[METHOD_pvChanged12] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("pvChanged", com.fr3ts0n.pvs.PvChangeEvent.class));
methods[METHOD_pvChanged12].setDisplayName("");
methods[METHOD_remove13] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("remove", Object.class));
methods[METHOD_remove13].setDisplayName("");
methods[METHOD_size14] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("size"));
methods[METHOD_size14].setDisplayName("");
methods[METHOD_toString15] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("toString"));
methods[METHOD_toString15].setDisplayName("");
methods[METHOD_values16] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("values"));
methods[METHOD_values16].setDisplayName("");
} catch (Exception ignored) {
}
return methods;
} | public MethodDescriptor[] getMethodDescriptors() {
<DeepExtract>
MethodDescriptor[] methods = new MethodDescriptor[17];
try {
methods[METHOD_addPvChangeListener0] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("addPvChangeListener", com.fr3ts0n.pvs.PvChangeListener.class, Integer.TYPE));
methods[METHOD_addPvChangeListener0].setDisplayName("");
methods[METHOD_clear1] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("clear"));
methods[METHOD_clear1].setDisplayName("");
methods[METHOD_clone2] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("clone"));
methods[METHOD_clone2].setDisplayName("");
methods[METHOD_containsKey3] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("containsKey", Object.class));
methods[METHOD_containsKey3].setDisplayName("");
methods[METHOD_containsValue4] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("containsValue", Object.class));
methods[METHOD_containsValue4].setDisplayName("");
methods[METHOD_entrySet5] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("entrySet"));
methods[METHOD_entrySet5].setDisplayName("");
methods[METHOD_equals6] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("equals", Object.class));
methods[METHOD_equals6].setDisplayName("");
methods[METHOD_get7] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("get", Object.class));
methods[METHOD_get7].setDisplayName("");
methods[METHOD_hashCode8] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("hashCode"));
methods[METHOD_hashCode8].setDisplayName("");
methods[METHOD_keySet9] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("keySet"));
methods[METHOD_keySet9].setDisplayName("");
methods[METHOD_put10] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("put", Object.class, Object.class, Integer.TYPE));
methods[METHOD_put10].setDisplayName("");
methods[METHOD_putAll11] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("putAll", java.util.Map.class, Integer.TYPE, Boolean.TYPE));
methods[METHOD_putAll11].setDisplayName("");
methods[METHOD_pvChanged12] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("pvChanged", com.fr3ts0n.pvs.PvChangeEvent.class));
methods[METHOD_pvChanged12].setDisplayName("");
methods[METHOD_remove13] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("remove", Object.class));
methods[METHOD_remove13].setDisplayName("");
methods[METHOD_size14] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("size"));
methods[METHOD_size14].setDisplayName("");
methods[METHOD_toString15] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("toString"));
methods[METHOD_toString15].setDisplayName("");
methods[METHOD_values16] = new MethodDescriptor(com.fr3ts0n.pvs.ProcessVar.class.getMethod("values"));
methods[METHOD_values16].setDisplayName("");
} catch (Exception ignored) {
}
return methods;
</DeepExtract>
} | AndrOBD | positive | 2,519 |
private JavaType getTypeFromModelName(String name) {
final TypeFactory tf = Json.mapper().getTypeFactory();
String modelName = name.replaceAll("^\"|\"$", "");
Class<?> cls;
try {
cls = Class.forName(modelName);
} catch (ClassNotFoundException e) {
cls = null;
}
if (cls != null) {
return tf.constructType(cls);
}
if (config.getModelPackage() != null && !modelName.contains(".")) {
modelName = config.getModelPackage() + "." + modelName;
cls = loadClass(modelName);
if (cls != null) {
return tf.constructType(cls);
}
}
unimplementedMappedModels.add(modelName);
return null;
} | private JavaType getTypeFromModelName(String name) {
final TypeFactory tf = Json.mapper().getTypeFactory();
String modelName = name.replaceAll("^\"|\"$", "");
<DeepExtract>
Class<?> cls;
try {
cls = Class.forName(modelName);
} catch (ClassNotFoundException e) {
cls = null;
}
</DeepExtract>
if (cls != null) {
return tf.constructType(cls);
}
if (config.getModelPackage() != null && !modelName.contains(".")) {
modelName = config.getModelPackage() + "." + modelName;
cls = loadClass(modelName);
if (cls != null) {
return tf.constructType(cls);
}
}
unimplementedMappedModels.add(modelName);
return null;
} | swagger-inflector | positive | 2,520 |
public int i30() {
assert (30 <= 32);
return readInt(30, true);
} | public int i30() {
<DeepExtract>
assert (30 <= 32);
return readInt(30, true);
</DeepExtract>
} | testing-video | positive | 2,523 |
public final Optional<R> asOptionalRight() {
if (isLeft()) {
return val -> Optional.<R>empty().apply(getLeft());
} else {
return Optional::of.apply(getRight());
}
} | public final Optional<R> asOptionalRight() {
<DeepExtract>
if (isLeft()) {
return val -> Optional.<R>empty().apply(getLeft());
} else {
return Optional::of.apply(getRight());
}
</DeepExtract>
} | durian | positive | 2,524 |
private boolean run(String[] args) throws IOException {
long started = System.currentTimeMillis();
if (!init(args)) {
return false;
}
if (!prepare()) {
return false;
}
JobMetadata.Builder metadataBuilder = new JobMetadata.Builder().setId(appIdString).setConf(yarnConf).setStarted(started).setUser(user);
JobMetadata metadata = metadataBuilder.build();
if (!eventHandler.setUpThread(jobDir, metadata)) {
return false;
}
int exitCode = 0;
if (enablePreprocessing || singleNode) {
exitCode = doPreprocessingJob();
}
if (singleNode) {
if (exitCode != 0) {
LOG.info("Single node job exits with " + exitCode + ", exiting.");
session.setFinalStatus(FinalApplicationStatus.FAILED, "Single node training failed..");
} else {
LOG.info("Single node job exits with " + exitCode + ", exiting.");
session.setFinalStatus(FinalApplicationStatus.SUCCEEDED, "Single node job succeeded.");
}
return;
}
if (exitCode != 0) {
return;
}
buildTonySession();
session.setResources(yarnConf, hdfsConf, localResources, containerEnv, hdfsClasspath);
scheduler = new TaskScheduler(session, amRMClient, localResources, resourceFs, tonyConf, jobTypeToContainerResources);
scheduler.scheduleTasks();
amRuntimeAdapter.setTonySession(session);
do {
String shouldCrash = System.getenv(Constants.TEST_AM_CRASH);
if (shouldCrash != null && shouldCrash.equals("true")) {
LOG.fatal("Error running ApplicationMaster !!");
return false;
}
String throwExceptionCrash = System.getenv(Constants.TEST_AM_THROW_EXCEPTION_CRASH);
if (throwExceptionCrash != null && throwExceptionCrash.equals("true")) {
throw new IOException("AM crashed.");
}
try {
eventHandler.emitEvent(new Event(EventType.APPLICATION_INITED, new ApplicationInited(appIdString, Utils.getNumTotalTasks(tonyConf), Utils.getCurrentHostName(), this.containerId.toString()), System.currentTimeMillis()));
start();
} catch (Exception e) {
LOG.error("Exception when we're starting TonyAM", e);
return false;
}
succeeded = monitor();
if (succeeded || amRetryCount == 0) {
LOG.info("Result: " + succeeded + ", retry count: " + amRetryCount);
break;
}
reset();
LOG.info("Retrying, remaining retry count" + amRetryCount);
amRetryCount -= 1;
numAMRetries += 1;
containerEnv.put(Constants.NUM_AM_RETRIES, Integer.toString(numAMRetries));
} while (!singleNode);
stopRunningContainers();
FinalApplicationStatus status = session.getFinalStatus();
String appMessage = session.getFinalMessage();
try {
amRMClient.unregisterApplicationMaster(status, appMessage, null);
} catch (YarnException | IOException e) {
LOG.error("Failed to unregister application", e);
}
amRuntimeAdapter.destroy();
nmClientAsync.stop();
amRMClient.stop();
boolean result = Utils.poll(() -> clientSignalToStop, 1, waitingClientSignalStopTimeout);
if (!result) {
LOG.warn("TonyClient didn't signal Tony AM to stop.");
}
long completed = System.currentTimeMillis();
if (session != null) {
session.getTonyTasks().values().stream().flatMap(Arrays::stream).forEach(task -> {
if (task != null) {
Utils.printTaskUrl(task.getTaskInfo(), LOG);
}
});
}
eventHandler.emitEvent(new Event(EventType.APPLICATION_FINISHED, new ApplicationFinished(appIdString, session.getNumCompletedTasks(), session.getNumFailedTasks(), new ArrayList<>()), System.currentTimeMillis()));
metadata = metadataBuilder.setCompleted(completed).setStatus(succeeded ? Constants.SUCCEEDED : Constants.FAILED).build();
eventHandler.stop(jobDir, metadata);
return succeeded;
} | private boolean run(String[] args) throws IOException {
long started = System.currentTimeMillis();
if (!init(args)) {
return false;
}
if (!prepare()) {
return false;
}
JobMetadata.Builder metadataBuilder = new JobMetadata.Builder().setId(appIdString).setConf(yarnConf).setStarted(started).setUser(user);
JobMetadata metadata = metadataBuilder.build();
if (!eventHandler.setUpThread(jobDir, metadata)) {
return false;
}
int exitCode = 0;
if (enablePreprocessing || singleNode) {
exitCode = doPreprocessingJob();
}
if (singleNode) {
if (exitCode != 0) {
LOG.info("Single node job exits with " + exitCode + ", exiting.");
session.setFinalStatus(FinalApplicationStatus.FAILED, "Single node training failed..");
} else {
LOG.info("Single node job exits with " + exitCode + ", exiting.");
session.setFinalStatus(FinalApplicationStatus.SUCCEEDED, "Single node job succeeded.");
}
return;
}
if (exitCode != 0) {
return;
}
buildTonySession();
session.setResources(yarnConf, hdfsConf, localResources, containerEnv, hdfsClasspath);
scheduler = new TaskScheduler(session, amRMClient, localResources, resourceFs, tonyConf, jobTypeToContainerResources);
scheduler.scheduleTasks();
amRuntimeAdapter.setTonySession(session);
do {
String shouldCrash = System.getenv(Constants.TEST_AM_CRASH);
if (shouldCrash != null && shouldCrash.equals("true")) {
LOG.fatal("Error running ApplicationMaster !!");
return false;
}
String throwExceptionCrash = System.getenv(Constants.TEST_AM_THROW_EXCEPTION_CRASH);
if (throwExceptionCrash != null && throwExceptionCrash.equals("true")) {
throw new IOException("AM crashed.");
}
try {
eventHandler.emitEvent(new Event(EventType.APPLICATION_INITED, new ApplicationInited(appIdString, Utils.getNumTotalTasks(tonyConf), Utils.getCurrentHostName(), this.containerId.toString()), System.currentTimeMillis()));
start();
} catch (Exception e) {
LOG.error("Exception when we're starting TonyAM", e);
return false;
}
succeeded = monitor();
if (succeeded || amRetryCount == 0) {
LOG.info("Result: " + succeeded + ", retry count: " + amRetryCount);
break;
}
reset();
LOG.info("Retrying, remaining retry count" + amRetryCount);
amRetryCount -= 1;
numAMRetries += 1;
containerEnv.put(Constants.NUM_AM_RETRIES, Integer.toString(numAMRetries));
} while (!singleNode);
stopRunningContainers();
FinalApplicationStatus status = session.getFinalStatus();
String appMessage = session.getFinalMessage();
try {
amRMClient.unregisterApplicationMaster(status, appMessage, null);
} catch (YarnException | IOException e) {
LOG.error("Failed to unregister application", e);
}
amRuntimeAdapter.destroy();
nmClientAsync.stop();
amRMClient.stop();
boolean result = Utils.poll(() -> clientSignalToStop, 1, waitingClientSignalStopTimeout);
if (!result) {
LOG.warn("TonyClient didn't signal Tony AM to stop.");
}
long completed = System.currentTimeMillis();
<DeepExtract>
if (session != null) {
session.getTonyTasks().values().stream().flatMap(Arrays::stream).forEach(task -> {
if (task != null) {
Utils.printTaskUrl(task.getTaskInfo(), LOG);
}
});
}
</DeepExtract>
eventHandler.emitEvent(new Event(EventType.APPLICATION_FINISHED, new ApplicationFinished(appIdString, session.getNumCompletedTasks(), session.getNumFailedTasks(), new ArrayList<>()), System.currentTimeMillis()));
metadata = metadataBuilder.setCompleted(completed).setStatus(succeeded ? Constants.SUCCEEDED : Constants.FAILED).build();
eventHandler.stop(jobDir, metadata);
return succeeded;
} | TonY | positive | 2,525 |
@Test
public void testMakePositionMessage() throws IOException {
PrintWriter fastqOut = new PrintWriter(new BufferedWriter(new FileWriter(tempFastq)));
fastqOut.write(fastqWithIdTwice);
fastqOut.close();
split = new FileSplit(new Path(tempFastq.toURI().toString()), 0, fastqWithIdTwice.length(), null);
FastqRecordReader reader = new FastqRecordReader(conf, split);
assertNotNull(reader.makePositionMessage());
} | @Test
public void testMakePositionMessage() throws IOException {
<DeepExtract>
PrintWriter fastqOut = new PrintWriter(new BufferedWriter(new FileWriter(tempFastq)));
fastqOut.write(fastqWithIdTwice);
fastqOut.close();
</DeepExtract>
split = new FileSplit(new Path(tempFastq.toURI().toString()), 0, fastqWithIdTwice.length(), null);
FastqRecordReader reader = new FastqRecordReader(conf, split);
assertNotNull(reader.makePositionMessage());
} | Hadoop-BAM | positive | 2,526 |
private void showSendRoute(byte saveKind) {
System.gc();
MapForms.saveKind = saveKind;
formSaveTrack = null;
if (formSaveTrack == null) {
textTrackSavePath = null;
choiceCP_S = null;
choiceOX_S = null;
choiceExpCount = null;
formSaveTrack = new Form(LangHolder.getString(Lang.export), new Item[] { getTextTrackSavePath(), getChoiceCP_S(), getChoiceOX_S(), getChoiceExpCount() });
formSaveTrack.addCommand(getItem1Save());
formSaveTrack.addCommand(getBack2Opt());
formSaveTrack.addCommand(getItemBrowseMap());
formSaveTrack.setCommandListener(this);
}
return formSaveTrack;
choiceCP_S.setSelectedIndex(RMSOption.routeCP, true);
choiceOX_S.setSelectedIndex(RMSOption.routeFormat, true);
formSaveTrack.delete(3);
formSaveTrack.delete(0);
formSaveTrack.removeCommand(itemBrowseMap);
getDisplay().setCurrent(formSaveTrack);
} | private void showSendRoute(byte saveKind) {
System.gc();
MapForms.saveKind = saveKind;
formSaveTrack = null;
<DeepExtract>
if (formSaveTrack == null) {
textTrackSavePath = null;
choiceCP_S = null;
choiceOX_S = null;
choiceExpCount = null;
formSaveTrack = new Form(LangHolder.getString(Lang.export), new Item[] { getTextTrackSavePath(), getChoiceCP_S(), getChoiceOX_S(), getChoiceExpCount() });
formSaveTrack.addCommand(getItem1Save());
formSaveTrack.addCommand(getBack2Opt());
formSaveTrack.addCommand(getItemBrowseMap());
formSaveTrack.setCommandListener(this);
}
return formSaveTrack;
</DeepExtract>
choiceCP_S.setSelectedIndex(RMSOption.routeCP, true);
choiceOX_S.setSelectedIndex(RMSOption.routeFormat, true);
formSaveTrack.delete(3);
formSaveTrack.delete(0);
formSaveTrack.removeCommand(itemBrowseMap);
getDisplay().setCurrent(formSaveTrack);
} | MapNav | positive | 2,527 |
public static void pong(Context context) {
if (isDestroyed(context) || isStopped(context)) {
return;
}
Intent serviceIntent = new Intent(context, CIMPushService.class);
serviceIntent.setAction(ServiceAction.ACTION_CIM_CONNECTION_PONG);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
context.startService(serviceIntent);
return;
}
try {
context.startForegroundService(serviceIntent);
} catch (Exception ignore) {
context.sendBroadcast(new Intent(IntentAction.ACTION_CONNECTION_RECOVERY));
}
} | public static void pong(Context context) {
if (isDestroyed(context) || isStopped(context)) {
return;
}
Intent serviceIntent = new Intent(context, CIMPushService.class);
serviceIntent.setAction(ServiceAction.ACTION_CIM_CONNECTION_PONG);
<DeepExtract>
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
context.startService(serviceIntent);
return;
}
try {
context.startForegroundService(serviceIntent);
} catch (Exception ignore) {
context.sendBroadcast(new Intent(IntentAction.ACTION_CONNECTION_RECOVERY));
}
</DeepExtract>
} | cim | positive | 2,528 |
@Override
public void connect() throws NameNotResolvedException, KcpcliParseException {
super.connect();
proxychains_enable = new File(getApplicationInfo().dataDir + "/proxychains.conf").exists();
try {
List<String> tempList = new ArrayList<>(Arrays.asList(profile.dns.split(",")));
Collections.shuffle(tempList);
String dns = tempList.get(0);
dns_address = dns.split(":")[0];
dns_port = Integer.parseInt(dns.split(":")[1]);
tempList.clear();
tempList = Arrays.asList(profile.china_dns.split(","));
Collections.shuffle(tempList);
String china_dns = tempList.get(0);
china_dns_address = china_dns.split(":")[0];
china_dns_port = Integer.parseInt(china_dns.split(":")[1]);
} catch (Exception e) {
dns_address = "8.8.8.8";
dns_port = 53;
china_dns_address = "223.5.5.5";
china_dns_port = 53;
}
vpnThread = new ShadowsocksVpnThread(this);
vpnThread.start();
if (sslocalProcess != null) {
sslocalProcess.destroy();
sslocalProcess = null;
}
if (sstunnelProcess != null) {
sstunnelProcess.destroy();
sstunnelProcess = null;
}
if (tun2socksProcess != null) {
tun2socksProcess.destroy();
tun2socksProcess = null;
}
if (pdnsdProcess != null) {
pdnsdProcess.destroy();
pdnsdProcess = null;
}
host_arg = profile.host;
if (!Utils.isNumeric(profile.host)) {
String addr = Utils.resolve(profile.host, profile.ipv6);
if (TextUtils.isEmpty(addr)) {
throw new NameNotResolvedException();
} else {
profile.host = addr;
}
}
try {
handleConnection();
} catch (Exception e) {
e.printStackTrace();
}
changeState(Constants.State.CONNECTED);
if (!Constants.Route.ALL.equals(profile.route)) {
AclSyncJob.schedule(profile.route);
}
notification = new ShadowsocksNotification(this, profile.name);
} | @Override
public void connect() throws NameNotResolvedException, KcpcliParseException {
super.connect();
proxychains_enable = new File(getApplicationInfo().dataDir + "/proxychains.conf").exists();
try {
List<String> tempList = new ArrayList<>(Arrays.asList(profile.dns.split(",")));
Collections.shuffle(tempList);
String dns = tempList.get(0);
dns_address = dns.split(":")[0];
dns_port = Integer.parseInt(dns.split(":")[1]);
tempList.clear();
tempList = Arrays.asList(profile.china_dns.split(","));
Collections.shuffle(tempList);
String china_dns = tempList.get(0);
china_dns_address = china_dns.split(":")[0];
china_dns_port = Integer.parseInt(china_dns.split(":")[1]);
} catch (Exception e) {
dns_address = "8.8.8.8";
dns_port = 53;
china_dns_address = "223.5.5.5";
china_dns_port = 53;
}
vpnThread = new ShadowsocksVpnThread(this);
vpnThread.start();
<DeepExtract>
if (sslocalProcess != null) {
sslocalProcess.destroy();
sslocalProcess = null;
}
if (sstunnelProcess != null) {
sstunnelProcess.destroy();
sstunnelProcess = null;
}
if (tun2socksProcess != null) {
tun2socksProcess.destroy();
tun2socksProcess = null;
}
if (pdnsdProcess != null) {
pdnsdProcess.destroy();
pdnsdProcess = null;
}
</DeepExtract>
host_arg = profile.host;
if (!Utils.isNumeric(profile.host)) {
String addr = Utils.resolve(profile.host, profile.ipv6);
if (TextUtils.isEmpty(addr)) {
throw new NameNotResolvedException();
} else {
profile.host = addr;
}
}
try {
handleConnection();
} catch (Exception e) {
e.printStackTrace();
}
changeState(Constants.State.CONNECTED);
if (!Constants.Route.ALL.equals(profile.route)) {
AclSyncJob.schedule(profile.route);
}
notification = new ShadowsocksNotification(this, profile.name);
} | Maying | positive | 2,529 |
public void setScale(float scale) {
this.cam_zoom = scale;
Rectangle2D.Float rect = new Rectangle2D.Float(0, 0, 16f / cam_zoom, 16f / cam_zoom);
paintLight = new TexturePaint(backgroundLight, rect);
paintDark = new TexturePaint(backgroundDark, rect);
this.repaint();
Spade.main.gui.checkDynamicInfo();
} | public void setScale(float scale) {
this.cam_zoom = scale;
<DeepExtract>
Rectangle2D.Float rect = new Rectangle2D.Float(0, 0, 16f / cam_zoom, 16f / cam_zoom);
paintLight = new TexturePaint(backgroundLight, rect);
paintDark = new TexturePaint(backgroundDark, rect);
</DeepExtract>
this.repaint();
Spade.main.gui.checkDynamicInfo();
} | Spade | positive | 2,530 |
private void setAllowed(Address address1, Address address2, BigInteger value) {
require(value != null && value.compareTo(BigInteger.ZERO) >= 0);
Map<Address, BigInteger> address1Allowed = allowed.get(address1);
if (address1Allowed == null) {
address1Allowed = new HashMap<Address, BigInteger>();
allowed.put(address1, address1Allowed);
}
address1Allowed.put(address2, value);
} | private void setAllowed(Address address1, Address address2, BigInteger value) {
<DeepExtract>
require(value != null && value.compareTo(BigInteger.ZERO) >= 0);
</DeepExtract>
Map<Address, BigInteger> address1Allowed = allowed.get(address1);
if (address1Allowed == null) {
address1Allowed = new HashMap<Address, BigInteger>();
allowed.put(address1, address1Allowed);
}
address1Allowed.put(address2, value);
} | nuls-contracts | positive | 2,531 |
public void setFTPUploadAlways(boolean always) {
preferences.ftpUploadAlways = always;
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(preferences);
try {
locations.getPreferencesFile().mkdirs();
FileReader.writeFile(locations.getPreferencesFile().getAbsolutePath(), json);
} catch (FileNotFoundException e) {
Logger.Log(e);
e.printStackTrace();
}
} | public void setFTPUploadAlways(boolean always) {
preferences.ftpUploadAlways = always;
<DeepExtract>
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(preferences);
try {
locations.getPreferencesFile().mkdirs();
FileReader.writeFile(locations.getPreferencesFile().getAbsolutePath(), json);
} catch (FileNotFoundException e) {
Logger.Log(e);
e.printStackTrace();
}
</DeepExtract>
} | SnippingToolPlusPlus | positive | 2,533 |
public static java.util.Date getEndDayOfYear() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, getNowYear());
cal.set(Calendar.MONTH, Calendar.DECEMBER);
cal.set(Calendar.DATE, 31);
Calendar calendar = Calendar.getInstance();
if (null != cal.getTime())
calendar.setTime(cal.getTime());
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
calendar.set(Calendar.MILLISECOND, 999);
return new Timestamp(calendar.getTimeInMillis());
} | public static java.util.Date getEndDayOfYear() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, getNowYear());
cal.set(Calendar.MONTH, Calendar.DECEMBER);
cal.set(Calendar.DATE, 31);
<DeepExtract>
Calendar calendar = Calendar.getInstance();
if (null != cal.getTime())
calendar.setTime(cal.getTime());
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
calendar.set(Calendar.MILLISECOND, 999);
return new Timestamp(calendar.getTimeInMillis());
</DeepExtract>
} | bill | positive | 2,534 |
public static <T extends KeyValueStorage<T>> T getKeyValueStorage(Class<T> type) {
if (app == null) {
throw new IllegalStateException("UIO not inited, please add init code in your application onCreate method!!");
}
return Ext.storage.getKeyValueStroage(type, Ext.app);
} | public static <T extends KeyValueStorage<T>> T getKeyValueStorage(Class<T> type) {
<DeepExtract>
if (app == null) {
throw new IllegalStateException("UIO not inited, please add init code in your application onCreate method!!");
}
</DeepExtract>
return Ext.storage.getKeyValueStroage(type, Ext.app);
} | AndroidUIO | positive | 2,535 |
private void initLeanCloud() {
AVOSCloud.initialize(this, BuildConfig.LEANCLOUD_APP_ID, BuildConfig.LEANCLOUD_APP_KEY);
AVInstallation.getCurrentInstallation().saveInBackground();
PushService.setDefaultPushCallback(this, HomeActivity.class);
AVAnalytics.enableCrashReport(this, true);
boolean enableNotification = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.pref_allow_new_program_notification), true);
Timber.d("setNotification:%s", String.valueOf(enableNotification));
if (enableNotification) {
PushService.subscribe(this, Constants.CHANNEL_NEW_PROGRAM, HomeActivity.class);
} else {
PushService.unsubscribe(this, Constants.CHANNEL_NEW_PROGRAM);
}
} | private void initLeanCloud() {
AVOSCloud.initialize(this, BuildConfig.LEANCLOUD_APP_ID, BuildConfig.LEANCLOUD_APP_KEY);
AVInstallation.getCurrentInstallation().saveInBackground();
PushService.setDefaultPushCallback(this, HomeActivity.class);
AVAnalytics.enableCrashReport(this, true);
<DeepExtract>
boolean enableNotification = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.pref_allow_new_program_notification), true);
Timber.d("setNotification:%s", String.valueOf(enableNotification));
if (enableNotification) {
PushService.subscribe(this, Constants.CHANNEL_NEW_PROGRAM, HomeActivity.class);
} else {
PushService.unsubscribe(this, Constants.CHANNEL_NEW_PROGRAM);
}
</DeepExtract>
} | Sky31Radio | positive | 2,536 |
@Override
public void run() {
textDeviceLevel.setText(R.string.no_valid_dba_value);
textStatus.setText(getString(R.string.calibration_status_waiting_for_start_timer));
try {
switch(viewPager.getCurrentItem()) {
case PAGE_SCATTER_CHART:
updateScatterChart();
break;
case PAGE_LINE_CHART:
updateLineChart();
break;
case PAGE_BAR_CHART:
updateBarChart();
break;
}
} catch (NullPointerException ex) {
LOGGER.error(ex.getLocalizedMessage(), ex);
}
} | @Override
public void run() {
textDeviceLevel.setText(R.string.no_valid_dba_value);
textStatus.setText(getString(R.string.calibration_status_waiting_for_start_timer));
<DeepExtract>
try {
switch(viewPager.getCurrentItem()) {
case PAGE_SCATTER_CHART:
updateScatterChart();
break;
case PAGE_LINE_CHART:
updateLineChart();
break;
case PAGE_BAR_CHART:
updateBarChart();
break;
}
} catch (NullPointerException ex) {
LOGGER.error(ex.getLocalizedMessage(), ex);
}
</DeepExtract>
} | NoiseCapture | positive | 2,537 |
@Override
public void beginObject(String name) {
closeTag();
append("<");
append(name);
inTag = true;
} | @Override
public void beginObject(String name) {
<DeepExtract>
closeTag();
append("<");
append(name);
inTag = true;
</DeepExtract>
} | amazon-mws-orders | positive | 2,538 |
public static VectorStoreRAM readFromFile(FlagConfig flagConfig, String vectorFile) throws IOException {
if (vectorFile.isEmpty()) {
throw new IllegalArgumentException("vectorFile argument cannot be empty.");
}
VectorStoreRAM store = new VectorStoreRAM(flagConfig);
CloseableVectorStore vectorReaderDisk = VectorStoreReader.openVectorStore(vectorFile, flagConfig);
Enumeration<ObjectVector> vectorEnumeration = vectorReaderDisk.getAllVectors();
logger.fine("Reading vectors from store on disk into memory cache ...");
while (vectorEnumeration.hasMoreElements()) {
ObjectVector objectVector = vectorEnumeration.nextElement();
this.objectVectors.put(objectVector.getObject().toString(), objectVector);
}
vectorReaderDisk.close();
logger.log(Level.FINE, "Cached {0} vectors.", objectVectors.size());
return store;
} | public static VectorStoreRAM readFromFile(FlagConfig flagConfig, String vectorFile) throws IOException {
if (vectorFile.isEmpty()) {
throw new IllegalArgumentException("vectorFile argument cannot be empty.");
}
VectorStoreRAM store = new VectorStoreRAM(flagConfig);
<DeepExtract>
CloseableVectorStore vectorReaderDisk = VectorStoreReader.openVectorStore(vectorFile, flagConfig);
Enumeration<ObjectVector> vectorEnumeration = vectorReaderDisk.getAllVectors();
logger.fine("Reading vectors from store on disk into memory cache ...");
while (vectorEnumeration.hasMoreElements()) {
ObjectVector objectVector = vectorEnumeration.nextElement();
this.objectVectors.put(objectVector.getObject().toString(), objectVector);
}
vectorReaderDisk.close();
logger.log(Level.FINE, "Cached {0} vectors.", objectVectors.size());
</DeepExtract>
return store;
} | semanticvectors | positive | 2,539 |
@Override
public Multimap<Scope, String> getFromFile(final File f) throws IOException {
final VariableScopeFinder scopeFinder = new VariableScopeFinder();
f.accept(scopeFinder);
final Multimap<Scope, String> scopes = TreeMultimap.create();
for (final Entry<ASTNode, Variable> variable : scopeFinder.variableScopes.entries()) {
final int astNodeType = variable.getKey().getNodeType();
final int astNodeParentType;
if (variable.getKey().getParent() == null) {
astNodeParentType = -1;
} else {
astNodeParentType = variable.getKey().getParent().getNodeType();
}
scopes.put(new Scope(variable.getKey().toString(), variable.getValue().scope, variable.getValue().type, astNodeType, astNodeParentType), variable.getValue().name);
}
return scopes;
} | @Override
public Multimap<Scope, String> getFromFile(final File f) throws IOException {
<DeepExtract>
final VariableScopeFinder scopeFinder = new VariableScopeFinder();
f.accept(scopeFinder);
final Multimap<Scope, String> scopes = TreeMultimap.create();
for (final Entry<ASTNode, Variable> variable : scopeFinder.variableScopes.entries()) {
final int astNodeType = variable.getKey().getNodeType();
final int astNodeParentType;
if (variable.getKey().getParent() == null) {
astNodeParentType = -1;
} else {
astNodeParentType = variable.getKey().getParent().getNodeType();
}
scopes.put(new Scope(variable.getKey().toString(), variable.getValue().scope, variable.getValue().type, astNodeType, astNodeParentType), variable.getValue().name);
}
return scopes;
</DeepExtract>
} | codemining-core | positive | 2,540 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.