blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2
values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 132
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 9.45M | extension stringclasses 28
values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 352 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
201254d409467cbf9b31436f5f62606b909e2387 | fe21f72e09cad8631415547d943a95739bf0d1fd | /library/powersdk/src/main/java/com/powervision/powersdk/callback/RemoteControlCallback.java | 25369f9e0e5c870dfa4f8cc4b55c977293f10f1e | [] | no_license | jjw1989/CommonTruss | 9b04e1c693fb9a8909bd4910fd3d8d314114c1c7 | 5685f11c7c3aab24b6e4bf32a89d391068469773 | refs/heads/master | 2021-01-01T19:09:33.788695 | 2017-09-28T08:31:25 | 2017-09-28T08:31:25 | 98,527,784 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,864 | java | package com.powervision.powersdk.callback;
import com.powervision.powersdk.param.ManualControlDateNotifyParam;
import com.powervision.powersdk.param.MountControlDateNotifyParam;
import com.powervision.powersdk.param.RemoteControlLocationNotifyParam;
/**
* 遥控器相关
*/
public class RemoteControlCallback {
/**
* Default constructor
*/
public RemoteControlCallback() {
}
/**
* 设置,获取遥控器参数回调
*/
public interface RemoteControlParamListener {
/**
* @param paramID
* @return
*/
public void onRemoteControlSetSuccess(String paramID);
/**
* @param paramID
* @return
*/
public void onRemoteControlSetTimeout(String paramID);
/**
* @param paramID
* @return
*/
public void onRemoteControlGetSuccess(String paramID);
/**
* @param paramID
* @return
*/
public void onRemoteControlGetTimeout(String paramID);
}
/**
* 遥控器固件升级结果
*/
public interface FirmwareUpgradeListener {
/**
*
*/
public static final int PVSDK_FIRMWAREUPGRADE_CALLBACK_STATUS_FAILED = -1;
/**
*
*/
public static final int PVSDK_FIRMWAREUPGRADE_CALLBACK_STATUS_SUCCESS = 0;
/**
*
*/
public static final int PVSDK_FIRMWAREUPGRADE_CALLBACK_STATUS_UPGRADING = 1;
/**
* 升级成功
*/
public void onFirmwareUpgradeSuccess();
/**
* 升级中
*
* @param progress 上传固件进度 0-100
*/
public void onFirmwareUpgradeProcessing(int progress);
/**
* 升级失败
*/
public void onFirmwareUpgradeFailed();
}
/**
* 遥控器校准回调
*/
public interface RemoteControlCalibrateListener {
/**
*
*/
public static final int PVSDK_REMOTECONTROLCALIBRATE_CALLBACK_INFO_CALIBRATE_SUCCESS = 0;
/**
*
*/
public static final int PVSDK_REMOTECONTROLCALIBRATE_CALLBACK_INFO_CALIBRATE_FAILED = 1;
/**
*
*/
public static final int PVSDK_REMOTECONTROLCALIBRATE_CALLBACK_INFO_COMPLETE_SUCCESS = 2;
/**
*
*/
public static final int PVSDK_REMOTECONTROLCALIBRATE_CALLBACK_INFO_COMPLETE_FAILED = 3;
/**
* 校准成功
*/
public void onRemoteControlCalibrateSuccess();
/**
* 校准失败
*/
public void onRemoteControlCalibrateFailed();
/**
* 校准完成成功
*/
public void onRemoteControlCompleteSuccess();
/**
* 校准完成失败
*/
public void onRemoteControlCompleteFailed();
}
/**
* 遥控器信息
*/
public interface ManualControlDataListener {
/**
* 遥控器信息数据
*
* @param data 遥控器数据
*/
public void onManualControlDataReceived(ManualControlDateNotifyParam data);
}
/**
* 遥控器拨轮数据
*/
public interface MountControlDataListener {
/**
* 遥控器拨轮数据接收回调
*
* @param data
* @return
*/
public void onMountControlDataReceived(MountControlDateNotifyParam data);
}
/**
* 遥控器位置
*/
public interface RemoteControlLocationListener {
/**
* 遥控器位置
*
* @param param
* @return
*/
public void onRemoteControlLocation(RemoteControlLocationNotifyParam param);
}
} | [
"2436668590@qq.com"
] | 2436668590@qq.com |
99ac879549fb19e91c078e9dfc4f91ec510e3545 | 7592d4f866aec2ce6724eea8a2ef256b9f8ee2ba | /chorDataModel/src/main/java/org/eclipse/bpel4chor/model/globalDataModel/DataMappings.java | 1ce129adaa06ad39ac830aeee0e330d37ec0fc7d | [
"MIT"
] | permissive | chorsystem/middleware | 831a55c92c41ac726fc0c3ecc556f1a20848132e | 6d1768c5ee3f1555ffea6c2ac566a70430fdc8ba | refs/heads/master | 2021-01-20T19:33:49.903074 | 2018-01-09T19:46:47 | 2018-01-09T19:46:47 | 63,236,713 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,383 | java | /**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.eclipse.bpel4chor.model.globalDataModel;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Data Mappings</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link org.eclipse.bpel4chor.model.globalDataModel.DataMappings#getDataMapping <em>Data Mapping</em>}</li>
* </ul>
* </p>
*
* @see org.eclipse.bpel4chor.model.globalDataModel.GlobalDataModelPackage#getDataMappings()
* @model
* @generated
*/
public interface DataMappings extends EObject {
/**
* Returns the value of the '<em><b>Data Mapping</b></em>' containment reference list.
* The list contents are of type {@link org.eclipse.bpel4chor.model.globalDataModel.DataMapping}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Data Mapping</em>' containment reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Data Mapping</em>' containment reference list.
* @see org.eclipse.bpel4chor.model.globalDataModel.GlobalDataModelPackage#getDataMappings_DataMapping()
* @model containment="true"
* @generated
*/
EList<DataMapping> getDataMapping();
} // DataMappings
| [
"andreas1.weiss@googlemail.com"
] | andreas1.weiss@googlemail.com |
15c8f90695a36043f27ee97da85ad8fdaeb6120f | 261834f32e8103c8b9aa338cae005920abb7c972 | /client and cache/client/src/com/osps/client/map/Class11.java | dd35878d173d698fdbbef7cb2452b12187011536 | [] | no_license | samspeake/Pkers.ca | 4c326a1b0c499793dc25e25d1f6a87e123f038cb | 5c014fe5efcac87a0f261eee6f9bb0a937ed55c6 | refs/heads/master | 2020-03-08T07:13:24.052257 | 2018-04-19T00:28:11 | 2018-04-19T00:28:11 | 127,989,194 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 12,267 | java | package com.osps.client.map;
// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
public final class Class11
{
public Class11()
{
anInt290 = 0;
anInt291 = 0;
anInt292 = 104;
anInt293 = 104;
anIntArrayArray294 = new int[anInt292][anInt293];
method210();
}
public void method210()
{
for(int i = 0; i < anInt292; i++)
{
for(int j = 0; j < anInt293; j++)
if(i == 0 || j == 0 || i == anInt292 - 1 || j == anInt293 - 1)
anIntArrayArray294[i][j] = 0xffffff;
else
anIntArrayArray294[i][j] = 0x1000000;
}
}
public void method211(int i, int j, int k, int l, boolean flag)
{
k -= anInt290;
i -= anInt291;
if(l == 0)
{
if(j == 0)
{
method214(k, i, 128);
method214(k - 1, i, 8);
}
if(j == 1)
{
method214(k, i, 2);
method214(k, i + 1, 32);
}
if(j == 2)
{
method214(k, i, 8);
method214(k + 1, i, 128);
}
if(j == 3)
{
method214(k, i, 32);
method214(k, i - 1, 2);
}
}
if(l == 1 || l == 3)
{
if(j == 0)
{
method214(k, i, 1);
method214(k - 1, i + 1, 16);
}
if(j == 1)
{
method214(k, i, 4);
method214(k + 1, i + 1, 64);
}
if(j == 2)
{
method214(k, i, 16);
method214(k + 1, i - 1, 1);
}
if(j == 3)
{
method214(k, i, 64);
method214(k - 1, i - 1, 4);
}
}
if(l == 2)
{
if(j == 0)
{
method214(k, i, 130);
method214(k - 1, i, 8);
method214(k, i + 1, 32);
}
if(j == 1)
{
method214(k, i, 10);
method214(k, i + 1, 32);
method214(k + 1, i, 128);
}
if(j == 2)
{
method214(k, i, 40);
method214(k + 1, i, 128);
method214(k, i - 1, 2);
}
if(j == 3)
{
method214(k, i, 160);
method214(k, i - 1, 2);
method214(k - 1, i, 8);
}
}
if(flag)
{
if(l == 0)
{
if(j == 0)
{
method214(k, i, 0x10000);
method214(k - 1, i, 4096);
}
if(j == 1)
{
method214(k, i, 1024);
method214(k, i + 1, 16384);
}
if(j == 2)
{
method214(k, i, 4096);
method214(k + 1, i, 0x10000);
}
if(j == 3)
{
method214(k, i, 16384);
method214(k, i - 1, 1024);
}
}
if(l == 1 || l == 3)
{
if(j == 0)
{
method214(k, i, 512);
method214(k - 1, i + 1, 8192);
}
if(j == 1)
{
method214(k, i, 2048);
method214(k + 1, i + 1, 32768);
}
if(j == 2)
{
method214(k, i, 8192);
method214(k + 1, i - 1, 512);
}
if(j == 3)
{
method214(k, i, 32768);
method214(k - 1, i - 1, 2048);
}
}
if(l == 2)
{
if(j == 0)
{
method214(k, i, 0x10400);
method214(k - 1, i, 4096);
method214(k, i + 1, 16384);
}
if(j == 1)
{
method214(k, i, 5120);
method214(k, i + 1, 16384);
method214(k + 1, i, 0x10000);
}
if(j == 2)
{
method214(k, i, 20480);
method214(k + 1, i, 0x10000);
method214(k, i - 1, 1024);
}
if(j == 3)
{
method214(k, i, 0x14000);
method214(k, i - 1, 1024);
method214(k - 1, i, 4096);
}
}
}
}
public void method212(boolean flag, int j, int k, int l, int i1, int j1)
{
int k1 = 256;
if(flag)
k1 += 0x20000;
l -= anInt290;
i1 -= anInt291;
if(j1 == 1 || j1 == 3)
{
int l1 = j;
j = k;
k = l1;
}
for(int i2 = l; i2 < l + j; i2++)
if(i2 >= 0 && i2 < anInt292)
{
for(int j2 = i1; j2 < i1 + k; j2++)
if(j2 >= 0 && j2 < anInt293)
method214(i2, j2, k1);
}
}
public void method213(int i, int k)
{
k -= anInt290;
i -= anInt291;
anIntArrayArray294[k][i] |= 0x200000;
}
private void method214(int i, int j, int k)
{
anIntArrayArray294[i][j] |= k;
}
public void method215(int i, int j, boolean flag, int k, int l)
{
k -= anInt290;
l -= anInt291;
if(j == 0)
{
if(i == 0)
{
method217(128, k, l);
method217(8, k - 1, l);
}
if(i == 1)
{
method217(2, k, l);
method217(32, k, l + 1);
}
if(i == 2)
{
method217(8, k, l);
method217(128, k + 1, l);
}
if(i == 3)
{
method217(32, k, l);
method217(2, k, l - 1);
}
}
if(j == 1 || j == 3)
{
if(i == 0)
{
method217(1, k, l);
method217(16, k - 1, l + 1);
}
if(i == 1)
{
method217(4, k, l);
method217(64, k + 1, l + 1);
}
if(i == 2)
{
method217(16, k, l);
method217(1, k + 1, l - 1);
}
if(i == 3)
{
method217(64, k, l);
method217(4, k - 1, l - 1);
}
}
if(j == 2)
{
if(i == 0)
{
method217(130, k, l);
method217(8, k - 1, l);
method217(32, k, l + 1);
}
if(i == 1)
{
method217(10, k, l);
method217(32, k, l + 1);
method217(128, k + 1, l);
}
if(i == 2)
{
method217(40, k, l);
method217(128, k + 1, l);
method217(2, k, l - 1);
}
if(i == 3)
{
method217(160, k, l);
method217(2, k, l - 1);
method217(8, k - 1, l);
}
}
if(flag)
{
if(j == 0)
{
if(i == 0)
{
method217(0x10000, k, l);
method217(4096, k - 1, l);
}
if(i == 1)
{
method217(1024, k, l);
method217(16384, k, l + 1);
}
if(i == 2)
{
method217(4096, k, l);
method217(0x10000, k + 1, l);
}
if(i == 3)
{
method217(16384, k, l);
method217(1024, k, l - 1);
}
}
if(j == 1 || j == 3)
{
if(i == 0)
{
method217(512, k, l);
method217(8192, k - 1, l + 1);
}
if(i == 1)
{
method217(2048, k, l);
method217(32768, k + 1, l + 1);
}
if(i == 2)
{
method217(8192, k, l);
method217(512, k + 1, l - 1);
}
if(i == 3)
{
method217(32768, k, l);
method217(2048, k - 1, l - 1);
}
}
if(j == 2)
{
if(i == 0)
{
method217(0x10400, k, l);
method217(4096, k - 1, l);
method217(16384, k, l + 1);
}
if(i == 1)
{
method217(5120, k, l);
method217(16384, k, l + 1);
method217(0x10000, k + 1, l);
}
if(i == 2)
{
method217(20480, k, l);
method217(0x10000, k + 1, l);
method217(1024, k, l - 1);
}
if(i == 3)
{
method217(0x14000, k, l);
method217(1024, k, l - 1);
method217(4096, k - 1, l);
}
}
}
}
public void method216(int i, int j, int k, int l, int i1, boolean flag)
{
int j1 = 256;
if(flag)
j1 += 0x20000;
k -= anInt290;
l -= anInt291;
if(i == 1 || i == 3)
{
int k1 = j;
j = i1;
i1 = k1;
}
for(int l1 = k; l1 < k + j; l1++)
if(l1 >= 0 && l1 < anInt292)
{
for(int i2 = l; i2 < l + i1; i2++)
if(i2 >= 0 && i2 < anInt293)
method217(j1, l1, i2);
}
}
private void method217(int i, int j, int k)
{
anIntArrayArray294[j][k] &= 0xffffff - i;
}
public void method218(int j, int k)
{
k -= anInt290;
j -= anInt291;
anIntArrayArray294[k][j] &= 0xdfffff;
}
public boolean method219(int i, int j, int k, int i1, int j1, int k1)
{
if(j == i && k == k1)
return true;
j -= anInt290;
k -= anInt291;
i -= anInt290;
k1 -= anInt291;
if(j1 == 0)
if(i1 == 0)
{
if(j == i - 1 && k == k1)
return true;
if(j == i && k == k1 + 1 && (anIntArrayArray294[j][k] & 0x1280120) == 0)
return true;
if(j == i && k == k1 - 1 && (anIntArrayArray294[j][k] & 0x1280102) == 0)
return true;
} else
if(i1 == 1)
{
if(j == i && k == k1 + 1)
return true;
if(j == i - 1 && k == k1 && (anIntArrayArray294[j][k] & 0x1280108) == 0)
return true;
if(j == i + 1 && k == k1 && (anIntArrayArray294[j][k] & 0x1280180) == 0)
return true;
} else
if(i1 == 2)
{
if(j == i + 1 && k == k1)
return true;
if(j == i && k == k1 + 1 && (anIntArrayArray294[j][k] & 0x1280120) == 0)
return true;
if(j == i && k == k1 - 1 && (anIntArrayArray294[j][k] & 0x1280102) == 0)
return true;
} else
if(i1 == 3)
{
if(j == i && k == k1 - 1)
return true;
if(j == i - 1 && k == k1 && (anIntArrayArray294[j][k] & 0x1280108) == 0)
return true;
if(j == i + 1 && k == k1 && (anIntArrayArray294[j][k] & 0x1280180) == 0)
return true;
}
if(j1 == 2)
if(i1 == 0)
{
if(j == i - 1 && k == k1)
return true;
if(j == i && k == k1 + 1)
return true;
if(j == i + 1 && k == k1 && (anIntArrayArray294[j][k] & 0x1280180) == 0)
return true;
if(j == i && k == k1 - 1 && (anIntArrayArray294[j][k] & 0x1280102) == 0)
return true;
} else
if(i1 == 1)
{
if(j == i - 1 && k == k1 && (anIntArrayArray294[j][k] & 0x1280108) == 0)
return true;
if(j == i && k == k1 + 1)
return true;
if(j == i + 1 && k == k1)
return true;
if(j == i && k == k1 - 1 && (anIntArrayArray294[j][k] & 0x1280102) == 0)
return true;
} else
if(i1 == 2)
{
if(j == i - 1 && k == k1 && (anIntArrayArray294[j][k] & 0x1280108) == 0)
return true;
if(j == i && k == k1 + 1 && (anIntArrayArray294[j][k] & 0x1280120) == 0)
return true;
if(j == i + 1 && k == k1)
return true;
if(j == i && k == k1 - 1)
return true;
} else
if(i1 == 3)
{
if(j == i - 1 && k == k1)
return true;
if(j == i && k == k1 + 1 && (anIntArrayArray294[j][k] & 0x1280120) == 0)
return true;
if(j == i + 1 && k == k1 && (anIntArrayArray294[j][k] & 0x1280180) == 0)
return true;
if(j == i && k == k1 - 1)
return true;
}
if(j1 == 9)
{
if(j == i && k == k1 + 1 && (anIntArrayArray294[j][k] & 0x20) == 0)
return true;
if(j == i && k == k1 - 1 && (anIntArrayArray294[j][k] & 2) == 0)
return true;
if(j == i - 1 && k == k1 && (anIntArrayArray294[j][k] & 8) == 0)
return true;
if(j == i + 1 && k == k1 && (anIntArrayArray294[j][k] & 0x80) == 0)
return true;
}
return false;
}
public boolean method220(int i, int j, int k, int l, int i1, int j1)
{
if(j1 == i && k == j)
return true;
j1 -= anInt290;
k -= anInt291;
i -= anInt290;
j -= anInt291;
if(l == 6 || l == 7)
{
if(l == 7)
i1 = i1 + 2 & 3;
if(i1 == 0)
{
if(j1 == i + 1 && k == j && (anIntArrayArray294[j1][k] & 0x80) == 0)
return true;
if(j1 == i && k == j - 1 && (anIntArrayArray294[j1][k] & 2) == 0)
return true;
} else
if(i1 == 1)
{
if(j1 == i - 1 && k == j && (anIntArrayArray294[j1][k] & 8) == 0)
return true;
if(j1 == i && k == j - 1 && (anIntArrayArray294[j1][k] & 2) == 0)
return true;
} else
if(i1 == 2)
{
if(j1 == i - 1 && k == j && (anIntArrayArray294[j1][k] & 8) == 0)
return true;
if(j1 == i && k == j + 1 && (anIntArrayArray294[j1][k] & 0x20) == 0)
return true;
} else
if(i1 == 3)
{
if(j1 == i + 1 && k == j && (anIntArrayArray294[j1][k] & 0x80) == 0)
return true;
if(j1 == i && k == j + 1 && (anIntArrayArray294[j1][k] & 0x20) == 0)
return true;
}
}
if(l == 8)
{
if(j1 == i && k == j + 1 && (anIntArrayArray294[j1][k] & 0x20) == 0)
return true;
if(j1 == i && k == j - 1 && (anIntArrayArray294[j1][k] & 2) == 0)
return true;
if(j1 == i - 1 && k == j && (anIntArrayArray294[j1][k] & 8) == 0)
return true;
if(j1 == i + 1 && k == j && (anIntArrayArray294[j1][k] & 0x80) == 0)
return true;
}
return false;
}
public boolean method221(int i, int j, int k, int l, int i1, int j1,
int k1)
{
int l1 = (j + j1) - 1;
int i2 = (i + l) - 1;
if(k >= j && k <= l1 && k1 >= i && k1 <= i2)
return true;
if(k == j - 1 && k1 >= i && k1 <= i2 && (anIntArrayArray294[k - anInt290][k1 - anInt291] & 8) == 0 && (i1 & 8) == 0)
return true;
if(k == l1 + 1 && k1 >= i && k1 <= i2 && (anIntArrayArray294[k - anInt290][k1 - anInt291] & 0x80) == 0 && (i1 & 2) == 0)
return true;
return k1 == i - 1 && k >= j && k <= l1 && (anIntArrayArray294[k - anInt290][k1 - anInt291] & 2) == 0 && (i1 & 4) == 0 || k1 == i2 + 1 && k >= j && k <= l1 && (anIntArrayArray294[k - anInt290][k1 - anInt291] & 0x20) == 0 && (i1 & 1) == 0;
}
private final int anInt290;
private final int anInt291;
private final int anInt292;
private final int anInt293;
public final int[][] anIntArrayArray294;
}
| [
"sanford.6716@gmail.com"
] | sanford.6716@gmail.com |
f4ebe16697f097b6c7950afe0985303ebadf1850 | 7d04a8d974351d8ca66f5b9ac662d4d7b1705d01 | /app/src/main/java/com/projects/sebastian/Smuuz/EqualizerTabActivity.java | c56db7b6ff8ef7b2307a58aaec75bbfe0fb60a49 | [] | no_license | skhara/smuuz | b4c909c75f582ac01838d2f5e432cebf0081b987 | 7af0ddc7b5d5555b56f0962dc0367111f0643320 | refs/heads/master | 2020-05-18T16:50:02.590156 | 2015-02-18T11:47:52 | 2015-02-18T11:47:52 | 39,686,730 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,408 | java | package com.projects.sebastian.Smuuz;
import android.app.Activity;
import android.os.Bundle;
import android.os.RemoteException;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class EqualizerTabActivity extends Activity {
private static boolean enabled = false;
private static int bassVol = 10;
private static int midVol = 10;
private static int trebleVol = 10;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.equalizertab);
/**
* Enable/Disable equalizer
*/
final CheckBox checkBoxEnable = (CheckBox) findViewById(R.id.EqualizerCheckBoxEnable);
checkBoxEnable.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
enabled = isChecked;
if(isChecked)
{
try
{
double dVol = bassVol;
dVol /= 10;
((App) getApplicationContext()).setEQ(0, dVol);
dVol = midVol;
dVol /= 10;
((App) getApplicationContext()).setEQ(1, dVol);
dVol = trebleVol;
dVol /= 10;
for(int i = 2; i < 32; i++)
((App) getApplicationContext()).setEQ(i, dVol);
} catch (RemoteException re) {
// TODO:
}
}
else
{
try
{
((App) getApplicationContext()).resetEQ();
} catch (RemoteException re) {
// TODO:
}
}
}
});
/**
* Set current equalizer
*/
final TextView textBassSt = (TextView) findViewById(R.id.EqualizerTextView1);
textBassSt.setText(Integer.valueOf(bassVol).toString());
final TextView textMidSt = (TextView) findViewById(R.id.EqualizerTextView2);
textMidSt.setText(Integer.valueOf(midVol).toString());
final TextView textTrebleSt = (TextView) findViewById(R.id.EqualizerTextView3);
textTrebleSt.setText(Integer.valueOf(trebleVol).toString());
/**
* Bass
*/
final Button buttonBassUp = (Button) findViewById(R.id.EqualizerButtonUp1);
buttonBassUp.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(bassVol < 30)
{
bassVol += 1;
try
{
double dVol = bassVol;
dVol /= 10;
if(enabled)
((App) getApplicationContext()).setEQ(0, dVol);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
final TextView textBass = (TextView) findViewById(R.id.EqualizerTextView1);
textBass.setText(Integer.valueOf(bassVol).toString());
}
});
final Button buttonBassDown = (Button) findViewById(R.id.EqualizerButtonDown1);
buttonBassDown.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(bassVol > 0)
{
bassVol -= 1;
try
{
double dVol = bassVol;
dVol /= 10;
if(enabled)
((App) getApplicationContext()).setEQ(0, dVol);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
final TextView textBass = (TextView) findViewById(R.id.EqualizerTextView1);
textBass.setText(Integer.valueOf(bassVol).toString());
}
});
/**
* Mid
*/
final Button buttonMidUp = (Button) findViewById(R.id.EqualizerButtonUp2);
buttonMidUp.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(midVol < 30)
{
midVol += 1;
try
{
double dVol = midVol;
dVol /= 10;
if(enabled)
((App) getApplicationContext()).setEQ(1, dVol);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
final TextView textMid = (TextView) findViewById(R.id.EqualizerTextView2);
textMid.setText(Integer.valueOf(midVol).toString());
}
});
final Button buttonMidDown = (Button) findViewById(R.id.EqualizerButtonDown2);
buttonMidDown.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(midVol > 0)
{
midVol -= 1;
try
{
double dVol = midVol;
dVol /= 10;
if(enabled)
((App) getApplicationContext()).setEQ(1, dVol);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
final TextView textMid = (TextView) findViewById(R.id.EqualizerTextView2);
textMid.setText(Integer.valueOf(midVol).toString());
}
});
/**
* Treble
*/
final Button buttonTrebleUp = (Button) findViewById(R.id.EqualizerButtonUp3);
buttonTrebleUp.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(trebleVol < 30)
{
trebleVol += 1;
double dVol = trebleVol;
dVol /= 10;
if(enabled)
{
for(int i = 2; i < 32; i++)
try
{
((App) getApplicationContext()).setEQ(i, dVol);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
final TextView textTreble = (TextView) findViewById(R.id.EqualizerTextView3);
textTreble.setText(Integer.valueOf(trebleVol).toString());
}
});
final Button buttonTrebleDown = (Button) findViewById(R.id.EqualizerButtonDown3);
buttonTrebleDown.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(trebleVol > 0)
{
trebleVol -= 1;
double dVol = trebleVol;
dVol /= 10;
if(enabled)
{
for(int i = 2; i < 32; i++)
try
{
((App) getApplicationContext()).setEQ(i, dVol);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
final TextView textTreble = (TextView) findViewById(R.id.EqualizerTextView3);
textTreble.setText(Integer.valueOf(trebleVol).toString());
}
});
}
}
| [
"sergey.oxygen@gmail.com"
] | sergey.oxygen@gmail.com |
e911fe513533ba78b7eacc752bb76af3711eedef | 7282d5e85d0876d8c363c365b4b34ac3c12fb08f | /Selenium_Tutorials/src/Basic_practice/simple.java | 32e65d337d9f1e440cf65960834a7e1bf2b6a8fa | [] | no_license | SUDHIR1995/Git-Tutorials | cec1307bba97c572208ec0eec871a3a8a6f54c0a | 715ce1b48a36093db7d1362a85bbcc1e9a1ca1c6 | refs/heads/master | 2023-01-29T16:02:32.620882 | 2020-12-12T17:45:19 | 2020-12-12T17:45:19 | 320,740,608 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,092 | java | package Basic_practice;
import java.util.List;
import org.apache.poi.hssf.record.RightMarginRecord;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class simple {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\SUDHIR NITNAWARE\\Desktop\\Newchrome\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com/");
driver.findElement(By.xpath("//input[@class='gLFyf gsfi']")).sendKeys("redmi");
Thread.sleep(5000);
List<WebElement> allOptions = driver.findElements(By.xpath("//ul[@class='erkvQe']/li"));
System.out.println(allOptions.size());
String exp = "redmi 8";
for (WebElement op : allOptions) {
String act = op.getText();
System.out.println(act);
if (op.getText().equalsIgnoreCase(exp)) {
op.click();
}
}
Thread.sleep(5000);
driver.close();
}
}
| [
"sudhirnitnawre@gmail.com"
] | sudhirnitnawre@gmail.com |
60bcdc40a45aa4a5e116af845e65ff1509adbb4f | 8f77fba8b7ee44c46d6b9594cb5b9a6890c44df4 | /src/NewUppgift1.java | 7001fdc9c04be4fcef973eb6d11569aaa21b94e8 | [] | no_license | Michael1100/Uppgifter | 767c8fd3e4e5a69fbd2f59c3a5c5c629162d1a92 | 4faeb59c1c7bdabf122a83fd6a1ded9ae3b1338e | refs/heads/master | 2020-03-27T17:52:15.180190 | 2018-09-07T10:49:51 | 2018-09-07T10:49:51 | 146,880,584 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 343 | java | import java.util.ArrayList;
public class NewUppgift1 {
public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<>();
int x = 10;
for (int i = 0; i <= x; i++) {
list.add(i);
}
int sum = 0;
for (int i=0; i<list.size(); i++) {
sum += list.get(i);
}
System.out.println(sum);
}
}
| [
"michael.gabrielsson.te16d@gmail.com"
] | michael.gabrielsson.te16d@gmail.com |
dc7b19b2a5d2955934b87f3d20f79c7c170ffd3e | b2a635e7cc27d2df8b1c4197e5675655add98994 | /com/facebook/react/uimanager/p0.java | 0b751a780c325e2e5efb2a2846967f32f594e230 | [] | no_license | history-purge/LeaveHomeSafe-source-code | 5f2d87f513d20c0fe49efc3198ef1643641a0313 | 0475816709d20295134c1b55d77528d74a1795cd | refs/heads/master | 2023-06-23T21:38:37.633657 | 2021-07-28T13:27:30 | 2021-07-28T13:27:30 | 390,328,492 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 529 | java | package com.facebook.react.uimanager;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.events.d;
@Deprecated
public class p0 {
o0 a(ReactApplicationContext paramReactApplicationContext, a1 parama1, d paramd, int paramInt) {
return new o0(paramReactApplicationContext, parama1, paramd, paramInt);
}
}
/* Location: /home/yc/Downloads/LeaveHomeSafe.jar!/com/facebook/react/uimanager/p0.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/ | [
"game0427game@gmail.com"
] | game0427game@gmail.com |
d66c3f94d64e32f0dcfcbd90d83578ee2eac9b97 | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/naver--pinpoint/5eedd95712aeeb603cf38e0341c60265d4fea5b8/before/ConnectorInitializeInterceptor.java | 6976da6723014ac6a651456499e159b2fe1a0d6f | [] | no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,222 | java | package com.profiler.modifier.tomcat.interceptors;
import com.profiler.Agent;
import com.profiler.interceptor.StaticAfterInterceptor;
import com.profiler.util.Assert;
import com.profiler.util.StringUtils;
import org.apache.catalina.connector.Connector;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class ConnectorInitializeInterceptor implements StaticAfterInterceptor {
private Logger logger = Logger.getLogger(this.getClass().getName());
private Agent agent;
public ConnectorInitializeInterceptor(Agent agent) {
Assert.notNull(agent, "agent must not be null");
this.agent = agent;
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
if (logger.isLoggable(Level.INFO)) {
logger.info("after " + StringUtils.toString(target) + " " + className + "." + methodName + parameterDescription + " args:" + Arrays.toString(args) + " result:" + result);
}
Connector connector = (Connector) target;
agent.getServerInfo().addConnector(connector.getProtocol(), connector.getPort());
}
} | [
"fraczwojciech@gmail.com"
] | fraczwojciech@gmail.com |
fcbd480e2107cdeb33f97785ba1c41b04c2e63da | 2d0f157033f825e9fb45d2d0fd9db984a7c64cc8 | /src/main/java/utils/MoreUtils.java | 693ee33cbebe6448fbd3fd09ba17d01fbc811d32 | [] | no_license | Leothon/artepie_server | 80d0b7f346d6b1e8bac3d40117835d90dad3446b | 0d57d011c7c2a7243dc8a1948d7f5b008a091cba | refs/heads/master | 2023-02-08T09:45:15.015349 | 2019-11-24T08:09:24 | 2019-11-24T08:09:24 | 325,735,470 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,775 | java | package utils;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.LoggerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import static org.apache.poi.ss.usermodel.CellType.STRING;
public class MoreUtils {
private static final String ExceptionToLog = "Exception";
/**
*
* @Title: getJSSBSJ_FSDYZBInfo
* @Description: 将附属单元子表.xls写入到JSSBSJ_FSDYZBEntity实体类中
* @param @param path
* @param @return 设定文件
* @return List<RegisterEntity> 返回类型
* @throws
*/
public static List<RegisterEntity> getExcel(String path) {
XSSFWorkbook xssfWorkbook = null;
InputStream is = null;
RegisterEntity Entity = null;
List<RegisterEntity> EntityList = new ArrayList<RegisterEntity>();
EntityList.clear();
try {
is = new FileInputStream(path);
xssfWorkbook = new XSSFWorkbook(is);
if (xssfWorkbook != null) {
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
for (int rowNum = 1; rowNum <= xssfSheet.getLastRowNum(); rowNum++) {
XSSFRow xssfRow = xssfSheet.getRow(rowNum);
if (xssfRow != null) {
Entity = new RegisterEntity();
XSSFCell name = xssfRow.getCell(0);
XSSFCell phone = xssfRow.getCell(1);
Entity.setUsername(getValue(name));
Entity.setUserPhone(getValue(phone));
EntityList.add(Entity);
}
}
}
} catch (Exception e) {
LoggerFactory.getLogger(ExceptionToLog).warn(e.toString());
} finally{
if (is != null) {
try {
is.close();
} catch (IOException e) {
LoggerFactory.getLogger(ExceptionToLog).warn(e.toString());
} finally{
}
}
}
return EntityList;
}
/**
*
* @Title: getValue
* @Description: 判断后缀为xls的excel文件的数据类型
* @param @param hssfCell
* @param @return 设定文件
* @return String 返回类型
* @throws
*/
private static String getValue(XSSFCell sfhssfCellCell) {
sfhssfCellCell.setCellType(STRING);
String Value = sfhssfCellCell.getStringCellValue();
return String.valueOf(Value);
}
}
| [
"langmancaizi@gmail.com"
] | langmancaizi@gmail.com |
22d511e3e0f8bf1a43bc0097b8b958d79c421f4d | 823975e73e39a90ae8c0a5276858d44a0870becf | /src/main/java/mat/server/service/impl/XLSGenerator.java | f0755d3c7d801f042ae18732bb9d0a29025431a5 | [
"LicenseRef-scancode-free-unknown",
"CC0-1.0"
] | permissive | casey-erdmann/mat-jdk-test | b5c9d6e2a187aaf36539308dcea57514c2cf9203 | cd53323dd44303a1893df0d1c7ef029d6c818bb9 | refs/heads/master | 2022-09-11T15:32:55.792064 | 2020-01-06T20:52:47 | 2020-01-06T20:52:47 | 230,963,098 | 0 | 0 | CC0-1.0 | 2022-09-01T23:18:28 | 2019-12-30T18:40:47 | JavaScript | UTF-8 | Java | false | false | 19,482 | java | package mat.server.service.impl;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.apache.poi.hpsf.SummaryInformation;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Name;
import mat.dao.ListObjectDAO;
import mat.dao.clause.MeasureExportDAO;
import mat.model.Code;
import mat.model.CodeList;
import mat.model.GroupedCodeList;
import mat.model.ListObject;
import mat.model.MatConcept;
import mat.model.MatValueSet;
import mat.model.clause.MeasureExport;
import mat.shared.ConstantMessages;
import mat.shared.DateUtility;
/** The Class XLSGenerator. */
public abstract class XLSGenerator {
/** The Class RowCacheItem. */
protected class RowCacheItem implements Comparable<RowCacheItem> {
/** The style. */
public HSSFCellStyle style;
/** The values. */
public String[] values;
/**
* Compare two RowCacheItems based on OID first. if they match on OID,
* then compare on Code.
* @param o - RowCacheItem.
* @return int.
*/
@Override
public final int compareTo(final RowCacheItem o) {
DotCompare dc = new DotCompare();
int ret;
ret = dc.dotNotationCompare(values[oid], o.values[oid]);
if (ret != 0) {
return ret;
}
return dc.dotNotationCompare(values[code], o.values[code]);
}
}
/** The author. */
protected final String AUTHOR = "eMeasureTool";
/**
* WorkBook Header.
* **/
private final String[] HEADER_STRINGS = { "Value Set Developer",
"Value Set OID", "Version" ,"Expansion Identifier", "Revision Date", "Value Set Name",
"Code System", "Code System Version", "Code" , "Descriptor"};
/** The keywords. */
protected final String KEYWORDS = "Value Set, OID, Export, Measure, Code, Descriptor";
/**
* WorkBook Content.
* **/
private final String[] NAME_STRINGS = { "ValueSetDeveloper",
"ValueSetOID", "Version", "ExpansionIdentifier", "RevisionDate", "ValueSetName", "QDMCategory",
"CodeSystem", "CodeSystemVersion", "Code" , "Descriptor"};
/** The row cache. */
protected ArrayList<RowCacheItem> rowCache = new ArrayList<RowCacheItem>();
/** The measuredeveloper. */
protected final int measuredeveloper = 0;
/** The oid. */
protected final int oid = 1;
/** The version */
protected final int version = 2;
/** The expansionIdentifier */
protected final int expansionIdentifier = 3;
/** The revision date. */
protected final int revisionDate = 4;
/** The standardconcept. */
protected final int standardconcept = 5;
/** The standardtaxonomy. */
protected final int standardtaxonomy = 6;
/** The standardtaxonomyversion. */
protected final int standardtaxonomyversion = 7;
/** The code. */
protected final int code = 8;
/** The codedescription. */
protected final int codedescription = 9;
/** The subject. */
protected final String SUBJECT = "Value Set Export";
/** The title. */
protected final String TITLE = "Value Set Export";
/** Adds the disclaimer.
*
* @param wkbk - HSSFWorkbook. * */
@SuppressWarnings("deprecation")
protected final void addDisclaimer(final HSSFWorkbook wkbk) {
String disclaimerText = "The codes that you are exporting directly reflect the codes you entered into the "
+ "Measure Authoring Tool. These codes may be owned by a third party and "
+ "subject to copyright or other intellectual property restrictions. Use of these "
+ "codes may require permission from the code owner or agreement to a license. "
+ "It is your responsibility to ensure that your use of any third party code is "
+ "permissible and that you have fulfilled any notice or license requirements "
+ "imposed by the code owner. Use of the Measure Authoring Tool does not "
+ "confer any rights on you with respect to these codes other than those codes that may "
+ "be available from the code owner.";
HSSFSheet wkst = wkbk.createSheet("Disclaimer");
HSSFRow row = wkst.createRow(0);
row.createCell(0, HSSFCell.CELL_TYPE_STRING).setCellValue(
disclaimerText);
wkst.setColumnWidth(0, (75 * 256));
HSSFCell cell = row.getCell(0);
HSSFCellStyle style = wkbk.createCellStyle();
style.setWrapText(true);
cell.setCellStyle(style);
}
/** Cache row.
*
* @param values - String array.
* @param style - HSSFCellStyle. * */
protected final void cacheRow(final String[] values, final HSSFCellStyle style) {
RowCacheItem row = new RowCacheItem();
row.values = values.clone();
row.style = style;
rowCache.add(row);
}
/** Cache xls row.
*
* @param lo - ListObject.
* @param listObjectDAO - ListObjectDAO.
* @param vsPackageDate - Time stamp.
*
* * */
protected abstract void cacheXLSRow(ListObject lo,
ListObjectDAO listObjectDAO, Timestamp vsPackageDate);
/** Cache xls row.
*
* @param lo - MatValueSet.
*
* * */
protected abstract void cacheXLSRow(MatValueSet lo);
/** Creates the header row.
*
* @param wkst - HSSFSheet.
* @param values - String Array.
* @param names - String Array.
* @param rownum - Integer.
* @param style -HSSFCellStyle.
* @return HSSFRow. * */
public final HSSFRow createHeaderRow(final HSSFSheet wkst, final String[] values,
final String[] names, final int rownum, final HSSFCellStyle style) {
HSSFRow headerRow = createXLSRow(wkst, values, rownum, style);
HSSFWorkbook wkbk = wkst.getWorkbook();
generateName(wkbk, names[measuredeveloper], "'" + wkst.getSheetName()
+ "'!$A$1");
generateName(wkbk, names[oid], "'" + wkst.getSheetName() + "'!$B$1");
generateName(wkbk, names[version], "'" + wkst.getSheetName()
+ "'!$H$1");
generateName(wkbk, names[expansionIdentifier], "'" + wkst.getSheetName()
+ "'!$I$1");
generateName(wkbk, names[revisionDate], "'" + wkst.getSheetName()
+ "'!$C$1");
generateName(wkbk, names[standardconcept], "'" + wkst.getSheetName()
+ "'!$D$1");
/*
* generateName(wkbk, names[standardcategory], "'" + wkst.getSheetName()
* + "'!$E$1");
*/
generateName(wkbk, names[standardtaxonomy], "'" + wkst.getSheetName()
+ "'!$E$1");
generateName(wkbk, names[standardtaxonomyversion],
"'" + wkst.getSheetName() + "'!$F$1");
generateName(wkbk, names[code], "'" + wkst.getSheetName() + "'!$G$1");
generateName(wkbk, names[codedescription], "'" + wkst.getSheetName()
+ "'!$J$1");
return headerRow;
}
/** Creates the meta data.
*
* @param wkbk - HSSFWorkbook.
*
* * */
public final void createMetaData(final HSSFWorkbook wkbk) {
// Author: eMeasureTool, Title: Value Set Export, Subject: Value Set
// Export, Keywords: Value Set, OID, Export, Measure, Code, Descriptor
wkbk.createInformationProperties();
SummaryInformation si = wkbk.getSummaryInformation();
si.setAuthor(AUTHOR);
si.setTitle(TITLE);
si.setSubject(SUBJECT);
si.setKeywords(KEYWORDS);
}
/** Creates the sheet.
*
* @param wkbk -HSSFWorkbook.
* @param style -HSSFCellStyle.
* @param sheetName - String.
* @return HSSFSheet. * */
protected final HSSFSheet createSheet(final HSSFWorkbook wkbk, final HSSFCellStyle style,
final String sheetName) {
HSSFSheet wkst = wkbk.createSheet(sheetName);
int heightPoint = 10;
HSSFFont font = wkbk.createFont();
font.setFontName(HSSFFont.FONT_ARIAL);
font.setFontHeightInPoints((short) heightPoint);
font.setBold(true);
font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
style.setFont(font);
style.setFillForegroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setBorderBottom(BorderStyle.THIN);
return wkst;
}
/** Creates the xls row.
*
* @param wkst - HSSFSheet.
* @param values - String Array.
* @param style - HSSFCellStyle.
* @return HSSFRow. * */
protected final HSSFRow createXLSRow(final HSSFSheet wkst, final String[] values,
final HSSFCellStyle style) {
return createXLSRow(wkst, values, wkst.getLastRowNum() + 1, style);
}
/** Creates the xls row.
*
* @param wkst - HSSFSheet.
* @param values - String Array.
* @param rownum - Integer.
* @param style - HSSFCellStyle.
* @return HSSFRow. * */
@SuppressWarnings("deprecation")
protected final HSSFRow createXLSRow(final HSSFSheet wkst, final String[] values, final int rownum,
final HSSFCellStyle style) {
HSSFRow row = wkst.createRow(rownum);
row.createCell(measuredeveloper, HSSFCell.CELL_TYPE_STRING)
.setCellValue(values[measuredeveloper]);
row.createCell(oid, HSSFCell.CELL_TYPE_STRING)
.setCellValue(values[oid]);
row.createCell(version, HSSFCell.CELL_TYPE_STRING)
.setCellValue(values[version]);
row.createCell(expansionIdentifier, HSSFCell.CELL_TYPE_STRING)
.setCellValue(values[expansionIdentifier]);
row.createCell(revisionDate, HSSFCell.CELL_TYPE_STRING).setCellValue(
values[revisionDate]);
row.createCell(standardconcept, HSSFCell.CELL_TYPE_STRING)
.setCellValue(values[standardconcept]);
row.createCell(standardtaxonomy, HSSFCell.CELL_TYPE_STRING)
.setCellValue(values[standardtaxonomy]);
row.createCell(standardtaxonomyversion, HSSFCell.CELL_TYPE_STRING)
.setCellValue(values[standardtaxonomyversion]);
row.createCell(code, HSSFCell.CELL_TYPE_STRING).setCellValue(
values[code]);
row.createCell(codedescription, HSSFCell.CELL_TYPE_STRING)
.setCellValue(values[codedescription]);
if (style != null) {
row.getCell(measuredeveloper).setCellStyle(style);
row.getCell(oid).setCellStyle(style);
row.getCell(version).setCellStyle(style);
row.getCell(expansionIdentifier).setCellStyle(style);
row.getCell(revisionDate).setCellStyle(style);
row.getCell(standardconcept).setCellStyle(style);
row.getCell(standardtaxonomy).setCellStyle(style);
row.getCell(standardtaxonomyversion).setCellStyle(style);
row.getCell(code).setCellStyle(style);
row.getCell(codedescription).setCellStyle(style);
}
return row;
}
/** Generate name.
*
* @param wkbk - HSSFWorkbook.
* @param nameStr - String.
* @param referenceStr - String. * */
protected final void generateName(final HSSFWorkbook wkbk, final String nameStr,
final String referenceStr) {
// names are required for 508 testing
Name name = wkbk.createName();
name.setNameName(nameStr);
name.setRefersToFormula(referenceStr);
}
/** Gets the error xls.
*
* @return HSSFWorkbook. * */
public HSSFWorkbook getErrorXLS() {
HSSFWorkbook wkbk = new HSSFWorkbook();
HSSFSheet wkst = wkbk.createSheet("Sheet 1");
wkst.createRow(0)
.createCell(0)
.setCellValue("Measure must be re-packaged to capture the Value Set export."
+ " Please re-package and try again.");
return wkbk;
}
/** Gets the header strings.
*
* @return the hEADER_STRINGS */
public String[] getHEADER_STRINGS() {
return HEADER_STRINGS;
}
/**
* NOTE: there is an error in the POI API that keeps us from using.
* HSSFWorkbook.getBytes()
*
* @param wkbk -HSSFWorkbook.
* @return byte array from workbook
* @throws IOException - IOException.
*/
public final byte[] getHSSFWorkbookBytes(final HSSFWorkbook wkbk) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
wkbk.write(baos);
byte[] barr = baos.toByteArray();
baos.close();
return barr;
}
/** Gets the name strings.
*
* @return the nAME_STRINGS */
public String[] getNAME_STRINGS() {
return NAME_STRINGS;
}
/** Gets the xls.
*
* @param measureId - String.
* @param measureExportDAO - MeasureExportDAO.
* @return HSSFWorkbook. * */
public final HSSFWorkbook getXLS(final String measureId,
final MeasureExportDAO measureExportDAO) {
MeasureExport me = measureExportDAO.findByMeasureId(measureId);
me.getCodeListBarr();
try {
byte[] barr = me.getCodeListBarr();
ByteArrayInputStream bais = new ByteArrayInputStream(barr);
HSSFWorkbook wkbk = new HSSFWorkbook(bais);
return wkbk;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/** Process xls row.
*
* @param lo - ListObject.
* @param listObjectDAO - ListObjectDAO.
* @param vsPackageDate - Timestamp.
*
* * */
protected final void processXLSRow(final ListObject lo, final ListObjectDAO listObjectDAO,
final Timestamp vsPackageDate) {
String measureDeveloper = "";
// US 178, Using steward organization name for SDE !!.
if ((lo.getSteward() != null)
&& !lo.getSteward().getOrgName().equalsIgnoreCase("Other")) {
measureDeveloper = lo.getSteward().getOrgName();
} else if (lo.getStewardOther() != null) {
measureDeveloper = lo.getStewardOther();
}
String standardConcept = lo.getName();
// String category = lo.getCategory().getDescription();
String taxonomy = lo.getCodeSystem().getDescription();
String taxonomyVersion = lo.getCodeSystemVersion();
String oid = lo.getOid();
String valueSetLastModified = DateUtility.convertDateToString(lo
.getLastModified());
if (lo instanceof CodeList) {
if (((CodeList) lo).getCodes().isEmpty()) {
String code = "";
String description = "";
cacheRow(new String[] {measureDeveloper, oid,
valueSetLastModified, standardConcept,
taxonomy, taxonomyVersion, code, description }, null);
}
Set<Code> codeSet = new HashSet<Code>();
for (Code c : ((CodeList) lo).getCodes()) {
codeSet.add(c);
}
for (Code c : codeSet) {
String code = c.getCode();
String description = c.getDescription();
cacheRow(new String[] { measureDeveloper, oid, valueSetLastModified, standardConcept,
taxonomy, taxonomyVersion, code, description }, null);
}
} else {
if (lo.getCodesLists().isEmpty()) {
String code = "";
String description = "";
cacheRow(new String[] { measureDeveloper, oid, valueSetLastModified, standardConcept,
taxonomy, taxonomyVersion, code, description }, null);
}
for (GroupedCodeList gcl : lo.getCodesLists()) {
String code = gcl.getCodeList().getOid();
String description = gcl.getDescription();
cacheRow(new String[] { measureDeveloper, oid, valueSetLastModified, standardConcept,
taxonomy, taxonomyVersion, code, description }, null);
cacheXLSRow(gcl.getCodeList(), listObjectDAO, vsPackageDate);
}
}
}
/** Process xls row.
*
* @param lo - MatValueSet.
*
* * */
protected final void processXLSRow(final MatValueSet lo) {
String measureDeveloper = "";
measureDeveloper = lo.getSource();
String standardConcept = lo.getDisplayName();
String code = "";
String oid = lo.getID();
String valueSetLastModified = lo.getRevisionDate();
String expansionProfile = lo.getExpansionProfile();
String version = "";
if(!lo.getVersion().equalsIgnoreCase("Draft")
) {
version = lo.getVersion();
}
if(expansionProfile==null){
expansionProfile = "";
}
if (ConstantMessages.GROUPING_CODE_SYSTEM
.equalsIgnoreCase(lo.getType())) {
String taxonomy = ConstantMessages.GROUPING_CODE_SYSTEM;
String taxonomyVersion = "";
String description = "";
if (lo.getGroupedValueSet().get(0)
.getConceptList().getConceptList() != null) {
taxonomyVersion = lo.getGroupedValueSet().get(0)
.getConceptList().getConceptList().get(0)
.getCodeSystemVersion();
}
if (lo.getGroupedValueSet().size() == 0) {
cacheRow(new String[] {measureDeveloper, oid, version, expansionProfile,
valueSetLastModified, standardConcept, taxonomy,
taxonomyVersion, code, description }, null);
}
for (MatValueSet gcl : lo.getGroupedValueSet()) {
code = gcl.getID();
// description = gcl.getDescription();
cacheRow(new String[] {measureDeveloper, oid, version, expansionProfile,
valueSetLastModified, standardConcept,
taxonomy, taxonomyVersion, code , description}, null);
cacheXLSRow(gcl);
}
} else {
String taxonomyVersion = "";
String taxonomy = "";
String description = "";
if (lo.getConceptList().getConceptList() != null) {
taxonomy = lo.getConceptList().getConceptList().get(0)
.getCodeSystemName();
taxonomyVersion = lo.getConceptList().getConceptList().get(0)
.getCodeSystemVersion();
if ((lo.getConceptList().getConceptList().size() == 0)) {
cacheRow(new String[] {measureDeveloper, oid, version, expansionProfile,
valueSetLastModified, standardConcept,
taxonomy, taxonomyVersion, code , description}, null);
}
for (MatConcept concept : lo.getConceptList().getConceptList()) {
code = concept.getCode();
description = concept.getDisplayName();
cacheRow(new String[] {measureDeveloper, oid, version, expansionProfile ,
valueSetLastModified, standardConcept,
taxonomy, taxonomyVersion, code, description}, null);
}
}
}
}
/** Size column.
*
* @param wkst - HSSFSheet.
* @param col - Short. * */
private void sizeColumn(final HSSFSheet wkst, final short col) {
try {
wkst.autoSizeColumn(col);
} catch (Exception e) {
wkst.setColumnWidth(col, (256 * 255));
}
}
/** Size columns.
*
* @param wkst - HSSFSheet. * */
protected final void sizeColumns(final HSSFSheet wkst) {
sizeColumn(wkst, (short) measuredeveloper);
sizeColumn(wkst, (short) oid);
sizeColumn(wkst, (short) revisionDate);
sizeColumn(wkst, (short) standardconcept);
sizeColumn(wkst, (short) standardtaxonomy);
sizeColumn(wkst, (short) standardtaxonomyversion);
sizeColumn(wkst, (short) code);
sizeColumn(wkst, (short) version);
sizeColumn(wkst, (short) expansionIdentifier);
sizeColumn(wkst, (short) codedescription);
}
/** Strip invalid chars.
*
* @param repStr - String.
* @return String. * */
protected final String stripInvalidChars(final String repStr) {
StringBuffer sb = new StringBuffer();
String acceptableStr = " `~1!2@3#4$5%6^7&89(0)-_=+qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM,<.>{}|";
for (char c : repStr.toCharArray()) {
if (acceptableStr.indexOf(c) >= 0) {
sb.append(c);
}
}
if (sb.length() == 0) {
return "temp";
}
return sb.toString();
}
/** Write row cache.
*
* @param wkst - HSSFSheet. * */
protected final void writeRowCache(final HSSFSheet wkst) {
Collections.sort(rowCache);
for (RowCacheItem row : rowCache) {
createXLSRow(wkst, row.values, row.style);
}
}
}
| [
"casey.erdmann@semanticbits.com"
] | casey.erdmann@semanticbits.com |
69f2838960d16fe1af38b3fe1bef57e7caec5bef | 65befe28d69189681a2c79c77d9fcbdceab3dc27 | /Algorithms/new2019/src/new2019/B11724.java | e4e92da5a3c433cc2c9704814f2098e46960706f | [] | no_license | solwish/TIL | 554a67f79c66ed5d5a5075f08b6f0369aa363249 | 4314767fa763de73238aa141e105a5cf3641a9fc | refs/heads/master | 2023-01-08T01:11:34.677452 | 2021-01-07T13:43:56 | 2021-01-07T13:43:56 | 101,876,124 | 10 | 0 | null | 2023-01-03T14:41:06 | 2017-08-30T12:03:25 | CSS | UTF-8 | Java | false | false | 845 | java | package new2019;
import java.util.Scanner;
public class B11724 {
static int N, M, map[][], cnt, start, visit[];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
N = sc.nextInt();
M = sc.nextInt();
map = new int[N + 1][N + 1];
visit = new int[N + 1];
cnt = 0;
int t1, t2;
for (int i = 1; i <= M; i++) {
t1 = sc.nextInt();
t2 = sc.nextInt();
map[t1][t2] = 1;
map[t2][t1] = 1;
}
for (int i = 1; i <= N; i++) {
start = i;
for (int j = 1; j <= N; j++)
if (map[start][j] == 1 && visit[i] == 0) {
cnt++;
dfs(j);
}
}
for (int i = 1; i <= N; i++)
if (visit[i] == 0)
cnt++;
System.out.println(cnt);
}
private static void dfs(int now) {
visit[now] = cnt;
for (int i = 1; i <= N; i++)
if (map[now][i] == 1 && visit[i] == 0)
dfs(i);
}
}
| [
"solwish90@gmail.com"
] | solwish90@gmail.com |
f3827b66cfcbea47ec505ee5f2c5c8132177bc8a | 3d895177dfa4b1845af59193769a79ef09d64b9f | /app/src/test/java/com/mafyusuf/flashnight/ExampleUnitTest.java | c3be5506b736b197075bfa2998c36e5edc4f6c55 | [] | no_license | mohdyusuf420/Flash | f2a45536a5c973535707d20816805925cc4822d5 | 20daba48e4a1ba1aa53fd4392ca8ff326787e8d0 | refs/heads/master | 2021-03-26T11:52:52.327410 | 2020-03-16T12:55:14 | 2020-03-16T12:55:14 | 247,701,886 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 386 | java | package com.mafyusuf.flashnight;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals( 4, 2 + 2 );
}
} | [
"mafyusuf420@gmail.com"
] | mafyusuf420@gmail.com |
24a6dc347bdf78d33fc02703bf0a7b8e1036584e | 946d30195a3ada6f9e4ad8b1b571ae26cd1da79f | /algorithmsplus/src/main/java/me/algo/leetcode/Lc0911OnlineElection.java | c7421d13d32b9e2efdb35dfdcb7f0a292f4233da | [] | no_license | bkpatel3108/algorithmplus | 62858916eb5bf4878908a12168f36c3c4a3b130b | e6583ffad1bdb8de69061dcbb84307663cc547cd | refs/heads/master | 2020-03-28T19:58:50.132078 | 2019-11-24T22:06:49 | 2019-11-24T22:06:49 | 149,027,363 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 637 | java | package me.algo.leetcode;
import java.util.Arrays;
public class Lc0911OnlineElection {
int[] times;
int[] winners;
public Lc0911OnlineElection(int[] persons, int[] times) {
this.times = times;
int winner = persons[0];
int[] votes = new int[persons.length];
winners = new int[times.length];
for (int i = 0; i < persons.length; i++) {
votes[persons[i]]++;
if (votes[persons[i]] >= votes[winner]) {
winner = persons[i];
}
winners[i] = winner;
}
}
public int q(int t) {
int search = Arrays.binarySearch(times, t);
if (search < 0) {
search = (search + 2) * (-1);
}
return winners[search];
}
}
| [
"bkpatel3108@gmail.com"
] | bkpatel3108@gmail.com |
cf39976610fb160f625686760cb0ad8008175e27 | 115dca67b15b4d0c2ba5be89a361d71fb73dd4d1 | /src/net/sourceforge/cardme/vcard/features/SourceFeature.java | a56667308202a11492ed3ece2665b6b799ef4816 | [] | no_license | george-haddad/cardme | 8c44c25e809de7835261775aacd5a747d798ecd0 | 2cdb02c627d103041288bc57f06b9deeb02f194a | refs/heads/master | 2023-08-21T20:30:30.234684 | 2022-04-06T07:56:14 | 2022-04-06T07:56:14 | 87,789,835 | 20 | 6 | null | 2022-04-06T07:56:16 | 2017-04-10T09:02:19 | Java | UTF-8 | Java | false | false | 1,024 | java | package net.sourceforge.cardme.vcard.features;
/**
*
* @author George El-Haddad
* <br/>
* Aug 7, 2012
*
* <p><b>RFC 2426</b><br/>
* <b>2.1.4 SOURCE Type Definition</b>
* <ul>
* <li><b>Type name:</b> SOURCE</li>
* <li><b>Type purpose:</b> If the SOURCE type is present, then its value provides information how to find the source for the vCard.</li>
* <li><b>Type encoding:</b> 8bit</li>
* <li><b>Type value:</b> A single text value.</li>
* </ul>
* </p>
*/
public interface SourceFeature {
/**
* <p>Retrieves the source.</p>
*
* @return the source or null if not set
*/
public String getSource();
/**
* <p>Sets the source.</p>
*
* @param source - the source to set
*/
public void setSource(String source);
/**
* <p>Indicates if the source has been set.</p>
*
* @return true if the source was set or false otherwise
*/
public boolean hasSource();
/**
* <p>Removes the source.</p>
*/
public void clearSource();
}
| [
"george-haddad@users.noreply.github.com"
] | george-haddad@users.noreply.github.com |
feccc066cde3e68775916ef423e2d5a82ec4b1d6 | e6fec7bf1714f3f71129332c4efc5359263c5446 | /bits/single_number.java | b15f0eb60b0457572efa7ed912ed4f1fa039da65 | [] | no_license | arnabs542/algorithms-4 | 7e5967b40f2bcc6b946955fcfa044196f24d5586 | 2115e434cdacb4ae6253ca3848f9de6bf69d39e5 | refs/heads/master | 2021-09-07T10:42:00.463453 | 2018-02-21T18:49:57 | 2018-02-21T18:49:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 797 | java | /*
*
* 136. Single Number
* https://leetcode.com/problems/single-number/description/
* ----------------------------------------------------------------------------------------------------------------------
* Given an array of integers, every element appears twice except for one. Find that single one.
*
* Note:
* Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
*
* 思路:XOR
* It is known that:
* 1. A XOR A = 0
* 2. the XOR operator is commutative
*
* the solution will be very straightforward.
*
* */
package bits;
public class single_number {
public int singleNumber(int[] nums) {
int result = 0;
for (int i = 0; i < nums.length; i++) {
result ^= nums[i];
}
return result;
}
}
| [
"floydchenchen@gmail.com"
] | floydchenchen@gmail.com |
e6856394f20a924d96ef765bbc4d86f1cb8c3155 | c1b5514b43bb3bfa7d3f52df1be0c01492557746 | /src/main/java/designPattern/Structural/Proxy/template/RealSubject.java | ddf3880bb97b9ff225abb96b6d0558dfe078f802 | [] | no_license | Qstar/JavaCases | 9fa7ff7bdd65aa9ba19c06c750712433c97efa71 | dc1e87c17a31365afaf3385d712018ceeea3470d | refs/heads/master | 2020-04-15T12:42:10.865419 | 2018-08-02T06:27:08 | 2018-08-02T06:27:08 | 64,284,352 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 173 | java | package designPattern.Structural.Proxy.template;
public class RealSubject extends Subject {
@Override
public void operation() {
//the real operation
}
} | [
"davesla2012@hotmail.com"
] | davesla2012@hotmail.com |
5418109706b5d455568a071f43c0883425fdb549 | 3114946fe009b18958e91395ca562fb27f77041d | /DSA_Project/DeleteAcc.java | 9afec0967a4ceb21fab6047a54df76b57fd1cf3b | [] | no_license | Charvik2020/Social-Network | 5a3b34602965bc6378052f661737c14519da73b3 | d14ee1bb4ed025a556b3c10f0072e399deef9a3e | refs/heads/master | 2021-07-24T21:14:46.994389 | 2017-11-05T09:30:28 | 2017-11-05T09:30:28 | 109,566,163 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 662 | java | import java.awt.GridLayout;
import java.awt.Button;
import java.awt.TextField;
import java.awt.Label;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
class DeleteAcc
{
public DeleteAcc(String username)
{
try
{
File file = new File("/home/ayam/DSA_Project/Files/"+username); //finds the file and opens it
FileWriter fw = new FileWriter(file,false); //appending disabled
BufferedWriter bw = new BufferedWriter(fw);
fw.write(""); //overwriting the file and making it empty
file.delete(); //after emptying the file, deletion is done
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
| [
"patelcharvik@gmail.com"
] | patelcharvik@gmail.com |
a60070a47c737afff4a4c3510cfa141b4b7dc583 | d0f9452387c43ae8278307a889517c33e24d3389 | /workpool-java/src/main/java/com/vmware/thinapp/workpool/WorkpoolImpl.java | 3cf84bc78a7c725d428ff716299c2c90f63d252e | [
"Apache-2.0"
] | permissive | pcrane70/thinapp_factory | 38ed7085c208eddf853a28b587f70cc42a0488fb | 5910839b29bf79e6565291bff51a555de0795176 | refs/heads/master | 2020-08-15T12:11:36.531525 | 2019-10-15T16:02:29 | 2019-10-15T16:02:29 | 215,339,895 | 0 | 0 | NOASSERTION | 2019-10-15T16:02:30 | 2019-10-15T16:00:46 | null | UTF-8 | Java | false | false | 8,994 | java | /* ***********************************************************************
* VMware ThinApp Factory
* Copyright (c) 2009-2013 VMware, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ***********************************************************************/
package com.vmware.thinapp.workpool;
import java.rmi.RemoteException;
import java.util.concurrent.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.common.util.concurrent.SettableFuture;
import com.vmware.thinapp.common.workpool.dto.InstanceInfo;
import com.vmware.thinapp.common.workpool.dto.Lease;
import com.vmware.thinapp.common.workpool.dto.VCConfig;
import com.vmware.thinapp.workpool.model.InstanceModel;
import com.vmware.thinapp.workpool.model.LeaseModel;
import com.vmware.thinapp.workpool.model.VCConfigModel;
import com.vmware.vim25.TaskInfo;
import com.vmware.vim25.TaskInfoState;
import com.vmware.vim25.mo.ServiceInstance;
import com.vmware.vim25.mo.Task;
import com.vmware.vim25.mo.VirtualMachineSnapshot;
import akka.japi.Procedure;
import scala.Option;
/**
* Wrapper around the new-style workpool for existing code.
*/
@Component
public class WorkpoolImpl implements Workpool {
private Logger log = LoggerFactory.getLogger(WorkpoolImpl.class);
@Autowired
private VCManager vcManager;
@Autowired
private WorkpoolManager workpool;
/**
* Return the managed object ID (moid) from the given datacenter name.
*
* @param name Human-readable datacenter name
* @return moid of the given datacenter
*/
private String datacenterNameToMoid(String name) {
// XXX: Fix null issues with this.
ServiceInstance si = vcManager.getConnection().get().get();
return Util.findDatacenter(name, si).getMOR().getVal();
}
private void createTemporarySnapshot(VCConfig vcInfo, InstanceInfo vmInfo) {
// Snapshot, power on, wait for tools, upload ThinApp, install ThinApp,
// upload license, run Setup Capture.
// XXX: Configure MDC in logging to attach current context state for us.
log.debug("Beginning VM preparation for {}/{}.", vcInfo, vmInfo);
ServiceInstance si = vcManager.getConnection().get().get();
com.vmware.vim25.mo.VirtualMachine vm = Util.findVm(vcInfo, vmInfo, si);
try {
log.debug("Creating a temporary snapshot.");
// XXX: Should we check for an existing snapshot?
Task task =
vm.createSnapshot_Task("Temporary Snapshot",
"Manual mode snapshot", false, false);
task.waitForTask();
TaskInfo taskInfo = task.getTaskInfo();
TaskInfoState state = taskInfo.getState();
if (state.equals(TaskInfoState.success)) {
log.debug("VM snapshot creation succeeded.");
} else {
log.error("VM snapshot creation failed.");
throw new TemporarySnapshotException(String.format(
"Failed to create a temporary snapshot: %s.", state));
}
} catch (RuntimeException e) {
throw e;
} catch (InterruptedException ignored) {
/* Ignore */
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
private void removeCurrentSnapshot(VCConfig vcConfig, InstanceInfo vmInfo) {
log.debug("Removing snapshot for {}/{}.", vcConfig, vmInfo);
ServiceInstance si = vcManager.getConnection().get().get();
com.vmware.vim25.mo.VirtualMachine vm = Util.findVm(vcConfig, vmInfo, si);
try {
Task revertTask = vm.revertToCurrentSnapshot_Task(null);
revertTask.waitForTask();
VirtualMachineSnapshot currentSnapshot = vm.getCurrentSnapShot();
Task task =
currentSnapshot.removeSnapshot_Task(false /* removeChildren */);
task.waitForTask();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public Future<Lease> acquire(final com.vmware.thinapp.common.workpool.dto.Workpool workpoolInstance) {
Option<WorkpoolInstance> maybeInstance = workpool.get(workpoolInstance.getId());
if (maybeInstance.isEmpty()) {
throw new RuntimeException("Unable to locate workpool: " + workpoolInstance);
}
final WorkpoolInstance instance = maybeInstance.get();
log.debug("Using workpool: {}.", instance);
akka.dispatch.Future<LeaseModel> future = instance.acquire().get();
// Regular Java future to return to caller.
final SettableFuture<Lease> returnFuture = SettableFuture.create();
future.onComplete(new Procedure<akka.dispatch.Future<LeaseModel>>() {
@Override
public void apply(akka.dispatch.Future<LeaseModel> param) {
try {
LeaseModel mlease = param.get();
InstanceModel clone = mlease.getInstance();
VCConfigModel vcConfigModel = mlease.getVcConfig();
VCConfig vcConfig = new VCConfig();
vcConfig.setDatacenter(vcConfigModel.getDatacenter());
vcConfig.setHost(vcConfigModel.getHost());
vcConfig.setUsername(vcConfigModel.getUsername());
vcConfig.setPassword(vcConfigModel.getPassword());
vcConfig.setDatacenterMoid(datacenterNameToMoid(vcConfig.getDatacenter()));
Lease lease = new Lease();
InstanceInfo inst = new InstanceInfo();
lease.setId(mlease.getId());
lease.setVc(vcConfig);
lease.setVm(inst);
lease.setWorkpool(workpoolInstance);
inst.setGuestUsername(clone.getGuestUsername());
inst.setGuestPassword(clone.getGuestPassword());
inst.setAutologon(clone.getAutologon());
inst.setMoid(clone.getMoid());
ServiceInstance si = vcManager.getConnection().get().get();
com.vmware.vim25.mo.VirtualMachine vm = Util.findVm(vcConfig, inst, si);
inst.setVmxPath(vm.getConfig().files.getVmPathName());
log.debug("Received lease: {}.", lease);
returnFuture.set(lease);
} catch (Throwable t) {
returnFuture.setException(t);
}
}
});
return returnFuture;
}
@Override
public void release(Lease lease) {
log.debug("Releasing lease: {}.", lease);
WorkpoolInstance instance = workpool.get(lease.getWorkpool().getId()).get();
LeaseModel mlease = new LeaseModel();
mlease.setId(lease.getId());
instance.release(mlease).get();
}
@Override
public void withTemporarySnapshot(CallWithTemporarySnapshot runWithSnapshot,
Lease lease) throws Exception {
ServiceInstance si = vcManager.getConnection().get().get();
VirtualMachine vm =
new VirtualMachineImpl(si, lease.getVc(), lease.getVm());
try {
createTemporarySnapshot(lease.getVc(), lease.getVm());
runWithSnapshot.call(vm, lease);
} finally {
removeCurrentSnapshot(lease.getVc(), lease.getVm());
}
}
/**
* Run a job in a temporary snapshot with a given state
*
* @param runWithSnapshot
* @param lease
* @throws Exception
*/
@Override
public void withSnapshot(CallWithTemporarySnapshot runWithSnapshot, Lease lease) throws Exception {
// It's kind of weird that we have two kinds of VM objects. Ours is
// basically just a utility wrapper so it should be refactored to act
// more as a utility than as a complete wrapper.
ServiceInstance si = vcManager.getConnection().get().get();
com.vmware.vim25.mo.VirtualMachine vmMo =
Util.findVm(lease.getVc(), lease.getVm(), si);
VirtualMachine vm =
new VirtualMachineImpl(si, lease.getVc(), lease.getVm());
VirtualMachineSnapshot originalSnapshot = vmMo.getCurrentSnapShot();
try {
runWithSnapshot.call(vm, lease);
} finally {
log.info("Reverting to snapshot {}.", originalSnapshot);
Task task = originalSnapshot.revertToSnapshot_Task(null);
log.debug("Waiting for task {} to complete.", task);
task.waitForTask();
}
}
}
| [
"keerthi@vmware.com"
] | keerthi@vmware.com |
424fbe9de75a78ba1ce5ca4fbb70e837d4a3fd85 | d677e6b3600ef0e7a82006f71c5da1f8fe308cff | /src/com/bjsxt/spark/util/SparkUtils.java | 00ee259e29daee7a59c11b86d2bda0ef1b44b90e | [] | no_license | un-knower/Traffic-1 | faf2c37130ebebde2d2cd3c1664a4dfc99db7dc9 | 324d06c1edbd7a71ad19c2ce753b0ae400c7fefb | refs/heads/master | 2020-03-17T16:08:26.817537 | 2017-12-20T12:27:02 | 2017-12-20T12:27:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,474 | java | package com.bjsxt.spark.util;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.DataFrame;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SQLContext;
import org.apache.spark.sql.hive.HiveContext;
import com.alibaba.fastjson.JSONObject;
import com.bjsxt.spark.conf.ConfigurationManager;
import com.bjsxt.spark.constant.Constants;
import com.spark.spark.test.MockData;
/**
* Spark工具类
* @author Administrator
*
*/
public class SparkUtils {
/**
* 根据当前是否本地测试的配置
* 决定,如何设置SparkConf的master
*/
public static void setMaster(SparkConf conf) {
boolean local = ConfigurationManager.getBoolean(Constants.SPARK_LOCAL);
if(local) {
conf.setMaster("local");
}
}
/**
* 获取SQLContext
* 如果spark.local设置为true,那么就创建SQLContext;否则,创建HiveContext
* @param sc
* @return
*/
public static SQLContext getSQLContext(JavaSparkContext sc) {
boolean local = ConfigurationManager.getBoolean(Constants.SPARK_LOCAL);
if(local) {
return new SQLContext(sc);
} else {
return new HiveContext(sc);
}
}
/**
* 生成模拟数据
* 如果spark.local配置设置为true,则生成模拟数据;否则不生成
* @param sc
* @param sqlContext
*/
public static void mockData(JavaSparkContext sc, SQLContext sqlContext) {
boolean local = ConfigurationManager.getBoolean(Constants.SPARK_LOCAL);
/**
* 如何local为true 说明在本地测试 应该生产模拟数据 RDD-》DataFrame-->注册成临时表0
* false HiveContext 直接可以操作hive表
*/
if(local) {
MockData.mock(sc, sqlContext);
}
}
/**
* 获取指定日期范围内的卡口信息
* @param sqlContext
* @param taskParamsJsonObject
*/
public static JavaRDD<Row> getCameraRDDByDateRange(SQLContext sqlContext, JSONObject taskParamsJsonObject) {
String startDate = ParamUtils.getParam(taskParamsJsonObject, Constants.PARAM_START_DATE);
String endDate = ParamUtils.getParam(taskParamsJsonObject, Constants.PARAM_END_DATE);
String sql =
"SELECT * "
+ "FROM monitor_flow_action "
+ "WHERE date>='" + startDate + "' "
+ "AND date<='" + endDate + "'";
DataFrame monitorDF = sqlContext.sql(sql);
/**
* repartition可以提高stage的并行度
*/
// return actionDF.javaRDD().repartition(1000);
return monitorDF.javaRDD();
}
public static JavaRDD<Row> getCameraRDDByDateRangeAndCars(SQLContext sqlContext, JSONObject taskParamsJsonObject) {
String startDate = ParamUtils.getParam(taskParamsJsonObject, Constants.PARAM_START_DATE);
String endDate = ParamUtils.getParam(taskParamsJsonObject, Constants.PARAM_END_DATE);
String cars = ParamUtils.getParam(taskParamsJsonObject, Constants.FIELD_CARS);
String[] carArr = cars.split(",");
String sql =
"SELECT * "
+ "FROM monitor_flow_action "
+ "WHERE date>='" + startDate + "' "
+ "AND date<='" + endDate + "' "
+ "AND car IN (";
for (int i = 0; i < carArr.length; i++) {
sql += "'" + carArr[i] + "'";
if(i < carArr.length - 1){
sql += ",";
}
}
sql += ")";
System.out.println("sql:"+sql);
DataFrame monitorDF = sqlContext.sql(sql);
/**
* repartition可以提高stage的并行度
*/
// return actionDF.javaRDD().repartition(1000);
return monitorDF.javaRDD();
}
}
| [
"1402357969@qq.com"
] | 1402357969@qq.com |
47f4a9e51fa060b4e7d885d8c9d17d06afa4478f | 383e578ec8ac3043ddece8223494f27f4a4c76dd | /legend.biz/src/main/java/com/tqmall/legend/biz/sms/impl/MobileVerifyRecordServiceImpl.java | 06e8ef8116a10e111107b706955dbd8cc8d44073 | [] | no_license | xie-summer/legend | 0018ee61f9e864204382cd202fe595b63d58343a | 7e7bb14d209e03445a098b84cf63566702e07f15 | refs/heads/master | 2021-06-19T13:44:58.640870 | 2017-05-18T08:34:13 | 2017-05-18T08:34:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,645 | java | package com.tqmall.legend.biz.sms.impl;
import com.tqmall.common.exception.BizException;
import com.tqmall.common.template.BizTemplate;
import com.tqmall.legend.biz.base.BaseServiceImpl;
import com.tqmall.legend.biz.sms.MobileVerifyRecordService;
import com.tqmall.legend.dao.sms.MobileVerifyRecordDao;
import com.tqmall.legend.entity.sms.MobileVerifyRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.validation.constraints.NotNull;
import java.util.*;
/**
* Created by lixiao on 15-3-13.
*/
@Service
public class MobileVerifyRecordServiceImpl extends BaseServiceImpl implements MobileVerifyRecordService {
@Autowired
MobileVerifyRecordDao mobileVerifyRecordDao;
@Override
public List<MobileVerifyRecord> select(Map map) {
return mobileVerifyRecordDao.select(map);
}
@Override
public int insert(MobileVerifyRecord mobileVerifyRecord) {
return mobileVerifyRecordDao.insert(mobileVerifyRecord);
}
@Override
public int update(MobileVerifyRecord mobileVerifyRecord) {
return mobileVerifyRecordDao.updateById(mobileVerifyRecord);
}
@Override
public void saveVerifyRecord(@NotNull String mobile, @NotNull String sendCode) {
// IF 存在记录 THEN 更新验证码
Map<String, Object> queryParam = new HashMap<String, Object>(4);
queryParam.put("mobile", mobile);
List<String> sorts = new ArrayList<String>(1);
sorts.add(" id desc ");
queryParam.put("sorts", sorts);
queryParam.put("offset", 0);
queryParam.put("limit", 1);
List<MobileVerifyRecord> mobileVerifyRecords = this.select(queryParam);
if (!CollectionUtils.isEmpty(mobileVerifyRecords)) {
MobileVerifyRecord mobileVerifyRecord = mobileVerifyRecords.get(0);
mobileVerifyRecord.setCode(sendCode);
mobileVerifyRecord.setGmtModified(new Date());
this.update(mobileVerifyRecord);
return;
}
// 插入一条新的验证码
MobileVerifyRecord mobileVerifyRecord = new MobileVerifyRecord();
mobileVerifyRecord.setCode(sendCode);
mobileVerifyRecord.setMobile(mobile);
mobileVerifyRecord.setGmtModified(new Date());
mobileVerifyRecord.setGmtCreate(new Date());
this.insert(mobileVerifyRecord);
}
@Override
public boolean checkSMSCode(@NotNull String mobile, @NotNull String smsCode, int validTime) {
// 是否通过
boolean isPass = Boolean.FALSE;
Map<String, Object> queryParam = new HashMap<String, Object>(4);
queryParam.put("mobile", mobile);
List<String> sorts = new ArrayList<String>(1);
sorts.add(" id desc ");
queryParam.put("sorts", sorts);
queryParam.put("offset", 0);
queryParam.put("limit", 1);
List<MobileVerifyRecord> mobileVerifyRecords = this.select(queryParam);
if (CollectionUtils.isEmpty(mobileVerifyRecords)) {
return isPass;
}
MobileVerifyRecord mobileVerifyRecord = mobileVerifyRecords.get(0);
Date gmtModified = mobileVerifyRecord.getGmtModified();
if (gmtModified == null) {
return isPass;
}
// 是否超过有效时间
Long diffTime = new Date().getTime() - gmtModified.getTime();
if (diffTime > validTime * 1000) {
return isPass;
}
String code = mobileVerifyRecord.getCode();
if (code != null && code.equals(smsCode)) {
return Boolean.TRUE;
}
return isPass;
}
@Override
public String checkSMSCodeThrowException(final String mobile, final String smsCode, final int validTime) {
return new BizTemplate<String>() {
@Override
protected void checkParams() throws IllegalArgumentException {
}
@Override
protected String process() throws BizException {
Map<String, Object> queryParam = new HashMap<String, Object>(4);
queryParam.put("mobile", mobile);
List<String> sorts = new ArrayList<String>(1);
sorts.add(" id desc ");
queryParam.put("sorts", sorts);
queryParam.put("offset", 0);
queryParam.put("limit", 1);
List<MobileVerifyRecord> mobileVerifyRecords = select(queryParam);
if (CollectionUtils.isEmpty(mobileVerifyRecords)) {
throw new BizException("未发送验证码");
}
MobileVerifyRecord mobileVerifyRecord = mobileVerifyRecords.get(0);
Date gmtModified = mobileVerifyRecord.getGmtModified();
if (gmtModified == null) {
throw new BizException("手机验证码错误");
}
// 是否超过有效时间ms
Long diffTime = new Date().getTime() - gmtModified.getTime();
if (diffTime > validTime) {
throw new BizException("手机验证码已失效,请重新发送");
}
String code = mobileVerifyRecord.getCode();
if (code != null && code.equals(smsCode)) {
return "验证通过";
}
throw new BizException("手机验证码错误");
}
}.execute();
}
@Override
public MobileVerifyRecord getMobileVerifyRecord(final String mobile) {
return new BizTemplate<MobileVerifyRecord>() {
@Override
protected void checkParams() throws IllegalArgumentException {
}
@Override
protected MobileVerifyRecord process() throws BizException {
MobileVerifyRecord mobileVerifyRecord = null;
Map<String, Object> queryParam = new HashMap<String, Object>(4);
queryParam.put("mobile", mobile);
List<String> sorts = new ArrayList<String>(1);
sorts.add(" id desc ");
queryParam.put("sorts", sorts);
queryParam.put("offset", 0);
queryParam.put("limit", 1);
List<MobileVerifyRecord> mobileVerifyRecords = select(queryParam);
if (!CollectionUtils.isEmpty(mobileVerifyRecords)) {
mobileVerifyRecord = mobileVerifyRecords.get(0);
}
return mobileVerifyRecord;
}
}.execute();
}
}
| [
"zhangting.huang@tqmall.com"
] | zhangting.huang@tqmall.com |
09f91d961f3eb5bfc56acb830546f031adf5cbc5 | fbe9278c49e825cf64ef34ab021ea15af208cf64 | /範例程式專案/單元022 Frame Animation和Multi-thread擲骰子遊戲/src/tw/android/Main.java | eeebe0236088838a8f00d58346a8db9972191380 | [] | no_license | amityshih/workspace | 75dcd11a29221ad411cb314e1ec7cb658fa81e50 | 62f1a6d6e8ac3d0df055e2639ca1d1da16c5aabb | refs/heads/master | 2016-09-05T20:09:22.836438 | 2014-04-18T10:09:35 | 2014-04-18T10:09:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,837 | java | package tw.android;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.res.Resources;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
public class Main extends Activity {
private ImageView mImgRollingDice;
private TextView mTxtDiceResult;
private Button mBtnRollDice;
private Handler handler=new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
int iRand = (int)(Math.random()*6 + 1);
String s = getString(R.string.diceResult);
mTxtDiceResult.setText(s + iRand);
switch (iRand) {
case 1:
mImgRollingDice.setImageResource(R.drawable.dice01);
break;
case 2:
mImgRollingDice.setImageResource(R.drawable.dice02);
break;
case 3:
mImgRollingDice.setImageResource(R.drawable.dice03);
break;
case 4:
mImgRollingDice.setImageResource(R.drawable.dice04);
break;
case 5:
mImgRollingDice.setImageResource(R.drawable.dice05);
break;
case 6:
mImgRollingDice.setImageResource(R.drawable.dice06);
break;
}
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setupViewComponent();
}
private void setupViewComponent() {
mImgRollingDice = (ImageView)findViewById(R.id.imgRollingDice);
mTxtDiceResult = (TextView)findViewById(R.id.txtDiceResult);
mBtnRollDice = (Button)findViewById(R.id.btnRollDice);
ObjectAnimator animBtnRotate = ObjectAnimator.ofFloat(mBtnRollDice, "rotation", 0,360);
animBtnRotate.setDuration(3000);
animBtnRotate.start();
mBtnRollDice.setOnClickListener(btnRollDiceOnClickLis);
}
private Button.OnClickListener btnRollDiceOnClickLis = new Button.OnClickListener() {
public void onClick(View v) {
String s = getString(R.string.diceResult);
mTxtDiceResult.setText(s);
Resources res = getResources();
final AnimationDrawable animDraw = (AnimationDrawable)res.getDrawable(R.drawable.anim_drawable);
mImgRollingDice.setImageDrawable(animDraw);
animDraw.start();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(5000);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
animDraw.stop();
handler.sendMessage(handler.obtainMessage());
}
}
).start();
}
};
} | [
"amity.shih@gmail.com"
] | amity.shih@gmail.com |
d21492ebdf60afa65ad8633e326e4793d8bbaa9a | 5f4afbc92a72bd847b8aa9ae95f9be9d706ad7d8 | /esuizhen-service/esuizhen-business-system/src/main/java/com/esuizhen/cloudservice/business/service/business/mdt/PatientActivityService.java | f63ab6b244d61055dd747d5e6cf49806743fa865 | [] | no_license | 331491512/esz | dfc13ba9e142ab1cbacc92cd0bf1b55fec2a05a1 | 8edd10a74b75d36d3963d2ae64602d02ba548b43 | refs/heads/master | 2021-04-06T20:31:45.968785 | 2018-03-16T02:56:36 | 2018-03-16T02:56:36 | 125,451,748 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 441 | java | package com.esuizhen.cloudservice.business.service.business.mdt;
import com.esuizhen.cloudservice.business.bean.TPatientActivitySignupReq;
/**
* @ClassName: PatientActivityService.java
* @Description:
* @author fanpanwei
* @date 2016年9月28日
*/
public interface PatientActivityService {
public Integer searchPatientActivity(TPatientActivitySignupReq req);
public void markPatientActivity(TPatientActivitySignupReq req);
}
| [
"zhuguo@qgs-china.com"
] | zhuguo@qgs-china.com |
2f73b15be1f96bf9907a7bb85feb339e57b4853d | 0f9c232b3e64c8b74446e87ed88818e50421ec4c | /app/src/main/java/com/example/uimihnathome/Fragment/ThongBaoFragment.java | 156ac4b1f85b329850b1bfbafd85cb7d34b3d9e4 | [] | no_license | quoccuong15111997/shopapp | 1aff1bbae618ab2058b195cc26c4f578398a843e | e14b75c82faec31acdf331aa9f265415d2bcda5c | refs/heads/master | 2020-07-03T10:43:49.563747 | 2019-08-12T07:44:35 | 2019-08-12T07:44:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 660 | java | package com.example.uimihnathome.Fragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.uimihnathome.R;
public class ThongBaoFragment extends Fragment {
View view;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_thongbao,container,false);
return view;
}
}
| [
"quoccuong151197@gmail.com"
] | quoccuong151197@gmail.com |
bb0d556b794749e93db3e857e980836c40e9271d | 9c3b9f3c638262b36593ee8382d339779cbe6694 | /ios/src/com/sample/libgdx/game/IOSLauncher.java | 96bb55ee8c484d1cef126b1f85882ab288656d40 | [] | no_license | LibGdxCiSample/test | 2d458f083265b3ceac910fe65a5a9388b7ce9aad | 5b110804e8762a5e290de4abb78c5d807d2c4ace | refs/heads/master | 2020-04-09T10:11:24.323821 | 2015-09-12T22:19:15 | 2015-10-07T12:04:55 | 42,004,436 | 2 | 0 | null | 2015-09-27T05:35:38 | 2015-09-06T13:57:10 | Java | UTF-8 | Java | false | false | 786 | java | package com.sample.libgdx.game;
import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.uikit.UIApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
import com.sample.libgdx.game.MySampleLibgdxGame;
public class IOSLauncher extends IOSApplication.Delegate {
@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
return new IOSApplication(new MySampleLibgdxGame(), config);
}
public static void main(String[] argv) {
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(argv, null, IOSLauncher.class);
pool.close();
}
} | [
"nicofr69.github@gmail.com"
] | nicofr69.github@gmail.com |
9948f36987123e89ac90153e4ed3f83597a81e61 | 2ae1b19920587f2463e64f557fea6c825c8d8af1 | /src/test/java/Utilities/Listeners.java | 41c346609bd156aca8d6573c90846fae00706d6d | [] | no_license | TrishitaTadala/IMS | 0a7043503be73e34dd928be258bbee7ce54d5a2b | 0d401a96781021fabec52abd08fbe4c9e8adaf4b | refs/heads/master | 2022-12-13T05:24:54.550745 | 2020-06-12T05:48:34 | 2020-06-12T05:48:34 | 249,441,020 | 0 | 0 | null | 2022-12-06T00:45:14 | 2020-03-23T13:38:54 | Java | UTF-8 | Java | false | false | 1,319 | java | package Utilities;
/**
* @author Praveen
*
*/
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.TestListenerAdapter;
public class Listeners extends TestListenerAdapter {
public void onTestFailure(ITestResult result) {
String rs = getMethodContext(result);
System.err.println(rs + " | FAILED");
Reporter.log(rs + " | FAILED");
}
@Override
public void onTestSkipped(ITestResult result) {
String rs = getMethodContext(result);
System.out.println(rs + " | SKIPPED");
Reporter.log(rs + " | SKIPPED");
}
@Override
public void onTestSuccess(ITestResult result) {
String rs = getMethodContext(result);
System.out.println(rs + " | PASSED");
Reporter.log(rs + " | PASSED");
}
private String getMethodContext(ITestResult result) {
//String browser = result.getTestContext().getCurrentXmlTest()
//.getParameter("browser");
String testClasss = result.getTestClass().getName();
String name = result.getName();
String rs = testClasss + " | " + name;
return rs;
}
}
| [
"Trishita.Tadala@S5139.inmarsat.local"
] | Trishita.Tadala@S5139.inmarsat.local |
d6b51dd6c285bf42d3f632d6fa0bd15167260a1f | a56a670eee4d3f52d262d8f1828904b20f7396b8 | /src/main/java/org/fwoxford/web/rest/errors/CustomParameterizedException.java | 522510e6c640e92bdb8208b5712db6dfe389a3ab | [] | no_license | kang01/BioBank | 8a2f0441a51286f5765fc159d7b375ff32f0fe35 | c42dfc418afa715281e896f9752e291f08afd3a2 | refs/heads/master | 2022-12-12T17:39:05.648458 | 2018-01-08T01:57:01 | 2018-01-08T01:57:01 | 219,245,250 | 1 | 0 | null | 2022-12-05T23:32:01 | 2019-11-03T03:18:09 | Java | UTF-8 | Java | false | false | 879 | java | package org.fwoxford.web.rest.errors;
/**
* Custom, parameterized exception, which can be translated on the client side.
* For example:
*
* <pre>
* throw new CustomParameterizedException("myCustomError", "hello", "world");
* </pre>
*
* Can be translated with:
*
* <pre>
* "error.myCustomError" : "The server says {{params[0]}} to {{params[1]}}"
* </pre>
*/
public class CustomParameterizedException extends RuntimeException {
private static final long serialVersionUID = 1L;
private final String message;
private final String[] params;
public CustomParameterizedException(String message, String... params) {
super(message);
this.message = message;
this.params = params;
}
public ParameterizedErrorVM getErrorVM() {
return new ParameterizedErrorVM(message, params);
}
}
| [
"luying.geng@fwoxford.org"
] | luying.geng@fwoxford.org |
18d76b35a8dc3bb16b3fd80c7f3ab32f963fe24e | e5e483a34e6d0b304d38b9bc3e466d95921a3a28 | /src/com/coinroster/api/UserSettleContest.java | f1dfcf92097dc01fe6e7eaac5dfced8b02039f07 | [] | no_license | CoinRoster/coinroster-java | a65f7ec31e836d9a5c499d4d2b6b9bb164e01b00 | 8ea0239a4be4446cc6bd269056ec0136e72f9eda | refs/heads/master | 2022-02-19T19:02:54.467545 | 2018-06-25T23:19:40 | 2018-06-25T23:19:40 | 70,530,981 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 30,119 | java | package com.coinroster.api;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Map;
import java.util.TreeMap;
import org.json.JSONArray;
import org.json.JSONObject;
import com.coinroster.DB;
import com.coinroster.MethodInstance;
import com.coinroster.Server;
import com.coinroster.Session;
import com.coinroster.Utils;
import com.coinroster.internal.Backup;
import com.coinroster.internal.BuildLobby;
import com.coinroster.internal.UserMail;
public class UserSettleContest extends Utils
{
public static String method_level = "standard";
@SuppressWarnings("unused")
public UserSettleContest(MethodInstance method) throws Exception
{
JSONObject
input = method.input,
output = method.output;
Session session = method.session;
Connection sql_connection = method.sql_connection;
DB db = new DB(sql_connection);
method : {
//------------------------------------------------------------------------------------
boolean do_update = true;
int contest_id = input.getInt("contest_id");
String contest_admin;
if(session==null)
contest_admin = "ContestBot";
else
contest_admin = session.user_id();
new Backup();
// lock it all
Statement statement = sql_connection.createStatement();
statement.execute("lock tables user write, contest write, entry write, transaction write, progressive write");
try {
lock : {
// initial contest validation
JSONObject contest = db.select_contest(contest_id);
String
contest_title = contest.getString("title"),
contest_type = contest.getString("contest_type");
log("Validating contest #" + contest_id);
log("Type: " + contest_type);
if (contest == null)
{
String error = "Invalid contest id: " + contest_id;
log(error);
output.put("error", error);
break lock;
}
if (contest.getInt("status") != 2)
{
String error = "Contest " + contest_id + " is not in play";
log(error);
output.put("error", error);
break lock;
}
log("");
//--------------------------------------------------------------------------------------------------------------
// Users can make only PARI-MUTUEL contests
int winning_outcome = 0;
//--------------------------------------------------------------------------------------------------------------
// validate settlement data provided by contest admin
log("Validating settlement data");
JSONArray option_table = new JSONArray(contest.getString("option_table"));
boolean valid_option = false;
winning_outcome = input.getInt("winning_outcome");
for (int i=0; i < option_table.length(); i++)
{
JSONObject option = option_table.getJSONObject(i);
int option_id = option.getInt("id");
if (winning_outcome == option_id)
{
option.put("outcome", 1);
valid_option = true;
}
else option.put("outcome", 0);
option_table.put(i, option);
}
if (!valid_option)
{
String error = "Invalid winning option id: " + winning_outcome;
log(error);
output.put("error", error);
break lock;
}
log("");
//--------------------------------------------------------------------------------------------------------------
// if we get here, user has provided valid settlement data for a contest that is in play
//--------------------------------------------------------------------------------------------------------------
// checksum entries against transactions
log("Validating prize pool ...");
PreparedStatement get_transaction_totals = sql_connection.prepareStatement("select sum(case when trans_type = 'BTC-CONTEST-ENTRY' then amount end), sum(case when trans_type = 'RC-CONTEST-ENTRY' then amount end) from transaction where contest_id = ?");
get_transaction_totals.setInt(1, contest_id);
ResultSet transaction_totals_rs = get_transaction_totals.executeQuery();
transaction_totals_rs.next();
PreparedStatement get_entry_total = sql_connection.prepareStatement("select sum(amount) from entry where contest_id = ?");
get_entry_total.setInt(1, contest_id);
ResultSet entry_total_rs = get_entry_total.executeQuery();
entry_total_rs.next();
double
btc_wagers_total = transaction_totals_rs.getDouble(1),
rc_wagers_total = transaction_totals_rs.getDouble(2),
total_from_transactions = add(btc_wagers_total, rc_wagers_total, 0),
total_from_entries = entry_total_rs.getDouble(1);
log("Total from transactions: " + total_from_transactions);
log("Total from entries: " + total_from_entries);
if (total_from_transactions != total_from_entries)
{
String error = "Total based on transactions does not match total based on entries - this is serious!";
log(error);
output.put("error", error);
break lock;
}
log("");
//--------------------------------------------------------------------------------------------------------------
// pull all funds from the contest
log("Pulling funds from contest");
JSONObject liability_account = db.select_user("username", "internal_liability");
String liability_account_id = liability_account.getString("user_id");
JSONObject contest_account = db.select_user("username", "internal_contest_asset");
String contest_account_id = contest_account.getString("user_id");
double
btc_contest_balance = contest_account.getDouble("btc_balance"),
rc_contest_balance = contest_account.getDouble("rc_balance");
btc_contest_balance = subtract(btc_contest_balance, btc_wagers_total, 0);
rc_contest_balance = subtract(rc_contest_balance, rc_wagers_total, 0);
if (do_update)
{
db.update_btc_balance(contest_account_id, btc_contest_balance);
db.update_rc_balance(contest_account_id, rc_contest_balance);
}
log("");
//--------------------------------------------------------------------------------------------------------------
// prepare rc swap
// our gross liability does not change at all during contest settlement, but the RC-to-BTC distribution changes
// at this stage, we convert all RC pulled from the contest into BTC
// later, we will convert the sum of all referrer payouts from BTC to RC
log("Swapping all RC to BTC");
double
btc_liability_balance = liability_account.getDouble("btc_balance"),
rc_liability_balance = liability_account.getDouble("rc_balance"),
opening_rc_liability_balance = rc_liability_balance; // used later to determine net swap
btc_liability_balance = subtract(btc_liability_balance, rc_wagers_total, 0); // subtract increases liability
rc_liability_balance = add(rc_liability_balance, rc_wagers_total, 0); // add decreases liability
log("");
//--------------------------------------------------------------------------------------------------------------
// calculate some general figures for the pool
double
rake = contest.getDouble("rake"), // e.g. 0.01 if rake is 1%
rake_amount = multiply(rake, total_from_transactions, 0),
actual_rake_amount = total_from_transactions, // gets decremented every time something is paid out; remainder -> internal_asset
progressive_paid = 0,
user_winnings_total = subtract(total_from_transactions, rake_amount, 0);
log("Pool: " + total_from_transactions);
log("Rake: " + rake);
log("Rake amount: " + rake_amount);
log("User winnings: " + user_winnings_total);
log("");
//--------------------------------------------------------------------------------------------------------------
// calculate referral rewards / process rake credits
log("Calculating referral rewards...");
TreeMap<String, Double> referrer_map = new TreeMap<String, Double>();
double total_referrer_payout = 0;
JSONArray entries = db.select_contest_entries(contest_id);
for (int i=0, limit=entries.length(); i<limit; i++)
{
JSONObject entry = entries.getJSONObject(i);
int entry_id = entry.getInt("entry_id");
String user_id = entry.getString("user_id");
JSONObject user = db.select_user("id", user_id);
int
free_play = user.getInt("free_play"),
withdrawal_locked = user.getInt("withdrawal_locked");
double
user_btc_balance = user.getDouble("btc_balance"),
entry_amount = entry.getDouble("amount"),
user_raked_amount = multiply(entry_amount, rake, 0);
log("");
log("Entry ID: " + entry_id);
log("User ID: " + user_id);
log("Amount: " + entry_amount);
log("Raked amount: " + user_raked_amount);
if (free_play == 1)
{
log("Free play credit: " + user_raked_amount);
user_btc_balance = add(user_btc_balance, user_raked_amount, 0);
actual_rake_amount = subtract(actual_rake_amount, user_raked_amount, 0);
if (do_update)
{
db.update_btc_balance(user_id, user_btc_balance);
String
transaction_type = "BTC-RAKE-CREDIT",
from_account = contest_account_id,
to_account = user_id,
from_currency = "BTC",
to_currency = "BTC",
memo = "Rake credit (BTC) from: " + contest_title;
PreparedStatement create_transaction = sql_connection.prepareStatement("insert into transaction(created, created_by, trans_type, from_account, to_account, amount, from_currency, to_currency, memo, contest_id) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
create_transaction.setLong(1, System.currentTimeMillis());
create_transaction.setString(2, contest_admin);
create_transaction.setString(3, transaction_type);
create_transaction.setString(4, from_account);
create_transaction.setString(5, to_account);
create_transaction.setDouble(6, user_raked_amount);
create_transaction.setString(7, from_currency);
create_transaction.setString(8, to_currency);
create_transaction.setString(9, memo);
create_transaction.setInt(10, contest_id);
create_transaction.executeUpdate();
}
}
else if (withdrawal_locked == 0) // affiliates only earn on accounts that have met playing requirement
{
String referrer = user.getString("referrer");
if (referrer.equals("")) continue;
// process referral payout if applicable
double
referral_program = user.getDouble("referral_program"),
referrer_payout = multiply(user_raked_amount, referral_program, 0);
actual_rake_amount = subtract(actual_rake_amount, referrer_payout, 0);
total_referrer_payout = add(total_referrer_payout, referrer_payout, 0);
log("Referral payout for " + referrer + " : " + referrer_payout);
if (referrer_map.containsKey(referrer))
{
referrer_payout = add(referrer_payout, referrer_map.get(referrer), 0);
referrer_map.put(referrer, referrer_payout);
}
else referrer_map.put(referrer, referrer_payout);
}
else if (withdrawal_locked == 1) db.credit_user_rollover_progress(user, entry_amount);
}
log("");
//--------------------------------------------------------------------------------------------------------------
// we previously converted all RC to BTC; now we create RC to fund affiliate payouts
log("Processing net swap ...");
btc_liability_balance = add(btc_liability_balance, total_referrer_payout, 0); // add decreases liability
rc_liability_balance = subtract(rc_liability_balance, total_referrer_payout, 0); // subtract increases liability
// at this point, we write out the updated liability balances
if (do_update)
{
db.update_btc_balance(liability_account_id, btc_liability_balance);
db.update_rc_balance(liability_account_id, rc_liability_balance);
}
// compare final rc_liability_balance against opening balance to determine net swap
log("Opening RC liability balance: " + opening_rc_liability_balance);
log("New RC liability balance: " + rc_liability_balance);
if (rc_liability_balance == opening_rc_liability_balance) log("No net swap");
else // net swap exists
{
String
swap_trans_type = null,
swap_from_currency = null,
swap_to_currency = null,
swap_memo = "Net swap for contest #" + contest_id;
double swap_amount = 0;
if (rc_liability_balance < opening_rc_liability_balance) // rc liability has increased; net creation of RC
{
swap_trans_type = "BTC-SWAP-TO-RC";
swap_from_currency = "BTC";
swap_to_currency = "RC";
swap_amount = subtract(opening_rc_liability_balance, rc_liability_balance, 0);
}
else if (rc_liability_balance > opening_rc_liability_balance) // rc liability has decreased; net destruction of RC
{
swap_trans_type = "RC-SWAP-TO-BTC";
swap_from_currency = "RC";
swap_to_currency = "BTC";
swap_amount = subtract(rc_liability_balance, opening_rc_liability_balance, 0);
}
log("Swap: " + swap_trans_type);
if (do_update)
{
PreparedStatement swap = sql_connection.prepareStatement("insert into transaction(created, created_by, trans_type, from_account, to_account, amount, from_currency, to_currency, memo, contest_id) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
swap.setLong(1, System.currentTimeMillis());
swap.setString(2, contest_admin);
swap.setString(3, swap_trans_type);
swap.setString(4, liability_account_id);
swap.setString(5, liability_account_id);
swap.setDouble(6, swap_amount);
swap.setString(7, swap_from_currency);
swap.setString(8, swap_to_currency);
swap.setString(9, swap_memo);
swap.setInt(10, contest_id);
swap.executeUpdate();
}
}
log("");
//--------------------------------------------------------------------------------------------------------------
// process referral rewards
log("Processing referral rewards");
for (Map.Entry<String, Double> entry : referrer_map.entrySet())
{
String user_id = entry.getKey();
double referrer_payout = entry.getValue();
JSONObject user = db.select_user("id", user_id);
double user_rc_balance = user.getDouble("rc_balance");
user_rc_balance = add(user_rc_balance, referrer_payout, 0);
if (do_update)
{
db.update_rc_balance(user_id, user_rc_balance);
String
transaction_type = "RC-REFERRAL-REVENUE",
from_account = liability_account_id,
to_account = user_id,
from_currency = "RC",
to_currency = "RC",
memo = "Referral revenue (RC) from: " + contest_title;
PreparedStatement create_transaction = sql_connection.prepareStatement("insert into transaction(created, created_by, trans_type, from_account, to_account, amount, from_currency, to_currency, memo, contest_id) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
create_transaction.setLong(1, System.currentTimeMillis());
create_transaction.setString(2, contest_admin);
create_transaction.setString(3, transaction_type);
create_transaction.setString(4, from_account);
create_transaction.setString(5, to_account);
create_transaction.setDouble(6, referrer_payout);
create_transaction.setString(7, from_currency);
create_transaction.setString(8, to_currency);
create_transaction.setString(9, memo);
create_transaction.setInt(10, contest_id);
create_transaction.executeUpdate();
String
subject = "Referral revenue from: " + contest_title,
message_body = "";
message_body += "You earned <b>" + format_btc(referrer_payout) + " RC</b> in referral revenue from: <b>" + contest_title + "</b>";
message_body += "<br/>";
message_body += "<br/>";
message_body += "<a href='" + Server.host + "/account/transactions.html'>Click here</a> to view your transactions.";
new UserMail(user, subject, message_body);
}
}
log("");
//--------------------------------------------------------------------------------------------------------------
// below is the main winnings processing section
//--------------------------------------------------------------------------------------------------------------
log("Processing winnings ...");
PreparedStatement get_amounts = sql_connection.prepareStatement("select sum(if(entry_data = ?, amount, 0)) from entry where contest_id = ?");
get_amounts.setInt(1, winning_outcome);
get_amounts.setInt(2, contest_id);
ResultSet amount_rs = get_amounts.executeQuery();
amount_rs.next();
double winning_outcome_total = amount_rs.getDouble(1);
if (winning_outcome_total == 0) // nobody picked the winning outcome
{
if (!contest.isNull("progressive"))
{
String progressive_code = contest.getString("progressive");
JSONObject
progressive = db.select_progressive(progressive_code),
internal_progressive = db.select_user("username", "internal_progressive");
String internal_progressive_id = internal_progressive.getString("user_id");
double
progressive_balance = progressive.getDouble("balance"),
internal_progressive_balance = internal_progressive.getDouble("btc_balance");
progressive_balance = add(progressive_balance, user_winnings_total, 0);
internal_progressive_balance = add(internal_progressive_balance, user_winnings_total, 0);
actual_rake_amount = subtract(actual_rake_amount, user_winnings_total, 0);
db.update_btc_balance(internal_progressive_id, internal_progressive_balance);
String
transaction_type = "BTC-PROGRESSIVE-HOLD",
from_account = contest_account_id,
to_account = internal_progressive_id,
from_currency = "BTC",
to_currency = "BTC",
memo = "Progressive hold for contest #" + contest_id;
PreparedStatement create_transaction = sql_connection.prepareStatement("insert into transaction(created, created_by, trans_type, from_account, to_account, amount, from_currency, to_currency, memo, contest_id) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
create_transaction.setLong(1, System.currentTimeMillis());
create_transaction.setString(2, contest_admin);
create_transaction.setString(3, transaction_type);
create_transaction.setString(4, from_account);
create_transaction.setString(5, to_account);
create_transaction.setDouble(6, user_winnings_total);
create_transaction.setString(7, from_currency);
create_transaction.setString(8, to_currency);
create_transaction.setString(9, memo);
create_transaction.setInt(10, contest_id);
create_transaction.executeUpdate();
PreparedStatement update_progressive = sql_connection.prepareStatement("update progressive set balance = ? where code = ?");
update_progressive.setDouble(1, progressive_balance);
update_progressive.setString(2, progressive_code);
update_progressive.executeUpdate();
}
}
else // at least one wager was placed on the winning outcome
{
if (!contest.isNull("progressive"))
{
String progressive_code = contest.getString("progressive");
JSONObject
progressive = db.select_progressive(progressive_code),
internal_progressive = db.select_user("username", "internal_progressive");
String internal_progressive_id = internal_progressive.getString("user_id");
double
progressive_balance = progressive.getDouble("balance"),
internal_progressive_balance = internal_progressive.getDouble("btc_balance");
internal_progressive_balance = subtract(internal_progressive_balance, progressive_balance, 0);
user_winnings_total = add(user_winnings_total, progressive_balance, 0);
actual_rake_amount = add(actual_rake_amount, progressive_balance, 0); // will get decremented back down
progressive_paid = progressive_balance;
progressive_balance = 0;
db.update_btc_balance(internal_progressive_id, internal_progressive_balance);
String
transaction_type = "BTC-PROGRESSIVE-DISBURSEMENT",
from_account = internal_progressive_id,
to_account = contest_account_id,
from_currency = "BTC",
to_currency = "BTC",
memo = "Progressive disbursement for contest #" + contest_id;
PreparedStatement create_transaction = sql_connection.prepareStatement("insert into transaction(created, created_by, trans_type, from_account, to_account, amount, from_currency, to_currency, memo, contest_id) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
create_transaction.setLong(1, System.currentTimeMillis());
create_transaction.setString(2, contest_admin);
create_transaction.setString(3, transaction_type);
create_transaction.setString(4, from_account);
create_transaction.setString(5, to_account);
create_transaction.setDouble(6, user_winnings_total);
create_transaction.setString(7, from_currency);
create_transaction.setString(8, to_currency);
create_transaction.setString(9, memo);
create_transaction.setInt(10, contest_id);
create_transaction.executeUpdate();
PreparedStatement update_progressive = sql_connection.prepareStatement("update progressive set balance = 0 where code = ?");
update_progressive.setString(1, progressive_code);
update_progressive.executeUpdate();
}
double payout_ratio = divide(user_winnings_total, winning_outcome_total, 0);
log("Winning selection: " + winning_outcome);
log("Total wagered on winning outcome: " + winning_outcome_total);
log("Payout ratio: " + payout_ratio);
// select all winning wagers summed by user_id
PreparedStatement select_entries = sql_connection.prepareStatement("select user_id, sum(amount) from entry where contest_id = ? and entry_data = ? group by user_id");
select_entries.setInt(1, contest_id);
select_entries.setInt(2, winning_outcome);
ResultSet entry_rs = select_entries.executeQuery();
while (entry_rs.next())
{
String user_id = entry_rs.getString(1);
JSONObject user = db.select_user("id", user_id);
double
user_wager = entry_rs.getDouble(2),
user_btc_balance = user.getDouble("btc_balance"),
user_winnings = multiply(user_wager, payout_ratio, 0);
log("");
log("User: " + user_id);
log("Wager: " + user_wager);
log("Winnings: " + user_winnings);
user_btc_balance = add(user_btc_balance, user_winnings, 0);
actual_rake_amount = subtract(actual_rake_amount, user_winnings, 0);
if (do_update)
{
db.update_btc_balance(user_id, user_btc_balance);
String
transaction_type = "BTC-CONTEST-WINNINGS",
from_account = contest_account_id,
to_account = user_id,
from_currency = "BTC",
to_currency = "BTC",
memo = "Winnings (BTC) from: " + contest_title;
PreparedStatement create_transaction = sql_connection.prepareStatement("insert into transaction(created, created_by, trans_type, from_account, to_account, amount, from_currency, to_currency, memo, contest_id) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
create_transaction.setLong(1, System.currentTimeMillis());
create_transaction.setString(2, contest_admin);
create_transaction.setString(3, transaction_type);
create_transaction.setString(4, from_account);
create_transaction.setString(5, to_account);
create_transaction.setDouble(6, user_winnings);
create_transaction.setString(7, from_currency);
create_transaction.setString(8, to_currency);
create_transaction.setString(9, memo);
create_transaction.setInt(10, contest_id);
create_transaction.executeUpdate();
String
subject = "You picked the correct outcome in: " + contest_title,
message_body = "";
message_body += "You picked the correct outcome in: <b>" + contest_title + "</b>";
message_body += "<br/>";
message_body += "<br/>";
message_body += "Payout: <b>" + format_btc(user_winnings) + " BTC</b>";
message_body += "<br/>";
message_body += "<br/>";
message_body += "<a href='" + Server.host + "/contests/entries.html?contest_id=" + contest_id + "'>Click here</a> for detailed results.";
new UserMail(user, subject, message_body);
}
}
}
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------
// end of winnings processing
log("");
//--------------------------------------------------------------------------------------------------------------
// any funds that have not been paid out as winnings or referral revenue are credited to internal_asset
log("Crediting asset account: " + actual_rake_amount);
JSONObject internal_asset = db.select_user("username", "internal_asset");
String internal_asset_id = internal_asset.getString("user_id");
double internal_asset_btc_balance = internal_asset.getDouble("btc_balance");
internal_asset_btc_balance = add(internal_asset_btc_balance, actual_rake_amount, 0);
if (do_update) db.update_btc_balance(internal_asset_id, internal_asset_btc_balance);
String
transaction_type = "BTC-RAKE",
from_account = contest_account_id,
to_account = internal_asset_id,
from_currency = "BTC",
to_currency = "BTC",
memo = "Rake (BTC) from contest #" + contest_id;
if (do_update)
{
PreparedStatement create_transaction = sql_connection.prepareStatement("insert into transaction(created, created_by, trans_type, from_account, to_account, amount, from_currency, to_currency, memo, contest_id) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
create_transaction.setLong(1, System.currentTimeMillis());
create_transaction.setString(2, contest_admin);
create_transaction.setString(3, transaction_type);
create_transaction.setString(4, from_account);
create_transaction.setString(5, to_account);
create_transaction.setDouble(6, actual_rake_amount);
create_transaction.setString(7, from_currency);
create_transaction.setString(8, to_currency);
create_transaction.setString(9, memo);
create_transaction.setInt(10, contest_id);
create_transaction.executeUpdate();
}
log("");
//--------------------------------------------------------------------------------------------------------------
// update contest with settlement info
log("Updating contest");
if (do_update)
{
PreparedStatement update_contest = null;
update_contest = sql_connection.prepareStatement("update contest set status = 3, settled_by = ?, option_table = ?, settled = ?, progressive_paid = ? where id = ?");
update_contest.setString(1, contest_admin);
update_contest.setString(2, option_table.toString());
update_contest.setLong(3, System.currentTimeMillis());
update_contest.setDouble(4, progressive_paid);
update_contest.setInt(5, contest_id);
update_contest.executeUpdate();
}
log("");
if (do_update) output.put("status", "1");
else output.put("error", "SettleContest is in test mode - updates have been turned off");
}
}
catch (Exception e)
{
output.put("error", e.getMessage());
Server.exception(e);
}
finally
{
statement.execute("unlock tables");
}
new BuildLobby(sql_connection);
//------------------------------------------------------------------------------------
} method.response.send(output);
}
} | [
"govi218mu@gmail.com"
] | govi218mu@gmail.com |
0b86552c29a63a9b8e9cd5839bf5ca4f187b75a2 | 7219f75733d906ff930e1b6ba1be249d6007b582 | /src/com/vikings/sanguo/ui/alert/PlayerWantedConfirmTip.java | ae258cac4363322d85069f46e5865723f9bdd7f6 | [] | no_license | wongainia/sanguo | 9c9b528a3b4cfaf58f94badf71add1b8bb77e038 | 55e38be665f1b9e3a4dc7a1caaa09728563cf4b2 | refs/heads/master | 2020-05-23T09:51:26.455001 | 2019-05-14T22:44:06 | 2019-05-14T22:44:06 | 186,711,060 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,513 | java | package com.vikings.sanguo.ui.alert;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import com.vikings.sanguo.R;
import com.vikings.sanguo.biz.GameBiz;
import com.vikings.sanguo.cache.Account;
import com.vikings.sanguo.exception.GameException;
import com.vikings.sanguo.invoker.BaseInvoker;
import com.vikings.sanguo.model.BriefGuildInfoClient;
import com.vikings.sanguo.model.ItemBag;
import com.vikings.sanguo.model.OtherUserClient;
import com.vikings.sanguo.model.ReturnInfoClient;
import com.vikings.sanguo.utils.IconUtil;
import com.vikings.sanguo.utils.StringUtil;
import com.vikings.sanguo.utils.ViewUtil;
import com.vikings.sanguo.widget.CustomConfirmDialog;
public class PlayerWantedConfirmTip extends CustomConfirmDialog implements
OnClickListener {
private static final int layout = R.layout.alert_player_wanted_confirm;
private OtherUserClient ouc;
private BriefGuildInfoClient bgic;
private ItemBag itemBag;
public PlayerWantedConfirmTip(OtherUserClient ouc,
BriefGuildInfoClient bgic, ItemBag itemBag) {
super("确认追杀目标", CustomConfirmDialog.DEFAULT);
this.bgic = bgic;
this.ouc = ouc;
this.itemBag = itemBag;
setButton(FIRST_BTN, "确定", this);
setButton(SECOND_BTN, "取消", closeL);
}
public void show() {
setValue();
super.show();
}
private void setValue() {
if (ouc.bref().isVip()) {
IconUtil.setUserIcon(
(ViewGroup) content.findViewById(R.id.iconLayout),
ouc.bref(), "VIP" + ouc.bref().getCurVip().getLevel());
} else {
IconUtil.setUserIcon(
(ViewGroup) content.findViewById(R.id.iconLayout),
ouc.bref());
}
ViewUtil.setText(content, R.id.nickName, ouc.getNick());
ViewUtil.setText(content, R.id.userID, "(ID:" + ouc.getId().intValue()
+ ")");
String countryName = ouc.bref().getCountryName();
ViewUtil.setText(content, R.id.countryName,
"国家:" + (StringUtil.isNull(countryName) ? "无" : countryName));
if (bgic == null) {
ViewUtil.setText(content, R.id.guildName, "家族:无");
} else {
ViewUtil.setText(content, R.id.guildName, "家族:" + bgic.getName());
}
}
@Override
protected View getContent() {
return controller.inflate(layout, contentLayout, false);
}
@Override
public void onClick(View v) {
if (Account.user.getCountry().intValue() == ouc.getCountry()) {
dismiss();
controller.alert("抱歉,追杀令使用失败!<br/>不可对本国玩家发布追杀令,请填写敌国玩家的ID;");
return;
}
if (ouc.getManor().getPos() == 0) {
dismiss();
controller.alert("抱歉,追杀令使用失败!<br>你选择的用户级别太低,等他开启了世界征战再来吧!");
return;
}
if (ouc.isWanted()) {
dismiss();
controller.alert("抱歉,追杀令使用失败!<br>目标正在被人追杀,请不要重复使用!");
return;
}
new PlayerWantedInvoker().start();
}
private class PlayerWantedInvoker extends BaseInvoker {
private ReturnInfoClient ric;
@Override
protected String loadingMsg() {
return "发布中...";
}
@Override
protected String failMsg() {
return "使用" + itemBag.getItem().getName() + "失败";
}
@Override
protected void fire() throws GameException {
ric = GameBiz.getInstance().playerWanted(ouc.getId());
}
@Override
protected void onOK() {
dismiss();
ric.setMsg("使用" + itemBag.getItem().getName() + "成功");
controller.updateUI(ric, true, false, true);
}
}
}
| [
"dengyuanming@dengyuanming"
] | dengyuanming@dengyuanming |
5828ec05ee8307858196cc4fed74e253eccc756c | a89a30a000a6c7eef6853aacbe051985f1965d6a | /topcoder/sources/MinCostPalindrome.java | 84f174f4712fd0a3f30f7e21543972efeaa33333 | [] | no_license | ak795/acm | 9edd7d18ddb6efeed8184b91489005aec7425caa | 81787e16e23ce54bf956714865b7162c0188eb3a | refs/heads/master | 2021-01-15T19:36:00.052971 | 2012-02-06T02:25:23 | 2012-02-06T02:25:23 | 44,054,046 | 1 | 0 | null | 2015-10-11T13:53:25 | 2015-10-11T13:53:23 | null | UTF-8 | Java | false | false | 4,878 | java | public class MinCostPalindrome {
public int getMinimum(String s, int oCost, int xCost) {
int n = s.length();
int res = 0;
for (int i = 0; i < n / 2; ++i) {
int j = n - i - 1;
char p = s.charAt(i), q = s.charAt(j);
if (p == q) {
if (p == '?')
res += Math.min(oCost, xCost) * 2;
} else {
if (p != '?' && q != '?') {
res = -1;
break;
} else if (p == 'o' || q == 'o') {
res += oCost;
} else {
res += xCost;
}
}
}
return res;
}
// BEGIN CUT HERE
public static void main(String[] args) {
if (args.length == 0) {
MinCostPalindromeHarness.run_test(-1);
} else {
for (int i=0; i<args.length; ++i)
MinCostPalindromeHarness.run_test(Integer.valueOf(args[i]));
}
}
// END CUT HERE
}
// BEGIN CUT HERE
class MinCostPalindromeHarness {
public static void run_test(int casenum) {
if (casenum != -1) {
if (runTestCase(casenum) == -1)
System.err.println("Illegal input! Test case " + casenum + " does not exist.");
return;
}
int correct = 0, total = 0;
for (int i=0;; ++i) {
int x = runTestCase(i);
if (x == -1) {
if (i >= 100) break;
continue;
}
correct += x;
++total;
}
if (total == 0) {
System.err.println("No test cases run.");
} else if (correct < total) {
System.err.println("Some cases FAILED (passed " + correct + " of " + total + ").");
} else {
System.err.println("All " + total + " tests passed!");
}
}
static boolean compareOutput(int expected, int result) { return expected == result; }
static String formatResult(int res) {
return String.format("%d", res);
}
static int verifyCase(int casenum, int expected, int received) {
System.err.print("Example " + casenum + "... ");
if (compareOutput(expected, received)) {
System.err.println("PASSED");
return 1;
} else {
System.err.println("FAILED");
System.err.println(" Expected: " + formatResult(expected));
System.err.println(" Received: " + formatResult(received));
return 0;
}
}
static int runTestCase(int casenum__) {
switch(casenum__) {
case 0: {
String s = "oxo?xox?";
int oCost = 3;
int xCost = 5;
int expected__ = 8;
return verifyCase(casenum__, expected__, new MinCostPalindrome().getMinimum(s, oCost, xCost));
}
case 1: {
String s = "x??x";
int oCost = 9;
int xCost = 4;
int expected__ = 8;
return verifyCase(casenum__, expected__, new MinCostPalindrome().getMinimum(s, oCost, xCost));
}
case 2: {
String s = "ooooxxxx";
int oCost = 12;
int xCost = 34;
int expected__ = -1;
return verifyCase(casenum__, expected__, new MinCostPalindrome().getMinimum(s, oCost, xCost));
}
case 3: {
String s = "oxoxooxxxxooxoxo";
int oCost = 7;
int xCost = 4;
int expected__ = 0;
return verifyCase(casenum__, expected__, new MinCostPalindrome().getMinimum(s, oCost, xCost));
}
case 4: {
String s = "?o";
int oCost = 6;
int xCost = 2;
int expected__ = 6;
return verifyCase(casenum__, expected__, new MinCostPalindrome().getMinimum(s, oCost, xCost));
}
case 5: {
String s = "????????????????????";
int oCost = 50;
int xCost = 49;
int expected__ = 980;
return verifyCase(casenum__, expected__, new MinCostPalindrome().getMinimum(s, oCost, xCost));
}
case 6: {
String s = "o??oxxo?xoox?ox??x??" ;
int oCost = 3;
int xCost = 10;
int expected__ = 38;
return verifyCase(casenum__, expected__, new MinCostPalindrome().getMinimum(s, oCost, xCost));
}
// custom cases
case 7: {
String s = "o??oxxo?xoox?ox??x??";
int oCost = 3;
int xCost = 10;
int expected__ = 38;
return verifyCase(casenum__, expected__, new MinCostPalindrome().getMinimum(s, oCost, xCost));
}
/* case 8: {
String s = ;
int oCost = ;
int xCost = ;
int expected__ = ;
return verifyCase(casenum__, expected__, new MinCostPalindrome().getMinimum(s, oCost, xCost));
}*/
/* case 9: {
String s = ;
int oCost = ;
int xCost = ;
int expected__ = ;
return verifyCase(casenum__, expected__, new MinCostPalindrome().getMinimum(s, oCost, xCost));
}*/
default:
return -1;
}
}
}
// END CUT HERE
| [
"rock.spartacus@gmail.com"
] | rock.spartacus@gmail.com |
0dd7912a0f683dfc3fd69d51a9570cd7f63ea3a5 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/1/1_a64eae67b35ba44593e79b2fab36e4afd28c7e82/ClassNode/1_a64eae67b35ba44593e79b2fab36e4afd28c7e82_ClassNode_s.java | 41aa281420cfc939b873d5338c7b8a9d091ab9f9 | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 9,257 | java | /**
* Copyright (c) 2009, Adobe Systems, Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of the Adobe Systems, Incorporated. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.adobe.ac.pmd.nodes.impl;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.adobe.ac.pmd.nodes.IAttribute;
import com.adobe.ac.pmd.nodes.IClass;
import com.adobe.ac.pmd.nodes.IConstant;
import com.adobe.ac.pmd.nodes.IFunction;
import com.adobe.ac.pmd.nodes.IMetaData;
import com.adobe.ac.pmd.nodes.MetaData;
import com.adobe.ac.pmd.nodes.Modifier;
import com.adobe.ac.pmd.nodes.utils.MetaDataUtils;
import com.adobe.ac.pmd.parser.IParserNode;
import com.adobe.ac.pmd.parser.NodeKind;
class ClassNode extends AbstractNode implements IClass
{
private final List< IAttribute > attributes;
private IParserNode block;
private final List< IConstant > constants;
private IFunction constructor;
private String extensionName;
private final List< IFunction > functions;
private List< IParserNode > implementations;
private final Map< MetaData, List< IMetaData > > metaDataList;
private final Set< Modifier > modifiers;
private IdentifierNode name;
protected ClassNode( final IParserNode node )
{
super( node );
modifiers = new HashSet< Modifier >();
metaDataList = new LinkedHashMap< MetaData, List< IMetaData > >();
implementations = new ArrayList< IParserNode >();
constants = new ArrayList< IConstant >();
attributes = new ArrayList< IAttribute >();
functions = new ArrayList< IFunction >();
name = null;
}
public void add( final IMetaData metaData )
{
final MetaData metaDataImpl = MetaData.create( metaData.getName() );
if ( !metaDataList.containsKey( metaDataImpl ) )
{
metaDataList.put( metaDataImpl,
new ArrayList< IMetaData >() );
}
metaDataList.get( metaDataImpl ).add( metaData );
}
public void add( final Modifier modifier )
{
modifiers.add( modifier );
}
@Override
public ClassNode compute()
{
if ( getInternalNode().numChildren() != 0 )
{
for ( final IParserNode node : getInternalNode().getChildren() )
{
if ( node.is( NodeKind.CONTENT ) )
{
computeClassContent( node );
}
else if ( node.is( NodeKind.MOD_LIST ) )
{
computeModifierList( this,
node );
}
else if ( node.is( NodeKind.NAME ) )
{
name = IdentifierNode.create( node );
}
else if ( node.is( NodeKind.META_LIST ) )
{
MetaDataUtils.computeMetaDataList( this,
node );
}
detectImplementations( node );
detectExtensions( node );
}
for ( final IFunction function : functions )
{
if ( name.toString().equals( function.getName() ) )
{
constructor = function;
}
}
}
return this;
}
public List< IAttribute > getAttributes()
{
return attributes;
}
@Override
public double getAverageCyclomaticComplexity()
{
if ( functions.isEmpty() )
{
return 0;
}
int totalCcn = 0;
for ( final IFunction function : functions )
{
totalCcn += function.getCyclomaticComplexity();
}
return totalCcn
/ functions.size();
}
public final IParserNode getBlock()
{
return block;
}
/*
* (non-Javadoc)
* @see com.adobe.ac.pmd.nodes.IClass#getConstants()
*/
public List< IConstant > getConstants()
{
return constants;
}
/*
* (non-Javadoc)
* @see com.adobe.ac.pmd.nodes.IClass#getConstructor()
*/
public IFunction getConstructor()
{
return constructor;
}
/*
* (non-Javadoc)
* @see com.adobe.ac.pmd.nodes.IClass#getExtensionName()
*/
public String getExtensionName()
{
return extensionName;
}
/*
* (non-Javadoc)
* @see com.adobe.ac.pmd.nodes.IClass#getFunctions()
*/
public List< IFunction > getFunctions()
{
return functions;
}
/*
* (non-Javadoc)
* @see com.adobe.ac.pmd.nodes.IClass#getImplementations()
*/
public List< IParserNode > getImplementations()
{
return implementations;
}
public List< IMetaData > getMetaData( final MetaData metaDataName )
{
if ( metaDataList.containsKey( metaDataName ) )
{
return metaDataList.get( metaDataName );
}
else
{
return new ArrayList< IMetaData >();
}
}
public int getMetaDataCount()
{
return metaDataList.size();
}
/*
* (non-Javadoc)
* @see com.adobe.ac.pmd.nodes.INamable#getName()
*/
public String getName()
{
return name.toString();
}
public boolean is( final Modifier modifier ) // NOPMD
{
return modifiers.contains( modifier );
}
public boolean isBindable()
{
return metaDataList.get( MetaData.BINDABLE ) != null;
}
/*
* (non-Javadoc)
* @see com.adobe.ac.pmd.nodes.IClass#isFinal()
*/
public boolean isFinal()
{
return is( Modifier.FINAL );
}
public boolean isPublic()
{
return is( Modifier.PUBLIC );
}
private void computeClassContent( final IParserNode classContentNode )
{
if ( classContentNode.numChildren() != 0 )
{
for ( final IParserNode node : classContentNode.getChildren() )
{
detectBlock( node );
detectFunction( node );
detectAttribute( node );
detectConstant( node );
}
}
}
private void detectAttribute( final IParserNode node )
{
if ( node.is( NodeKind.VAR_LIST ) )
{
attributes.add( new AttributeNode( node ).compute() );
}
}
private void detectBlock( final IParserNode node )
{
if ( node.is( NodeKind.BLOCK ) )
{
block = node;
}
}
private void detectConstant( final IParserNode node )
{
if ( node.is( NodeKind.CONST_LIST ) )
{
constants.add( new ConstantNode( node ).compute() );
}
}
private void detectExtensions( final IParserNode node )
{
if ( node.is( NodeKind.EXTENDS ) )
{
extensionName = node.getStringValue();
}
}
private void detectFunction( final IParserNode node )
{
if ( node.is( NodeKind.FUNCTION )
|| node.is( NodeKind.GET ) || node.is( NodeKind.SET ) )
{
functions.add( new FunctionNode( node ).compute() );
}
}
private void detectImplementations( final IParserNode node )
{
if ( node.is( NodeKind.IMPLEMENTS_LIST ) )
{
implementations = node.getChildren();
}
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
cef560304e67a88260ee5c4503019e8167f668cb | d14d8ce63277154728e3ee25d8f4c14b3c292a36 | /core/src/main/java/com/cantu/watchlist/core/application/addProvider/AddProviderCommandHandler.java | 128157adae24be688077a005135f658f16b53d16 | [] | no_license | eduardocantu/watchlist | 411b6697260f450908998c910ae4ef7fb2c5ca07 | 6eea554ce5110a4d2d1d76ba3fe71aff5542466a | refs/heads/main | 2023-08-03T00:27:35.494140 | 2021-10-07T13:33:46 | 2021-10-07T13:33:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 999 | java | package com.cantu.watchlist.core.application.addProvider;
import com.cantu.ddd.framework.command.CommandHandler;
import com.cantu.ddd.framework.command.CommandResponse;
import com.cantu.watchlist.core.domain.ProviderBuilder;
import com.cantu.watchlist.core.domain.ProviderRepository;
public class AddProviderCommandHandler implements CommandHandler<AddProviderCommand> {
private final ProviderRepository providerRepository;
public AddProviderCommandHandler(final ProviderRepository providerRepository) {
this.providerRepository = providerRepository;
}
@Override
public CommandResponse handle(AddProviderCommand command) {
return CommandResponse.withResponse(
providerRepository.save(
ProviderBuilder
.aProviderBuilder()
.withName(command.getName())
.build()
)
);
}
}
| [
"mellocae@emea.roche.com"
] | mellocae@emea.roche.com |
623c66d3f164caac58d6c4d1b613d2a10c6d14e8 | 2e7341bfc19f46cf285c4d2caf304dda5924576e | /WXLikeVideoRecorderLib/src/main/java/sz/itguy/utils/SystemVersionUtil.java | 152f5b897a2e795f5b23f4c332308d2ba4da6988 | [] | no_license | blueflychief/BlueFlyRecordVideo | d85b04c50ba987d347069661ffa69dd5a6d566b9 | e2a1978643474c5228f18fa4934221d44190b918 | refs/heads/master | 2020-04-19T14:45:55.963209 | 2016-08-21T14:03:02 | 2016-08-21T14:03:02 | 66,201,711 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,445 | java | package sz.itguy.utils;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
/**
* 系统版本工具类
* @author Martin
*
*/
public class SystemVersionUtil {
/**
* 判断版本>=2.2
* @return
*/
public static boolean hasFroyo() {
return VERSION.SDK_INT >= VERSION_CODES.FROYO;
}
/**
* 判断版本>=3.0
* @return
*/
public static boolean hasHoneycomb() {
return VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
}
/**
* 判断版本>=4.0
* @return
*/
public static boolean hasICS() {
return VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH;
}
/**
* 判断版本>=4.1
* @return
*/
public static boolean hasJellyBean() {
return VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
}
/**
* 判断版本>=4.2
* @return
*/
public static boolean hasJellyBeanMR1() {
return VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1;
}
/**
* 判断版本>=4.3
* @return
*/
public static boolean hasJellyBeanMR2() {
return VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2;
}
/**
* 判断版本>=4.4
* @return
*/
public static boolean hasKitKat() {
return VERSION.SDK_INT >= VERSION_CODES.KITKAT;
}
/**
* 判断版本>=5.0
* @return
*/
public static boolean hasLollipop() {
return VERSION.SDK_INT >= 21;
}
}
| [
"luoshuiquan@kuaikuaikeji.com"
] | luoshuiquan@kuaikuaikeji.com |
2f9312a6311a4110531de3803451839f7ef52d27 | fca2e675f48aaff31048710cc00ce7046aa711d9 | /src/main/java/com/xero/models/payrollnz/Account.java | 6f630eedd17f456b32de3e1299b75b9c8699f280 | [
"MIT"
] | permissive | XeroAPI/Xero-Java | c13b69366cd624bbba2993e9db9e38bdecb7c7eb | 9912bd6fe795b706aadb152e53c9c28b1e03d9ba | refs/heads/master | 2023-08-08T20:14:56.452424 | 2023-06-15T18:38:41 | 2023-06-15T18:38:41 | 61,156,602 | 82 | 114 | MIT | 2023-08-29T20:36:57 | 2016-06-14T21:22:47 | Java | UTF-8 | Java | false | false | 5,542 | java | /*
* Xero Payroll NZ
* This is the Xero Payroll API for orgs in the NZ region.
*
* Contact: api@xero.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.xero.models.payrollnz;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import com.xero.api.StringUtil;
import io.swagger.annotations.ApiModelProperty;
import java.util.Objects;
import java.util.UUID;
/** Account */
public class Account {
StringUtil util = new StringUtil();
@JsonProperty("accountID")
private UUID accountID;
/** The assigned AccountType */
public enum TypeEnum {
/** PAYELIABILITY */
PAYELIABILITY("PAYELIABILITY"),
/** WAGESPAYABLE */
WAGESPAYABLE("WAGESPAYABLE"),
/** WAGESEXPENSE */
WAGESEXPENSE("WAGESEXPENSE"),
/** BANK */
BANK("BANK");
private String value;
TypeEnum(String value) {
this.value = value;
}
/**
* getValue
*
* @return String value
*/
@JsonValue
public String getValue() {
return value;
}
/**
* toString
*
* @return String value
*/
@Override
public String toString() {
return String.valueOf(value);
}
/**
* fromValue
*
* @param value String
*/
@JsonCreator
public static TypeEnum fromValue(String value) {
for (TypeEnum b : TypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
@JsonProperty("type")
private TypeEnum type;
@JsonProperty("code")
private String code;
@JsonProperty("name")
private String name;
/**
* The Xero identifier for Settings.
*
* @param accountID UUID
* @return Account
*/
public Account accountID(UUID accountID) {
this.accountID = accountID;
return this;
}
/**
* The Xero identifier for Settings.
*
* @return accountID
*/
@ApiModelProperty(value = "The Xero identifier for Settings.")
/**
* The Xero identifier for Settings.
*
* @return accountID UUID
*/
public UUID getAccountID() {
return accountID;
}
/**
* The Xero identifier for Settings.
*
* @param accountID UUID
*/
public void setAccountID(UUID accountID) {
this.accountID = accountID;
}
/**
* The assigned AccountType
*
* @param type TypeEnum
* @return Account
*/
public Account type(TypeEnum type) {
this.type = type;
return this;
}
/**
* The assigned AccountType
*
* @return type
*/
@ApiModelProperty(value = "The assigned AccountType")
/**
* The assigned AccountType
*
* @return type TypeEnum
*/
public TypeEnum getType() {
return type;
}
/**
* The assigned AccountType
*
* @param type TypeEnum
*/
public void setType(TypeEnum type) {
this.type = type;
}
/**
* A unique 3 digit number for each Account
*
* @param code String
* @return Account
*/
public Account code(String code) {
this.code = code;
return this;
}
/**
* A unique 3 digit number for each Account
*
* @return code
*/
@ApiModelProperty(value = "A unique 3 digit number for each Account")
/**
* A unique 3 digit number for each Account
*
* @return code String
*/
public String getCode() {
return code;
}
/**
* A unique 3 digit number for each Account
*
* @param code String
*/
public void setCode(String code) {
this.code = code;
}
/**
* Name of the Account.
*
* @param name String
* @return Account
*/
public Account name(String name) {
this.name = name;
return this;
}
/**
* Name of the Account.
*
* @return name
*/
@ApiModelProperty(value = "Name of the Account.")
/**
* Name of the Account.
*
* @return name String
*/
public String getName() {
return name;
}
/**
* Name of the Account.
*
* @param name String
*/
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Account account = (Account) o;
return Objects.equals(this.accountID, account.accountID)
&& Objects.equals(this.type, account.type)
&& Objects.equals(this.code, account.code)
&& Objects.equals(this.name, account.name);
}
@Override
public int hashCode() {
return Objects.hash(accountID, type, code, name);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Account {\n");
sb.append(" accountID: ").append(toIndentedString(accountID)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" code: ").append(toIndentedString(code)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
| [
"sid.maestre@gmail.com"
] | sid.maestre@gmail.com |
00409d2c95b34ddc8e26bcb13fff06a3884b8152 | 767b1a9f1049ea36159b27d152f4d77d72e0ebc4 | /src/main/java/com/thegingerbeardd/dndbot/character/sheet/CharacterSaveProficiencies.java | cb96634216bd59ffe0f85168f202690a2e870856 | [] | no_license | cmazur14/DnD_Discord_Bot | b2ae193d77353ed5d244b65a8fec734478e99188 | 5504226bfb344b0e3428144fb6da7c910f298afc | refs/heads/master | 2020-06-30T14:18:48.527999 | 2019-08-13T12:13:50 | 2019-08-13T12:13:50 | 200,854,163 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,277 | java | package com.thegingerbeardd.dndbot.character.sheet;
import com.thegingerbeardd.dndbot.character.utils.fifthedition.AbilityTypes;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
public class CharacterSaveProficiencies implements Serializable {
private Map<AbilityTypes, Boolean> proficiencies;
public CharacterSaveProficiencies() {
proficiencies = new HashMap<>();
for (AbilityTypes type : AbilityTypes.values()) {
proficiencies.put(type, false);
}
}
public CharacterSaveProficiencies(CharacterClass charClass) {
proficiencies = new HashMap<>();
for (AbilityTypes s : charClass.getSaveProficiencyList())
proficiencies.put(s, true);
}
public void updateProficienciesBasedOnNewClass(CharacterClass charClass) {
for (AbilityTypes s : charClass.getSaveProficiencyList())
proficiencies.put(s, true);
}
public void makeProficientIn(AbilityTypes saveType) {
proficiencies.put(saveType, true);
}
public void makeNotProficientIn(AbilityTypes saveType) {
proficiencies.put(saveType, false);
}
public boolean isProficientIn(AbilityTypes saveType) {
return proficiencies.get(saveType);
}
}
| [
"christopher.mazur@fedex.com"
] | christopher.mazur@fedex.com |
27dd33538dbaba1935824559cdd6e0602a266be9 | 2ccb42d80a22c69f2bb362a86454e46b5805a909 | /src/main/java/com/oseasy/pact/modules/actyw/tool/process/vo/StenTypeBak.java | a192b01c70e2c68dde11abc4f6b7758bc4ff2141 | [] | no_license | SchuckBeta/aip | 42bbd5d24e68419e6e8a7329e762fd4ff7fda7b3 | b073aac090f29fc599ccc68816356e824b4fc948 | refs/heads/master | 2020-04-08T22:06:28.154187 | 2019-01-13T14:54:24 | 2019-01-13T14:54:24 | 159,771,927 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,779 | java | /**
* 源代码版权归[[os-easy]]公司所有.
* @Project: ROOT
* @Package com.oseasy.initiate.modules.actyw.tool.process.vo
* @Description [[_StenType_]]文件
* @date 2017年6月2日 下午6:08:00
*
*/
package com.oseasy.pact.modules.actyw.tool.process.vo;
import java.util.List;
import com.google.common.collect.Lists;
import com.oseasy.pact.modules.actyw.tool.process.ActYwSten;
import com.oseasy.putil.common.utils.StringUtil;
/**
* stencil类型枚举.
*
* @author chenhao
* @date 2017年6月2日 下午6:08:00
*
*/
public enum StenTypeBak {
ST_BPMDI("990111", StenEtype.SE_NODE, StenEsubType.SES_CORE, 1, "BPMNDiagram", "BPMN流程图"),
ST_START_EVENT_NONE("990211", StenEtype.SE_NODE, StenEsubType.SES_EVENT_START, 2, "StartNoneEvent", "开始无事件节点"),
ST_START_EVENT_TIMER("990221", StenEtype.SE_NODE, StenEsubType.SES_EVENT_START, 2, "StartTimerEvent", "定时开始事件"),
ST_START_EVENT_SIGNAL("990231", StenEtype.SE_NODE, StenEsubType.SES_EVENT_START, 2, "StartSignalEvent", "信号开始事件"),
ST_START_EVENT_MESSAGE("990241", StenEtype.SE_NODE, StenEsubType.SES_EVENT_START, 2, "StartMessageEvent", "消息开始事件"),
ST_START_EVENT_ERROR("990251", StenEtype.SE_NODE, StenEsubType.SES_EVENT_START, 2, "StartErrorEvent", "错误开始事件"),
ST_TASK_USER("990311", StenEtype.SE_NODE, StenEsubType.SES_TASK, 2, "UserTask", "用户任务节点"),
ST_TASK_SERVICE("990321", StenEtype.SE_NODE, StenEsubType.SES_TASK, 2, "ServiceTask", "服务任务节点"),
ST_TASK_SCRIPT("990331", StenEtype.SE_NODE, StenEsubType.SES_TASK, 2, "ScriptTask", "脚本任务节点"),
ST_TASK_BUSINESS_RULE("990341", StenEtype.SE_NODE, StenEsubType.SES_TASK, 2, "BusinessRule", "业务规则任务节点"),
ST_TASK_RECEIVE("990351", StenEtype.SE_NODE, StenEsubType.SES_TASK, 2, "ReceiveTask", "接收任务节点"),
ST_TASK_MANUAL("990361", StenEtype.SE_NODE, StenEsubType.SES_TASK, 2, "ManualTask", "人工任务节点"),
ST_TASK_MAIL("990371", StenEtype.SE_NODE, StenEsubType.SES_TASK, 2, "MailTask", "邮件任务节点"),
ST_TASK_CAMEL("990381", StenEtype.SE_NODE, StenEsubType.SES_TASK, 2, "CamelTask", "骆驼任务节点"),
ST_TASK_MULE("990391", StenEtype.SE_NODE, StenEsubType.SES_TASK, 2, "MuleTask", "Mule任务节点"),
ST_TASK_SEND("990392", StenEtype.SE_NODE, StenEsubType.SES_TASK, 2, "SendTask", "发送任务节点"),
ST_JG_SUB_PROCESS("990411", StenEtype.SE_NODE, StenEsubType.SES_JG, 2, "SubProcess", "子流程结构"),
ST_JG_SUB_PROCESS_EVENT("990421", StenEtype.SE_NODE, StenEsubType.SES_JG, 2, "EventSubProcess", "事件子流程结构"),
ST_JG_CALL_ACTIVITY("990431", StenEtype.SE_NODE, StenEsubType.SES_JG, 2, "CallActivity", "调用活动结构"),
ST_GATEWAY_EXCLUSIVE("990511", StenEtype.SE_NODE, StenEsubType.SES_GATEWAY, 2, "ExclusiveGateway", "互斥网关"),
ST_GATEWAY_PARALLEL("990521", StenEtype.SE_NODE, StenEsubType.SES_GATEWAY, 2, "ParallelGateway", "并行网关"),
ST_GATEWAY_INCLUSIVE("990531", StenEtype.SE_NODE, StenEsubType.SES_GATEWAY, 2, "InclusiveGateway", "包容性网关"),
ST_GATEWAY_EVENT("990541", StenEtype.SE_NODE, StenEsubType.SES_GATEWAY, 2, "EventGateway", "事件网关"),
ST_BOUNDARY_EVENT_ERROR("990611", StenEtype.SE_NODE, StenEsubType.SES_BOUNDARY_EVENT, 2, "BoundaryErrorEvent", "边界错误事件"),
ST_BOUNDARY_EVENT_TIMER("990621", StenEtype.SE_NODE, StenEsubType.SES_BOUNDARY_EVENT, 2, "BoundaryTimerEvent", "边界定时事件"),
ST_BOUNDARY_EVENT_SIGNAL("990631", StenEtype.SE_NODE, StenEsubType.SES_BOUNDARY_EVENT, 2, "BoundarySignalEvent", "边界信号事件"),
ST_BOUNDARY_EVENT_MESSAGE("990641", StenEtype.SE_NODE, StenEsubType.SES_BOUNDARY_EVENT, 2, "BoundaryMessageEvent", "边界消息事件"),
ST_BOUNDARY_EVENT_CANCEL("990651", StenEtype.SE_NODE, StenEsubType.SES_BOUNDARY_EVENT, 2, "BoundaryCancelEvent", "边界消息事件"),
ST_BOUNDARY_EVENT_COMPENSATION("990661", StenEtype.SE_NODE, StenEsubType.SES_BOUNDARY_EVENT, 2, "BoundaryCompensationEvent", "边界补偿事件"),
ST_CATCH_EVENT_TIMER("990711", StenEtype.SE_NODE, StenEsubType.SES_CATCH_EVENT, 2, "CatchTimerEvent", "中间定时器捕获事件"),
ST_CATCH_EVENT_SIGNAL("990721", StenEtype.SE_NODE, StenEsubType.SES_CATCH_EVENT, 2, "CatchSignalEvent", "中间信号捕获事件"),
ST_CATCH_EVENT_MESSAGE("990731", StenEtype.SE_NODE, StenEsubType.SES_CATCH_EVENT, 2, "CatchMessageEvent", "中间消息事件"),
ST_CTROW_EVENT_THROW_NONE("990841", StenEtype.SE_NODE, StenEsubType.SES_CTROW_EVENT, 2, "ThrowNoneEvent", "中间无抛出事件"),
ST_CTROW_EVENT_THROW_SIGNAL("990851", StenEtype.SE_NODE, StenEsubType.SES_CTROW_EVENT, 2, "ThrowSignalEvent", "中间信号抛出事件"),
ST_END_EVENT_NONE("990911", StenEtype.SE_NODE, StenEsubType.SES_EVENT_END, 2, "EndNoneEvent", "结束无事件"),
ST_END_EVENT_ERROR("990921", StenEtype.SE_NODE, StenEsubType.SES_EVENT_END, 2, "EndErrorEvent", "结束错误事件"),
ST_END_EVENT_CANCEL("990931", StenEtype.SE_NODE, StenEsubType.SES_EVENT_END, 2, "EndCancelEvent", "结束取消事件"),
ST_END_EVENT_TERMINATE("990941", StenEtype.SE_NODE, StenEsubType.SES_EVENT_END, 2, "EndTerminateEvent", "结束终止事件"),
ST_YD_POOL("991011", StenEtype.SE_NODE, StenEsubType.SES_YD, 2, "Pool", "池"),
ST_YD_LANE("991021", StenEtype.SE_NODE, StenEsubType.SES_YD, 2, "Lane", "道"),
ST_ZJ_TEXT_ANNOTATION("991111", StenEtype.SE_NODE, StenEsubType.SES_ZJ, 2, "TextAnnotation", "文本注释"),
ST_ZJ_DATA_STORE("991121", StenEtype.SE_NODE, StenEsubType.SES_ZJ, 2, "DataStore", "数据存储"),
ST_FLOW_SEQUENCE("991211", StenEtype.SE_EDGE, StenEsubType.SES_FLOW, 2, "SequenceFlow", "流程序列"),
ST_FLOW_MESSAGE("991221", StenEtype.SE_EDGE, StenEsubType.SES_FLOW, 2, "MessageFlow", "消息流程序列"),
ST_FLOW_ASSOCIATION("991231", StenEtype.SE_EDGE, StenEsubType.SES_FLOW, 2, "Association", "联系序列"),
ST_FLOW_ASSOCIATION_DATA("991241", StenEtype.SE_EDGE, StenEsubType.SES_FLOW, 2, "DataAssociation", "数据联系序列");
private String id;
private StenEtype type;
private StenEsubType subtype;
private Integer level;
private String key;
private String remark;
private StenTypeBak(String id, StenEtype type, StenEsubType subtype, Integer level, String key,
String remark) {
this.id = id;
this.type = type;
this.subtype = subtype;
this.level = level;
this.key = key;
this.remark = remark;
}
/**
* 根据ID获取枚举 .
*
* @author chenhao
* @param id
* 枚举标识
* @return StenType
*/
public static StenTypeBak getById(String id) {
StenTypeBak[] entitys = StenTypeBak.values();
for (StenTypeBak entity : entitys) {
if ((id != null) && (id).equals(entity.getId())) {
return entity;
}
}
return null;
}
/**
* 根据类型获取枚举 .
*
* @author chenhao
* @param type
* 类型
* @param subtype
* 子类型
* @return StenType
*/
public static StenTypeBak getByType(StenEtype type, StenEsubType subtype) {
StenTypeBak[] entitys = StenTypeBak.values();
for (StenTypeBak entity : entitys) {
if (type.equals(entity.getType()) && subtype.equals(entity.getSubtype())) {
return entity;
}
}
return null;
}
/**
* 根据类型获取枚举 .
*
* @author chenhao
* @param subtype
* 子类型
* @return List
*/
public static List<StenTypeBak> getBySubType(StenEsubType subtype) {
List<StenTypeBak> stenTypes = Lists.newArrayList();
StenTypeBak[] entitys = StenTypeBak.values();
for (StenTypeBak entity : entitys) {
if (subtype.equals(entity.getSubtype())) {
stenTypes.add(entity);
}
}
return stenTypes;
}
public static List<StenTypeBak> getBySubType(String subtype) {
return getBySubType(StenEsubType.getByType(subtype));
}
/**
* 根据等级获取枚举 .
*
* @author chenhao
* @param level
* 等级
* @return StenType
*/
public static StenTypeBak getByLevel(Integer level) {
StenTypeBak[] entitys = StenTypeBak.values();
for (StenTypeBak entity : entitys) {
if ((level).equals(entity.getLevel())) {
return entity;
}
}
return null;
}
/**
* 根据关键字获取枚举 .
*
* @author chenhao
* @param key
* 关键字
* @return StenType
*/
public static StenTypeBak getByKey(String key) {
StenTypeBak[] entitys = StenTypeBak.values();
for (StenTypeBak entity : entitys) {
if ((StringUtil.isNotEmpty(key)) && (key).equals(entity.getKey())) {
return entity;
}
}
return null;
}
public String getId() {
return id;
}
public StenEtype getType() {
return type;
}
public Integer getLevel() {
return level;
}
public String getKey() {
return key;
}
public String getRemark() {
return remark;
}
public StenEsubType getSubtype() {
return subtype;
}
/**
* 根据Key生成节点代码 .
* @author chenhao
* @param key 唯一标识
* @return String
*/
public static String genNodeByType(String key) {
return genNodeByStenType(StenTypeBak.getByKey(key));
}
/**
* 根据StenType生成节点代码 .
* @author chenhao
* @param entity StenType
* @return String
*/
public static String genNodeByStenType(StenTypeBak entity) {
StringBuffer buffer = new StringBuffer();
ActYwSten actYwResult = ActYwSten.genActYwSten();
for (SnStencils snStencils : actYwResult.getStencils()) {
if ((snStencils.getId()).equals(entity.getKey())) {
buffer.append(snStencils.getLayout());
}
}
return buffer.toString();
}
}
| [
"chenhao@os-easy.com"
] | chenhao@os-easy.com |
376730c7fa7812a85a2638bab0de539b687e26aa | 05ed11176b5dd761966b5a62309c4d39faf40b14 | /target/tomcat/work/Tomcat/localhost/_/org/apache/jsp/index_jsp.java | 11fa1c5e3147a1d023ea7cb816e7372239ebf17c | [] | no_license | AnqiZhao110/bbb | 7615ba38ada2c78ef0ee7567b2175877f83f8be4 | eead5d60a0c187459a31889089427cd560e31837 | refs/heads/master | 2020-06-21T04:37:26.695478 | 2019-07-17T09:21:36 | 2019-07-17T09:21:36 | 197,345,683 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,297 | java | /*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/7.0.47
* Generated at: 2019-07-11 00:46:46 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory();
private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
private javax.el.ExpressionFactory _el_expressionfactory;
private org.apache.tomcat.InstanceManager _jsp_instancemanager;
public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
}
public void _jspInit() {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
public void _jspDestroy() {
}
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("<!DOCTYPE html>\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<meta charset=\"UTF-8\">\r\n");
out.write("<title>Insert title here</title>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write("\t\t<a href=\"user\">click</a>\r\n");
out.write("</body>\r\n");
out.write("</html>");
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try { out.clearBuffer(); } catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
| [
"zhaoanqi_lee@163.com"
] | zhaoanqi_lee@163.com |
bb1a3d4ea0ea7503a75c5fbb94d57dc23c2dbf85 | 84eec548e27cb28f68b9a1898c0b9468c7cf6385 | /platforms/android/app/src/main/java/com/fcmpushnotification/georgeikwegbu/MainActivity.java | cc4094906ffd558826342a791df27695d3b19f5a | [] | no_license | gikwegbu/Cordova-Push-Notification-with-FCM | 66c4e692b3ee2400848e6fe1a66dad35b4768a81 | 145005e2fe1e7d8f71a3d7f1abbc7d0c23c50a09 | refs/heads/master | 2023-06-03T03:00:55.429095 | 2021-06-20T22:25:08 | 2021-06-20T22:25:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,470 | java | /*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package com.fcmpushnotification.georgeikwegbu;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// enable Cordova apps to be started in the background
Bundle extras = getIntent().getExtras();
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
moveTaskToBack(true);
}
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
| [
"g.ikwegbu@gmail.com"
] | g.ikwegbu@gmail.com |
92c54cf1a2fa6f4e3025f1f2ff274225124ec45a | b4be0cdc5b66ae22d24fa1fbebf7a9d8d259561f | /src/test/java/com/yet88/springboot/springrestservice/auth/basic/RestBasicAuthTemplateFactory.java | bea63c5c1f15da7157f20755d320ed02d75b5143 | [] | no_license | yilbertoledo/spring-rest-service | 1144bd82b58c4e354f3a61269b0a31a098b993e9 | 6f6b72d0c71fbff422f673312973cb78bc6de074 | refs/heads/master | 2020-04-18T00:13:43.680637 | 2019-02-05T20:17:19 | 2019-02-05T20:17:19 | 167,068,407 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,326 | java | package com.yet88.springboot.springrestservice.auth.basic;
import org.apache.http.HttpHost;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* Class for setting up the RestTemplate with Basic Authentication
*
* @author yilber.toledo
*
*/
@Configuration
@ConditionalOnProperty(value = "authentication.type", havingValue = "basic", matchIfMissing = true)
public class RestBasicAuthTemplateFactory implements FactoryBean<RestTemplate>, InitializingBean
{
@Value("${server.port}")
public int port;
private RestTemplate restTemplate;
public RestTemplate getObject()
{
return restTemplate;
}
public Class<RestTemplate> getObjectType()
{
return RestTemplate.class;
}
public boolean isSingleton()
{
return true;
}
public void afterPropertiesSet()
{
HttpHost host = new HttpHost("localhost", port, "http");
restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactoryBasicAuth(host));
}
}
| [
"26316784+yilbertoledo@users.noreply.github.com"
] | 26316784+yilbertoledo@users.noreply.github.com |
e63f02b6a84e1520761342a9b21cac2a392c7d35 | 74c28740110a7896741337d3565e38150251d13e | /src/controller/DevelopmentController.java | 84bf9697385d381782fa4680cc1b009ac41dba4e | [] | no_license | JeppeV/ARPG_MarkII | 3feae2fb9522a37169fc632bc16154188ce238e9 | 04c9f35ec0add5b3e375ddc4fbe8792a132742ea | refs/heads/master | 2020-12-11T08:01:03.299475 | 2016-02-18T14:40:54 | 2016-02-18T14:40:54 | 49,745,634 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,567 | java | package controller;
import model.Game;
import model.entities.Player;
import org.newdawn.slick.Input;
/**
* Created by Jeppe Vinberg on 02-02-2016.
*/
public class DevelopmentController extends AbstractController {
private Game game;
private Player player;
public DevelopmentController(Game game) {
this.game = game;
this.player = game.getPlayer();
}
@Override
public void keyPressed(int i, char c) {
}
@Override
public void keyReleased(int i, char c) {
switch (i) {
case Input.KEY_C:
player.toggleCollisionCheck();
System.out.println("Collision checking toggled");
break;
default:
break;
}
}
@Override
public void mouseWheelMoved(int i) {
}
@Override
public void mouseClicked(int i, int i1, int i2, int i3) {
}
@Override
public void mousePressed(int i, int i1, int i2) {
}
@Override
public void mouseReleased(int i, int i1, int i2) {
}
@Override
public void mouseMoved(int i, int i1, int i2, int i3) {
}
@Override
public void mouseDragged(int i, int i1, int i2, int i3) {
}
@Override
public void setInput(Input input) {
}
@Override
public boolean isAcceptingInput() {
return true;
}
@Override
public void inputEnded() {
}
@Override
public void inputStarted() {
}
}
| [
"Jeppevinberg@gmail.com"
] | Jeppevinberg@gmail.com |
3cd3d1a8260cf346d919d390be5e85b960d875b0 | 998fd0fb6f4238c95d59d7462c5aed44a418e4b3 | /core/src/com/pixeldweller/game/demo/OverlayDemo.java | 2b2bdf2f378fe7c00ebef0d03bac4470a633de90 | [] | no_license | duchien85/GetTogetherPseudoPartyGame | 951a4484905251df19748f33ef8d36d2163569a0 | d3a159f4fed21e551c76ec6a6415dee00b3eaa37 | refs/heads/master | 2020-11-24T01:07:26.708346 | 2019-11-14T13:53:23 | 2019-11-14T13:53:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,346 | java | package com.pixeldweller.game.demo;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.pixeldweller.game.clientcontroller.ArrowController;
public class OverlayDemo extends ApplicationAdapter {
public static final float PPM = 100;
public static SpriteBatch batch;
World world;
OrthographicCamera cam;
Viewport viewport;
Box2DDebugRenderer b2dr;
Body player;
ArrowController controller;
@Override
public void create () {
cam = new OrthographicCamera();
viewport = new FitViewport(800 / PPM, 480 / PPM, cam);
batch = new SpriteBatch();
world = new World(new Vector2(0, -10), true);
b2dr = new Box2DDebugRenderer();
createGround();
createPlayer();
controller = new ArrowController();
}
@Override
public void resize(int width, int height) {
super.resize(width, height);
viewport.update(width, height);
controller.resize(width, height);
}
public void handleInput(){
if(controller.isRightPressed())
player.setLinearVelocity(new Vector2(1, player.getLinearVelocity().y));
else if (controller.isLeftPressed())
player.setLinearVelocity(new Vector2(-1, player.getLinearVelocity().y));
else
player.setLinearVelocity(new Vector2(0, player.getLinearVelocity().y));
if (controller.isUpPressed() && player.getLinearVelocity().y == 0)
player.applyLinearImpulse(new Vector2(0, 5f), player.getWorldCenter(), true);
}
public void update(float dt){
handleInput();
world.step(1/60f, 6, 2);
cam.position.set(viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2, 0);
cam.update();
}
@Override
public void render () {
update(Gdx.graphics.getDeltaTime());
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
b2dr.render(world, cam.combined);
if(Gdx.app.getType() == Application.ApplicationType.Android)
controller.draw();
}
public void createGround(){
BodyDef bdef = new BodyDef();
bdef.position.set(viewport.getWorldWidth() / 2, 0);
bdef.type = BodyDef.BodyType.StaticBody;
Body b2body = world.createBody(bdef);
FixtureDef fdef = new FixtureDef();
PolygonShape shape = new PolygonShape();
shape.setAsBox(viewport.getWorldWidth() / 2, 20 / PPM);
fdef.shape = shape;
b2body.createFixture(fdef);
}
public void createPlayer(){
BodyDef bdef = new BodyDef();
bdef.position.set(viewport.getWorldWidth() / 2, 80 / PPM);
bdef.type = BodyDef.BodyType.DynamicBody;
player = world.createBody(bdef);
FixtureDef fdef = new FixtureDef();
PolygonShape shape = new PolygonShape();
shape.setAsBox(40 / PPM, 40 / PPM);
fdef.shape = shape;
player.createFixture(fdef);
}
} | [
"fabfab.needs@gmail.com"
] | fabfab.needs@gmail.com |
28f9112267eb0705ba0d56b4d222ec3dbbc1f20a | 8cae58709344857d3f542d1e95d868873cb7526f | /src/com/class07/Task6.java | a5e6308873b7b8755127d30b4025d2377cf9e87a | [] | no_license | MChTester1/JavaProjectBatch9 | 66ae677db31b78d3ac969536c372012742eb6081 | 2eb5b93765a63717bb2e1db1682e0d8a9754df83 | refs/heads/main | 2023-03-22T09:07:40.878688 | 2021-03-15T21:48:06 | 2021-03-15T21:48:06 | 348,132,738 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 897 | java | package com.class07;
public class Task6 {
public static void main(String[] args) {
/*
* Print odd numbers from 20 to 50 (2 ways)
*/
for(int i=20; i<=50; i++) {
if(i%2==1) {
System.out.print(i+ " ");
}
}
System.out.println("--------------------");
for(int i=21; i<=50; i+=2) {
System.out.print(i+ " ");
}
System.out.println();
System.out.println("-------------------What is the output-------------");
int sum=0;
for(int i=1; i<=5; i++) {
sum=sum+i;
}
System.out.println(sum);//its outside the loop; sum will be printed only once
System.out.println();
System.out.println("-------------------What is the output-------------");
int result=0;
for(int i=2; i<10; i+=2) {
result +=i;
//System.out.println(result);//output 2,6,12,20
}
System.out.println(result);//output 20 it is only one output
}
}
| [
"magdalena.christopher.com"
] | magdalena.christopher.com |
c9926af89800f4d03c683960814b4c2301b94ddf | c52e8e7f736643531b4ba453f7c19372e633d91b | /app/src/main/java/com/yangyi/app/gcountdown/MainActivity.java | b5ea99bc3c79f374b5e53eaa7b6cc835f0c0723d | [] | no_license | gyh/Countdown | 5523b78d279c37946f9d570cf31e1b5f026c0288 | 3813741d1bc92c610b2554077f9b2621f48b77af | refs/heads/master | 2016-08-11T01:47:39.233110 | 2015-12-21T05:13:33 | 2015-12-21T05:13:33 | 47,451,967 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,170 | java | package com.yangyi.app.gcountdown;
import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener{
private String[] strTypes = new String[]{"使用Java的Timer与TimerTask",
"TimerTask与Handler",
"Handler自循环",
"Handler与Thread(不占用UI线程)",
"Handler与Runnable(最简单型)"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
initListView();
}
private void initListView(){
ListView listView = (ListView)findViewById(R.id.listview);
listView.setAdapter(new MyAdapter(this,this.strTypes));
listView.setOnItemClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position){
case 0:
NavigationIn.navigatiionTimeAndTast(MainActivity.this,strTypes[position]);
break;
case 1:
NavigationIn.navigationTimeAndHandler(MainActivity.this,strTypes[position]);
break;
case 2:
NavigationIn.navigationHandlerAc(MainActivity.this,strTypes[position]);
break;
case 3:
NavigationIn.navigationHandlerThre(MainActivity.this, strTypes[position]);
break;
case 4:
NavigationIn.navigationHandlerRun(MainActivity.this,strTypes[position]);
break;
}
}
class MyAdapter extends BaseAdapter{
String[] strings;
LayoutInflater listContainer;
MyAdapter(Context context,String[] strings){
this.strings = strings;
listContainer = LayoutInflater.from(context);
}
@Override
public int getCount() {
return strings.length;
}
@Override
public Object getItem(int position) {
return strings[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView = null;
if(convertView==null){
convertView = listContainer.inflate(R.layout.item_listview,null);
textView = (TextView)convertView.findViewById(R.id.itemTv);
convertView.setTag(textView);
}else {
textView = (TextView)convertView.getTag();
}
textView.setText(strings[position]);
return convertView;
}
}
}
| [
"guoyuehua@ninetowns.com"
] | guoyuehua@ninetowns.com |
9226f05b30e16dac60d0bd843255c8ef043c65b3 | 0c5e2f73fbe10196eb0e46293b3d18924cf99740 | /framecorelibrary/src/main/java/com/junlong/framecorelibrary/conn/okserver/ProgressListener.java | 3be5df237bde5d260af4c7e3835fd64a19a85998 | [] | no_license | gxj0116/QuickDevelopFrame | 3ed6d701479ed7d785c8e5d8f588d2891530baa1 | 345f32d78d1303ec8c404863c3e1aa381e00bc9c | refs/heads/master | 2020-12-13T18:59:12.718237 | 2017-09-30T02:44:40 | 2017-09-30T02:44:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,409 | java | /*
* Copyright 2016 jeasonlzy(廖子尧)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.junlong.framecorelibrary.conn.okserver;
import com.junlong.framecorelibrary.conn.okgo.model.Progress;
/**
* ================================================
* 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
* 版 本:1.0
* 创建日期:2017/6/4
* 描 述:
* 修订历史:
* ================================================
*/
public interface ProgressListener<T> {
/** 成功添加任务的回调 */
void onStart(Progress progress);
/** 下载进行时回调 */
void onProgress(Progress progress);
/** 下载出错时回调 */
void onError(Progress progress);
/** 下载完成时回调 */
void onFinish(T t, Progress progress);
/** 被移除时回调 */
void onRemove(Progress progress);
}
| [
"1056407060@qq.com"
] | 1056407060@qq.com |
39606a6fd6594e5269944133e5bc1a9a08bcbcab | 4130b7409486344bd2903320309c016646a4bce0 | /MegaJump/MainMenu.java | ea2def3617e027a5513972b7e6e8d554c525d70a | [] | no_license | vasav123/Megajump | 12b2df82b0b7879fcf7f26d370c93b012a13bd8d | 93ea30c7ed9f7850c0edfe9349642fd1bc181144 | refs/heads/master | 2020-06-08T20:54:46.123356 | 2015-12-28T06:46:53 | 2015-12-28T06:46:53 | 29,781,879 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 23,537 | java | //MainMenu.java
//Vasav Shah, Kevin Shi
//there are two class in this file
//the Main Menu class makes the JFrame and allows the user to switch between the game and menu screen
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.sound.sampled.AudioSystem;
import java.applet.*;
public class MainMenu extends JFrame implements ActionListener{
javax.swing.Timer myTimer;
javax.swing.Timer player1Timer;
MenuPanel panel = new MenuPanel();
GamePanel game = new GamePanel("android",1);
public MainMenu() {
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Creation of panels and frames
super("Mega Jump");
setLayout(null);
setSize(975,639);
panel.setSize(975,639);
panel.setLocation(0,0);
add(panel);
panel.setVisible(true);
game.setSize(479,768);
game.setLocation(0,0);
add(game);
game.setVisible(false);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Timers
myTimer=new javax.swing.Timer (10,this);
myTimer.start();
player1Timer= new javax.swing.Timer(5000,this); //5 seconds for the powerup
}
public void actionPerformed(ActionEvent evnt){
Object source = evnt.getSource();
if (panel.getGame()){
if (!game.getOn()){
game.startMusic();
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Game Panel
panel.setVisible(false); //if the user is in on the gamePanel set the menu panel to not visible
game.setVisible(true); //now the user is focused on the game
game.requestFocus();
game.repaint();
setSize(479,768);
if (game.getPowerUp().equals("P1")){
player1Timer.start();
}
if (source==player1Timer && game.getPowerUp().equals("P1")){
game.resetPower();
player1Timer.stop();
}
if(game.getMenu()){
panel.setGame();
game.setVisible(false);
}
}
else{ //here the user is on the main menu screen
if (panel.getOn()==false){
panel.startMusic();
}
panel.setVisible(true);
game.setVisible(false);
setSize(975,639);
panel.requestFocus();
panel.repaint();
game.setMenu();
game.stopMusic();
game.resetValues(panel.getLevel(),panel.getCharacter());
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
public static void main(String[] arguments){
MainMenu menu = new MainMenu();
}
}
class MenuPanel extends JPanel implements MouseListener,MouseMotionListener,KeyListener,MouseWheelListener{
private Image mainBackground;
private int mx,my;
boolean click;
AudioClip bckGrndMusic; //Audio Files
AudioClip clicked;//<--sounds when a button is clicked
private Font scoreFont;
SButton startGame,rightArrowC,leftArrowC,rightArrowL,leftArrowL,play,lvlSelect,store,options,help,blocks,powerup,enemies,howToPlay,backMenu,backOptn,backLvl,backHelp,play1,play2,coin,powerupStoreb,playerStoreb,backStore,rightArrow,leftArrow,buyBtn;
//ArrayLists of buttons that show up on each screen.
//Setup for arraylists
ArrayList <SButton> mainBtnList = new ArrayList <SButton>();
ArrayList <SButton> modesBtnList = new ArrayList <SButton>();
ArrayList <SButton> playBtnList = new ArrayList <SButton>();
ArrayList <SButton> lvlBtnList = new ArrayList <SButton>();
ArrayList <SButton> storeBtnList = new ArrayList <SButton>();
ArrayList <SButton> optnBtnList = new ArrayList <SButton>();
ArrayList <SButton> helpBtnList = new ArrayList <SButton>();
ArrayList <SButton> hTPBtnList = new ArrayList <SButton>();
ArrayList <SButton> blockBtnList = new ArrayList <SButton>();
ArrayList <SButton> powerupBtnList = new ArrayList <SButton>();
ArrayList <SButton> enemBtnList = new ArrayList <SButton>();
ArrayList <SButton> coinBtnList = new ArrayList <SButton>();
ArrayList <SButton> powerupStoreBtnList = new ArrayList<SButton>();
ArrayList <SButton> charStoreBtnList = new ArrayList<SButton>();
ArrayList <String> charPickList = new ArrayList<String>();//Characters have not been unloicked
int[]levelPickList = {1,2,3,4,5,6,7,8,9,10};//<All levels have been unlocked. You're welcome.
//Character and Level selection
ArrayList<Image> charPics = new ArrayList<Image>();
ArrayList<Image> levelPics = new ArrayList<Image>();
ArrayList <String> stats = new ArrayList<String>();
int charCounter;
int levelCounter;
//Variables that keep track of stats
int coins, highscore,maxHeight,totalDist;
Image displayPanel = new ImageIcon("Store/displayPanel.png").getImage();
Image lock = new ImageIcon("Store/lock.png").getImage();
Store str= new Store("");
String screen;
Slider s =new Slider(0,0);
boolean [] keys;
private boolean on=true;
public MenuPanel(){
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Setup for Menu
setFocusable(true);
grabFocus();
addMouseListener(this);
addMouseMotionListener(this);
addKeyListener(this);
addMouseWheelListener(this);
keys=new boolean[2000];
mx=0;my=0; //<---mouse position
click = false; //<---mouse click
screen = "main"; //keeps track of which screen the menu currently is on
try{scoreFont = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(new File("BRLNSB.ttf"))).deriveFont(0,48);}//<Font Stuff
catch(IOException ioe){System.out.println("error loading BRLNSB.tff");}
catch(FontFormatException ffe){System.out.println("Something went wrong with the font.");}
charCounter = 0;
levelCounter= 0;
for(int i=1;i<11;i++){
levelPics.add(new ImageIcon("levelSelect/level"+i+".png").getImage());
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Sounds
bckGrndMusic= Applet.newAudioClip(getClass().getResource("bgmusic00.wav"));
clicked= Applet.newAudioClip(getClass().getResource("grav_step_4.wav"));
bckGrndMusic.loop();
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Buttons
play = new SButton(510,250,"play","playModes");
play1 = new SButton(200,200,"1PlayerButton","menu");
play2 = new SButton(300,200,"2PlayerButton","menu");
store = new SButton(530,370,"store","store");
options = new SButton(10,10,"options","options");
help = new SButton(800,10,"help","help");
backMenu = new SButton(700,490,"back","menu");
backLvl = new SButton(50,500,"lvlSelect","playModes");
backHelp = new SButton(20,510,"help","help");
howToPlay = new SButton(50,15,"howToPlay","howToPlay");
blocks = new SButton(50,135,"blocks","blocks");
powerup = new SButton(50,255,"powerup","powerup");
enemies = new SButton(50,375,"enemies","enemies");
coin = new SButton(50,495,"coin","coin");
backStore = new SButton(20,510,"store","store");
startGame = new SButton(300,490,"play","menu");
leftArrowC = new SButton(10,250,"leftArrow","leftChar");
rightArrowC = new SButton(455,250,"rightArrow","rightChar");
leftArrowL = new SButton(500,250,"leftArrow","leftLevel");
rightArrowL = new SButton(910,250,"rightArrow","rightLevel");
powerupStoreb = new SButton(50,135,"powerup_store","powerup_store");
playerStoreb = new SButton(50,255,"char_store","char_store");
rightArrow = new SButton(885,200,"rightArrow","right");
leftArrow = new SButton(30,200,"leftArrow","left");
buyBtn = new SButton(700,370,"buy","buy");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Adding Buttons into lists
storeBtnList.add(powerupStoreb);storeBtnList.add(playerStoreb);
mainBtnList.add(play);mainBtnList.add(store);mainBtnList.add(options);mainBtnList.add(help);
modesBtnList.add(startGame);modesBtnList.add(rightArrowC);modesBtnList.add(leftArrowC);modesBtnList.add(rightArrowL);modesBtnList.add(leftArrowL);modesBtnList.add(backMenu);
lvlBtnList.add(backLvl);lvlBtnList.add(backMenu);lvlBtnList.add(play1);lvlBtnList.add(play2);
storeBtnList.add(backMenu);
optnBtnList.add(backMenu);
helpBtnList.add(howToPlay);helpBtnList.add(blocks);helpBtnList.add(powerup);helpBtnList.add(enemies);helpBtnList.add(backMenu);helpBtnList.add(coin);
hTPBtnList.add(backHelp);blockBtnList.add(backHelp);powerupBtnList.add(backHelp);enemBtnList.add(backHelp);coinBtnList.add(backHelp);
hTPBtnList.add(backMenu);blockBtnList.add(backMenu);powerupBtnList.add(backMenu);enemBtnList.add(backMenu);coinBtnList.add(backMenu);
powerupStoreBtnList.add(backStore);powerupStoreBtnList.add(backMenu);powerupStoreBtnList.add(rightArrow);powerupStoreBtnList.add(leftArrow);powerupStoreBtnList.add(buyBtn);
charStoreBtnList.add(backStore);charStoreBtnList.add(backMenu);charStoreBtnList.add(rightArrow);charStoreBtnList.add(leftArrow);charStoreBtnList.add(buyBtn);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
mainBackground = new ImageIcon("menus/mainMenu.png").getImage();
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Mouse stuff
public void mouseEntered(MouseEvent e){}
public void mouseReleased(MouseEvent e){click = false;}
public void mousePressed(MouseEvent e){
click = true;//<--keeps track of if the mouse is clicked or not
//First it checks which screen the user is on. Then it goes through the list of buttons for the menu and checks to see if they
//have been clicked or not
if(screen.equals("main")){ //<---When the screen is on the main menu, then the buttons on the main menu
for(SButton i : mainBtnList){
if(i.clicked(mx,my,click) && i.checkScreen()){
clicked.play();//<-----fancy sound
screen = i.getScreen();
}
}
}
else if(screen.equals("playModes")){
for(SButton i : modesBtnList){
if (i.clicked(mx,my,click)&&i.checkScreen()){
if(i.clicked(mx,my,click) && i.getType().equals("play")){
clicked.play();
screen="1playergame";
}
//These are character and level selection
//When these arrows are clicked, it changes the position of the lists that contain the levels and characters
else if(i.clicked(mx,my,click) && i.getScreen().equals("leftChar")){
clicked.play();
charCounter-=1;
if(charCounter<0){
charCounter = charPics.size()-1;
}
}
else if(i.clicked(mx,my,click) && i.getScreen().equals("rightChar")){
clicked.play();
charCounter+=1;
if(charCounter>charPics.size()-1){
charCounter = 0;
}
}
else if(i.clicked(mx,my,click) && i.getScreen().equals("leftLevel")){
clicked.play();
levelCounter-=1;
if(levelCounter<0){
levelCounter = 9;
}
}
else if(i.clicked(mx,my,click) && i.getScreen().equals("rightLevel")){
clicked.play();
levelCounter+=1;
if(levelCounter>9){
levelCounter = 0;
}
}
else{
clicked.play();
screen = i.getScreen();
}
}
}
}
else if(screen.equals("help")){
s.reset();
for(SButton i : helpBtnList){
if(i.clicked(mx,my,click) && i.checkScreen()){
clicked.play();
screen = i.getScreen();
}
}
}
else if(screen.equals("howToPlay") || screen.equals("blocks") || screen.equals("powerup") || screen.equals("enemies") || screen.equals("coin")){
//These menus all have the same buttons so only one statement was needed
for(SButton i : hTPBtnList){
if(i.clicked(mx,my,click) && i.checkScreen()){
clicked.play();
screen = i.getScreen();
}
}
}
else if (screen.equals("store")){
for (SButton i:storeBtnList){
if (i.clicked(mx,my,click)&&i.checkScreen()){
clicked.play();
screen=i.getScreen();
}
}
}
else if (screen.equals("powerup_store")){
//When left and right buttons are clicked, changes position in the list (which shows what item is currently selected)
for (SButton i :powerupStoreBtnList){
if (i.clicked(mx,my,click)&&i.checkScreen()){
if (i.getScreen().equals("right")){
clicked.play();
str.goRight();
}
else if (i.getScreen().equals("left")){
clicked.play();
str.goLeft();
}
else if (i.getScreen().equals("buy")){
//buys an item and updates the textfile
clicked.play();
str.buy("powerup");
str.updateFile();
}
else{
screen=i.getScreen();
}
}
}
}
else if (screen.equals("char_store")){
//When left and right buttons are clicked, changes position in the list (which shows what item is currently selected)
for (SButton i:charStoreBtnList){
if (i.clicked(mx,my,click)&&i.checkScreen()){
if (i.getScreen().equals("right")){
clicked.play();
str.goRight();
}
else if (i.getScreen().equals("left")){
clicked.play();
str.goLeft();
}
else if (i.getScreen().equals("buy")){
//buys an item and updates the textfile
clicked.play();
str.buy("char");
str.updateFile();
}
else{
screen=i.getScreen();
}
}
}
}
if(! screen.equals("main")){
//this is the back button that every screen has
if(backMenu.clicked(mx,my,click)){
clicked.play();
screen = "main";
}
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
public void mouseDragged(MouseEvent e){mx = e.getX();my = e.getY();}
public void mouseMoved(MouseEvent e){mx = e.getX();my = e.getY();}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
public void mouseWheelMoved(MouseWheelEvent e){
//This is for scrolling on the tutorial screens
if(screen.equals("howToPlay") || screen.equals("blocks") || screen.equals("powerup") || screen.equals("enemies") || screen.equals("coin")){
if (e.getWheelRotation()>0){
s.moveDown(e.getScrollAmount()*2);
}
else if (e.getWheelRotation()<0){
s.moveUp(Math.abs(e.getScrollAmount())*2);
}
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
public void keyPressed(KeyEvent evt){ //if i pressed an keydown then set it to equal true
int i=evt.getKeyCode();
keys[i]=true;
}
public void keyReleased(KeyEvent evt){ //one i let go set it to equal false
int i=evt.getKeyCode();
keys[i]=false;
}
public void keyTyped(KeyEvent evt){
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------
public void readFile(String name){ //reads the file and puts everything in the textfile
Scanner inFile=null;
stats=new ArrayList<String>();
try{
inFile=new Scanner (new BufferedReader (new FileReader(name+".txt")));
while (inFile.hasNextLine()){
stats.add(inFile.nextLine());
}
}
catch(IOException ex){
System.out.println("Did you forget to make the"+name+".txt file?");
}
}
public void manageStuff(){
//Goes through the arraylists and manages them
int c=0;
c++;
for (int i = 0; i<Integer.parseInt(stats.get(1));i++){
c++;
}
c++;
charPickList= new ArrayList <String>();
charPics= new ArrayList<Image>();
for(int i = c+1;i<c+Integer.parseInt(stats.get(c))+1;i++){
charPickList.add(stats.get(i));
}
for(String name : charPickList){
charPics.add(new ImageIcon("charSelect/"+name+".png").getImage());
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------
public void drawPowerUpScreen(Graphics g,String screen){
g.drawImage(new ImageIcon("menus/"+screen+"Menu.png").getImage(),0,0,this);
g.drawImage(displayPanel,100,25,displayPanel.getWidth(null),displayPanel.getHeight(null),this);
g.drawImage(str.getPowerPic(),100,25,this);
g.drawImage(new ImageIcon("InGameMenu/coin.png").getImage(),300,515,this);
g.setFont(scoreFont);
g.setColor(Color.WHITE);
g.drawString(""+str.getPowerUpPrice(),600,400);
g.drawString(""+str.getMoney(),370,553);
if (str.getPowerLocked()){
g.drawImage(lock,150,300,this);
//g.drawImage(buyBtn.getPic(mx,my),buyBtn.getX(),buyBtn.getY(),this);
}
}
public void drawCharScreen(Graphics g,String screen){
g.drawImage(new ImageIcon("menus/"+screen+"Menu.png").getImage(),0,0,this);
g.drawImage(displayPanel,100,25,displayPanel.getWidth(null),displayPanel.getHeight(null),this);
g.drawImage(str.getCharPic(),100,25,this);
g.drawImage(new ImageIcon("InGameMenu/coin.png").getImage(),300,515,this);
g.setFont(scoreFont);
g.setColor(Color.WHITE);
g.drawString(""+str.getCharPrice(),550,400);
g.drawString(""+str.getMoney(),370,553);
if (str.getCharLocked()){
g.drawImage(lock,150,300,this);
// g.drawImage(buyBtn.getPic(mx,my),buyBtn.getX(),buyBtn.getY(),this);
}
// str.drawEverything(g,this);
}
public void drawHelpScreen(Graphics g, String screen){
g.drawImage(new ImageIcon("menus/"+screen+"help.png").getImage(),0,s.move(new ImageIcon("menus/"+screen+"help.png").getIconHeight())*-1,this);
g.drawImage(new ImageIcon("menus/sliderBigBar.png").getImage(),958,0,this);
g.drawImage(new ImageIcon("menus/sliderSmallBar.png").getImage(),957,s.getY(),this);
if (keys[KeyEvent.VK_UP]){
s.moveUp(1);
}
if (keys[KeyEvent.VK_DOWN]){
s.moveDown(1);
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------
public void paintComponent(Graphics g){
readFile("stats");
manageStuff();
highscore = Integer.parseInt(stats.get(stats.size()-3));
maxHeight = Integer.parseInt(stats.get(stats.size()-2));
totalDist = Integer.parseInt(stats.get(stats.size()-1));
if(screen.equals("main")){
g.drawImage(mainBackground,0,0,this);
displayButtons(g,mainBtnList);
}
if (screen.equals("1playergame")){
// game.repaint();
}
for (SButton i: powerupStoreBtnList){
if (screen.equals(i.getScreen())){
g.drawImage(new ImageIcon("menus/"+i.getScreen()+"Menu.png").getImage(),0,0,this);
}
}
if (screen.equals("powerup_store")){
drawPowerUpScreen(g,"powerup_store");
displayButtons(g,powerupStoreBtnList);}
if (screen.equals("char_store")){drawCharScreen(g,screen);displayButtons(g,charStoreBtnList);}
for(SButton i : mainBtnList){
if(screen.equals(i.getScreen())){
g.drawImage(new ImageIcon("menus/"+i.getScreen()+"Menu.png").getImage(),0,0,this);
if(i.getScreen().equals("playModes")){
displayButtons(g,modesBtnList);
g.drawImage(charPics.get(charCounter),100,150,this);
g.drawImage(levelPics.get(levelCounter),570,150,this);
}
if(i.getScreen().equals("store")){displayButtons(g,storeBtnList);}
if(i.getScreen().equals("options")){
displayButtons(g,optnBtnList);
g.setFont(scoreFont);
g.setColor(Color.BLACK);
g.drawString("Coins: "+stats.get(0),50,100);
g.drawString("Highscore: "+highscore+" points",50,200);
g.drawString("Highest Point Reached: "+ maxHeight+" m",50,300);
g.drawString("Total Distance Travelled: "+ totalDist+" m",50,400);
}
if(i.getScreen().equals("help")){displayButtons(g,helpBtnList);}
}
}
for(SButton i : modesBtnList){
if(screen.equals(i.getScreen())){
g.drawImage(new ImageIcon("menus/"+i.getScreen()+"Menu.png").getImage(),0,0,this);
if(i.getScreen().equals("lvlSelect")){displayButtons(g,lvlBtnList);}
}
}
for(SButton i : helpBtnList){
if(screen.equals(i.getScreen())){
g.drawImage(new ImageIcon("menus/"+i.getScreen()+"Menu.png").getImage(),0,0,this);
//------------------------------------------------------------------------------------------------------------------------------------------------------------
if(i.getScreen().equals("howToPlay")){ //CODED ADDED FOR SLIDER BAR REMOVE LATER
drawHelpScreen(g,"howtoplay");
//------------------------------------------------------------------------------------------------------------------------
displayButtons(g,hTPBtnList);}
if(i.getScreen().equals("blocks")){
drawHelpScreen(g,"blocks");
displayButtons(g,blockBtnList);
}
if(i.getScreen().equals("powerup")){
drawHelpScreen(g,"powerup");
displayButtons(g,powerupBtnList);
}
if(i.getScreen().equals("enemies")){
drawHelpScreen(g,"enemies");
displayButtons(g,enemBtnList);
}
if (i.getScreen().equals("coin")){
drawHelpScreen(g,"coin");
displayButtons(g,coinBtnList);
}
}
}
}
public int getLevel(){
return levelPickList[levelCounter];
}
public String getCharacter(){
return charPickList.get(charCounter);
}
public void setGame(){
screen="main";
// bckGrndMusic.loop();
}
public void startMusic(){
if (on==false){
bckGrndMusic.loop();
on=true;
}
}
public boolean getOn(){
return on;
}
public boolean getGame(){
if (screen.equals("1playergame")){
bckGrndMusic.stop();
on=false;
return true;
}else{
return false;
}
}
private void displayButtons(Graphics g, ArrayList <SButton> buttons){
for(SButton i : buttons){
g.drawImage(i.getPic(mx,my),i.getX(),i.getY(),this);
}
}
} | [
"vasavrules@hotmail.com"
] | vasavrules@hotmail.com |
5238c6d700201fc8c6d8e2ea85e02d213410ae65 | 0f0179bc26263b7dbbd0eb9b15522b852deefaeb | /Recursividad/src/mochila/Elemento.java | f4fb2ef2fb294bf18347752a49a3107c888dd107 | [] | no_license | fedeatanasoff/backtracking-java | c77cb95293e53e5c337560f21ac97fbd14781ead | 29114a9efeaee9409d6e2c3f80af708455730561 | refs/heads/master | 2020-04-06T10:57:31.262264 | 2018-11-13T17:00:38 | 2018-11-13T17:00:38 | 157,398,198 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,050 | java | package mochila;
public class Elemento {
private int peso, beneficio;
public Elemento(int peso, int beneficio) {
super();
this.peso = peso;
this.beneficio = beneficio;
}
public int getPeso() {
return peso;
}
public void setPeso(int peso) {
this.peso = peso;
}
public int getBeneficio() {
return beneficio;
}
public void setBeneficio(int beneficio) {
this.beneficio = beneficio;
}
@Override
public boolean equals(Object obj) {
if(this == obj) return true;
if(obj == null) return false;
if( getClass() != obj.getClass()) return false;
final Elemento otro = (Elemento) obj;
if(this.peso != otro.peso) return false;
if(this.beneficio != otro.beneficio) return false;
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 23*hash + this.peso;
hash = 23*hash + this.beneficio;
return hash;
}
@Override
public String toString() {
return "Elemento [peso=" + peso + ", beneficio=" + beneficio + "]";
}
}
| [
"fede.atanasoff@gmail.com"
] | fede.atanasoff@gmail.com |
514e922b6a7b6457347d37f5197861e31b1dc4d6 | e8bf30970a351c2ebeba564576b909dd45560626 | /concurrency-02.01.explicitlock/search/MyCollection.java | f73ae1fc8dbe5a2e63103c67d19db8e0b7c6ac33 | [] | no_license | HBrauer/Skeleton | 499656e9aa19998c9b933b9d2d047203d36fc545 | 9b3c1ecbfd8b1249a17f3ef5c138a40f11fd0508 | refs/heads/master | 2021-01-10T17:44:00.123883 | 2016-01-27T16:02:40 | 2016-01-27T16:02:40 | 50,282,693 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 2,285 | java | /*
Based on course material for "Concurrent Programming Java", a seminar
prepared and owned by Angelika Langer & Klaus Kreft, November 2003
contact: http://www.langer.camelot.de/ or mailto: langer@camelot.de
© Copyright by Angelika Langer & Klaus Kreft.
Permission to use, copy, and modify this software for any non-profit
purpose is hereby granted to attendants of the above mentioned seminar
without fee, provided that the above copyright notice appears in all
copies. Angelika Langer and Klaus Kreft make no representations about
the suitability of this software for any purpose. It is provided
"as is" without express or implied warranty.
*/
package search;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import test.FakeModifier;
public class MyCollection {
private Collection<ElementType> data = CollectionProvider.makeCollection();
private Lock lock = new ReentrantLock();
public int size() {
lock.lock();
try {
return data.size();
} finally {
lock.unlock();
}
}
public String toString() {
lock.lock();
try {
return data.toString();
} finally {
lock.unlock();
}
}
public boolean remove(Predicate<ElementType> isInteresting) {
boolean found = false;
lock.lock();
try {
Iterator<ElementType> iter = data.iterator();
while (iter.hasNext()) {
ElementType element = iter.next();
if (isInteresting.evaluate(element)) {
found = true;
synchronized (element) {
iter.remove();
}
}
}
} finally {
lock.unlock();
}
return found;
}
public boolean modify(Predicate<ElementType> isInteresting) {
boolean found = false;
ElementType element = null;
lock.lock();
try {
Iterator<ElementType> iter = data.iterator();
while (iter.hasNext()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
} // for test purposes only
element = iter.next();
if (isInteresting.evaluate(element)) {
found = true;
break;
}
}
} finally {
synchronized (element) {
lock.unlock();
if (found) {
// perform a time-consuming modification
FakeModifier.modify(element);
}
}
}
return found;
}
}
| [
"hbrauer@gmx.de"
] | hbrauer@gmx.de |
f6e936c7348f85497cf67dc424f744fa47b00cd4 | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/XWIKI-13141-17-22-NSGA_II-LineCoverage:ExceptionType:StackTraceSimilarity/com/xpn/xwiki/web/ActionFilter_ESTest.java | fc473f03383fb375fb5316d460ab0fdee660c2f4 | [] | no_license | STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application | cf118b23ecb87a8bf59643e42f7556b521d1f754 | 3bb39683f9c343b8ec94890a00b8f260d158dfe3 | refs/heads/master | 2022-07-29T14:44:00.774547 | 2020-08-10T15:14:49 | 2020-08-10T15:14:49 | 285,804,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 548 | java | /*
* This file was automatically generated by EvoSuite
* Wed Jan 22 04:14:17 UTC 2020
*/
package com.xpn.xwiki.web;
import org.junit.Test;
import static org.junit.Assert.*;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true)
public class ActionFilter_ESTest extends ActionFilter_ESTest_scaffolding {
@Test
public void notGeneratedAnyTest() {
// EvoSuite did not generate any tests
}
}
| [
"pouria.derakhshanfar@gmail.com"
] | pouria.derakhshanfar@gmail.com |
72c435fc34b69c18aec68684683563f44d7a886e | ba080f92a85cd03cd9ae836e1c9067b76eb87d76 | /JavaEECourseProjectEJB/ejbModule/bg/softuni/forum/entity/base/BaseDomainObject.java | 9d7c2540ca4037edb1e836486f4db4098b26ad45 | [] | no_license | Nitroto/JaveEECourseProject | 5768285aec721417b38e5aadb383c4760c162256 | 27aadaed8414323c351069ea43deeb647657f72b | refs/heads/master | 2020-06-22T10:20:21.847062 | 2016-11-23T16:45:24 | 2016-11-23T16:45:24 | 74,595,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,348 | java | package bg.softuni.forum.entity.base;
import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
/**
* Base model class, all entities should extend this one.
*/
@MappedSuperclass
public class BaseDomainObject implements Serializable {
private static final long serialVersionUID = 1L;
protected Long id;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
BaseDomainObject other = (BaseDomainObject) obj;
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
return true;
}
}
| [
"astodorov@outlook.com"
] | astodorov@outlook.com |
36cc5d74240d6f67c32227b5d093c8de5e84c9df | f7fdeb00703a71862a490aa0bd65ccbe9958e1b7 | /org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renameclass/TS_RenameClass.java | d23062b2bb21bc90dc995b7c0f4e4805d4574aef | [] | no_license | misto/Ruby-Refactoring | d3b421b8c70b6b5118ff074d774aaf4e77ccf0de | 1113af36324e6499fae011788ae740962d6accc0 | refs/heads/master | 2020-12-24T13:28:01.402530 | 2012-10-22T08:22:30 | 2012-10-22T08:22:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,106 | java | /***** BEGIN LICENSE BLOCK *****
* Version: CPL 1.0/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Common Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.eclipse.org/legal/cpl-v10.html
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Copyright (C) 2006 Mirko Stocker <me@misto.ch>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the CPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
package org.rubypeople.rdt.refactoring.tests.core.renameclass;
import junit.framework.TestSuite;
import org.rubypeople.rdt.refactoring.tests.FileTestSuite;
import org.rubypeople.rdt.refactoring.tests.core.renameclass.conditionchecker.TS_RenameClassChecks;
public class TS_RenameClass extends FileTestSuite {
public static TestSuite suite() {
TestSuite suite = createSuite("Rename Class", "rename_class_test_*source", ClassRenameTester.class);
suite.addTestSuite(TC_ClassFinder.class);
suite.addTestSuite(TC_ClassInstanciationFinder.class);
suite.addTest(TS_RenameClassChecks.suite());
return suite;
}
} | [
"mirkostocker@0bd42bcd-5f16-0410-9896-c9ec0b0ce843"
] | mirkostocker@0bd42bcd-5f16-0410-9896-c9ec0b0ce843 |
94b55ac3aff8d2222e31f5a8a4d28a83009b1d0e | b22ec5a13eda0427f9434139da9b1515862d6b0e | /binary-REST-Serializer/src/main/java/org/xine/bookshop/business/restserialization/control/JavaDeserializer.java | 8045d7df9a9cac4ec4b5767fb930aa201b10c6a7 | [] | no_license | juliankotrba/microservices | d3c1b482594379b5cd7ae15d53910c88fd94b2f4 | ca0478f72910ad837aa2450d4458aaae82c5452e | refs/heads/master | 2021-10-21T14:03:10.647083 | 2019-03-04T11:37:10 | 2019-03-04T11:37:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,344 | java | package org.xine.bookshop.business.restserialization.control;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.Consumes;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.Provider;
@Provider
@Consumes(CustomMediaType.SERIALIZATION_JAVA)
public class JavaDeserializer implements MessageBodyReader<Object> {
public boolean isReadable(final Class<?> type,
final Type genericType,
final Annotation[] annotations,
final MediaType mediaType) {
return Serializable.class.isAssignableFrom(type);
}
public Object readFrom(final Class<Object> type, final Type genericType, final Annotation[] annotations,
final MediaType mediaType, final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream)
throws IOException, WebApplicationException {
try {
final ObjectInputStream in = new ObjectInputStream(entityStream);
return in.readObject();
} catch (final ClassNotFoundException ex) {
throw new IOException("Cannot find class for: " + type.getName(), ex);
}
}
}
| [
"joao.costa@present-technologies.com"
] | joao.costa@present-technologies.com |
6a20216864b17f849b92aa34865a8105277f3f19 | fbd08cb7657f7dcd01236f9f21084efc4a202fc5 | /app/src/main/java/com/tomrichardson/datacollection/ui/utils/OnSwipeTouchListener.java | 08eecd9045e579f509facd70f778a7c0280f2ef7 | [] | no_license | mrtomrichy/DataCollection | b3d62f2adbc3650635231709ce1de43abf1a081e | 0cd96370dbcfbec13e5769b234f65dafd38039a2 | refs/heads/master | 2021-01-10T06:11:46.153814 | 2016-08-15T23:20:15 | 2016-08-15T23:20:15 | 46,669,677 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,978 | java | package com.tomrichardson.datacollection.ui.utils;
import android.content.Context;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
public class OnSwipeTouchListener implements OnTouchListener {
private final GestureDetector gestureDetector;
public OnSwipeTouchListener (Context ctx){
gestureDetector = new GestureDetector(ctx, new GestureListener());
}
@Override
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
private final class GestureListener extends SimpleOnGestureListener {
private static final int SWIPE_THRESHOLD = 100;
private static final int SWIPE_VELOCITY_THRESHOLD = 100;
@Override
public boolean onDown(MotionEvent e) {
return true;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
boolean result = false;
try {
float diffY = e2.getY() - e1.getY();
float diffX = e2.getX() - e1.getX();
if (Math.abs(diffX) > Math.abs(diffY)) {
if (Math.abs(diffX) > SWIPE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
if (diffX > 0) {
onSwipeRight();
} else {
onSwipeLeft();
}
}
result = true;
}
else if (Math.abs(diffY) > SWIPE_THRESHOLD && Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) {
if (diffY > 0) {
onSwipeBottom();
} else {
onSwipeTop();
}
}
result = true;
} catch (Exception exception) {
exception.printStackTrace();
}
return result;
}
}
public void onSwipeRight() {
}
public void onSwipeLeft() {
}
public void onSwipeTop() {
}
public void onSwipeBottom() {
}
}
| [
"tom@pc-208-196.wireless.mancourt.opal.lan"
] | tom@pc-208-196.wireless.mancourt.opal.lan |
85674a44fbdaa9cbe8aaf821751256254dc5c6ef | 640c9eb9e4e5ae7195fccb7627e3207d4247ac51 | /com/raugfer/crypto/sha512.java | 3f26032d20677e6c72af3d60e7ed516318634ac5 | [
"MIT"
] | permissive | vae520283995/crypto-java-1 | dcc4cd31670ecf82f5deab6ff5e036d38d7c5ceb | 2b2c9fc80df1fc901103054bd3f5ef0b6d1e166d | refs/heads/master | 2021-07-14T07:20:25.691101 | 2020-04-29T09:10:42 | 2020-04-29T09:10:42 | 219,698,745 | 0 | 1 | MIT | 2020-01-22T13:43:14 | 2019-11-05T08:50:39 | Java | UTF-8 | Java | false | false | 6,322 | java | package com.raugfer.crypto;
public class sha512 {
private static long CH(long x, long y, long z) { return (x & (y ^ z)) ^ z; }
private static long MAJ(long x, long y, long z) { return (x & y) ^ ((x ^ y) & z); }
private static long RTR(long x, int y) { return (x >>> y) ^ (x << (64 - y)); }
private static long EP0(long x) { return RTR(x, 28) ^ RTR(x, 34) ^ RTR(x, 39); }
private static long EP1(long x) { return RTR(x, 14) ^ RTR(x, 18) ^ RTR(x, 41); }
private static long SIG0(long x) { return RTR(x, 1) ^ RTR(x, 8) ^ (x >>> 7); }
private static long SIG1(long x) { return RTR(x, 19) ^ RTR(x, 61) ^ (x >>> 6); }
public static byte[] hash(byte[] message) {
return hash(message, false);
}
public static byte[] hash(byte[] message, boolean compressed) {
if (!compressed) {
int bytesize = message.length;
long bitsize = 8 * bytesize;
int modulo = (bytesize + 1 + 16) % 128;
int padding = modulo > 0 ? 128 - modulo : 0;
byte[] b = new byte[bytesize + 1 + padding + 16];
System.arraycopy(message, 0, b, 0, message.length);
b[bytesize] = (byte)0x80;
b[b.length-8] = (byte)((bitsize >> 56) & 0xff);
b[b.length-7] = (byte)((bitsize >> 48) & 0xff);
b[b.length-6] = (byte)((bitsize >> 40) & 0xff);
b[b.length-5] = (byte)((bitsize >> 32) & 0xff);
b[b.length-4] = (byte)((bitsize >> 24) & 0xff);
b[b.length-3] = (byte)((bitsize >> 16) & 0xff);
b[b.length-2] = (byte)((bitsize >> 8) & 0xff);
b[b.length-1] = (byte)((bitsize >> 0) & 0xff);
message = b;
}
assert message.length % 128 == 0;
long[] ws = new long[message.length/8];
for (int i = 0; i < message.length; i += 8) {
ws[i/8] = ((long)(message[i+0] & 0xff) << 56)
| ((long)(message[i+1] & 0xff) << 48)
| ((long)(message[i+2] & 0xff) << 40)
| ((long)(message[i+3] & 0xff) << 32)
| ((long)(message[i+4] & 0xff) << 24)
| ((long)(message[i+5] & 0xff) << 16)
| ((long)(message[i+6] & 0xff) << 8)
| ((long)(message[i+7] & 0xff) << 0);
}
long[] s = {
0x6a09e667f3bcc908L, 0xbb67ae8584caa73bL, 0x3c6ef372fe94f82bL, 0xa54ff53a5f1d36f1L,
0x510e527fade682d1L, 0x9b05688c2b3e6c1fL, 0x1f83d9abfb41bd6bL, 0x5be0cd19137e2179L,
};
long[] k = {
0x428a2f98d728ae22L, 0x7137449123ef65cdL, 0xb5c0fbcfec4d3b2fL, 0xe9b5dba58189dbbcL,
0x3956c25bf348b538L, 0x59f111f1b605d019L, 0x923f82a4af194f9bL, 0xab1c5ed5da6d8118L,
0xd807aa98a3030242L, 0x12835b0145706fbeL, 0x243185be4ee4b28cL, 0x550c7dc3d5ffb4e2L,
0x72be5d74f27b896fL, 0x80deb1fe3b1696b1L, 0x9bdc06a725c71235L, 0xc19bf174cf692694L,
0xe49b69c19ef14ad2L, 0xefbe4786384f25e3L, 0x0fc19dc68b8cd5b5L, 0x240ca1cc77ac9c65L,
0x2de92c6f592b0275L, 0x4a7484aa6ea6e483L, 0x5cb0a9dcbd41fbd4L, 0x76f988da831153b5L,
0x983e5152ee66dfabL, 0xa831c66d2db43210L, 0xb00327c898fb213fL, 0xbf597fc7beef0ee4L,
0xc6e00bf33da88fc2L, 0xd5a79147930aa725L, 0x06ca6351e003826fL, 0x142929670a0e6e70L,
0x27b70a8546d22ffcL, 0x2e1b21385c26c926L, 0x4d2c6dfc5ac42aedL, 0x53380d139d95b3dfL,
0x650a73548baf63deL, 0x766a0abb3c77b2a8L, 0x81c2c92e47edaee6L, 0x92722c851482353bL,
0xa2bfe8a14cf10364L, 0xa81a664bbc423001L, 0xc24b8b70d0f89791L, 0xc76c51a30654be30L,
0xd192e819d6ef5218L, 0xd69906245565a910L, 0xf40e35855771202aL, 0x106aa07032bbd1b8L,
0x19a4c116b8d2d0c8L, 0x1e376c085141ab53L, 0x2748774cdf8eeb99L, 0x34b0bcb5e19b48a8L,
0x391c0cb3c5c95a63L, 0x4ed8aa4ae3418acbL, 0x5b9cca4f7763e373L, 0x682e6ff3d6b2b8a3L,
0x748f82ee5defb2fcL, 0x78a5636f43172f60L, 0x84c87814a1f0ab72L, 0x8cc702081a6439ecL,
0x90befffa23631e28L, 0xa4506cebde82bde9L, 0xbef9a3f7b2c67915L, 0xc67178f2e372532bL,
0xca273eceea26619cL, 0xd186b8c721c0c207L, 0xeada7dd6cde0eb1eL, 0xf57d4f7fee6ed178L,
0x06f067aa72176fbaL, 0x0a637dc5a2c898a6L, 0x113f9804bef90daeL, 0x1b710b35131c471bL,
0x28db77f523047d84L, 0x32caab7b40c72493L, 0x3c9ebe0a15c9bebcL, 0x431d67c49c100d4cL,
0x4cc5d4becb3e42b6L, 0x597f299cfc657e2aL, 0x5fcb6fab3ad6faecL, 0x6c44198c4a475817L,
};
long s0 = s[0], s1 = s[1], s2 = s[2], s3 = s[3], s4 = s[4], s5 = s[5], s6 = s[6], s7 = s[7];
for (int j = 0; j < ws.length; j += 16) {
long[] w = new long[80];
System.arraycopy(ws, j, w, 0, 16);
for (int i = 16; i < 80; i++) {
w[i] = w[i-16] + SIG0(w[i-15]) + w[i-7] + SIG1(w[i-2]);
}
long a = s0;
long b = s1;
long c = s2;
long d = s3;
long e = s4;
long f = s5;
long g = s6;
long h = s7;
for (int i = 0; i < 80; i++) {
long t1 = h + EP1(e) + CH(e, f, g) + k[i] + w[i];
long t2 = EP0(a) + MAJ(a, b, c);
h = g;
g = f;
f = e;
e = d + t1;
d = c;
c = b;
b = a;
a = t1 + t2;
}
s0 += a;
s1 += b;
s2 += c;
s3 += d;
s4 += e;
s5 += f;
s6 += g;
s7 += h;
}
s[0] = s0; s[1] = s1; s[2] = s2; s[3] = s3; s[4] = s4; s[5] = s5; s[6] = s6; s[7] = s7;
byte[] b = new byte[64];
for (int i = 0; i < s.length; i++) {
b[8*i+0] = (byte)((s[i] >> 56) & 0xff);
b[8*i+1] = (byte)((s[i] >> 48) & 0xff);
b[8*i+2] = (byte)((s[i] >> 40) & 0xff);
b[8*i+3] = (byte)((s[i] >> 32) & 0xff);
b[8*i+4] = (byte)((s[i] >> 24) & 0xff);
b[8*i+5] = (byte)((s[i] >> 16) & 0xff);
b[8*i+6] = (byte)((s[i] >> 8) & 0xff);
b[8*i+7] = (byte)((s[i] >> 0) & 0xff);
}
return b;
}
}
| [
"rodrigo.ferreira@aya.yale.edu"
] | rodrigo.ferreira@aya.yale.edu |
5b6f4337ad31a3470290c06f5b38275198cfc352 | fe7c232fb3aa9f9fbe0a135e29685995c7dffc1b | /src/floobits/tests/ColorsTest.java | 4d1db9d7dac39c4fee96b1d00fc742f955295d22 | [
"Apache-2.0"
] | permissive | dopsonbr/floobits-intellij | 0beb2cb4c9154aa4aab09f0770c59ce2174c937b | 731e21cb426b7e89280382c0c3411393d3b7590e | refs/heads/master | 2022-04-14T19:42:53.155941 | 2020-04-15T20:56:06 | 2020-04-15T20:56:06 | 256,032,927 | 0 | 0 | Apache-2.0 | 2020-04-15T20:47:04 | 2020-04-15T20:47:04 | null | UTF-8 | Java | false | false | 1,045 | java | package floobits.tests;
import com.intellij.ui.JBColor;
import floobits.utilities.Colors;
import org.junit.Test;
import java.awt.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class ColorsTest {
@Test
public void testGetFGColor(){
JBColor expected = new JBColor(new Color(255, 255, 255, 255), new Color(255, 255, 255, 255));
JBColor received = Colors.getFGColor();
assertEquals("FG color should be black.", expected.getRGB(), received.getRGB());
}
@Test
public void testGetHex() {
JBColor c = new JBColor(new Color(255, 0, 0), new Color(255, 0, 0));
assertEquals("Should have gotten red hex value", "#FF0000", Colors.getHex(c));
}
@Test
public void testToHex() {
assertEquals("Should have gotten red hex value", "#FF0000", Colors.toHex(255, 0, 0));
}
@Test
public void testGetColorForUser() {
assertNotNull("testing get color for username", Colors.getColorForUser("bjorn"));
}
}
| [
"bjorn@ambientchill.com"
] | bjorn@ambientchill.com |
c6519268fef0fb144480cb93fe5c74776c265848 | f0e64aba2e435d3be962b85fdbe2c94b94df214b | /webDemo/src/main/java/org/smartmvc/controller/InterceptorController.java | 25d85cb7aec28e67dce9c0d53b6cfe60e80fc49a | [] | no_license | hualiuwuxin/smartmvc | bb2b92c227757d2b7fdb162ef4dd63782fc11d4e | 34fb5925ddb384e9f6db441044bc3230fbb19fa0 | refs/heads/master | 2021-01-11T14:07:04.765009 | 2017-06-21T06:40:43 | 2017-06-21T06:40:43 | 94,970,812 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,874 | java | package org.smartmvc.controller;
import org.smartmvc.core.annotation.Action;
import org.smartmvc.core.annotation.Aspect;
import org.smartmvc.core.annotation.Clear;
import org.smartmvc.core.annotation.Controller;
import org.smartmvc.core.annotation.Response;
import org.smartmvc.core.annotation.em.ResponseType;
import org.smartmvc.interceptor.ActionInterceptor;
import org.smartmvc.interceptor.ControllerInterceptor;
@Controller("interceptor")
/**
* 过滤器的执行顺序 全局过滤器 > 类控制器 >方法过滤器(类似于回链的执行方式,但是内部实现并不是回链,目的是做到 和方法过滤器格式统一)
*/
/**
* 为之歌控制器的每一个方法指定了一个过滤器ControllerInterceptor
* @author ZHANGYUKUN
*
*/
@Aspect(ControllerInterceptor.class)
public class InterceptorController {
/**
* 指定了一个方法过滤器
* @param name
* @return
*/
@Action
@Aspect(ActionInterceptor.class)
@Response(type=ResponseType.JSON)
public String t1( ){
System.out.println( "t1执行");
return "OK";
}
/**
* 指定了方法过滤器,但是清楚掉了上层过滤器
* @author ZHANGYUKUN
* @param name
* @return
*/
@Action
@Clear(value={ControllerInterceptor.class})
@Aspect(ActionInterceptor.class)
@Response(type=ResponseType.JSON)
public String t2(){
System.out.println( "t2执行");
return "OK";
}
/**
* @Clear()不指定清楚对象的时候默认清楚全部过滤器,但是@Clear() 永远只能清楚 上层 过滤器,不能清楚本层过滤器,因为完全没有必要清楚本层,本层直接在 @Aspect 中少些一个 就是最好的清除本层
* @return
*/
@Action
@Clear()
@Aspect(ActionInterceptor.class)
@Response(type=ResponseType.JSON)
public String t3(){
System.out.println( "t2执行");
return "OK";
}
}
| [
"zhangyukun@caihang.com"
] | zhangyukun@caihang.com |
b02c86780a286a6b195050fd53e822bb9db0d290 | 638b7f061d27ac7094a5a11ff908cba95f5688e8 | /springboot-jpa/src/main/java/demo/yanming/springboot/jpa/entity/Student.java | b8c505dead31ba97dfb7fe0f53c0e78e7d5f7f2e | [] | no_license | yanming-work/SpringBootDemo | 3a01f5ab93ffbd68bcc349af43435fb01b96cabd | 2d50106cacf5ef4ee9bc94e9e7feed34e63f2ba9 | refs/heads/master | 2022-07-07T02:07:09.027615 | 2019-07-01T05:42:15 | 2019-07-01T05:42:15 | 193,321,394 | 0 | 0 | null | 2022-06-17T03:02:05 | 2019-06-23T07:57:29 | Java | UTF-8 | Java | false | false | 998 | java | package demo.yanming.springboot.jpa.entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Project Name:springboot_jpa_demo <br/>
* Package Name:demo.yanming.springboot.jpa.entity <br/>
* Date:2019/2/19 21:35 <br/>
* <b>Description:</b> TODO: 描述该类的作用 <br/>
*
* @author <a href="turodog@foxmail.com">nasus</a><br/>
* Copyright Notice =========================================================
* This file contains proprietary information of Eastcom Technologies Co. Ltd.
* Copying or reproduction without prior written approval is prohibited.
* Copyright (c) 2019 =======================================================
*/
@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
public class Student {
// 自增 id
@Id
@GeneratedValue
private Integer id;
private String name;
private Integer age;
}
| [
"Administrator@BY-20170925SJPC"
] | Administrator@BY-20170925SJPC |
ed849c05f64870a714b08e7f015dcf8460840fb2 | 5be98d59b01e5edd672d92d6318d4711c017dce8 | /app/src/main/java/in/dailytalent/www/chemistryinhindi/dbhelper/ExternalDbOpenHelper.java | 90deeba12dfe008a6ed89b99ca76fdd0539c7f13 | [] | no_license | sagarsrao/Chemistryinhindi | c673f9a34a3a382e98cb9ed8e730b11d58a47ed8 | 157e8ad50496f6ade7d931478edf157e9e77001b | refs/heads/master | 2021-01-16T21:36:37.029202 | 2016-08-11T13:30:22 | 2016-08-11T13:30:22 | 65,471,663 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,505 | java | package in.dailytalent.www.chemistryinhindi.dbhelper;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.widget.Toast;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class ExternalDbOpenHelper extends SQLiteOpenHelper {
public static String DB_NAME;
public static String DB_PATH;
public final Context context;
public SQLiteDatabase database;
public SQLiteDatabase getDb() {
return this.database;
}
public ExternalDbOpenHelper(Context context, String databaseName) {
super(context, databaseName, null, 2);
this.context = context;
DB_PATH = String.format("//data//data//%s//databases//", new Object[]{context.getPackageName()});
DB_NAME = databaseName;
openDataBase();
}
public void createDataBase() {
if (checkDataBase()) {
Log.i(getClass().toString(), "Database already exists");
return;
}
getReadableDatabase();
try {
copyDataBase();
Log.e(getClass().toString(), "Copying Succesfully........Congrats Imran");
} catch (IOException e) {
Log.e(getClass().toString(), "Copying error");
throw new Error("Error copying database!");
}
}
private boolean checkDataBase() {
SQLiteDatabase checkDb = null;
try {
checkDb = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, 1);
} catch (SQLException e) {
Log.e(getClass().toString(), "Error while checking db");
}
if (checkDb != null) {
checkDb.close();
}
if (checkDb != null) {
return true;
}
return false;
}
private void copyDataBase() throws IOException {
InputStream externalDbStream = this.context.getAssets().open(DB_NAME);
OutputStream localDbStream = new FileOutputStream(DB_PATH + DB_NAME);
byte[] buffer = new byte[1024];
while (true) {
int bytesRead = externalDbStream.read(buffer);
if (bytesRead > 0) {
localDbStream.write(buffer, 0, bytesRead);
} else {
localDbStream.close();
externalDbStream.close();
return;
}
}
}
public SQLiteDatabase openDataBase() throws SQLException {
try {
String path = DB_PATH + DB_NAME;
if (this.database == null) {
/*File file =new File(path);
if(file.exists() && !file.isDirectory())
{
}else
{
Toast.makeText(context,"Could not open the database",Toast.LENGTH_SHORT).show();
}*/
createDataBase();
this.database = SQLiteDatabase.openDatabase(path, null, 0);
}
}catch(SQLException e){
e.printStackTrace();
}
return this.database;
}
public synchronized void close() {
if (this.database != null) {
this.database.close();
}
super.close();
}
public void onCreate(SQLiteDatabase db) {
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
} | [
"sagar.s.rao@gmail.com"
] | sagar.s.rao@gmail.com |
6f1dec5087ec7a6e222943aa40ebff573ad92bf3 | 3ba29d679db01cac8778ed4b8afa39d338c01348 | /aula02/ex2.java | 109abd0173a615e3001849569c231bc19a6be6eb | [] | no_license | ricardombrodriguez/POO-Practical-Classes | 6dfb2d2a60f67dcc8b7dc6f06d5cb2b97d0556bb | 98eae6c855dfccdb2110bb0fb94e96fe35e73ce2 | refs/heads/main | 2023-03-13T06:32:24.873273 | 2021-03-03T18:51:31 | 2021-03-03T18:51:31 | 344,229,103 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 339 | java | package aula02;
import java.util.Scanner;
public class ex2 {
public static void main(String[] args) {
double celsius, fahrenheit;
Scanner sc = new Scanner(System.in);
System.out.print("Celsius: ");
celsius = sc.nextDouble();
fahrenheit = 1.8 * celsius + 32;
sc.close();
System.out.print("Fahrenheit: " + fahrenheit);
}
}
| [
"ricardorodriguez@ua.pt"
] | ricardorodriguez@ua.pt |
0e4aaefb038cf23abc1616eef46d226a8d60d9b6 | 04f80ee8e3f2ab38ee2890e28f25352ce80a880b | /src/main/java/ss/bshop/service/SupplierOrderStructureService.java | 52fed669b70b0f557418e4eb18e3fc4bae89822b | [] | no_license | tokarevv/BeerShop | 343d2991e851ec7ae5ca4b8122877c18170f2f88 | 0b7cfc7f4ef222944c9365d30f9d0dbf99af6a56 | refs/heads/master | 2023-01-10T02:34:54.676494 | 2012-08-08T06:45:17 | 2012-08-08T06:45:17 | 5,106,843 | 0 | 0 | null | 2022-12-16T00:39:53 | 2012-07-19T07:36:07 | Java | UTF-8 | Java | false | false | 1,380 | java | package ss.bshop.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ss.bshop.dao.ISupOrderStructDAO;
import ss.bshop.domain.SupOrderStructure;
@Service
@Transactional(readOnly = true)
public class SupplierOrderStructureService implements ISupplierOrderStructureService{
@Autowired
private ISupOrderStructDAO supplierOrderStructureDAO;
public ISupOrderStructDAO getSupplierDAO() {
return supplierOrderStructureDAO;
}
public void setSupplierDAO(ISupOrderStructDAO supplierOrderStructureDAO) {
this.supplierOrderStructureDAO = supplierOrderStructureDAO;
}
@Transactional(readOnly = false)
@Override
public void add(SupOrderStructure orderStructure) {
supplierOrderStructureDAO.add(orderStructure);
}
@Override
public SupOrderStructure get(Long orgerId) {
return supplierOrderStructureDAO.get(orgerId);
}
@Override
public List<SupOrderStructure> getAll() {
return supplierOrderStructureDAO.getAll();
}
@Transactional(readOnly = false)
@Override
public void remove(Long id) {
supplierOrderStructureDAO.remove(id);
}
@Transactional(readOnly = false)
@Override
public void update(SupOrderStructure orderStructure) {
supplierOrderStructureDAO.update(orderStructure);
}
}
| [
"nick@ubuntu"
] | nick@ubuntu |
19ada69562757a69e6ca69238f0fdbecfb509f5a | d1ce45612d016be1382deac6f49162120ef51842 | /src/day32_LocalDate_WrapperClass/TimeFormat.java | 0a88f8ccc4dc797ceb1adc30f4017c1a13645854 | [] | no_license | Rosie-g/Java_Programming2020_B21 | 392ecd5b3bb92942cd065e9aa18dd7f8ccd6fd5a | 1f68cbd54be2236a0501cf41b74c49dfd10caf78 | refs/heads/master | 2023-02-24T05:31:14.308407 | 2021-02-03T21:57:15 | 2021-02-03T21:57:15 | 312,088,256 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,716 | java | package day32_LocalDate_WrapperClass;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
public class TimeFormat {
/*
LocalDate:
year: yyyy
month: MM (number), MMM (3 letters of month), MMMM(full name of month)
days: dd
name of Day: E( 3 letters), EEEE(full name of day)
LocalTime:
hours: hh
minutes: mm
seconds: ss
am/pm: a
*/
public static void main(String[] args) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("MMMM/dd/yy EEEE");
LocalDate today = LocalDate.now(); // 2020-11-23
System.out.println(today);
System.out.println(today.format(df));
DateTimeFormatter tf = DateTimeFormatter.ofPattern("hh:mm a");
LocalTime now = LocalTime.now();
System.out.println(now);
LocalTime t1 = LocalTime.of(23, 35, 55);
System.out.println(t1);
System.out.println(t1.format(tf));
// Monday, 12:40 pm Nov/23/2020
LocalDateTime dt1 = LocalDateTime.of(2020, 11, 23, 12, 40);
System.out.println(dt1);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("EEEE, hh:mm a MMM/dd/yyyy");
System.out.println(dt1.format(dtf));
// task:
LocalDate tomorrow = LocalDate.of(2020, 11, 24);
System.out.println(tomorrow.format(df));
boolean r1 = today.isBefore(tomorrow);// true
boolean r2 = today.isAfter(tomorrow);// false
System.out.println(r1);
System.out.println(r2);
// calculate the age:
int currentYear = LocalDate.now().getYear();
LocalDate DofB = LocalDate.of(2000, 5, 19);
int age = currentYear - DofB.getYear();
System.out.println(age);
System.out.println(DofB.plusDays(10));
LocalDate rightNow = LocalDate.now();
LocalDate holidayBreak = rightNow.plusDays(2);
System.out.println(holidayBreak);
LocalTime time = LocalTime.now();
LocalTime lunchBreak = time.plusMinutes(15);
System.out.println(lunchBreak.format(tf));
System.out.println("==================================");
LocalTime classStarts = LocalTime.of(10, 0);
LocalTime firstBreak = classStarts.plusMinutes(45);
System.out.println(firstBreak);
LocalTime secondBreak = firstBreak.plusHours(1);
System.out.println(secondBreak);
LocalTime thirdBreak=secondBreak.plusHours(1).plusMinutes(15);
System.out.println(thirdBreak);
LocalTime afternoonClass=thirdBreak.plusHours(1);
System.out.println(afternoonClass);
}
}
| [
"ruz0408@gmail.com"
] | ruz0408@gmail.com |
a0a462ea936003b44c48c6ac94f80e3e05c14b7d | 9304eb613773b8d3a5efdebbad40137d286ba68f | /cyb-mybatis-demo/src/main/java/com/cyb/mybatis/demo/controller/StudentController.java | 0fa0f6aa01a0260152f977e459b6ffa7dd487c79 | [] | no_license | hustcyb/cyb-mybatis-parent | 95f454f1e5e6c46e9ff9fbf5a9517b94f4be5cc2 | e5dad08f33dd6c3c88d093ac367dfff705d369f4 | refs/heads/master | 2020-05-27T20:31:34.979556 | 2020-05-20T13:01:12 | 2020-05-20T13:01:12 | 95,129,734 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,682 | java | package com.cyb.mybatis.demo.controller;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cyb.mybatis.demo.domain.Student;
import com.cyb.mybatis.demo.serivce.StudentService;
/**
* 学生控制器
*
* @author Administrator
*
*/
@RequestMapping("students")
@RestController
public class StudentController {
/**
* 学生数据仓库
*/
@Autowired
private StudentService studentService;
@GetMapping("{id:\\d+}")
public Student getById(@PathVariable Integer id) {
return studentService.getById(id);
}
@GetMapping("{ids:\\d+,[,\\d]*}")
public List<Student> listByIds(@PathVariable Collection<Integer> ids) {
return studentService.listByIds(ids);
}
@PostMapping
public Integer save(@RequestBody Student student) {
return studentService.save(student);
}
@PutMapping("{id}")
public void update(@PathVariable Integer id, @RequestBody Student student) {
Optional.of(student).ifPresent(stu -> stu.setId(id));
studentService.update(student);
}
@DeleteMapping("{id}")
public void deleteById(@PathVariable Integer id) {
studentService.deleteById(id);
}
}
| [
"hustcyb@gmail.com"
] | hustcyb@gmail.com |
37e5dda9e20e431fe8de9984dff9ea376e48b7ca | d55551fde61565e2d2b43d19b7e22d21dafc4d8f | /app/src/main/java/zapsolutions/zap/channelManagement/OpenChannelItem.java | 059c5c985060c836ebe4b5f8c1c702f389928289 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | decorumvelox/zap-android | 3eae41d9ff279b9c2e68c769418e722f845015b8 | 74c811f07394d929cf3618af6c1a4c7666d8694e | refs/heads/master | 2020-06-22T00:44:21.351199 | 2019-07-14T16:40:17 | 2019-07-14T16:40:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 416 | java | package zapsolutions.zap.channelManagement;
import com.github.lightningnetwork.lnd.lnrpc.Channel;
public class OpenChannelItem extends ChannelListItem {
private Channel mChannel;
public OpenChannelItem(Channel channel) {
mChannel = channel;
}
@Override
public int getType() {
return TYPE_OPEN_CHANNEL;
}
public Channel getChannel() {
return mChannel;
}
}
| [
"michael90@protonmail.com"
] | michael90@protonmail.com |
9f919c67250b00ee459e83e90588571689f9b20a | 24fc9f0292e7b736a91ca899f3205d645c24267e | /app/src/main/java/com/example/latihanfragment1/ui/profile/ProfileViewModel.java | 2ed694a34e4c3d883c7b31ffa4a9396270eb51b4 | [] | no_license | muhamadsyahrulramadhan/LatihanFragment1 | f2ac337810d7e25e10d795a624d0a0361dffd474 | 243a0063777d281d8e4399b2ce049e6487146982 | refs/heads/master | 2022-12-08T07:37:00.456626 | 2020-08-30T13:39:23 | 2020-08-30T13:39:23 | 291,477,473 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 464 | java | package com.example.latihanfragment1.ui.profile;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class ProfileViewModel extends ViewModel {
private MutableLiveData<String> mText;
public ProfileViewModel() {
mText = new MutableLiveData<>();
mText.setValue("This is profile fragment");
}
public LiveData<String> getText() {
return mText;
}
}
| [
"syahrulramadhan.siswa@smkn4bdg.sch.id"
] | syahrulramadhan.siswa@smkn4bdg.sch.id |
bc50d443439a10625035d51fde4cd118527a7512 | 51ac1a65ff41436a141c85c8580a5965f178235e | /src/CountEvenSum.java | 24a8d812f9cefac5a8246e843d1f2eeca25cdb17 | [] | no_license | munishk/ScratchPad | d28bf59e93e8b7bd6aa4f715a1e95a615b7c0c07 | ce02cfe0830e2d2cbbe44211619809714f24292e | refs/heads/master | 2020-12-05T22:43:13.528719 | 2020-01-07T07:25:55 | 2020-01-07T07:25:55 | 232,266,814 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 501 | java | public class CountEvenSum {
public static void main(String[] args) {
int[] a= {1,2,2,3,4,1};
System.out.println(countWithEvenSum(a));
}
private static int countWithEvenSum(int[] a) {
int temp[] = {1,0};
int sum = 0, result=0;
for(int i =0; i < a.length; i++) {
sum = (sum + i%2+2)%2;
temp[sum]++;
}
for(int i: temp) {
System.out.println(i);
}
result = result + (temp[0] * (temp[0]-1)/2);
result = result + (temp[1] * (temp[1]-1)/2);
return result;
}
}
| [
"manish.engg2001@gmail.com"
] | manish.engg2001@gmail.com |
ce78fb68cdc298a2994bdf89eed8e452d21f85d4 | 4aa47ab05770907c4f8a57be6b2a45ea3a14e45c | /deneme/src/deneme/deneme.java | 0785772faa2adc5f3fb1f5b8604977a73fd97d17 | [] | no_license | sylar31/sylar31 | a9468f1763b13768fc8f42923858fed4c03ecbca | 3a084d8f52b2ff35f0dfd4529090d0865a3bc6a9 | refs/heads/main | 2023-01-18T21:27:32.336000 | 2020-11-21T09:09:10 | 2020-11-21T09:10:45 | 314,772,472 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 135 | java | package deneme;
public class deneme {
public static void main(String[] args) {
System.out.println("Hello iste");
}
}
| [
"M. İBN-İ ARABİ@DESKTOP-9J831IR"
] | M. İBN-İ ARABİ@DESKTOP-9J831IR |
ba4b910deda86c2e6eda78e479d20f271a958039 | 0981333953bdbf488421f094bd584efd0c789902 | /SillyChildClient/app/src/main/java/com/sillykid/app/mine/myorder/goodorder/GoodOrderContract.java | 3fb1bb33caec602b2b9929d0969d4f90e7a250c7 | [
"Apache-2.0"
] | permissive | 921668753/SillyChildClient2-Android | ff7f0d9a97be64e610ecad304903bc853cbb3db0 | f8f8ea3cca9013d39c9d7164bd2bd9573528093d | refs/heads/master | 2020-03-23T09:18:15.433017 | 2018-12-04T13:46:33 | 2018-12-04T13:46:33 | 141,379,323 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 836 | java | package com.sillykid.app.mine.myorder.goodorder;
import android.content.Context;
import com.common.cklibrary.common.BasePresenter;
import com.common.cklibrary.common.BaseView;
/**
* Created by ruitu on 2016/9/24.
*/
public interface GoodOrderContract {
interface Presenter extends BasePresenter {
/**
* 获取订单信息
*/
void getOrderList(Context context, String status, int page);
/**
* 取消订单
*/
void postOrderCancel(Context context, int orderid);
/**
* 提醒发货
*/
void postOrderRemind(Context context, int orderid);
/**
* 确认收货
*/
void postOrderConfirm(Context context, int orderid);
}
interface View extends BaseView<Presenter, String> {
}
}
| [
"921668753@qq.com"
] | 921668753@qq.com |
b110ee213b474bdde4988a54b5cec814b5fa4a95 | 32d70784dedff6e1738d3a498c315a1b6fefde82 | /java8demo/src/main/java/com/art2cat/dev/Insurance.java | 7eaf8dcaa70e2b879b7cf475cd60912410688a16 | [] | no_license | UncleTian/JavaDemo | 125fb9ad6709ddfe55c00de97a4bdcf8a77402c7 | 1cfb26e6b5c5df8ddb90a24f628b49d6987ffdfa | refs/heads/master | 2020-03-24T17:19:56.713230 | 2018-07-18T09:54:47 | 2018-07-18T09:54:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 321 | java | package com.art2cat.dev;
public class Insurance {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return this.name + this.hashCode();
}
}
| [
"yiming.whz@gmail.com"
] | yiming.whz@gmail.com |
f9a2aacf99eac57aa8512cf5ca2eb7e90e5baf0d | 91a4af5ccf8030e7e1536a46632cf8a85e32cc8f | /src/main/java/com/aztec/student/repository/StudentRepository.java | 4aefb56a0039a719c091f96dd7353fc5c1b5c8a9 | [] | no_license | Aztec1234/Rest-api-using-jwt-and-jpa | 595c46d2d1e3870626a754547cf0e9ac3660da4e | f017801fec32c8338694606ce8149140b5972ebd | refs/heads/main | 2023-04-04T23:44:49.167026 | 2021-03-30T03:30:55 | 2021-03-30T03:30:55 | 352,857,419 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 683 | java | package com.aztec.student.repository;
import com.aztec.student.domain.Student;
import com.aztec.student.domain.StudentDto;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Repository
public interface StudentRepository extends JpaRepository<Student, Long> {
@Query("SELECT new com.aztec.student.domain.StudentDto(s.firstName,s.middleName,s.lastName,s.dateOfBirth,s.gender) from Student s")
public List<StudentDto> findStudents();
public Optional<Student> findByCitizenshipNo(String citizenshipNo);
} | [
"ayushguidel1234@gmail.com"
] | ayushguidel1234@gmail.com |
be93a8d7afa7b487574825a08305757fd0efaf5c | 5a027c7a6d9afc1bbc8b2bc86e43e96b80dd9fa8 | /workspace_movistar_wl11/zejbVpiStbBa/ejbModule/co/com/telefonica/atiempo/vpistbba/serviciosba/ejb/sb/ConfiguracionTerraBABean.java | 840d2ba93c244ea2acd7c4c370d2cb6bed228710 | [] | no_license | alexcamp/ArrobaTiempoGradle | 00135dc6f101e99026a377adc0d3b690cb5f2bd7 | fc4a845573232e332c5f1211b72216ce227c3f38 | refs/heads/master | 2020-12-31T00:18:57.337668 | 2016-05-27T15:02:04 | 2016-05-27T15:02:04 | 59,520,455 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 588 | java | package co.com.telefonica.atiempo.vpistbba.serviciosba.ejb.sb;
import co.com.telefonica.atiempo.intf.IServicio;
import co.com.telefonica.atiempo.vpistbba.serviciosba.ConfiguracionTerraBAServicio;
/**
* Bean implementation class for Enterprise Bean: ConfiguracionTerraBA
*/
public class ConfiguracionTerraBABean
extends co.com.telefonica.atiempo.utiles.MDServicioBean{
/* (non-Javadoc)
* @see co.com.telefonica.atiempo.utiles.MDServicioBean#getServicio()
*/
public IServicio getServicio() {
// TODO Auto-generated method stub
return new ConfiguracionTerraBAServicio();
}
}
| [
"alexander5075@hotmail.com"
] | alexander5075@hotmail.com |
432c0ab5a5bc9d09151fb47713b1cd637eb08e40 | d7eeefe0d25024f46c3472f44be4ed2d1cef650b | /ProjectEpam/Hotel/src/ua/epam/resource/Resourses_en_us.java | 0f5f75048c9a4315d5067b10edd79e48db077ec1 | [] | no_license | lomakoartem/JavaPool2015 | f33f8cd86dcc998dffa0e36456ac12a51fea5606 | 2cba72d2b89c79cad3242f58c987116dba97969b | refs/heads/master | 2021-01-17T17:29:03.505368 | 2016-08-09T18:26:04 | 2016-08-09T18:26:04 | 65,316,153 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,067 | java | package ua.epam.resource;
import java.util.ListResourceBundle;
/**
* Created by lomak on 19.01.2016.
*/
public class Resourses_en_us extends ListResourceBundle {
@Override
public Object[][] getContents() {
return contents;
}
static final Object[][] contents = {
{ "billtag.label.order", " order " },
{ "billtag.label.days", " days "},
{ "billtag.label.price", " price "},
{ "billtag.label.sum", " sum "},
{ "billtag.label.bill", " Bill "},
{ "order.from", " from "} ,
{ "order.to", " to "} ,
{ "order.places", " places "},
{ "order.roomClass", " room class "},
{"user.label.accepted", " Your order accepted "},
{"user.label.incorrectData"," Incorrect data input "}
};
} | [
"Artem_Lomako@epam.com"
] | Artem_Lomako@epam.com |
50d584eafae95a1900cb80ec019ca94df2e1a76f | 9558f5d60d1ae2b4b0684cea95d36d7bd694ba34 | /src/application/GoogleAuthHelper.java | 5f413b4ac5153db4e802755d639050c60a1ab28e | [] | no_license | alifradityar/KomodoMailClient | 8907caa5a4c84fc10e52b4c049be12cf008e5026 | 0c8a36303eed90063908cafffa4e9efae919b0e5 | refs/heads/master | 2021-01-23T02:28:50.785884 | 2015-04-20T01:16:48 | 2015-04-20T01:16:48 | 34,231,101 | 0 | 3 | null | null | null | null | UTF-8 | Java | false | false | 21,823 | java | package application;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.auth.oauth2.TokenResponse;
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64;
import com.google.api.client.util.store.FileDataStoreFactory;
import java.io.IOException;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Collection;
import com.google.api.services.gmail.Gmail;
import com.google.api.services.gmail.model.Label;
import com.google.api.services.gmail.model.ListLabelsResponse;
import com.google.api.services.gmail.model.ListMessagesResponse;
import com.google.api.services.gmail.model.Message;
import com.google.api.services.gmail.model.MessagePartHeader;
import com.google.api.services.gmail.model.ModifyMessageRequest;
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Part;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.HttpServletRequest;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
/**
* A helper class for Google's Gmail API.
*
*/
public final class GoogleAuthHelper {
/**
* Directory to store user credentials.
*/
private static final File DATA_STORE_DIR = new File(
System.getProperty("user.home"), "credentials");
/**
* Global instance of the
* {@link com.google.api.client.util.store.DataStoreFactory}. The best
* practice is to make it a single globally shared instance across your
* application.
*/
private static FileDataStoreFactory data_store_factory;
/**
* Please provide a value for the CLIENT_ID constant before proceeding, set
* this up at https://code.google.com/apis/console/
*/
private static final String CLIENT_ID = "{Client Id from Google Consle}";
/**
* Please provide a value for the CLIENT_SECRET constant before proceeding,
* set this up at https://code.google.com/apis/console/
*/
private static final String CLIENT_SECRET = "{Client secret from Google Consle}";
/**
* Callback URI that google will redirect to after successful authentication
*/
private static final String CALLBACK_URI = "{Callback URL to receive the access token.}";
// start google authentication constants
private static final Collection<String> SCOPE = Arrays
.asList("https://www.googleapis.com/auth/userinfo.profile;https://www.googleapis.com/auth/userinfo.email;https://www.googleapis.com/auth/gmail.modify"
.split(";"));
private static final String USER_INFO_URL = "https://www.googleapis.com/oauth2/v1/userinfo";
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
// end google authentication constants
private String stateToken;
private GoogleAuthorizationCodeFlow flow;
private Credential credential;
private Gmail service;
public GoogleAuthHelper(Credential credential,Gmail service){
this.credential = credential;
this.service = service;
}
/**
* Constructor initializes the Google Authorization Code Flow with CLIENT
* ID, SECRET, and SCOPE
*/
public GoogleAuthHelper(String userId) {
try {
data_store_factory = new FileDataStoreFactory(DATA_STORE_DIR);
flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT,
JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, SCOPE)
// .setApprovalPrompt("force")
.setDataStoreFactory(data_store_factory)
.setApprovalPrompt("force").setAccessType("offline")
.build();
credential = flow.loadCredential(userId);
System.out.println("cred=" + credential);
} catch (IOException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
}
generateStateToken();
}
public boolean isCredentialAvailable(String userName) {
Credential credential = null;
try {
credential = flow.loadCredential(userName);
} catch (IOException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
}
if (credential == null) {
return false;
} else {
return true;
}
}
/**
* Builds a login URL based on client ID, secret, callback URI, and scope
*/
public String buildLoginUrl() {
final GoogleAuthorizationCodeRequestUrl url = flow
.newAuthorizationUrl();
return url.setRedirectUri(CALLBACK_URI).setState(stateToken).build();
// return url.setState(stateToken).build();
}
/**
* Generates a secure state token
*/
private void generateStateToken() {
SecureRandom sr1 = new SecureRandom();
stateToken = "google;" + sr1.nextInt();
}
/**
* Accessor for state token
*/
public String getStateToken() {
return stateToken;
}
/**
* Expects an Authentication Code, and makes an authenticated request for
* the user's profile information
*
* @return JSON formatted user profile information
* @param authCode
* authentication code provided by google
*/
public String getUserInfoJson(final String authCode, final String userName)
throws IOException {
final GoogleTokenResponse response = flow.newTokenRequest(authCode)
.setRedirectUri(CALLBACK_URI).execute();
System.out.println("resp=" + response);
Credential credential = flow.createAndStoreCredential(response,
userName);
final HttpRequestFactory requestFactory = HTTP_TRANSPORT
.createRequestFactory(credential);
// Make an authenticated request
final GenericUrl url = new GenericUrl(USER_INFO_URL);
final HttpRequest request = requestFactory.buildGetRequest(url);
request.getHeaders().setContentType("application/json");
final String jsonIdentity = request.execute().parseAsString();
return jsonIdentity;
}
public void getCredential(String authCode) {
try {
GoogleTokenResponse response = flow.newTokenRequest(authCode)
.setRedirectUri(CALLBACK_URI).execute();
System.out.println("refresh token:" + response.getRefreshToken());
// credential = flow.createAndStoreCredential(response, null);
Credential credential = createCredentialWithRefreshToken(
HTTP_TRANSPORT, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET,
response);
} catch (IOException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
}
}
public static GoogleCredential createCredentialWithRefreshToken(
HttpTransport transport, JsonFactory jsonFactory, String clientId,
String clientSecret, TokenResponse tokenResponse) {
return new GoogleCredential.Builder().setTransport(transport)
.setJsonFactory(jsonFactory)
.setClientSecrets(clientId, clientSecret).build()
.setFromTokenResponse(tokenResponse);
}
public String getUserEmails() throws IOException {
service = new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY,
credential).setApplicationName("Gmail Quickstart").build();
JSONObject ticketDetails = new JSONObject();
ListMessagesResponse openMessages = service.users().messages()
.list("me")
// .setLabelIds(labelIds)
.setQ("is:unread label:inbox").setMaxResults(new Long(3))
.execute();
ticketDetails.put("open", "" + openMessages.getResultSizeEstimate());
ListMessagesResponse closedMessages = service.users().messages()
.list("me")
// .setLabelIds(labelIds)
.setQ("label:inbox label:closed").setMaxResults(new Long(1))
.execute();
ticketDetails
.put("closed", "" + closedMessages.getResultSizeEstimate());
ListMessagesResponse pendingMessages = service.users().messages()
.list("me")
// .setLabelIds(labelIds)
.setQ("label:inbox label:pending").setMaxResults(new Long(1))
.execute();
ticketDetails.put("pending",
"" + pendingMessages.getResultSizeEstimate());
ticketDetails.put("unassigned", "0");
List<Message> messages = openMessages.getMessages();
// List<Map> openTickets=new ArrayList<Map>();
JSONArray openTickets = new JSONArray();
String returnVal = "";
// Print ID and snippet of each Thread.
if (messages != null) {
for (Message message : messages) {
openTickets.add(new JSONObject(
getBareGmailMessageDetails(message.getId())));
}
ticketDetails.put("openTicketDetails", openTickets);
}
return ticketDetails.toJSONString();
}
public String getUserEmails(String label) throws IOException {
service = new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY,
credential).setApplicationName("Gmail Quickstart").build();
JSONObject ticketDetails = new JSONObject();
ListMessagesResponse labelMessages = service.users().messages()
.list("me")
// .setLabelIds(labelIds)
.setQ("label:inbox label:" + label).setMaxResults(new Long(3))
.execute();
List<Message> messages = labelMessages.getMessages();
JSONArray labelTickets = new JSONArray();
String returnVal = "";
if (messages != null) {
for (Message message : messages) {
labelTickets.add(new JSONObject(
getBareGmailMessageDetails(message.getId())));
}
ticketDetails.put("labelTicketDetails", labelTickets);
}
return ticketDetails.toJSONString();
}
public String setMessageLabel(String messageId, String labelName) {
try {
service = new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY,
credential).setApplicationName("Gmail Quickstart").build();
// For now assuming that when a label is set, we make it read also.
List<String> labelsToRemove = new ArrayList();
labelsToRemove.add("UNREAD");
List<String> labelsToAdd = new ArrayList();
if (labelName != null) {
// this can be optimized by get all label names once they login
ListLabelsResponse response = service.users().labels()
.list("me").execute();
List<Label> labels = response.getLabels();
boolean labelExists = false;
for (Label label : labels) {
// System.out.println(label.toPrettyString());
if (label.getName().equalsIgnoreCase(labelName)) {
labelsToAdd.add(label.getId());
System.out.println("Adding label:" + labelName);
labelExists = true;
break;
}
}
if (!labelExists) {
Label label = new Label().setName(labelName)
.setLabelListVisibility("labelShow")
.setMessageListVisibility("show");
label = service.users().labels().create("me", label)
.execute();
labelsToAdd.add(label.getId());
}
}
ModifyMessageRequest mods;
mods = new ModifyMessageRequest().setRemoveLabelIds(labelsToRemove)
.setAddLabelIds(labelsToAdd);
Message message = service.users().messages()
.modify("me", messageId, mods).execute();
return "success";
} catch (IOException ioe) {
System.out.println("ioerror");
// ioe.printStackTrace();
return "error";
}
}
public String trashMessage(String messageId) {
String msg = "";
try {
service = new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY,
credential).setApplicationName("Gmail Quickstart").build();
service.users().messages().trash("me", messageId).execute();
return "success";
} catch (IOException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
return "error";
}
}
public String getMessage(String messageId) {
// helper function to get message details in JSON format
return new JSONObject(getMessageDetails(messageId)).toJSONString();
}
public Map getMessageDetails(String messageId) {
Map<String, Object> messageDetails = new HashMap<String, Object>();
try {
service = new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY,
credential).setApplicationName("Gmail Quickstart").build();
Message message = service.users().messages().get("me", messageId)
.setFormat("raw").execute();
byte[] emailBytes = Base64.decodeBase64(message.getRaw());
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage email = new MimeMessage(session,
new ByteArrayInputStream(emailBytes));
messageDetails.put("subject", email.getSubject());
messageDetails.put("from", email.getSender() != null ? email
.getSender().toString() : "None");
messageDetails.put("time", email.getSentDate() != null ? email
.getSentDate().toString() : "None");
messageDetails.put("snippet", message.getSnippet());
messageDetails.put("threadId", message.getThreadId());
messageDetails.put("id", message.getId());
messageDetails.put("body", getText(email));
} catch (MessagingException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
}
return messageDetails;
}
public Map getBareMessageDetails(String messageId) {
Map<String, Object> messageDetails = new HashMap<String, Object>();
try {
service = new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY,
credential).setApplicationName("Gmail Quickstart").build();
Message message = service.users().messages().get("me", messageId)
.setFormat("raw").execute();
byte[] emailBytes = Base64.decodeBase64(message.getRaw());
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage email = new MimeMessage(session,
new ByteArrayInputStream(emailBytes));
messageDetails.put("subject", email.getSubject());
messageDetails.put("from", email.getSender() != null ? email
.getSender().toString() : "None");
messageDetails.put("time", email.getSentDate() != null ? email
.getSentDate().toString() : "None");
messageDetails.put("snippet", message.getSnippet());
messageDetails.put("threadId", message.getThreadId());
messageDetails.put("id", message.getId());
messageDetails.put("body", getText(email));
} catch (MessagingException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
}
return messageDetails;
}
public Map getBareGmailMessageDetails(String messageId) {
Map<String, Object> messageDetails = new HashMap<String, Object>();
try {
service = new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY,
credential).setApplicationName("Gmail Quickstart").build();
Message message = service.users().messages().get("me", messageId)
.setFormat("full")
.setFields("id,payload,sizeEstimate,snippet,threadId")
.execute();
List<MessagePartHeader> headers = message.getPayload().getHeaders();
for (MessagePartHeader header : headers) {
if (header.getName().equals("From")
|| header.getName().equals("Date")
|| header.getName().equals("Subject")
|| header.getName().equals("To")
|| header.getName().equals("CC")) {
messageDetails.put(header.getName().toLowerCase(),
header.getValue());
}
}
messageDetails.put("snippet", message.getSnippet());
messageDetails.put("threadId", message.getThreadId());
messageDetails.put("id", message.getId());
// messageDetails.put("body",message.getPayload().getBody().getData());
} catch (IOException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
}
return messageDetails;
}
private boolean textIsHtml = false;
/**
* Return the primary text content of the message.
*/
private String getText(Part p) throws MessagingException, IOException {
if (p.isMimeType("text/*")) {
String s = (String) p.getContent();
textIsHtml = p.isMimeType("text/html");
return s;
}
if (p.isMimeType("multipart/alternative")) {
// prefer html text over plain text
Multipart mp = (Multipart) p.getContent();
String text = null;
for (int i = 0; i < mp.getCount(); i++) {
Part bp = mp.getBodyPart(i);
if (bp.isMimeType("text/plain")) {
if (text == null) {
text = getText(bp);
}
continue;
} else if (bp.isMimeType("text/html")) {
String s = getText(bp);
if (s != null) {
return s;
}
} else {
return getText(bp);
}
}
return text;
} else if (p.isMimeType("multipart/*")) {
Multipart mp = (Multipart) p.getContent();
for (int i = 0; i < mp.getCount(); i++) {
String s = getText(mp.getBodyPart(i));
if (s != null) {
return s;
}
}
}
return null;
}
public String getMessageThread(String threadId) {
String returnVal = "";
JSONObject threadDetails = new JSONObject();
try {
service = new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY,
credential).setApplicationName("Gmail Quickstart").build();
com.google.api.services.gmail.model.Thread thread = service.users()
.threads().get("me", threadId).execute();
System.out.println("Thread id: " + thread.getId());
System.out.println("No. of messages in this thread: "
+ thread.getMessages().size());
List<Message> messages = thread.getMessages();
if (messages != null) {
for (Message message : messages) {
Message msg1 = service.users().messages()
.get("me", message.getId()).execute();
// returnVal = returnVal + getMessage(message.getId());
returnVal = returnVal
+ getMessageDetails(message.getId()).get("body");
}
System.out.println(thread.toPrettyString());
}
threadDetails.put("message", returnVal);
return threadDetails.toJSONString();
} catch (IOException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
return "error";
}
}
/**
* Send an email from the user's mailbox to its recipient.
*
* @param service
* Authorized Gmail API instance.
* @param userId
* User's email address. The special value "me" can be used to
* indicate the authenticated user.
* @param email
* Email to be sent.
* @throws MessagingException
* @throws IOException
*/
public String sendMessage(String to, String from, String subject,
String body) throws MessagingException, IOException {
service = new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY,
credential).setApplicationName("Gmail Quickstart").build();
MimeMessage email = createMimeMessage(to, from, subject, body);
Message message = createMessageWithEmail(email);
message = service.users().messages().send("me", message).execute();
System.out.println("Message id: " + message.getId());
System.out.println(message.toPrettyString());
if (message.getId() != null) {
return "success";
} else {
return "fail";
}
}
/**
* Create a Message from an email
*
* @param email
* Email to be set to raw of message
* @return Message containing base64 encoded email.
* @throws IOException
* @throws MessagingException
*/
private Message createMessageWithEmail(MimeMessage email)
throws MessagingException, IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
email.writeTo(baos);
String encodedEmail = Base64.encodeBase64URLSafeString(baos
.toByteArray());
Message message = new Message();
message.setRaw(encodedEmail);
return message;
}
public String getBody(HttpServletRequest request) throws IOException {
String body = null;
StringBuilder stringBuilder = new StringBuilder();
BufferedReader bufferedReader = null;
try {
InputStream inputStream = request.getInputStream();
if (inputStream != null) {
bufferedReader = new BufferedReader(new InputStreamReader(
inputStream));
char[] charBuffer = new char[128];
int bytesRead = -1;
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
stringBuilder.append(charBuffer, 0, bytesRead);
}
} else {
stringBuilder.append("");
}
} catch (IOException ex) {
throw ex;
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException ex) {
throw ex;
}
}
}
body = stringBuilder.toString();
return body;
}
private MimeMessage createMimeMessage(String to, String from,
String subject, String body) {
try {
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
// Set From: header field of the header.
message.setFrom(new InternetAddress(from));
// Set To: header field of the header.
message.addRecipient(javax.mail.Message.RecipientType.TO,
new InternetAddress(to));
// Set Subject: header field
message.setSubject(subject);
// Send the actual HTML message, as big as you like
message.setContent(body, "text/html");
return message;
} catch (MessagingException ex) {
Logger.getLogger(GoogleAuthHelper.class.getName()).log(
Level.SEVERE, null, ex);
return null;
}
}
}
| [
"alifradityar@gmail.com"
] | alifradityar@gmail.com |
380530284dc52a8b544f987ce6a70f3419f68467 | 73e508007bbe6755cdbb7c7d694fb86698b28fe1 | /module2/src/main/java/com/pfl/module2/ui/fragment/Module2Fragment.java | 792acf7f060371fceaecda02baf9c97e5756d745 | [] | no_license | philo-dragon/topzuqiu-kotlin | 6f86c7d8b0db44764de0dc5dd0f6a75b056723bf | 077c74af2f24c273ff93edab45da0cb3e09cfcd5 | refs/heads/master | 2021-05-02T02:09:19.586719 | 2018-03-22T01:41:05 | 2018-03-22T01:41:05 | 120,880,854 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,873 | java | package com.pfl.module2.ui.fragment;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.pfl.common.base.BaseFragment;
import com.pfl.common.di.AppComponent;
import com.pfl.common.utils.RouteUtils;
import com.pfl.common.utils.StatusBarUtil;
import com.pfl.component.R;
import com.pfl.module2.di.module2.DaggerModule2Component;
import com.pfl.module2.di.module2.Module2Module;
import com.pfl.module2.mvp.module2.Module2Persenter;
import com.pfl.module2.mvp.module2.Module2View;
import javax.inject.Inject;
/**
* A simple {@link Fragment} subclass.
*/
@Route(path = RouteUtils.MODULE2_FRAGMENT)
public class Module2Fragment extends BaseFragment implements Module2View {
private TextView textView;
@Inject
Module2Persenter persenter;
private void requestData() {
persenter.requestData();
}
@Override
public void componentInject(AppComponent appComponent) {
DaggerModule2Component.builder()
.appComponent(appComponent)
.module2Module(new Module2Module(this, this))
.build()
.inject(this);
}
@Override
public int getContextView() {
return R.layout.fragment_module2;
}
@Override
public void initView(View view) {
textView = view.findViewById(R.id.textView);
}
@Override
public void initData() {
requestData();
}
@Override
public void initEvent() {
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
StatusBarUtil.darkMode(mContext, false);
}
});
}
@Override
public void onSuccess(String token) {
textView.setText(token);
}
}
| [
"panfeilong2012@163.com"
] | panfeilong2012@163.com |
e65590496a62e5417f67fd0f447c20a986657e74 | bc1aa4db32f1b79b576970ef588ac004465c581b | /src/test/java/com/codurance/year/YearShould.java | 210f7098cbd14651a1065e5a610e5c7516d3a333 | [] | no_license | sandromancuso/leap_year | 169787b0de2bdbf4264f2702e75824e9c23e2745 | 656840bfe466774bf5a43a27371252d40ede7e21 | refs/heads/master | 2021-01-10T20:36:46.066114 | 2014-04-09T23:04:40 | 2014-04-09T23:04:40 | 18,613,010 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 693 | java | package com.codurance.year;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public class YearShould {
@Test public void
not_be_a_leap_year_if_not_divisible_by_4() {
assertThat(leapYear(1997), is(false));
}
@Test public void
be_a_leap_year_if_divisible_by_4() {
assertThat(leapYear(1996), is(true));
}
@Test public void
be_a_leap_year_if_divisible_by_400() {
assertThat(leapYear(1600), is(true));
}
@Test public void
not_be_a_leap_year_if_divisible_by_100_but_not_by_400() {
assertThat(leapYear(1800), is(false));
}
private boolean leapYear(int year) {
return new Year(year).leapYear();
}
}
| [
"sandromancuso@yahoo.com"
] | sandromancuso@yahoo.com |
7277ee312c46ce0b67dc820b64dd7e5b6f71b234 | a1a95944fd4f31d0eab1e72ef8642d0b115a5353 | /bitCamp - workspace/workspace/Week11Classes/src/ba/bitcamp/day1/EchoServer.java | af0934c440ecc369179ef20453cb8466ed30e21d | [] | no_license | bc-boristomic/JavaProjects | 4d293e08e7c0cbc91df681cb79c01579e31ebb8b | b07353fa7d46639ecbcdab35a4ac2949be27e757 | refs/heads/master | 2021-05-28T21:15:50.648539 | 2015-11-03T12:09:08 | 2015-11-03T12:09:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,237 | java | package ba.bitcamp.day1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class EchoServer {
public static final int ECHO_PORT = 12345;
public static void main(String[] args) {
ServerSocket server = null;
try {
server = new ServerSocket(ECHO_PORT);
while (true) {
System.out.println("Waiting for next request");
Socket clientSocket = server.accept();
System.out.println("Req accepted, waiting for response");
InputStream is = clientSocket.getInputStream();
OutputStream os = clientSocket.getOutputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
//br.readLine();
OutputStreamWriter writer = new OutputStreamWriter(os);
writer.write("OK");
writer.write(br.readLine());
writer.flush();
System.out.println("Resp flushed, closing conn.");
//os.close();
clientSocket.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
server.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
| [
"boris.tomic@bitcamp.ba"
] | boris.tomic@bitcamp.ba |
159fe60e6dea2009297539136e5eef2517badf25 | ad83524188bf2a14214b76e192642d8fd3c89a14 | /TugasSederhana/src/daos/AccountDao.java | df4d1d9e90899851425c24b1976fe34bb12dc4bf | [] | no_license | MarMarWijaya/KapitaSelekta | a06dd56d265282486ad546301c68579b084d0854 | 56338ede472105a208795508d8817af6457dfabb | refs/heads/master | 2022-12-24T23:55:01.256988 | 2020-10-06T04:13:35 | 2020-10-06T04:13:35 | 299,471,345 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 897 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package daos;
import java.sql.ResultSet;
import models.Account;
/**
*
* @author Ardian
*/
public interface AccountDao {
/**
* Melakukan pengambilan saldo terbaru dari Active User
*
* @param account -> AccountModel
* @param userDao -> DAO
* @return -> ResultSet
*/
ResultSet getCurrentBalance(Account account, UserDao userDao);
ResultSet getCurrentBalanceDest(String destination);
ResultSet getUserId(Account account);
ResultSet getUserIdDest(String destination, Account account);
void updateBalance(String query, int value1, int value2, Account account);
void updateBalanceReceiver(String query, int value1, int value2, String destination);
}
| [
"mariowijaya31@gmail.com"
] | mariowijaya31@gmail.com |
94eb00737385d9dffbd82d5cfbe8ffac976e3346 | e1e5bd6b116e71a60040ec1e1642289217d527b0 | /H5/L2jReunion/L2jReunion_2014_07_14/L2J_ReunionProject_Core/java/l2r/gameserver/datatables/sql/TeleportLocationTable.java | 3057cb9e021f9a73a9b9198eed55d4d46ecd5c69 | [] | no_license | serk123/L2jOpenSource | 6d6e1988a421763a9467bba0e4ac1fe3796b34b3 | 603e784e5f58f7fd07b01f6282218e8492f7090b | refs/heads/master | 2023-03-18T01:51:23.867273 | 2020-04-23T10:44:41 | 2020-04-23T10:44:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,014 | java | /*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package l2r.gameserver.datatables.sql;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import l2r.Config;
import l2r.L2DatabaseFactory;
import l2r.gameserver.model.L2TeleportLocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class ...
* @version $Revision: 1.3.2.2.2.3 $ $Date: 2005/03/27 15:29:18 $
*/
public class TeleportLocationTable
{
private static Logger _log = LoggerFactory.getLogger(TeleportLocationTable.class);
private final Map<Integer, L2TeleportLocation> _teleports = new HashMap<>();
protected TeleportLocationTable()
{
reloadAll();
}
public void reloadAll()
{
_teleports.clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT id, loc_x, loc_y, loc_z, price, fornoble, itemId FROM teleport"))
{
L2TeleportLocation teleport;
while (rs.next())
{
teleport = new L2TeleportLocation();
teleport.setTeleId(rs.getInt("id"));
teleport.setX(rs.getInt("loc_x"));
teleport.setY(rs.getInt("loc_y"));
teleport.setZ(rs.getInt("loc_z"));
teleport.setPrice(rs.getInt("price"));
teleport.setIsForNoble(rs.getInt("fornoble") == 1);
teleport.setItemId(rs.getInt("itemId"));
_teleports.put(teleport.getTeleId(), teleport);
}
_log.info(getClass().getSimpleName() + ": Loaded " + _teleports.size() + " Teleport Location Templates.");
}
catch (Exception e)
{
_log.error(getClass().getSimpleName() + ": Error loading Teleport Table.", e);
}
if (Config.CUSTOM_TELEPORT_TABLE)
{
int _cTeleCount = _teleports.size();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT id, loc_x, loc_y, loc_z, price, fornoble, itemId FROM custom_teleport"))
{
L2TeleportLocation teleport;
while (rs.next())
{
teleport = new L2TeleportLocation();
teleport.setTeleId(rs.getInt("id"));
teleport.setX(rs.getInt("loc_x"));
teleport.setY(rs.getInt("loc_y"));
teleport.setZ(rs.getInt("loc_z"));
teleport.setPrice(rs.getInt("price"));
teleport.setIsForNoble(rs.getInt("fornoble") == 1);
teleport.setItemId(rs.getInt("itemId"));
_teleports.put(teleport.getTeleId(), teleport);
}
_cTeleCount = _teleports.size() - _cTeleCount;
if (_cTeleCount > 0)
{
_log.info(getClass().getSimpleName() + ": Loaded " + _cTeleCount + " Custom Teleport Location Templates.");
}
}
catch (Exception e)
{
_log.warn(getClass().getSimpleName() + ": Error while creating custom teleport table " + e.getMessage(), e);
}
}
}
/**
* @param id
* @return
*/
public L2TeleportLocation getTemplate(int id)
{
return _teleports.get(id);
}
public static TeleportLocationTable getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final TeleportLocationTable _instance = new TeleportLocationTable();
}
}
| [
"64197706+L2jOpenSource@users.noreply.github.com"
] | 64197706+L2jOpenSource@users.noreply.github.com |
89486168af6d56d0232ad9d232539d44415d51b9 | 498dd2daff74247c83a698135e4fe728de93585a | /clients/google-api-services-videointelligence/v1p2beta1/1.26.0/com/google/api/services/videointelligence/v1p2beta1/model/GoogleCloudVideointelligenceV1p3beta1Entity.java | fc7a1e6845c67667848784e4d849e29d9c838db2 | [
"Apache-2.0"
] | permissive | googleapis/google-api-java-client-services | 0e2d474988d9b692c2404d444c248ea57b1f453d | eb359dd2ad555431c5bc7deaeafca11af08eee43 | refs/heads/main | 2023-08-23T00:17:30.601626 | 2023-08-20T02:16:12 | 2023-08-20T02:16:12 | 147,399,159 | 545 | 390 | Apache-2.0 | 2023-09-14T02:14:14 | 2018-09-04T19:11:33 | null | UTF-8 | Java | false | false | 3,905 | java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.videointelligence.v1p2beta1.model;
/**
* Detected entity from video analysis.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Cloud Video Intelligence API. For a detailed
* explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class GoogleCloudVideointelligenceV1p3beta1Entity extends com.google.api.client.json.GenericJson {
/**
* Textual description, e.g. `Fixed-gear bicycle`.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String description;
/**
* Opaque entity ID. Some IDs may be available in [Google Knowledge Graph Search
* API](https://developers.google.com/knowledge-graph/).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String entityId;
/**
* Language code for `description` in BCP-47 format.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String languageCode;
/**
* Textual description, e.g. `Fixed-gear bicycle`.
* @return value or {@code null} for none
*/
public java.lang.String getDescription() {
return description;
}
/**
* Textual description, e.g. `Fixed-gear bicycle`.
* @param description description or {@code null} for none
*/
public GoogleCloudVideointelligenceV1p3beta1Entity setDescription(java.lang.String description) {
this.description = description;
return this;
}
/**
* Opaque entity ID. Some IDs may be available in [Google Knowledge Graph Search
* API](https://developers.google.com/knowledge-graph/).
* @return value or {@code null} for none
*/
public java.lang.String getEntityId() {
return entityId;
}
/**
* Opaque entity ID. Some IDs may be available in [Google Knowledge Graph Search
* API](https://developers.google.com/knowledge-graph/).
* @param entityId entityId or {@code null} for none
*/
public GoogleCloudVideointelligenceV1p3beta1Entity setEntityId(java.lang.String entityId) {
this.entityId = entityId;
return this;
}
/**
* Language code for `description` in BCP-47 format.
* @return value or {@code null} for none
*/
public java.lang.String getLanguageCode() {
return languageCode;
}
/**
* Language code for `description` in BCP-47 format.
* @param languageCode languageCode or {@code null} for none
*/
public GoogleCloudVideointelligenceV1p3beta1Entity setLanguageCode(java.lang.String languageCode) {
this.languageCode = languageCode;
return this;
}
@Override
public GoogleCloudVideointelligenceV1p3beta1Entity set(String fieldName, Object value) {
return (GoogleCloudVideointelligenceV1p3beta1Entity) super.set(fieldName, value);
}
@Override
public GoogleCloudVideointelligenceV1p3beta1Entity clone() {
return (GoogleCloudVideointelligenceV1p3beta1Entity) super.clone();
}
}
| [
"45548808+kolea2@users.noreply.github.com"
] | 45548808+kolea2@users.noreply.github.com |
44f3fa4da9b0fa5c73729996779c2ad94fce86d1 | 72a1eecf939c8a94836d2c85dc378552c503d212 | /InClass/Chapter 26/Three.java | 0542492606df08ca9227eb8235cb96b18cf2259a | [] | no_license | HarryGuerrilla/LA-City-College-CSIT-142- | 7155b18aeafdf4ce91c23c6c70968559dbe66358 | c3d6daf56578997f8209f022b93da35914748944 | refs/heads/master | 2021-01-16T19:00:15.042888 | 2011-06-01T19:34:35 | 2011-06-01T19:34:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,677 | java | // Display output from three threads to text area
import javax.swing.*;
public class Three extends JFrame {
private JTextArea jta = new JTextArea();
public static void main(String[] args) {
Three frame = new Three();
frame.setTitle("Three Threads");
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null); // Center the frame
frame.setVisible(true);
}
public Three() {
JScrollPane jsp = new JScrollPane(jta);
add(jsp);
jta.setLineWrap(true);
Thread printA = new Thread(new PrintChar('a', 100));
Thread printB = new Thread(new PrintChar('b', 100));
Thread print1000 = new Thread(new PrintNum(100));
// Start threads
print1000.start();
printA.start();
printB.start();
}
//The thread class for printing a specified character in specified times
class PrintChar implements Runnable {
private char charToPrint; //the character to print
private int times; //the times to repeat
//The thread class constructor
public PrintChar(char c, int t) {
charToPrint = c;
times = t;
}
//override the run() method to tell the system what the thread will do
public void run() {
for (int i=1; i < times; i++)
jta.append(charToPrint+"");
}
}
//The thread class for printing number from 1 to n for a given n.
class PrintNum implements Runnable {
private int lastNum;
public PrintNum(int i) {
lastNum = i;
}
public void run() {
for (int i=1; i <= lastNum; i++)
jta.append(" "+i);
}
}
}
| [
"tnyplz@gmail.com"
] | tnyplz@gmail.com |
6df40bf9358a51980349375b40b682b460c5c7d2 | 51a172696626ff4eecd69e24178db52212de1b7d | /mall/dao/src/main/java/com/dao/common/ExpressCompanyMapper.java | c31122cc8fda6c46d8293f27dd51bed869418160 | [] | no_license | 295647706/mall | eb2bf9d9c8efd326aa01fb5b7e7dd8ff7bb814e5 | 141643f92bc7edff8c5888ba18df6d4029233503 | refs/heads/master | 2020-05-16T18:35:31.123120 | 2019-04-24T13:20:29 | 2019-04-24T13:20:29 | 183,231,222 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 266 | java | package com.dao.common;
import com.dao.BaseMapper;
import com.model.common.ExpressCompany;
import com.model.common.ExpressCompanySub;
/**
*
* @Author Ruan
*
*/
public interface ExpressCompanyMapper extends BaseMapper<ExpressCompany, ExpressCompanySub> {
} | [
"295647706@qq.com"
] | 295647706@qq.com |
864752c4a27dc4a09726f2c3822a3ce6f88f58f0 | ccc836eb256c916cc88c402646f0c4c2bde8ae3c | /src/BinaryTree/P10_HeightOfTree.java | 2378dadc20b832596d84df448c25e177e92e51c4 | [] | no_license | dhruv3/DS_PracticeProblems | 37a01474d056b75e055dacdbda1a93a176b27fb1 | b2998019f3dc20ac722f4b89887cdb6880008555 | refs/heads/master | 2021-04-29T07:38:43.387157 | 2017-10-22T18:37:21 | 2017-10-22T18:37:21 | 77,948,134 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,160 | java | package BinaryTree;
import java.util.Stack;
public class P10_HeightOfTree {
public static void main(String[] args) {
BinaryTreeNode root = createTree();
//print initial state
System.out.println("Initial state of the tree:");
PreOrder(root);
int heightTree = maxDepthRecursive(root);
System.out.println("Height of the tree by recursive method is: " + heightTree);
heightTree = PostOrderTreeHeight(root);
System.out.println("Height of the tree using a Stack is: " + heightTree);
}
//recursive method
private static int maxDepthRecursive(BinaryTreeNode root) {
if(root == null)
return 0;
int leftDepth = maxDepthRecursive(root.getLeft());
int rightDepth = maxDepthRecursive(root.getRight());
//+1 added so as to include the element at the present level
return (leftDepth > rightDepth) ? leftDepth + 1 : rightDepth + 1;
}
//Height using a Stack
private static int PostOrderTreeHeight(BinaryTreeNode root) {
BinaryTreeNode current = root;
Stack<BinaryTreeNode> st = new Stack<BinaryTreeNode>();
int heightTree = 0;
//loop
while(current != null || !st.isEmpty()){
//if current is not empty; add it to stack and update current to left node
if(current != null){
st.push(current);
current = current.getLeft();
}
else{
//get right node of topmost node in the stack
BinaryTreeNode temp = ((BinaryTreeNode) st.peek()).getRight();
//if right node does NOT exist
if(temp == null){
//right node is NULL-->We are done with LEFT and RIGHT side of topmost stack node
//pop and print topmost stack element
temp = (BinaryTreeNode) st.pop();
//Commenting print line // System.out.println(temp.getData());
//check if popped node is same as the NEW topmost node right neighbor
//if it is => we have completed with both left & right subtrees
//pop topmost node
while(!st.isEmpty() && temp == ((BinaryTreeNode) st.peek()).getRight()){
temp = (BinaryTreeNode) st.pop();
//Commenting print line // System.out.println(temp.getData());
}
}
else{
//set current to temp; This will insert the right element into the stack.
current = temp;
}
}
if(st.size() > heightTree){
heightTree = st.size();
}
}
return heightTree;
}
//to print the tree
private static void PreOrder(BinaryTreeNode root) {
if(root != null){
System.out.println(root.getData());
PreOrder(root.getLeft());
PreOrder(root.getRight());
}
}
private static BinaryTreeNode createTree() {
BinaryTreeNode n1 = new BinaryTreeNode(1);
BinaryTreeNode n2 = new BinaryTreeNode(2);
BinaryTreeNode n3 = new BinaryTreeNode(3);
n1.setLeft(n2);
n1.setRight(n3);
BinaryTreeNode n4 = new BinaryTreeNode(4);
BinaryTreeNode n5 = new BinaryTreeNode(5);
n2.setLeft(n4);
n2.setRight(n5);
BinaryTreeNode n6 = new BinaryTreeNode(6);
BinaryTreeNode n7 = new BinaryTreeNode(7);
n3.setLeft(n6);
n3.setRight(n7);
BinaryTreeNode n8 = new BinaryTreeNode(8);
BinaryTreeNode n9 = new BinaryTreeNode(9);
n6.setLeft(n8);
n7.setLeft(n9);
BinaryTreeNode root = n1;
return root;
}
}
| [
"dhruv.mnit@gmail.com"
] | dhruv.mnit@gmail.com |
c866f3cd6434baccb145c9f464d8a5b6d31b7573 | fd112bcc46128e986bd7fd131702981b5c0f5729 | /src/main/java/local/mrjnk/messenger/config/MvcConfig.java | e355af0586f30e4a16bfbe7cf566a8e98c92745a | [] | no_license | MrJonniK/messenger | de84a04f4f8d02d1a115b04f9bedc524a97f9558 | 8843bae292d4b9643bab7a514fd521a18782652c | refs/heads/master | 2020-05-16T11:04:25.404041 | 2019-06-03T13:50:37 | 2019-06-03T13:50:37 | 183,002,045 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,162 | java | package local.mrjnk.messenger.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
@Value("${upload.path}")
private String uploadPath;
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("login");
// registry.addViewController("/error").setViewName("error");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/img/**")
.addResourceLocations("file:///" + uploadPath + "/");
registry.addResourceHandler("/static/**")
.addResourceLocations("classpath:/static/");
}
}
| [
"jimmyfuzzjam@gmail.com"
] | jimmyfuzzjam@gmail.com |
069ea5561c069a813caf5e10682033d40a5117a4 | 1ef43b146e94acf2dfaf02fe5acdd8ad13d882de | /Java/SSM/SSM/src/main/java/com/isprint/cnaac/server/utils/ConfigManager.java | ce2d01df253556b55a60d57fe6e26dbc8980fedc | [] | no_license | xkang8902/bigdata | 90d46e37d938bc4160e116673bb5048faebe8570 | 5859c11d5e87faa605fa04139b08e12da18e4063 | refs/heads/master | 2020-04-26T13:26:22.942041 | 2019-03-04T04:25:37 | 2019-03-04T04:25:37 | 173,579,318 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,350 | java | package com.isprint.cnaac.server.utils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Properties;
public class ConfigManager {
private static String CONFIG_FILE = "/config.properties";
private static Properties configProps = new Properties();
static {
initialize();
}
private static void initialize() {
try {
configProps.load(ConfigManager.class.getResourceAsStream(CONFIG_FILE));
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getConfigValue(String configKey) {
String configValue = (String) configProps
.getProperty(configKey);
return configValue;
}
public static int getConfigValueAsInt(String configKey) {
int intValue = 0;
try {
intValue = Integer.parseInt(getConfigValue(configKey));
} catch (NumberFormatException e) {
intValue = 0;
}
return intValue;
}
public static Properties getConfigProps(){
return configProps;
}
public static void main(String[] args)
throws UnsupportedEncodingException, IOException {
String x = getConfigValue("api_server_name");
System.out.println(x);
}
}
| [
"xkang8902@163.com"
] | xkang8902@163.com |
a03d5e57e32884716983268dc440dcedd7735f37 | 398dc952d5dff20d26d58947b7f353a6aa936cc4 | /app/src/main/java/com/rakib/moviewer/MoviesResponse.java | ce590d5e38af4058c1f6209795483314b80e321b | [] | no_license | rakib10rr3/Movie-Tracker | 808ebb5caf0a96156b38efc6b20b66ec3cb9f60f | d8b2c4e297e74b98912cdf915fad66e12742ba49 | refs/heads/master | 2020-07-27T04:14:13.088655 | 2018-10-16T10:59:52 | 2018-10-16T10:59:52 | 208,863,989 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 794 | java | package com.rakib.moviewer;
import java.util.List;
/**
* Created by Rakib on 1/5/2018.
*/
public class MoviesResponse {
private int page;
public int getPage() { return this.page; }
public void setPage(int page) { this.page = page; }
private int total_results;
public int getTotalResults() { return this.total_results; }
public void setTotalResults(int total_results) { this.total_results = total_results; }
private int total_pages;
public int getTotalPages() { return this.total_pages; }
public void setTotalPages(int total_pages) { this.total_pages = total_pages; }
private List<Result> results;
public List<Result> getResults() { return this.results; }
public void setResults(List<Result> results) { this.results = results; }
}
| [
"rakib10rr3@gmail.com"
] | rakib10rr3@gmail.com |
e844f37e8a44463e0564f07e52b40e10ae0615a5 | cc210baab2a49df23cb8731884cbf916a50baf07 | /src/main/java/com/adrisilva/comercial/repository/OpportunityRepository.java | 704c6cf718c01bf23ffd6c5c2eb898cbd81f6650 | [] | no_license | AdriJonhson/spring-api | 7a39d6209bd12e786930642cb430ff132b9a8042 | c24bbd83771dc7c14a55001993d9aa471b2885b6 | refs/heads/master | 2020-04-18T20:08:10.122632 | 2019-01-27T03:35:22 | 2019-01-27T03:35:22 | 167,729,852 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 375 | java | package com.adrisilva.comercial.repository;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import com.adrisilva.comercial.model.Opportunity;
public interface OpportunityRepository extends JpaRepository<Opportunity, Long>{
Optional<Opportunity> findByDescriptionAndNameProspector(String description, String nameProspector);
}
| [
"adrisilva0002@gmail.com"
] | adrisilva0002@gmail.com |
609cfd273f9594fcc2f2293220e33bd0ba7bbed7 | 8a74c0acdf6d2f49d0d7b92d1dcd58424afcf386 | /MouseMotionServer/src/network/Impl/OwnEngine.java | 81970408c42c7f95a36cb83124be63309917d50a | [] | no_license | Rylith/AndroidTCPConnection | 40a927934c87a0ac7638651b481fbc22b2d8cf32 | 222881b0b0db0632aac80cdf6de9ca5dcf07a286 | refs/heads/master | 2020-04-02T18:50:16.310822 | 2016-07-13T10:28:04 | 2016-07-13T10:28:04 | 62,565,012 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 6,905 | java | package network.Impl;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.channels.spi.SelectorProvider;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import network.Interface.AcceptCallback;
import network.Interface.Channel;
import network.Interface.ConnectCallback;
import network.Interface.Engine;
import network.Interface.Server;
public class OwnEngine extends Engine implements Runnable{
private Selector m_selector;
private Map<SelectionKey, Channel> listKey= new HashMap<SelectionKey, Channel>();
private Map<SelectionKey, Server> mapServer = new HashMap<SelectionKey, Server>();
// The message to send to the server
private byte[] msg="0".getBytes();
private ConnectCallback connectCallback;
private AcceptCallback acceptCallback;
public OwnEngine() throws IOException {
m_selector = SelectorProvider.provider().openSelector();
}
//Boucle pour NIO, redirige vers l'action suivant la clé
public void mainloop() {
while (true) {
try {
m_selector.select();
Iterator<?> selectedKeys = this.m_selector.selectedKeys().iterator();
while (selectedKeys.hasNext()) {
SelectionKey key = (SelectionKey) selectedKeys.next();
selectedKeys.remove();
if (!key.isValid()) {
continue;
} else if (key.isAcceptable()) {
handleAccept(key);
} else if (key.isReadable()) {
handleRead(key);
} else if (key.isWritable()) {
handleWrite(key);
} else if (key.isConnectable()) {
handleConnect(key);
} else
System.out.println(" ---> unknown key=");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
//Utilisé quand la connexion est acceptée
private void handleConnect(SelectionKey key) {
SocketChannel socketChannel = (SocketChannel) key.channel();
try {
socketChannel.finishConnect();
} catch (IOException e) {
e.printStackTrace();
key.cancel();
return;
}
//Callback avertissant de la connection
Channel channel = listKey.get(key);
connectCallback.connected(channel);
//channel.send(msg, 0, msg.length);
key.interestOps(SelectionKey.OP_READ /*| SelectionKey.OP_WRITE*/);
}
private void handleWrite(SelectionKey key) {
boolean finish = true;
//System.out.println("call of handleWrite");
Channel channel = listKey.get(key);
try {
finish=((ChannelTest) channel).getWriteAutomata().handleWrite();
if(finish && ((ChannelTest) channel).getWriteAutomata().isEmpty()){
key.interestOps(SelectionKey.OP_READ);
}else{
key.interestOps(SelectionKey.OP_WRITE | SelectionKey.OP_READ);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private void handleRead(SelectionKey key) {
SocketChannel socketChannel = (SocketChannel) key.channel();
Channel channel = listKey.get(key);
try {
msg=((ChannelTest) channel).getReadAutomata().handleRead();
} catch (IOException e) {
// the connection as been closed unexpectedly, cancel the selection and close the channel
key.cancel();
try {
socketChannel.close();
} catch (IOException e1) {
e1.printStackTrace();
}
return;
}
if (((ChannelTest) channel).getReadAutomata().isConnectionClosed()) {
// the socket has been shutdown remotely cleanly"
try {
key.channel().close();
listKey.remove(key);
channel.close();
System.out.println("Connection closed by client : "+channel);
} catch (IOException e) {
e.printStackTrace();
}
key.cancel();
return;
}
//Si le message est non null c'est qu'il a été lu entièrement
if(msg != null){
((ChannelTest) channel).getCallback().deliver(channel, msg);
//msg = String.valueOf(Integer.valueOf(new String(msg))+1).getBytes();
//channel.send(msg, 0, msg.length);
}
}
private void handleAccept(SelectionKey key) {
SocketChannel socketChannel = null;
ServerSocketChannel serverSocketChannel = (ServerSocketChannel) key.channel();
try {
socketChannel = serverSocketChannel.accept();
socketChannel.configureBlocking(false);
} catch (IOException e) {
// as if there was no accept done
return;
}
// be notified when there is incoming data
try {
SelectionKey m_key = socketChannel.register(this.m_selector, SelectionKey.OP_READ /*| SelectionKey.OP_WRITE*/);
//Création du channel
Channel channel = new ChannelTest(socketChannel);
channel.setDeliverCallback(new DeliverCallbackTest());
//Callback d'acceptation
Server server = mapServer.get(key);
acceptCallback.accepted(server, channel);
listKey.put(m_key, channel);
} catch (ClosedChannelException e) {
handleClose(socketChannel);
}
}
private void handleClose(SocketChannel socketChannel) {
socketChannel.keyFor(m_selector).cancel();
try{
socketChannel.close();
} catch (IOException e) {
//nothing to do, the channel is already closed
}
}
public Server listen(int port, AcceptCallback callback) throws IOException {
//Création de la socketserveur dans le constructeur
ServerTest server = new ServerTest(port);
SelectionKey key = server.getSocket().register(m_selector, SelectionKey.OP_ACCEPT);
acceptCallback=callback;
//Pour retrouver le serveur lors de l'appel du callback d'acceptation
mapServer.put(key,server);
return server;
}
public void connect(InetAddress hostAddress, int port,
ConnectCallback callback) throws UnknownHostException,
SecurityException, IOException {
SocketChannel m_ch;
//Création de la socket de connexion
m_ch = SocketChannel.open();
m_ch.configureBlocking(false);
m_ch.socket().setTcpNoDelay(true);
SelectionKey m_key;
// be notified when the connection to the server will be accepted
m_key = m_ch.register(m_selector, SelectionKey.OP_CONNECT);
// request to connect to the server
m_ch.connect(new InetSocketAddress(hostAddress, port));
Channel channel = new ChannelTest(m_ch);
channel.setDeliverCallback(new DeliverCallbackTest());
listKey.put(m_key, channel);
connectCallback=callback;
}
public void run() {
mainloop();
}
//Use to send to every member of group
public void send(String msg, int offset, int length) {
for(Entry<SelectionKey, Channel> mapEntry : listKey.entrySet()){
SelectionKey key = mapEntry.getKey();
Channel channel = mapEntry.getValue();
channel.send(msg.getBytes(), offset, length);
//handleWrite(key);
try {
Thread.sleep(0,1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
| [
"vivien.michel@e.ujf-grenoble.fr"
] | vivien.michel@e.ujf-grenoble.fr |
e222d9382a4d4b787b2fb993d95ac3ad09a76bc3 | c0dfff217e1e935733aaea3c10cbaae24c7cd37d | /src/main/java/com/wjcwleklinski/investor/exception/WrongAlgorithmNameException.java | 73b3dc2e3dbe19163c1391bcf2be7ce9e4c1af5a | [] | no_license | wjcwleklinski/investor | 590729627d5de9fd8439e50f9148eea1df625cbe | 2ebb64dd1596b0d78dd9f93e673224f22d5a2b30 | refs/heads/master | 2020-09-20T08:16:12.487808 | 2019-11-27T11:46:17 | 2019-11-27T11:46:17 | 224,420,300 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 342 | java | package com.wjcwleklinski.investor.exception;
public class WrongAlgorithmNameException extends RuntimeException {
private String algorithmName;
public WrongAlgorithmNameException(String algorithmName) {
this.algorithmName = algorithmName;
}
public String getAlgorithmName() {
return algorithmName;
}
}
| [
"wjcwleklinski@gmail.com"
] | wjcwleklinski@gmail.com |
9908d144530cba727e8010decfcf77c237187b54 | c900a2d8666fbc9cceb833e343577bb58bd4b470 | /src/main/java/com/example/repository/OrderRepository.java | 89e84fa6bad20243a20143b33ac5b3150922c293 | [] | no_license | inarayan/Taco-CloudApp | 72ee0c1cc8bf2243dbaf0e94b3faa43dd0c943be | 1fc02bbc573b85560f8cfc7c649958cb005c97c3 | refs/heads/master | 2020-08-21T10:48:19.659032 | 2019-10-20T10:20:16 | 2019-10-20T10:20:16 | 216,143,616 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 138 | java | package com.example.repository;
import com.example.dto.Order;
public interface OrderRepository {
public Order save(Order order);
}
| [
"manishakumari@MANISHAs-MBP.Dlink"
] | manishakumari@MANISHAs-MBP.Dlink |
a39c25d523923cdccb32d85cb7bb692387c555cc | 0b6f85407604daa80e203097d99a7224434e8b8e | /AndroidHealthDemoSource~/android/support/v4/content/pm/ActivityInfoCompat.java | c6ac8cd9e2466b1ecb7932703358f234c46248a9 | [] | no_license | GrantColes/BestAppDev2017 | d85312ca9b4428a0b5a22e598fe6734a41263523 | ad35fdfa0cee83d8a91dceb3bf35fc12f04495a8 | refs/heads/master | 2021-01-23T05:14:15.312831 | 2017-04-07T01:32:14 | 2017-04-07T01:32:14 | 86,286,243 | 1 | 3 | null | 2017-04-07T00:19:19 | 2017-03-27T03:15:11 | Java | UTF-8 | Java | false | false | 330 | java | package android.support.v4.content.pm;
public class ActivityInfoCompat
{
public static final int CONFIG_UI_MODE = 512;
}
/* Location: C:\Users\Grant\Desktop\ConversionFolder\output2.jar!\android\support\v4\content\pm\ActivityInfoCompat.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"gcoles@okstate.edu"
] | gcoles@okstate.edu |
d381f0ac7cb4a31eb3897b86fb847fa81a1dfb4f | 66974610bdf74f579502fabc0dd9909f17a7ff98 | /src/main/java/org/programmiersportgruppe/jirabrowser/AnotherMain.java | 5095f83059cd2b4e86a2043fcea0abec874b9b3c | [] | no_license | fleipold/jira-browser | b55fb9dd13b0354b036933ef7283a3e4b5d6696c | e8670e622205658aece1982e7a638f7b2148610d | refs/heads/master | 2020-05-19T12:35:45.368393 | 2015-09-28T20:28:28 | 2015-09-28T20:28:28 | 38,122,867 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,614 | java | package org.programmiersportgruppe.jirabrowser;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.factories.Borders;
import com.jgoodies.forms.layout.FormLayout;
import org.programmiersportgruppe.swingutils.UIUtils;
import javax.swing.*;
/**
* Created by fleipold on 26/03/2015.
*/
public class AnotherMain {
public static void main(String[] args) {
DefaultFormBuilder formBuilder = new DefaultFormBuilder(new FormLayout("fill:100dlu:grow", "fill:pref:grow"));
JTextArea textArea = new JTextArea("Here is the problem: for many years, the Supreme Court wrestled with\n" +
"the issue of pornography, until finally Associate Justice John Paul\n" +
"Stevens came up with the famous quotation about how he couldn't define\n" +
"pornography, but he knew it when he saw it. So for a while, the\n" +
"court's policy was to have all the suspected pornography trucked to\n" +
"Justice Stevens' house, where he would look it over. \"Nope, this isn't\n" +
"it,\" he'd say. \"Bring some more.\" This went on until one morning when\n" +
"his housekeeper found him trapped in the recreation room under an\n" +
"enormous mound of rubberized implements, and the court had to issue a\n" +
"ruling stating that it didn't know what the hell pornography was except\n" +
"that it was illegal and everybody should stop badgering the court about\n" +
"it because the court was going to take a nap.\n" +
"\t\t-- Dave Barry, \"Pornography\"\n" +
"example-apps 0 $ fortune -o\n" +
"I'm going to Iowa for an award. Then I'm appearing at Carnegie Hall,\n" +
"it's sold out. Then I'm sailing to France to be honored by the French\n" +
"government -- I'd give it all up for one erection.\n" +
"\t\t-- Groucho Marx");
formBuilder.append(textArea);
System.out.println(textArea.getPreferredSize());
System.out.println(textArea.getMinimumSize());
textArea.addPropertyChangeListener("preferredSize", evt -> System.out.println(textArea.getPreferredSize()));
textArea.addPropertyChangeListener("minimumSize", evt -> System.out.println(textArea.getMinimumSize()));
formBuilder.border(Borders.DIALOG);
textArea.setColumns(30);
textArea.setWrapStyleWord(true);
textArea.setLineWrap(true);
UIUtils.showInFrame(formBuilder.build());
}
}
| [
"felix.leipold@gmail.com"
] | felix.leipold@gmail.com |
7565f2000dc0a2a1e4deffdef205ebb8bcb3f5b3 | ebc552f294be6a2b1a4ff383671ba800660d96a6 | /src/squares/Squares_main.java | 4c514b1038c15b64140af6538be7f79ad4896c40 | [] | no_license | rv058059/Squares | d8d88733c7f371962f9d16948548e4524c932023 | c2f6804b243982c27ea56b7fac04b5c7345ed0e0 | refs/heads/master | 2020-07-01T15:04:31.112543 | 2016-11-21T07:29:45 | 2016-11-21T07:29:45 | 74,337,273 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 534 | java | package squares;
public class Squares_main {
public static void main(String[] args) {
// TODO Auto-generated method stub
double x[]={0.0,0.2,0.4,0.6,0.8,1.0,1.2};
double y[]={1.0,1.8,3.1,4.5,4.9,6.8,7.6};
double theta[]=new double[2];
Squares_lib slib = new Squares_lib(x,y);
for (int i=0; i < 100; i++){
theta = slib.getDx();
System.out.println(i+" : theta[0] = " +theta[0]);
System.out.println(i+" : theta[1] = " +theta[1]);
System.out.println(i+" : Objective function = " +slib.getRx());
}
}
}
| [
"rv058059@outlook.jp"
] | rv058059@outlook.jp |
afcd6b5e1692bd746fd75f2077e8e92c03095b12 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/14/14_0ebaa13942d084dd78704a38e7eebdb5c14bcf8f/CheckBoxZone/14_0ebaa13942d084dd78704a38e7eebdb5c14bcf8f_CheckBoxZone_t.java | 206a8d81f747e410aa8215c261b0668f03014882 | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 539 | java | package vialab.SMT;
public class CheckBoxZone extends Zone {
public CheckBoxZone(String name, int x, int y, int width, int height) {
super(name, x, y, width, height);
}
public boolean checked = false;
protected void drawImpl() {
fill(255);
rect(0, 0, width, height, 10);
if (checked) {
stroke(0);
strokeWeight(5);
line(width, 0, width / 3, height);
line(width / 3, height, 0, (float) (height * 2. / 3.));
}
}
@Override
protected void touchUpImpl(Touch t) {
checked = !checked;
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
9710094d244416e00603bd790d87c8b6a12dbad6 | 26ed9cdb8874153b34fa906934db9fc19a7cb360 | /MassiveCore/src/com/massivecraft/massivecore/util/MUtil.java | bbb65620f2b28e170367873033794292e0f1c01d | [
"MIT"
] | permissive | sarhatabaot/SuperFactions | 9a10c0714d950011cef5c8d90d39f38ba1434119 | 3301cf0bb7ba66b720e01d9eb2530ac420e77b2a | refs/heads/master | 2021-07-24T06:34:42.178446 | 2021-07-08T17:07:00 | 2021-07-08T17:07:00 | 185,599,748 | 0 | 0 | null | 2021-07-08T17:07:01 | 2019-05-08T12:16:18 | Java | UTF-8 | Java | false | false | 53,809 | java | package com.massivecraft.massivecore.util;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.collections.ExceptionSet;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.collections.MassiveMap;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.collections.MassiveTreeSet;
import com.massivecraft.massivecore.comparator.ComparatorCaseInsensitive;
import com.massivecraft.massivecore.engine.EngineMassiveCoreDatabase;
import com.massivecraft.massivecore.engine.EngineMassiveCoreMain;
import com.massivecraft.massivecore.engine.EngineMassiveCoreWorldNameSet;
import com.massivecraft.massivecore.integration.liability.IntegrationLiabilityAreaEffectCloud;
import com.massivecraft.massivecore.mixin.MixinMessage;
import com.massivecraft.massivecore.nms.NmsEntityGet;
import com.massivecraft.massivecore.predicate.PredicateElementGarbage;
import com.massivecraft.massivecore.predicate.PredicateElementSignificant;
import com.massivecraft.massivecore.util.extractor.Extractor;
import com.massivecraft.massivecore.util.extractor.ExtractorSenderId;
import com.massivecraft.massivecore.util.extractor.ExtractorWorld;
import com.massivecraft.massivecore.util.extractor.ExtractorWorldName;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.metadata.Metadatable;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.regex.Pattern;
public class MUtil
{
// -------------------------------------------- //
// GET ONLINE PLAYERS
// -------------------------------------------- //
// Old thing that had to do with the converfrion from 1.17 to 1.8
@Deprecated
public static Collection<Player> getOnlinePlayers()
{
Collection<? extends Player>coll = Bukkit.getOnlinePlayers();
List<Player> ret = new MassiveList<>(coll.size());
return ret;
}
// -------------------------------------------- //
// GET NEARBY PLAYERS
// -------------------------------------------- //
public static Set<Player> getNearbyPlayers(Entity entity, double raidus, boolean includeSelf)
{
Set<Player> ret = getNearbyPlayers(entity.getLocation(), raidus);
if (isPlayer(entity) && !includeSelf) ret.remove(entity);
return ret;
}
public static Set<Player> getNearbyPlayers(Location location, double radius)
{
// Create
Set<Player> ret = new MassiveSet<>();
// Fill
final World world = location.getWorld();
final double radiusSquared = radius * radius;
for (Player player : Bukkit.getOnlinePlayers())
{
Location playerLocation = player.getLocation();
World playerWorld = playerLocation.getWorld();
if ( ! world.equals(playerWorld)) continue;
double distanceSquared = location.distanceSquared(playerLocation);
if (distanceSquared > radiusSquared) continue;
ret.add(player);
}
// Return
return ret;
}
// -------------------------------------------- //
// IS SYNCHRONOUS
// -------------------------------------------- //
public static boolean isSynchronous()
{
return Thread.holdsLock(Bukkit.getPluginManager()) || Bukkit.isPrimaryThread();
}
// -------------------------------------------- //
// GET ENTITY
// -------------------------------------------- //
public static Entity getEntity(World world, UUID uuid)
{
return NmsEntityGet.get().getEntity(world, uuid);
}
public static Entity getEntity(UUID uuid)
{
return NmsEntityGet.get().getEntity(uuid);
}
// -------------------------------------------- //
// IS VALID PLAYER NAME
// -------------------------------------------- //
// The regex for a valid minecraft player name.
public final static Pattern PATTERN_PLAYER_NAME = Pattern.compile("^[a-zA-Z0-9_]{2,16}$");
public static boolean isValidPlayerName(String string)
{
return PATTERN_PLAYER_NAME.matcher(string).matches();
}
// -------------------------------------------- //
// UUID
// -------------------------------------------- //
public static UUID asUuid(String string)
{
// Null
if (string == null) throw new NullPointerException("string");
// Avoid Exception
if (string.length() != 36) return null;
// Try
try
{
return UUID.fromString(string);
}
catch (Exception e)
{
return null;
}
}
public static boolean isUuid(String string)
{
return asUuid(string) != null;
}
// -------------------------------------------- //
// CONTAINS COMMAND
// -------------------------------------------- //
public static boolean containsCommand(String needle, ExceptionSet haystack)
{
boolean ret = haystack.isStandard();
if (containsCommand(needle, haystack.exceptions)) ret = !ret;
return ret;
}
public static boolean containsCommand(String needle, Iterable<String> haystack)
{
if (needle == null) throw new NullPointerException("needle");
needle = prepareCommand(needle);
for (String straw : haystack)
{
if (straw == null) continue;
straw = prepareCommand(straw);
// If it starts with then it is possibly a subject.
if ( ! needle.startsWith(straw)) continue;
// Get the remainder.
String remainder = needle.substring(straw.length());
// If they were equal, definitely true.
if (remainder.isEmpty()) return true;
// If the next is a space, the space is used as separator for sub commands or arguments.
// Otherwise it might just have been another command coincidentally starting with the first command.
// The old behaviour was if (needle.startsWith(straw)) return true;
// If "s" was block, then all commands starting with "s" was, now it isn't.
if (remainder.startsWith(" ")) return true;
}
return false;
}
private static String prepareCommand(String string)
{
if (string == null) throw new NullPointerException("string");
string = Txt.removeLeadingCommandDust(string);
string = string.toLowerCase();
string = string.trim();
return string;
}
// -------------------------------------------- //
// IP
// -------------------------------------------- //
public static String getIp(CommandSender sender)
{
if (!(sender instanceof Player)) return null;
Player player = (Player)sender;
InetSocketAddress address = player.getAddress();
if (address != null) return getIp(address);
String id = IdUtil.getId(player);
PlayerLoginEvent event = EngineMassiveCoreDatabase.idToPlayerLoginEvent.get(id);
if (event != null) return getIp(event);
return null;
}
public static String getIp(InetSocketAddress address)
{
if (address == null) return null;
String ret = address.toString();
String[] parts = ret.split("/");
ret = parts[1];
parts = ret.split(":");
ret = parts[0];
return ret;
}
public static String getIp(PlayerLoginEvent event)
{
InetAddress address = event.getAddress();
return getIp(address);
}
public static String getIp(InetAddress address)
{
if (address == null) return null;
String ret = address.toString();
String[] parts = ret.split("/");
ret = parts[1];
return ret;
}
public static Pattern PATTERN_IPV4 = Pattern.compile("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
public static boolean isIp(String string)
{
if (string == null) return false;
return PATTERN_IPV4.matcher(string).matches();
}
// -------------------------------------------- //
// IS(NT) NPC, SENDER, PLAYER
// -------------------------------------------- //
public static boolean isNpc(Object object)
{
if (object == null) throw new NullPointerException("object");
if ( ! (object instanceof Metadatable)) return false;
Metadatable metadatable = (Metadatable)object;
try
{
return metadatable.hasMetadata("NPC");
}
catch (UnsupportedOperationException e)
{
// ProtocolLib
// UnsupportedOperationException: The method hasMetadata is not supported for temporary players.
return false;
}
}
public static boolean isntNpc(Object object)
{
return !isNpc(object);
}
public static boolean isSender(Object object)
{
if (object == null) throw new NullPointerException("object");
if (!(object instanceof CommandSender)) return false;
if (isNpc(object)) return false;
return true;
}
public static boolean isntSender(Object object)
{
return !isSender(object);
}
public static boolean isPlayer(Object object)
{
if (object == null) throw new NullPointerException("object");
if (!(object instanceof Player)) return false;
if (isNpc(object)) return false;
return true;
}
public static boolean isntPlayer(Object object)
{
return !isPlayer(object);
}
// -------------------------------------------- //
// STACK TRACE: GET
// -------------------------------------------- //
public static List<StackTraceElement> getStackTrace(Thread thread, int skip)
{
// Cut away this method.
// Cut away system line.
// We must check if it's the current thread.
if (thread.equals(Thread.currentThread())) skip += 2;
StackTraceElement[] elements = thread.getStackTrace();
elements = Arrays.copyOfRange(elements, skip, elements.length);
return new MassiveList<>(Arrays.asList(elements));
}
public static List<StackTraceElement> getStackTrace(Thread thread)
{
int skip = 0;
// Cut away this method.
// We must check if it's the current thread.
if (thread.equals(Thread.currentThread())) skip += 1;
return getStackTrace(thread, skip);
}
public static List<StackTraceElement> getStackTrace(int skip)
{
// Cut away this method.
// We already know it's going to be the current thread.
skip++;
Thread thread = Thread.currentThread();
return getStackTrace(thread, skip);
}
public static List<StackTraceElement> getStackTrace()
{
// Cut away this method.
// We already know it's going to be the current thread.
int skip = 1;
Thread thread = Thread.currentThread();
return getStackTrace(thread, skip);
}
// -------------------------------------------- //
// STACK TRACE: CUT
// -------------------------------------------- //
public static void cutStackTrace(List<StackTraceElement> trace)
{
// Cut Significant
int index = 0;
while (index < trace.size())
{
StackTraceElement element = trace.get(index);
if (PredicateElementSignificant.get().apply(element)) break;
index++;
}
trace.subList(index, trace.size()).clear();
// Reverse
Collections.reverse(trace);
// Eat Garbage
for (Iterator<StackTraceElement> iterator = trace.iterator(); iterator.hasNext();)
{
StackTraceElement element = iterator.next();
if (PredicateElementGarbage.get().apply(element))
{
iterator.remove();
}
}
// Unreverse
Collections.reverse(trace);
}
// -------------------------------------------- //
// STACK TRACE STRING: MANY
// -------------------------------------------- //
public static List<String> getStackTraceStrings(List<StackTraceElement> stackTrace, boolean color)
{
List<String> ret = new MassiveList<>();
for (StackTraceElement element : stackTrace)
{
ret.add(getStackTraceString(element, color));
}
return ret;
}
public static List<String> getStackTraceStrings(int skip, boolean color)
{
skip++;
return getStackTraceStrings(getStackTrace(skip), color);
}
public static List<String> getStackTraceStrings(boolean color)
{
return getStackTraceStrings(0, color);
}
public static String getStackTraceString(List<StackTraceElement> stackTrace, boolean color)
{
return Txt.implode(getStackTraceStrings(stackTrace, color), "\n");
}
public static String getStackTraceString(int skip, boolean color)
{
skip++;
return getStackTraceString(getStackTrace(skip), color);
}
public static String getStackTraceString(boolean color)
{
return getStackTraceString(0, color);
}
// -------------------------------------------- //
// STACK TRACE STRING: ONE
// -------------------------------------------- //
// Same as the Java8 source but with color option.
public static String getStackTraceString(StackTraceElement element, boolean color)
{
ChatColor separatorColor = ChatColor.GRAY;
ChatColor classColor = ChatColor.YELLOW;
ChatColor methodColor = ChatColor.GREEN;
ChatColor fileColor = ChatColor.AQUA;
ChatColor lineColor = ChatColor.LIGHT_PURPLE;
String className = element.getClassName();
String methodName = element.getMethodName();
boolean nativeMethod = element.isNativeMethod();
String fileName = element.getFileName();
int lineNumber = element.getLineNumber();
StringBuilder ret = new StringBuilder();
if (color) ret.append(classColor);
ret.append(className);
if (color) ret.append(separatorColor);
ret.append(".");
if (color) ret.append(methodColor);
ret.append(methodName);
if (color) ret.append(separatorColor);
ret.append("(");
if (color) ret.append(fileColor);
if (nativeMethod)
{
ret.append("Native Method");
}
else
{
if (fileName != null && lineNumber >= 0)
{
ret.append(fileName);
if (color) ret.append(separatorColor);
ret.append(":");
if (color) ret.append(lineColor);
ret.append(lineNumber);
}
else
{
if (fileName != null)
{
ret.append(fileName);
}
else
{
ret.append("Unknown Source");
}
}
}
if (color) ret.append(separatorColor);
ret.append(")");
return ret.toString();
}
// -------------------------------------------- //
// STACK TRACE: DEBUG
// -------------------------------------------- //
public static void stackTraceDebug(String title)
{
// Create
List<String> messages = new MassiveList<>();
// Fill
messages.add(Txt.titleize(title).toPlain(true));
messages.addAll(MUtil.getStackTraceStrings(1, true));
// Message
MixinMessage.get().messageOne(IdUtil.CONSOLE_ID, messages);
}
// -------------------------------------------- //
// LIST OPERATIONS
// -------------------------------------------- //
public static <T> List<T> repeat(T object, int times)
{
List<T> ret = new ArrayList<>(times);
for (int i = 1; i <= times; i++)
{
ret.add(object);
}
return ret;
}
public static List<Integer> range(int from, int to)
{
List<Integer> ret = new MassiveList<>(to - from);
for (int i = from; i < to; i++)
{
ret.add(i);
}
return ret;
}
public static void keepLeft(List<?> list, int maxlength)
{
if (list.size() <= maxlength) return;
list.subList(maxlength, list.size()).clear();
}
public static void keepRight(List<?> list, int maxlength)
{
if (list.size() <= maxlength) return;
list.subList(0, maxlength).clear();
}
public static <T> void padLeft(List<T> list, T object, int length)
{
if (list.size() >= length) return;
list.addAll(0, repeat(object, length - list.size()));
}
public static <T> void padRight(List<T> list, T object, int length)
{
if (list.size() >= length) return;
list.addAll(repeat(object, length - list.size()));
}
// -------------------------------------------- //
// MAP OPERATIONS
// -------------------------------------------- //
public static void keepLeft(Map<?, ?> map, int maxSize)
{
int i = 0;
Iterator<?> iter = map.entrySet().iterator();
while (iter.hasNext())
{
iter.next();
i++;
if (i > maxSize) iter.remove();
}
}
// -------------------------------------------- //
// ITERABLE MATH
// -------------------------------------------- //
public static <T extends Number> double getSum(Iterable<T> numbers)
{
if (numbers == null) throw new NullPointerException("numbers");
double sum = 0;
for (T number : numbers)
{
sum += number.doubleValue();
}
return sum;
}
public static <T extends Number> double getAverage(Iterable<T> numbers)
{
if (numbers == null) throw new NullPointerException("numbers");
double sum = 0;
int count = 0;
for (T number : numbers)
{
sum += number.doubleValue();
count++;
}
if (count == 0) throw new IllegalArgumentException("numbers empty");
return sum / count;
}
// -------------------------------------------- //
// TABLE OPERATIONS
// -------------------------------------------- //
public static <T> List<List<T>> rotateLeft(List<List<T>> rows)
{
List<List<T>> ret = transpose(rows);
flipVertically(ret);
return ret;
}
public static <T> List<List<T>> rotateRight(List<List<T>> rows)
{
List<List<T>> ret = transpose(rows);
flipHorizontally(ret);
return ret;
}
public static <T> List<List<T>> transpose(List<List<T>> rows)
{
List<List<T>> ret = new ArrayList<>();
final int n = rows.get(0).size();
for (int i = 0; i < n; i++)
{
List<T> col = new ArrayList<>();
for (List<T> row : rows)
{
col.add(row.get(i));
}
ret.add(col);
}
return ret;
}
public static <T> void flipHorizontally(List<List<T>> rows)
{
for (List<T> row : rows)
{
Collections.reverse(row);
}
}
public static <T> void flipVertically(List<List<T>> rows)
{
Collections.reverse(rows);
}
// -------------------------------------------- //
// COLOR INT CODE
// -------------------------------------------- //
public static int getChatColorCode(ChatColor chatColor)
{
switch (chatColor)
{
case BLACK: return 0x00;
case DARK_BLUE: return 0x1;
case DARK_GREEN: return 0x2;
case DARK_AQUA: return 0x3;
case DARK_RED: return 0x4;
case DARK_PURPLE: return 0x5;
case GOLD: return 0x6;
case GRAY: return 0x7;
case DARK_GRAY: return 0x8;
case BLUE: return 0x9;
case GREEN: return 0xA;
case AQUA: return 0xB;
case RED: return 0xC;
case LIGHT_PURPLE: return 0xD;
case YELLOW: return 0xE;
case WHITE: return 0xF;
case MAGIC: return 0x10;
case BOLD: return 0x11;
case STRIKETHROUGH: return 0x12;
case UNDERLINE: return 0x13;
case ITALIC: return 0x14;
case RESET: return 0x15;
}
throw new IllegalArgumentException("The chat color " + chatColor.name() + " is not yet supported!");
}
public static ChatColor getChatColor(int chatColorCode)
{
switch (chatColorCode)
{
case 0x00: return ChatColor.BLACK;
case 0x1: return ChatColor.DARK_BLUE;
case 0x2: return ChatColor.DARK_GREEN;
case 0x3: return ChatColor.DARK_AQUA;
case 0x4: return ChatColor.DARK_RED;
case 0x5: return ChatColor.DARK_PURPLE;
case 0x6: return ChatColor.GOLD;
case 0x7: return ChatColor.GRAY;
case 0x8: return ChatColor.DARK_GRAY;
case 0x9: return ChatColor.BLUE;
case 0xA: return ChatColor.GREEN;
case 0xB: return ChatColor.AQUA;
case 0xC: return ChatColor.RED;
case 0xD: return ChatColor.LIGHT_PURPLE;
case 0xE: return ChatColor.YELLOW;
case 0xF: return ChatColor.WHITE;
case 0x10: return ChatColor.MAGIC;
case 0x11: return ChatColor.BOLD;
case 0x12: return ChatColor.STRIKETHROUGH;
case 0x13: return ChatColor.UNDERLINE;
case 0x14: return ChatColor.ITALIC;
case 0x15: return ChatColor.RESET;
}
throw new IllegalArgumentException("The chat color code " + chatColorCode + " is not yet supported!");
}
@SuppressWarnings("deprecation")
public static ChatColor getChatColor(DyeColor dyeColor)
{
int woolColorCode = dyeColor.getWoolData();
switch (woolColorCode)
{
case 0x0: return ChatColor.WHITE;
case 0x1: return ChatColor.GOLD;
case 0x2: return ChatColor.LIGHT_PURPLE;
case 0x3: return ChatColor.AQUA;
case 0x4: return ChatColor.YELLOW;
case 0x5: return ChatColor.GREEN;
case 0x6: return ChatColor.LIGHT_PURPLE;
case 0x7: return ChatColor.DARK_GRAY;
case 0x8: return ChatColor.GRAY;
case 0x9: return ChatColor.DARK_AQUA;
case 0xA: return ChatColor.DARK_PURPLE;
case 0xB: return ChatColor.BLUE;
case 0xC: return ChatColor.GRAY;
case 0xD: return ChatColor.DARK_GREEN;
case 0xE: return ChatColor.RED;
case 0xF: return ChatColor.BLACK;
}
throw new IllegalArgumentException("The dye color " + dyeColor + " is not yet supported!");
}
// -------------------------------------------- //
// ENTITY DAMAGE EVENT
// -------------------------------------------- //
// The EntityDamageEvent#setDamge(double damage) is somehow broken.
// The MAGIC modifier does not scale as one would expect it to.
// It jumps all over the place every time the method is called.
// And finally it has accumulated so much randomness that players may suddenly be healed instead of harmed.
// Or they may instantly die. For this reason we take inspiration from MCMMO who rolled their own setDamage function.
// This method sets the BASE damage modifier and scales all other modifiers proportionally.
public static void setDamage(EntityDamageEvent event, double newDamage)
{
// Check New Damage
if ( ! isFinite(newDamage)) throw new IllegalStateException("not finite newDamage: " + newDamage);
// Get Old Damage
final double oldDamage = event.getDamage(DamageModifier.BASE);
// Check Old Damage
if ( ! isFinite(oldDamage)) throw new IllegalStateException("not finite oldDamage: " + oldDamage);
// No Change?
if (newDamage == oldDamage) return;
// No Old Damage? (Avoid DBZ)
if (oldDamage == 0) return;
// Get Factor
final double factor = newDamage / oldDamage;
// Check Factor
if ( ! isFinite(factor)) throw new IllegalStateException("not finite factor: " + factor + " damage: " + newDamage + " oldDamage: " + oldDamage);
// Now scale all damage modifiers!
for (DamageModifier modifier : DamageModifier.values())
{
// Is this modifier used in the event?
if ( ! event.isApplicable(modifier)) continue;
// Is it the base damage? Cool! Just set it directly!
// We could have used the factor too but then we might suffer floating point degredation.
if (modifier == DamageModifier.BASE)
{
event.setDamage(modifier, newDamage);
continue;
}
// Apply Factor
event.setDamage(modifier, factor * event.getDamage(modifier));
}
}
// Same as above but scales directly.
public static void scaleDamage(EntityDamageEvent event, double factor)
{
// Clean Input
if ( ! isFinite(factor)) throw new IllegalStateException("not finite factor: " + factor);
// No Change?
if (equalsishNumber(factor, 1)) return;
for (DamageModifier modifier : DamageModifier.values())
{
// Is this modifier used in the event?
if ( ! event.isApplicable(modifier)) continue;
// Apply Factor
event.setDamage(modifier, factor * event.getDamage(modifier));
}
}
// isFinite check recreation to be compatible with java 1.7/1.6
public static boolean isFinite(double d)
{
return Math.abs(d) <= Double.MAX_VALUE;
}
// -------------------------------------------- //
// PICK
// -------------------------------------------- //
public static <T> T regexPickFirstVal(String input, Map<String, T> regex2val)
{
if (regex2val == null) throw new NullPointerException("regex2val");
T ret = null;
for (Entry<String, T> entry : regex2val.entrySet())
{
ret = entry.getValue();
if (input == null) continue;
String regex = entry.getKey();
if (Pattern.matches(regex, input)) break;
}
return ret;
}
public static <E, T> T equalsPickFirstVal(E input, Map<E, T> thing2val)
{
if (thing2val == null) throw new NullPointerException("thing2val");
T ret = null;
for (Entry<E, T> entry : thing2val.entrySet())
{
ret = entry.getValue();
if (input == null) continue;
E thing = entry.getKey();
if (MUtil.equals(input, thing)) break;
}
return ret;
}
public static <T> T recurseResolveMap(T input, Map<T, T> map)
{
T output = map.get(input);
if (output == null) return input;
return recurseResolveMap(output, map);
}
// -------------------------------------------- //
// GET BLOCKS
// -------------------------------------------- //
public static List<Block> getBlocks(Location location, int halfWidth)
{
return getBlocks(location.getBlock(), halfWidth);
}
public static List<Block> getBlocks(Block block, int halfWidth)
{
int xmin = block.getX() - halfWidth;
int ymin = block.getY() - halfWidth;
int zmin = block.getZ() - halfWidth;
int xmax = block.getX() + halfWidth;
int ymax = block.getY() + halfWidth;
int zmax = block.getZ() + halfWidth;
return getBlocks(block.getWorld(), xmin, ymin, zmin, xmax, ymax, zmax);
}
public static List<Block> getBlocks(World world, int xmin, int ymin, int zmin, int xmax, int ymax, int zmax)
{
List<Block> blocks = new ArrayList<>();
for (int x = xmin; x <= xmax; x++)
{
for (int y = ymin; y <= ymax; y++)
{
for (int z = zmin; z <= zmax; z++)
{
blocks.add(world.getBlockAt(x, y, z));
}
}
}
return blocks;
}
// -------------------------------------------- //
// LOCATIONS COMPARISON
// -------------------------------------------- //
public static boolean isSameBlock(PlayerMoveEvent event)
{
return isSameBlock(event.getFrom(), event.getTo());
}
public static boolean isSameBlock(Location one, Location two)
{
if (one.getBlockX() != two.getBlockX()) return false;
if (one.getBlockZ() != two.getBlockZ()) return false;
if (one.getBlockY() != two.getBlockY()) return false;
return one.getWorld().equals(two.getWorld());
}
public static boolean isSameChunk(PlayerMoveEvent event)
{
return isSameChunk(event.getFrom(), event.getTo());
}
public static boolean isSameChunk(Location one, Location two)
{
if (one.getBlockX() >> 4 != two.getBlockX() >> 4) return false;
if (one.getBlockZ() >> 4 != two.getBlockZ() >> 4) return false;
if (one.getWorld() != two.getWorld()) return false;
return true;
}
// -------------------------------------------- //
// FACE AND YAW
// -------------------------------------------- //
public static Float getYaw(BlockFace face)
{
switch (face)
{
case NORTH: return 0f;
case EAST: return 90f;
case SOUTH: return 180f;
case WEST: return 270f;
case UP: return null;
case DOWN: return null;
case NORTH_EAST: return 45f;
case NORTH_WEST: return 315f;
case SOUTH_EAST: return 135f;
case SOUTH_WEST: return 225f;
case WEST_NORTH_WEST: return 292.5f;
case NORTH_NORTH_WEST: return 337.5f;
case NORTH_NORTH_EAST: return 22.5f;
case EAST_NORTH_EAST: return 67.5f;
case EAST_SOUTH_EAST: return 112.5f;
case SOUTH_SOUTH_EAST: return 157.5f;
case SOUTH_SOUTH_WEST: return 202.5f;
case WEST_SOUTH_WEST: return 247.5f;
case SELF: return null;
}
return null;
}
// -------------------------------------------- //
// MATERIAL FACTS
// -------------------------------------------- //
// FOOD
public final static Set<Material> FOOD_MATERIALS = new HashSet<>(MUtil.list(
Material.APPLE,
Material.BREAD,
Material.COOKED_BEEF,
Material.COOKED_CHICKEN,
Material.COOKED_COD,
Material.COOKED_MUTTON,
Material.COOKED_PORKCHOP,
Material.COOKED_RABBIT,
Material.COOKED_SALMON,
Material.COOKIE,
Material.GOLDEN_APPLE,
Material.MELON,
Material.MUSHROOM_STEW,
Material.PORKCHOP,
Material.BEEF,
Material.CHICKEN,
Material.COD,
Material.SALMON,
Material.PUFFERFISH,
Material.TROPICAL_FISH,
Material.ROTTEN_FLESH,
Material.SPIDER_EYE
));
// Archery
public static boolean isArchery(Entity entity)
{
if (entity == null) return false;
return entity instanceof Arrow;
}
public static boolean isArchery(EntityDamageByEntityEvent event)
{
return isArchery(event.getDamager());
}
public static boolean isArchery(EntityDamageEvent event)
{
if ( ! (event instanceof EntityDamageByEntityEvent)) return false;
return isArchery((EntityDamageByEntityEvent)event);
}
// Sword
public static Set<Material> SWORD_MATERIALS = EnumSet.of(
Material.WOODEN_SWORD,
Material.STONE_SWORD,
Material.IRON_SWORD,
Material.GOLDEN_SWORD,
Material.DIAMOND_SWORD
);
public static boolean isSword(Material material)
{
return SWORD_MATERIALS.contains(material);
}
public static boolean isSword(ItemStack item)
{
if (item == null) return false;
return isSword(item.getType());
}
public static boolean isSword(Entity entity)
{
if (entity == null) return false;
if (!(entity instanceof LivingEntity)) return false;
LivingEntity lentity = (LivingEntity)entity;
return isSword(lentity.getEquipment().getItemInHand());
}
public static boolean isSword(EntityDamageByEntityEvent event)
{
return isSword(event.getDamager());
}
public static boolean isSword(EntityDamageEvent event)
{
if ( ! (event instanceof EntityDamageByEntityEvent)) return false;
return isSword((EntityDamageByEntityEvent)event);
}
// Axe
public static Set<Material> AXE_MATERIALS = EnumSet.of(
Material.WOODEN_AXE,
Material.STONE_AXE,
Material.IRON_AXE,
Material.GOLDEN_AXE,
Material.DIAMOND_AXE
);
public static boolean isAxe(Material material)
{
return AXE_MATERIALS.contains(material);
}
public static boolean isAxe(ItemStack item)
{
if (item == null) return false;
return isAxe(item.getType());
}
public static boolean isAxe(Entity entity)
{
if (entity == null) return false;
if (!(entity instanceof LivingEntity)) return false;
LivingEntity lentity = (LivingEntity)entity;
return isAxe(lentity.getEquipment().getItemInHand());
}
public static boolean isAxe(EntityDamageByEntityEvent event)
{
return isAxe(event.getDamager());
}
public static boolean isAxe(EntityDamageEvent event)
{
if ( ! (event instanceof EntityDamageByEntityEvent)) return false;
return isAxe((EntityDamageByEntityEvent)event);
}
// Unarmed
public static boolean isUnarmed(ItemStack item)
{
if (item == null) return true;
return InventoryUtil.isNothing(item);
}
public static boolean isUnarmed(Entity entity)
{
if (entity == null) return false;
if (!(entity instanceof LivingEntity)) return false;
LivingEntity lentity = (LivingEntity)entity;
return isUnarmed(lentity.getEquipment().getItemInHand());
}
public static boolean isUnarmed(EntityDamageByEntityEvent event)
{
return isUnarmed(event.getDamager());
}
public static boolean isUnarmed(EntityDamageEvent event)
{
if ( ! (event instanceof EntityDamageByEntityEvent)) return false;
return isUnarmed((EntityDamageByEntityEvent)event);
}
public static boolean isAxe(BlockBreakEvent event)
{
return isAxe(InventoryUtil.getWeapon(event.getPlayer()));
}
// Pickaxe
public static Set<Material> PICKAXE_MATERIALS = EnumSet.of(
Material.WOODEN_PICKAXE,
Material.STONE_PICKAXE,
Material.IRON_PICKAXE,
Material.GOLDEN_PICKAXE,
Material.DIAMOND_PICKAXE
);
public static boolean isPickaxe(Material material)
{
return PICKAXE_MATERIALS.contains(material);
}
public static boolean isPickaxe(ItemStack item)
{
if (item == null) return false;
return isPickaxe(item.getType());
}
public static boolean isPickaxe(Entity entity)
{
if (entity == null) return false;
if (!(entity instanceof LivingEntity)) return false;
LivingEntity lentity = (LivingEntity)entity;
return isPickaxe(lentity.getEquipment().getItemInHand());
}
public static boolean isPickaxe(BlockBreakEvent event)
{
return isPickaxe(InventoryUtil.getWeapon(event.getPlayer()));
}
// Spade
public static Set<Material> SPADE_MATERIALS = EnumSet.of(
Material.WOODEN_SHOVEL,
Material.IRON_SHOVEL,
Material.IRON_SHOVEL,
Material.GOLDEN_SHOVEL,
Material.DIAMOND_SHOVEL
);
public static boolean isSpade(Material material)
{
return SPADE_MATERIALS.contains(material);
}
public static boolean isSpade(ItemStack item)
{
if (item == null) return false;
return isSpade(item.getType());
}
public static boolean isSpade(Entity entity)
{
if (entity == null) return false;
if (!(entity instanceof LivingEntity)) return false;
LivingEntity lentity = (LivingEntity)entity;
return isSpade(lentity.getEquipment().getItemInHand());
}
public static boolean isSpade(BlockBreakEvent event)
{
return isSpade(InventoryUtil.getWeapon(event.getPlayer()));
}
// -------------------------------------------- //
// EVENT DERP
// -------------------------------------------- //
// Note that this one is unstable and invalid. It cannot catch all cases.
public static Material getEatenMaterial(PlayerInteractEvent event)
{
Action action = event.getAction();
if (action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK) return null;
Material ret = null;
if (action == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CAKE)
{
ret = Material.CAKE;
}
else if (FOOD_MATERIALS.contains(event.getMaterial()))
{
ret = event.getMaterial();
}
return ret;
}
public static boolean isCombatEvent(EntityDamageEvent event)
{
if (event.getCause() != DamageCause.ENTITY_ATTACK && event.getCause() != DamageCause.PROJECTILE) return false;
return event instanceof EntityDamageByEntityEvent;
}
public static boolean isCloseCombatEvent(EntityDamageEvent event)
{
if (event.getCause() != DamageCause.ENTITY_ATTACK) return false;
return event instanceof EntityDamageByEntityEvent;
}
public static Entity getLiableDamager(EntityDamageEvent event)
{
if (!(event instanceof EntityDamageByEntityEvent)) return null;
EntityDamageByEntityEvent edbeEvent = (EntityDamageByEntityEvent)event;
Entity ret = edbeEvent.getDamager();
if (ret instanceof Projectile)
{
Projectile projectile = (Projectile)ret;
ProjectileSource projectileSource = projectile.getShooter();
if (projectileSource instanceof Entity) ret = (Entity)projectileSource;
}
Entity cloudBasedDamager = IntegrationLiabilityAreaEffectCloud.get().getLiableDamager(edbeEvent);
if (cloudBasedDamager != null) ret = cloudBasedDamager;
return ret;
}
public static String kickReason(PlayerQuitEvent event)
{
Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) return null;
UUID uuid = player.getUniqueId();
return EngineMassiveCoreMain.kickedPlayerReasons.get(uuid);
}
public static boolean causedByKick(PlayerQuitEvent event)
{
return kickReason(event) != null;
}
// -------------------------------------------- //
// POTION DERP
// -------------------------------------------- //
/**
* Get just the potion effect bits. This is to work around bugs with potion parsing.
* Workaround created by the WorldGuard team: https://github.com/sk89q/worldguard/commit/8dec32fa6a1238a11743cea8b8302a6c9d2aaa55
* This issue is reported as BUKKIT-4612 "Potion.fromItemStack causes IllegalArgumentException: Instant potions cannot be extended"
*
* @param item item
* @return new bits
*/
public static int getPotionEffectBits(ItemStack item)
{
return item.getDurability() & 0x3F;
}
/**
* Checks if the given potion is a vial of water.
*
* @param item the item to check
* @return true if it's a water vial
*/
public static boolean isWaterPotion(ItemStack item)
{
return getPotionEffectBits(item) == 0;
}
@SuppressWarnings("deprecation")
public static List<PotionEffect> getPotionEffects(ItemStack itemStack)
{
if (itemStack == null) return null;
if (itemStack.getType() != Material.POTION) return null;
List<PotionEffect> ret = new ArrayList<>();
if (isWaterPotion(itemStack)) return ret;
Potion potion = Potion.fromDamage(getPotionEffectBits(itemStack));
ret.addAll(potion.getEffects());
PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
if (meta.hasCustomEffects())
{
ret.addAll(meta.getCustomEffects());
}
return ret;
}
public static final Set<PotionEffectType> HARMFUL_POTION_EFFECTS = Collections.unmodifiableSet(MUtil.set(
PotionEffectType.BLINDNESS,
PotionEffectType.CONFUSION,
PotionEffectType.HARM,
PotionEffectType.HUNGER,
PotionEffectType.POISON,
PotionEffectType.SLOW,
PotionEffectType.SLOW_DIGGING,
PotionEffectType.WEAKNESS,
PotionEffectType.WITHER
));
public static boolean isHarmfulPotion(PotionEffectType potionEffectType)
{
return HARMFUL_POTION_EFFECTS.contains(potionEffectType);
}
public static boolean isHarmfulPotion(PotionEffect potionEffect)
{
if (potionEffect == null) return false;
return isHarmfulPotion(potionEffect.getType());
}
public static boolean isHarmfulPotion(ItemStack itemStack)
{
List<PotionEffect> potionEffects = getPotionEffects(itemStack);
if (potionEffects == null) return false;
for (PotionEffect potionEffect : potionEffects)
{
if (isHarmfulPotion(potionEffect)) return true;
}
return false;
}
public static boolean isHarmfulPotion(ThrownPotion thrownPotion)
{
return isHarmfulPotion(thrownPotion.getItem());
}
// -------------------------------------------- //
// WORLD DERP
// -------------------------------------------- //
public static Set<String> getLoadedWorldNames()
{
return EngineMassiveCoreWorldNameSet.get().getWorldNames();
}
// -------------------------------------------- //
// TRANSFORM
// -------------------------------------------- //
@Deprecated
public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where, Comparator<? super T> orderby, Integer limit, Integer offset)
{
return transform(items, (Predicate<? super T>) where, orderby, limit, offset);
}
public static <T> List<T> transform(Iterable<T> items, Predicate<? super T> where, Comparator<? super T> orderby, Integer limit, Integer offset)
{
// Collection
Collection<T> collection = null;
if (items instanceof Collection<?>) collection = (Collection<T>)items;
// WHERE
List<T> ret;
if (where == null)
{
if (collection != null)
{
ret = new ArrayList<>(collection);
}
else
{
ret = new ArrayList<>();
for (T item : items)
{
ret.add(item);
}
}
}
else
{
if (collection != null)
{
ret = new ArrayList<>(collection.size());
}
else
{
ret = new ArrayList<>();
}
for (T item : items)
{
if (where.test(item))
{
ret.add(item);
}
}
}
// ORDERBY
if (orderby != null)
{
Collections.sort(ret, orderby);
}
// LIMIT AND OFFSET
// Parse args
int fromIndex = 0;
if (offset != null)
{
fromIndex = offset;
}
int toIndex = ret.size()-1;
if (limit != null)
{
toIndex = offset+limit;
}
// Clean args
if (fromIndex <= 0)
{
fromIndex = 0;
}
else if (fromIndex > ret.size()-1)
{
fromIndex = ret.size()-1;
}
if (toIndex < fromIndex)
{
toIndex = fromIndex;
}
else if (toIndex > ret.size()-1)
{
toIndex = ret.size()-1;
}
// No limit?
if (fromIndex == 0 && toIndex == ret.size()-1) return ret;
return new ArrayList<>(ret.subList(fromIndex, toIndex));
}
public static <T> List<T> transform(Iterable<T> items, Predicate<? super T> where) { return transform(items, where, null, null, null); }
public static <T> List<T> transform(Iterable<T> items, Predicate<? super T> where, Comparator<? super T> orderby) { return transform(items, where, orderby, null, null); }
public static <T> List<T> transform(Iterable<T> items, Predicate<? super T> where, Comparator<? super T> orderby, Integer limit) { return transform(items, where, orderby, limit, null); }
public static <T> List<T> transform(Iterable<T> items, Predicate<? super T> where, Integer limit) { return transform(items, where, null, limit, null); }
public static <T> List<T> transform(Iterable<T> items, Predicate<? super T> where, Integer limit, Integer offset) { return transform(items, where, null, limit, offset); }
public static <T> List<T> transform(Iterable<T> items, Comparator<? super T> orderby) { return transform(items, null, orderby, null, null); }
public static <T> List<T> transform(Iterable<T> items, Comparator<? super T> orderby, Integer limit) { return transform(items, null, orderby, limit, null); }
public static <T> List<T> transform(Iterable<T> items, Comparator<? super T> orderby, Integer limit, Integer offset) { return transform(items, null, orderby, limit, offset); }
public static <T> List<T> transform(Iterable<T> items, Integer limit) { return transform(items, null, null, limit, null); }
public static <T> List<T> transform(Iterable<T> items, Integer limit, Integer offset) { return transform(items, null, null, limit, offset); }
// OLD PREDICATE
@Deprecated public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where) { return transform(items, where, null, null, null); }
@Deprecated public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where, Comparator<? super T> orderby) { return transform(items, where, orderby, null, null); }
@Deprecated public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where, Comparator<? super T> orderby, Integer limit) { return transform(items, where, orderby, limit, null); }
@Deprecated public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where, Integer limit) { return transform(items, where, null, limit, null); }
@Deprecated public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where, Integer limit, Integer offset) { return transform(items, where, null, limit, offset); }
// -------------------------------------------- //
// SIMPLE CONSTRUCTORS
// -------------------------------------------- //
@SafeVarargs
public static <T> List<T> list(T... items)
{
List<T> ret = new MassiveList<>(items.length);
Collections.addAll(ret, items);
return ret;
}
@SafeVarargs
public static <T> Set<T> set(T... items)
{
Set<T> ret = new MassiveSet<>(items.length);
Collections.addAll(ret, items);
return ret;
}
public static Set<String> treeset(String... items)
{
return new MassiveTreeSet<String, ComparatorCaseInsensitive>(ComparatorCaseInsensitive.get(), Arrays.asList(items));
}
@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> map(K key1, V value1, Object... objects)
{
Map<K, V> ret = new MassiveMap<>();
ret.put(key1, value1);
Iterator<Object> iter = Arrays.asList(objects).iterator();
while (iter.hasNext())
{
K key = (K) iter.next();
V value = (V) iter.next();
ret.put(key, value);
}
return ret;
}
public static <K, V> Map<V, K> flippedMap(Map<K, V> map)
{
Map<V, K> ret = new MassiveMap<>();
for(Entry<K, V> entry : map.entrySet())
{
V value = entry.getValue();
K key = entry.getKey();
if (value == null) continue;
ret.put(value, key);
}
return ret;
}
public static <K, V> Map<V, Set<K>> reverseIndex(Map<K, V> map)
{
Map<V, Set<K>> ret = new MassiveMap<>();
for (Entry<K, V> entry : map.entrySet())
{
K key = entry.getKey();
V value = entry.getValue();
Set<K> set = ret.get(value);
if (set == null)
{
set = new HashSet<>();
ret.put(value, set);
}
set.add(key);
}
return ret;
}
// -------------------------------------------- //
// COLLECTION MANIPULATION
// -------------------------------------------- //
public static <T> T removeByIndex(Collection<T> coll, int index)
{
if (coll == null) throw new NullPointerException("coll");
if (coll instanceof List<?>)
{
return ((List<T>)coll).remove(index);
}
if (index < 0) throw new IndexOutOfBoundsException("index < 0");
if (index >= coll.size()) throw new IndexOutOfBoundsException("index > collection size");
int i = -1;
Iterator<T> iter = coll.iterator();
while (iter.hasNext())
{
i++;
T ret = iter.next();
if (i != index) continue;
iter.remove();
return ret;
}
return null;
}
// -------------------------------------------- //
// LE NICE RANDOM
// -------------------------------------------- //
public static <T> T random(Collection<T> coll)
{
if (coll.size() == 0) return null;
if (coll.size() == 1) return coll.iterator().next();
List<T> list = null;
if (coll instanceof List<?>)
{
list = (List<T>)coll;
}
else
{
list = new ArrayList<>(coll);
}
int index = MassiveCore.random.nextInt(list.size());
return list.get(index);
}
public static <T> List<T> randomSubset(Collection<T> coll, int count)
{
// Clean Input
if (count < 0) count = 0;
// Create Ret
List<T> ret = new ArrayList<>(coll);
while (ret.size() > count)
{
int index = MassiveCore.random.nextInt(ret.size());
ret.remove(index);
}
// Return Ret
return ret;
}
public static <E> List<E> random(List<E> list, int count)
{
// Create Ret
List<E> ret = new MassiveList<>();
// Empty
if (list.isEmpty()) return ret;
// Fill Ret
for (int i = 0; i < count; i++)
{
ret.add(MUtil.random(list));
}
// Return Ret
return ret;
}
// -------------------------------------------- //
// EQUALS
// -------------------------------------------- //
public static boolean equals(Object object1, Object object2)
{
if (object1 == null) return object2 == null;
if (object2 == null) return false;
return object1.equals(object2);
}
public static boolean equals(Object... objects)
{
if (objects == null) throw new NullPointerException("objects");
if (objects.length % 2 != 0) throw new IllegalArgumentException("objects length not even");
int index = 1;
while (index < objects.length)
{
Object object1 = objects[index - 1];
Object object2 = objects[index];
if ( ! equals(object1, object2)) return false;
index += 2;
}
return true;
}
// -------------------------------------------- //
// EQUALSISH
// -------------------------------------------- //
public static final double EQUALSISH_EPSILON = 0.0001;
public static boolean equalsishObject(Object o1, Object o2)
{
if (o1 instanceof Number && o2 instanceof Number)
{
return equalsishNumber((Number) o1, (Number) o2);
}
return equals(o1, o2);
}
public static boolean equalsishNumber(Number number1, Number number2)
{
if (number1 == null) return number2 == null;
if (number2 == null) return false;
return Math.abs(number1.doubleValue() - number2.doubleValue()) < EQUALSISH_EPSILON;
}
/**
* @deprecated use equalsishNumber
*/
@Deprecated
public static boolean equalsish(Number number1, Number number2)
{
return equalsishNumber(number1, number2);
}
// -------------------------------------------- //
// SET IF DIFFERENT
// -------------------------------------------- //
public static <T> boolean setIfDifferent(T value, Supplier<T> getter, Consumer<T> setter)
{
T currentVal = getter.get();
if (currentVal == value) return false;
setter.accept(value);
return true;
}
// -------------------------------------------- //
// SORTING
// -------------------------------------------- //
//http://stackoverflow.com/questions/2864840/treemap-sort-by-value
/*public static <K,V extends Comparable<? super V>> SortedSet<Map.Entry<K,V>> entriesSortedByValues(Map<K,V> map) {
SortedSet<Map.Entry<K,V>> sortedEntries = new TreeSet<Map.Entry<K,V>>(
new Comparator<Map.Entry<K,V>>() {
@Override public int compare(Map.Entry<K,V> e1, Map.Entry<K,V> e2) {
int res = e1.getValue().compareTo(e2.getValue());
return res != 0 ? res : 1; // Special fix to preserve items with equal values
}
}
);
sortedEntries.addAll(map.entrySet());
return sortedEntries;
}*/
// http://stackoverflow.com/questions/2864840/treemap-sort-by-value
public static <K,V extends Comparable<? super V>> SortedSet<Map.Entry<K,V>> entriesSortedByValues(Map<K,V> map)
{
return entriesSortedByValues(map, true);
}
public static <K,V extends Comparable<? super V>> SortedSet<Map.Entry<K,V>> entriesSortedByValues(Map<K,V> map, final boolean ascending)
{
SortedSet<Map.Entry<K,V>> sortedEntries = new TreeSet<>(
new Comparator<Map.Entry<K, V>>()
{
@Override
public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2)
{
int res;
if (ascending)
{
res = e1.getValue().compareTo(e2.getValue());
}
else
{
res = e2.getValue().compareTo(e1.getValue());
}
return res != 0 ? res : 1;
}
}
);
sortedEntries.addAll(map.entrySet());
return sortedEntries;
}
// -------------------------------------------- //
// MATH
// -------------------------------------------- //
public static <T extends Number> T limitNumber(T d, T min, T max)
{
if (d.doubleValue() < min.doubleValue())
{
return min;
}
if (d.doubleValue() > max.doubleValue())
{
return max;
}
return d;
}
public static long probabilityRound(double value)
{
long ret = (long) Math.floor(value);
double probability = value % 1;
if (MassiveCore.random.nextDouble() < probability) ret += 1;
return ret;
}
public static int probabilityRound(float value)
{
int ret = (int) Math.floor(value);
float probability = value % 1;
if (MassiveCore.random.nextFloat() < probability) ret += 1;
return ret;
}
public static double round(double value, int places)
{
if (places < 0) throw new IllegalArgumentException();
BigDecimal bd = new BigDecimal(value);
bd = bd.setScale(places, RoundingMode.HALF_UP);
return bd.doubleValue();
}
// -------------------------------------------- //
// PREDICATE
// -------------------------------------------- //
public static <T> Predicate<T> predicatesAnd(Predicate<? super T>... predicates)
{
List<Predicate<? super T>> predicateList = Arrays.asList(predicates); // Must be explicit this way
return predicatesAnd(predicateList);
}
public static <T> Predicate<T> predicatesAnd(Collection<Predicate<? super T>> predicates)
{
if (predicates.isEmpty()) throw new IllegalArgumentException("isEmpty");
PredicateAnd<T> predicate = new PredicateAnd<T>();
predicate.predicates = new MassiveList<>(predicates);
return predicate;
}
private static class PredicateAnd<T> implements Predicate<T>
{
private List<Predicate<? super T>> predicates;
@Override
public boolean test(T t)
{
for (Predicate<? super T> predicate : predicates)
{
if (predicate.test(t)) continue;
return false;
}
return true;
}
}
// -------------------------------------------- //
// EXTRACTION
// -------------------------------------------- //
protected static Map<Class<?>, Map<String, Set<Extractor>>> classesPropertiesExtractors = new HashMap<>();
protected static Map<String, Set<Extractor>> getPropertiesExtractors(Class<?> propertyClass)
{
classesPropertiesExtractors.computeIfAbsent(propertyClass, x -> new HashMap<>());
return classesPropertiesExtractors.get(propertyClass);
}
protected static Set<Extractor> getExtractors(Class<?> propertyClass, String propertyName)
{
Map<String, Set<Extractor>> propertiesExtractors = getPropertiesExtractors(propertyClass);
propertiesExtractors.computeIfAbsent(propertyName, x -> new HashSet<>());
return propertiesExtractors.get(propertyName);
}
@SuppressWarnings("unchecked")
public static <T> T extract(Class<T> propertyClass, String propertyName, Object o)
{
Object ret = null;
for (Extractor extractor : getExtractors(propertyClass, propertyName))
{
ret = extractor.extract(o);
if (ret != null) break;
}
return (T) ret;
}
public static <T> void registerExtractor(Class<T> clazz, String propertyName, Extractor extractor)
{
getExtractors(clazz, propertyName).add(extractor);
}
// -------------------------------------------- //
// STATIC CONSTRUCT
// -------------------------------------------- //
static
{
registerExtractor(World.class, "world", ExtractorWorld.get());
registerExtractor(String.class, "worldName", ExtractorWorldName.get());
// The accountId extractor is used for the money mixin.
registerExtractor(String.class, "accountId", ExtractorSenderId.get());
}
}
| [
"sarhatabaot1@gmail.com"
] | sarhatabaot1@gmail.com |
6f6f68d5a4f45c8084f462f5ded61d6d117f832a | f5617cc36ce109767083ad234e72064cdfd6b2ff | /src/main/java/datastructure/tree/binaryTree/BinaryTreeDemo.java | acd747240b061e6eef20af5d8d06ec336a22609a | [] | no_license | Songleen/algorithm | c63325311d80ebd3b6180b2897415e5c69f9b354 | 1ba4f413b94d72d3c43b3db5addf99f137837d52 | refs/heads/master | 2021-08-17T10:28:29.136587 | 2021-06-28T02:02:32 | 2021-06-28T02:02:32 | 207,781,902 | 0 | 0 | null | 2020-10-13T15:58:06 | 2019-09-11T10:08:26 | Java | UTF-8 | Java | false | false | 1,497 | java | package datastructure.tree.binaryTree;
/**
* @ClassName algorithm
* @Author Songleen
* @Date 2019/09/03/8:56
*/
public class BinaryTreeDemo {
public static void main(String[] args) {
// HeroNode root = new HeroNode(0, "0");
HeroNode node1 = new HeroNode(1, "1");
HeroNode node2 = new HeroNode(2, "2");
HeroNode node3 = new HeroNode(3, "3");
HeroNode node4 = new HeroNode(4, "4");
HeroNode node5 = new HeroNode(5, "5");
HeroNode node6 = new HeroNode(6, "6");
HeroNode node7 = new HeroNode(7, "7");
node1.setLeft(node2);
node1.setRight(node3);
node2.setLeft(node4);
node2.setRight(node5);
node3.setLeft(node6);
node3.setRight(node7);
BinaryTree tree = new BinaryTree(node1);
System.out.println("前序遍历");
tree.preOrder();
System.out.println("中序遍历");
tree.infixOrder();
System.out.println("后序遍历");
tree.postOrder();
System.out.println("前序查找");
HeroNode heroNode = tree.preSearch(3);
System.out.println(heroNode);
System.out.println("中序查找");
HeroNode heroNode1 = tree.infixSearch(3);
System.out.println(heroNode1);
System.out.println("后序查找");
HeroNode heroNode2 = tree.postSearch(3);
System.out.println(heroNode2);
System.out.println("删除指定节点");
tree.deleteNode(3);
}
}
| [
"sellee7092@163.com"
] | sellee7092@163.com |
616980aad12d164df7e2d721884cf9d8293d9b6f | 678cab849edfe4513cc0d9eb3d8fd23e86d63399 | /src/com/fls/main/core/Tiles/HoleTile.java | 7a753c1cec06523b780c1d0ee08c45e772785dc2 | [] | no_license | h2n0/NinjaGame | 3745ea8d28d7bd647062d34b8752cf1ed6407ad5 | 5a6bc6349a3a919041da9e21d605356a4c09c020 | refs/heads/master | 2020-12-24T13:53:13.987492 | 2013-09-19T15:21:32 | 2013-09-19T15:21:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 132 | java | package com.fls.main.core.Tiles;
public class HoleTile extends Tile {
public HoleTile() {
tex = 27;
}
}
| [
"elc954@hotmail.co.uk"
] | elc954@hotmail.co.uk |
d6daa8603c135f081dc68ecaf3a3fb96b818bb50 | 375cff773db5aa9f97492e6aa6a920152d3673c1 | /android/app/src/main/java/com/testreactnative/MainApplication.java | ad21b6260742715aca939ea13dfb09affe70b7ec | [] | no_license | RickGusG/testReactNative | 659156dae825a310d3bbdeea750ec3d082556821 | fdbeb1f51fb54f0ef4fff829699df225891afcec | refs/heads/main | 2023-06-28T11:57:55.815934 | 2021-08-03T07:06:33 | 2021-08-03T07:06:33 | 391,442,776 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,680 | java | package com.testreactnative;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*
* @param context
* @param reactInstanceManager
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.testreactnative.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
| [
"rigumiero@gmail.com"
] | rigumiero@gmail.com |
9e3d3fb6c5d94ad95954614a5643d416d22019d0 | c50c0ca434982487c98ca0e2310c2b0c632759c2 | /code/java/springstudy/src/main/java/com/as1124/spring/remote/http/SpringHttpInvokerClient.java | c82d0eacf0cd47c3d67ab326836fce38026624bd | [] | no_license | as1124/AS-1124 | 513c22814b188c8b532e6deb116089c59f8b50b6 | 98dcdcdfb77f7ffcdaa84c231b7362b14b6cd206 | refs/heads/master | 2022-12-24T22:03:15.489535 | 2021-03-21T10:25:46 | 2021-03-21T10:25:46 | 58,107,811 | 2 | 1 | null | 2022-12-16T14:50:14 | 2016-05-05T05:55:06 | Java | UTF-8 | Java | false | false | 1,926 | java | package com.as1124.spring.remote.http;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
import com.as1124.spring.web.model.IUserAction;
/**
* 模拟客户端调用 Spring-HTTP 远程服务; 值得注意的是:虽然是调用http服务,但是客户端却没有显示的
* 发送http请求进行处理,这就是Spring-HttpInvoker的特点,和RMI是类似的,关注使用而不关注底层网络交互细节
*
* @author As-1124 (mailto:as1124huang@gmail.com)
*/
public class SpringHttpInvokerClient {
@Autowired
private IUserAction serviceBean;
public static void main(String[] args) {
try (ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(
SpringHttpInvokerClient.class)) {
SpringHttpInvokerClient testClient = ctx.getBean(SpringHttpInvokerClient.class);
if (testClient != null) {
testClient.testSpringHttpInvoker();
}
IUserAction service = ctx.getBean(IUserAction.class);
if (service != null) {
System.out.println(service.findOne(0));
System.out.println(service.allUsers().get(1).getUserName());
}
}
}
@Bean("httpServiceBean")
public static HttpInvokerProxyFactoryBean createHttpFactoryBean() {
HttpInvokerProxyFactoryBean factoryBean = new HttpInvokerProxyFactoryBean();
factoryBean.setServiceInterface(IUserAction.class);
// 请求服务端获取 HTTP 服务端URL
factoryBean.setServiceUrl("http://localhost:8080/springstudy/userHttpService");
return factoryBean;
}
private void testSpringHttpInvoker() {
System.out.println(serviceBean.findOne(0));
System.out.println(serviceBean.allUsers().get(0).getUserName());
}
}
| [
"as1124huang@gmail.com"
] | as1124huang@gmail.com |
4f0c5fe0db1d734f78917f5d34ca29f928c7d90c | a7c5985daa35c9068221b1c416a04441c15a9631 | /team-frame/src/main/java/cn/moling/spacet/common/security/AjaxAuthenticationFailureHandler.java | 9bd47f011abdb766182ababf59dd97d0ff33bd8a | [] | no_license | zlk225/TeamSpacet | 5771805a71cf9a7c8f7b4d300c0f0a36e650048a | a616e7004a32e2e74aeb236aa40efd5b4fe5905e | refs/heads/master | 2022-06-23T19:54:43.023794 | 2019-06-11T08:57:42 | 2019-06-11T08:57:42 | 190,503,274 | 0 | 0 | null | 2022-06-21T01:14:05 | 2019-06-06T02:51:45 | Java | UTF-8 | Java | false | false | 1,075 | java | package cn.moling.spacet.common.security;
import cn.moling.spacet.common.enums.ResultEnum;
import cn.moling.spacet.utils.CommandResult;
import com.alibaba.fastjson.JSON;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @Auther: zhanglk
* @Date: 2019/5/30 11:45
* @Description: 用户登录失败时返回给前端的数据
*/
@Component
public class AjaxAuthenticationFailureHandler implements AuthenticationFailureHandler {
@Override
public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
httpServletResponse.getWriter().write(JSON.toJSONString(new CommandResult(ResultEnum.USER_LOGIN_FAILED)));
}
}
| [
"425859771@qq.com"
] | 425859771@qq.com |
23f484caebcebe8d6a69cf6fc18407797af163ae | 59e6dc1030446132fb451bd711d51afe0c222210 | /components/mediators/payloadFactory/org.wso2.carbon.mediator.payloadfactory.ui/4.2.0/src/main/java/org/wso2/carbon/mediator/payloadfactory/PayloadFactoryMediator.java | 6d7a87c657853cbe1defba5a83eba91ab2348051 | [] | no_license | Alsan/turing-chunk07 | 2f7470b72cc50a567241252e0bd4f27adc987d6e | e9e947718e3844c07361797bd52d3d1391d9fb5e | refs/heads/master | 2020-05-26T06:20:24.554039 | 2014-02-07T12:02:53 | 2014-02-07T12:02:53 | 38,284,349 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 11,113 | java | /*
* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.mediator.payloadfactory;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.util.AXIOMUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.config.xml.SynapseJsonPathFactory;
import org.apache.synapse.config.xml.SynapseXPathFactory;
import org.apache.synapse.config.xml.SynapseXPathSerializer;
import org.apache.synapse.config.xml.XMLConfigConstants;
import org.apache.synapse.util.xpath.SynapseJsonPath;
import org.apache.synapse.util.xpath.SynapseXPath;
import org.jaxen.JaxenException;
import org.wso2.carbon.mediator.service.MediatorException;
import org.wso2.carbon.mediator.service.ui.AbstractMediator;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class PayloadFactoryMediator extends AbstractMediator {
private static Log log = LogFactory.getLog(PayloadFactoryMediator.class);
private static final String PAYLOAD_FACTORY = "payloadFactory";
private static final String FORMAT = "format";
private static final String ARGS = "args";
private static final String ARG = "arg";
private static final String VALUE = "value";
private static final String EXPRESSION = "expression";
private static final String EVAL = "evaluator";
private static final String TYPE = "media-type";
private static final QName FORMAT_Q = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "format");
private static final QName ARGS_Q = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "args");
protected static final QName ATT_KEY = new QName("key");
protected static final QName ATT_EVAL = new QName("evaluator");
protected static final QName ATT_MEDIA = new QName("media-type");
private final String JSON_TYPE="json";
private final String XML_TYPE="xml";
private String format = null;
private String type = null;
private boolean dynamic = false;
private String formatKey = null;
private List<Argument> argumentList = new ArrayList<Argument>();
/// This the error private String evaluator = null;
public OMElement serialize(OMElement parent) {
OMElement payloadFactoryElem = fac.createOMElement(PAYLOAD_FACTORY, synNS);
if(type!=null){
payloadFactoryElem.addAttribute(fac.createOMAttribute(TYPE, nullNS,type));
}
saveTracingState(payloadFactoryElem, this);
if (!dynamic) {
if (format != null) {
try {
OMElement formatElem = fac.createOMElement(FORMAT, synNS);
if(type!=null && type.contains(JSON_TYPE)){
formatElem.setText(format);
} else{
formatElem.addChild(AXIOMUtil.stringToOM(format));
}
payloadFactoryElem.addChild(formatElem);
} catch (XMLStreamException e) {
handleException("Error while serializing payloadFactory mediator", e);
}
} else {
handleException("Invalid payloadFactory mediator, format is required");
}
} else {
if (formatKey != null) {
OMElement formatElem = fac.createOMElement(FORMAT, synNS);
formatElem.addAttribute(fac.createOMAttribute(
"key", nullNS, formatKey));
payloadFactoryElem.addChild(formatElem);
} else {
handleException("Invalid payloadFactory mediator, format is required");
}
}
if (argumentList != null && argumentList.size() > 0) {
OMElement argumentsElem = fac.createOMElement(ARGS, synNS);
for (Argument arg : argumentList) {
OMElement argElem = fac.createOMElement(ARG, synNS);
if (arg.getValue() != null) {
argElem.addAttribute(fac.createOMAttribute(VALUE, nullNS, arg.getValue()));
} else if (arg.getExpression() != null) {
SynapseXPathSerializer.serializeXPath(arg.getExpression(), argElem, EXPRESSION);
} else if(arg.getJsonPath()!=null){
argElem.addAttribute(fac.createOMAttribute(EXPRESSION, nullNS, arg.getJsonPath().getExpression()));
}
//error happens somewhere here
if (arg.getEvaluator() != null) {
argElem.addAttribute(fac.createOMAttribute(EVAL, nullNS, arg.getEvaluator()));
}
argumentsElem.addChild(argElem);
}
payloadFactoryElem.addChild(argumentsElem);
}
if (parent != null) {
parent.addChild(payloadFactoryElem);
}
return payloadFactoryElem;
}
public void build(OMElement elem) {
OMAttribute mediaType = elem.getAttribute(ATT_MEDIA);
if(mediaType!=null){
this.type=mediaType.getAttributeValue();
}
OMElement formatElem = elem.getFirstChildWithName(FORMAT_Q);
if (formatElem != null) {
OMAttribute n = formatElem.getAttribute(ATT_KEY);
if (n == null) {
if(type!=null && type.contains(JSON_TYPE)){
this.format = formatElem.getText();
} else{
this.format = formatElem.getFirstElement().toString();
}
} else {
this.formatKey = n.getAttributeValue();
this.dynamic = true;
}
} else {
handleException("format element of payloadFactoryMediator is required");
}
OMElement argumentsElem = elem.getFirstChildWithName(ARGS_Q);
if (argumentsElem != null) {
Iterator itr = argumentsElem.getChildElements();
while (itr.hasNext()) {
OMElement argElem = (OMElement) itr.next();
Argument arg = new Argument();
String attrValue;
if ((attrValue = argElem.getAttributeValue(ATT_VALUE)) != null) {
arg.setValue(attrValue);
argumentList.add(arg);
} else if ((attrValue = argElem.getAttributeValue(ATT_EXPRN)) != null) {
if (attrValue.trim().length() == 0) {
handleException("Attribute value for expression cannot be empty");
} else {
try {
String evaluator;
if((evaluator=argElem.getAttributeValue(ATT_EVAL))!=null && evaluator.contains(JSON_TYPE)){
arg.setEvaluator(evaluator);
arg.setJsonPath(SynapseJsonPathFactory.getSynapseJsonPath(attrValue));
argumentList.add(arg);
} else{
if(evaluator!=null && evaluator.equals(XML_TYPE)){
arg.setEvaluator(XML_TYPE);
}
arg.setExpression(SynapseXPathFactory.getSynapseXPath(argElem, ATT_EXPRN));
argumentList.add(arg);
}
} catch (JaxenException e) {
handleException("Invalid XPath expression for attribute expression : " +
attrValue, e);
}
}
} else {
handleException("Unsupported arg type or expression attribute required");
}
///argumentList.add(arg); values and args all get added to this.
// need to change this part of the cord.
}
}
// set its common attributes such as tracing etc
processAuditStatus(this, elem);
}
public boolean isDynamic() {
return dynamic;
}
public void setDynamic(boolean dynamic) {
this.dynamic = dynamic;
}
public String getFormatKey() {
return formatKey;
}
public void setFormatKey(String formatKey) {
this.formatKey = formatKey;
}
public String getFormat() {
return format;
}
public String getType(){
return type;
}
public void setType(String type){
this.type=type;
}
public void addArgument(Argument arg) {
argumentList.add(arg);
}
public List<Argument> getArgumentList() {
return argumentList;
}
public String getTagLocalName() {
return PAYLOAD_FACTORY;
}
public void setFormat(String format) {
this.format = format;
}
private void handleException(String msg) {
log.error(msg);
throw new MediatorException(msg);
}
private void handleException(String msg, Exception ex) {
log.error(msg, ex);
throw new MediatorException(msg + " Caused by " + ex.getMessage());
}
public static class Argument {
private String value;
private SynapseXPath expression;
private SynapseJsonPath jsonPath;
private String evaluator;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public SynapseXPath getExpression() {
return expression;
}
public void setExpression(SynapseXPath expression) {
this.expression = expression;
}
public SynapseJsonPath getJsonPath() {
return jsonPath;
}
public void setJsonPath(SynapseJsonPath jsonPath) {
this.jsonPath = jsonPath;
}
public String getEvaluator() {
return evaluator;
}
public void setEvaluator(String evaluator) {
this.evaluator = evaluator;
}
}
}
| [
"malaka@wso2.com"
] | malaka@wso2.com |
e58c0c3a17f3780edc9f2936c3f4bffc8665445e | 9d951651d15ae4b69ba38352d9e1c7920cdc2f0d | /conferences/src/main/java/com/hralievskyi/conferences/repository/ReportRepository.java | 839e7963167eda55cb885ad3144d87101d974c15 | [] | no_license | Gralevskyi/conferences_spring | e6a8fec048cee67c5755ca0e0fea3456ef0bb430 | 85daca69a48d615d4110a2543e39c18331942787 | refs/heads/master | 2023-03-11T09:57:20.312762 | 2021-02-27T22:05:39 | 2021-02-27T22:05:39 | 336,200,207 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,261 | java | package com.hralievskyi.conferences.repository;
import java.util.List;
import javax.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import com.hralievskyi.conferences.entity.Report;
public interface ReportRepository extends JpaRepository<Report, String> {
@Query(value = "SELECT t.* FROM reports t WHERE t.topic_en = ?1 OR t.topic_uk = ?1", nativeQuery = true)
Report findByTopic(String topic);
@Query(value = "SELECT t.* FROM reports t INNER JOIN event_reports et on t.id = et.report_id WHERE et.event_id = ?1", nativeQuery = true)
Iterable<Report> findByEventid(long id);
@Query(value = "SELECT t.* FROM reports t WHERE t.speaker is null", nativeQuery = true)
Iterable<Report> findFreeOfSpeaker();
@Query(value = "SELECT t.* FROM reports t LEFT JOIN event_reports et on t.id = et.report_id WHERE et.report_id is null", nativeQuery = true)
Iterable<Report> findFreeOfEvent();
@Query(value = "SELECT t.* FROM reports t LEFT JOIN event_reports et on t.id = et.report_id WHERE et.report_id is null AND t.speaker is not null and t.accepted = 1", nativeQuery = true)
List<Report> findAcceptedFreeOfEvent();
@Transactional
@Modifying
@Query(value = "UPDATE reports r SET r.accepted = 1 WHERE r.id IN (:reportId)", nativeQuery = true)
void setAccepted(@Param("reportId") List<Long> reportId);
@Transactional
@Modifying
@Query(value = "UPDATE reports r SET r.speaker = NULL WHERE r.id IN (:reportId)", nativeQuery = true)
void setSpeakerToNull(@Param("reportId") List<Long> reportId);
@Modifying
@Query(value = "UPDATE reports r SET r.accepted = ?1 WHERE r.topic_en = ?2 OR r.topic_uk = ?2", nativeQuery = true)
void setAccepted(boolean accepted, String localTopic);
@Modifying
@Query(value = "UPDATE reports r SET r.speaker = ?1 WHERE r.topic_en = ?2 OR r.topic_uk = ?2", nativeQuery = true)
void setSpeaker(long speakerId, String localTopic);
@Modifying
@Query(value = "UPDATE reports r SET r.speaker = NULL WHERE r.topic_en = ?1 OR r.topic_uk = ?1", nativeQuery = true)
void setSpeakerToNull(String localTopic);
}
| [
"ogralievskyi@gmail.com"
] | ogralievskyi@gmail.com |
d08191ad590e3395d052d3be8b41b5b7fb4f6962 | 6fbeb49a8035ac6cd40fb9424ee1b41a6560ef39 | /app/src/test/java/com/example/s522050/newsapp/ExampleUnitTest.java | 05a23a8f96d122100bee298526d9665422d36e2c | [] | no_license | rjsvkfdl91/NewsApp-New-version | f0521398fa5a3bf8a156bf3e83933b71803b1b6a | 0f7c1b05c4d68e3c59b69c78f51ca04470f5fd8e | refs/heads/master | 2021-08-19T11:50:32.994353 | 2017-11-26T03:30:22 | 2017-11-26T03:30:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 405 | java | package com.example.s522050.newsapp;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"s522050@nwmissouri.edu"
] | s522050@nwmissouri.edu |
963b3e57971bf841f7cd741c50385191989bf30b | 955114cc2d7eba22b8ec81c475476ec37d623991 | /MyWorks/cnooc/Xj_CNooc(fastmeeting)/Xj_CNooc/src/com/xj/cnooc/view/SettingActivity.java | 62d8c965662a822e610c29f782aa7f9435ce53d2 | [] | no_license | allencall1234/MyWorks | b7ecd8282c05c8de86902c5d79d90e9212e22788 | 7bdb99333f8994c7ceb36ac77bb42ce20f0e7d8c | refs/heads/master | 2016-08-12T06:19:51.097949 | 2016-01-27T09:08:28 | 2016-01-27T09:08:28 | 50,494,506 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,587 | java | package com.xj.cnooc.view;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.xj.cnooc.common.BaseActivity;
import com.xj.cnooc.common.CustomDialog;
import com.xj.cnooc.common.CustomSwitch;
import com.xj.cnooc.common.CustomSwitch.OnChangeListener;
/**
*
* @author Administrator 设置界面
*
*/
public class SettingActivity extends BaseActivity implements OnClickListener,
OnChangeListener {
private RelativeLayout rl_update_app;// 软件更新
private Button btn_exit;// 退出
// 标题
// private Button btn_back;
private ImageView iv_back;
private ImageView iv_setting;
private TextView tv_center_title;
private TextView tv_right_title;
// private Button btn_setting;
/**
* 辅助按钮开关,用于显示以及隐藏辅助按钮
* <p>
* add by zhulanting 2015/9/19
*/
private CustomSwitch mSwitch_float;
/**
* 新消息通知开关
*/
private CustomSwitch mSwitch_notification;
/**
* 声音提醒开关
*/
private CustomSwitch mSwitch_voice;
/**
* 震动提醒开关
*/
private CustomSwitch mSwitch_vibrate;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.setting_view);
initView();// 初始化界面
}
private void initView() {
rl_update_app = (RelativeLayout) findViewById(R.id.rl_update_app);
btn_exit = (Button) findViewById(R.id.btn_exit);
mSwitch_float = (CustomSwitch) findViewById(R.id.switch_float);
mSwitch_float.setChecked(mSettings.isEnableAssistive());
mSwitch_float.setOnChangeListener(this);
mSwitch_notification = (CustomSwitch) findViewById(R.id.switch_notification);
mSwitch_notification.setChecked(mSettings.isEnableNotification());
showOrHideView(mSettings.isEnableNotification());
mSwitch_notification.setOnChangeListener(this);
mSwitch_voice = (CustomSwitch) findViewById(R.id.switch_voice);
mSwitch_voice.setChecked(mSettings.isEnableVoice());
mSwitch_voice.setOnChangeListener(this);
mSwitch_vibrate = (CustomSwitch) findViewById(R.id.switch_vibrate);
mSwitch_vibrate.setChecked(mSettings.isEnableVirbrator());
mSwitch_vibrate.setOnChangeListener(this);
// btn_back = (Button) findViewById(R.id.btn_back);
iv_back = (ImageView) findViewById(R.id.iv_back);
iv_setting = (ImageView) findViewById(R.id.iv_setting);
tv_center_title = (TextView) findViewById(R.id.tv_center_title);
tv_right_title = (TextView) findViewById(R.id.tv_right_title);
// btn_setting = (Button) findViewById(R.id.btn_setting);
tv_center_title.setText("设置");
tv_right_title.setVisibility(View.GONE);
iv_setting.setVisibility(View.GONE);
iv_back.setOnClickListener(this);
// 软件更新监听
rl_update_app.setOnClickListener(this);
// 退出
btn_exit.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.iv_back:
finish();
break;
case R.id.rl_update_app:// 在线更新
// UmengUpdateAgent.update(this);
showToast("当前软件已更新到最新版本!");
break;
case R.id.btn_exit:// 退出
CustomDialog dialog = new CustomDialog(SettingActivity.this,
R.style.mystyle, R.layout.customdialog);
dialog.show();
break;
default:
break;
}
}
// add by zhulanting 2015/9/19
@Override
public void onChanged(CustomSwitch mSwitch, boolean checkState) {
// TODO Auto-generated method stub
switch (mSwitch.getId()) {
case R.id.switch_float:
if (checkState) {
mTouchView.showView();
} else {
mTouchView.removeView();
}
mSettings.setEnableAssistive(checkState);
break;
case R.id.switch_notification:
showOrHideView(checkState);
mSettings.setEnableNotificaction(checkState);
break;
case R.id.switch_voice:
mSettings.setEnableVoice(checkState);
break;
case R.id.switch_vibrate:
mSettings.setEnableVibrator(checkState);
break;
default:
break;
}
}
private void showOrHideView(boolean checkState) {
// TODO Auto-generated method stub
findViewById(R.id.rl_switch_voice).setVisibility(
checkState ? View.VISIBLE : View.GONE);
findViewById(R.id.rl_switch_vibrate).setVisibility(
checkState ? View.VISIBLE : View.GONE);
findViewById(R.id.view1).setVisibility(
checkState ? View.VISIBLE : View.GONE);
findViewById(R.id.view2).setVisibility(
checkState ? View.VISIBLE : View.GONE);
}
}
| [
"809832192@163.com"
] | 809832192@163.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.