blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
sequence | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
sequence | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
55df85d741c26974d799e69fb30af71a5b334240 | 3,246,995,291,467 | 1fc0f91d24051780b3fad446cd41d1a43d807355 | /src/menu/battle/helper/StatID.java | a2d57db822ee470121241c6cfc40c545560003c0 | [] | no_license | farandbeyond/GeorgianRPGInnov8 | https://github.com/farandbeyond/GeorgianRPGInnov8 | cc6d90cce1dbff2f92e411706e23249a5db5f9cc | 97697b3cd0a64fb3507049cff3ca5879bb570cae | refs/heads/master | 2016-09-12T15:30:00.476000 | 2016-05-19T20:11:27 | 2016-05-19T20:11:27 | 59,239,136 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* 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 menu.battle.helper;
/**
*
* @author Connor
*/
public class StatID {
public static final int
STRENGTH=0,
DEXTERITY=1,
VITALITY=2,
INTELLIGENCE=3,
RESISTANCE=4,
HP=6,
MAXHP=7,
MP=8,
MAXMP=9;
public static int retrieveStat(BattleEntity e, int stat){
switch(stat){
case 0:return e.getStr();
case 1:return e.getDex();
case 2:return e.getVit();
case 3:return e.getInt();
case 4:return e.getRes();
case 6:return e.getHp();
case 7:return e.getMaxHp();
case 8:return e.getMp();
case 9:return e.getMaxMp();
}
return 0;
}
public static String getStatName(int stat){
switch(stat){
case STRENGTH:return "Strength";
case DEXTERITY:return "Dexterity";
case VITALITY:return "Vitality";
case INTELLIGENCE:return "Intelligence";
case RESISTANCE:return "Resistance";
case HP:return "HP";
case MAXHP:return "Max HP";
case MP:return "MP";
case MAXMP:return "Max MP";
}
return "null";
}
}
| UTF-8 | Java | 1,469 | java | StatID.java | Java | [
{
"context": " */\npackage menu.battle.helper;\n\n/**\n *\n * @author Connor\n */\npublic class StatID {\n public static final",
"end": 238,
"score": 0.998465359210968,
"start": 232,
"tag": "NAME",
"value": "Connor"
}
] | null | [] | /*
* 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 menu.battle.helper;
/**
*
* @author Connor
*/
public class StatID {
public static final int
STRENGTH=0,
DEXTERITY=1,
VITALITY=2,
INTELLIGENCE=3,
RESISTANCE=4,
HP=6,
MAXHP=7,
MP=8,
MAXMP=9;
public static int retrieveStat(BattleEntity e, int stat){
switch(stat){
case 0:return e.getStr();
case 1:return e.getDex();
case 2:return e.getVit();
case 3:return e.getInt();
case 4:return e.getRes();
case 6:return e.getHp();
case 7:return e.getMaxHp();
case 8:return e.getMp();
case 9:return e.getMaxMp();
}
return 0;
}
public static String getStatName(int stat){
switch(stat){
case STRENGTH:return "Strength";
case DEXTERITY:return "Dexterity";
case VITALITY:return "Vitality";
case INTELLIGENCE:return "Intelligence";
case RESISTANCE:return "Resistance";
case HP:return "HP";
case MAXHP:return "Max HP";
case MP:return "MP";
case MAXMP:return "Max MP";
}
return "null";
}
}
| 1,469 | 0.52757 | 0.514636 | 52 | 27.25 | 17.570599 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.653846 | false | false | 15 |
b4db77c628e0189b1c3c787a23a4000cdacf658a | 3,246,995,293,295 | 1b3ab3e554f80a48ac24673fbb9c24384f08341a | /src/test/java/automtionPractice/pageFactory/pages/AddressPage.java | b485744484a1903fe72d882971ceecca8c46541d | [] | no_license | paulajofre/AutomationPractice | https://github.com/paulajofre/AutomationPractice | 425ba7438a358df54c5a2f69a24c13e3c892053b | f4d672d10c4b0fd497e00c04ddc8b228e68f3d5a | refs/heads/master | 2021-06-26T03:23:32.906000 | 2019-12-03T23:26:28 | 2019-12-03T23:26:28 | 215,414,579 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package automtionPractice.pageFactory.pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class AddressPage {
WebDriver driver;
@FindBy(xpath = "//*[@id=\"center_column\"]/form/p/button/span")
WebElement getBtnProceedToCheckoutAddress;
public AddressPage(WebDriver driver){
this.driver = driver;
PageFactory.initElements(driver, this);
}
public String getOrderAddressPageTitle(){
return driver.getTitle();
}
public void setGetBtnProceedToCheckoutAddress(){
getBtnProceedToCheckoutAddress.click();
}
public void clickProceedOnAddress(){
this.setGetBtnProceedToCheckoutAddress();
}
}
| UTF-8 | Java | 835 | java | AddressPage.java | Java | [] | null | [] | package automtionPractice.pageFactory.pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class AddressPage {
WebDriver driver;
@FindBy(xpath = "//*[@id=\"center_column\"]/form/p/button/span")
WebElement getBtnProceedToCheckoutAddress;
public AddressPage(WebDriver driver){
this.driver = driver;
PageFactory.initElements(driver, this);
}
public String getOrderAddressPageTitle(){
return driver.getTitle();
}
public void setGetBtnProceedToCheckoutAddress(){
getBtnProceedToCheckoutAddress.click();
}
public void clickProceedOnAddress(){
this.setGetBtnProceedToCheckoutAddress();
}
}
| 835 | 0.697006 | 0.697006 | 31 | 24.935484 | 21.375196 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.419355 | false | false | 15 |
ffc63feb7388ad83f38376cc57c6d390c57e5ed4 | 22,376,779,625,092 | 09df00d1aedb9454a92b821d29d484b131ef3a22 | /OOP/src/biljniIZivotinjskiSvijet/Deva.java | 47db0498fc426d382575d73a1d526b47e65aa913 | [] | no_license | Josip-github/OOP | https://github.com/Josip-github/OOP | bed9c807655fbca20aa51309ae5b3c927f54441f | 7cc9b862e1c9d067d08d019c36c3b2d5b1762b12 | refs/heads/master | 2023-07-08T03:36:21.720000 | 2021-08-05T06:16:31 | 2021-08-05T06:16:31 | 383,153,295 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package biljniIZivotinjskiSvijet;
public class Deva extends Sisavac {
private int velicina;
private String boja;
public Deva() {
// TODO Auto-generated constructor stub
}
public Deva(boolean rast, boolean razmnozavanje, boolean probavniSustav, boolean pokretljivost2,
boolean imaKraljeznicu, String okolis, boolean zubi, String hranjenjePodmlatka, int velicina, String boja) {
super(rast, razmnozavanje, probavniSustav, pokretljivost2, imaKraljeznicu, okolis, zubi,
hranjenjePodmlatka);
this.velicina = velicina;
this.boja = boja;
}
public int getVelicina() {
return velicina;
}
public void setVelicina(int velicina) {
this.velicina = velicina;
}
public String getBoja() {
return boja;
}
public void setBoja(String boja) {
this.boja = boja;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return "Deva - Veličina u m: " + this.getVelicina() + "; boja: " + this.getBoja()
+ ";\nhrani podmladak " + super.getHranjenjePodmlatka() + "; ima zube: " + super.isZubi()
+ ";\nokoliš: " + super.getOkolis() + ", ima kralježnicu: " + super.isImaKraljeznicu()
+ ";\nima probavni sustav: " + super.isProbavniSustav() + ", kreće se: " + super.isPokretljivost()
+ ";\nraste: " + super.isRast() + ", razmnožava se: " + super.isRazmnozavanje();
}
}
| WINDOWS-1250 | Java | 1,326 | java | Deva.java | Java | [] | null | [] | package biljniIZivotinjskiSvijet;
public class Deva extends Sisavac {
private int velicina;
private String boja;
public Deva() {
// TODO Auto-generated constructor stub
}
public Deva(boolean rast, boolean razmnozavanje, boolean probavniSustav, boolean pokretljivost2,
boolean imaKraljeznicu, String okolis, boolean zubi, String hranjenjePodmlatka, int velicina, String boja) {
super(rast, razmnozavanje, probavniSustav, pokretljivost2, imaKraljeznicu, okolis, zubi,
hranjenjePodmlatka);
this.velicina = velicina;
this.boja = boja;
}
public int getVelicina() {
return velicina;
}
public void setVelicina(int velicina) {
this.velicina = velicina;
}
public String getBoja() {
return boja;
}
public void setBoja(String boja) {
this.boja = boja;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return "Deva - Veličina u m: " + this.getVelicina() + "; boja: " + this.getBoja()
+ ";\nhrani podmladak " + super.getHranjenjePodmlatka() + "; ima zube: " + super.isZubi()
+ ";\nokoliš: " + super.getOkolis() + ", ima kralježnicu: " + super.isImaKraljeznicu()
+ ";\nima probavni sustav: " + super.isProbavniSustav() + ", kreće se: " + super.isPokretljivost()
+ ";\nraste: " + super.isRast() + ", razmnožava se: " + super.isRazmnozavanje();
}
}
| 1,326 | 0.697956 | 0.696442 | 46 | 27.717392 | 32.626118 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.934783 | false | false | 15 |
1500afad2e4e8794a56be2d24d0cb9bb2dfadb21 | 10,642,928,968,735 | 8b77e7f05bbe13315e60e98ebe38136616fad910 | /bikesharing-backend/src/main/java/com/godeltech/bikesharing/service/RentService.java | c84e9ce0cc681878d2f1a26b24b5ada709f2cb7e | [] | no_license | DzmitryKravchuk/bikesharing | https://github.com/DzmitryKravchuk/bikesharing | c480a28074d2dd45a33223f67fd92e54138e3acc | 35a211dbda99d9093718837c19ea3ecb14427975 | refs/heads/master | 2023-07-28T05:47:29.700000 | 2021-08-05T13:28:28 | 2021-08-05T13:28:28 | 383,834,535 | 1 | 1 | null | false | 2021-08-05T08:34:42 | 2021-07-07T14:54:29 | 2021-07-09T07:14:03 | 2021-08-05T08:34:41 | 398 | 1 | 1 | 0 | Java | false | false | package com.godeltech.bikesharing.service;
import com.godeltech.bikesharing.models.RentOperationModel;
import java.util.List;
public interface RentService {
RentOperationModel startRentOperation(RentOperationModel model);
RentOperationModel getByEquipmentItemRegistrationNumberAndRentStatusCode(String registrationNumber, String code);
RentOperationModel finishRentOperation(RentOperationModel rentOperation, Long id);
RentOperationModel getById(Long id);
List<RentOperationModel> getAllByStatusCode(String statusCode);
}
| UTF-8 | Java | 538 | java | RentService.java | Java | [] | null | [] | package com.godeltech.bikesharing.service;
import com.godeltech.bikesharing.models.RentOperationModel;
import java.util.List;
public interface RentService {
RentOperationModel startRentOperation(RentOperationModel model);
RentOperationModel getByEquipmentItemRegistrationNumberAndRentStatusCode(String registrationNumber, String code);
RentOperationModel finishRentOperation(RentOperationModel rentOperation, Long id);
RentOperationModel getById(Long id);
List<RentOperationModel> getAllByStatusCode(String statusCode);
}
| 538 | 0.85316 | 0.85316 | 16 | 32.625 | 35.271935 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625 | false | false | 15 |
1e8b099924fd65f23f6cc4499f76ddece70c5af7 | 10,892,037,129,068 | 5b61f39629ca8dee89ee58f65d55bc49fbd45037 | /app/src/main/java/com/ajax/pinchzoomdemo/PinchImageView.java | 7b14ed7b0913868b2fee3d07c511318b1479b33a | [] | no_license | lesliebeijing/PinchImageView | https://github.com/lesliebeijing/PinchImageView | eedbaf104e95c6cdeed2b3d579ef06ce644e517e | c8feb44cbbe7cb58f6c3746d281dca048e501166 | refs/heads/master | 2018-11-02T05:37:16.777000 | 2015-10-21T02:53:19 | 2015-10-21T02:53:19 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ajax.pinchzoomdemo;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
/**
* Created by Administrator on 2015/10/21.
*/
public class PinchImageView extends ImageView {
private int mode = 0;
private static final int MODE_DRAG = 1;
private static final int MODE_ZOOM = 2;
private PointF startPoint = new PointF();
private Matrix matrix = new Matrix();
private Matrix currentMatrix = new Matrix();
private Matrix startMatrix = new Matrix();
private GestureDetector mGestureDetector;
private float startHeight;
private float startWidth;
private float startDis;
private PointF midPoint;
public PinchImageView(Context context, AttributeSet attrs) {
super(context, attrs);
MatrixTouchListener mListener = new MatrixTouchListener();
setOnTouchListener(mListener);
mGestureDetector = new GestureDetector(getContext(), new GestureListener(mListener));
}
public class MatrixTouchListener implements OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
mode = MODE_DRAG;
startMatrix = getMatrix();
currentMatrix.set(getImageMatrix());
startPoint.set(event.getX(), event.getY());
startHeight = getMeasuredHeight();
startWidth = getMeasuredWidth();
break;
case MotionEvent.ACTION_MOVE:
if (mode == MODE_DRAG) {
float dx = event.getX() - startPoint.x;
float dy = event.getY() - startPoint.y;
matrix.set(currentMatrix);
matrix.postTranslate(dx, dy);
} else if (mode == MODE_ZOOM) {
float endDis = distance(event);
if (endDis > 10f) {
float scale = endDis / startDis;
matrix.set(currentMatrix);
matrix.postScale(scale, scale, midPoint.x, midPoint.y);
}
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
mode = 0;
break;
case MotionEvent.ACTION_POINTER_DOWN:
mode = MODE_ZOOM;
startDis = distance(event);
if (startDis > 10f) {
midPoint = mid(event);
currentMatrix.set(getImageMatrix());
}
break;
}
setImageMatrix(matrix);
return mGestureDetector.onTouchEvent(event);
}
private float distance(MotionEvent event) {
float dx = event.getX(1) - event.getX(0);
float dy = event.getY(1) - event.getY(0);
return (float) Math.sqrt(dx * dx + dy * dy);
}
private PointF mid(MotionEvent event) {
float midX = (event.getX(1) + event.getX(0)) / 2;
float midY = (event.getY(1) + event.getY(0)) / 2;
return new PointF(midX, midY);
}
//FIXME 判定缩放扩大和移动后进行还原
public void onDoubleClick() {
float scale = 1;
if (startMatrix != null) {
currentMatrix.set(startMatrix);
currentMatrix.postScale(scale, scale, startWidth, startHeight);
setImageMatrix(currentMatrix);
}
}
}
private class GestureListener extends GestureDetector.SimpleOnGestureListener {
private final MatrixTouchListener listener;
public GestureListener(MatrixTouchListener listener) {
this.listener = listener;
}
@Override
public boolean onDown(MotionEvent e) { //捕获Down事件
return true;
}
@Override
public boolean onDoubleTap(MotionEvent e) { //触发双击事件
listener.onDoubleClick();
return true;
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return super.onSingleTapUp(e);
}
@Override
public void onLongPress(MotionEvent e) {
super.onLongPress(e);
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return super.onScroll(e1, e2, distanceX,
distanceY);
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return super.onFling(e1, e2, velocityX, velocityY);
}
@Override
public void onShowPress(MotionEvent e) {
super.onShowPress(e);
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
return super.onDoubleTapEvent(e);
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
return super.onSingleTapConfirmed(e);
}
}
}
| UTF-8 | Java | 5,514 | java | PinchImageView.java | Java | [] | null | [] | package com.ajax.pinchzoomdemo;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
/**
* Created by Administrator on 2015/10/21.
*/
public class PinchImageView extends ImageView {
private int mode = 0;
private static final int MODE_DRAG = 1;
private static final int MODE_ZOOM = 2;
private PointF startPoint = new PointF();
private Matrix matrix = new Matrix();
private Matrix currentMatrix = new Matrix();
private Matrix startMatrix = new Matrix();
private GestureDetector mGestureDetector;
private float startHeight;
private float startWidth;
private float startDis;
private PointF midPoint;
public PinchImageView(Context context, AttributeSet attrs) {
super(context, attrs);
MatrixTouchListener mListener = new MatrixTouchListener();
setOnTouchListener(mListener);
mGestureDetector = new GestureDetector(getContext(), new GestureListener(mListener));
}
public class MatrixTouchListener implements OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
mode = MODE_DRAG;
startMatrix = getMatrix();
currentMatrix.set(getImageMatrix());
startPoint.set(event.getX(), event.getY());
startHeight = getMeasuredHeight();
startWidth = getMeasuredWidth();
break;
case MotionEvent.ACTION_MOVE:
if (mode == MODE_DRAG) {
float dx = event.getX() - startPoint.x;
float dy = event.getY() - startPoint.y;
matrix.set(currentMatrix);
matrix.postTranslate(dx, dy);
} else if (mode == MODE_ZOOM) {
float endDis = distance(event);
if (endDis > 10f) {
float scale = endDis / startDis;
matrix.set(currentMatrix);
matrix.postScale(scale, scale, midPoint.x, midPoint.y);
}
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
mode = 0;
break;
case MotionEvent.ACTION_POINTER_DOWN:
mode = MODE_ZOOM;
startDis = distance(event);
if (startDis > 10f) {
midPoint = mid(event);
currentMatrix.set(getImageMatrix());
}
break;
}
setImageMatrix(matrix);
return mGestureDetector.onTouchEvent(event);
}
private float distance(MotionEvent event) {
float dx = event.getX(1) - event.getX(0);
float dy = event.getY(1) - event.getY(0);
return (float) Math.sqrt(dx * dx + dy * dy);
}
private PointF mid(MotionEvent event) {
float midX = (event.getX(1) + event.getX(0)) / 2;
float midY = (event.getY(1) + event.getY(0)) / 2;
return new PointF(midX, midY);
}
//FIXME 判定缩放扩大和移动后进行还原
public void onDoubleClick() {
float scale = 1;
if (startMatrix != null) {
currentMatrix.set(startMatrix);
currentMatrix.postScale(scale, scale, startWidth, startHeight);
setImageMatrix(currentMatrix);
}
}
}
private class GestureListener extends GestureDetector.SimpleOnGestureListener {
private final MatrixTouchListener listener;
public GestureListener(MatrixTouchListener listener) {
this.listener = listener;
}
@Override
public boolean onDown(MotionEvent e) { //捕获Down事件
return true;
}
@Override
public boolean onDoubleTap(MotionEvent e) { //触发双击事件
listener.onDoubleClick();
return true;
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return super.onSingleTapUp(e);
}
@Override
public void onLongPress(MotionEvent e) {
super.onLongPress(e);
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return super.onScroll(e1, e2, distanceX,
distanceY);
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return super.onFling(e1, e2, velocityX, velocityY);
}
@Override
public void onShowPress(MotionEvent e) {
super.onShowPress(e);
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
return super.onDoubleTapEvent(e);
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
return super.onSingleTapConfirmed(e);
}
}
}
| 5,514 | 0.556348 | 0.549945 | 160 | 33.162498 | 23.189676 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.60625 | false | false | 15 |
0aa023c3cf0475ece3b37ed4dede6b9f417029b7 | 1,563,368,130,956 | 6ce546ef0a86442bb80dc84bcb97be5477984d47 | /src/main/java/DateUtils.java | 2a4ded70beccbde66a2179335fafcff8be915af6 | [] | no_license | wangyongsen/testOrderCost | https://github.com/wangyongsen/testOrderCost | 12b9ccca20b323b986527c4353024b1666aaef25 | 4c9e1a5f5d8261b1bd01cd09de0d2c178d37cf20 | refs/heads/master | 2021-07-09T00:07:34.275000 | 2017-10-09T06:55:28 | 2017-10-09T06:55:28 | 106,242,210 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
/**
* @author LiuMingMing
* 2015年8月7日 下午12:54:19
* Version 1.0
*/
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
private static String[] parsePatterns = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
/**
* 默认格式"yyyy-MM-dd HH:mm:ss"
*
* @return
* @throws ParseException
*/
public static Date parse(String date) throws ParseException {
return new SimpleDateFormat(DateFormatEnum.DATETIME.value()).parse(date);
}
/**
* 指定格式format日期
*
* @return
* @throws ParseException
*/
public static Date parse(String date, DateFormatEnum df) throws ParseException {
return new SimpleDateFormat(df.value()).parse(date);
}
/**
* 默认格式"yyyy-MM-dd HH:mm:ss"
*
* @return
* @throws ParseException
*/
public static Timestamp parseTimestamp(String date) throws ParseException {
return Timestamp.valueOf(date);
}
/**
* 默认格式"yyyy-MM-dd HH:mm:ss"
*
* @return
* @throws ParseException
*/
public static String format(String date) throws ParseException {
return new SimpleDateFormat(DateFormatEnum.DATETIME.value()).format(parse(date));
}
/**
* 格式化日期,保留年份时分
*
* @param dateStr
* @return
* @throws Exception
*/
public static String formatShort(String dateStr) {
if (StringUtils.isNotEmpty(dateStr)) {
try {
int cYear = Calendar.getInstance().get(Calendar.YEAR);
Date date = DateUtils.parse(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int inYear = calendar.get(Calendar.YEAR);
if (cYear != inYear) {
String cyTime = "yyyy-MM-dd HH:mm";
dateStr = new SimpleDateFormat(cyTime).format(date);
} else {
String cTime = "MM-dd HH:mm";
dateStr = new SimpleDateFormat(cTime).format(date);
}
} catch (ParseException e) {
}
}
return dateStr;
}
/**
* 指定格式format日期
*
* @return
* @throws ParseException
*/
public static String format(String date, DateFormatEnum df) throws ParseException {
return new SimpleDateFormat(df.value()).format(parse(date, df));
}
/**
* 默认格式"yyyy-MM-dd HH:mm:ss"
*
* @return
* @throws ParseException
*/
public static String format(Date date) throws ParseException {
return new SimpleDateFormat(DateFormatEnum.DATETIME.value()).format(date);
}
/**
* 指定格式format日期
*
* @return
* @throws ParseException
*/
public static String format(Date date, DateFormatEnum df) throws ParseException {
return new SimpleDateFormat(df.value()).format(date);
}
public static String convert(java.sql.Date date) {
return new SimpleDateFormat(DateFormatEnum.DATE.value()).format(date);
}
public static String convert(java.sql.Time time) {
return new SimpleDateFormat(DateFormatEnum.DATETIME.value()).format(time);
}
public static String convert(Timestamp timestamp) {
return new SimpleDateFormat(DateFormatEnum.TIMESTAMP.value()).format(timestamp);
}
public static Date now() {
return Calendar.getInstance(Locale.getDefault()).getTime();
}
public static String now(DateFormatEnum df) throws ParseException {
return format(now(), df != null ? df : DateFormatEnum.DEFAULT);
}
public static java.sql.Date curDate() {
return new java.sql.Date(Calendar.getInstance(Locale.getDefault()).getTimeInMillis());
}
public static Timestamp curTimeStamp() {
return new Timestamp(Calendar.getInstance(Locale.getDefault()).getTimeInMillis());
}
///////////////////////////
/**
* 得到当前日期字符串 格式(yyyy-MM-dd)
*/
public static String getDate() {
return getDate(DateFormatEnum.DATE.value());
}
/**
* 得到当前日期字符串 格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E"
*/
public static String getDate(String pattern) {
return DateFormatUtils.format(new Date(), pattern);
}
/**
* 得到日期字符串 默认格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E"
*/
public static String formatDate(Date date, Object... pattern) {
String formatDate = null;
if (pattern != null && pattern.length > 0) {
formatDate = DateFormatUtils.format(date, pattern[0].toString());
} else {
formatDate = DateFormatUtils.format(date, DateFormatEnum.DATE.value());
}
return formatDate;
}
/**
* 得到日期时间字符串,转换格式(yyyy-MM-dd HH:mm:ss)
*/
public static String formatDateTime(Date date) {
return formatDate(date, DateFormatEnum.DATETIME.value());
}
/**
* 得到当前时间字符串 格式(HH:mm:ss)
*/
public static String getTime() {
return formatDate(new Date(), DateFormatEnum.TIME.value());
}
/**
* 得到当前日期和时间字符串 格式(yyyy-MM-dd HH:mm:ss)
*/
public static String getDateTime() {
return formatDate(new Date(), DateFormatEnum.DATETIME.value());
}
/**
* 得到当前年份字符串 格式(yyyy)
*/
public static String getYear() {
return formatDate(new Date(), DateFormatEnum.YEAR.value());
}
/**
* 得到当前月份字符串 格式(MM)
*/
public static String getMonth() {
return formatDate(new Date(), DateFormatEnum.MONTH.value());
}
/**
* 得到当天字符串 格式(dd)
*/
public static String getDay() {
return formatDate(new Date(), DateFormatEnum.DAY.value());
}
/**
* 得到当前星期字符串 格式(E)星期几
*/
public static String getWeek() {
return formatDate(new Date(), DateFormatEnum.WEEK.value());
}
/**
* 日期型字符串转化为日期 格式
* { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm",
* "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm",
* "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm" }
*/
public static Date parseDate(Object str) {
if (str == null) {
return null;
}
try {
return parseDate(str.toString(), parsePatterns);
} catch (ParseException e) {
return null;
}
}
/**
* 获取过去的天数
*
* @param date
* @return
*/
public static long pastDays(Date date) {
long t = new Date().getTime() - date.getTime();
return t / (24 * 60 * 60 * 1000);
}
/**
* 获取过去的小时
*
* @param date
* @return
*/
public static long pastHour(Date date) {
long t = new Date().getTime() - date.getTime();
return t / (60 * 60 * 1000);
}
/**
* 获取过去的分钟
*
* @param date
* @return
*/
public static long pastMinutes(Date date) {
long t = new Date().getTime() - date.getTime();
return t / (60 * 1000);
}
/**
* 转换为时间(天,时:分:秒.毫秒)
*
* @param timeMillis
* @return
*/
public static String formatDateTime(long timeMillis) {
long day = timeMillis / (24 * 60 * 60 * 1000);
long hour = (timeMillis / (60 * 60 * 1000) - day * 24);
long min = ((timeMillis / (60 * 1000)) - day * 24 * 60 - hour * 60);
long s = (timeMillis / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
long sss = (timeMillis - day * 24 * 60 * 60 * 1000 - hour * 60 * 60 * 1000 - min * 60 * 1000 - s * 1000);
return (day > 0 ? day + "," : "") + hour + ":" + min + ":" + s + "." + sss;
}
/**
* 获取两个日期之间的天数
*
* @param before
* @param after
* @return
*/
public static double getDistanceOfTwoDate(Date before, Date after) {
long beforeTime = before.getTime();
long afterTime = after.getTime();
return (afterTime - beforeTime) / (1000 * 60 * 60 * 24);
}
public static Date getBeginDayOfMonth(Date day){
Calendar c1=Calendar.getInstance();
c1.setTime(day);
c1.set(Calendar.DATE,1);
c1.set(Calendar.HOUR,0);
c1.set(Calendar.MINUTE,0);
c1.set(Calendar.SECOND,0);
c1.set(Calendar.MILLISECOND,0);
return c1.getTime();
}
public static Date getEndDayOfMonth(Date day){
Date beginDay=getBeginDayOfMonth(day);
Calendar c1=Calendar.getInstance();
c1.setTime(beginDay);
c1.add(Calendar.MONTH,1);
return c1.getTime();
}
/**
* 获取横跨月度数
* @param date1
* @param date2
* @return
* @throws ParseException
*/
public static int getSpanMonths(String date1,String date2,String pattern) throws ParseException {
SimpleDateFormat sdf=new SimpleDateFormat(pattern);
Calendar c1=Calendar.getInstance();
Calendar c2=Calendar.getInstance();
c1.setTime(sdf.parse(date1));
c2.setTime(sdf.parse(date2));
int year =c2.get(Calendar.YEAR)-c1.get(Calendar.YEAR);
//开始日期若小月结束日期
if(year<0){
year=-year;
return year*12+c1.get(Calendar.MONTH)-c2.get(Calendar.MONTH)+1;
}
return year*12+c2.get(Calendar.MONTH)-c1.get(Calendar.MONTH)+1;
}
/**
* 获取日期之间的天数
*
* @param d1
* @param d2
* @return
*/
public static int getDaysBetween(Calendar d1, Calendar d2) {
if (d1.after(d2)) { // swap dates so that d1 is start and d2 is end
Calendar swap = d1;
d1 = d2;
d2 = swap;
}
int days = d2.get(Calendar.DAY_OF_YEAR)
- d1.get(Calendar.DAY_OF_YEAR);
int y2 = d2.get(Calendar.YEAR);
if (d1.get(Calendar.YEAR) != y2) {
d1 = (Calendar) d1.clone();
do {
days += d1.getActualMaximum(Calendar.DAY_OF_YEAR);
d1.add(Calendar.YEAR, 1);
} while (d1.get(Calendar.YEAR) != y2);
}
return days;
}
/**
* 获取工作日
*
* @param d1
* @param d2
* @return
*/
public static int getWorkingDay(Calendar d1, Calendar d2) {
int result = -1;
if (d1.after(d2)) { // swap dates so that d1 is start and d2 is end
Calendar swap = d1;
d1 = d2;
d2 = swap;
}
int charge_start_date = 0;// 开始日期的日期偏移量
int charge_end_date = 0;// 结束日期的日期偏移量
// 日期不在同一个日期内
int stmp;
int etmp;
stmp = 7 - d1.get(Calendar.DAY_OF_WEEK);
etmp = 7 - d2.get(Calendar.DAY_OF_WEEK);
if (stmp != 0 && stmp != 6) {// 开始日期为星期六和星期日时偏移量为0
charge_start_date = stmp - 1;
}
if (etmp != 0 && etmp != 6) {// 结束日期为星期六和星期日时偏移量为0
charge_end_date = etmp - 1;
}
// }
result = (getDaysBetween(getNextMonday(d1), getNextMonday(d2)) / 7)
* 5 + charge_start_date - charge_end_date;
return result;
}
/**
* 获取中文日期
*
* @param date
* @return
*/
public static String getChineseWeek(Calendar date) {
final String dayNames[] = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
int dayOfWeek = date.get(Calendar.DAY_OF_WEEK);
// System.out.println(dayNames[dayOfWeek - 1]);
return dayNames[dayOfWeek - 1];
}
/**
* 获得日期的下一个星期一的日期
*
* @param date
* @return
*/
public static Calendar getNextMonday(Calendar date) {
Calendar result = null;
result = date;
do {
result = (Calendar) result.clone();
result.add(Calendar.DATE, 1);
} while (result.get(Calendar.DAY_OF_WEEK) != 2);
return result;
}
/**
* 获取休息日
*
* @param d1
* @param d2
* @return
*/
public static int getHolidays(Calendar d1, Calendar d2) {
return getDaysBetween(d1, d2) - getWorkingDay(d1, d2);
}
/**
* 获取对应时间的为星期几
* 星期一:1
* 星期二:2
* 星期三:3
* 星期四:4
* 星期五:5
* 星期六:6
* 星期日:0
*
* @param dt
* @return
*/
public static int getWeekOfDate(Date dt) {
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w < 0)
w = 0;
return w;
}
/**
* 两时间做比较
*
* @param originalDate
* @param targetDate
* @return 当 originalDate 大于等于 targetDate 返回 true
* 反之 返回false
*/
public static boolean compareTime(Date originalDate, Date targetDate) {
if (targetDate == null) {
targetDate = new Date();
}
int ret = originalDate.compareTo(targetDate);
if (ret != -1) {
return true;
}
return false;
}
/**
* 与当前时间做比较
*
* @param date
* @return 当传入时间小于当前时间时,返回true;
* 当传入时间大于当天时间时,返回false;
*/
public static boolean compareCurrentTime(Date date) {
return compareTime(date, null);
}
/**
* 比较时间是否超过一个月
*
* @param date
* @param nowDate
* @return
*/
public static boolean compareIfOutOneMonth(Date date, Date nowDate) {
if(date.getTime()>nowDate.getTime()){
return false;
}
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(calendar.MONTH, 1);//把日期往后增加一个月.整数往后推,负数往前移动
date = calendar.getTime(); //这个时间就是日期往后推一个月的结果
//nowDate-date>一个月返回true,否则返回false
return date.getTime()<nowDate.getTime()?true:false;
}
public static void main(String[] args) throws Exception{
DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = dateFormat2.parse("2017-08-04 22:36:01");
Date nowDate = new Date();
boolean b = compareIfOutOneMonth(date, nowDate);
System.out.println(b);
}
}
| UTF-8 | Java | 15,673 | java | DateUtils.java | Java | [
{
"context": "Calendar;\nimport java.util.Locale;\n\n/**\n * @author LiuMingMing\n * 2015年8月7日 下午12:54:19\n * Versio",
"end": 362,
"score": 0.9993517398834229,
"start": 351,
"tag": "NAME",
"value": "LiuMingMing"
}
] | null | [] | import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
/**
* @author LiuMingMing
* 2015年8月7日 下午12:54:19
* Version 1.0
*/
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
private static String[] parsePatterns = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
/**
* 默认格式"yyyy-MM-dd HH:mm:ss"
*
* @return
* @throws ParseException
*/
public static Date parse(String date) throws ParseException {
return new SimpleDateFormat(DateFormatEnum.DATETIME.value()).parse(date);
}
/**
* 指定格式format日期
*
* @return
* @throws ParseException
*/
public static Date parse(String date, DateFormatEnum df) throws ParseException {
return new SimpleDateFormat(df.value()).parse(date);
}
/**
* 默认格式"yyyy-MM-dd HH:mm:ss"
*
* @return
* @throws ParseException
*/
public static Timestamp parseTimestamp(String date) throws ParseException {
return Timestamp.valueOf(date);
}
/**
* 默认格式"yyyy-MM-dd HH:mm:ss"
*
* @return
* @throws ParseException
*/
public static String format(String date) throws ParseException {
return new SimpleDateFormat(DateFormatEnum.DATETIME.value()).format(parse(date));
}
/**
* 格式化日期,保留年份时分
*
* @param dateStr
* @return
* @throws Exception
*/
public static String formatShort(String dateStr) {
if (StringUtils.isNotEmpty(dateStr)) {
try {
int cYear = Calendar.getInstance().get(Calendar.YEAR);
Date date = DateUtils.parse(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int inYear = calendar.get(Calendar.YEAR);
if (cYear != inYear) {
String cyTime = "yyyy-MM-dd HH:mm";
dateStr = new SimpleDateFormat(cyTime).format(date);
} else {
String cTime = "MM-dd HH:mm";
dateStr = new SimpleDateFormat(cTime).format(date);
}
} catch (ParseException e) {
}
}
return dateStr;
}
/**
* 指定格式format日期
*
* @return
* @throws ParseException
*/
public static String format(String date, DateFormatEnum df) throws ParseException {
return new SimpleDateFormat(df.value()).format(parse(date, df));
}
/**
* 默认格式"yyyy-MM-dd HH:mm:ss"
*
* @return
* @throws ParseException
*/
public static String format(Date date) throws ParseException {
return new SimpleDateFormat(DateFormatEnum.DATETIME.value()).format(date);
}
/**
* 指定格式format日期
*
* @return
* @throws ParseException
*/
public static String format(Date date, DateFormatEnum df) throws ParseException {
return new SimpleDateFormat(df.value()).format(date);
}
public static String convert(java.sql.Date date) {
return new SimpleDateFormat(DateFormatEnum.DATE.value()).format(date);
}
public static String convert(java.sql.Time time) {
return new SimpleDateFormat(DateFormatEnum.DATETIME.value()).format(time);
}
public static String convert(Timestamp timestamp) {
return new SimpleDateFormat(DateFormatEnum.TIMESTAMP.value()).format(timestamp);
}
public static Date now() {
return Calendar.getInstance(Locale.getDefault()).getTime();
}
public static String now(DateFormatEnum df) throws ParseException {
return format(now(), df != null ? df : DateFormatEnum.DEFAULT);
}
public static java.sql.Date curDate() {
return new java.sql.Date(Calendar.getInstance(Locale.getDefault()).getTimeInMillis());
}
public static Timestamp curTimeStamp() {
return new Timestamp(Calendar.getInstance(Locale.getDefault()).getTimeInMillis());
}
///////////////////////////
/**
* 得到当前日期字符串 格式(yyyy-MM-dd)
*/
public static String getDate() {
return getDate(DateFormatEnum.DATE.value());
}
/**
* 得到当前日期字符串 格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E"
*/
public static String getDate(String pattern) {
return DateFormatUtils.format(new Date(), pattern);
}
/**
* 得到日期字符串 默认格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E"
*/
public static String formatDate(Date date, Object... pattern) {
String formatDate = null;
if (pattern != null && pattern.length > 0) {
formatDate = DateFormatUtils.format(date, pattern[0].toString());
} else {
formatDate = DateFormatUtils.format(date, DateFormatEnum.DATE.value());
}
return formatDate;
}
/**
* 得到日期时间字符串,转换格式(yyyy-MM-dd HH:mm:ss)
*/
public static String formatDateTime(Date date) {
return formatDate(date, DateFormatEnum.DATETIME.value());
}
/**
* 得到当前时间字符串 格式(HH:mm:ss)
*/
public static String getTime() {
return formatDate(new Date(), DateFormatEnum.TIME.value());
}
/**
* 得到当前日期和时间字符串 格式(yyyy-MM-dd HH:mm:ss)
*/
public static String getDateTime() {
return formatDate(new Date(), DateFormatEnum.DATETIME.value());
}
/**
* 得到当前年份字符串 格式(yyyy)
*/
public static String getYear() {
return formatDate(new Date(), DateFormatEnum.YEAR.value());
}
/**
* 得到当前月份字符串 格式(MM)
*/
public static String getMonth() {
return formatDate(new Date(), DateFormatEnum.MONTH.value());
}
/**
* 得到当天字符串 格式(dd)
*/
public static String getDay() {
return formatDate(new Date(), DateFormatEnum.DAY.value());
}
/**
* 得到当前星期字符串 格式(E)星期几
*/
public static String getWeek() {
return formatDate(new Date(), DateFormatEnum.WEEK.value());
}
/**
* 日期型字符串转化为日期 格式
* { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm",
* "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm",
* "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm" }
*/
public static Date parseDate(Object str) {
if (str == null) {
return null;
}
try {
return parseDate(str.toString(), parsePatterns);
} catch (ParseException e) {
return null;
}
}
/**
* 获取过去的天数
*
* @param date
* @return
*/
public static long pastDays(Date date) {
long t = new Date().getTime() - date.getTime();
return t / (24 * 60 * 60 * 1000);
}
/**
* 获取过去的小时
*
* @param date
* @return
*/
public static long pastHour(Date date) {
long t = new Date().getTime() - date.getTime();
return t / (60 * 60 * 1000);
}
/**
* 获取过去的分钟
*
* @param date
* @return
*/
public static long pastMinutes(Date date) {
long t = new Date().getTime() - date.getTime();
return t / (60 * 1000);
}
/**
* 转换为时间(天,时:分:秒.毫秒)
*
* @param timeMillis
* @return
*/
public static String formatDateTime(long timeMillis) {
long day = timeMillis / (24 * 60 * 60 * 1000);
long hour = (timeMillis / (60 * 60 * 1000) - day * 24);
long min = ((timeMillis / (60 * 1000)) - day * 24 * 60 - hour * 60);
long s = (timeMillis / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
long sss = (timeMillis - day * 24 * 60 * 60 * 1000 - hour * 60 * 60 * 1000 - min * 60 * 1000 - s * 1000);
return (day > 0 ? day + "," : "") + hour + ":" + min + ":" + s + "." + sss;
}
/**
* 获取两个日期之间的天数
*
* @param before
* @param after
* @return
*/
public static double getDistanceOfTwoDate(Date before, Date after) {
long beforeTime = before.getTime();
long afterTime = after.getTime();
return (afterTime - beforeTime) / (1000 * 60 * 60 * 24);
}
public static Date getBeginDayOfMonth(Date day){
Calendar c1=Calendar.getInstance();
c1.setTime(day);
c1.set(Calendar.DATE,1);
c1.set(Calendar.HOUR,0);
c1.set(Calendar.MINUTE,0);
c1.set(Calendar.SECOND,0);
c1.set(Calendar.MILLISECOND,0);
return c1.getTime();
}
public static Date getEndDayOfMonth(Date day){
Date beginDay=getBeginDayOfMonth(day);
Calendar c1=Calendar.getInstance();
c1.setTime(beginDay);
c1.add(Calendar.MONTH,1);
return c1.getTime();
}
/**
* 获取横跨月度数
* @param date1
* @param date2
* @return
* @throws ParseException
*/
public static int getSpanMonths(String date1,String date2,String pattern) throws ParseException {
SimpleDateFormat sdf=new SimpleDateFormat(pattern);
Calendar c1=Calendar.getInstance();
Calendar c2=Calendar.getInstance();
c1.setTime(sdf.parse(date1));
c2.setTime(sdf.parse(date2));
int year =c2.get(Calendar.YEAR)-c1.get(Calendar.YEAR);
//开始日期若小月结束日期
if(year<0){
year=-year;
return year*12+c1.get(Calendar.MONTH)-c2.get(Calendar.MONTH)+1;
}
return year*12+c2.get(Calendar.MONTH)-c1.get(Calendar.MONTH)+1;
}
/**
* 获取日期之间的天数
*
* @param d1
* @param d2
* @return
*/
public static int getDaysBetween(Calendar d1, Calendar d2) {
if (d1.after(d2)) { // swap dates so that d1 is start and d2 is end
Calendar swap = d1;
d1 = d2;
d2 = swap;
}
int days = d2.get(Calendar.DAY_OF_YEAR)
- d1.get(Calendar.DAY_OF_YEAR);
int y2 = d2.get(Calendar.YEAR);
if (d1.get(Calendar.YEAR) != y2) {
d1 = (Calendar) d1.clone();
do {
days += d1.getActualMaximum(Calendar.DAY_OF_YEAR);
d1.add(Calendar.YEAR, 1);
} while (d1.get(Calendar.YEAR) != y2);
}
return days;
}
/**
* 获取工作日
*
* @param d1
* @param d2
* @return
*/
public static int getWorkingDay(Calendar d1, Calendar d2) {
int result = -1;
if (d1.after(d2)) { // swap dates so that d1 is start and d2 is end
Calendar swap = d1;
d1 = d2;
d2 = swap;
}
int charge_start_date = 0;// 开始日期的日期偏移量
int charge_end_date = 0;// 结束日期的日期偏移量
// 日期不在同一个日期内
int stmp;
int etmp;
stmp = 7 - d1.get(Calendar.DAY_OF_WEEK);
etmp = 7 - d2.get(Calendar.DAY_OF_WEEK);
if (stmp != 0 && stmp != 6) {// 开始日期为星期六和星期日时偏移量为0
charge_start_date = stmp - 1;
}
if (etmp != 0 && etmp != 6) {// 结束日期为星期六和星期日时偏移量为0
charge_end_date = etmp - 1;
}
// }
result = (getDaysBetween(getNextMonday(d1), getNextMonday(d2)) / 7)
* 5 + charge_start_date - charge_end_date;
return result;
}
/**
* 获取中文日期
*
* @param date
* @return
*/
public static String getChineseWeek(Calendar date) {
final String dayNames[] = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
int dayOfWeek = date.get(Calendar.DAY_OF_WEEK);
// System.out.println(dayNames[dayOfWeek - 1]);
return dayNames[dayOfWeek - 1];
}
/**
* 获得日期的下一个星期一的日期
*
* @param date
* @return
*/
public static Calendar getNextMonday(Calendar date) {
Calendar result = null;
result = date;
do {
result = (Calendar) result.clone();
result.add(Calendar.DATE, 1);
} while (result.get(Calendar.DAY_OF_WEEK) != 2);
return result;
}
/**
* 获取休息日
*
* @param d1
* @param d2
* @return
*/
public static int getHolidays(Calendar d1, Calendar d2) {
return getDaysBetween(d1, d2) - getWorkingDay(d1, d2);
}
/**
* 获取对应时间的为星期几
* 星期一:1
* 星期二:2
* 星期三:3
* 星期四:4
* 星期五:5
* 星期六:6
* 星期日:0
*
* @param dt
* @return
*/
public static int getWeekOfDate(Date dt) {
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w < 0)
w = 0;
return w;
}
/**
* 两时间做比较
*
* @param originalDate
* @param targetDate
* @return 当 originalDate 大于等于 targetDate 返回 true
* 反之 返回false
*/
public static boolean compareTime(Date originalDate, Date targetDate) {
if (targetDate == null) {
targetDate = new Date();
}
int ret = originalDate.compareTo(targetDate);
if (ret != -1) {
return true;
}
return false;
}
/**
* 与当前时间做比较
*
* @param date
* @return 当传入时间小于当前时间时,返回true;
* 当传入时间大于当天时间时,返回false;
*/
public static boolean compareCurrentTime(Date date) {
return compareTime(date, null);
}
/**
* 比较时间是否超过一个月
*
* @param date
* @param nowDate
* @return
*/
public static boolean compareIfOutOneMonth(Date date, Date nowDate) {
if(date.getTime()>nowDate.getTime()){
return false;
}
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(calendar.MONTH, 1);//把日期往后增加一个月.整数往后推,负数往前移动
date = calendar.getTime(); //这个时间就是日期往后推一个月的结果
//nowDate-date>一个月返回true,否则返回false
return date.getTime()<nowDate.getTime()?true:false;
}
public static void main(String[] args) throws Exception{
DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = dateFormat2.parse("2017-08-04 22:36:01");
Date nowDate = new Date();
boolean b = compareIfOutOneMonth(date, nowDate);
System.out.println(b);
}
}
| 15,673 | 0.555212 | 0.536888 | 539 | 26.033396 | 24.479797 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.391466 | false | false | 15 |
797bfb2d844e4ca177e65988dddf585ad90f6c06 | 7,378,753,853,016 | 67cbc3699bbcc837eb0249b19486e944e5e9ede7 | /51tzgl-common/common/base-service/src/main/java/com/base/service/user/impl/UserLoginFacadeImpl.java | 94e27d8e1e6b79aa3d45d7ffb5d49fba0077f756 | [] | no_license | 7158798/zuohao | https://github.com/7158798/zuohao | 7dc771c9dbc680447797555bda947c738015aa45 | e14efa801f6f7a831a66b5385178b5dac2791800 | refs/heads/master | 2020-03-13T06:40:49.190000 | 2018-01-27T06:56:01 | 2018-01-27T06:56:01 | 131,009,690 | 2 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.base.service.user.impl;
import com.base.facade.user.pojo.po.UserLogin;
import com.base.facade.user.service.UserLoginFacade;
import com.base.service.pool.BaseServiceBizPool;
/**
* @author luwei
* @Date 12/27/16 5:52 PM
*/
public class UserLoginFacadeImpl implements UserLoginFacade{
@Override
public void addUserLogin(Long userId, String loginPlatform, String adressIP, String status) {
BaseServiceBizPool.getInstance().userLoginBiz.addUserLogin(userId, loginPlatform, adressIP, status);
}
@Override
public int changeUserId(Long userId, Long thirdId) {
return BaseServiceBizPool.getInstance().userLoginBiz.changeUserId(userId, thirdId);
}
@Override
public UserLogin getLastLogin(Long userId) {
return BaseServiceBizPool.getInstance().userLoginBiz.getLastLogin(userId);
}
@Override
public Boolean queryIsAppLogin(Long userId) {
return BaseServiceBizPool.getInstance().userLoginBiz.queryIsAppLogin(userId);
}
}
| UTF-8 | Java | 1,009 | java | UserLoginFacadeImpl.java | Java | [
{
"context": "e.service.pool.BaseServiceBizPool;\n\n/**\n * @author luwei\n * @Date 12/27/16 5:52 PM\n */\npublic class UserLo",
"end": 207,
"score": 0.9996669292449951,
"start": 202,
"tag": "USERNAME",
"value": "luwei"
}
] | null | [] | package com.base.service.user.impl;
import com.base.facade.user.pojo.po.UserLogin;
import com.base.facade.user.service.UserLoginFacade;
import com.base.service.pool.BaseServiceBizPool;
/**
* @author luwei
* @Date 12/27/16 5:52 PM
*/
public class UserLoginFacadeImpl implements UserLoginFacade{
@Override
public void addUserLogin(Long userId, String loginPlatform, String adressIP, String status) {
BaseServiceBizPool.getInstance().userLoginBiz.addUserLogin(userId, loginPlatform, adressIP, status);
}
@Override
public int changeUserId(Long userId, Long thirdId) {
return BaseServiceBizPool.getInstance().userLoginBiz.changeUserId(userId, thirdId);
}
@Override
public UserLogin getLastLogin(Long userId) {
return BaseServiceBizPool.getInstance().userLoginBiz.getLastLogin(userId);
}
@Override
public Boolean queryIsAppLogin(Long userId) {
return BaseServiceBizPool.getInstance().userLoginBiz.queryIsAppLogin(userId);
}
}
| 1,009 | 0.745292 | 0.736373 | 32 | 30.53125 | 33.043518 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 15 |
827035520f82d5a4923b83c1a3594be5ca33b2dd | 21,388,937,184,947 | b65a9a9cd248b9bc4afafe4e3cfdad618e3d4d4f | /myfile.java | f84a207f19dd66f6f41dfe31cbb56e950697f13c | [] | no_license | junief/Share-a | https://github.com/junief/Share-a | f5649a0ab6e81cb7c2b47b56077164ce60578354 | ebd9c01fcabc3967f87f324e36eb8a7d12424024 | refs/heads/master | 2020-12-30T15:30:56.409000 | 2018-07-19T13:33:15 | 2018-07-19T13:33:15 | 91,155,804 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class Summer{
}
| UTF-8 | Java | 23 | java | myfile.java | Java | [] | null | [] | public class Summer{
}
| 23 | 0.73913 | 0.73913 | 2 | 10.5 | 9.5 | 20 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | false | false | 15 |
7a17bc69d7bd4efaa32af1d6435b28f0a3463309 | 26,834,955,666,643 | c323a7a5f278c43f6df2a5ed2a653ea851fcdb30 | /src/main/java/teamdraco/fins/client/model/BullCrabModel.java | 587e75a13296aa233a2545da937b462578aeaa39 | [] | no_license | Coda1552/FinsAndTails | https://github.com/Coda1552/FinsAndTails | 7d05a364f2a7fd3158814c115d45ae183dc3cb98 | 6d6b6b1690d4e49a37c609f87d5e2e3354686601 | refs/heads/master | 2023-03-15T13:58:37.687000 | 2023-03-07T08:19:56 | 2023-03-07T08:19:56 | 319,189,414 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package teamdraco.fins.client.model;
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BullCrabModel<T extends Entity> extends EntityModel<T> {
public ModelRenderer body;
public ModelRenderer rightclaw;
public ModelRenderer leftclaw;
public ModelRenderer rightleg1;
public ModelRenderer rightleg2;
public ModelRenderer leftleg1;
public ModelRenderer leftleg2;
public ModelRenderer righthorn;
public ModelRenderer lefthorn;
public ModelRenderer rightleg3;
public ModelRenderer leftleg3;
public ModelRenderer right_eye;
public ModelRenderer left_eye;
public BullCrabModel() {
this.texWidth = 32;
this.texHeight = 32;
this.leftleg2 = new ModelRenderer(this, 0, 0);
this.leftleg2.mirror = true;
this.leftleg2.setPos(2.0F, 2.0F, 0.0F);
this.leftleg2.addBox(0.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(leftleg2, 0.0F, 0.0F, 1.0471975511965976F);
this.leftleg3 = new ModelRenderer(this, 0, 0);
this.leftleg3.mirror = true;
this.leftleg3.setPos(2.0F, 2.0F, 1.5F);
this.leftleg3.addBox(0.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(leftleg3, 0.0F, 0.0F, 1.0471975511965976F);
this.rightleg3 = new ModelRenderer(this, 0, 0);
this.rightleg3.setPos(-2.0F, 2.0F, 1.5F);
this.rightleg3.addBox(-2.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(rightleg3, 0.0F, 0.0F, -1.0471975511965976F);
this.lefthorn = new ModelRenderer(this, 14, 10);
this.lefthorn.setPos(1.5F, -1.5F, -1.5F);
this.lefthorn.addBox(-0.5F, -1.0F, -3.0F, 1, 1, 3, 0.0F);
this.setRotateAngle(lefthorn, -0.39269908169872414F, -0.39269908169872414F, 0.0F);
this.leftleg1 = new ModelRenderer(this, 0, 0);
this.leftleg1.mirror = true;
this.leftleg1.setPos(2.0F, 2.0F, -1.5F);
this.leftleg1.addBox(0.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(leftleg1, 0.0F, 0.0F, 1.0471975511965976F);
this.right_eye = new ModelRenderer(this, 2, 3);
this.right_eye.setPos(1.0F, 1.5F, -3.0F);
this.right_eye.addBox(-0.5F, -3.0F, 0.0F, 1, 3, 0, 0.0F);
this.setRotateAngle(right_eye, 0.39269908169872414F, 0.0F, 0.0F);
this.rightleg1 = new ModelRenderer(this, 0, 0);
this.rightleg1.setPos(-2.0F, 2.0F, -1.5F);
this.rightleg1.addBox(-2.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(rightleg1, 0.0F, 0.0F, -1.0471975511965976F);
this.rightleg2 = new ModelRenderer(this, 0, 0);
this.rightleg2.setPos(-2.0F, 2.0F, 0.0F);
this.rightleg2.addBox(-2.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(rightleg2, 0.0F, 0.0F, -1.0471975511965976F);
this.rightclaw = new ModelRenderer(this, 0, 10);
this.rightclaw.setPos(-3.0F, 1.5F, -2.0F);
this.rightclaw.addBox(-2.0F, -3.0F, -4.0F, 3, 4, 4, 0.0F);
this.setRotateAngle(rightclaw, 0.0F, 0.17453292519943295F, 0.0F);
this.body = new ModelRenderer(this, 0, 0);
this.body.setPos(0.0F, 20.5F, 0.0F);
this.body.addBox(-3.0F, -2.0F, -3.0F, 6, 4, 6, 0.0F);
this.leftclaw = new ModelRenderer(this, 0, 10);
this.leftclaw.mirror = true;
this.leftclaw.setPos(3.0F, 1.5F, -2.0F);
this.leftclaw.addBox(-1.0F, -3.0F, -4.0F, 3, 4, 4, 0.0F);
this.setRotateAngle(leftclaw, 0.0F, -0.17453292519943295F, 0.0F);
this.left_eye = new ModelRenderer(this, 2, 3);
this.left_eye.setPos(-1.0F, 1.5F, -3.0F);
this.left_eye.addBox(-0.5F, -3.0F, 0.0F, 1, 3, 0, 0.0F);
this.setRotateAngle(left_eye, 0.39269908169872414F, 0.0F, 0.0F);
this.righthorn = new ModelRenderer(this, 14, 10);
this.righthorn.setPos(-1.5F, -1.5F, -1.5F);
this.righthorn.addBox(-0.5F, -1.0F, -3.0F, 1, 1, 3, 0.0F);
this.setRotateAngle(righthorn, -0.39269908169872414F, 0.39269908169872414F, 0.0F);
this.body.addChild(this.leftleg2);
this.body.addChild(this.leftleg3);
this.body.addChild(this.rightleg3);
this.body.addChild(this.lefthorn);
this.body.addChild(this.leftleg1);
this.body.addChild(this.right_eye);
this.body.addChild(this.rightleg1);
this.body.addChild(this.rightleg2);
this.body.addChild(this.rightclaw);
this.body.addChild(this.leftclaw);
this.body.addChild(this.left_eye);
this.body.addChild(this.righthorn);
}
@Override
public void renderToBuffer(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
ImmutableList.of(this.body).forEach((modelRenderer) -> {
modelRenderer.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
});
}
@Override
public void setupAnim(T entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
float speed = 2.0f;
float degree = 1.0f;
this.rightclaw.xRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * -0.4F * limbSwingAmount;
this.rightclaw.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * -0.4F * limbSwingAmount;
this.leftclaw.xRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * 0.4F * limbSwingAmount;
this.leftclaw.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * -0.4F * limbSwingAmount;
this.rightleg1.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * 0.8F * limbSwingAmount;
this.rightleg2.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * -0.8F * limbSwingAmount;
this.rightleg3.yRot = MathHelper.cos(0.5F + limbSwing * speed * 0.4F) * degree * 0.8F * limbSwingAmount + 0.2F;
this.leftleg1.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * -0.8F * limbSwingAmount;
this.leftleg2.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * 0.8F * limbSwingAmount;
this.leftleg3.yRot = MathHelper.cos(0.5F + limbSwing * speed * 0.4F) * degree * -0.8F * limbSwingAmount - 0.2F;
this.body.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * 0.1F * limbSwingAmount;
}
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.xRot = x;
modelRenderer.yRot = y;
modelRenderer.zRot = z;
}
}
| UTF-8 | Java | 6,903 | java | BullCrabModel.java | Java | [] | null | [] | package teamdraco.fins.client.model;
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BullCrabModel<T extends Entity> extends EntityModel<T> {
public ModelRenderer body;
public ModelRenderer rightclaw;
public ModelRenderer leftclaw;
public ModelRenderer rightleg1;
public ModelRenderer rightleg2;
public ModelRenderer leftleg1;
public ModelRenderer leftleg2;
public ModelRenderer righthorn;
public ModelRenderer lefthorn;
public ModelRenderer rightleg3;
public ModelRenderer leftleg3;
public ModelRenderer right_eye;
public ModelRenderer left_eye;
public BullCrabModel() {
this.texWidth = 32;
this.texHeight = 32;
this.leftleg2 = new ModelRenderer(this, 0, 0);
this.leftleg2.mirror = true;
this.leftleg2.setPos(2.0F, 2.0F, 0.0F);
this.leftleg2.addBox(0.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(leftleg2, 0.0F, 0.0F, 1.0471975511965976F);
this.leftleg3 = new ModelRenderer(this, 0, 0);
this.leftleg3.mirror = true;
this.leftleg3.setPos(2.0F, 2.0F, 1.5F);
this.leftleg3.addBox(0.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(leftleg3, 0.0F, 0.0F, 1.0471975511965976F);
this.rightleg3 = new ModelRenderer(this, 0, 0);
this.rightleg3.setPos(-2.0F, 2.0F, 1.5F);
this.rightleg3.addBox(-2.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(rightleg3, 0.0F, 0.0F, -1.0471975511965976F);
this.lefthorn = new ModelRenderer(this, 14, 10);
this.lefthorn.setPos(1.5F, -1.5F, -1.5F);
this.lefthorn.addBox(-0.5F, -1.0F, -3.0F, 1, 1, 3, 0.0F);
this.setRotateAngle(lefthorn, -0.39269908169872414F, -0.39269908169872414F, 0.0F);
this.leftleg1 = new ModelRenderer(this, 0, 0);
this.leftleg1.mirror = true;
this.leftleg1.setPos(2.0F, 2.0F, -1.5F);
this.leftleg1.addBox(0.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(leftleg1, 0.0F, 0.0F, 1.0471975511965976F);
this.right_eye = new ModelRenderer(this, 2, 3);
this.right_eye.setPos(1.0F, 1.5F, -3.0F);
this.right_eye.addBox(-0.5F, -3.0F, 0.0F, 1, 3, 0, 0.0F);
this.setRotateAngle(right_eye, 0.39269908169872414F, 0.0F, 0.0F);
this.rightleg1 = new ModelRenderer(this, 0, 0);
this.rightleg1.setPos(-2.0F, 2.0F, -1.5F);
this.rightleg1.addBox(-2.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(rightleg1, 0.0F, 0.0F, -1.0471975511965976F);
this.rightleg2 = new ModelRenderer(this, 0, 0);
this.rightleg2.setPos(-2.0F, 2.0F, 0.0F);
this.rightleg2.addBox(-2.0F, 0.0F, -0.5F, 2, 0, 1, 0.0F);
this.setRotateAngle(rightleg2, 0.0F, 0.0F, -1.0471975511965976F);
this.rightclaw = new ModelRenderer(this, 0, 10);
this.rightclaw.setPos(-3.0F, 1.5F, -2.0F);
this.rightclaw.addBox(-2.0F, -3.0F, -4.0F, 3, 4, 4, 0.0F);
this.setRotateAngle(rightclaw, 0.0F, 0.17453292519943295F, 0.0F);
this.body = new ModelRenderer(this, 0, 0);
this.body.setPos(0.0F, 20.5F, 0.0F);
this.body.addBox(-3.0F, -2.0F, -3.0F, 6, 4, 6, 0.0F);
this.leftclaw = new ModelRenderer(this, 0, 10);
this.leftclaw.mirror = true;
this.leftclaw.setPos(3.0F, 1.5F, -2.0F);
this.leftclaw.addBox(-1.0F, -3.0F, -4.0F, 3, 4, 4, 0.0F);
this.setRotateAngle(leftclaw, 0.0F, -0.17453292519943295F, 0.0F);
this.left_eye = new ModelRenderer(this, 2, 3);
this.left_eye.setPos(-1.0F, 1.5F, -3.0F);
this.left_eye.addBox(-0.5F, -3.0F, 0.0F, 1, 3, 0, 0.0F);
this.setRotateAngle(left_eye, 0.39269908169872414F, 0.0F, 0.0F);
this.righthorn = new ModelRenderer(this, 14, 10);
this.righthorn.setPos(-1.5F, -1.5F, -1.5F);
this.righthorn.addBox(-0.5F, -1.0F, -3.0F, 1, 1, 3, 0.0F);
this.setRotateAngle(righthorn, -0.39269908169872414F, 0.39269908169872414F, 0.0F);
this.body.addChild(this.leftleg2);
this.body.addChild(this.leftleg3);
this.body.addChild(this.rightleg3);
this.body.addChild(this.lefthorn);
this.body.addChild(this.leftleg1);
this.body.addChild(this.right_eye);
this.body.addChild(this.rightleg1);
this.body.addChild(this.rightleg2);
this.body.addChild(this.rightclaw);
this.body.addChild(this.leftclaw);
this.body.addChild(this.left_eye);
this.body.addChild(this.righthorn);
}
@Override
public void renderToBuffer(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
ImmutableList.of(this.body).forEach((modelRenderer) -> {
modelRenderer.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
});
}
@Override
public void setupAnim(T entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
float speed = 2.0f;
float degree = 1.0f;
this.rightclaw.xRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * -0.4F * limbSwingAmount;
this.rightclaw.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * -0.4F * limbSwingAmount;
this.leftclaw.xRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * 0.4F * limbSwingAmount;
this.leftclaw.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * -0.4F * limbSwingAmount;
this.rightleg1.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * 0.8F * limbSwingAmount;
this.rightleg2.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * -0.8F * limbSwingAmount;
this.rightleg3.yRot = MathHelper.cos(0.5F + limbSwing * speed * 0.4F) * degree * 0.8F * limbSwingAmount + 0.2F;
this.leftleg1.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * -0.8F * limbSwingAmount;
this.leftleg2.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * 0.8F * limbSwingAmount;
this.leftleg3.yRot = MathHelper.cos(0.5F + limbSwing * speed * 0.4F) * degree * -0.8F * limbSwingAmount - 0.2F;
this.body.yRot = MathHelper.cos(limbSwing * speed * 0.4F) * degree * 0.1F * limbSwingAmount;
}
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.xRot = x;
modelRenderer.yRot = y;
modelRenderer.zRot = z;
}
}
| 6,903 | 0.651746 | 0.557439 | 131 | 51.694656 | 29.951843 | 173 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.274809 | false | false | 15 |
1473fffbcfebe1102a15715b7175545d8d7a827a | 12,893,491,870,925 | 11fefd7854fb868b00a723770bf85d0e2974a273 | /covid-19/src/main/java/com/jianhui/covid19/services/DataServices.java | 1cf197481a181dc33dd1274011a944c05717a807 | [] | no_license | shuwenhhh/Coronavirus-Tracker | https://github.com/shuwenhhh/Coronavirus-Tracker | 94aff5992741b58d3a372a7753b70d8cab94ac10 | c88f486261f139087958fda5bcd2932788d5afad | refs/heads/master | 2021-04-08T05:04:11.409000 | 2020-04-01T10:32:32 | 2020-04-01T10:32:32 | 248,742,683 | 1 | 0 | null | false | 2021-01-05T22:36:48 | 2020-03-20T11:49:45 | 2020-04-01T10:36:09 | 2021-01-05T22:36:47 | 387 | 1 | 0 | 1 | Java | false | false | package com.jianhui.covid19.services;
import com.jianhui.covid19.models.CountriesModel;
import com.jianhui.covid19.models.StatesModel;
import com.jianhui.covid19.models.WorldModel;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class DataServices {
private static final String CONFIRMED_URL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv";
private static final String DEATH_URL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv";
private List<StatesModel> allStates = new ArrayList<>();
private List<CountriesModel> allCountries = new ArrayList<>();
private Set<String> countrySet = new HashSet<>();
private WorldModel worldModel = new WorldModel();
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yy");
@PostConstruct
@Scheduled(cron = "0 0 * * * *")
public void fetchData() throws IOException, InterruptedException, ParseException {
List<StatesModel> newStates = new ArrayList<>();
List<CountriesModel> newCountries = new ArrayList<>();
HttpClient client = HttpClient.newBuilder().build();
String[] urls = new String[]{CONFIRMED_URL, DEATH_URL};
for (int i = 0; i < 2; ++i) {
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(urls[i])).build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
StringReader csvBodyReader = new StringReader(response.body());
Iterable<CSVRecord> records = CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(csvBodyReader);
if (i == 0)
fetchConfirmedData(records, newStates);
else
fetchDeathData(records, newStates);
}
fetchCountryData(newStates, newCountries);
allStates = newStates;
allCountries = newCountries;
getWorldDailyReport();
getStateDailyList();
getCountryDailyList();
getWorldDailyList();
}
private void fetchConfirmedData(Iterable<CSVRecord> records, List<StatesModel> newStates) throws ParseException {
int totalConfirmed=0;
for (CSVRecord record : records){
StatesModel tempState = new StatesModel();
String state = record.get("Province/State");
String country = record.get("Country/Region");
String lat = record.get("Lat");
String lon = record.get("Long");
if (lat.equalsIgnoreCase(lon))
continue;
if (state.length() == 0)
tempState.setState("UNDEF");
else
tempState.setState(state);
tempState.setCountry(country);
this.countrySet.add(country);
tempState.setLatitude(lat);
tempState.setLongitude(lon);
Map<String,Integer> map = new LinkedHashMap<>();
int total = getStateDailyReport(map,record);
int confirmedRate = 0;
String latest = record.get(record.size()-1);
if (latest.length() != 0)
confirmedRate = Integer.parseInt(latest) - Integer.parseInt(record.get(record.size()-2));
tempState.setConfirmedRate(confirmedRate);
tempState.setDailyConfirmed(map);
tempState.setTotalConfirmed(total);
newStates.add(tempState);
totalConfirmed += tempState.getTotalConfirmed();
}
worldModel.setTotalConfirmed(totalConfirmed);
}
private void fetchDeathData(Iterable<CSVRecord> records, List<StatesModel> newStates) throws ParseException{
int index = 0;
int totalDeath = 0;
for (CSVRecord record : records){
String lat = record.get("Lat");
String lon = record.get("Long");
if (lat.equalsIgnoreCase(lon))
continue;
Map<String,Integer> map = new LinkedHashMap<>();
int total = getStateDailyReport(map,record);
int deathRate = 0;
String latest = record.get(record.size()-1);
if (latest.length() != 0)
deathRate = Integer.parseInt(latest) - Integer.parseInt(record.get(record.size()-2));
newStates.get(index).setDeathRate(deathRate);
newStates.get(index).setTotalDeath(total);
newStates.get(index).setDailyDeath(map);
totalDeath += newStates.get(index++).getTotalDeath();
}
worldModel.setTotalDeath(totalDeath);
}
private void fetchCountryData(List<StatesModel> newStates, List<CountriesModel> newCountries){
for(String country: this.countrySet){
List<StatesModel> list = new LinkedList<>();
CountriesModel newCountry = new CountriesModel();
newCountry.setCountryName(country);
int countryTotalConfirmed=0;
int countryTotalDeath=0;
int deathRate = 0;
int confirmedRate=0;
List<Map<String,Integer>> confirmedDailyList = new LinkedList<>();
List<Map<String,Integer>> deathDailyList = new LinkedList<>();
for (StatesModel state: newStates){
if (state.getCountry().equalsIgnoreCase(country)){
if (!state.getState().equalsIgnoreCase("UNDEF"))
list.add(state);
confirmedDailyList.add(state.getDailyConfirmed());
deathDailyList.add(state.getDailyDeath());
countryTotalConfirmed += state.getTotalConfirmed();
countryTotalDeath += state.getTotalDeath();
deathRate += state.getDeathRate();
confirmedRate += state.getConfirmedRate();
}
}
newCountry.setTotalConfirmed(countryTotalConfirmed);
newCountry.setTotalDeath(countryTotalDeath);
newCountry.setDeathRate(deathRate);
newCountry.setConfirmedRate(confirmedRate);
newCountry.setStates(list);
Map<String,Integer> confirmedDaily = new LinkedHashMap<>();
Map<String,Integer> deathDaily = new LinkedHashMap<>();
getCountryDailyReport(confirmedDaily,confirmedDailyList);
getCountryDailyReport(deathDaily,deathDailyList);
newCountry.setDailyConfirmed(confirmedDaily);
newCountry.setDailyDeath(deathDaily);
newCountries.add(newCountry);
}
}
private void getWorldDailyReport() throws ParseException {
String date = "1/22/20";
String today = dateFormat.format(new Date());
Map<String,Integer> confirmedDaily = new LinkedHashMap<>();
Map<String, Integer> deathDaily = new LinkedHashMap<>();
boolean isEnd = false;
while (!date.equals(today)) {
int confirmed=0,death=0;
for (CountriesModel country : allCountries) {
if (!country.getDailyConfirmed().containsKey(date)){
isEnd = true;
break;
}
confirmed += country.getDailyConfirmed().get(date);
death += country.getDailyDeath().get(date);
}
if (isEnd)
break;
confirmedDaily.put(date, confirmed);
deathDaily.put(date, death);
date = plusOneDay(date);
}
int deathRate = 0;
int confirmedRate=0;
for (CountriesModel country: allCountries){
deathRate += country.getDeathRate();
confirmedRate += country.getConfirmedRate();
}
worldModel.setDeathRate(deathRate);
worldModel.setConfirmedRate(confirmedRate);
worldModel.setDailyConfirmed(confirmedDaily);
worldModel.setDailyDeath(deathDaily);
}
public void getStateDailyList() throws ParseException{
for (StatesModel state: allStates){
Map<String,Integer> dailyConfirmed = state.getDailyConfirmed();
Map<String,Integer> dailyDeath = state.getDailyDeath();
List<Map<String,String>> list = new LinkedList<>();
String date = "1/22/20";
String today = dateFormat.format(new Date());
while (!date.equals(today)){
Map<String,String> map = new LinkedHashMap<>();
map.put("date",date);
map.put("confirmed", String.valueOf(dailyConfirmed.get(date)));
map.put("death", String.valueOf(dailyDeath.get(date)));
list.add(map);
date = plusOneDay(date);
}
state.setDailyList(list);
}
}
public void getCountryDailyList() throws ParseException{
for (CountriesModel country: allCountries){
Map<String,Integer> dailyConfirmed = country.getDailyConfirmed();
Map<String,Integer> dailyDeath = country.getDailyDeath();
List<Map<String,String>> list = new LinkedList<>();
String date = "1/22/20";
String today = dateFormat.format(new Date());
while (!date.equals(today)){
Map<String,String> map = new LinkedHashMap<>();
map.put("date",date);
map.put("confirmed", String.valueOf(dailyConfirmed.get(date)));
map.put("death", String.valueOf(dailyDeath.get(date)));
list.add(map);
date = plusOneDay(date);
}
country.setDailyList(list);
}
}
public void getWorldDailyList() throws ParseException {
Map<String,Integer> dailyConfirmed = worldModel.getDailyConfirmed();
Map<String,Integer> dailyDeath = worldModel.getDailyDeath();
List<Map<String,String>> list = new LinkedList<>();
String date = "1/22/20";
String today = dateFormat.format(new Date());
while (!date.equals(today)){
Map<String,String> map = new LinkedHashMap<>();
map.put("date",date);
map.put("confirmed", String.valueOf(dailyConfirmed.get(date)));
map.put("death", String.valueOf(dailyDeath.get(date)));
list.add(map);
date = plusOneDay(date);
}
worldModel.setDailyList(list);
}
private int getStateDailyReport(Map<String,Integer> map, CSVRecord record) throws ParseException {
String date = "1/22/20";
int max = 0;
int index = 4;
while (index < record.size()){
String num = record.get(index++);
if (num.length() == 0)
break;
max = Math.max(Integer.parseInt(num),max);
map.put(date,max);
date = plusOneDay(date);
}
return max;
}
private void getCountryDailyReport (Map<String,Integer> map, List<Map<String,Integer>> mapList){
for (Map<String,Integer> daily: mapList) {
for (String date : daily.keySet()) {
map.put(date, map.getOrDefault(date, 0) + daily.get(date));
}
}
}
private String plusOneDay(String dt) throws ParseException {
Date date = dateFormat.parse(dt);
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, 1);
return dateFormat.format(c.getTime());
}
public List<CountriesModel> getAllCountries() {
Comparator<CountriesModel> compareByConfirmed = (o1, o2) -> o2.getTotalConfirmed()-o1.getTotalConfirmed();
Collections.sort(allCountries,compareByConfirmed);
return allCountries;
}
public List<StatesModel> getAllStates(){
return allStates;
}
public WorldModel getWorld() {
return worldModel;
}
public StatesModel getStateInfoByName(String name){
for (StatesModel state: allStates){
if (state.getState().equalsIgnoreCase(name))
return state;
}
return null;
}
public CountriesModel getCountryInfoByName(String name){
for (CountriesModel country: allCountries){
if (country.getCountryName().equalsIgnoreCase(name))
return country;
}
return null;
}
public List<StatesModel> getStateListByCountry(String name){
for (CountriesModel country: allCountries){
if (country.getCountryName().equalsIgnoreCase(name)) {
return country.getStates();
}
}
return null;
}
}
| UTF-8 | Java | 13,165 | java | DataServices.java | Java | [] | null | [] | package com.jianhui.covid19.services;
import com.jianhui.covid19.models.CountriesModel;
import com.jianhui.covid19.models.StatesModel;
import com.jianhui.covid19.models.WorldModel;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class DataServices {
private static final String CONFIRMED_URL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv";
private static final String DEATH_URL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv";
private List<StatesModel> allStates = new ArrayList<>();
private List<CountriesModel> allCountries = new ArrayList<>();
private Set<String> countrySet = new HashSet<>();
private WorldModel worldModel = new WorldModel();
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yy");
@PostConstruct
@Scheduled(cron = "0 0 * * * *")
public void fetchData() throws IOException, InterruptedException, ParseException {
List<StatesModel> newStates = new ArrayList<>();
List<CountriesModel> newCountries = new ArrayList<>();
HttpClient client = HttpClient.newBuilder().build();
String[] urls = new String[]{CONFIRMED_URL, DEATH_URL};
for (int i = 0; i < 2; ++i) {
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(urls[i])).build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
StringReader csvBodyReader = new StringReader(response.body());
Iterable<CSVRecord> records = CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(csvBodyReader);
if (i == 0)
fetchConfirmedData(records, newStates);
else
fetchDeathData(records, newStates);
}
fetchCountryData(newStates, newCountries);
allStates = newStates;
allCountries = newCountries;
getWorldDailyReport();
getStateDailyList();
getCountryDailyList();
getWorldDailyList();
}
private void fetchConfirmedData(Iterable<CSVRecord> records, List<StatesModel> newStates) throws ParseException {
int totalConfirmed=0;
for (CSVRecord record : records){
StatesModel tempState = new StatesModel();
String state = record.get("Province/State");
String country = record.get("Country/Region");
String lat = record.get("Lat");
String lon = record.get("Long");
if (lat.equalsIgnoreCase(lon))
continue;
if (state.length() == 0)
tempState.setState("UNDEF");
else
tempState.setState(state);
tempState.setCountry(country);
this.countrySet.add(country);
tempState.setLatitude(lat);
tempState.setLongitude(lon);
Map<String,Integer> map = new LinkedHashMap<>();
int total = getStateDailyReport(map,record);
int confirmedRate = 0;
String latest = record.get(record.size()-1);
if (latest.length() != 0)
confirmedRate = Integer.parseInt(latest) - Integer.parseInt(record.get(record.size()-2));
tempState.setConfirmedRate(confirmedRate);
tempState.setDailyConfirmed(map);
tempState.setTotalConfirmed(total);
newStates.add(tempState);
totalConfirmed += tempState.getTotalConfirmed();
}
worldModel.setTotalConfirmed(totalConfirmed);
}
private void fetchDeathData(Iterable<CSVRecord> records, List<StatesModel> newStates) throws ParseException{
int index = 0;
int totalDeath = 0;
for (CSVRecord record : records){
String lat = record.get("Lat");
String lon = record.get("Long");
if (lat.equalsIgnoreCase(lon))
continue;
Map<String,Integer> map = new LinkedHashMap<>();
int total = getStateDailyReport(map,record);
int deathRate = 0;
String latest = record.get(record.size()-1);
if (latest.length() != 0)
deathRate = Integer.parseInt(latest) - Integer.parseInt(record.get(record.size()-2));
newStates.get(index).setDeathRate(deathRate);
newStates.get(index).setTotalDeath(total);
newStates.get(index).setDailyDeath(map);
totalDeath += newStates.get(index++).getTotalDeath();
}
worldModel.setTotalDeath(totalDeath);
}
private void fetchCountryData(List<StatesModel> newStates, List<CountriesModel> newCountries){
for(String country: this.countrySet){
List<StatesModel> list = new LinkedList<>();
CountriesModel newCountry = new CountriesModel();
newCountry.setCountryName(country);
int countryTotalConfirmed=0;
int countryTotalDeath=0;
int deathRate = 0;
int confirmedRate=0;
List<Map<String,Integer>> confirmedDailyList = new LinkedList<>();
List<Map<String,Integer>> deathDailyList = new LinkedList<>();
for (StatesModel state: newStates){
if (state.getCountry().equalsIgnoreCase(country)){
if (!state.getState().equalsIgnoreCase("UNDEF"))
list.add(state);
confirmedDailyList.add(state.getDailyConfirmed());
deathDailyList.add(state.getDailyDeath());
countryTotalConfirmed += state.getTotalConfirmed();
countryTotalDeath += state.getTotalDeath();
deathRate += state.getDeathRate();
confirmedRate += state.getConfirmedRate();
}
}
newCountry.setTotalConfirmed(countryTotalConfirmed);
newCountry.setTotalDeath(countryTotalDeath);
newCountry.setDeathRate(deathRate);
newCountry.setConfirmedRate(confirmedRate);
newCountry.setStates(list);
Map<String,Integer> confirmedDaily = new LinkedHashMap<>();
Map<String,Integer> deathDaily = new LinkedHashMap<>();
getCountryDailyReport(confirmedDaily,confirmedDailyList);
getCountryDailyReport(deathDaily,deathDailyList);
newCountry.setDailyConfirmed(confirmedDaily);
newCountry.setDailyDeath(deathDaily);
newCountries.add(newCountry);
}
}
private void getWorldDailyReport() throws ParseException {
String date = "1/22/20";
String today = dateFormat.format(new Date());
Map<String,Integer> confirmedDaily = new LinkedHashMap<>();
Map<String, Integer> deathDaily = new LinkedHashMap<>();
boolean isEnd = false;
while (!date.equals(today)) {
int confirmed=0,death=0;
for (CountriesModel country : allCountries) {
if (!country.getDailyConfirmed().containsKey(date)){
isEnd = true;
break;
}
confirmed += country.getDailyConfirmed().get(date);
death += country.getDailyDeath().get(date);
}
if (isEnd)
break;
confirmedDaily.put(date, confirmed);
deathDaily.put(date, death);
date = plusOneDay(date);
}
int deathRate = 0;
int confirmedRate=0;
for (CountriesModel country: allCountries){
deathRate += country.getDeathRate();
confirmedRate += country.getConfirmedRate();
}
worldModel.setDeathRate(deathRate);
worldModel.setConfirmedRate(confirmedRate);
worldModel.setDailyConfirmed(confirmedDaily);
worldModel.setDailyDeath(deathDaily);
}
public void getStateDailyList() throws ParseException{
for (StatesModel state: allStates){
Map<String,Integer> dailyConfirmed = state.getDailyConfirmed();
Map<String,Integer> dailyDeath = state.getDailyDeath();
List<Map<String,String>> list = new LinkedList<>();
String date = "1/22/20";
String today = dateFormat.format(new Date());
while (!date.equals(today)){
Map<String,String> map = new LinkedHashMap<>();
map.put("date",date);
map.put("confirmed", String.valueOf(dailyConfirmed.get(date)));
map.put("death", String.valueOf(dailyDeath.get(date)));
list.add(map);
date = plusOneDay(date);
}
state.setDailyList(list);
}
}
public void getCountryDailyList() throws ParseException{
for (CountriesModel country: allCountries){
Map<String,Integer> dailyConfirmed = country.getDailyConfirmed();
Map<String,Integer> dailyDeath = country.getDailyDeath();
List<Map<String,String>> list = new LinkedList<>();
String date = "1/22/20";
String today = dateFormat.format(new Date());
while (!date.equals(today)){
Map<String,String> map = new LinkedHashMap<>();
map.put("date",date);
map.put("confirmed", String.valueOf(dailyConfirmed.get(date)));
map.put("death", String.valueOf(dailyDeath.get(date)));
list.add(map);
date = plusOneDay(date);
}
country.setDailyList(list);
}
}
public void getWorldDailyList() throws ParseException {
Map<String,Integer> dailyConfirmed = worldModel.getDailyConfirmed();
Map<String,Integer> dailyDeath = worldModel.getDailyDeath();
List<Map<String,String>> list = new LinkedList<>();
String date = "1/22/20";
String today = dateFormat.format(new Date());
while (!date.equals(today)){
Map<String,String> map = new LinkedHashMap<>();
map.put("date",date);
map.put("confirmed", String.valueOf(dailyConfirmed.get(date)));
map.put("death", String.valueOf(dailyDeath.get(date)));
list.add(map);
date = plusOneDay(date);
}
worldModel.setDailyList(list);
}
private int getStateDailyReport(Map<String,Integer> map, CSVRecord record) throws ParseException {
String date = "1/22/20";
int max = 0;
int index = 4;
while (index < record.size()){
String num = record.get(index++);
if (num.length() == 0)
break;
max = Math.max(Integer.parseInt(num),max);
map.put(date,max);
date = plusOneDay(date);
}
return max;
}
private void getCountryDailyReport (Map<String,Integer> map, List<Map<String,Integer>> mapList){
for (Map<String,Integer> daily: mapList) {
for (String date : daily.keySet()) {
map.put(date, map.getOrDefault(date, 0) + daily.get(date));
}
}
}
private String plusOneDay(String dt) throws ParseException {
Date date = dateFormat.parse(dt);
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, 1);
return dateFormat.format(c.getTime());
}
public List<CountriesModel> getAllCountries() {
Comparator<CountriesModel> compareByConfirmed = (o1, o2) -> o2.getTotalConfirmed()-o1.getTotalConfirmed();
Collections.sort(allCountries,compareByConfirmed);
return allCountries;
}
public List<StatesModel> getAllStates(){
return allStates;
}
public WorldModel getWorld() {
return worldModel;
}
public StatesModel getStateInfoByName(String name){
for (StatesModel state: allStates){
if (state.getState().equalsIgnoreCase(name))
return state;
}
return null;
}
public CountriesModel getCountryInfoByName(String name){
for (CountriesModel country: allCountries){
if (country.getCountryName().equalsIgnoreCase(name))
return country;
}
return null;
}
public List<StatesModel> getStateListByCountry(String name){
for (CountriesModel country: allCountries){
if (country.getCountryName().equalsIgnoreCase(name)) {
return country.getStates();
}
}
return null;
}
}
| 13,165 | 0.61147 | 0.605165 | 317 | 40.529968 | 28.027756 | 201 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.804416 | false | false | 15 |
95e078c0a02e8a811751c0e0744b684459f214ef | 30,923,764,551,342 | d95b40e5b5d512d9e4171711dfaea6dd6bc6d1e9 | /rms-client/jplaya-engine/src/main/java/de/oliver_heger/jplaya/engine/DataBufferEvent.java | 5d9a26e077760cc154f6c98c0b03d08ad4de3331 | [] | no_license | VijayEluri/RemoteMediaStore | https://github.com/VijayEluri/RemoteMediaStore | 220cfd7c35f4f320ae5fb0199c573c557025238f | f85886d80c8d55ba83394e1b215827e229946311 | refs/heads/master | 2020-05-20T11:10:53.816000 | 2015-05-14T17:47:12 | 2015-05-14T17:47:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package de.oliver_heger.jplaya.engine;
import java.util.EventObject;
/**
* <p>
* An event class for reporting changes of the state of a {@link DataBuffer}.
* </p>
* <p>
* Event notifications of this type can be received by components that want to
* monitor a data buffer.
* </p>
*
* @author Oliver Heger
* @version $Id$
* @see DataBufferListener
*/
public class DataBufferEvent extends EventObject
{
/**
* The serial version UID.
*/
private static final long serialVersionUID = -8848510987223655615L;
/** Stores the event type. */
private Type type;
/**
* Creates a new instance of {@code DataBufferEvent} and sets the event
* source and its type. The source is the {@code AudioBuffer} object that
* caused this event.
*
* @param source the source of this event
* @param t the event type
*/
public DataBufferEvent(DataBuffer source, Type t)
{
super(source);
type = t;
}
/**
* Returns the data buffer instance that caused this event.
*
* @return the source {@code DataBuffer}
*/
public DataBuffer getSourceBuffer()
{
return (DataBuffer) getSource();
}
/**
* Returns the type of this event.
*
* @return the event type
*/
public Type getType()
{
return type;
}
/**
* <p>
* An enumeration class for the event type.
* </p>
*/
public static enum Type
{
/**
* Constant for the event type <em>CHUNK_COUNT_CHANGED</em>. The number
* of used chunks has changed.
*/
CHUNK_COUNT_CHANGED,
/**
* Constant for the event type <em>DATA_ADDED</em>. A number of bytes
* has been added to the buffer.
*/
DATA_ADDED,
/**
* Constant for the event type <em>BUFFER_FULL</em>. The buffer is full.
* If new data is to be added, this operation will block until data is
* read from the buffer.
*/
BUFFER_FULL,
/**
* Constant for the event type <em>BUFFER_FREE</em>. This event will be
* sent after a <em>BUFFER_FULL</em> event when there is again free
* space in the buffer. Now new data can be inserted.
*/
BUFFER_FREE,
/**
* Constant for the event type <em>BUFFER_CLOSED</em>. The buffer has
* been closed.
*/
BUFFER_CLOSED
}
}
| UTF-8 | Java | 2,475 | java | DataBufferEvent.java | Java | [
{
"context": "to\n * monitor a data buffer.\n * </p>\n *\n * @author Oliver Heger\n * @version $Id$\n * @see DataBufferListener\n */\np",
"end": 314,
"score": 0.9998658299446106,
"start": 302,
"tag": "NAME",
"value": "Oliver Heger"
}
] | null | [] | package de.oliver_heger.jplaya.engine;
import java.util.EventObject;
/**
* <p>
* An event class for reporting changes of the state of a {@link DataBuffer}.
* </p>
* <p>
* Event notifications of this type can be received by components that want to
* monitor a data buffer.
* </p>
*
* @author <NAME>
* @version $Id$
* @see DataBufferListener
*/
public class DataBufferEvent extends EventObject
{
/**
* The serial version UID.
*/
private static final long serialVersionUID = -8848510987223655615L;
/** Stores the event type. */
private Type type;
/**
* Creates a new instance of {@code DataBufferEvent} and sets the event
* source and its type. The source is the {@code AudioBuffer} object that
* caused this event.
*
* @param source the source of this event
* @param t the event type
*/
public DataBufferEvent(DataBuffer source, Type t)
{
super(source);
type = t;
}
/**
* Returns the data buffer instance that caused this event.
*
* @return the source {@code DataBuffer}
*/
public DataBuffer getSourceBuffer()
{
return (DataBuffer) getSource();
}
/**
* Returns the type of this event.
*
* @return the event type
*/
public Type getType()
{
return type;
}
/**
* <p>
* An enumeration class for the event type.
* </p>
*/
public static enum Type
{
/**
* Constant for the event type <em>CHUNK_COUNT_CHANGED</em>. The number
* of used chunks has changed.
*/
CHUNK_COUNT_CHANGED,
/**
* Constant for the event type <em>DATA_ADDED</em>. A number of bytes
* has been added to the buffer.
*/
DATA_ADDED,
/**
* Constant for the event type <em>BUFFER_FULL</em>. The buffer is full.
* If new data is to be added, this operation will block until data is
* read from the buffer.
*/
BUFFER_FULL,
/**
* Constant for the event type <em>BUFFER_FREE</em>. This event will be
* sent after a <em>BUFFER_FULL</em> event when there is again free
* space in the buffer. Now new data can be inserted.
*/
BUFFER_FREE,
/**
* Constant for the event type <em>BUFFER_CLOSED</em>. The buffer has
* been closed.
*/
BUFFER_CLOSED
}
}
| 2,469 | 0.573333 | 0.565657 | 101 | 23.50495 | 24.360584 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.138614 | false | false | 15 |
4095e57f2ece412fb3fc2f45e8dbe67ba46f088d | 29,248,727,328,995 | 8b7b4a183b0066ceda7faf26687e3281dcc709cd | /src/main/java/com/example/demo/service/CommentsService.java | 5c047781f3a3b476ef74dc79dd5ea80ec29e828a | [] | no_license | newoni/balook_alpha | https://github.com/newoni/balook_alpha | e4ef7cc7cbf8e1ffd4ab34d70277ab864ac10835 | 379a70f116a59cd086a9d259954cbbfd1a7445c8 | refs/heads/main | 2023-06-16T16:20:06.517000 | 2021-07-12T04:49:21 | 2021-07-12T04:49:21 | 380,939,069 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.demo.service;
import com.example.demo.model.entity.Board;
import com.example.demo.model.entity.Comments;
import com.example.demo.model.entity.Customer;
import com.example.demo.model.network.Header;
import com.example.demo.model.network.request.CommentsRequest;
import com.example.demo.model.network.response.BoardListResponse;
import com.example.demo.model.network.response.BoardResponse;
import com.example.demo.model.network.response.CommentsListResponse;
import com.example.demo.model.network.response.CommentsResponse;
import com.example.demo.repository.BoardRepository;
import com.example.demo.repository.CommentsRepository;
import com.example.demo.repository.CustomerRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.xml.stream.events.Comment;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
@Service
@Slf4j
public class CommentsService {
@Autowired
CommentsRepository commentsRepository;
@Autowired
BoardRepository boardRepository;
@Autowired
CustomerRepository customerRepository;
public Header<CommentsResponse> create(Header<CommentsRequest> request, String nickname){
CommentsRequest body = request.getData();
log.info("request: " + request);
log.info("body: " + body);
log.info("boardAuthor: " + body.getAuthor());
log.info("commentsAuthor: " + nickname);
Customer boardAuthor = customerRepository.findByNickNameLike(body.getAuthor());
Customer user = customerRepository.findByNickNameLike(nickname);
Board board = boardRepository.findByAuthorAndTitle(boardAuthor.getId(),body.getTitle());
Comments comments = Comments.builder()
.author(user.getId()) // comment author
.targetBoard(board.getId())
.contents(body.getContents())
.boardedAt(LocalDate.now())
.build();
Comments newComments = commentsRepository.save(comments);
Customer savedAuthor = customerRepository.findById(newComments.getAuthor()).get();
CommentsResponse commentsResponse = CommentsResponse.builder()
.author(savedAuthor.getNickName())
.contents(newComments.getContents())
.boardedAt(LocalDate.now())
.build();
return Header.OK(commentsResponse);
}
public Header<CommentsListResponse> getOneBoardCommentsList(String authorNickName, String title){
log.info("author Nickname: " + authorNickName);
log.info("title: " + title);
Customer author = customerRepository.findByNickNameLike(authorNickName);
log.info("author: " + author);
Board board = boardRepository.findByAuthorAndTitle(author.getId(),title);
log.info("board: " + board);
ArrayList<Comments> commentsList = (ArrayList<Comments>)(commentsRepository.findByTargetBoard(board.getId()));
ArrayList<CommentsResponse> commentsResponseArrayList = new ArrayList<CommentsResponse>();
for(Comments comments : commentsList){
Customer tmpCustomer = customerRepository.findById(comments.getAuthor()).get();
CommentsResponse commentsResponse = CommentsResponse.builder()
.author(tmpCustomer.getNickName())
.boardedAt(comments.getBoardedAt())
.contents(comments.getContents())
.build();
commentsResponseArrayList.add(commentsResponse);
}
CommentsListResponse commentsListResponse = CommentsListResponse.builder()
.commentsResponseArrayList(commentsResponseArrayList)
.build();
return Header.OK(commentsListResponse);
}
}
| UTF-8 | Java | 3,868 | java | CommentsService.java | Java | [] | null | [] | package com.example.demo.service;
import com.example.demo.model.entity.Board;
import com.example.demo.model.entity.Comments;
import com.example.demo.model.entity.Customer;
import com.example.demo.model.network.Header;
import com.example.demo.model.network.request.CommentsRequest;
import com.example.demo.model.network.response.BoardListResponse;
import com.example.demo.model.network.response.BoardResponse;
import com.example.demo.model.network.response.CommentsListResponse;
import com.example.demo.model.network.response.CommentsResponse;
import com.example.demo.repository.BoardRepository;
import com.example.demo.repository.CommentsRepository;
import com.example.demo.repository.CustomerRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.xml.stream.events.Comment;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
@Service
@Slf4j
public class CommentsService {
@Autowired
CommentsRepository commentsRepository;
@Autowired
BoardRepository boardRepository;
@Autowired
CustomerRepository customerRepository;
public Header<CommentsResponse> create(Header<CommentsRequest> request, String nickname){
CommentsRequest body = request.getData();
log.info("request: " + request);
log.info("body: " + body);
log.info("boardAuthor: " + body.getAuthor());
log.info("commentsAuthor: " + nickname);
Customer boardAuthor = customerRepository.findByNickNameLike(body.getAuthor());
Customer user = customerRepository.findByNickNameLike(nickname);
Board board = boardRepository.findByAuthorAndTitle(boardAuthor.getId(),body.getTitle());
Comments comments = Comments.builder()
.author(user.getId()) // comment author
.targetBoard(board.getId())
.contents(body.getContents())
.boardedAt(LocalDate.now())
.build();
Comments newComments = commentsRepository.save(comments);
Customer savedAuthor = customerRepository.findById(newComments.getAuthor()).get();
CommentsResponse commentsResponse = CommentsResponse.builder()
.author(savedAuthor.getNickName())
.contents(newComments.getContents())
.boardedAt(LocalDate.now())
.build();
return Header.OK(commentsResponse);
}
public Header<CommentsListResponse> getOneBoardCommentsList(String authorNickName, String title){
log.info("author Nickname: " + authorNickName);
log.info("title: " + title);
Customer author = customerRepository.findByNickNameLike(authorNickName);
log.info("author: " + author);
Board board = boardRepository.findByAuthorAndTitle(author.getId(),title);
log.info("board: " + board);
ArrayList<Comments> commentsList = (ArrayList<Comments>)(commentsRepository.findByTargetBoard(board.getId()));
ArrayList<CommentsResponse> commentsResponseArrayList = new ArrayList<CommentsResponse>();
for(Comments comments : commentsList){
Customer tmpCustomer = customerRepository.findById(comments.getAuthor()).get();
CommentsResponse commentsResponse = CommentsResponse.builder()
.author(tmpCustomer.getNickName())
.boardedAt(comments.getBoardedAt())
.contents(comments.getContents())
.build();
commentsResponseArrayList.add(commentsResponse);
}
CommentsListResponse commentsListResponse = CommentsListResponse.builder()
.commentsResponseArrayList(commentsResponseArrayList)
.build();
return Header.OK(commentsListResponse);
}
}
| 3,868 | 0.701655 | 0.700879 | 98 | 38.469387 | 29.731865 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.540816 | false | false | 15 |
eaa29bf04043ee2ddef6b8fdadb5b32da43af975 | 28,166,395,585,405 | 459225ed1cbb1ec4736dead1a57457f69a23a75d | /src/main/java/ch/slrg/mvp/repository/EducationRepository.java | 5bf6e448f837b9b8aff2d47e2365e6e6ea0751fa | [] | no_license | BulkSecurityGeneratorProject/slrgluzern | https://github.com/BulkSecurityGeneratorProject/slrgluzern | 1dc226c06e31c7db9e8bd2cc09c02bc8df4e7f99 | b40cb5132febe757678c8392a193effc940fb5dd | refs/heads/master | 2022-12-17T08:57:24.624000 | 2016-08-25T05:40:24 | 2016-08-25T05:40:24 | 296,548,941 | 0 | 0 | null | true | 2020-09-18T07:37:54 | 2020-09-18T07:37:54 | 2016-06-28T19:39:47 | 2016-08-25T05:40:28 | 4,589 | 0 | 0 | 0 | null | false | false | package ch.slrg.mvp.repository;
import ch.slrg.mvp.domain.Education;
import org.springframework.data.jpa.repository.*;
import java.util.List;
/**
* Spring Data JPA repository for the Education entity.
*/
@SuppressWarnings("unused")
public interface EducationRepository extends JpaRepository<Education,Long> {
List<Education> findEducationByMemberId(long id);
}
| UTF-8 | Java | 372 | java | EducationRepository.java | Java | [] | null | [] | package ch.slrg.mvp.repository;
import ch.slrg.mvp.domain.Education;
import org.springframework.data.jpa.repository.*;
import java.util.List;
/**
* Spring Data JPA repository for the Education entity.
*/
@SuppressWarnings("unused")
public interface EducationRepository extends JpaRepository<Education,Long> {
List<Education> findEducationByMemberId(long id);
}
| 372 | 0.77957 | 0.77957 | 16 | 22.25 | 24.468092 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 15 |
fd428ebecca889052512e9d8b60e808ee84080dc | 1,142,461,324,371 | 812d8fe49a17e24d1840649158c49eb98093c94a | /brijframework-jpa/src/main/java/org/brijframework/jpa/factories/EntityConfigFactory.java | 9c629c7c31b078304ecfa62da4a874b685219fc2 | [] | no_license | brijframework/brijframework-boot-context | https://github.com/brijframework/brijframework-boot-context | 565c6960c365b905bdc001dcf6de20d9a0866814 | 0369bc986c6fedcaca495306e33ac000fb10038f | refs/heads/master | 2020-12-09T20:25:26.643000 | 2020-03-12T15:14:22 | 2020-03-12T15:14:22 | 233,409,247 | 0 | 0 | null | false | 2020-01-12T16:54:40 | 2020-01-12T14:55:59 | 2020-01-12T16:54:22 | 2020-01-12T16:54:39 | 354 | 0 | 0 | 1 | Java | false | false | package org.brijframework.jpa.factories;
import static org.brijframework.jpa.util.EntityConstants.REF;
import java.util.LinkedHashMap;
import java.util.Map;
import org.brijframework.jpa.container.EntityConfigContainer;
import org.brijframework.jpa.context.EntityContext;
import org.brijframework.jpa.files.ModelData;
import org.brijframework.util.accessor.PropertyAccessorUtil;
public class EntityConfigFactory{
private LinkedHashMap<String, Object> cache = new LinkedHashMap<>();
private EntityConfigContainer container=EntityConfigContainer.getContainer();
private EntityContext entityContext;
public void setContext(EntityContext entityContext) {
this.entityContext=entityContext;
}
public EntityContext getContext() {
return entityContext;
}
public void register(String id,Object model) {
getCache().put(id, model);
loadInContainer(id, model);
}
@SuppressWarnings("unchecked")
public <T> T find(String key) {
T t=(T) getCache().get(key);
if(t!=null) {
return t;
}
return findInContainer(key);
}
@SuppressWarnings("unchecked")
public void mergeRelationship(ModelData data,Object model){
data.getProperties().forEach((key, val) -> {
if (val instanceof Map) {
Map<String, Object> mapVal = (Map<String, Object>) val;
String ref = (String) mapVal.get(REF);
if (ref != null) {
val =getContainer().find(ref);
} else {
val = mapVal;
}
PropertyAccessorUtil.setProperty(model, key, val);
}
});
}
public void loadInContainer(String id,Object model) {
if(getContainer()==null) {
return;
}
if(getContainer().find(id)==null) {
getContainer().register(id, model);
}
}
public <T> T findInContainer(String model) {
if(getContainer()==null) {
return null;
}
return getContainer().find(model);
}
public EntityConfigContainer getContainer() {
return container;
}
public void setContainer(EntityConfigContainer container) {
this.container = container;
}
public LinkedHashMap<String, Object> getCache() {
return cache;
}
public void loadFactory() {
}
}
| UTF-8 | Java | 2,083 | java | EntityConfigFactory.java | Java | [] | null | [] | package org.brijframework.jpa.factories;
import static org.brijframework.jpa.util.EntityConstants.REF;
import java.util.LinkedHashMap;
import java.util.Map;
import org.brijframework.jpa.container.EntityConfigContainer;
import org.brijframework.jpa.context.EntityContext;
import org.brijframework.jpa.files.ModelData;
import org.brijframework.util.accessor.PropertyAccessorUtil;
public class EntityConfigFactory{
private LinkedHashMap<String, Object> cache = new LinkedHashMap<>();
private EntityConfigContainer container=EntityConfigContainer.getContainer();
private EntityContext entityContext;
public void setContext(EntityContext entityContext) {
this.entityContext=entityContext;
}
public EntityContext getContext() {
return entityContext;
}
public void register(String id,Object model) {
getCache().put(id, model);
loadInContainer(id, model);
}
@SuppressWarnings("unchecked")
public <T> T find(String key) {
T t=(T) getCache().get(key);
if(t!=null) {
return t;
}
return findInContainer(key);
}
@SuppressWarnings("unchecked")
public void mergeRelationship(ModelData data,Object model){
data.getProperties().forEach((key, val) -> {
if (val instanceof Map) {
Map<String, Object> mapVal = (Map<String, Object>) val;
String ref = (String) mapVal.get(REF);
if (ref != null) {
val =getContainer().find(ref);
} else {
val = mapVal;
}
PropertyAccessorUtil.setProperty(model, key, val);
}
});
}
public void loadInContainer(String id,Object model) {
if(getContainer()==null) {
return;
}
if(getContainer().find(id)==null) {
getContainer().register(id, model);
}
}
public <T> T findInContainer(String model) {
if(getContainer()==null) {
return null;
}
return getContainer().find(model);
}
public EntityConfigContainer getContainer() {
return container;
}
public void setContainer(EntityConfigContainer container) {
this.container = container;
}
public LinkedHashMap<String, Object> getCache() {
return cache;
}
public void loadFactory() {
}
}
| 2,083 | 0.718195 | 0.718195 | 89 | 22.404495 | 21.352957 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.955056 | false | false | 15 |
6658939b6ba05a2364fa71e9c0c8742097a5559b | 17,059,610,144,424 | b84b0a8084a948b668357c3e02ad750f85213593 | /app/src/test/java/IO/IO_project/TournamentLadderTest.java | 6660707c1365c464cde2984f4068dfc981dc545a | [] | no_license | pawelrys/TableTennisApp | https://github.com/pawelrys/TableTennisApp | 344fe3d9ef2879e6e103eb0e76c2baf491465f00 | a7cb7c74e29aa6669a6d47c0feeca2dfcaf5b2c0 | refs/heads/master | 2022-10-28T05:55:08.626000 | 2020-06-12T21:31:40 | 2020-06-12T21:31:40 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package IO.IO_project;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
@RunWith(AndroidJUnit4.class)
public class TournamentLadderTest {
// @Test
// public void checkPlayersSpacing_isCorrect(){ //sprawdzanie czy rozstawianie dziala prawidlowo
// // given
// databaseAdmin db = new databaseAdmin(ApplicationProvider.getApplicationContext());
// Player player1 = new Player("Bartek1", "Kowalski1", "M", "01-01-1999", "ULKS Krakow", "Junior", 125);
// Player player2 = new Player("Mikołaj2", "Kowalski2", "M", "01-01-1999", "ULKS Krakow", "Junior", 225);
// Player player3 = new Player("Tadeusz3", "Kowalski3", "M", "01-01-1999", "ULKS Krakow", "Junior", 325);
// Player player4 = new Player("Maciej4", "Kowalski4", "M", "01-01-1999", "ULKS Krakow", "Junior", 425);
// db.addPlayer(player1);
// db.addPlayer(player2);
// db.addPlayer(player3);
// db.addPlayer(player4);
// db.addPlayerToTournament(player1);
// db.addPlayerToTournament(player2);
// db.addPlayerToTournament(player3);
// db.addPlayerToTournament(player4);
// Cursor k = db.showPlayersTournamentOrderByPunkty();
//
// // when
// boolean result = spacePlayerPage.spacingPlayers(4, 0, k, db); //funkcja rozstawia zawodnikow po punktach, zwraca true jezeli wszystko sie wykonalo prawidlowo
//
// // then
// assertTrue(result);
// db.close();
// }
//
// @Test
// public void checkPlayersRandom_isCorrect(){ //sprawdzenie czy losowanie dziala prawidlowo
// //given
// databaseAdmin db = new databaseAdmin(ApplicationProvider.getApplicationContext());
// Player player1 = new Player("Bartek5", "Kowalski1", "M", "01-01-1999", "ULKS Krakow", "Junior", 125);
// Player player2 = new Player("Mikołaj6", "Kowalski2", "M", "01-01-1999", "ULKS Krakow", "Junior", 225);
// Player player3 = new Player("Tadeusz7", "Kowalski3", "M", "01-01-1999", "ULKS Krakow", "Junior", 325);
// Player player4 = new Player("Maciej8", "Kowalski4", "M", "01-01-1999", "ULKS Krakow", "Junior", 425);
// db.addPlayer(player1);
// db.addPlayer(player2);
// db.addPlayer(player3);
// db.addPlayer(player4);
// db.addPlayerToTournament(player1);
// db.addPlayerToTournament(player2);
// db.addPlayerToTournament(player3);
// db.addPlayerToTournament(player4);
// Cursor k = db.showPlayersTournamentOrderByPunkty();
//
// // when
// boolean result = randomPlayerPage.randomPlayer(4, 4, k, db); //funkcja rozstawia zawodnikow po punktach, zwraca true jezeli wszystko sie wykonalo prawidlowo
//
// // then
// assertTrue(result);
// db.close();
// }
@Test
public void check1AdditionMatch_isCorrect(){ //Sprawdzanie dodawania meczy
// given
databaseAdmin db = new databaseAdmin(ApplicationProvider.getApplicationContext());
Player player1 = new Player("Bartek76", "Kowalski", "M", "01-01-1999", "ULKS Krakow", "Junior", 25);
Player player2 = new Player("Maciej43", "Boryna", "M", "01-01-1999", "ULKS Krakow", "Junior", 25);
Match match = new Match(1, player1.getID(), player2.getID());
// when
boolean result = db.addMatch(match);; //jesli mecz dodano prawidlowo, to liczba meczy++
// then
assertTrue(result);
db.close();
}
@Test
public void check2AdditionMatch_isCorrect(){ //Sprawdzanie dodawania meczy
// given
databaseAdmin db = new databaseAdmin(ApplicationProvider.getApplicationContext());
Player player1 = new Player("Bartek42", "Kowalski", "M", "01-01-1999", "ULKS Krakow", "Junior", 25);
Match match = new Match(1, player1.getID(), player1.getID());
// when
boolean result = db.addMatch(match); //jesli mecz dodano prawidlowo, to liczba meczy++
// then
assertFalse(result);
db.close();
}
}
| UTF-8 | Java | 4,228 | java | TournamentLadderTest.java | Java | [
{
"context": "ontext());\n// Player player1 = new Player(\"Bartek1\", \"Kowalski1\", \"M\", \"01-01-1999\", \"ULKS Krakow\", ",
"end": 629,
"score": 0.9052317142486572,
"start": 622,
"tag": "NAME",
"value": "Bartek1"
},
{
"context": "// Player player1 = new Player(\"Bartek1\", \"Kowalski1\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 125",
"end": 642,
"score": 0.899631142616272,
"start": 633,
"tag": "NAME",
"value": "Kowalski1"
},
{
"context": "or\", 125);\n// Player player2 = new Player(\"Mikołaj2\", \"Kowalski2\", \"M\", \"01-01-1999\", \"ULKS Krakow\", ",
"end": 742,
"score": 0.9528661966323853,
"start": 734,
"tag": "NAME",
"value": "Mikołaj2"
},
{
"context": "/ Player player2 = new Player(\"Mikołaj2\", \"Kowalski2\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 225",
"end": 755,
"score": 0.9504960775375366,
"start": 746,
"tag": "NAME",
"value": "Kowalski2"
},
{
"context": "or\", 225);\n// Player player3 = new Player(\"Tadeusz3\", \"Kowalski3\", \"M\", \"01-01-1999\", \"ULKS Krakow\", ",
"end": 855,
"score": 0.9638226628303528,
"start": 847,
"tag": "NAME",
"value": "Tadeusz3"
},
{
"context": "/ Player player3 = new Player(\"Tadeusz3\", \"Kowalski3\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 325",
"end": 868,
"score": 0.9448687434196472,
"start": 859,
"tag": "NAME",
"value": "Kowalski3"
},
{
"context": "or\", 325);\n// Player player4 = new Player(\"Maciej4\", \"Kowalski4\", \"M\", \"01-01-1999\", \"ULKS Krakow\", ",
"end": 967,
"score": 0.9061816334724426,
"start": 960,
"tag": "NAME",
"value": "Maciej4"
},
{
"context": "// Player player4 = new Player(\"Maciej4\", \"Kowalski4\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 425",
"end": 980,
"score": 0.9376394152641296,
"start": 971,
"tag": "NAME",
"value": "Kowalski4"
},
{
"context": "ontext());\n// Player player1 = new Player(\"Bartek5\", \"Kowalski1\", \"M\", \"01-01-1999\", \"ULKS Krakow\",",
"end": 1944,
"score": 0.9386177062988281,
"start": 1938,
"tag": "NAME",
"value": "Bartek"
},
{
"context": "());\n// Player player1 = new Player(\"Bartek5\", \"Kowalski1\", \"M\", \"01-01-1999\", \"ULKS Krakow\", ",
"end": 1945,
"score": 0.5834831595420837,
"start": 1944,
"tag": "USERNAME",
"value": "5"
},
{
"context": "// Player player1 = new Player(\"Bartek5\", \"Kowalski1\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 125",
"end": 1958,
"score": 0.9212943911552429,
"start": 1949,
"tag": "NAME",
"value": "Kowalski1"
},
{
"context": "yer player1 = new Player(\"Bartek5\", \"Kowalski1\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 125);\n//",
"end": 1963,
"score": 0.560431718826294,
"start": 1962,
"tag": "NAME",
"value": "M"
},
{
"context": "or\", 125);\n// Player player2 = new Player(\"Mikołaj6\", \"Kowalski2\", \"M\", \"01-01-1999\", \"ULKS Krakow\", ",
"end": 2058,
"score": 0.9611312747001648,
"start": 2050,
"tag": "NAME",
"value": "Mikołaj6"
},
{
"context": "/ Player player2 = new Player(\"Mikołaj6\", \"Kowalski2\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 225",
"end": 2071,
"score": 0.9805803298950195,
"start": 2062,
"tag": "NAME",
"value": "Kowalski2"
},
{
"context": "er player2 = new Player(\"Mikołaj6\", \"Kowalski2\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 225);\n//",
"end": 2076,
"score": 0.5449278354644775,
"start": 2075,
"tag": "NAME",
"value": "M"
},
{
"context": "or\", 225);\n// Player player3 = new Player(\"Tadeusz7\", \"Kowalski3\", \"M\", \"01-01-1999\", \"ULKS Krakow\"",
"end": 2169,
"score": 0.8324101567268372,
"start": 2163,
"tag": "NAME",
"value": "Tadeus"
},
{
"context": "25);\n// Player player3 = new Player(\"Tadeusz7\", \"Kowalski3\", \"M\", \"01-01-1999\", \"ULKS Krakow\", ",
"end": 2171,
"score": 0.7189352512359619,
"start": 2169,
"tag": "USERNAME",
"value": "z7"
},
{
"context": "/ Player player3 = new Player(\"Tadeusz7\", \"Kowalski3\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 325",
"end": 2184,
"score": 0.9494732618331909,
"start": 2175,
"tag": "NAME",
"value": "Kowalski3"
},
{
"context": "er player3 = new Player(\"Tadeusz7\", \"Kowalski3\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 325);\n//",
"end": 2189,
"score": 0.6206039190292358,
"start": 2188,
"tag": "NAME",
"value": "M"
},
{
"context": "eusz7\", \"Kowalski3\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 325);\n// Player player4 = new ",
"end": 2218,
"score": 0.537794828414917,
"start": 2216,
"tag": "NAME",
"value": "ow"
},
{
"context": "or\", 325);\n// Player player4 = new Player(\"Maciej8\", \"Kowalski4\", \"M\", \"01-01-1999\", \"ULKS Krakow\",",
"end": 2282,
"score": 0.7677389979362488,
"start": 2276,
"tag": "NAME",
"value": "Maciej"
},
{
"context": "25);\n// Player player4 = new Player(\"Maciej8\", \"Kowalski4\", \"M\", \"01-01-1999\", \"ULKS Krakow\", ",
"end": 2283,
"score": 0.677995502948761,
"start": 2282,
"tag": "USERNAME",
"value": "8"
},
{
"context": "// Player player4 = new Player(\"Maciej8\", \"Kowalski4\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 425",
"end": 2296,
"score": 0.9726177453994751,
"start": 2287,
"tag": "NAME",
"value": "Kowalski4"
},
{
"context": "yer player4 = new Player(\"Maciej8\", \"Kowalski4\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 425);\n//",
"end": 2301,
"score": 0.6421971917152405,
"start": 2300,
"tag": "NAME",
"value": "M"
},
{
"context": "nContext());\n Player player1 = new Player(\"Bartek76\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Kra",
"end": 3229,
"score": 0.9955736398696899,
"start": 3228,
"tag": "USERNAME",
"value": "B"
},
{
"context": "Context());\n Player player1 = new Player(\"Bartek76\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Krakow",
"end": 3232,
"score": 0.7535684704780579,
"start": 3229,
"tag": "NAME",
"value": "art"
},
{
"context": "text());\n Player player1 = new Player(\"Bartek76\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"",
"end": 3236,
"score": 0.9763097763061523,
"start": 3232,
"tag": "USERNAME",
"value": "ek76"
},
{
"context": "\n Player player1 = new Player(\"Bartek76\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 25)",
"end": 3248,
"score": 0.9991739392280579,
"start": 3240,
"tag": "NAME",
"value": "Kowalski"
},
{
"context": "yer player1 = new Player(\"Bartek76\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 25);\n ",
"end": 3253,
"score": 0.964392364025116,
"start": 3252,
"tag": "NAME",
"value": "M"
},
{
"context": "layer(\"Bartek76\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 25);\n Player player2 = new Pla",
"end": 3282,
"score": 0.9853790998458862,
"start": 3271,
"tag": "NAME",
"value": "ULKS Krakow"
},
{
"context": "unior\", 25);\n Player player2 = new Player(\"Maciej43\", \"Boryna\", \"M\", \"01-01-1999\", \"ULKS Krakow\"",
"end": 3340,
"score": 0.9452642202377319,
"start": 3337,
"tag": "USERNAME",
"value": "Mac"
},
{
"context": "or\", 25);\n Player player2 = new Player(\"Maciej43\", \"Boryna\", \"M\", \"01-01-1999\", \"ULKS Krakow\", ",
"end": 3342,
"score": 0.5839024782180786,
"start": 3340,
"tag": "NAME",
"value": "ie"
},
{
"context": "\", 25);\n Player player2 = new Player(\"Maciej43\", \"Boryna\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Ju",
"end": 3345,
"score": 0.865656852722168,
"start": 3342,
"tag": "USERNAME",
"value": "j43"
},
{
"context": "\n Player player2 = new Player(\"Maciej43\", \"Boryna\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 25)",
"end": 3355,
"score": 0.9987913966178894,
"start": 3349,
"tag": "NAME",
"value": "Boryna"
},
{
"context": "layer player2 = new Player(\"Maciej43\", \"Boryna\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 25);\n ",
"end": 3360,
"score": 0.9170395135879517,
"start": 3359,
"tag": "NAME",
"value": "M"
},
{
"context": " Player(\"Maciej43\", \"Boryna\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 25);\n Match match = new Match(",
"end": 3389,
"score": 0.9890144467353821,
"start": 3378,
"tag": "NAME",
"value": "ULKS Krakow"
},
{
"context": "nContext());\n Player player1 = new Player(\"Bartek42\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Kra",
"end": 3898,
"score": 0.9402633905410767,
"start": 3897,
"tag": "USERNAME",
"value": "B"
},
{
"context": "Context());\n Player player1 = new Player(\"Bartek42\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Krakow",
"end": 3901,
"score": 0.9503064751625061,
"start": 3898,
"tag": "NAME",
"value": "art"
},
{
"context": "text());\n Player player1 = new Player(\"Bartek42\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"",
"end": 3905,
"score": 0.8774819374084473,
"start": 3901,
"tag": "USERNAME",
"value": "ek42"
},
{
"context": "\n Player player1 = new Player(\"Bartek42\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 25)",
"end": 3917,
"score": 0.9993929266929626,
"start": 3909,
"tag": "NAME",
"value": "Kowalski"
},
{
"context": "yer player1 = new Player(\"Bartek42\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 25);\n ",
"end": 3922,
"score": 0.945193350315094,
"start": 3921,
"tag": "NAME",
"value": "M"
},
{
"context": "layer(\"Bartek42\", \"Kowalski\", \"M\", \"01-01-1999\", \"ULKS Krakow\", \"Junior\", 25);\n Match match = new Match(",
"end": 3951,
"score": 0.9947208166122437,
"start": 3940,
"tag": "NAME",
"value": "ULKS Krakow"
}
] | null | [] | package IO.IO_project;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
@RunWith(AndroidJUnit4.class)
public class TournamentLadderTest {
// @Test
// public void checkPlayersSpacing_isCorrect(){ //sprawdzanie czy rozstawianie dziala prawidlowo
// // given
// databaseAdmin db = new databaseAdmin(ApplicationProvider.getApplicationContext());
// Player player1 = new Player("Bartek1", "Kowalski1", "M", "01-01-1999", "ULKS Krakow", "Junior", 125);
// Player player2 = new Player("Mikołaj2", "Kowalski2", "M", "01-01-1999", "ULKS Krakow", "Junior", 225);
// Player player3 = new Player("Tadeusz3", "Kowalski3", "M", "01-01-1999", "ULKS Krakow", "Junior", 325);
// Player player4 = new Player("Maciej4", "Kowalski4", "M", "01-01-1999", "ULKS Krakow", "Junior", 425);
// db.addPlayer(player1);
// db.addPlayer(player2);
// db.addPlayer(player3);
// db.addPlayer(player4);
// db.addPlayerToTournament(player1);
// db.addPlayerToTournament(player2);
// db.addPlayerToTournament(player3);
// db.addPlayerToTournament(player4);
// Cursor k = db.showPlayersTournamentOrderByPunkty();
//
// // when
// boolean result = spacePlayerPage.spacingPlayers(4, 0, k, db); //funkcja rozstawia zawodnikow po punktach, zwraca true jezeli wszystko sie wykonalo prawidlowo
//
// // then
// assertTrue(result);
// db.close();
// }
//
// @Test
// public void checkPlayersRandom_isCorrect(){ //sprawdzenie czy losowanie dziala prawidlowo
// //given
// databaseAdmin db = new databaseAdmin(ApplicationProvider.getApplicationContext());
// Player player1 = new Player("Bartek5", "Kowalski1", "M", "01-01-1999", "ULKS Krakow", "Junior", 125);
// Player player2 = new Player("Mikołaj6", "Kowalski2", "M", "01-01-1999", "ULKS Krakow", "Junior", 225);
// Player player3 = new Player("Tadeusz7", "Kowalski3", "M", "01-01-1999", "ULKS Krakow", "Junior", 325);
// Player player4 = new Player("Maciej8", "Kowalski4", "M", "01-01-1999", "ULKS Krakow", "Junior", 425);
// db.addPlayer(player1);
// db.addPlayer(player2);
// db.addPlayer(player3);
// db.addPlayer(player4);
// db.addPlayerToTournament(player1);
// db.addPlayerToTournament(player2);
// db.addPlayerToTournament(player3);
// db.addPlayerToTournament(player4);
// Cursor k = db.showPlayersTournamentOrderByPunkty();
//
// // when
// boolean result = randomPlayerPage.randomPlayer(4, 4, k, db); //funkcja rozstawia zawodnikow po punktach, zwraca true jezeli wszystko sie wykonalo prawidlowo
//
// // then
// assertTrue(result);
// db.close();
// }
@Test
public void check1AdditionMatch_isCorrect(){ //Sprawdzanie dodawania meczy
// given
databaseAdmin db = new databaseAdmin(ApplicationProvider.getApplicationContext());
Player player1 = new Player("Bartek76", "Kowalski", "M", "01-01-1999", "<NAME>", "Junior", 25);
Player player2 = new Player("Maciej43", "Boryna", "M", "01-01-1999", "<NAME>", "Junior", 25);
Match match = new Match(1, player1.getID(), player2.getID());
// when
boolean result = db.addMatch(match);; //jesli mecz dodano prawidlowo, to liczba meczy++
// then
assertTrue(result);
db.close();
}
@Test
public void check2AdditionMatch_isCorrect(){ //Sprawdzanie dodawania meczy
// given
databaseAdmin db = new databaseAdmin(ApplicationProvider.getApplicationContext());
Player player1 = new Player("Bartek42", "Kowalski", "M", "01-01-1999", "<NAME>", "Junior", 25);
Match match = new Match(1, player1.getID(), player1.getID());
// when
boolean result = db.addMatch(match); //jesli mecz dodano prawidlowo, to liczba meczy++
// then
assertFalse(result);
db.close();
}
}
| 4,213 | 0.637246 | 0.594416 | 97 | 42.567009 | 40.621437 | 167 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.391753 | false | false | 15 |
91937a387d409063f2d6b9f19b373ba207b9f976 | 13,005,160,975,015 | f31b5b1e94327f361346680c8a4ce27265a4b43b | /src/test/java/com/ajmspring/org/window/WindowSwitchTest.java | cf5b57508b49128f284c47a3e5f04cfd2924c323 | [] | no_license | anjoepax/selenium-springboot | https://github.com/anjoepax/selenium-springboot | c1857ac7c1574a03b7aeddac97bd0390e6fa6692 | cf25387392da7d0ae7499c192650b7898c1d4023 | refs/heads/master | 2023-07-17T21:14:35.678000 | 2021-09-04T17:30:49 | 2021-09-04T17:30:49 | 402,735,221 | 2 | 0 | null | false | 2021-09-04T17:30:50 | 2021-09-03T10:43:31 | 2021-09-04T16:48:40 | 2021-09-04T17:30:49 | 83 | 0 | 0 | 0 | Java | false | false | package com.ajmspring.org.window;
import com.ajmspring.org.page.window.MainPage;
import com.ajmspring.org.page.window.PageA;
import com.ajmspring.org.page.window.PageB;
import com.ajmspring.org.page.window.PageC;
import com.ajmspring.org.test.SpringBaseTestNgTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.TestPropertySource;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@TestPropertySource(properties = "browser=chrome")
public class WindowSwitchTest extends SpringBaseTestNgTest {
@Autowired
private MainPage mainPage;
@Autowired
private PageA pageA;
@Autowired
private PageB pageB;
@Autowired
private PageC pageC;
@BeforeClass
public void setUp() {
this.mainPage.goTo();
this.mainPage.isAt();
this.mainPage.launchAllWindows();
}
@Test(dataProvider = "getData")
public void switchTest(int index) {
this.pageA.addToArea(index + "\n");
this.pageB.addToArea((index * 2) + "\n");
this.pageC.addToArea((index * 3) + "\n");
}
@DataProvider
public Object[] getData() {
return new Object[] {
3,
4,
1,
5,
6,
2
};
}
}
| UTF-8 | Java | 1,376 | java | WindowSwitchTest.java | Java | [] | null | [] | package com.ajmspring.org.window;
import com.ajmspring.org.page.window.MainPage;
import com.ajmspring.org.page.window.PageA;
import com.ajmspring.org.page.window.PageB;
import com.ajmspring.org.page.window.PageC;
import com.ajmspring.org.test.SpringBaseTestNgTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.TestPropertySource;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@TestPropertySource(properties = "browser=chrome")
public class WindowSwitchTest extends SpringBaseTestNgTest {
@Autowired
private MainPage mainPage;
@Autowired
private PageA pageA;
@Autowired
private PageB pageB;
@Autowired
private PageC pageC;
@BeforeClass
public void setUp() {
this.mainPage.goTo();
this.mainPage.isAt();
this.mainPage.launchAllWindows();
}
@Test(dataProvider = "getData")
public void switchTest(int index) {
this.pageA.addToArea(index + "\n");
this.pageB.addToArea((index * 2) + "\n");
this.pageC.addToArea((index * 3) + "\n");
}
@DataProvider
public Object[] getData() {
return new Object[] {
3,
4,
1,
5,
6,
2
};
}
}
| 1,376 | 0.654797 | 0.648983 | 54 | 24.462963 | 18.320917 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 15 |
97e2dca4cb3e61618da0ed6ae6d32ea142290a6f | 19,567,871,033,163 | 89a2a06a49902b58b7617447e4732e46a2a6ce7f | /ctci/java/00-Data-Structures/MyArrayStack.java | 9cabf0b68d49cdb579df9cc16d974d2d606996f7 | [] | no_license | j84guo/algorithms-and-data-structures | https://github.com/j84guo/algorithms-and-data-structures | b743ce5bb97e33814efbb465b4dce913a0db8824 | af6ec9c2c8bf4303be6df39ba4ee7265080c84d0 | refs/heads/master | 2020-02-15T02:15:15.287000 | 2019-06-05T14:23:53 | 2019-06-05T14:23:53 | 115,651,211 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class MyArrayStack<T extends Comparable>{
int size;
int minSize;
int maxSize;
int capacity;
Object[] A;
Object[] min;
Object[] max;
public MyArrayStack(int capacity){
this.size = 0;
this.capacity = capacity;
this.A = new Object[capacity];
this.min = new Object[capacity];
this.max = new Object[capacity];
}
public int size(){
return size;
}
public int capacity(){
return capacity;
}
public void push(T element){
if(size == capacity) ensureCapacity();
A[size] = element;
size++;
if(minSize == 0 || element.compareTo(min[minSize-1]) <= 0){
min[minSize] = element;
minSize++;
}
if(maxSize == 0 || element.compareTo(max[maxSize-1]) >= 0){
max[maxSize] = element;
maxSize++;
}
}
public T pop(){
if(size == 0) throw new RuntimeException("MyArrayStack is empty");
T element = (T) A[size-1];
size--;
if(element.compareTo(min[minSize-1]) == 0) minSize--;
if(element.compareTo(max[maxSize-1]) == 0) maxSize--;
return element;
}
private void ensureCapacity(){
Object[] tmp = new Object[capacity*2];
System.arraycopy(A, 0, tmp, 0, A.length);
A = tmp;
tmp = new Object[capacity*2];
System.arraycopy(min, 0, tmp, 0, min.length);
min = tmp;
tmp = new Object[capacity*2];
System.arraycopy(max, 0, tmp, 0, max.length);
max = tmp;
capacity *= 2;
}
public T min(){
if(size == 0) throw new RuntimeException("MyArrayStack is empty");
return (T) min[minSize-1];
}
public T max(){
if(size == 0) throw new RuntimeException("MyArrayStack is empty");
return (T) max[maxSize-1];
}
public static void main(String[] args){
// MyArrayStack<Integer> s = new MyArrayStack<>(3);
//
// s.push(10);
// s.push(5);
// s.push(7);
// s.push(8);
// s.push(9);
// s.push(20);
//
// s.pop();
// s.pop();
// s.pop();
// s.pop();
// s.pop();
//
// System.out.println(s.min());
// System.out.println(s.max());
}
}
| UTF-8 | Java | 2,073 | java | MyArrayStack.java | Java | [] | null | [] | public class MyArrayStack<T extends Comparable>{
int size;
int minSize;
int maxSize;
int capacity;
Object[] A;
Object[] min;
Object[] max;
public MyArrayStack(int capacity){
this.size = 0;
this.capacity = capacity;
this.A = new Object[capacity];
this.min = new Object[capacity];
this.max = new Object[capacity];
}
public int size(){
return size;
}
public int capacity(){
return capacity;
}
public void push(T element){
if(size == capacity) ensureCapacity();
A[size] = element;
size++;
if(minSize == 0 || element.compareTo(min[minSize-1]) <= 0){
min[minSize] = element;
minSize++;
}
if(maxSize == 0 || element.compareTo(max[maxSize-1]) >= 0){
max[maxSize] = element;
maxSize++;
}
}
public T pop(){
if(size == 0) throw new RuntimeException("MyArrayStack is empty");
T element = (T) A[size-1];
size--;
if(element.compareTo(min[minSize-1]) == 0) minSize--;
if(element.compareTo(max[maxSize-1]) == 0) maxSize--;
return element;
}
private void ensureCapacity(){
Object[] tmp = new Object[capacity*2];
System.arraycopy(A, 0, tmp, 0, A.length);
A = tmp;
tmp = new Object[capacity*2];
System.arraycopy(min, 0, tmp, 0, min.length);
min = tmp;
tmp = new Object[capacity*2];
System.arraycopy(max, 0, tmp, 0, max.length);
max = tmp;
capacity *= 2;
}
public T min(){
if(size == 0) throw new RuntimeException("MyArrayStack is empty");
return (T) min[minSize-1];
}
public T max(){
if(size == 0) throw new RuntimeException("MyArrayStack is empty");
return (T) max[maxSize-1];
}
public static void main(String[] args){
// MyArrayStack<Integer> s = new MyArrayStack<>(3);
//
// s.push(10);
// s.push(5);
// s.push(7);
// s.push(8);
// s.push(9);
// s.push(20);
//
// s.pop();
// s.pop();
// s.pop();
// s.pop();
// s.pop();
//
// System.out.println(s.min());
// System.out.println(s.max());
}
}
| 2,073 | 0.565847 | 0.54848 | 101 | 19.524752 | 18.515497 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.70297 | false | false | 15 |
a24c476ecde7141126476b37e227d4cda665f8a9 | 24,481,313,612,775 | 3fb75dda35139ed243a3dbe4cc8d7495416d28a0 | /osgi-bundles/bundles/kpm/src/main/java/org/killbill/billing/osgi/bundles/kpm/PluginFileService.java | 93c0e8d70ab006addc82d8ff446fb7d799acbda3 | [
"Apache-2.0"
] | permissive | killbill/killbill-platform | https://github.com/killbill/killbill-platform | b3c92b0cfd24669f50c49f21992afaa679ce4027 | 4fa797eaa30c82d0821c85daddf4a2e647794379 | refs/heads/master | 2023-09-02T01:36:46.693000 | 2023-07-13T20:20:27 | 2023-07-13T20:20:27 | 20,577,351 | 20 | 44 | Apache-2.0 | false | 2023-07-13T20:20:29 | 2014-06-06T20:34:36 | 2023-04-26T04:18:01 | 2023-07-13T20:20:27 | 233,699 | 21 | 38 | 6 | Java | false | false | /*
* Copyright 2020-2023 Equinix, Inc
* Copyright 2014-2023 The Billing Project, LLC
*
* The Billing Project 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.killbill.billing.osgi.bundles.kpm;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import javax.annotation.Nonnull;
public interface PluginFileService {
/**
* Get download path. This is usually temporary path where plugin file should be downloaded before processed further.
* This is satisfies "Current Implementation" point 5 section in
* <a href="https://github.com/killbill/technical-support/issues/92">this issue</a>.
*/
static Path createTmpDownloadPath() throws IOException {
return Files.createTempDirectory("kpm-" + System.currentTimeMillis()).toAbsolutePath();
}
/**
* Create directory for actual plugin location. {@link Path} object returned by this method:
* <ol>
* <li>Will actually exist in file system</li>
* <li>One of hierarchical sequence should contains correct <strong>plugin name</strong>.</li>
* <li>One of hierarchical sequence should contains version with public <strong>semantic versioning</strong> format.</li>
* <li>
* plugin name and version will always be in {@code <plugin-name><fs-separator><version>} format.
* For example {@code helloworld-plugin/3.0.0}, {@code super-plugin/4.3.1}, etc.
* </li>
* </ol>
*/
Path createPluginDirectory(String pluginKey, String pluginVersion) throws IOException;
/**
* Create symlink for directory. Port
* <a href="https://github.com/killbill/killbill-cloud/blob/master/kpm/lib/kpm/plugins_manager.rb#L22">setActive</a>
* operation.
*
* @return symlink {@link Path}.
*/
void createSymlink(@Nonnull final Path pluginDirectory) throws IOException;
Path getPluginDirByPluginKeyAndVersion(@Nonnull final String pluginKey, @Nonnull final String pluginVersion);
}
| UTF-8 | Java | 2,545 | java | PluginFileService.java | Java | [
{
"context": "t 5 section in\n * <a href=\"https://github.com/killbill/technical-support/issues/92\">this issue</a>.\n ",
"end": 1135,
"score": 0.9991980791091919,
"start": 1127,
"tag": "USERNAME",
"value": "killbill"
},
{
"context": "irectory. Port\n * <a href=\"https://github.com/killbill/killbill-cloud/blob/master/kpm/lib/kpm/plugins_ma",
"end": 2200,
"score": 0.9911288022994995,
"start": 2192,
"tag": "USERNAME",
"value": "killbill"
}
] | null | [] | /*
* Copyright 2020-2023 Equinix, Inc
* Copyright 2014-2023 The Billing Project, LLC
*
* The Billing Project 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.killbill.billing.osgi.bundles.kpm;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import javax.annotation.Nonnull;
public interface PluginFileService {
/**
* Get download path. This is usually temporary path where plugin file should be downloaded before processed further.
* This is satisfies "Current Implementation" point 5 section in
* <a href="https://github.com/killbill/technical-support/issues/92">this issue</a>.
*/
static Path createTmpDownloadPath() throws IOException {
return Files.createTempDirectory("kpm-" + System.currentTimeMillis()).toAbsolutePath();
}
/**
* Create directory for actual plugin location. {@link Path} object returned by this method:
* <ol>
* <li>Will actually exist in file system</li>
* <li>One of hierarchical sequence should contains correct <strong>plugin name</strong>.</li>
* <li>One of hierarchical sequence should contains version with public <strong>semantic versioning</strong> format.</li>
* <li>
* plugin name and version will always be in {@code <plugin-name><fs-separator><version>} format.
* For example {@code helloworld-plugin/3.0.0}, {@code super-plugin/4.3.1}, etc.
* </li>
* </ol>
*/
Path createPluginDirectory(String pluginKey, String pluginVersion) throws IOException;
/**
* Create symlink for directory. Port
* <a href="https://github.com/killbill/killbill-cloud/blob/master/kpm/lib/kpm/plugins_manager.rb#L22">setActive</a>
* operation.
*
* @return symlink {@link Path}.
*/
void createSymlink(@Nonnull final Path pluginDirectory) throws IOException;
Path getPluginDirByPluginKeyAndVersion(@Nonnull final String pluginKey, @Nonnull final String pluginVersion);
}
| 2,545 | 0.703733 | 0.691552 | 61 | 40.72131 | 39.34177 | 129 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.327869 | false | false | 15 |
ac1f718676826e5fd70bf774aabb697697764602 | 7,670,811,650,492 | 42f7aa7d21e41d0e3017f2dd3d71e116c27d5a6d | /Day6/MultiplicationTable.java | 07b6407527bd63605e2f0e6883e8fa3612de7d66 | [] | no_license | menwhitehead/CP122CS1 | https://github.com/menwhitehead/CP122CS1 | 0d8dbe15216cac328bc033a7d8f4172c9e1dd7bf | 98b5d8a7ebe85a81343b5975d90704f1577f105b | refs/heads/master | 2021-05-08T00:11:07.311000 | 2017-11-13T20:50:15 | 2017-11-13T20:50:15 | 107,600,469 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class MultiplicationTable {
public static void main(String[] args) {
int[][] mult_table = new int[12][12];
for (int row = 0; row < 12; row++) {
for (int col = 0; col < 12; col++) {
mult_table[row][col] = (row + 1) * (col + 1);
}
}
for (int row = 0; row < 12; row++) {
for (int col = 0; col < 12; col++) {
System.out.printf("%5d", mult_table[row][col]);
}
System.out.println();
}
}
}
| UTF-8 | Java | 483 | java | MultiplicationTable.java | Java | [] | null | [] |
public class MultiplicationTable {
public static void main(String[] args) {
int[][] mult_table = new int[12][12];
for (int row = 0; row < 12; row++) {
for (int col = 0; col < 12; col++) {
mult_table[row][col] = (row + 1) * (col + 1);
}
}
for (int row = 0; row < 12; row++) {
for (int col = 0; col < 12; col++) {
System.out.printf("%5d", mult_table[row][col]);
}
System.out.println();
}
}
}
| 483 | 0.465839 | 0.426501 | 21 | 21.904762 | 19.554331 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.619048 | false | false | 15 |
064bd8fd4989011988e0c7387e0c14dc82cd1342 | 17,093,969,891,077 | ecfa7bec36a1fe1a301654fb2e53e48b51af78e0 | /src/main/java/org/toucanpdf/font/parser/package-info.java | 2028cab5f566c0384e9a60a6872d69fb671113f4 | [] | no_license | 42BV/pdf-library | https://github.com/42BV/pdf-library | 30f60aa72af2f8d4785a7f5de182ed90ee846373 | 45360abdf5047896b903060aeabcb8862264da75 | refs/heads/master | 2021-01-10T20:43:14.407000 | 2016-01-15T11:08:46 | 2016-01-15T11:08:46 | 16,905,895 | 6 | 3 | null | false | 2016-01-05T12:22:45 | 2014-02-17T08:06:36 | 2016-01-05T10:20:41 | 2016-01-05T12:22:45 | 14,643 | 6 | 2 | 10 | Java | null | null | /**
* Provides classes necessary for parsing different font files and font types.
*/
package org.toucanpdf.font.parser;
| UTF-8 | Java | 123 | java | package-info.java | Java | [] | null | [] | /**
* Provides classes necessary for parsing different font files and font types.
*/
package org.toucanpdf.font.parser;
| 123 | 0.756098 | 0.756098 | 4 | 29.5 | 30.728651 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 15 |
61ea1b41a72ae35d13eaa586150530724c4b8d92 | 4,664,334,500,079 | 62f3fa07696daabd4e0ba2d3d505dc408ce62003 | /agt-parent/agt-desktop-gui/src/ru/mephi/agt/desktop/view/ContactsController.java | 074392c5c8782ff7b39a12c48733b1a1229b4766 | [] | no_license | androsovgr/agt | https://github.com/androsovgr/agt | 62ae2f257019cc9c9b2174d6318c84cc483afef5 | 5308c22ac40d19ef13a92e1909bf71d8798bcdf8 | refs/heads/master | 2021-01-01T05:46:47.052000 | 2014-12-07T20:23:12 | 2014-12-07T20:23:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ru.mephi.agt.desktop.view;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SelectionMode;
import javafx.stage.Stage;
import org.controlsfx.control.Notifications;
import org.controlsfx.dialog.Dialogs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.mephi.agt.desktop.MainApp;
import ru.mephi.agt.desktop.component.ContactListCell;
import ru.mephi.agt.desktop.model.ContactModel;
import ru.mephi.agt.desktop.model.extractor.ContactExtractor;
import ru.mephi.agt.desktop.util.ControllerUtil;
import ru.mephi.agt.desktop.util.ServerInteractor;
import ru.mephi.agt.model.Status;
import ru.mephi.agt.response.BaseResponse;
public class ContactsController {
private static final Logger LOGGER = LoggerFactory
.getLogger(ContactsController.class);
@FXML
private ListView<ContactModel> onlineListView;
@FXML
private ListView<ContactModel> offlineListView;
@FXML
private ListView<ContactModel> unknownListView;
@FXML
private MenuItem chatMenuItem;
@FXML
private MenuItem infoMenuItem;
@FXML
private MenuItem renameMenuItem;
@FXML
private MenuItem searchMenuItem;
@FXML
private MenuItem selfInfoMenuItem;
private MainApp mainApp;
private Stage stage;
private ObservableList<ContactModel> onlineList;
private ObservableList<ContactModel> unknownList;
private ObservableList<ContactModel> offlineList;
@FXML
private void initialize() {
addHandlersForLists();
addCellFactoriesForLists();
onlineList = FXCollections.observableArrayList(new ContactExtractor());
onlineListView.setItems(onlineList);
onlineListView.getSelectionModel().setSelectionMode(
SelectionMode.SINGLE);
offlineList = FXCollections.observableArrayList(new ContactExtractor());
offlineListView.setItems(offlineList);
offlineListView.getSelectionModel().setSelectionMode(
SelectionMode.SINGLE);
unknownList = FXCollections.observableArrayList(new ContactExtractor());
unknownListView.setItems(unknownList);
unknownListView.getSelectionModel().setSelectionMode(
SelectionMode.SINGLE);
}
public void updateContactList(List<ContactModel> delta) {
selectionHandler(delta);
checkStatusChangeWithReplace();
}
private void checkStatusChangeWithReplace() {
checkStatusChangeWithReplaceForList(onlineList, Status.ONLINE);
checkStatusChangeWithReplaceForList(offlineList, Status.OFFLINE);
checkStatusChangeWithReplaceForList(unknownList, Status.UNKNOWN);
}
private void checkStatusChangeWithReplaceForList(
ObservableList<ContactModel> list, Status status) {
for (Iterator<ContactModel> iterator = list.iterator(); iterator
.hasNext();) {
ContactModel contactModel = iterator.next();
if (contactModel.getStatus() != status) {
iterator.remove();
if (contactModel.getStatus() == Status.ONLINE) {
onlineList.add(contactModel);
} else if (contactModel.getStatus() == Status.OFFLINE) {
offlineList.add(contactModel);
} else if (contactModel.getStatus() == Status.UNKNOWN) {
unknownList.add(contactModel);
} else {
LOGGER.warn("Unknown type of model: {}", contactModel);
}
}
}
}
@FXML
private void startChat(ActionEvent event) {
ContactModel selected = getSelected();
if (selected != null) {
mainApp.startChatWith(selected, true);
} else {
LOGGER.warn("Can't find selected item");
}
}
@FXML
private void showSelfInfo(ActionEvent event) {
mainApp.showSelfInfo();
}
@FXML
private void showInfo(ActionEvent event) {
ContactModel selected = getSelected();
if (selected != null) {
mainApp.showOtherInfo(selected.getUserId());
} else {
LOGGER.warn("Can't find selected item");
}
}
@FXML
private void startSearch() {
mainApp.showSearchStage();
}
@FXML
private void updateContact() {
ContactModel selected = getSelected();
if (selected != null) {
Optional<String> dialogResponse = Dialogs.create().owner(stage)
.title("Изменение контакта")
.message("Введите желаемое имя контакта:")
.showTextInput(selected.getDisplayName());
if (dialogResponse.isPresent()) {
String displayName = dialogResponse.get();
BaseResponse response = ServerInteractor.updateContact(
displayName, selected.getUserId(),
selected.getContactId(), mainApp.getUid(),
mainApp.getOwnId());
if (ControllerUtil.handleResponse(response)) {
Notifications
.create()
.title("Обновление контакта")
.text("Контакт " + displayName
+ " успешно обновлен").showInformation();
mainApp.updateContactMapPutIntoContacts();
}
}
}
}
private ContactModel getSelected() {
ContactModel selected = onlineListView.getSelectionModel()
.getSelectedItem();
if (selected == null) {
selected = offlineListView.getSelectionModel().getSelectedItem();
}
if (selected == null) {
selected = unknownListView.getSelectionModel().getSelectedItem();
}
return selected;
}
private void addHandlersForLists() {
onlineListView
.getSelectionModel()
.selectedItemProperty()
.addListener(
(observable, oldValue, newValue) -> dropOtherSelection(
newValue, onlineListView));
offlineListView
.getSelectionModel()
.selectedItemProperty()
.addListener(
(observable, oldValue, newValue) -> dropOtherSelection(
newValue, offlineListView));
unknownListView
.getSelectionModel()
.selectedItemProperty()
.addListener(
(observable, oldValue, newValue) -> dropOtherSelection(
newValue, unknownListView));
}
private void addCellFactoriesForLists() {
onlineListView.setCellFactory(column -> new ContactListCell());
offlineListView.setCellFactory(column -> new ContactListCell());
unknownListView.setCellFactory(column -> new ContactListCell());
}
private void dropOtherSelection(ContactModel newValue,
ListView<ContactModel> listView) {
if (newValue != null) {
if (!offlineListView.getId().equals(listView.getId())) {
offlineListView.getSelectionModel().clearSelection();
LOGGER.info("Cleared offline");
}
if (!onlineListView.getId().equals(listView.getId())) {
onlineListView.getSelectionModel().clearSelection();
LOGGER.info("Cleared online");
}
if (!unknownListView.getId().equals(listView.getId())) {
unknownListView.getSelectionModel().clearSelection();
}
} else {
offlineListView.getSelectionModel().clearSelection();
onlineListView.getSelectionModel().clearSelection();
unknownListView.getSelectionModel().clearSelection();
}
}
private void selectionHandler(List<ContactModel> delta) {
List<ContactModel> onlineContactModels = new ArrayList<ContactModel>();
for (ContactModel contactModel : delta) {
if (contactModel.getStatus().equals(Status.ONLINE)) {
onlineContactModels.add(contactModel);
}
}
onlineList.addAll(onlineContactModels);
// OFFLINE
List<ContactModel> offlineContactModels = new ArrayList<ContactModel>();
for (ContactModel contactModel : delta) {
if (contactModel.getStatus().equals(Status.OFFLINE)) {
offlineContactModels.add(contactModel);
}
}
offlineList.addAll(offlineContactModels);
// UNKNOWN
List<ContactModel> unknownContactModels = new ArrayList<ContactModel>();
for (ContactModel contactModel : delta) {
if (contactModel.getStatus().equals(Status.UNKNOWN)) {
unknownContactModels.add(contactModel);
}
}
unknownList.addAll(unknownContactModels);
}
@FXML
private void validateMenu() {
if (getSelected() == null) {
chatMenuItem.setDisable(true);
infoMenuItem.setDisable(true);
renameMenuItem.setDisable(true);
} else {
chatMenuItem.setDisable(false);
infoMenuItem.setDisable(false);
renameMenuItem.setDisable(false);
}
}
public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp;
}
public void setStage(Stage stage) {
this.stage = stage;
}
}
| WINDOWS-1251 | Java | 8,509 | java | ContactsController.java | Java | [] | null | [] | package ru.mephi.agt.desktop.view;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SelectionMode;
import javafx.stage.Stage;
import org.controlsfx.control.Notifications;
import org.controlsfx.dialog.Dialogs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.mephi.agt.desktop.MainApp;
import ru.mephi.agt.desktop.component.ContactListCell;
import ru.mephi.agt.desktop.model.ContactModel;
import ru.mephi.agt.desktop.model.extractor.ContactExtractor;
import ru.mephi.agt.desktop.util.ControllerUtil;
import ru.mephi.agt.desktop.util.ServerInteractor;
import ru.mephi.agt.model.Status;
import ru.mephi.agt.response.BaseResponse;
public class ContactsController {
private static final Logger LOGGER = LoggerFactory
.getLogger(ContactsController.class);
@FXML
private ListView<ContactModel> onlineListView;
@FXML
private ListView<ContactModel> offlineListView;
@FXML
private ListView<ContactModel> unknownListView;
@FXML
private MenuItem chatMenuItem;
@FXML
private MenuItem infoMenuItem;
@FXML
private MenuItem renameMenuItem;
@FXML
private MenuItem searchMenuItem;
@FXML
private MenuItem selfInfoMenuItem;
private MainApp mainApp;
private Stage stage;
private ObservableList<ContactModel> onlineList;
private ObservableList<ContactModel> unknownList;
private ObservableList<ContactModel> offlineList;
@FXML
private void initialize() {
addHandlersForLists();
addCellFactoriesForLists();
onlineList = FXCollections.observableArrayList(new ContactExtractor());
onlineListView.setItems(onlineList);
onlineListView.getSelectionModel().setSelectionMode(
SelectionMode.SINGLE);
offlineList = FXCollections.observableArrayList(new ContactExtractor());
offlineListView.setItems(offlineList);
offlineListView.getSelectionModel().setSelectionMode(
SelectionMode.SINGLE);
unknownList = FXCollections.observableArrayList(new ContactExtractor());
unknownListView.setItems(unknownList);
unknownListView.getSelectionModel().setSelectionMode(
SelectionMode.SINGLE);
}
public void updateContactList(List<ContactModel> delta) {
selectionHandler(delta);
checkStatusChangeWithReplace();
}
private void checkStatusChangeWithReplace() {
checkStatusChangeWithReplaceForList(onlineList, Status.ONLINE);
checkStatusChangeWithReplaceForList(offlineList, Status.OFFLINE);
checkStatusChangeWithReplaceForList(unknownList, Status.UNKNOWN);
}
private void checkStatusChangeWithReplaceForList(
ObservableList<ContactModel> list, Status status) {
for (Iterator<ContactModel> iterator = list.iterator(); iterator
.hasNext();) {
ContactModel contactModel = iterator.next();
if (contactModel.getStatus() != status) {
iterator.remove();
if (contactModel.getStatus() == Status.ONLINE) {
onlineList.add(contactModel);
} else if (contactModel.getStatus() == Status.OFFLINE) {
offlineList.add(contactModel);
} else if (contactModel.getStatus() == Status.UNKNOWN) {
unknownList.add(contactModel);
} else {
LOGGER.warn("Unknown type of model: {}", contactModel);
}
}
}
}
@FXML
private void startChat(ActionEvent event) {
ContactModel selected = getSelected();
if (selected != null) {
mainApp.startChatWith(selected, true);
} else {
LOGGER.warn("Can't find selected item");
}
}
@FXML
private void showSelfInfo(ActionEvent event) {
mainApp.showSelfInfo();
}
@FXML
private void showInfo(ActionEvent event) {
ContactModel selected = getSelected();
if (selected != null) {
mainApp.showOtherInfo(selected.getUserId());
} else {
LOGGER.warn("Can't find selected item");
}
}
@FXML
private void startSearch() {
mainApp.showSearchStage();
}
@FXML
private void updateContact() {
ContactModel selected = getSelected();
if (selected != null) {
Optional<String> dialogResponse = Dialogs.create().owner(stage)
.title("Изменение контакта")
.message("Введите желаемое имя контакта:")
.showTextInput(selected.getDisplayName());
if (dialogResponse.isPresent()) {
String displayName = dialogResponse.get();
BaseResponse response = ServerInteractor.updateContact(
displayName, selected.getUserId(),
selected.getContactId(), mainApp.getUid(),
mainApp.getOwnId());
if (ControllerUtil.handleResponse(response)) {
Notifications
.create()
.title("Обновление контакта")
.text("Контакт " + displayName
+ " успешно обновлен").showInformation();
mainApp.updateContactMapPutIntoContacts();
}
}
}
}
private ContactModel getSelected() {
ContactModel selected = onlineListView.getSelectionModel()
.getSelectedItem();
if (selected == null) {
selected = offlineListView.getSelectionModel().getSelectedItem();
}
if (selected == null) {
selected = unknownListView.getSelectionModel().getSelectedItem();
}
return selected;
}
private void addHandlersForLists() {
onlineListView
.getSelectionModel()
.selectedItemProperty()
.addListener(
(observable, oldValue, newValue) -> dropOtherSelection(
newValue, onlineListView));
offlineListView
.getSelectionModel()
.selectedItemProperty()
.addListener(
(observable, oldValue, newValue) -> dropOtherSelection(
newValue, offlineListView));
unknownListView
.getSelectionModel()
.selectedItemProperty()
.addListener(
(observable, oldValue, newValue) -> dropOtherSelection(
newValue, unknownListView));
}
private void addCellFactoriesForLists() {
onlineListView.setCellFactory(column -> new ContactListCell());
offlineListView.setCellFactory(column -> new ContactListCell());
unknownListView.setCellFactory(column -> new ContactListCell());
}
private void dropOtherSelection(ContactModel newValue,
ListView<ContactModel> listView) {
if (newValue != null) {
if (!offlineListView.getId().equals(listView.getId())) {
offlineListView.getSelectionModel().clearSelection();
LOGGER.info("Cleared offline");
}
if (!onlineListView.getId().equals(listView.getId())) {
onlineListView.getSelectionModel().clearSelection();
LOGGER.info("Cleared online");
}
if (!unknownListView.getId().equals(listView.getId())) {
unknownListView.getSelectionModel().clearSelection();
}
} else {
offlineListView.getSelectionModel().clearSelection();
onlineListView.getSelectionModel().clearSelection();
unknownListView.getSelectionModel().clearSelection();
}
}
private void selectionHandler(List<ContactModel> delta) {
List<ContactModel> onlineContactModels = new ArrayList<ContactModel>();
for (ContactModel contactModel : delta) {
if (contactModel.getStatus().equals(Status.ONLINE)) {
onlineContactModels.add(contactModel);
}
}
onlineList.addAll(onlineContactModels);
// OFFLINE
List<ContactModel> offlineContactModels = new ArrayList<ContactModel>();
for (ContactModel contactModel : delta) {
if (contactModel.getStatus().equals(Status.OFFLINE)) {
offlineContactModels.add(contactModel);
}
}
offlineList.addAll(offlineContactModels);
// UNKNOWN
List<ContactModel> unknownContactModels = new ArrayList<ContactModel>();
for (ContactModel contactModel : delta) {
if (contactModel.getStatus().equals(Status.UNKNOWN)) {
unknownContactModels.add(contactModel);
}
}
unknownList.addAll(unknownContactModels);
}
@FXML
private void validateMenu() {
if (getSelected() == null) {
chatMenuItem.setDisable(true);
infoMenuItem.setDisable(true);
renameMenuItem.setDisable(true);
} else {
chatMenuItem.setDisable(false);
infoMenuItem.setDisable(false);
renameMenuItem.setDisable(false);
}
}
public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp;
}
public void setStage(Stage stage) {
this.stage = stage;
}
}
| 8,509 | 0.718134 | 0.717897 | 280 | 28.092857 | 21.79184 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.485714 | false | false | 15 |
5ca7918e9e8f1b354c2291e24ed95c9fb33c3ee8 | 24,103,356,525,951 | a67513bd10fc8298e20b9b01a31edfa97a4e3c26 | /azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ARMResourceConnector.java | 47375c50f85a892abf789e51cbcfdf0141d7ff06 | [
"MIT"
] | permissive | smartmaster/azure-sdk-for-java | https://github.com/smartmaster/azure-sdk-for-java | 738014326d7e392c27b4982e13c88a595ccd760c | e0d20b240225c61ff25690158d02c1090db1c9f1 | refs/heads/master | 2019-07-06T22:10:59.488000 | 2016-05-23T22:01:02 | 2016-05-23T22:01:02 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.microsoft.azure.management.resources.implementation;
import com.microsoft.azure.management.resources.Deployments;
import com.microsoft.azure.management.resources.GenericResources;
import com.microsoft.azure.management.resources.ResourceConnector;
import com.microsoft.azure.management.resources.ResourceGroup;
import com.microsoft.rest.RestClient;
public class ARMResourceConnector extends ResourceConnectorBase {
private ResourceManager resourceClient;
private GenericResources.InGroup genericResources;
private Deployments.InGroup deployments;
private ARMResourceConnector(RestClient restClient, String subscriptionId, ResourceGroup resourceGroup) {
super(restClient, subscriptionId, resourceGroup);
}
private static ARMResourceConnector create(RestClient restClient, String subscriptionId, ResourceGroup resourceGroup) {
return new ARMResourceConnector(restClient, subscriptionId, resourceGroup);
}
public static class Builder implements ResourceConnector.Builder<ARMResourceConnector> {
public ARMResourceConnector create(RestClient restClient, String subscriptionId, ResourceGroup resourceGroup) {
return ARMResourceConnector.create(restClient, subscriptionId, resourceGroup);
}
}
public GenericResources.InGroup genericResources() {
if (genericResources == null) {
genericResources = new GenericResourcesInGroupImpl(resourceClient().genericResources(), resourceGroup);
}
return genericResources;
}
public Deployments.InGroup deployments() {
if (deployments == null) {
deployments = new DeploymentsInGroupImpl(resourceClient().deployments(), resourceGroup);
}
return deployments;
}
private ResourceManager resourceClient() {
if (resourceClient == null) {
resourceClient = ResourceManager
.authenticate(restClient)
.withSubscription(subscriptionId);
}
return resourceClient;
}
}
| UTF-8 | Java | 2,055 | java | ARMResourceConnector.java | Java | [] | null | [] | package com.microsoft.azure.management.resources.implementation;
import com.microsoft.azure.management.resources.Deployments;
import com.microsoft.azure.management.resources.GenericResources;
import com.microsoft.azure.management.resources.ResourceConnector;
import com.microsoft.azure.management.resources.ResourceGroup;
import com.microsoft.rest.RestClient;
public class ARMResourceConnector extends ResourceConnectorBase {
private ResourceManager resourceClient;
private GenericResources.InGroup genericResources;
private Deployments.InGroup deployments;
private ARMResourceConnector(RestClient restClient, String subscriptionId, ResourceGroup resourceGroup) {
super(restClient, subscriptionId, resourceGroup);
}
private static ARMResourceConnector create(RestClient restClient, String subscriptionId, ResourceGroup resourceGroup) {
return new ARMResourceConnector(restClient, subscriptionId, resourceGroup);
}
public static class Builder implements ResourceConnector.Builder<ARMResourceConnector> {
public ARMResourceConnector create(RestClient restClient, String subscriptionId, ResourceGroup resourceGroup) {
return ARMResourceConnector.create(restClient, subscriptionId, resourceGroup);
}
}
public GenericResources.InGroup genericResources() {
if (genericResources == null) {
genericResources = new GenericResourcesInGroupImpl(resourceClient().genericResources(), resourceGroup);
}
return genericResources;
}
public Deployments.InGroup deployments() {
if (deployments == null) {
deployments = new DeploymentsInGroupImpl(resourceClient().deployments(), resourceGroup);
}
return deployments;
}
private ResourceManager resourceClient() {
if (resourceClient == null) {
resourceClient = ResourceManager
.authenticate(restClient)
.withSubscription(subscriptionId);
}
return resourceClient;
}
}
| 2,055 | 0.739659 | 0.739659 | 50 | 40.099998 | 35.925617 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.64 | false | false | 15 |
a2ed5bc1061bef07c09fc2e39232668e1abd6d3c | 19,782,619,408,458 | d77daf9d36134aa739516f3085ef1e419d46fe2c | /Dubbo02-api/src/main/java/com/xp/api/IComment.java | bb7c7983677820c1aceb772f582cc0b0500a8eec | [] | no_license | xiaopGitHub/Dubbo02-PARENT | https://github.com/xiaopGitHub/Dubbo02-PARENT | c73c46afa9fd5778086332e2db176dcc80640d08 | 13a89ebc731675c00822a14562c8091d3b66145b | refs/heads/master | 2020-04-28T05:19:38.107000 | 2018-12-01T01:53:17 | 2018-12-01T01:53:17 | 175,015,415 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xp.api;
import com.xp.common.JSON;
import com.xp.vo.Comment;
import java.util.Map;
/**
* @author xp
* @create 2018/11/30 9:38
* @function 评论接口
*/
public interface IComment {
/*查询所有评论*/
JSON selectComments(Map<String,Integer> map);
/*删除指定评论*/
Integer deleteComment(Integer id);
/*添加评论*/
void insertComment(Comment comment);
/*修改评论*/
int updateComment(Comment comment);
}
| UTF-8 | Java | 473 | java | IComment.java | Java | [
{
"context": "vo.Comment;\n\nimport java.util.Map;\n\n/**\n * @author xp\n * @create 2018/11/30 9:38\n * @function 评论接口\n */",
"end": 115,
"score": 0.9984036087989807,
"start": 113,
"tag": "USERNAME",
"value": "xp"
}
] | null | [] | package com.xp.api;
import com.xp.common.JSON;
import com.xp.vo.Comment;
import java.util.Map;
/**
* @author xp
* @create 2018/11/30 9:38
* @function 评论接口
*/
public interface IComment {
/*查询所有评论*/
JSON selectComments(Map<String,Integer> map);
/*删除指定评论*/
Integer deleteComment(Integer id);
/*添加评论*/
void insertComment(Comment comment);
/*修改评论*/
int updateComment(Comment comment);
}
| 473 | 0.658824 | 0.632941 | 25 | 16 | 14.538225 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.36 | false | false | 15 |
626ee47ce643ef0166e1405ccc38625d1e26aaa6 | 27,307,402,121,795 | 8d20d875cedd14ba127031efa40f9bda8f7d2495 | /src/com/tencent/mm/ui/base/MMTagPanel$4.java | 0a5b23bfc7024aac08d6e9ffa4457ea2829edaf3 | [] | no_license | Gruop5/com.tencent.mm | https://github.com/Gruop5/com.tencent.mm | ab491f841daa8f5bee63b117412218b0bf18c894 | 43f057359bee12c5d52fa17e2e94b3772da5d94d | refs/heads/master | 2017-04-29T22:11:10.295000 | 2016-03-19T21:04:27 | 2016-03-19T21:04:27 | 62,294,225 | 0 | 0 | null | true | 2016-06-30T08:34:48 | 2016-06-30T08:34:46 | 2016-06-27T23:57:08 | 2016-03-19T21:07:01 | 74,626 | 0 | 0 | 0 | null | null | null | package com.tencent.mm.ui.base;
import android.view.View;
import android.view.View.OnClickListener;
import com.tencent.mm.sdk.platformtools.u;
final class MMTagPanel$4
implements View.OnClickListener
{
MMTagPanel$4(MMTagPanel paramMMTagPanel) {}
public final void onClick(View paramView)
{
u.d("!32@/B4Tb64lLpL4fhNdmBV+Mf4yaXXb52KA", "on edittext click");
kHq.bcY();
if (MMTagPanel.e(kHq) != null) {
MMTagPanel.e(kHq).SS();
}
}
}
/* Location:
* Qualified Name: com.tencent.mm.ui.base.MMTagPanel.4
* Java Class Version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | UTF-8 | Java | 604 | java | MMTagPanel$4.java | Java | [] | null | [] | package com.tencent.mm.ui.base;
import android.view.View;
import android.view.View.OnClickListener;
import com.tencent.mm.sdk.platformtools.u;
final class MMTagPanel$4
implements View.OnClickListener
{
MMTagPanel$4(MMTagPanel paramMMTagPanel) {}
public final void onClick(View paramView)
{
u.d("!32@/B4Tb64lLpL4fhNdmBV+Mf4yaXXb52KA", "on edittext click");
kHq.bcY();
if (MMTagPanel.e(kHq) != null) {
MMTagPanel.e(kHq).SS();
}
}
}
/* Location:
* Qualified Name: com.tencent.mm.ui.base.MMTagPanel.4
* Java Class Version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | 604 | 0.687086 | 0.655629 | 26 | 22.26923 | 19.690992 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.307692 | false | false | 15 |
323c2e220d0d2574e24d553dc371f33b0b17154c | 23,158,463,694,694 | 649eaed7c81f51d1289099c50d36561e6fe01bc0 | /RPSPredictor/src/main/java/pl/edu/agh/rps/predictor/SimpleApacheRegression.java | dcc1219dabf73129dc0823d57c6cd6c08cc02219 | [] | no_license | agh-rps/rps | https://github.com/agh-rps/rps | 357ac3ac0aad76718138fb5ab4d422ac00a2cee8 | 7724ad7b7f34507eec943dace3025d455a5f866f | refs/heads/master | 2021-01-25T08:49:19.623000 | 2014-06-16T16:03:43 | 2014-06-16T16:03:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pl.edu.agh.rps.predictor;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.math3.stat.regression.SimpleRegression;
import pl.edu.agh.rps.metricsprovider.model.MetricValue;
public class SimpleApacheRegression {
Map<Long, SimpleRegression> regressionMap = new HashMap<Long, SimpleRegression>();
int frequency;
Long startingDate = null;
public void setData(Map<Long, List<MetricValue>> values, int frequency) {
this.frequency = frequency;
for (Long resourceId : values.keySet()) {
SimpleRegression regression = new SimpleRegression();
for (MetricValue value : values.get(resourceId)) {
if (startingDate == null) {
startingDate = value.getTimestamp().getTime();
}
regression.addData(
(value.getTimestamp().getTime() - startingDate)
/ frequency, value.getValue());
}
regressionMap.put(resourceId, regression);
}
}
public Map<Long, Double> predict(Date date) {
Map<Long, Double> result = new TreeMap<Long, Double>();
for (Long resourceId : regressionMap.keySet()) {
result.put(
resourceId,
regressionMap.get(resourceId).predict(
(date.getTime() - startingDate) / frequency));
}
return result;
}
}
| UTF-8 | Java | 1,334 | java | SimpleApacheRegression.java | Java | [] | null | [] | package pl.edu.agh.rps.predictor;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.math3.stat.regression.SimpleRegression;
import pl.edu.agh.rps.metricsprovider.model.MetricValue;
public class SimpleApacheRegression {
Map<Long, SimpleRegression> regressionMap = new HashMap<Long, SimpleRegression>();
int frequency;
Long startingDate = null;
public void setData(Map<Long, List<MetricValue>> values, int frequency) {
this.frequency = frequency;
for (Long resourceId : values.keySet()) {
SimpleRegression regression = new SimpleRegression();
for (MetricValue value : values.get(resourceId)) {
if (startingDate == null) {
startingDate = value.getTimestamp().getTime();
}
regression.addData(
(value.getTimestamp().getTime() - startingDate)
/ frequency, value.getValue());
}
regressionMap.put(resourceId, regression);
}
}
public Map<Long, Double> predict(Date date) {
Map<Long, Double> result = new TreeMap<Long, Double>();
for (Long resourceId : regressionMap.keySet()) {
result.put(
resourceId,
regressionMap.get(resourceId).predict(
(date.getTime() - startingDate) / frequency));
}
return result;
}
}
| 1,334 | 0.688906 | 0.688156 | 46 | 27 | 23.120667 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.456522 | false | false | 15 |
e45447e3d3bbd00d158dc76cd93117c1553d708a | 14,748,917,707,813 | 939d2dc8f56fb2c469c068803d9047fff1b98c2c | /src/main/java/com/kakaoix/todoapp/domain/TodoItem.java | 79e3f09eee584dd73bcd2451527074c7cbfb87b9 | [] | no_license | ShipJH/TodoApp | https://github.com/ShipJH/TodoApp | 7ec5041e63506310f740d4630837adb8b1768417 | 3c6fee6f7a5b4990c889bee1795e360fe195731f | refs/heads/master | 2020-04-23T14:39:55.608000 | 2019-01-02T05:29:02 | 2019-01-02T05:29:09 | 171,238,983 | 2 | 0 | null | true | 2019-02-18T07:54:33 | 2019-02-18T07:54:33 | 2019-02-16T07:13:33 | 2019-02-07T03:01:04 | 1,476 | 0 | 0 | 0 | null | false | null | package com.kakaoix.todoapp.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;
import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;
@Entity @Table(name = "todo_item")
@Getter @Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
//@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class TodoItem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
// TODO: 2019-01-01 : validate 기능 작동은 하나 에러 메시지 반환이 안됨......
@Size(max = 255, message = "최대 255자를 넘을 수 없습니다.")
@NotEmpty(message = "Todo 명을 입력해 주세요.")
@Column(nullable = false)
private String content;
@Column(length = 1, columnDefinition = "int default 0")
private Integer isChecked;
@Enumerated(EnumType.STRING)
@Column(length = 4, nullable = false)
private Status status;
@Column
private LocalDateTime regDate;
@Column
private LocalDateTime modDate;
@Transient
private List<Long> prevTodoIds;
}
| UTF-8 | Java | 1,255 | java | TodoItem.java | Java | [] | null | [] | package com.kakaoix.todoapp.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;
import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;
@Entity @Table(name = "todo_item")
@Getter @Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
//@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class TodoItem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
// TODO: 2019-01-01 : validate 기능 작동은 하나 에러 메시지 반환이 안됨......
@Size(max = 255, message = "최대 255자를 넘을 수 없습니다.")
@NotEmpty(message = "Todo 명을 입력해 주세요.")
@Column(nullable = false)
private String content;
@Column(length = 1, columnDefinition = "int default 0")
private Integer isChecked;
@Enumerated(EnumType.STRING)
@Column(length = 4, nullable = false)
private Status status;
@Column
private LocalDateTime regDate;
@Column
private LocalDateTime modDate;
@Transient
private List<Long> prevTodoIds;
}
| 1,255 | 0.725275 | 0.710904 | 46 | 24.717392 | 19.781044 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.434783 | false | false | 15 |
2650d83d0507725598d037bf0647d06a4a6ff85e | 13,108,240,206,045 | cfe3592459a42e44944319e0aa7538ff624eb601 | /src/main/java/ua/karatnyk/service/impl/VideoYouTubeServiceImpl.java | a85b29931addd9197f6414ecf237900e9b37d3b5 | [] | no_license | pkarat12/Distance2 | https://github.com/pkarat12/Distance2 | 429be4119878c0a2ea6ee9cd1a040c78f08c9ced | 83a64af8eeafcff3d1fff51ded67917d31d3f507 | refs/heads/master | 2020-03-10T05:19:22.484000 | 2018-04-12T14:38:59 | 2018-04-12T14:38:59 | 129,214,858 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ua.karatnyk.service.impl;
import java.util.Date;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import ua.karatnyk.domain.VideoYouTubeTaskFilter;
import ua.karatnyk.entity.Lesson;
import ua.karatnyk.entity.UserEntity;
import ua.karatnyk.entity.VideoYouTubeTask;
import ua.karatnyk.repository.VideoYouTubeRepository;
import ua.karatnyk.service.VideoYouTubeService;
@Service
public class VideoYouTubeServiceImpl implements VideoYouTubeService{
@Autowired
private VideoYouTubeRepository repository;
@Override
public List<VideoYouTubeTask> findAllNotDeletedByUser(UserEntity entity) {
return repository.findAllNotDeletedByUser(entity);
}
@Override
public Page<VideoYouTubeTask> getPagesVideoYouTubeTasksByUser(int pageNumber, int pageSize, String sort,
String sortByField, UserEntity userEntity) {
PageRequest request = new PageRequest(pageNumber-1, pageSize, sort.toUpperCase().equals("ASC")?Sort.Direction.ASC:Sort.Direction.DESC, sortByField);
return repository.findAllNotDeletedByUser(request, userEntity);
}
@Override
public Page<VideoYouTubeTask> getPagesVideoYouTubeTasksWithFilter(int pageNumber, int pageSize, String sort,
String sortByField, VideoYouTubeTaskFilter filter) {
PageRequest request = new PageRequest(pageNumber-1, pageSize, sort.toUpperCase().equals("ASC")?Sort.Direction.ASC:Sort.Direction.DESC, sortByField);
return repository.findAll(new Specification<VideoYouTubeTask>() {
@Override
public Predicate toPredicate(Root<VideoYouTubeTask> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate predicate1 = cb.isFalse(root.get("isDeleted"));
Predicate predicate2 = cb.equal(root.get("createdByUser"), filter.getUserEntity());
Predicate predicate3 = cb.like(root.get("title"), "%" + filter.getTitle() +"%");
return cb.and(predicate1, predicate2, predicate3);
}
}, request);
}
@Override
public void save(VideoYouTubeTask task) {
repository.save(task);
}
@Override
public VideoYouTubeTask findTaskByIdNotDeleted(int id, UserEntity userEntity) {
return repository.findOne(new Specification<VideoYouTubeTask>() {
@Override
public Predicate toPredicate(Root<VideoYouTubeTask> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate predicate1 = cb.isFalse(root.get("isDeleted"));
Predicate predicate2 = cb.equal(root.get("id"), id);
Predicate predicate3 = cb.equal(root.get("createdByUser"), userEntity);
return cb.and(predicate1, predicate2, predicate3);
}
});
}
@Override
@Transactional
public void update(String title, String description, String link, UserEntity currentUser, Date lastUpdatedAt,
int id) {
repository.update(title, description, link, currentUser, lastUpdatedAt, id);
}
@Override
@Transactional
public void update(UserEntity currentUser, Date lastUpdatedAt, int id) {
repository.update(currentUser, lastUpdatedAt, id);
}
@Override
public VideoYouTubeTask find(Lesson lesson, int id) {
return repository.findOne(new Specification<VideoYouTubeTask>() {
@Override
public Predicate toPredicate(Root<VideoYouTubeTask> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate predicate1 = cb.isFalse(root.get("isDeleted"));
Predicate predicate2 = cb.isMember(lesson, root.get("lessons"));
Predicate predicate3 = cb.equal(root.get("id"), id);
return cb.and(predicate1, predicate2, predicate3);
}
});
}
@Override
public List<VideoYouTubeTask> getVideoYouTubeTasksWithFilter(VideoYouTubeTaskFilter filter) {
return repository.findAll(new Specification<VideoYouTubeTask>() {
@Override
public Predicate toPredicate(Root<VideoYouTubeTask> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate predicate1 = cb.isFalse(root.get("isDeleted"));
Predicate predicate2 = cb.equal(root.get("createdByUser"), filter.getUserEntity());
Predicate predicate3 = cb.like(root.get("title"), "%" + filter.getTitle() +"%");
return cb.and(predicate1, predicate2, predicate3);
}
});
}
}
| UTF-8 | Java | 4,527 | java | VideoYouTubeServiceImpl.java | Java | [] | null | [] | package ua.karatnyk.service.impl;
import java.util.Date;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import ua.karatnyk.domain.VideoYouTubeTaskFilter;
import ua.karatnyk.entity.Lesson;
import ua.karatnyk.entity.UserEntity;
import ua.karatnyk.entity.VideoYouTubeTask;
import ua.karatnyk.repository.VideoYouTubeRepository;
import ua.karatnyk.service.VideoYouTubeService;
@Service
public class VideoYouTubeServiceImpl implements VideoYouTubeService{
@Autowired
private VideoYouTubeRepository repository;
@Override
public List<VideoYouTubeTask> findAllNotDeletedByUser(UserEntity entity) {
return repository.findAllNotDeletedByUser(entity);
}
@Override
public Page<VideoYouTubeTask> getPagesVideoYouTubeTasksByUser(int pageNumber, int pageSize, String sort,
String sortByField, UserEntity userEntity) {
PageRequest request = new PageRequest(pageNumber-1, pageSize, sort.toUpperCase().equals("ASC")?Sort.Direction.ASC:Sort.Direction.DESC, sortByField);
return repository.findAllNotDeletedByUser(request, userEntity);
}
@Override
public Page<VideoYouTubeTask> getPagesVideoYouTubeTasksWithFilter(int pageNumber, int pageSize, String sort,
String sortByField, VideoYouTubeTaskFilter filter) {
PageRequest request = new PageRequest(pageNumber-1, pageSize, sort.toUpperCase().equals("ASC")?Sort.Direction.ASC:Sort.Direction.DESC, sortByField);
return repository.findAll(new Specification<VideoYouTubeTask>() {
@Override
public Predicate toPredicate(Root<VideoYouTubeTask> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate predicate1 = cb.isFalse(root.get("isDeleted"));
Predicate predicate2 = cb.equal(root.get("createdByUser"), filter.getUserEntity());
Predicate predicate3 = cb.like(root.get("title"), "%" + filter.getTitle() +"%");
return cb.and(predicate1, predicate2, predicate3);
}
}, request);
}
@Override
public void save(VideoYouTubeTask task) {
repository.save(task);
}
@Override
public VideoYouTubeTask findTaskByIdNotDeleted(int id, UserEntity userEntity) {
return repository.findOne(new Specification<VideoYouTubeTask>() {
@Override
public Predicate toPredicate(Root<VideoYouTubeTask> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate predicate1 = cb.isFalse(root.get("isDeleted"));
Predicate predicate2 = cb.equal(root.get("id"), id);
Predicate predicate3 = cb.equal(root.get("createdByUser"), userEntity);
return cb.and(predicate1, predicate2, predicate3);
}
});
}
@Override
@Transactional
public void update(String title, String description, String link, UserEntity currentUser, Date lastUpdatedAt,
int id) {
repository.update(title, description, link, currentUser, lastUpdatedAt, id);
}
@Override
@Transactional
public void update(UserEntity currentUser, Date lastUpdatedAt, int id) {
repository.update(currentUser, lastUpdatedAt, id);
}
@Override
public VideoYouTubeTask find(Lesson lesson, int id) {
return repository.findOne(new Specification<VideoYouTubeTask>() {
@Override
public Predicate toPredicate(Root<VideoYouTubeTask> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate predicate1 = cb.isFalse(root.get("isDeleted"));
Predicate predicate2 = cb.isMember(lesson, root.get("lessons"));
Predicate predicate3 = cb.equal(root.get("id"), id);
return cb.and(predicate1, predicate2, predicate3);
}
});
}
@Override
public List<VideoYouTubeTask> getVideoYouTubeTasksWithFilter(VideoYouTubeTaskFilter filter) {
return repository.findAll(new Specification<VideoYouTubeTask>() {
@Override
public Predicate toPredicate(Root<VideoYouTubeTask> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate predicate1 = cb.isFalse(root.get("isDeleted"));
Predicate predicate2 = cb.equal(root.get("createdByUser"), filter.getUserEntity());
Predicate predicate3 = cb.like(root.get("title"), "%" + filter.getTitle() +"%");
return cb.and(predicate1, predicate2, predicate3);
}
});
}
}
| 4,527 | 0.774243 | 0.7685 | 121 | 36.413223 | 35.85339 | 150 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.305785 | false | false | 15 |
2fbfae45c2bdcc1d29e0a33ff19ff4059295b683 | 3,281,355,074,287 | 50e2d48671cfcc3ac49e9cdb23a43d2693bdbe9c | /src/main/java/uk/ac/lancaster/scc/turtles/stellar/core/protocol/Message.java | a44745591160f420b221e5b2f35f0bdaecbad16b | [] | no_license | akingunay/stellar-core | https://github.com/akingunay/stellar-core | d6926b5ca5e5a97c38d0cd20c96b7b00500f12a3 | ff0606909248fa28214d0f5437a84738cda1b601 | refs/heads/master | 2020-04-09T13:46:30.290000 | 2018-12-04T15:45:30 | 2018-12-04T15:45:30 | 140,873,039 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package uk.ac.lancaster.scc.turtles.stellar.core.protocol;
public interface Message {
}
| UTF-8 | Java | 90 | java | Message.java | Java | [] | null | [] | package uk.ac.lancaster.scc.turtles.stellar.core.protocol;
public interface Message {
}
| 90 | 0.788889 | 0.788889 | 5 | 17 | 22.785961 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 15 |
987cf879af71922952b18aef7d31f0ade15c1ead | 9,019,431,373,901 | fef98749b4158c4ce24756d26d27a17354f32768 | /src/vue/FenetreConnexion.java | 36b3a7ccf3554bfb9bac72d743d398defc7daf40 | [] | no_license | arthurguyader/Gestionnaire-Base-De-Donnees | https://github.com/arthurguyader/Gestionnaire-Base-De-Donnees | 38b115837ab6ae60d6df11969124fe59108f8516 | 6150bea6fa99c03affd8909158b2311a7c93c3aa | refs/heads/master | 2021-06-18T20:08:57.705000 | 2017-06-28T05:05:21 | 2017-06-28T05:05:21 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package vue;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import model.*;
import controleur.*;
import java.sql.*;
import java.lang.*;
/**
* Cette classe est la classe d'IHM de la fenêtre permettant la connexion à la base de donnée. Trois champs de texte sont présents, demandant
* à l'utilsiateur son identifiant, son mot de passe et l'adresse de la base. Une fois ces champs remplis, l'utilsateur n'a qu'à cliquer sur le bouton de connexion pour
* se connecter à la base, si bien sûr aucune erreur de connexion ne survient.
* <P>Le champs de saisie du mot de passe cache les caractères saisis.
*/
public class FenetreConnexion extends JFrame{
/**
* Le bouton de connexion
*/
private JButton connexion;
/**
* Les intitutlés des différents champs de saisie
*/
private JLabel nomUtili, mdp, adresse, nomDeLaBase;
/**
* Les champs de saisie de l'identifiant et de l'adresse
*/
private JTextField nomUtiliTF, adresseTF, nomDeLaBaseTF;
/**
* Le champ de saisie du mot de passe. Les caractères saisis sont remplacés par le symbole •
*/
private JPasswordField mdpPF;
/**
* Le constructeur de la classe. Créé le panneau avec le constructeur de sa super-classe JPanel et lui applique un BorderLayout. Appelle ensuite sa méthode miseEnPlace() pour générer les éléments
* et les placer dans le panneau.
*/
private Utilisateur lUtilisateur;
private FenetrePrincipale fp;
public FenetreConnexion(Utilisateur lUtilisateur,FenetrePrincipale fp){
super("Connexion");
this.lUtilisateur=lUtilisateur;
this.fp = fp;
this.setLayout(new BorderLayout());
this.getRootPane().setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
miseEnPlace();
this.setVisible(true);
this.setSize(500,300);
}
public FenetreConnexion(Utilisateur lUtilisateur,FenetrePrincipale fp, int l3){
super("Connexion");
this.lUtilisateur=lUtilisateur;
this.fp = fp;
this.setLayout(new BorderLayout());
this.getRootPane().setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
miseEnPlace();
this.nomUtiliTF.setText("admin");
this.mdpPF.setText("iutvannes");
this.adresseTF.setText("jdbc:mysql://vps.arthurguyader.fr:3306/");
this.setVisible(true);
this.setSize(500,300);
}
/**
* Génère les éléments graphiques et les dispose dans la fenêtre.
*/
private void miseEnPlace(){
// Initialisation des composants
connexion = new JButton("Connexion");
nomUtili = new JLabel("Nom d'utilisateur : ");
adresse = new JLabel("Adresse : ");
mdp = new JLabel("Mot de passe : ");
nomDeLaBase = new JLabel("Nom de la base : ");
nomUtiliTF = new JTextField();
adresseTF = new JTextField();
mdpPF = new JPasswordField();
nomDeLaBaseTF = new JTextField();
// Création des sous-panneaux
JPanel panneauBouton = new JPanel(new FlowLayout(FlowLayout.CENTER));
JPanel panneauChamps = new JPanel(new GridLayout(4,2));
// Ajout des composants dans leurs sous-panneaux respectifs
panneauBouton.add(connexion);
panneauChamps.add(nomUtili);
panneauChamps.add(nomUtiliTF);
panneauChamps.add(mdp);
panneauChamps.add(mdpPF);
panneauChamps.add(adresse);
panneauChamps.add(adresseTF);
panneauChamps.add(nomDeLaBase);
panneauChamps.add(nomDeLaBaseTF);
// Ajout des sous-panneaux dans le panneau de connexion
this.add(panneauChamps, BorderLayout.CENTER);
this.add(panneauBouton, BorderLayout.SOUTH);
connexion.addActionListener(new EcouteurFenetreConnexion(this));
}
/**
* Retourne le bouton Connexion de l'instance
* @return le bouton Connexion de l'instance
*/
public JButton getBoutonConnexion(){
return this.connexion;
}
/**
* Retourne le champs de saisie de nom d'utilisateur de l'instance (nomUtiliTF)
* @return le champs de saisie de nom d'utilisateur de l'instance (nomUtiliTF)
*/
public JTextField getNomUtiliTF(){
return this.nomUtiliTF;
}
/**
* Retourne le champs de saisie d'adresse de l'instance (adresseTF)
* @return le champs de saisie d'adresse de l'instance (adresseTF)
*/
public JTextField getAdresseTF(){
return this.adresseTF;
}
/**
* Retourne le champs de saisie de nom de la base de l'instance (nomDeLaBaseTF)
* @return le champs de saisie de nom de la base de l'instance (nomDeLaBaseTF)
*/
public JTextField getNomDeLaBaseTF(){
return this.nomDeLaBaseTF;
}
/**
* Retourne le champs de saisie de mot de passe de l'instance (mdpPF)
* @return le champs de saisie de mot de passe de l'instance (mdpPF)
*/
public JPasswordField getMdpPF(){
return this.mdpPF;
}
/**
* Retourne l'Utilisateur associé à l'instance
* @return l'Utilisateur associé à l'instance
*/
public Utilisateur getUtilisateur(){
return this.lUtilisateur;
}
/**
* Retourne la FenetrePrincipale associée à l'instance
* @return la FenetrePrincipale associée à l'instance
*/
public FenetrePrincipale getFP(){
return this.fp;
}
} | UTF-8 | Java | 4,956 | java | FenetreConnexion.java | Java | [
{
"context": "20));\n\t\tmiseEnPlace();\n\t\tthis.nomUtiliTF.setText(\"admin\");\n\t\tthis.mdpPF.setText(\"iutvannes\");\n\t\tthis.adre",
"end": 2093,
"score": 0.9549006819725037,
"start": 2088,
"tag": "USERNAME",
"value": "admin"
}
] | null | [] | package vue;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import model.*;
import controleur.*;
import java.sql.*;
import java.lang.*;
/**
* Cette classe est la classe d'IHM de la fenêtre permettant la connexion à la base de donnée. Trois champs de texte sont présents, demandant
* à l'utilsiateur son identifiant, son mot de passe et l'adresse de la base. Une fois ces champs remplis, l'utilsateur n'a qu'à cliquer sur le bouton de connexion pour
* se connecter à la base, si bien sûr aucune erreur de connexion ne survient.
* <P>Le champs de saisie du mot de passe cache les caractères saisis.
*/
public class FenetreConnexion extends JFrame{
/**
* Le bouton de connexion
*/
private JButton connexion;
/**
* Les intitutlés des différents champs de saisie
*/
private JLabel nomUtili, mdp, adresse, nomDeLaBase;
/**
* Les champs de saisie de l'identifiant et de l'adresse
*/
private JTextField nomUtiliTF, adresseTF, nomDeLaBaseTF;
/**
* Le champ de saisie du mot de passe. Les caractères saisis sont remplacés par le symbole •
*/
private JPasswordField mdpPF;
/**
* Le constructeur de la classe. Créé le panneau avec le constructeur de sa super-classe JPanel et lui applique un BorderLayout. Appelle ensuite sa méthode miseEnPlace() pour générer les éléments
* et les placer dans le panneau.
*/
private Utilisateur lUtilisateur;
private FenetrePrincipale fp;
public FenetreConnexion(Utilisateur lUtilisateur,FenetrePrincipale fp){
super("Connexion");
this.lUtilisateur=lUtilisateur;
this.fp = fp;
this.setLayout(new BorderLayout());
this.getRootPane().setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
miseEnPlace();
this.setVisible(true);
this.setSize(500,300);
}
public FenetreConnexion(Utilisateur lUtilisateur,FenetrePrincipale fp, int l3){
super("Connexion");
this.lUtilisateur=lUtilisateur;
this.fp = fp;
this.setLayout(new BorderLayout());
this.getRootPane().setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
miseEnPlace();
this.nomUtiliTF.setText("admin");
this.mdpPF.setText("iutvannes");
this.adresseTF.setText("jdbc:mysql://vps.arthurguyader.fr:3306/");
this.setVisible(true);
this.setSize(500,300);
}
/**
* Génère les éléments graphiques et les dispose dans la fenêtre.
*/
private void miseEnPlace(){
// Initialisation des composants
connexion = new JButton("Connexion");
nomUtili = new JLabel("Nom d'utilisateur : ");
adresse = new JLabel("Adresse : ");
mdp = new JLabel("Mot de passe : ");
nomDeLaBase = new JLabel("Nom de la base : ");
nomUtiliTF = new JTextField();
adresseTF = new JTextField();
mdpPF = new JPasswordField();
nomDeLaBaseTF = new JTextField();
// Création des sous-panneaux
JPanel panneauBouton = new JPanel(new FlowLayout(FlowLayout.CENTER));
JPanel panneauChamps = new JPanel(new GridLayout(4,2));
// Ajout des composants dans leurs sous-panneaux respectifs
panneauBouton.add(connexion);
panneauChamps.add(nomUtili);
panneauChamps.add(nomUtiliTF);
panneauChamps.add(mdp);
panneauChamps.add(mdpPF);
panneauChamps.add(adresse);
panneauChamps.add(adresseTF);
panneauChamps.add(nomDeLaBase);
panneauChamps.add(nomDeLaBaseTF);
// Ajout des sous-panneaux dans le panneau de connexion
this.add(panneauChamps, BorderLayout.CENTER);
this.add(panneauBouton, BorderLayout.SOUTH);
connexion.addActionListener(new EcouteurFenetreConnexion(this));
}
/**
* Retourne le bouton Connexion de l'instance
* @return le bouton Connexion de l'instance
*/
public JButton getBoutonConnexion(){
return this.connexion;
}
/**
* Retourne le champs de saisie de nom d'utilisateur de l'instance (nomUtiliTF)
* @return le champs de saisie de nom d'utilisateur de l'instance (nomUtiliTF)
*/
public JTextField getNomUtiliTF(){
return this.nomUtiliTF;
}
/**
* Retourne le champs de saisie d'adresse de l'instance (adresseTF)
* @return le champs de saisie d'adresse de l'instance (adresseTF)
*/
public JTextField getAdresseTF(){
return this.adresseTF;
}
/**
* Retourne le champs de saisie de nom de la base de l'instance (nomDeLaBaseTF)
* @return le champs de saisie de nom de la base de l'instance (nomDeLaBaseTF)
*/
public JTextField getNomDeLaBaseTF(){
return this.nomDeLaBaseTF;
}
/**
* Retourne le champs de saisie de mot de passe de l'instance (mdpPF)
* @return le champs de saisie de mot de passe de l'instance (mdpPF)
*/
public JPasswordField getMdpPF(){
return this.mdpPF;
}
/**
* Retourne l'Utilisateur associé à l'instance
* @return l'Utilisateur associé à l'instance
*/
public Utilisateur getUtilisateur(){
return this.lUtilisateur;
}
/**
* Retourne la FenetrePrincipale associée à l'instance
* @return la FenetrePrincipale associée à l'instance
*/
public FenetrePrincipale getFP(){
return this.fp;
}
} | 4,956 | 0.727143 | 0.720033 | 165 | 28.836363 | 30.835691 | 196 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.751515 | false | false | 15 |
602e87960356faa78f4819aa47bbea4d012071aa | 27,144,193,360,202 | b1e8f2d4271e4caebb95e20ac117c6058208b08b | /headfirst/factory/pizzaaf/small/CheesePizza.java | ad6b2b3bfc3b37332e8c5785ccfff6aeba017c28 | [] | no_license | KyrixSherly/j1-201611121 | https://github.com/KyrixSherly/j1-201611121 | ff75f7d51d09f90818aaf65d6ccf906fa8a89f8f | d4c64e4f5781e8c3084073a4925d143a6e3e9255 | refs/heads/master | 2020-05-25T03:50:25.774000 | 2017-06-13T05:01:42 | 2017-06-13T05:01:42 | 84,908,481 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package headfirst.factory.pizzaaf.small;
public class CheesePizza extends Pizza{
PizzaIngredientFactory inFac;
public CheesePizza(PizzaIngredientFactory inFac){
this.inFac = inFac;
}
protected void prepare() {
System.out.println("Preparing " + name);
dough = inFac.createDough();
cheese = inFac.createCheese();
potato = inFac.createPotato();
}
}
| UTF-8 | Java | 397 | java | CheesePizza.java | Java | [] | null | [] | package headfirst.factory.pizzaaf.small;
public class CheesePizza extends Pizza{
PizzaIngredientFactory inFac;
public CheesePizza(PizzaIngredientFactory inFac){
this.inFac = inFac;
}
protected void prepare() {
System.out.println("Preparing " + name);
dough = inFac.createDough();
cheese = inFac.createCheese();
potato = inFac.createPotato();
}
}
| 397 | 0.680101 | 0.680101 | 15 | 24.466667 | 16.977894 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.466667 | false | false | 15 |
d9380844ff49f8e68891a1fa1dcb2466ba78f6ac | 5,377,299,115,677 | fbc66482d13561e053dc3dc086d09d2fefb5dc24 | /src/main/java/com/gachon/UntactPhotoBooth/Controller/DetectFaceController.java | 9d91588cce6ca3ef7700233d8c9424defb7b2711 | [] | no_license | SheepEatLion/UntactPhotoBooth | https://github.com/SheepEatLion/UntactPhotoBooth | b03301d2fa5996456e7ea30abaa3a5b9a2b114a1 | 1577dee57a49ceb1dd5e7f6e8656d1877243108a | refs/heads/master | 2023-09-06T08:20:02.869000 | 2021-10-21T14:18:31 | 2021-10-21T14:18:31 | 388,778,254 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gachon.UntactPhotoBooth.Controller;
import com.gachon.UntactPhotoBooth.Configuration.Oauth.LoginUser;
import com.gachon.UntactPhotoBooth.Configuration.Oauth.dto.SessionUser;
import com.gachon.UntactPhotoBooth.Service.DetectFaceService;
import com.gachon.UntactPhotoBooth.Service.S3Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.configurationprocessor.json.JSONArray;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
/**
* 얼굴분석 컨트롤러 ( 클라 <--> 네이버 클로바 )
* AWS S3 서비스 의존 추가
*/
@Slf4j
@RequiredArgsConstructor
@Controller
public class DetectFaceController {
private final DetectFaceService detectFaceService;
private final S3Service s3Service;
@PostMapping("/face")
public String detectFace(Model model, @RequestParam("files") MultipartFile[] files, @LoginUser SessionUser user) throws JSONException {
ArrayList<String> imgUrl = s3Service.uploadImageToS3(files);
String result = detectFaceService.faceAPI(imgUrl);
JSONObject jsonObject = new JSONObject(result);
JSONArray face = jsonObject.getJSONArray("faces");
JSONObject face_list = face.getJSONObject(0);
JSONObject gender = face_list.getJSONObject("gender");
JSONObject age = face_list.getJSONObject("age");
JSONObject emotion = face_list.getJSONObject("emotion");
JSONObject pose = face_list.getJSONObject("pose");
JSONObject imgObject = new JSONObject();
imgObject.put("image", imgUrl.get(0));
if(user != null){ // @LoginUser 를 통해 이제 어느 컨트롤러에서도 세션 정보를 가져올 수 있게 되었다.
model.addAttribute("userEmail", user.getEmail()); // 세션에 값이 있을때만 유저 이름이 보이게 하고 그 외엔 로그인 버튼
}
model.addAttribute("gender", gender);
model.addAttribute("age", age);
model.addAttribute("emotion", emotion);
model.addAttribute("pose", pose);
model.addAttribute("image", imgObject);
return "/result";
}
}
| UTF-8 | Java | 2,659 | java | DetectFaceController.java | Java | [] | null | [] | package com.gachon.UntactPhotoBooth.Controller;
import com.gachon.UntactPhotoBooth.Configuration.Oauth.LoginUser;
import com.gachon.UntactPhotoBooth.Configuration.Oauth.dto.SessionUser;
import com.gachon.UntactPhotoBooth.Service.DetectFaceService;
import com.gachon.UntactPhotoBooth.Service.S3Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.configurationprocessor.json.JSONArray;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
/**
* 얼굴분석 컨트롤러 ( 클라 <--> 네이버 클로바 )
* AWS S3 서비스 의존 추가
*/
@Slf4j
@RequiredArgsConstructor
@Controller
public class DetectFaceController {
private final DetectFaceService detectFaceService;
private final S3Service s3Service;
@PostMapping("/face")
public String detectFace(Model model, @RequestParam("files") MultipartFile[] files, @LoginUser SessionUser user) throws JSONException {
ArrayList<String> imgUrl = s3Service.uploadImageToS3(files);
String result = detectFaceService.faceAPI(imgUrl);
JSONObject jsonObject = new JSONObject(result);
JSONArray face = jsonObject.getJSONArray("faces");
JSONObject face_list = face.getJSONObject(0);
JSONObject gender = face_list.getJSONObject("gender");
JSONObject age = face_list.getJSONObject("age");
JSONObject emotion = face_list.getJSONObject("emotion");
JSONObject pose = face_list.getJSONObject("pose");
JSONObject imgObject = new JSONObject();
imgObject.put("image", imgUrl.get(0));
if(user != null){ // @LoginUser 를 통해 이제 어느 컨트롤러에서도 세션 정보를 가져올 수 있게 되었다.
model.addAttribute("userEmail", user.getEmail()); // 세션에 값이 있을때만 유저 이름이 보이게 하고 그 외엔 로그인 버튼
}
model.addAttribute("gender", gender);
model.addAttribute("age", age);
model.addAttribute("emotion", emotion);
model.addAttribute("pose", pose);
model.addAttribute("image", imgObject);
return "/result";
}
}
| 2,659 | 0.745905 | 0.74151 | 63 | 38.73016 | 29.127092 | 139 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.746032 | false | false | 15 |
6bfbb436210123d934bae81d2fed8e3d349bac0a | 1,073,741,848,335 | 1d4926ebce0aecea9806603a1fe4e73b013ce667 | /src/test/java/com/in28minutes/unittesting/unittesting/spike/HamcrestMatchersTest.java | 1497722238eda1062f7312d2815cf5f906eca5a7 | [] | no_license | dimalahno/UdemyUnitTesting | https://github.com/dimalahno/UdemyUnitTesting | 1b2efafc4e2cb204c440a1d9ec09c10091706843 | 0445385fcdd6205c8c20c1e3b0d1e8afd67dcab5 | refs/heads/master | 2023-06-15T08:58:08.403000 | 2021-07-12T05:24:26 | 2021-07-12T05:24:26 | 385,133,170 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.in28minutes.unittesting.unittesting.spike;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.blankOrNullString;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.startsWith;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
public class HamcrestMatchersTest {
@Test
public void learning() {
List<Integer> numbers = Arrays.asList(12, 15, 45);
assertThat(numbers, hasSize(3));
assertThat(numbers, hasItem(12));
assertThat(numbers, hasItems(15, 45));
assertThat(numbers, hasItems(greaterThan(10)));
assertThat(numbers, hasItems(lessThan(50)));
assertThat("", blankOrNullString());
assertThat("ABCDE", containsString("BCD"));
assertThat("ABCDE", startsWith("ABC"));
assertThat("ABCDE", endsWith("CDE"));
}
}
| UTF-8 | Java | 1,202 | java | HamcrestMatchersTest.java | Java | [] | null | [] | package com.in28minutes.unittesting.unittesting.spike;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.blankOrNullString;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.startsWith;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
public class HamcrestMatchersTest {
@Test
public void learning() {
List<Integer> numbers = Arrays.asList(12, 15, 45);
assertThat(numbers, hasSize(3));
assertThat(numbers, hasItem(12));
assertThat(numbers, hasItems(15, 45));
assertThat(numbers, hasItems(greaterThan(10)));
assertThat(numbers, hasItems(lessThan(50)));
assertThat("", blankOrNullString());
assertThat("ABCDE", containsString("BCD"));
assertThat("ABCDE", startsWith("ABC"));
assertThat("ABCDE", endsWith("CDE"));
}
}
| 1,202 | 0.735441 | 0.719634 | 36 | 32.388889 | 20.699272 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 15 |
dbc90a8d3e74243c1a3e890160ececd8982283b6 | 16,930,761,082,544 | cc17e978eab60908ebd55da5292fa842fe9c8fa2 | /cadsrutil/src/java/gov/nih/nci/ncicb/cadsr/common/resource/ContextHolder.java | 659d108167a7ff19f21654611a3543ee54a8ef21 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | CBIIT/cadsr-util | https://github.com/CBIIT/cadsr-util | a0ddf0095b0d9f4537457d352f3e3e9503115cec | 9bb4d578eef5190e76ef5d5587eb6bf6c69c2011 | refs/heads/master | 2021-01-18T13:24:54.521000 | 2015-08-27T17:59:46 | 2015-08-27T17:59:46 | 19,791,063 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*L
* Copyright Oracle inc, SAIC-F
*
* Distributed under the OSI-approved BSD 3-Clause License.
* See http://ncip.github.com/cadsr-util/LICENSE.txt for details.
*/
package gov.nih.nci.ncicb.cadsr.common.resource;
import javax.swing.tree.DefaultMutableTreeNode;
public interface ContextHolder
{
public void setContext(Context context);
public Context getContext();
public void setNode(DefaultMutableTreeNode node);
public DefaultMutableTreeNode getNode();
} | UTF-8 | Java | 478 | java | ContextHolder.java | Java | [] | null | [] | /*L
* Copyright Oracle inc, SAIC-F
*
* Distributed under the OSI-approved BSD 3-Clause License.
* See http://ncip.github.com/cadsr-util/LICENSE.txt for details.
*/
package gov.nih.nci.ncicb.cadsr.common.resource;
import javax.swing.tree.DefaultMutableTreeNode;
public interface ContextHolder
{
public void setContext(Context context);
public Context getContext();
public void setNode(DefaultMutableTreeNode node);
public DefaultMutableTreeNode getNode();
} | 478 | 0.763598 | 0.761506 | 23 | 19.826086 | 22.987051 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.304348 | false | false | 15 |
9d5d199b84c627c4737445bef4c92c5774703878 | 16,930,761,081,373 | 2e49d1c033d3677e2eed4f2e560acfa53feb6cfc | /src/main/java/com/spring/mediacompaign/dao/entities/PostEntity.java | 684c97b93bda08025a782afbdd8174069b6bde3d | [] | no_license | saadalenany/MediaCampaign | https://github.com/saadalenany/MediaCampaign | 9f7a54ab1404624c8b8cb769094f6a9c55d066c0 | a0c980038bdd8f1d4d8d8585c77691811e254f00 | refs/heads/master | 2022-06-10T03:01:32.444000 | 2019-10-20T12:50:41 | 2019-10-20T12:50:41 | 211,415,831 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.spring.mediacompaign.dao.entities;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "post")
public class PostEntity {
@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(name = "UUID", strategy = "uuid2")
@Column(name = "id")
private String id;
@Column(name="title")
private String title;
@Column(name="date")
private LocalDateTime date;
@ManyToOne
@JoinColumn(name = "campaign_id")
private CampaignEntity campaign;
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<TextEntity> texts = new ArrayList<>();
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<ImageEntity> images = new ArrayList<>();
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<VideoEntity> videos = new ArrayList<>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public LocalDateTime getDate() {
return date;
}
public void setDate(LocalDateTime date) {
this.date = date;
}
public CampaignEntity getCampaign() {
return campaign;
}
public void setCampaign(CampaignEntity campaign) {
this.campaign = campaign;
}
public List<TextEntity> getTexts() {
return texts;
}
public void setTexts(List<TextEntity> texts) {
this.texts = texts;
}
public List<ImageEntity> getImages() {
return images;
}
public void setImages(List<ImageEntity> newImages) {
this.images.clear();
if (newImages != null) {
newImages.forEach(o -> o.setPost(this));
this.images.addAll(newImages);
}
}
public List<VideoEntity> getVideos() {
return videos;
}
public void setVideos(List<VideoEntity> newVideos) {
this.videos.clear();
if (newVideos != null) {
newVideos.forEach(o -> o.setPost(this));
this.videos.addAll(newVideos);
}
}
}
| UTF-8 | Java | 2,384 | java | PostEntity.java | Java | [] | null | [] | package com.spring.mediacompaign.dao.entities;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "post")
public class PostEntity {
@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(name = "UUID", strategy = "uuid2")
@Column(name = "id")
private String id;
@Column(name="title")
private String title;
@Column(name="date")
private LocalDateTime date;
@ManyToOne
@JoinColumn(name = "campaign_id")
private CampaignEntity campaign;
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<TextEntity> texts = new ArrayList<>();
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<ImageEntity> images = new ArrayList<>();
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<VideoEntity> videos = new ArrayList<>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public LocalDateTime getDate() {
return date;
}
public void setDate(LocalDateTime date) {
this.date = date;
}
public CampaignEntity getCampaign() {
return campaign;
}
public void setCampaign(CampaignEntity campaign) {
this.campaign = campaign;
}
public List<TextEntity> getTexts() {
return texts;
}
public void setTexts(List<TextEntity> texts) {
this.texts = texts;
}
public List<ImageEntity> getImages() {
return images;
}
public void setImages(List<ImageEntity> newImages) {
this.images.clear();
if (newImages != null) {
newImages.forEach(o -> o.setPost(this));
this.images.addAll(newImages);
}
}
public List<VideoEntity> getVideos() {
return videos;
}
public void setVideos(List<VideoEntity> newVideos) {
this.videos.clear();
if (newVideos != null) {
newVideos.forEach(o -> o.setPost(this));
this.videos.addAll(newVideos);
}
}
}
| 2,384 | 0.622483 | 0.622064 | 102 | 22.372549 | 20.938717 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.372549 | false | false | 15 |
23c518b6af0926f0812871aa31f60a3c0a880865 | 1,537,598,308,894 | 6b79dc34b5a85034fc083b1ad09411a4cc4ca65d | /src/java/illinois/edu/DocumentStreamServer/documentsMail/ReadEmail.java | 298be94defed476836009a196c0f111aa9004b37 | [] | no_license | rohankasivis/MetabooksProgramming | https://github.com/rohankasivis/MetabooksProgramming | 95594c9e23afb622186ec3ccd10e84dfa0bdb173 | 2e6a61454ffb8e865bcc109cc03108eb49b14f27 | refs/heads/master | 2021-01-10T04:23:33.923000 | 2016-01-07T08:00:48 | 2016-01-07T08:00:48 | 36,969,215 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package java.illinois.edu.DocumentStreamServer.documentsMail;
import java.io.File;
import java.io.IOException;
import java.util.List;
public interface ReadEmail
{
public void readEmail(String email, String password);
public List<File> getAttachments() throws IOException;
}
| UTF-8 | Java | 284 | java | ReadEmail.java | Java | [] | null | [] | package java.illinois.edu.DocumentStreamServer.documentsMail;
import java.io.File;
import java.io.IOException;
import java.util.List;
public interface ReadEmail
{
public void readEmail(String email, String password);
public List<File> getAttachments() throws IOException;
}
| 284 | 0.792253 | 0.792253 | 11 | 24.818182 | 23.060467 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false | 15 |
dfa7188c70b2dc594aa4d8a11aa2db22396c3571 | 22,883,585,761,964 | f346f86fd9b5e0c017ded12e0738d4bfc22dd55b | /kendzi3d-plugin/src/main/java/kendzi/josm/kendzi3d/ExceptionHandler.java | f5d2a398e8118ef9cbde81fe90dbe1ec1762ccb0 | [
"BSD-3-Clause"
] | permissive | kendzi/kendzi3d | https://github.com/kendzi/kendzi3d | ecc00c06f47c1565ac1d0863e112ae1c37eb00e1 | d2db2a26d7955b43eaf1acc7c0993e9fcff41174 | refs/heads/master | 2023-08-05T05:04:38.231000 | 2022-02-23T16:58:45 | 2022-02-24T23:19:14 | 1,894,087 | 56 | 15 | null | false | 2023-07-20T21:54:39 | 2011-06-14T12:18:06 | 2023-06-09T09:31:58 | 2023-07-20T21:54:38 | 104,926 | 54 | 19 | 51 | Java | false | false | package kendzi.josm.kendzi3d;
class ExceptionHandler implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
handle(e);
}
public void handle(Throwable throwable) {
try {
throwable.printStackTrace();
} catch (Throwable t) {
// don't let the exception get thrown out, will cause infinite
// looping!
}
}
public static void registerExceptionHandler() {
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());
System.setProperty("sun.awt.exception.handler", ExceptionHandler.class.getName());
}
}
| UTF-8 | Java | 673 | java | ExceptionHandler.java | Java | [] | null | [] | package kendzi.josm.kendzi3d;
class ExceptionHandler implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
handle(e);
}
public void handle(Throwable throwable) {
try {
throwable.printStackTrace();
} catch (Throwable t) {
// don't let the exception get thrown out, will cause infinite
// looping!
}
}
public static void registerExceptionHandler() {
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());
System.setProperty("sun.awt.exception.handler", ExceptionHandler.class.getName());
}
}
| 673 | 0.656761 | 0.655275 | 22 | 29.59091 | 27.812128 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false | 15 |
dd3dd3adfaf63d6e5c3a6ce0ea31c8d40c3626bb | 25,297,357,377,814 | 66af70d1ed70922895debd49741741d1bb56709e | /ClassObjectField/TestEqualsEx3.java | b961c4550c99f68e35fffa87e5eba0cac2c5343b | [] | no_license | LinYuRu/Project | https://github.com/LinYuRu/Project | 025a2cc29639fd7a091898acfc62227a3ec87570 | d2c61201e19bede6961a22d4c10a769766bdabef | refs/heads/master | 2022-07-21T09:05:47.775000 | 2022-07-18T12:12:45 | 2022-07-18T12:12:45 | 209,800,109 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ClassObjectField;
class Car{
String setBrand = "BMW", "Porsch";
}
public class TestEqualsEx3 {
public static void main(String[] args) {
Car myCar = new Car();
myCar.setBrand("BMW");
myCar.setPrice(1500000);
myCar.showInfo();
System.out.println("------------------------------------");
Car yourCar = new Car();
yourCar.setBrand("Porsch");
yourCar.setPrice(1600000);
yourCar.showInfo();
System.out.println("------------------------------------");
System.out.println("(myCar==yourCar)_1"+(myCar==yourCar));
System.out.println("(myCarequalsyourCar)_1"+(myCar.equals(yourCar)));
}
}
| UTF-8 | Java | 633 | java | TestEqualsEx3.java | Java | [] | null | [] | package ClassObjectField;
class Car{
String setBrand = "BMW", "Porsch";
}
public class TestEqualsEx3 {
public static void main(String[] args) {
Car myCar = new Car();
myCar.setBrand("BMW");
myCar.setPrice(1500000);
myCar.showInfo();
System.out.println("------------------------------------");
Car yourCar = new Car();
yourCar.setBrand("Porsch");
yourCar.setPrice(1600000);
yourCar.showInfo();
System.out.println("------------------------------------");
System.out.println("(myCar==yourCar)_1"+(myCar==yourCar));
System.out.println("(myCarequalsyourCar)_1"+(myCar.equals(yourCar)));
}
}
| 633 | 0.586098 | 0.559242 | 28 | 21.607143 | 21.032864 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.928571 | false | false | 9 |
63c71d069d9396e9836c36aef13b4e1b2d80c459 | 2,207,613,230,276 | c1600e3635a8b9ebdcfe11cbf30d74754e229b7d | /01525907_Beispiel2_Shabani/src/tree/node/GenericTreeNode.java | d1e9cbc8dd2bbd072714e244060c362a37a9da2f | [] | no_license | RronShabani/OOP | https://github.com/RronShabani/OOP | 32c666539619b4abce33c8e0a464f424935a29dd | 5872ee62dc1e3ec3e0a0f82a6ab12155d859c570 | refs/heads/master | 2020-02-19T02:37:15.833000 | 2019-03-24T19:01:07 | 2019-03-24T19:01:07 | 125,639,196 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tree.node;
import container.Container;
import util.searchable.ISearchFilter;
import java.util.Collection;
import java.util.Iterator;
/**
* Created by @author Rron Shabani - 1526907
* on 17/05/2018
*/
public class GenericTreeNode<NODETYPE> implements ITreeNode<NODETYPE>{
private Collection<ITreeNode<NODETYPE>> children;
private String label;
private NODETYPE nodeValue;
public GenericTreeNode(String label, NODETYPE nodeValue) {
this.children = null;
this.label = label;
this.nodeValue = nodeValue;
}
@Override
public boolean checkNodeByValue(NODETYPE value) {
return value == null && nodeValue == null || (value != null && nodeValue != null && value.equals(nodeValue));
}
@Override
public ITreeNode<NODETYPE> findNodeByNode(ITreeNode<NODETYPE> searchNode) {
if(searchNode==null)
return null;
ITreeNode<NODETYPE> temp = null;
if(searchNode.equals(this)){
return this;
}else {
for(ITreeNode<NODETYPE> itr: children) {
temp = itr .findNodeByNode(searchNode);
if(temp != null)
break;
}
}
return temp;
}
@Override
public ITreeNode<NODETYPE> findNodeByValue(NODETYPE value) {
if(value==null)
return null;
ITreeNode<NODETYPE> temp = null;
if(value.equals(this.nodeValue())){
return this;
}else {
for(ITreeNode<NODETYPE> itr: children) {
temp = itr.findNodeByValue(value);
if(temp != null)
break;
}
}
return temp;
}
@Override
public String generateConsoleView(String spacer, String preamble) {
String out = "";
if(getChildren()==null)
return preamble + spacer + this.getLabel();
for(ITreeNode<NODETYPE> itr: children) {
if(itr!=null)//Should always be true, is there just in case!
{
out.concat(generateConsoleView(spacer + spacer, "") + "\n");
}
}
return out.concat(preamble + spacer + this.getLabel());
}
@Override
public Collection<ITreeNode<NODETYPE>> getChildren() {
return children;
}
@Override
public String getLabel() {
return label;
}
@Override
public boolean isLeaf() {
return children == null;
}
@Override
public NODETYPE nodeValue() {
return nodeValue;
}
@Override
public ITreeNode<NODETYPE> deepCopy() {
GenericTreeNode<NODETYPE> copy = new GenericTreeNode<NODETYPE>(this.getLabel(), this.nodeValue());
if (!this.isLeaf()){
Iterator<ITreeNode<NODETYPE>> childrenItr = this.getChildren().iterator();
while(childrenItr.hasNext()){
copy.children.add(childrenItr.next().deepCopy());
}
}
return copy;
}
@Override
public Collection<ITreeNode<NODETYPE>> searchByFilter(ISearchFilter filter, Object compareObject) {
Collection<ITreeNode<NODETYPE>> outCollection = new Container<>();
if (filter.searchFilterFunction(this, compareObject) || filter.searchFilterFunction(this.nodeValue(), compareObject)){
outCollection.add(this);
}
if(children!=null)
for(ITreeNode<NODETYPE> child: children){
outCollection.addAll(child.searchByFilter(filter, compareObject));
}
return outCollection;
}
}
| UTF-8 | Java | 3,592 | java | GenericTreeNode.java | Java | [
{
"context": "ort java.util.Iterator;\n\n/**\n * Created by @author Rron Shabani - 1526907\n * on 17/05/2018\n */\npublic class Gener",
"end": 182,
"score": 0.9996036291122437,
"start": 170,
"tag": "NAME",
"value": "Rron Shabani"
}
] | null | [] | package tree.node;
import container.Container;
import util.searchable.ISearchFilter;
import java.util.Collection;
import java.util.Iterator;
/**
* Created by @author <NAME> - 1526907
* on 17/05/2018
*/
public class GenericTreeNode<NODETYPE> implements ITreeNode<NODETYPE>{
private Collection<ITreeNode<NODETYPE>> children;
private String label;
private NODETYPE nodeValue;
public GenericTreeNode(String label, NODETYPE nodeValue) {
this.children = null;
this.label = label;
this.nodeValue = nodeValue;
}
@Override
public boolean checkNodeByValue(NODETYPE value) {
return value == null && nodeValue == null || (value != null && nodeValue != null && value.equals(nodeValue));
}
@Override
public ITreeNode<NODETYPE> findNodeByNode(ITreeNode<NODETYPE> searchNode) {
if(searchNode==null)
return null;
ITreeNode<NODETYPE> temp = null;
if(searchNode.equals(this)){
return this;
}else {
for(ITreeNode<NODETYPE> itr: children) {
temp = itr .findNodeByNode(searchNode);
if(temp != null)
break;
}
}
return temp;
}
@Override
public ITreeNode<NODETYPE> findNodeByValue(NODETYPE value) {
if(value==null)
return null;
ITreeNode<NODETYPE> temp = null;
if(value.equals(this.nodeValue())){
return this;
}else {
for(ITreeNode<NODETYPE> itr: children) {
temp = itr.findNodeByValue(value);
if(temp != null)
break;
}
}
return temp;
}
@Override
public String generateConsoleView(String spacer, String preamble) {
String out = "";
if(getChildren()==null)
return preamble + spacer + this.getLabel();
for(ITreeNode<NODETYPE> itr: children) {
if(itr!=null)//Should always be true, is there just in case!
{
out.concat(generateConsoleView(spacer + spacer, "") + "\n");
}
}
return out.concat(preamble + spacer + this.getLabel());
}
@Override
public Collection<ITreeNode<NODETYPE>> getChildren() {
return children;
}
@Override
public String getLabel() {
return label;
}
@Override
public boolean isLeaf() {
return children == null;
}
@Override
public NODETYPE nodeValue() {
return nodeValue;
}
@Override
public ITreeNode<NODETYPE> deepCopy() {
GenericTreeNode<NODETYPE> copy = new GenericTreeNode<NODETYPE>(this.getLabel(), this.nodeValue());
if (!this.isLeaf()){
Iterator<ITreeNode<NODETYPE>> childrenItr = this.getChildren().iterator();
while(childrenItr.hasNext()){
copy.children.add(childrenItr.next().deepCopy());
}
}
return copy;
}
@Override
public Collection<ITreeNode<NODETYPE>> searchByFilter(ISearchFilter filter, Object compareObject) {
Collection<ITreeNode<NODETYPE>> outCollection = new Container<>();
if (filter.searchFilterFunction(this, compareObject) || filter.searchFilterFunction(this.nodeValue(), compareObject)){
outCollection.add(this);
}
if(children!=null)
for(ITreeNode<NODETYPE> child: children){
outCollection.addAll(child.searchByFilter(filter, compareObject));
}
return outCollection;
}
}
| 3,586 | 0.590479 | 0.586303 | 125 | 27.736 | 26.713934 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.424 | false | false | 9 |
7fdf0be8e0188c9b635995a6d3115a8a9e2ea318 | 28,922,309,789,322 | 32b72e1dc8b6ee1be2e80bb70a03a021c83db550 | /ast_results/seizonsenryaku_HayaiLauncher/app/src/main/java/com/hayaisoftware/launcher/comparators/PinToTop.java | 781d1ad4c57a1c5dcb6186d04674dd61853898d0 | [] | no_license | cmFodWx5YWRhdjEyMTA5/smell-and-machine-learning | https://github.com/cmFodWx5YWRhdjEyMTA5/smell-and-machine-learning | d90c41a17e88fcd99d543124eeb6e93f9133cb4a | 0564143d92f8024ff5fa6b659c2baebf827582b1 | refs/heads/master | 2020-07-13T13:53:40.297000 | 2019-01-11T11:51:18 | 2019-01-11T11:51:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // isComment
package com.hayaisoftware.launcher.comparators;
import com.hayaisoftware.launcher.LaunchableActivity;
import java.util.Comparator;
public class isClassOrIsInterface implements Comparator<LaunchableActivity> {
@Override
public int isMethod(LaunchableActivity isParameter, LaunchableActivity isParameter) {
return isNameExpr.isMethod() - isNameExpr.isMethod();
}
}
| UTF-8 | Java | 399 | java | PinToTop.java | Java | [] | null | [] | // isComment
package com.hayaisoftware.launcher.comparators;
import com.hayaisoftware.launcher.LaunchableActivity;
import java.util.Comparator;
public class isClassOrIsInterface implements Comparator<LaunchableActivity> {
@Override
public int isMethod(LaunchableActivity isParameter, LaunchableActivity isParameter) {
return isNameExpr.isMethod() - isNameExpr.isMethod();
}
}
| 399 | 0.794486 | 0.794486 | 13 | 29.692308 | 30.697994 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.384615 | false | false | 9 |
ac9123d20e8e685fc1ad893517b1c376a2909568 | 12,584,254,190,890 | 9668d1476e62220105146b2c4b09dcf9621f0dc6 | /Social/src/main/java/ua/service/UserPageService.java | bf58912654933206fd1f72958df2027fc491a6e3 | [] | no_license | AndriiDidukh/SocialNetwork | https://github.com/AndriiDidukh/SocialNetwork | ef93a0f41442ff0440232ef3914ecc68c1d99816 | 65450c28a003f0ac37c67be66e537a4e151f2e68 | refs/heads/master | 2021-09-07T20:13:32.761000 | 2018-02-28T13:22:48 | 2018-02-28T13:22:48 | 105,368,698 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ua.service;
import java.security.Principal;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import ua.entity.UserPage;
import ua.form.UserPageForm;
import ua.form.filter.UserPageFilterForm;
public interface UserPageService {
List<UserPage> findAll();
void save(UserPageForm form);
UserPageForm findForForm(int id);
void delete(int id);
UserPage findOne(int id);
Page<UserPage> findAll(Pageable pageable, UserPageFilterForm filter);
UserPage findByLogin(String login);
UserPage findById(int id);
UserPage findByPrincipal(Principal principal);
}
| UTF-8 | Java | 677 | java | UserPageService.java | Java | [] | null | [] | package ua.service;
import java.security.Principal;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import ua.entity.UserPage;
import ua.form.UserPageForm;
import ua.form.filter.UserPageFilterForm;
public interface UserPageService {
List<UserPage> findAll();
void save(UserPageForm form);
UserPageForm findForForm(int id);
void delete(int id);
UserPage findOne(int id);
Page<UserPage> findAll(Pageable pageable, UserPageFilterForm filter);
UserPage findByLogin(String login);
UserPage findById(int id);
UserPage findByPrincipal(Principal principal);
}
| 677 | 0.753323 | 0.753323 | 33 | 18.515152 | 19.080564 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.818182 | false | false | 9 |
2e18f3b1a8c24fb9856d024dfbf7e4a84226ecfb | 8,323,646,639,024 | b91028f2a2f7a3a53c0c308feb66a35496a70398 | /android/WifiLocalization/src/com/neu/wifilocalization/model/BaseModel.java | 644b80c39872af967b9b1024606e0f752802a89f | [] | no_license | chilynn/indoor-positioning-system | https://github.com/chilynn/indoor-positioning-system | 5b243d834d328262fb2f13bb37b88f144ab9530f | 4362d1c86c7da5c986e131dc774c8831ccf21e60 | refs/heads/master | 2021-01-20T19:53:27.910000 | 2016-06-24T09:26:30 | 2016-06-24T09:26:30 | 61,873,355 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.neu.wifilocalization.model;
import java.io.Serializable;
/**
* model的基类
* @author alin
*
*/
public class BaseModel implements Serializable{
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
| UTF-8 | Java | 300 | java | BaseModel.java | Java | [
{
"context": " java.io.Serializable;\n\n/**\n * model的基类\n * @author alin\n *\n */\npublic class BaseModel implements Serializ",
"end": 102,
"score": 0.8781651258468628,
"start": 98,
"tag": "USERNAME",
"value": "alin"
}
] | null | [] | package com.neu.wifilocalization.model;
import java.io.Serializable;
/**
* model的基类
* @author alin
*
*/
public class BaseModel implements Serializable{
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
| 300 | 0.612245 | 0.612245 | 22 | 12.363636 | 13.871309 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.227273 | false | false | 9 |
81568449869996a9252db255b6cc599a40edfd04 | 8,332,236,599,352 | 5f29072f031d43decb0f72dc92485d35e7248486 | /src/main/java/com/ailhanli/calculator/decider/CouponDiscountDecider.java | fc12e74f42bb04ce709eb53407574330110267a2 | [] | no_license | ailhanli/shopping_cart_calculator | https://github.com/ailhanli/shopping_cart_calculator | 6c9f6b3122c2a5cf990ef522658152d661c528ac | 74dd5543b108df6350883aad4030b6f3290e969a | refs/heads/master | 2020-04-07T21:54:20.973000 | 2018-11-22T20:08:09 | 2018-11-22T20:08:09 | 158,745,800 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ailhanli.calculator.decider;
import com.ailhanli.domain.ShoppingCart;
public interface CouponDiscountDecider {
boolean canApplyDiscount(ShoppingCart card);
}
| UTF-8 | Java | 185 | java | CouponDiscountDecider.java | Java | [] | null | [] | package com.ailhanli.calculator.decider;
import com.ailhanli.domain.ShoppingCart;
public interface CouponDiscountDecider {
boolean canApplyDiscount(ShoppingCart card);
}
| 185 | 0.783784 | 0.783784 | 9 | 18.555555 | 20.353056 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 9 |
bb2ac749b81255facfc79e4a5d2815d1da06c936 | 25,177,098,330,018 | 9a690c364dd1dfe37ec26bf1bc577b7e35ca7880 | /roster/src/i/hate/java/staffroster/NoSuchWorkException.java | 0b9ef372233c13ac25e998c87d8af7fd4bafab5d | [
"BSD-2-Clause"
] | permissive | phagara/staffroster | https://github.com/phagara/staffroster | 956ca9c8898bf297d9a878dbbcd131814021f1e4 | 304d941cb7a32f660da99fdce843bf87453e28fe | refs/heads/master | 2016-09-14T04:15:53.011000 | 2016-05-01T22:40:46 | 2016-05-01T22:40:46 | 57,854,521 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package i.hate.java.staffroster;
public class NoSuchWorkException extends Exception {
NoSuchWorkException(String string) {
super(string);
}
private static final long serialVersionUID = 5383626137113921146L;
}
| UTF-8 | Java | 230 | java | NoSuchWorkException.java | Java | [] | null | [] | package i.hate.java.staffroster;
public class NoSuchWorkException extends Exception {
NoSuchWorkException(String string) {
super(string);
}
private static final long serialVersionUID = 5383626137113921146L;
}
| 230 | 0.752174 | 0.669565 | 11 | 18.90909 | 23.188768 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.818182 | false | false | 9 |
06f3386fb1258f86649b9fd5e0f6d8abce8cf4e5 | 27,444,841,061,678 | 2fb97011203ed128cb4d828c99dd6ef750717582 | /src/Pr5091.java | 4de080d78191a73aad6b37b6ea6eaee0c8e53d02 | [] | no_license | RovshanHuseynov/eolimp | https://github.com/RovshanHuseynov/eolimp | a7a47aa72624b55c61d012afc1552896eaee7af1 | c9e7634f0855193e352748f13edd173fb7782e69 | refs/heads/master | 2022-12-06T03:30:51.303000 | 2020-08-29T15:04:01 | 2020-08-29T15:04:01 | 275,661,258 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner;
public class Pr5091 {
public static void main(String[] args) {
Pr5091 a = new Pr5091();
a.calc();
}
public void calc(){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int f=2,s=3,temp=0;
if(n == 1){
System.out.println(f);
}
else if(n == 2){
System.out.println(s);
}
else{
for(int i=3; i<=n; i++) {
temp = f + s;
f = s;
s = temp;
}
System.out.println(temp);
}
}
}
| UTF-8 | Java | 616 | java | Pr5091.java | Java | [] | null | [] | import java.util.Scanner;
public class Pr5091 {
public static void main(String[] args) {
Pr5091 a = new Pr5091();
a.calc();
}
public void calc(){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int f=2,s=3,temp=0;
if(n == 1){
System.out.println(f);
}
else if(n == 2){
System.out.println(s);
}
else{
for(int i=3; i<=n; i++) {
temp = f + s;
f = s;
s = temp;
}
System.out.println(temp);
}
}
}
| 616 | 0.404221 | 0.375 | 29 | 20.241379 | 13.179543 | 44 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.551724 | false | false | 9 |
b9dde2cd86ac6683b0dfecd3e63caa56c50ae8d0 | 8,787,503,135,136 | 20486b9e7308547bc218388e8543bb3cb71676fa | /src/edu/nyuad/svm/GaussianSmoothing.java | 1765c0f03277fd4aac074156ff13f665b35c0a19 | [] | no_license | Technology-Hatchery/Support-Vector-Machine-Optimization | https://github.com/Technology-Hatchery/Support-Vector-Machine-Optimization | b6a284c7e34a90ae3b36704fc387f13020e94d4e | 75187e7fdb7e7c1a76e0f3eee78049ba25f28006 | refs/heads/master | 2021-01-17T10:17:32.792000 | 2014-03-07T11:24:11 | 2014-03-07T11:24:11 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package edu.nyuad.svm;
import weka.core.Capabilities;
import weka.core.Instance;
import weka.core.Instances;
import weka.filters.SimpleBatchFilter;
import java.util.Random;
import java.util.Stack;
/**
* Created with IntelliJ IDEA.
* User: ling
* Date: 28/10/13
* Time: 10:25 PM
* To change this template use File | Settings | File Templates.
*/
public class GaussianSmoothing extends SimpleBatchFilter{
@Override
public String globalInfo() {
return "Probabilistically removes points proportional to their standard deviations away from the mean of their class";
}
@Override
protected Instances determineOutputFormat(Instances instances) throws Exception {
return instances; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
protected Instances process(Instances instances) throws Exception {
// Generate the stats map
StatsMap statsMap = new StatsMap(instances);
statsMap.rankMap();
int numInstances = instances.numInstances();
int numAttributes = instances.numAttributes();
int numClasses = statsMap.classMap.keySet().size();
int classIndex = instances.classIndex();
int removeCount = 0;
Random random = new Random();
Stack<Integer> toRemove = new Stack<Integer>();
// iterate over the instances
Instance instance;
Double classVal;
Double partialRemoveProbability;
Double removeProbability;
Double[] gaussianVals;
Double[] gaussianValsOther;
int rank;
double value;
Double[] otherClassValuePair;
for (int i=0; i < numInstances; i++) {
instance = instances.get(i);
classVal = instance.classValue();
removeProbability = 0.0;
// iterate over each instances attributes
for (int j=0; j < numAttributes; j++) {
// skip the actual class
if (j == classIndex) {
continue;
}
gaussianVals = statsMap.getClassAttributeGaussian(classVal, j);
value = instance.value(j);
// find its rank
rank = statsMap.getFeatureClassRank(j, classVal);
// if its to the left of the mean
// if it's the leftmost, skip
// otherwise find the gaussian of the rank to the left
if (value < gaussianVals[0] && rank-- == 0) continue;
else if (++rank == numClasses) continue;
otherClassValuePair = statsMap.getFeatureClassRankList(j)[rank];
gaussianValsOther = statsMap.getClassAttributeGaussian(otherClassValuePair[0], j);
// add up the remove probabilities
partialRemoveProbability =
(Gaussian.phi(instance.value(j), gaussianVals[0], gaussianVals[1]) /
Gaussian.phi(otherClassValuePair[1], gaussianValsOther[0], gaussianValsOther[1]));
// if this instance does not have a bigger pdf than it's neighbor, just continue
if (partialRemoveProbability > 1) continue;
removeProbability += 1 - partialRemoveProbability;
}
// take the average of the removeProbabilities
removeProbability /= numAttributes;
// System.out.println(removeProbability);
// probabilitistically add the instance to the remove stack
if (removeProbability > random.nextDouble()) {
toRemove.push(i);
removeCount += 1;
}
}
// delete the instances in reverse order
while (!toRemove.empty()) {
instances.delete(toRemove.pop());
}
return instances;
}
@Override
public Capabilities getCapabilities() {
return super.getCapabilities(); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
public String getRevision() {
return super.getRevision(); //To change body of overridden methods use File | Settings | File Templates.
}
public static void main(String[] args) {
String filepath = "data/ling_test.arff";
DataFilters dataset = null;
try {
dataset = new DataFilters(filepath);
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
Instances data = dataset.getData();
StatsMap statsMap = new StatsMap(data);
statsMap.rankMap();
GaussianSmoothing test = new GaussianSmoothing();
try {
System.out.println(data.numInstances());
test.process(data);
System.out.println(data.numInstances());
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
| UTF-8 | Java | 5,039 | java | GaussianSmoothing.java | Java | [
{
"context": "tack;\n\n/**\n * Created with IntelliJ IDEA.\n * User: ling\n * Date: 28/10/13\n * Time: 10:25 PM\n * To change ",
"end": 248,
"score": 0.9993003606796265,
"start": 244,
"tag": "USERNAME",
"value": "ling"
}
] | null | [] | package edu.nyuad.svm;
import weka.core.Capabilities;
import weka.core.Instance;
import weka.core.Instances;
import weka.filters.SimpleBatchFilter;
import java.util.Random;
import java.util.Stack;
/**
* Created with IntelliJ IDEA.
* User: ling
* Date: 28/10/13
* Time: 10:25 PM
* To change this template use File | Settings | File Templates.
*/
public class GaussianSmoothing extends SimpleBatchFilter{
@Override
public String globalInfo() {
return "Probabilistically removes points proportional to their standard deviations away from the mean of their class";
}
@Override
protected Instances determineOutputFormat(Instances instances) throws Exception {
return instances; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
protected Instances process(Instances instances) throws Exception {
// Generate the stats map
StatsMap statsMap = new StatsMap(instances);
statsMap.rankMap();
int numInstances = instances.numInstances();
int numAttributes = instances.numAttributes();
int numClasses = statsMap.classMap.keySet().size();
int classIndex = instances.classIndex();
int removeCount = 0;
Random random = new Random();
Stack<Integer> toRemove = new Stack<Integer>();
// iterate over the instances
Instance instance;
Double classVal;
Double partialRemoveProbability;
Double removeProbability;
Double[] gaussianVals;
Double[] gaussianValsOther;
int rank;
double value;
Double[] otherClassValuePair;
for (int i=0; i < numInstances; i++) {
instance = instances.get(i);
classVal = instance.classValue();
removeProbability = 0.0;
// iterate over each instances attributes
for (int j=0; j < numAttributes; j++) {
// skip the actual class
if (j == classIndex) {
continue;
}
gaussianVals = statsMap.getClassAttributeGaussian(classVal, j);
value = instance.value(j);
// find its rank
rank = statsMap.getFeatureClassRank(j, classVal);
// if its to the left of the mean
// if it's the leftmost, skip
// otherwise find the gaussian of the rank to the left
if (value < gaussianVals[0] && rank-- == 0) continue;
else if (++rank == numClasses) continue;
otherClassValuePair = statsMap.getFeatureClassRankList(j)[rank];
gaussianValsOther = statsMap.getClassAttributeGaussian(otherClassValuePair[0], j);
// add up the remove probabilities
partialRemoveProbability =
(Gaussian.phi(instance.value(j), gaussianVals[0], gaussianVals[1]) /
Gaussian.phi(otherClassValuePair[1], gaussianValsOther[0], gaussianValsOther[1]));
// if this instance does not have a bigger pdf than it's neighbor, just continue
if (partialRemoveProbability > 1) continue;
removeProbability += 1 - partialRemoveProbability;
}
// take the average of the removeProbabilities
removeProbability /= numAttributes;
// System.out.println(removeProbability);
// probabilitistically add the instance to the remove stack
if (removeProbability > random.nextDouble()) {
toRemove.push(i);
removeCount += 1;
}
}
// delete the instances in reverse order
while (!toRemove.empty()) {
instances.delete(toRemove.pop());
}
return instances;
}
@Override
public Capabilities getCapabilities() {
return super.getCapabilities(); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
public String getRevision() {
return super.getRevision(); //To change body of overridden methods use File | Settings | File Templates.
}
public static void main(String[] args) {
String filepath = "data/ling_test.arff";
DataFilters dataset = null;
try {
dataset = new DataFilters(filepath);
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
Instances data = dataset.getData();
StatsMap statsMap = new StatsMap(data);
statsMap.rankMap();
GaussianSmoothing test = new GaussianSmoothing();
try {
System.out.println(data.numInstances());
test.process(data);
System.out.println(data.numInstances());
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
| 5,039 | 0.605477 | 0.600318 | 131 | 37.465649 | 28.932482 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.656489 | false | false | 9 |
1ac772423bc776d6a854b2b72a7441de46cde9d7 | 2,293,512,553,508 | 07aaa6d5ebdd3c28866a4a54b6755a89066df761 | /src/main/java/com/wvaviator/aviatorapi/Events/ToolBreakEvent.java | 02d14dea04b9efec1a5e84fb14cc8d57e87a1a3e | [] | no_license | WVAviator/AviatorAPI | https://github.com/WVAviator/AviatorAPI | 331d1589b6fcdc34c60c720a3909f3060c443908 | a16aa5de06d741ea15426e115e55a3d205a6d760 | refs/heads/master | 2021-01-20T05:32:26.352000 | 2015-04-25T19:26:03 | 2015-04-25T19:26:03 | 34,494,339 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wvaviator.aviatorapi.Events;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
/**ToolBreakEvent
* @author Alexander
*Event fires whenever a player breaks a block with a tool, such as a shovel or axe
*/
@Cancelable
public class ToolBreakEvent extends BreakEvent{
private World world;
private BlockPos pos;
private IBlockState state;
private EntityPlayer player;
private ItemStack itemStack;
public ToolBreakEvent(World world, BlockPos pos, IBlockState state, EntityPlayer player, ItemStack itemStack) {
super(world, pos, state, player);
this.player = player;
this.pos = pos;
this.state = state;
this.player = player;
this.itemStack = itemStack;
}
public ItemStack getTool() {
return itemStack;
}
public Item getItem() {
return itemStack.getItem();
}
public Block getBlock() {
return state.getBlock();
}
}
| UTF-8 | Java | 1,256 | java | ToolBreakEvent.java | Java | [
{
"context": "thandler.Cancelable;\n\n/**ToolBreakEvent\n * @author Alexander\n *Event fires whenever a player breaks a block wi",
"end": 517,
"score": 0.7640553116798401,
"start": 508,
"tag": "NAME",
"value": "Alexander"
}
] | null | [] | package com.wvaviator.aviatorapi.Events;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
/**ToolBreakEvent
* @author Alexander
*Event fires whenever a player breaks a block with a tool, such as a shovel or axe
*/
@Cancelable
public class ToolBreakEvent extends BreakEvent{
private World world;
private BlockPos pos;
private IBlockState state;
private EntityPlayer player;
private ItemStack itemStack;
public ToolBreakEvent(World world, BlockPos pos, IBlockState state, EntityPlayer player, ItemStack itemStack) {
super(world, pos, state, player);
this.player = player;
this.pos = pos;
this.state = state;
this.player = player;
this.itemStack = itemStack;
}
public ItemStack getTool() {
return itemStack;
}
public Item getItem() {
return itemStack.getItem();
}
public Block getBlock() {
return state.getBlock();
}
}
| 1,256 | 0.769108 | 0.769108 | 50 | 24.120001 | 22.542973 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.46 | false | false | 9 |
44fbac396be695fda8cfa4fb8977bd09383d4d00 | 25,031,069,402,324 | c00ca708bb02a27a46a836f2843952c5c6abd080 | /tag/graph_valid_tree.java | ce967c227d4e388327e1f4c640689b76e8ef3450 | [] | no_license | floydchenchen/facebook | https://github.com/floydchenchen/facebook | 2ec396cefc285bea51b7765ce565392e81d328bb | 2df08c78fee0e3abccc39958234f2c177d673908 | refs/heads/master | 2021-05-14T13:10:34.412000 | 2018-01-08T21:35:27 | 2018-01-08T21:35:27 | 116,430,359 | 21 | 10 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
*
* 261. Graph Valid Tree
* https://leetcode.com/problems/graph-valid-tree/
*
* Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes),
* write a function to check whether these edges make up a valid tree.
*
* For example:
* Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], return true.
* Given n = 5 and edges = [[0, 1], [1, 2], [2, 3], [1, 3], [1, 4]], return false.
*
* assume no duplicate edges, e.g. [0,1] and [1,0] are duplicate
* the conditions for a valid tree:
* 1. all nodes are connected to root
* 2. no forward or backward nodes(也就是么有cycle)
* n >= 2
*
* 点比边个数多一个!!!!!!!
* 从一个 node 到另一个 node,必须有且只有一个 unique path
* 用一个adjacent list (a representation of graph)
* */
package tag;
import java.util.*;
public class graph_valid_tree {
// method 1: union find
// time: O(VE) V is the number of vertices, E is the number of edges
public static boolean validTree1(int n, int[][] edges) {
// initialize n isolated islands with -1
int[] nodes = new int[n];
Arrays.fill(nodes, -1);
// perform union find
for (int i = 0; i < edges.length; i++) {
// 相当于从edge连接的两个node分别去找两个node的parent
int x = find(nodes, edges[i][0]);
int y = find(nodes, edges[i][1]);
System.out.println("edge: " + i + ", x: " + x + ", y: " + y);
// if two vertices happen to be in the same set
// then there's a cycle
if (x == y) return false;
// union
nodes[y] = x;
System.out.println(Arrays.toString(nodes));
}
return edges.length == n - 1;
}
// union find helper method
// time: O(v), v is the number of the vertices
static private int find(int nodes[], int i) {
return nodes[i] == -1 ? i : find(nodes, nodes[i]);
}
// method 2: BFS + build graph
// time: O(VE) space: O(VE)
public static boolean validTree2(int n, int[][] edges) {
// 点必须比边数多一个!
// 从一个node到另一个node,必须有且只有一个unique path
// 这个方法的思路是,从任意一点出发,必须能到其他所有的点
// 能到达的点,加到set里面,最后看能到达的点的数量是否是n
if (n == 0 || edges.length != n - 1) return false;
// 用map来建graph
Map<Integer, Set<Integer>> graph = initializeGraph(n, edges);
// 里面存的node的数字key
Queue<Integer> queue = new LinkedList<>();
//
Set<Integer> visitedNodes = new HashSet<>();
queue.add(0);
visitedNodes.add(0);
while(!queue.isEmpty()) {
int key = queue.poll();
for (Integer node : graph.get(key)) {
if (visitedNodes.contains(node)) continue;
visitedNodes.add(node);
queue.add(node);
}
}
return (visitedNodes.size() == n);
}
public static Map<Integer, Set<Integer>> initializeGraph(int n, int[][] edges) {
Map<Integer, Set<Integer>> graph = new HashMap<Integer, Set<Integer>>();
for (int i = 0; i < n; i++) graph.put(i, new HashSet<Integer>());
for (int i = 0; i < edges.length; i++) {
int u = edges[i][0];
int v = edges[i][1];
graph.get(u).add(v);
graph.get(v).add(u);
}
return graph;
}
// method 3: DFS, 没细看,网上找的
// time: O(VE) space: O(VE)
public static boolean validTree3(int n, int[][] edges) {
List<List<Integer>> adjList = new ArrayList<>();
//if (edges.length == 0 && n == 1) return true;
if (edges.length != n - 1) return false;
for (int i = 0; i < n; i++)
adjList.add(i, new LinkedList<>());
for (int[] edge : edges) {
adjList.get(edge[0]).add(edge[1]);
adjList.get(edge[1]).add(edge[0]);
}
boolean[] visited = new boolean[n];
if (hasCycle(adjList, visited, 0, -1)) return false; // here use 0 as graph source
for (int i = 0; i < n; i++) // but 0 may not be in 'adjList', so should check if all vertices are visited, e.x.[[1,2],[2,3],[1,3]]
if (!visited[i]) return false;
return true;
}
public static boolean hasCycle(List<List<Integer>> adjList, boolean[] visited, int i, int pre) {
visited[i] = true;
for (int v : adjList.get(i))
if (v != pre && visited[v] || !visited[v] && hasCycle(adjList, visited, v, i)) return true;
return false;
}
public static void main(String[] args) {
int[][] edges = {{0, 1}, {0, 2}, {0, 3},{1,4}};
System.out.println(validTree3(5, edges));
}
}
| UTF-8 | Java | 4,895 | java | graph_valid_tree.java | Java | [] | null | [] | /*
*
* 261. Graph Valid Tree
* https://leetcode.com/problems/graph-valid-tree/
*
* Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes),
* write a function to check whether these edges make up a valid tree.
*
* For example:
* Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], return true.
* Given n = 5 and edges = [[0, 1], [1, 2], [2, 3], [1, 3], [1, 4]], return false.
*
* assume no duplicate edges, e.g. [0,1] and [1,0] are duplicate
* the conditions for a valid tree:
* 1. all nodes are connected to root
* 2. no forward or backward nodes(也就是么有cycle)
* n >= 2
*
* 点比边个数多一个!!!!!!!
* 从一个 node 到另一个 node,必须有且只有一个 unique path
* 用一个adjacent list (a representation of graph)
* */
package tag;
import java.util.*;
public class graph_valid_tree {
// method 1: union find
// time: O(VE) V is the number of vertices, E is the number of edges
public static boolean validTree1(int n, int[][] edges) {
// initialize n isolated islands with -1
int[] nodes = new int[n];
Arrays.fill(nodes, -1);
// perform union find
for (int i = 0; i < edges.length; i++) {
// 相当于从edge连接的两个node分别去找两个node的parent
int x = find(nodes, edges[i][0]);
int y = find(nodes, edges[i][1]);
System.out.println("edge: " + i + ", x: " + x + ", y: " + y);
// if two vertices happen to be in the same set
// then there's a cycle
if (x == y) return false;
// union
nodes[y] = x;
System.out.println(Arrays.toString(nodes));
}
return edges.length == n - 1;
}
// union find helper method
// time: O(v), v is the number of the vertices
static private int find(int nodes[], int i) {
return nodes[i] == -1 ? i : find(nodes, nodes[i]);
}
// method 2: BFS + build graph
// time: O(VE) space: O(VE)
public static boolean validTree2(int n, int[][] edges) {
// 点必须比边数多一个!
// 从一个node到另一个node,必须有且只有一个unique path
// 这个方法的思路是,从任意一点出发,必须能到其他所有的点
// 能到达的点,加到set里面,最后看能到达的点的数量是否是n
if (n == 0 || edges.length != n - 1) return false;
// 用map来建graph
Map<Integer, Set<Integer>> graph = initializeGraph(n, edges);
// 里面存的node的数字key
Queue<Integer> queue = new LinkedList<>();
//
Set<Integer> visitedNodes = new HashSet<>();
queue.add(0);
visitedNodes.add(0);
while(!queue.isEmpty()) {
int key = queue.poll();
for (Integer node : graph.get(key)) {
if (visitedNodes.contains(node)) continue;
visitedNodes.add(node);
queue.add(node);
}
}
return (visitedNodes.size() == n);
}
public static Map<Integer, Set<Integer>> initializeGraph(int n, int[][] edges) {
Map<Integer, Set<Integer>> graph = new HashMap<Integer, Set<Integer>>();
for (int i = 0; i < n; i++) graph.put(i, new HashSet<Integer>());
for (int i = 0; i < edges.length; i++) {
int u = edges[i][0];
int v = edges[i][1];
graph.get(u).add(v);
graph.get(v).add(u);
}
return graph;
}
// method 3: DFS, 没细看,网上找的
// time: O(VE) space: O(VE)
public static boolean validTree3(int n, int[][] edges) {
List<List<Integer>> adjList = new ArrayList<>();
//if (edges.length == 0 && n == 1) return true;
if (edges.length != n - 1) return false;
for (int i = 0; i < n; i++)
adjList.add(i, new LinkedList<>());
for (int[] edge : edges) {
adjList.get(edge[0]).add(edge[1]);
adjList.get(edge[1]).add(edge[0]);
}
boolean[] visited = new boolean[n];
if (hasCycle(adjList, visited, 0, -1)) return false; // here use 0 as graph source
for (int i = 0; i < n; i++) // but 0 may not be in 'adjList', so should check if all vertices are visited, e.x.[[1,2],[2,3],[1,3]]
if (!visited[i]) return false;
return true;
}
public static boolean hasCycle(List<List<Integer>> adjList, boolean[] visited, int i, int pre) {
visited[i] = true;
for (int v : adjList.get(i))
if (v != pre && visited[v] || !visited[v] && hasCycle(adjList, visited, v, i)) return true;
return false;
}
public static void main(String[] args) {
int[][] edges = {{0, 1}, {0, 2}, {0, 3},{1,4}};
System.out.println(validTree3(5, edges));
}
}
| 4,895 | 0.541386 | 0.523572 | 131 | 34.137405 | 26.574614 | 139 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.961832 | false | false | 9 |
b7af8fcdfcdd8f10537e59a154d4b30bc5db0994 | 29,695,403,918,332 | 04b0419399691a7469ff4fdadc04bbdbeaa178ee | /src/main/java/com/synovia/digital/dto/PrdProductFilterDto.java | 3a126274b71f3e1e60f50257c3de010e5a314896 | [] | no_license | ds-gurukandhamoorthi/eavest-web-app | https://github.com/ds-gurukandhamoorthi/eavest-web-app | 9d17c04f8997aa103a6c552af00013de5501d059 | 02a4834cdd7dd823de2fcf15f9d2a26407f8b154 | refs/heads/master | 2021-01-20T08:15:36.264000 | 2017-05-02T15:56:41 | 2017-05-02T15:56:41 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
*
*/
package com.synovia.digital.dto;
/**
* This class defines TODO
*
* @author TeddyCouriol
* @since 30 mars 2017
*/
public class PrdProductFilterDto {
private String isin;
private String label;
private String deliver;
private String labelSousJacent;
private Boolean isEavest;
/**
* TODO Constructs ... based on ...
*
*/
public PrdProductFilterDto() {
this(null, null, null, null, null);
}
public PrdProductFilterDto(String isin, String label, String deliver, String labelSousJacent, Boolean isEavest) {
this.isin = isin;
this.label = label;
this.deliver = deliver;
this.labelSousJacent = labelSousJacent;
this.isEavest = isEavest;
}
public String getIsin() {
return this.isin;
}
public void setIsin(String isin) {
this.isin = isin;
}
public String getLabel() {
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDeliver() {
return this.deliver;
}
public String getLabelSousJacent() {
return this.labelSousJacent;
}
public void setLabelSousJacent(String labelSousJacent) {
this.labelSousJacent = labelSousJacent;
}
public void setDeliver(String deliver) {
this.deliver = deliver;
}
public Boolean getIsEavest() {
return this.isEavest;
}
public void setIsEavest(Boolean isEavest) {
this.isEavest = isEavest;
}
@Override
public String toString() {
return new StringBuilder("[").append("ISIN: ").append(isin).append(", Product name:").append(label)
.append(", Bank name: ").append(deliver).append(", Sous-jacent: ").append(labelSousJacent)
.append(", Produit Eavest: ").append(isEavest).append("]").toString();
}
}
| UTF-8 | Java | 1,672 | java | PrdProductFilterDto.java | Java | [
{
"context": "to;\n\n/**\n * This class defines TODO\n * \n * @author TeddyCouriol\n * @since 30 mars 2017\n */\npublic class PrdProduc",
"end": 104,
"score": 0.9998722672462463,
"start": 92,
"tag": "NAME",
"value": "TeddyCouriol"
}
] | null | [] | /**
*
*/
package com.synovia.digital.dto;
/**
* This class defines TODO
*
* @author TeddyCouriol
* @since 30 mars 2017
*/
public class PrdProductFilterDto {
private String isin;
private String label;
private String deliver;
private String labelSousJacent;
private Boolean isEavest;
/**
* TODO Constructs ... based on ...
*
*/
public PrdProductFilterDto() {
this(null, null, null, null, null);
}
public PrdProductFilterDto(String isin, String label, String deliver, String labelSousJacent, Boolean isEavest) {
this.isin = isin;
this.label = label;
this.deliver = deliver;
this.labelSousJacent = labelSousJacent;
this.isEavest = isEavest;
}
public String getIsin() {
return this.isin;
}
public void setIsin(String isin) {
this.isin = isin;
}
public String getLabel() {
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDeliver() {
return this.deliver;
}
public String getLabelSousJacent() {
return this.labelSousJacent;
}
public void setLabelSousJacent(String labelSousJacent) {
this.labelSousJacent = labelSousJacent;
}
public void setDeliver(String deliver) {
this.deliver = deliver;
}
public Boolean getIsEavest() {
return this.isEavest;
}
public void setIsEavest(Boolean isEavest) {
this.isEavest = isEavest;
}
@Override
public String toString() {
return new StringBuilder("[").append("ISIN: ").append(isin).append(", Product name:").append(label)
.append(", Bank name: ").append(deliver).append(", Sous-jacent: ").append(labelSousJacent)
.append(", Produit Eavest: ").append(isEavest).append("]").toString();
}
}
| 1,672 | 0.695574 | 0.691986 | 86 | 18.44186 | 22.700581 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.313954 | false | false | 9 |
c276b54ced092dad4b30a087a9a22d6220834439 | 12,111,807,806,404 | 75bf8bfefd770d66c5f09b0db9ec1f27b39642ef | /core/src/com/louisfellows/ld29/screens/listeners/MenuListener.java | 43e9938605ed7cd8a441a8340473d9a4ddd748cd | [] | no_license | louisfellows/LD29 | https://github.com/louisfellows/LD29 | fc4325b32abcd7778f9ef774f0345c462ec3b0d1 | b21bb13e6098a75dfa456bf156bd52abe4cb16e9 | refs/heads/master | 2020-12-24T17:36:20.840000 | 2014-05-01T16:53:59 | 2014-05-01T16:54:09 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.louisfellows.ld29.screens.listeners;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.louisfellows.ld29.LD29;
import com.louisfellows.ld29.ScreenFactory;
import com.louisfellows.ld29.screens.MenuScreen;
public class MenuListener extends InputListener {
final MenuScreen parentScreen;
public MenuListener(MenuScreen screen) {
parentScreen = screen;
}
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (event.getTarget().getParent() instanceof TextButton || event.getTarget() instanceof TextButton) {
return true;
}
return false;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
if (event.getTarget().getName() != null && event.getTarget().getName().equals("start")) {
parentScreen.setNextScreen(ScreenFactory.createBattleScreen(parentScreen.getControlChoices()));
LD29.screenComplete();
} else if (event.getTarget().getParent().getName() != null && event.getTarget().getParent().getName().equals("start")) {
parentScreen.setNextScreen(ScreenFactory.createBattleScreen(parentScreen.getControlChoices()));
LD29.screenComplete();
}
}
}
| UTF-8 | Java | 1,422 | java | MenuListener.java | Java | [] | null | [] | package com.louisfellows.ld29.screens.listeners;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.louisfellows.ld29.LD29;
import com.louisfellows.ld29.ScreenFactory;
import com.louisfellows.ld29.screens.MenuScreen;
public class MenuListener extends InputListener {
final MenuScreen parentScreen;
public MenuListener(MenuScreen screen) {
parentScreen = screen;
}
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (event.getTarget().getParent() instanceof TextButton || event.getTarget() instanceof TextButton) {
return true;
}
return false;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
if (event.getTarget().getName() != null && event.getTarget().getName().equals("start")) {
parentScreen.setNextScreen(ScreenFactory.createBattleScreen(parentScreen.getControlChoices()));
LD29.screenComplete();
} else if (event.getTarget().getParent().getName() != null && event.getTarget().getParent().getName().equals("start")) {
parentScreen.setNextScreen(ScreenFactory.createBattleScreen(parentScreen.getControlChoices()));
LD29.screenComplete();
}
}
}
| 1,422 | 0.703235 | 0.69128 | 38 | 36.421051 | 36.946358 | 128 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.657895 | false | false | 9 |
7cd52903524affae344f145fabb04b0b7cc16c4d | 12,704,513,303,791 | c7cb67d3b921fefbf8e77a945098391df082f6f6 | /dijkstra/src/main/java/edu/iit/network/lsp/OriginalRoutingTableParser.java | 13942d4e8d7783f9c4b144146fae41998941c17c | [] | no_license | sb53rm/dijkstra | https://github.com/sb53rm/dijkstra | e8ff1abca5f4b01e01c0d2964b4cbe106535394e | 26910aea99828f661478169eeaedb74d9e19b24f | refs/heads/master | 2021-01-15T22:41:45.516000 | 2013-07-28T00:46:09 | 2013-07-28T00:46:09 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package edu.iit.network.lsp;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class OriginalRoutingTableParser {
public List<List<Integer>> parse(File ortFile)
{
try
{
List<List<Integer>> matrix = parseFile(ortFile);
return matrix;
} catch (FileNotFoundException e)
{
throw new LSPException(e);
} catch (IOException e)
{
throw new LSPException("An error occured during parsing of file: " + ortFile.getName(), e);
}
}
private List<List<Integer>> parseFile(File ortFile) throws IOException
{
List<List<Integer>> matrix = new ArrayList<List<Integer>>();
FileReader fr = new FileReader(ortFile);
try
{
BufferedReader br = new BufferedReader(fr);
try
{
String l;
while ((l = br.readLine()) != null)
{
String[] costs = l.split("\\s+");
List<Integer> line = new ArrayList<Integer>();
for (String cost : costs)
{
line.add(parseInteger(cost));
}
matrix.add(line);
}
} finally
{
if (br != null)
{
br.close();
}
}
} finally
{
if (fr != null)
{
fr.close();
}
}
return matrix;
}
private int parseInteger(String cost)
{
try
{
return Integer.parseInt(cost.trim());
} catch (NumberFormatException e)
{
throw new LSPException("The original routing table file contains a non-integer character: " + cost);
}
}
}
| UTF-8 | Java | 1,594 | java | OriginalRoutingTableParser.java | Java | [] | null | [] | package edu.iit.network.lsp;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class OriginalRoutingTableParser {
public List<List<Integer>> parse(File ortFile)
{
try
{
List<List<Integer>> matrix = parseFile(ortFile);
return matrix;
} catch (FileNotFoundException e)
{
throw new LSPException(e);
} catch (IOException e)
{
throw new LSPException("An error occured during parsing of file: " + ortFile.getName(), e);
}
}
private List<List<Integer>> parseFile(File ortFile) throws IOException
{
List<List<Integer>> matrix = new ArrayList<List<Integer>>();
FileReader fr = new FileReader(ortFile);
try
{
BufferedReader br = new BufferedReader(fr);
try
{
String l;
while ((l = br.readLine()) != null)
{
String[] costs = l.split("\\s+");
List<Integer> line = new ArrayList<Integer>();
for (String cost : costs)
{
line.add(parseInteger(cost));
}
matrix.add(line);
}
} finally
{
if (br != null)
{
br.close();
}
}
} finally
{
if (fr != null)
{
fr.close();
}
}
return matrix;
}
private int parseInteger(String cost)
{
try
{
return Integer.parseInt(cost.trim());
} catch (NumberFormatException e)
{
throw new LSPException("The original routing table file contains a non-integer character: " + cost);
}
}
}
| 1,594 | 0.613551 | 0.613551 | 75 | 19.253334 | 21.518421 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.573333 | false | false | 9 |
ef1ba3112fbf7b0a65f1c3f889c5dad33e08dc16 | 26,121,991,136,653 | c9c04084a40c7929c0b45cf69e4519807f85f63b | /src/practice/pw1/StudentsGrades.java | fb2f4686044c645ed6efde0e69d91e172ef60c6b | [] | no_license | zloy-di/AlgorihmsDataStructures | https://github.com/zloy-di/AlgorihmsDataStructures | 4640aa9287eae4dbf736e007aadbaf4c015bbdfa | e0b9bdcad4452db1ea9707291144969fea4fe759 | refs/heads/master | 2023-04-15T12:41:56.437000 | 2021-04-25T12:28:01 | 2021-04-25T12:28:01 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package practice.pw1;
public class StudentsGrades {
private int[] grades;
private int index;
StudentsGrades(){};
StudentsGrades(int size){
grades = new int[size];
index = 0;
}
public int[] getGrades() {
return grades;
}
public void setGrades(int[] grades) {
this.grades = grades;
}
public boolean addGrade(int grade){
if(grade < 0 || grade > 100)return false;
grades[index++]= grade;
return true;
}
public int maxGrade(){
if(index == 0)return -1;
int ret = -1;
for(int i = 0;i < index; ++i){
ret = Math.max(ret,grades[i]);
}
return ret;
}
public int minGrade(){
if(index == 0)return -1;
int ret = 101;
for(int i = 0;i < index; ++i){
ret = Math.min(ret,grades[i]);
}
return ret;
}
public float averageGrade(){
if(index == 0)return -1;
int sum = 0;
for(int i = 0;i < index; ++i){
sum += grades[i];
}
return sum / (float)index;
}
public int studentsWithGreaterAverage(){
return studentsGradeLR((int)Math.floor(averageGrade()),101);
}
public int studentsWithLowerAverage(){
return studentsGradeLR(-1,(int)Math.ceil(averageGrade()));
}
public int studentsWithA(){
return studentsGradeLR(90,101);
}
public int studentsWithBC(){
return studentsGradeLR(70,91);
}
public int studentsWithDE(){
return studentsGradeLR(59,71);
}
public int studentsWithF(){
return studentsGradeLR(-1,60);
}
@Override
public String toString() {
String ret = "Students grades : ";
for(int i = 0; i < index; ++i){
if(i != index - 1)ret = ret + grades[i] +", ";
else ret = ret + grades[i];
}
return ret;
}
public int studentsGradeLR(int l, int r){
int cnt = 0;
for(int i = 0;i < index; ++i){
if(l < grades[i] && grades[i] < r)cnt++;
}
return cnt;
}
}
| UTF-8 | Java | 2,131 | java | StudentsGrades.java | Java | [] | null | [] | package practice.pw1;
public class StudentsGrades {
private int[] grades;
private int index;
StudentsGrades(){};
StudentsGrades(int size){
grades = new int[size];
index = 0;
}
public int[] getGrades() {
return grades;
}
public void setGrades(int[] grades) {
this.grades = grades;
}
public boolean addGrade(int grade){
if(grade < 0 || grade > 100)return false;
grades[index++]= grade;
return true;
}
public int maxGrade(){
if(index == 0)return -1;
int ret = -1;
for(int i = 0;i < index; ++i){
ret = Math.max(ret,grades[i]);
}
return ret;
}
public int minGrade(){
if(index == 0)return -1;
int ret = 101;
for(int i = 0;i < index; ++i){
ret = Math.min(ret,grades[i]);
}
return ret;
}
public float averageGrade(){
if(index == 0)return -1;
int sum = 0;
for(int i = 0;i < index; ++i){
sum += grades[i];
}
return sum / (float)index;
}
public int studentsWithGreaterAverage(){
return studentsGradeLR((int)Math.floor(averageGrade()),101);
}
public int studentsWithLowerAverage(){
return studentsGradeLR(-1,(int)Math.ceil(averageGrade()));
}
public int studentsWithA(){
return studentsGradeLR(90,101);
}
public int studentsWithBC(){
return studentsGradeLR(70,91);
}
public int studentsWithDE(){
return studentsGradeLR(59,71);
}
public int studentsWithF(){
return studentsGradeLR(-1,60);
}
@Override
public String toString() {
String ret = "Students grades : ";
for(int i = 0; i < index; ++i){
if(i != index - 1)ret = ret + grades[i] +", ";
else ret = ret + grades[i];
}
return ret;
}
public int studentsGradeLR(int l, int r){
int cnt = 0;
for(int i = 0;i < index; ++i){
if(l < grades[i] && grades[i] < r)cnt++;
}
return cnt;
}
}
| 2,131 | 0.512905 | 0.492257 | 96 | 21.197916 | 17.159557 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.604167 | false | false | 9 |
b5ccc50a301ad6790d6133fe484b8a58f9d1c072 | 24,137,716,228,425 | c7bf11678e055558583c58434f7af7d6e0897bb2 | /software/caadapter/src/java/gov/nih/nci/caadapter/mms/map/AssociationMapping.java | 5015281206468e266b6b34feee26a4e7c542ee90 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | stilesb/caadapter | https://github.com/stilesb/caadapter | 2c9409e75d5f4e94a23fdeb3b244243b87a84cfc | e8b1d71133574c37bb7770da30f723736b43ba89 | refs/heads/master | 2021-01-01T18:20:01.951000 | 2017-07-25T15:20:03 | 2017-07-25T15:20:03 | 98,307,151 | 1 | 0 | null | true | 2017-07-25T13:06:50 | 2017-07-25T13:06:50 | 2017-07-25T13:06:45 | 2013-09-25T19:00:57 | 428,809 | 0 | 0 | 0 | null | null | null | /*L
* Copyright SAIC, SAIC-Frederick.
*
* Distributed under the OSI-approved BSD 3-Clause License.
* See http://ncip.github.com/caadapter/LICENSE.txt for details.
*/
package gov.nih.nci.caadapter.mms.map;
import gov.nih.nci.caadapter.common.metadata.AssociationMetadata;
import gov.nih.nci.caadapter.common.metadata.ColumnMetadata;
/**
* This class represents the mapping between a single association role
* name and a foregeign key column of a table.
*
* @author OWNER: Chunqing Lin
* @author LAST UPDATE $Author: wangeug $
* @since caAdatper v4.0
* @version $Revision: 1.1 $
* @date $Date: 2009-07-14 16:36:00 $
* @created 11-Aug-2006 8:18:19 AM
*/
public class AssociationMapping {
private AssociationMetadata associationEndMetadata;
private ColumnMetadata columnMetadata;
public AssociationMetadata getAssociationEndMetadata(){
return associationEndMetadata;
}
public ColumnMetadata getColumnMetadata(){
return columnMetadata;
}
/**
*
* @param associationEndMetadata
*/
public void setAssociationEndMetadata(AssociationMetadata associationEndMetadata){
this.associationEndMetadata = associationEndMetadata;
}
/**
*
* @param columnMetadata
*/
public void setColumnMetadata(ColumnMetadata columnMetadata){
this.columnMetadata = columnMetadata;
}
}
/**
* HISTORY: $Log: not supported by cvs2svn $
* HISTORY: Revision 1.5 2008/09/26 20:35:27 linc
* HISTORY: Updated according to code standard.
* HISTORY:
*/
| UTF-8 | Java | 1,491 | java | AssociationMapping.java | Java | [
{
"context": "egeign key column of a table.\n *\n * @author OWNER: Chunqing Lin\n * @author LAST UPDATE $Author: wangeug $\n * @sin",
"end": 495,
"score": 0.999841570854187,
"start": 483,
"tag": "NAME",
"value": "Chunqing Lin"
},
{
"context": "WNER: Chunqing Lin\n * @author LAST UPDATE $Author: wangeug $\n * @since caAdatper v4.0\n * @version $Re",
"end": 535,
"score": 0.9994750618934631,
"start": 528,
"tag": "USERNAME",
"value": "wangeug"
}
] | null | [] | /*L
* Copyright SAIC, SAIC-Frederick.
*
* Distributed under the OSI-approved BSD 3-Clause License.
* See http://ncip.github.com/caadapter/LICENSE.txt for details.
*/
package gov.nih.nci.caadapter.mms.map;
import gov.nih.nci.caadapter.common.metadata.AssociationMetadata;
import gov.nih.nci.caadapter.common.metadata.ColumnMetadata;
/**
* This class represents the mapping between a single association role
* name and a foregeign key column of a table.
*
* @author OWNER: <NAME>
* @author LAST UPDATE $Author: wangeug $
* @since caAdatper v4.0
* @version $Revision: 1.1 $
* @date $Date: 2009-07-14 16:36:00 $
* @created 11-Aug-2006 8:18:19 AM
*/
public class AssociationMapping {
private AssociationMetadata associationEndMetadata;
private ColumnMetadata columnMetadata;
public AssociationMetadata getAssociationEndMetadata(){
return associationEndMetadata;
}
public ColumnMetadata getColumnMetadata(){
return columnMetadata;
}
/**
*
* @param associationEndMetadata
*/
public void setAssociationEndMetadata(AssociationMetadata associationEndMetadata){
this.associationEndMetadata = associationEndMetadata;
}
/**
*
* @param columnMetadata
*/
public void setColumnMetadata(ColumnMetadata columnMetadata){
this.columnMetadata = columnMetadata;
}
}
/**
* HISTORY: $Log: not supported by cvs2svn $
* HISTORY: Revision 1.5 2008/09/26 20:35:27 linc
* HISTORY: Updated according to code standard.
* HISTORY:
*/
| 1,485 | 0.737089 | 0.705567 | 59 | 24.271187 | 24.12245 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.576271 | false | false | 9 |
2daef9e47a0cd4a03105d6c62213208b928c482c | 16,320,875,742,352 | 58aaa420cbdd76f042df77febc01e5e51e4822b8 | /src/main/java/quicktest/IsValidTest.java | a1fcf35c8a2053fe001530bbbf7118fbb0dffd51 | [] | no_license | xiaogui5910/LeetCodeJavaTest | https://github.com/xiaogui5910/LeetCodeJavaTest | fa969f8c992fed3f7afdb446ac41d2c77255912e | 48d9a83f44d3ba4360e18a364b07e1907a9ffece | refs/heads/master | 2022-01-03T08:37:51.530000 | 2021-12-28T09:48:29 | 2021-12-28T09:48:29 | 251,500,347 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package quicktest;
import sort.Utils;
import java.util.HashMap;
import java.util.Stack;
/**
* Created by xiaogui on 2021/12/25.
*/
public class IsValidTest {
public boolean isValid(String s) {
HashMap<Character,Character> map = new HashMap<Character, Character>();
map.put('(',')');
map.put('[',']');
map.put('{','}');
Stack<Character> stack = new Stack<Character>();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '(' || c == '[' || c =='{') {
stack.push(c);
}else {
if (stack.isEmpty()){
return false;
}else{
Character pop = stack.pop();
if (c!=map.get(pop)){
return false;
}
}
}
}
return stack.isEmpty();
}
public void test() {
String text1 = "{[{]}";
Utils.printNum(this, text1);
boolean result = isValid(text1);
Utils.printNum(this, result);
}
}
| UTF-8 | Java | 1,110 | java | IsValidTest.java | Java | [
{
"context": "ashMap;\nimport java.util.Stack;\n\n/**\n * Created by xiaogui on 2021/12/25.\n */\npublic class IsValidTest {\n ",
"end": 116,
"score": 0.9995923042297363,
"start": 109,
"tag": "USERNAME",
"value": "xiaogui"
}
] | null | [] | package quicktest;
import sort.Utils;
import java.util.HashMap;
import java.util.Stack;
/**
* Created by xiaogui on 2021/12/25.
*/
public class IsValidTest {
public boolean isValid(String s) {
HashMap<Character,Character> map = new HashMap<Character, Character>();
map.put('(',')');
map.put('[',']');
map.put('{','}');
Stack<Character> stack = new Stack<Character>();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '(' || c == '[' || c =='{') {
stack.push(c);
}else {
if (stack.isEmpty()){
return false;
}else{
Character pop = stack.pop();
if (c!=map.get(pop)){
return false;
}
}
}
}
return stack.isEmpty();
}
public void test() {
String text1 = "{[{]}";
Utils.printNum(this, text1);
boolean result = isValid(text1);
Utils.printNum(this, result);
}
}
| 1,110 | 0.441441 | 0.430631 | 44 | 24.227272 | 17.656912 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.727273 | false | false | 9 |
57889c7cb0084a9869a2ac06cdeec77ba75eb64d | 16,320,875,743,109 | 4ba2cd6716872e2becbebdf7fb40047c9e4b562a | /project-overdue/overdue-parent/overdue-role/src/main/java/cn/sjxy/overdue/service/TeacherServiceImpl.java | 60cc408e6675341cf667fa242bb164c20f9ae9f8 | [] | no_license | talkyoung/talkyoung.github.io | https://github.com/talkyoung/talkyoung.github.io | 7b18374f92ed5bd18e6bc3733c4cbfde33a824cf | 49ff55db39dab22d360f881c53d38b2c7e05785b | refs/heads/master | 2022-12-21T13:48:04.694000 | 2019-07-24T02:46:40 | 2019-07-24T02:46:40 | 196,694,761 | 1 | 0 | null | false | 2022-12-16T08:00:40 | 2019-07-13T07:56:22 | 2019-07-24T02:47:09 | 2022-12-16T08:00:38 | 90,186 | 1 | 0 | 20 | JavaScript | false | false | package cn.sjxy.overdue.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cn.sjxy.overdue.dao.CourseMapper;
import cn.sjxy.overdue.dao.StudentMapper;
import cn.sjxy.overdue.dao.TeaassignMapper;
import cn.sjxy.overdue.dao.TeacherMapper;
import cn.sjxy.overdue.pojo.*;
import cn.sjxy.overdue.pojo.entity.PageResult;
import cn.sjxy.overdue.service.TeacherService;
import com.fasterxml.jackson.databind.annotation.JsonAppend;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 服务实现层
* @author Administrator
*
*/
@Service
public class TeacherServiceImpl implements TeacherService {
@Autowired
private TeacherMapper teacherMapper;
@Autowired
private CourseMapper courseMapper;
@Autowired
private TeaassignMapper teaassignMapper;
@Autowired
private StudentMapper studentMapper;
/**
* 查询全部
*/
@Override
public List<Teacher> findAll() {
return teacherMapper.selectByExample(null);
}
/**
* 按分页查询
*/
@Override
public PageResult findPage(int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
Page<Teacher> page= (Page<Teacher>) teacherMapper.selectByExample(null);
return new PageResult(page.getTotal(), page.getResult());
}
/**
* 增加
*/
@Override
public void add(Teacher teacher) {
teacherMapper.insert(teacher);
}
/**
* 修改
*/
@Override
public void update(Teacher teacher){
teacherMapper.updateByPrimaryKey(teacher);
}
/**
* 根据ID获取实体
* @param id
* @return
*/
@Override
public Teacher findOne(Integer id){
return teacherMapper.selectByPrimaryKey(id);
}
/**
* 批量删除
*/
@Override
public void delete(Integer[] ids) {
for(Integer id:ids){
teacherMapper.deleteByPrimaryKey(id);
}
}
@Override
public PageResult findPage(Teacher teacher, int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
TeacherExample example=new TeacherExample();
TeacherExample.Criteria criteria = example.createCriteria();
if(teacher!=null){
if(teacher.getTeaName()!=null && teacher.getTeaName().length()>0){
criteria.andTeaNameLike("%"+teacher.getTeaName()+"%");
}
if(teacher.getTeaPassword()!=null && teacher.getTeaPassword().length()>0){
criteria.andTeaPasswordLike("%"+teacher.getTeaPassword()+"%");
}
if(teacher.getTeaPhone()!=null && teacher.getTeaPhone().length()>0){
criteria.andTeaPhoneLike("%"+teacher.getTeaPhone()+"%");
}
}
//单纯的让前端显示界面正确
List<Teacher> teacherList = teacherMapper.selectByExample(example);
for(Teacher teacher1 :teacherList){
String teaCourse = teacher1.getTeaCourse();
String[] split = teaCourse.split(",");
List<String> list = Arrays.asList(split);
List<String> list1 = new ArrayList<String>();
for(String s:list){
Course course = courseMapper.selectByPrimaryKey(Integer.valueOf(s));
list1.add(course.getCouName());
}
String s = list1.toString();
String substring = s.substring(1, s.length() - 1);
teacher1.setTeaCourse(substring);
TeaassignExample teaassignExample = new TeaassignExample();
TeaassignExample.Criteria criteria1 = teaassignExample.createCriteria();
criteria1.andTeaIdEqualTo(teacher1.getTeaId());
List<Teaassign> teaassigns = teaassignMapper.selectByExample(teaassignExample);
List<String> list2 = new ArrayList<String>();
if(teaassigns.size() != 0){
for (Teaassign teaassign:teaassigns){
Integer stuId = teaassign.getStuId();
Student student = studentMapper.selectByPrimaryKey(stuId);
list2.add(student.getStuName());
}
}
String s1 = list2.toString();
String substring1 = s1.substring(1, s1.length() - 1);
teacher1.setAssignStudent(substring1);
}
Page<Teacher> page= (Page<Teacher>) teacherList;
return new PageResult(page.getTotal(), page.getResult());
}
}
| UTF-8 | Java | 4,087 | java | TeacherServiceImpl.java | Java | [
{
"context": "avax.annotation.Resource;\n\n/**\n * 服务实现层\n * @author Administrator\n *\n */\n@Service\npublic class TeacherServiceImpl i",
"end": 725,
"score": 0.9885043501853943,
"start": 712,
"tag": "NAME",
"value": "Administrator"
}
] | null | [] | package cn.sjxy.overdue.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cn.sjxy.overdue.dao.CourseMapper;
import cn.sjxy.overdue.dao.StudentMapper;
import cn.sjxy.overdue.dao.TeaassignMapper;
import cn.sjxy.overdue.dao.TeacherMapper;
import cn.sjxy.overdue.pojo.*;
import cn.sjxy.overdue.pojo.entity.PageResult;
import cn.sjxy.overdue.service.TeacherService;
import com.fasterxml.jackson.databind.annotation.JsonAppend;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 服务实现层
* @author Administrator
*
*/
@Service
public class TeacherServiceImpl implements TeacherService {
@Autowired
private TeacherMapper teacherMapper;
@Autowired
private CourseMapper courseMapper;
@Autowired
private TeaassignMapper teaassignMapper;
@Autowired
private StudentMapper studentMapper;
/**
* 查询全部
*/
@Override
public List<Teacher> findAll() {
return teacherMapper.selectByExample(null);
}
/**
* 按分页查询
*/
@Override
public PageResult findPage(int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
Page<Teacher> page= (Page<Teacher>) teacherMapper.selectByExample(null);
return new PageResult(page.getTotal(), page.getResult());
}
/**
* 增加
*/
@Override
public void add(Teacher teacher) {
teacherMapper.insert(teacher);
}
/**
* 修改
*/
@Override
public void update(Teacher teacher){
teacherMapper.updateByPrimaryKey(teacher);
}
/**
* 根据ID获取实体
* @param id
* @return
*/
@Override
public Teacher findOne(Integer id){
return teacherMapper.selectByPrimaryKey(id);
}
/**
* 批量删除
*/
@Override
public void delete(Integer[] ids) {
for(Integer id:ids){
teacherMapper.deleteByPrimaryKey(id);
}
}
@Override
public PageResult findPage(Teacher teacher, int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
TeacherExample example=new TeacherExample();
TeacherExample.Criteria criteria = example.createCriteria();
if(teacher!=null){
if(teacher.getTeaName()!=null && teacher.getTeaName().length()>0){
criteria.andTeaNameLike("%"+teacher.getTeaName()+"%");
}
if(teacher.getTeaPassword()!=null && teacher.getTeaPassword().length()>0){
criteria.andTeaPasswordLike("%"+teacher.getTeaPassword()+"%");
}
if(teacher.getTeaPhone()!=null && teacher.getTeaPhone().length()>0){
criteria.andTeaPhoneLike("%"+teacher.getTeaPhone()+"%");
}
}
//单纯的让前端显示界面正确
List<Teacher> teacherList = teacherMapper.selectByExample(example);
for(Teacher teacher1 :teacherList){
String teaCourse = teacher1.getTeaCourse();
String[] split = teaCourse.split(",");
List<String> list = Arrays.asList(split);
List<String> list1 = new ArrayList<String>();
for(String s:list){
Course course = courseMapper.selectByPrimaryKey(Integer.valueOf(s));
list1.add(course.getCouName());
}
String s = list1.toString();
String substring = s.substring(1, s.length() - 1);
teacher1.setTeaCourse(substring);
TeaassignExample teaassignExample = new TeaassignExample();
TeaassignExample.Criteria criteria1 = teaassignExample.createCriteria();
criteria1.andTeaIdEqualTo(teacher1.getTeaId());
List<Teaassign> teaassigns = teaassignMapper.selectByExample(teaassignExample);
List<String> list2 = new ArrayList<String>();
if(teaassigns.size() != 0){
for (Teaassign teaassign:teaassigns){
Integer stuId = teaassign.getStuId();
Student student = studentMapper.selectByPrimaryKey(stuId);
list2.add(student.getStuName());
}
}
String s1 = list2.toString();
String substring1 = s1.substring(1, s1.length() - 1);
teacher1.setAssignStudent(substring1);
}
Page<Teacher> page= (Page<Teacher>) teacherList;
return new PageResult(page.getTotal(), page.getResult());
}
}
| 4,087 | 0.718992 | 0.712503 | 151 | 25.536425 | 23.63065 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.152318 | false | false | 9 |
a4b785d77b6ee42fe1e65582ff02255551c63a7e | 14,611,478,769,166 | bf150436d0258beea51353d69ba38d9cc2847ec2 | /Lab3/RabbitMq/src/Order.java | ff7de467ecb60de0ee09937dea41a008c5aec773 | [] | no_license | szymon-rogus/Rozprochy_Labs | https://github.com/szymon-rogus/Rozprochy_Labs | 679a47546b7cb8b5b6a8ff8e82898763f2256bb0 | cd5ef9bffbab87c7204a3f615034f53ac0c64622 | refs/heads/master | 2021-03-02T11:33:42.460000 | 2020-06-17T11:39:59 | 2020-06-17T11:39:59 | 245,865,431 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public enum Order {
PEOPLE, EQUIP, SPACE;
}
| UTF-8 | Java | 48 | java | Order.java | Java | [] | null | [] | public enum Order {
PEOPLE, EQUIP, SPACE;
}
| 48 | 0.645833 | 0.645833 | 3 | 15 | 10.198039 | 25 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 9 |
961fc51c6e28918f0d145d46f9d14c4f60c48a8c | 481,036,360,744 | bda3dac62a25fe9b3db9f0b56a619d1e01777218 | /ids-pm-web/src/main/java/com/glaway/ids/planGeneral/plantabtemplate/service/impl/TabTemplateServiceImpl.java | 6c67d7ebdaf8ff5f58e56d1c862136e944b6076d | [] | no_license | soireeme/my-learn-project | https://github.com/soireeme/my-learn-project | 228135147197f2c8de4b8458a01a1c934c497956 | 663b4f1bc4e47024172a305ade0bd24c8b9f34de | refs/heads/master | 2021-07-21T19:42:35.561000 | 2021-03-15T09:00:35 | 2021-03-15T09:00:35 | 244,584,542 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.glaway.ids.planGeneral.plantabtemplate.service.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.glaway.foundation.common.dto.TSDepartDto;
import com.glaway.foundation.common.dto.TSUserDto;
import com.glaway.foundation.common.util.CommonUtil;
import com.glaway.foundation.common.util.UserUtil;
import com.glaway.foundation.common.vo.ConditionVO;
import com.glaway.foundation.core.common.hibernate.qbc.PageList;
import com.glaway.foundation.core.common.model.json.AjaxJson;
import com.glaway.foundation.fdk.dev.common.FeignJson;
import com.glaway.foundation.tag.core.easyui.TagUtil;
import com.glaway.ids.planGeneral.plantabtemplate.dto.ObjectPropertyInfoDto;
import com.glaway.ids.planGeneral.plantabtemplate.dto.TabTemplateDto;
import com.glaway.ids.planGeneral.plantabtemplate.feign.TabTemplateFeign;
import com.glaway.ids.planGeneral.plantabtemplate.service.TabTemplateServiceI;
import com.glaway.ids.planGeneral.plantabtemplate.utils.DatagridStrUtils;
import com.glaway.ids.planGeneral.tabCombinationTemplate.feign.TabCombinationTemplateFeignServiceI;
import com.glaway.ids.planGeneral.tabCombinationTemplate.vo.CombinationTemplateVo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Title: ServiceImpl
* @Description: 页签模版管理ServiceImpl
* @author wuxing
* @date 2019-08-27
* @version V1.0
*/
@Service("tabTemplateServiceImpl")
public class TabTemplateServiceImpl implements TabTemplateServiceI {
//页签模版Feign
@Autowired
private TabTemplateFeign tabTemplateFeign;
@Autowired
private TabCombinationTemplateFeignServiceI tabCbTemplateFeignService;
/**
* 功能描述:根据查询条件展示列表(数据过滤)
* @param conditionList
*/
@Override
public void searchDatagrid(List<ConditionVO> conditionList, HttpServletResponse response) {
Map<String, String> params = new HashMap<String, String>();
for (ConditionVO conditionVO : conditionList) {
params.put("sort", conditionVO.getSort());
params.put(conditionVO.getKey(), conditionVO.getValue());
}
PageList pageList = tabTemplateFeign.searchDatagrid(params);
String datagridStr = DatagridStrUtils.getDatagridStr(pageList, true);
TagUtil.ajaxResponse(response, datagridStr);
}
/**
* 功能描述:批量/单条 启用或禁用页签模版
* @param ids id集合
* @param status 状态(启用“1”或者禁用“0”)
*/
@Override
public AjaxJson doStartOrStop(String ids, String status) {
AjaxJson ajaxJson = new AjaxJson();
FeignJson feignJson = tabTemplateFeign.doStartOrStop(ids, status);
if (feignJson.isSuccess()){
ajaxJson.setSuccess(true);
ajaxJson.setMsg(feignJson.getMsg());
}else{
ajaxJson.setSuccess(false);
ajaxJson.setMsg(feignJson.getMsg());
}
return ajaxJson;
}
/**
* 功能描述:批量/单条 删除页签模版
* @param ids id集合(“,”分隔)
*/
@Override
public AjaxJson doBatchDelete(String ids) {
AjaxJson ajaxJson = new AjaxJson();
FeignJson feignJson = tabTemplateFeign.doBatchDelete(ids);
if (feignJson.isSuccess()){
ajaxJson.setSuccess(true);
ajaxJson.setMsg(feignJson.getMsg());
}else{
ajaxJson.setSuccess(false);
ajaxJson.setMsg(feignJson.getMsg());
}
return ajaxJson;
}
/**
* 功能描述:数据保存
* @param dto
* @return AjaxJson
*/
@Override
public AjaxJson doSave(HttpServletRequest request, TabTemplateDto dto) {
TSUserDto userDto = UserUtil.getCurrentUser();
TSDepartDto departDto = userDto.getTSDepart();
//判断是新增还是修改
if (StringUtils.isEmpty(dto.getId())){
dto.setCreateBy(userDto.getUserId());
dto.setCreateFullName(userDto.getRealName());
dto.setCreateName(userDto.getUserName());
dto.setCreateOrgId(departDto.getDeptCode());
dto.setCreateTime(new Date());
}else{
dto.setUpdateBy(userDto.getUserId());
dto.setUpdateFullName(userDto.getRealName());
dto.setUpdateName(userDto.getUserName());
dto.setUpdateOrgId(departDto.getDeptCode());
dto.setUpdateTime(new Date());
}
dto.setExt1(userDto.getId());
dto = tabTemplateFeign.doSave(dto);
AjaxJson ajaxJson = new AjaxJson();
ajaxJson.setObj(dto);
ajaxJson.setSuccess(true);
return ajaxJson;
}
/**
* 功能描述:判断名称是否重复
* @param name
* @return AjaxJson
*/
@Override
public AjaxJson isRepeatName(String name, String id) {
AjaxJson ajaxJson = new AjaxJson();
boolean isRepeat = tabTemplateFeign.isRepeatName(name, id);
if (isRepeat){
ajaxJson.setSuccess(false);
}
return ajaxJson;
}
/**
* 功能描述:根据ID查询数据
* @param id
* @return TabTemplateDto
*/
@Override
public TabTemplateDto queryInfoById(String id) {
return tabTemplateFeign.queryTabTemplate(id);
}
/**
* 功能描述:根据ID复制数据
* @param id
* @return TabTemplateDto
*/
@Override
public TabTemplateDto copyEntity(String id) {
return tabTemplateFeign.copyEntity(id);
}
/**
* 功能描述:数据保存
* @param dto
* @return AjaxJson
*/
@Override
public AjaxJson doUpdateOrRevise(String updateOrRevise, TabTemplateDto dto) {
String userId = UserUtil.getInstance().getUser().getId();
dto = tabTemplateFeign.doUpdateOrRevise(dto,userId,updateOrRevise);
AjaxJson ajaxJson = new AjaxJson();
ajaxJson.setObj(dto);
ajaxJson.setSuccess(true);
return ajaxJson;
}
/**
* 功能描述:撤回
* @param params
* @return FeignJson
*/
@Override
public FeignJson doRevoke(Map<String, String> params) {
return tabTemplateFeign.doBack(params);
}
@Override
public FeignJson doBack(Map<String, String> params) {
return tabTemplateFeign.doBack(params);
}
@Override
public FeignJson doSubmitApprove(Map<String, String> params) {
return tabTemplateFeign.doSubmitApprove(params);
}
@Override
public FeignJson getVersionDatagridStr(String bizId, Integer pageSize, Integer pageNum) {
return tabTemplateFeign.getVersionDatagridStr(bizId, pageSize, pageNum);
}
@Override
public List<List<List<List<ObjectPropertyInfoDto>>>> goTabsView(HttpServletRequest request, String id,String displayAccess,String fromShow,String typeIds) {
//获取页签组合模板对应的页签
List<List<List<List<ObjectPropertyInfoDto>>>> listss = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
FeignJson combTemplateInfos = tabCbTemplateFeignService.getCombTemplateInfos(id);
List<CombinationTemplateVo> combinationTemplateVoList = mapper.convertValue(combTemplateInfos.getObj(), new TypeReference<List<CombinationTemplateVo>>() {
});
combinationTemplateVoList.forEach(vo -> {
if(!CommonUtil.isEmpty(typeIds)){
if("all".equals(typeIds)){
String tabId = vo.getTypeId();
List<List<List<ObjectPropertyInfoDto>>> lists = new ArrayList<>();
//获取对象信息
List<ObjectPropertyInfoDto> arrayList = tabTemplateFeign.queryObjectPropertyInfoDtoTabId(tabId);
ObjectPropertyInfoDto objectPropertyInfoDto = new ObjectPropertyInfoDto();
if(CommonUtil.isEmpty(arrayList) && !CommonUtil.isEmpty(vo.getUrl())){
if(CommonUtil.isEmpty(fromShow)) {
objectPropertyInfoDto.setLoadUrl(vo.getUrl()+"&fromType=tabTemplate");
}else {
objectPropertyInfoDto.setLoadUrl(vo.getUrl());
}
objectPropertyInfoDto.setOrderNumber(String.valueOf(vo.getOrderNum()));
objectPropertyInfoDto.setPropertyName(vo.getName());
objectPropertyInfoDto.setDisplayUsage("2");
objectPropertyInfoDto.setControl("0");
objectPropertyInfoDto.setId(vo.getId());
objectPropertyInfoDto.setDisplay(displayAccess);
}
//排序
List<ObjectPropertyInfoDto> orderList = arrayList.stream().sorted((o1, o2) -> Integer.valueOf(o1.getOrderNumber()).compareTo(Integer.valueOf(o2.getOrderNumber()))).collect(Collectors.toList());
//组装数据
if(!CommonUtil.isEmpty(orderList)){
orderList.forEach(it -> {
it.setDisplayUsage("1");
List<List<ObjectPropertyInfoDto>> list = new ArrayList<>();
List<ObjectPropertyInfoDto> dtos = new ArrayList<>();
dtos.add(it);
list.add(dtos);
lists.add(list);
});
}else{
List<List<ObjectPropertyInfoDto>> list = new ArrayList<>();
List<ObjectPropertyInfoDto> dtos = new ArrayList<>();
dtos.add(objectPropertyInfoDto);
list.add(dtos);
lists.add(list);
}
//出现表格格式,二次组装
lists.forEach(thisList -> {
if (!CommonUtil.isEmpty(thisList.get(0).get(0).getControl()) && thisList.get(0).get(0).getControl().equals("6")){
List<ObjectPropertyInfoDto> objectPropertyInfoDtoList = new ArrayList<>();
lists.forEach(it -> {
if (it.get(0).get(0).getControl().equals("7") && thisList.get(0).get(0).getDataSourceId().equals(it.get(0).get(0).getDataSourceId()) && thisList.get(0).get(0).getObjectPath().equals(it.get(0).get(0).getObjectPath())){
objectPropertyInfoDtoList.add(it.get(0).get(0));
}
});
thisList.add(objectPropertyInfoDtoList);
}
});
//筛选按钮
Boolean flag = false;
List<List<List<ObjectPropertyInfoDto>>> newlists = new ArrayList();
List<List<ObjectPropertyInfoDto>> itList = new ArrayList<>();
int size = lists.size();
for (int i = 0; i < size; i++) {
if (!CommonUtil.isEmpty(lists.get(i).get(0).get(0).getControl()) && !lists.get(i).get(0).get(0).getControl().equals("8")){
newlists.add(lists.get(i));
flag = true;
}else {
if(i+1 < size){
itList.add(lists.get(i).get(0));
if(!CommonUtil.isEmpty(lists.get(i+1).get(0).get(0).getControl()) && !lists.get(i+1).get(0).get(0).getControl().equals("8")){
newlists.add(itList);
itList = new ArrayList<>();
}
} else {
itList.add(lists.get(i).get(0));
newlists.add(itList);
}
}
}
//剔除为7的列表
if(!CommonUtil.isEmpty(newlists)) {
List<List<List<ObjectPropertyInfoDto>>> collect = newlists.stream().filter(i ->!CommonUtil.isEmpty(i.get(0).get(0).getControl()) && !i.get(0).get(0).getControl().equals("7")).collect(Collectors.toList());
List<List<List<ObjectPropertyInfoDto>>> list = collect.stream().filter(it -> it.size() != 0).collect(Collectors.toList());
if(!CommonUtil.isEmpty(list)) {
list.get(0).get(0).get(0).setExt1(vo.getName());
list.get(0).get(0).get(0).setExt2(vo.getTypeId());
listss.add(list);
}
}
}else{
for(String typeId : typeIds.split(",")){
if(!CommonUtil.isEmpty(typeId) && vo.getTypeId().equals(typeId)){
String tabId = vo.getTypeId();
List<List<List<ObjectPropertyInfoDto>>> lists = new ArrayList<>();
//获取对象信息
List<ObjectPropertyInfoDto> arrayList = tabTemplateFeign.queryObjectPropertyInfoDtoTabId(tabId);
ObjectPropertyInfoDto objectPropertyInfoDto = new ObjectPropertyInfoDto();
if(CommonUtil.isEmpty(arrayList) && !CommonUtil.isEmpty(vo.getUrl())){
if(CommonUtil.isEmpty(fromShow)) {
objectPropertyInfoDto.setLoadUrl(vo.getUrl()+"&fromType=tabTemplate");
}else {
objectPropertyInfoDto.setLoadUrl(vo.getUrl());
}
objectPropertyInfoDto.setOrderNumber(String.valueOf(vo.getOrderNum()));
objectPropertyInfoDto.setPropertyName(vo.getName());
objectPropertyInfoDto.setDisplayUsage("2");
objectPropertyInfoDto.setControl("0");
objectPropertyInfoDto.setId(vo.getId());
objectPropertyInfoDto.setDisplay(displayAccess);
}
//排序
List<ObjectPropertyInfoDto> orderList = arrayList.stream().sorted((o1, o2) -> Integer.valueOf(o1.getOrderNumber()).compareTo(Integer.valueOf(o2.getOrderNumber()))).collect(Collectors.toList());
//组装数据
if(!CommonUtil.isEmpty(orderList)){
orderList.forEach(it -> {
it.setDisplayUsage("1");
List<List<ObjectPropertyInfoDto>> list = new ArrayList<>();
List<ObjectPropertyInfoDto> dtos = new ArrayList<>();
dtos.add(it);
list.add(dtos);
lists.add(list);
});
}else{
List<List<ObjectPropertyInfoDto>> list = new ArrayList<>();
List<ObjectPropertyInfoDto> dtos = new ArrayList<>();
dtos.add(objectPropertyInfoDto);
list.add(dtos);
lists.add(list);
}
//出现表格格式,二次组装
lists.forEach(thisList -> {
if (!CommonUtil.isEmpty(thisList.get(0).get(0).getControl()) && thisList.get(0).get(0).getControl().equals("6")){
List<ObjectPropertyInfoDto> objectPropertyInfoDtoList = new ArrayList<>();
lists.forEach(it -> {
if (it.get(0).get(0).getControl().equals("7") && thisList.get(0).get(0).getDataSourceId().equals(it.get(0).get(0).getDataSourceId()) && thisList.get(0).get(0).getObjectPath().equals(it.get(0).get(0).getObjectPath())){
objectPropertyInfoDtoList.add(it.get(0).get(0));
}
});
thisList.add(objectPropertyInfoDtoList);
}
});
//筛选按钮
Boolean flag = false;
List<List<List<ObjectPropertyInfoDto>>> newlists = new ArrayList();
List<List<ObjectPropertyInfoDto>> itList = new ArrayList<>();
int size = lists.size();
for (int i = 0; i < size; i++) {
if (!CommonUtil.isEmpty(lists.get(i).get(0).get(0).getControl()) && !lists.get(i).get(0).get(0).getControl().equals("8")){
newlists.add(lists.get(i));
flag = true;
}else {
if(i+1 < size){
itList.add(lists.get(i).get(0));
if(!CommonUtil.isEmpty(lists.get(i+1).get(0).get(0).getControl()) && !lists.get(i+1).get(0).get(0).getControl().equals("8")){
newlists.add(itList);
itList = new ArrayList<>();
}
} else {
itList.add(lists.get(i).get(0));
newlists.add(itList);
}
}
}
//剔除为7的列表
if(!CommonUtil.isEmpty(newlists)) {
List<List<List<ObjectPropertyInfoDto>>> collect = newlists.stream().filter(i ->!CommonUtil.isEmpty(i.get(0).get(0).getControl()) && !i.get(0).get(0).getControl().equals("7")).collect(Collectors.toList());
List<List<List<ObjectPropertyInfoDto>>> list = collect.stream().filter(it -> it.size() != 0).collect(Collectors.toList());
if(!CommonUtil.isEmpty(list)) {
list.get(0).get(0).get(0).setExt1(vo.getName());
list.get(0).get(0).get(0).setExt2(vo.getTypeId());
listss.add(list);
}
}
}
}
}
}
/*if(!CommonUtil.isEmpty(displayAccess) && (displayAccess.equals(vo.getDisplayAccess()) || vo.getDisplayAccess().equals("1")) || displayAccess.equals("all")){*/
/* }*/
});
return listss;
}
@Override
public List<List<List<ObjectPropertyInfoDto>>> goTabView(HttpServletRequest request, String id) {
List<List<List<ObjectPropertyInfoDto>>> lists = new ArrayList<>();
//获取对象信息
List<ObjectPropertyInfoDto> arrayList = tabTemplateFeign.queryObjectPropertyInfoDtoTabId(id);
//排序
List<ObjectPropertyInfoDto> orderList = arrayList.stream().sorted((o1, o2) -> Integer.valueOf(o1.getOrderNumber()).compareTo(Integer.valueOf(o2.getOrderNumber()))).collect(Collectors.toList());
//组装数据
orderList.forEach(it -> {
List<List<ObjectPropertyInfoDto>> list = new ArrayList<>();
List<ObjectPropertyInfoDto> dtos = new ArrayList<>();
dtos.add(it);
list.add(dtos);
lists.add(list);
});
//出现表格格式,二次组装
lists.forEach(thisList -> {
if (thisList.get(0).get(0).getControl().equals("6")){
List<ObjectPropertyInfoDto> objectPropertyInfoDtoList = new ArrayList<>();
lists.forEach(it -> {
if (it.get(0).get(0).getControl().equals("7") && thisList.get(0).get(0).getDataSourceId().equals(it.get(0).get(0).getDataSourceId()) && thisList.get(0).get(0).getObjectPath().equals(it.get(0).get(0).getObjectPath())){
objectPropertyInfoDtoList.add(it.get(0).get(0));
}
});
thisList.add(objectPropertyInfoDtoList);
}
});
//筛选按钮
Boolean flag = false;
List<List<List<ObjectPropertyInfoDto>>> newlists = new ArrayList();
List<List<ObjectPropertyInfoDto>> itList = new ArrayList<>();
int size = lists.size();
for (int i = 0; i < size; i++) {
if (!lists.get(i).get(0).get(0).getControl().equals("8")){
newlists.add(lists.get(i));
flag = true;
}else {
if(i+1 < size){
itList.add(lists.get(i).get(0));
if(!lists.get(i+1).get(0).get(0).getControl().equals("8")){
newlists.add(itList);
itList = new ArrayList<>();
}
} else {
itList.add(lists.get(i).get(0));
newlists.add(itList);
}
}
}
//剔除为7的列表
List<List<List<ObjectPropertyInfoDto>>> collect = newlists.stream().filter(i -> !i.get(0).get(0).getControl().equals("7")).collect(Collectors.toList());
List<List<List<ObjectPropertyInfoDto>>> list = collect.stream().filter(it -> it.size() != 0).collect(Collectors.toList());
return list;
}
public List<List<Integer>> getA(Integer[] data){
List<List<Integer>> list = new ArrayList<>();
ArrayList<Integer> group = null;
for (int i = 0; i < data.length; i++) {
group = new ArrayList<Integer>();
group.add(data[i]);
while (i+1<data.length && data[i+1] == data[i] + 1){
group.add(data[++i]);
}
list.add(group);
}
return list;
}
}
| UTF-8 | Java | 22,846 | java | TabTemplateServiceImpl.java | Java | [
{
"context": "Impl\n * @Description: 页签模版管理ServiceImpl\n * @author wuxing\n * @date 2019-08-27\n * @version V1.0\n */\n@Service",
"end": 1610,
"score": 0.9995830655097961,
"start": 1604,
"tag": "USERNAME",
"value": "wuxing"
}
] | null | [] | package com.glaway.ids.planGeneral.plantabtemplate.service.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.glaway.foundation.common.dto.TSDepartDto;
import com.glaway.foundation.common.dto.TSUserDto;
import com.glaway.foundation.common.util.CommonUtil;
import com.glaway.foundation.common.util.UserUtil;
import com.glaway.foundation.common.vo.ConditionVO;
import com.glaway.foundation.core.common.hibernate.qbc.PageList;
import com.glaway.foundation.core.common.model.json.AjaxJson;
import com.glaway.foundation.fdk.dev.common.FeignJson;
import com.glaway.foundation.tag.core.easyui.TagUtil;
import com.glaway.ids.planGeneral.plantabtemplate.dto.ObjectPropertyInfoDto;
import com.glaway.ids.planGeneral.plantabtemplate.dto.TabTemplateDto;
import com.glaway.ids.planGeneral.plantabtemplate.feign.TabTemplateFeign;
import com.glaway.ids.planGeneral.plantabtemplate.service.TabTemplateServiceI;
import com.glaway.ids.planGeneral.plantabtemplate.utils.DatagridStrUtils;
import com.glaway.ids.planGeneral.tabCombinationTemplate.feign.TabCombinationTemplateFeignServiceI;
import com.glaway.ids.planGeneral.tabCombinationTemplate.vo.CombinationTemplateVo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Title: ServiceImpl
* @Description: 页签模版管理ServiceImpl
* @author wuxing
* @date 2019-08-27
* @version V1.0
*/
@Service("tabTemplateServiceImpl")
public class TabTemplateServiceImpl implements TabTemplateServiceI {
//页签模版Feign
@Autowired
private TabTemplateFeign tabTemplateFeign;
@Autowired
private TabCombinationTemplateFeignServiceI tabCbTemplateFeignService;
/**
* 功能描述:根据查询条件展示列表(数据过滤)
* @param conditionList
*/
@Override
public void searchDatagrid(List<ConditionVO> conditionList, HttpServletResponse response) {
Map<String, String> params = new HashMap<String, String>();
for (ConditionVO conditionVO : conditionList) {
params.put("sort", conditionVO.getSort());
params.put(conditionVO.getKey(), conditionVO.getValue());
}
PageList pageList = tabTemplateFeign.searchDatagrid(params);
String datagridStr = DatagridStrUtils.getDatagridStr(pageList, true);
TagUtil.ajaxResponse(response, datagridStr);
}
/**
* 功能描述:批量/单条 启用或禁用页签模版
* @param ids id集合
* @param status 状态(启用“1”或者禁用“0”)
*/
@Override
public AjaxJson doStartOrStop(String ids, String status) {
AjaxJson ajaxJson = new AjaxJson();
FeignJson feignJson = tabTemplateFeign.doStartOrStop(ids, status);
if (feignJson.isSuccess()){
ajaxJson.setSuccess(true);
ajaxJson.setMsg(feignJson.getMsg());
}else{
ajaxJson.setSuccess(false);
ajaxJson.setMsg(feignJson.getMsg());
}
return ajaxJson;
}
/**
* 功能描述:批量/单条 删除页签模版
* @param ids id集合(“,”分隔)
*/
@Override
public AjaxJson doBatchDelete(String ids) {
AjaxJson ajaxJson = new AjaxJson();
FeignJson feignJson = tabTemplateFeign.doBatchDelete(ids);
if (feignJson.isSuccess()){
ajaxJson.setSuccess(true);
ajaxJson.setMsg(feignJson.getMsg());
}else{
ajaxJson.setSuccess(false);
ajaxJson.setMsg(feignJson.getMsg());
}
return ajaxJson;
}
/**
* 功能描述:数据保存
* @param dto
* @return AjaxJson
*/
@Override
public AjaxJson doSave(HttpServletRequest request, TabTemplateDto dto) {
TSUserDto userDto = UserUtil.getCurrentUser();
TSDepartDto departDto = userDto.getTSDepart();
//判断是新增还是修改
if (StringUtils.isEmpty(dto.getId())){
dto.setCreateBy(userDto.getUserId());
dto.setCreateFullName(userDto.getRealName());
dto.setCreateName(userDto.getUserName());
dto.setCreateOrgId(departDto.getDeptCode());
dto.setCreateTime(new Date());
}else{
dto.setUpdateBy(userDto.getUserId());
dto.setUpdateFullName(userDto.getRealName());
dto.setUpdateName(userDto.getUserName());
dto.setUpdateOrgId(departDto.getDeptCode());
dto.setUpdateTime(new Date());
}
dto.setExt1(userDto.getId());
dto = tabTemplateFeign.doSave(dto);
AjaxJson ajaxJson = new AjaxJson();
ajaxJson.setObj(dto);
ajaxJson.setSuccess(true);
return ajaxJson;
}
/**
* 功能描述:判断名称是否重复
* @param name
* @return AjaxJson
*/
@Override
public AjaxJson isRepeatName(String name, String id) {
AjaxJson ajaxJson = new AjaxJson();
boolean isRepeat = tabTemplateFeign.isRepeatName(name, id);
if (isRepeat){
ajaxJson.setSuccess(false);
}
return ajaxJson;
}
/**
* 功能描述:根据ID查询数据
* @param id
* @return TabTemplateDto
*/
@Override
public TabTemplateDto queryInfoById(String id) {
return tabTemplateFeign.queryTabTemplate(id);
}
/**
* 功能描述:根据ID复制数据
* @param id
* @return TabTemplateDto
*/
@Override
public TabTemplateDto copyEntity(String id) {
return tabTemplateFeign.copyEntity(id);
}
/**
* 功能描述:数据保存
* @param dto
* @return AjaxJson
*/
@Override
public AjaxJson doUpdateOrRevise(String updateOrRevise, TabTemplateDto dto) {
String userId = UserUtil.getInstance().getUser().getId();
dto = tabTemplateFeign.doUpdateOrRevise(dto,userId,updateOrRevise);
AjaxJson ajaxJson = new AjaxJson();
ajaxJson.setObj(dto);
ajaxJson.setSuccess(true);
return ajaxJson;
}
/**
* 功能描述:撤回
* @param params
* @return FeignJson
*/
@Override
public FeignJson doRevoke(Map<String, String> params) {
return tabTemplateFeign.doBack(params);
}
@Override
public FeignJson doBack(Map<String, String> params) {
return tabTemplateFeign.doBack(params);
}
@Override
public FeignJson doSubmitApprove(Map<String, String> params) {
return tabTemplateFeign.doSubmitApprove(params);
}
@Override
public FeignJson getVersionDatagridStr(String bizId, Integer pageSize, Integer pageNum) {
return tabTemplateFeign.getVersionDatagridStr(bizId, pageSize, pageNum);
}
@Override
public List<List<List<List<ObjectPropertyInfoDto>>>> goTabsView(HttpServletRequest request, String id,String displayAccess,String fromShow,String typeIds) {
//获取页签组合模板对应的页签
List<List<List<List<ObjectPropertyInfoDto>>>> listss = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
FeignJson combTemplateInfos = tabCbTemplateFeignService.getCombTemplateInfos(id);
List<CombinationTemplateVo> combinationTemplateVoList = mapper.convertValue(combTemplateInfos.getObj(), new TypeReference<List<CombinationTemplateVo>>() {
});
combinationTemplateVoList.forEach(vo -> {
if(!CommonUtil.isEmpty(typeIds)){
if("all".equals(typeIds)){
String tabId = vo.getTypeId();
List<List<List<ObjectPropertyInfoDto>>> lists = new ArrayList<>();
//获取对象信息
List<ObjectPropertyInfoDto> arrayList = tabTemplateFeign.queryObjectPropertyInfoDtoTabId(tabId);
ObjectPropertyInfoDto objectPropertyInfoDto = new ObjectPropertyInfoDto();
if(CommonUtil.isEmpty(arrayList) && !CommonUtil.isEmpty(vo.getUrl())){
if(CommonUtil.isEmpty(fromShow)) {
objectPropertyInfoDto.setLoadUrl(vo.getUrl()+"&fromType=tabTemplate");
}else {
objectPropertyInfoDto.setLoadUrl(vo.getUrl());
}
objectPropertyInfoDto.setOrderNumber(String.valueOf(vo.getOrderNum()));
objectPropertyInfoDto.setPropertyName(vo.getName());
objectPropertyInfoDto.setDisplayUsage("2");
objectPropertyInfoDto.setControl("0");
objectPropertyInfoDto.setId(vo.getId());
objectPropertyInfoDto.setDisplay(displayAccess);
}
//排序
List<ObjectPropertyInfoDto> orderList = arrayList.stream().sorted((o1, o2) -> Integer.valueOf(o1.getOrderNumber()).compareTo(Integer.valueOf(o2.getOrderNumber()))).collect(Collectors.toList());
//组装数据
if(!CommonUtil.isEmpty(orderList)){
orderList.forEach(it -> {
it.setDisplayUsage("1");
List<List<ObjectPropertyInfoDto>> list = new ArrayList<>();
List<ObjectPropertyInfoDto> dtos = new ArrayList<>();
dtos.add(it);
list.add(dtos);
lists.add(list);
});
}else{
List<List<ObjectPropertyInfoDto>> list = new ArrayList<>();
List<ObjectPropertyInfoDto> dtos = new ArrayList<>();
dtos.add(objectPropertyInfoDto);
list.add(dtos);
lists.add(list);
}
//出现表格格式,二次组装
lists.forEach(thisList -> {
if (!CommonUtil.isEmpty(thisList.get(0).get(0).getControl()) && thisList.get(0).get(0).getControl().equals("6")){
List<ObjectPropertyInfoDto> objectPropertyInfoDtoList = new ArrayList<>();
lists.forEach(it -> {
if (it.get(0).get(0).getControl().equals("7") && thisList.get(0).get(0).getDataSourceId().equals(it.get(0).get(0).getDataSourceId()) && thisList.get(0).get(0).getObjectPath().equals(it.get(0).get(0).getObjectPath())){
objectPropertyInfoDtoList.add(it.get(0).get(0));
}
});
thisList.add(objectPropertyInfoDtoList);
}
});
//筛选按钮
Boolean flag = false;
List<List<List<ObjectPropertyInfoDto>>> newlists = new ArrayList();
List<List<ObjectPropertyInfoDto>> itList = new ArrayList<>();
int size = lists.size();
for (int i = 0; i < size; i++) {
if (!CommonUtil.isEmpty(lists.get(i).get(0).get(0).getControl()) && !lists.get(i).get(0).get(0).getControl().equals("8")){
newlists.add(lists.get(i));
flag = true;
}else {
if(i+1 < size){
itList.add(lists.get(i).get(0));
if(!CommonUtil.isEmpty(lists.get(i+1).get(0).get(0).getControl()) && !lists.get(i+1).get(0).get(0).getControl().equals("8")){
newlists.add(itList);
itList = new ArrayList<>();
}
} else {
itList.add(lists.get(i).get(0));
newlists.add(itList);
}
}
}
//剔除为7的列表
if(!CommonUtil.isEmpty(newlists)) {
List<List<List<ObjectPropertyInfoDto>>> collect = newlists.stream().filter(i ->!CommonUtil.isEmpty(i.get(0).get(0).getControl()) && !i.get(0).get(0).getControl().equals("7")).collect(Collectors.toList());
List<List<List<ObjectPropertyInfoDto>>> list = collect.stream().filter(it -> it.size() != 0).collect(Collectors.toList());
if(!CommonUtil.isEmpty(list)) {
list.get(0).get(0).get(0).setExt1(vo.getName());
list.get(0).get(0).get(0).setExt2(vo.getTypeId());
listss.add(list);
}
}
}else{
for(String typeId : typeIds.split(",")){
if(!CommonUtil.isEmpty(typeId) && vo.getTypeId().equals(typeId)){
String tabId = vo.getTypeId();
List<List<List<ObjectPropertyInfoDto>>> lists = new ArrayList<>();
//获取对象信息
List<ObjectPropertyInfoDto> arrayList = tabTemplateFeign.queryObjectPropertyInfoDtoTabId(tabId);
ObjectPropertyInfoDto objectPropertyInfoDto = new ObjectPropertyInfoDto();
if(CommonUtil.isEmpty(arrayList) && !CommonUtil.isEmpty(vo.getUrl())){
if(CommonUtil.isEmpty(fromShow)) {
objectPropertyInfoDto.setLoadUrl(vo.getUrl()+"&fromType=tabTemplate");
}else {
objectPropertyInfoDto.setLoadUrl(vo.getUrl());
}
objectPropertyInfoDto.setOrderNumber(String.valueOf(vo.getOrderNum()));
objectPropertyInfoDto.setPropertyName(vo.getName());
objectPropertyInfoDto.setDisplayUsage("2");
objectPropertyInfoDto.setControl("0");
objectPropertyInfoDto.setId(vo.getId());
objectPropertyInfoDto.setDisplay(displayAccess);
}
//排序
List<ObjectPropertyInfoDto> orderList = arrayList.stream().sorted((o1, o2) -> Integer.valueOf(o1.getOrderNumber()).compareTo(Integer.valueOf(o2.getOrderNumber()))).collect(Collectors.toList());
//组装数据
if(!CommonUtil.isEmpty(orderList)){
orderList.forEach(it -> {
it.setDisplayUsage("1");
List<List<ObjectPropertyInfoDto>> list = new ArrayList<>();
List<ObjectPropertyInfoDto> dtos = new ArrayList<>();
dtos.add(it);
list.add(dtos);
lists.add(list);
});
}else{
List<List<ObjectPropertyInfoDto>> list = new ArrayList<>();
List<ObjectPropertyInfoDto> dtos = new ArrayList<>();
dtos.add(objectPropertyInfoDto);
list.add(dtos);
lists.add(list);
}
//出现表格格式,二次组装
lists.forEach(thisList -> {
if (!CommonUtil.isEmpty(thisList.get(0).get(0).getControl()) && thisList.get(0).get(0).getControl().equals("6")){
List<ObjectPropertyInfoDto> objectPropertyInfoDtoList = new ArrayList<>();
lists.forEach(it -> {
if (it.get(0).get(0).getControl().equals("7") && thisList.get(0).get(0).getDataSourceId().equals(it.get(0).get(0).getDataSourceId()) && thisList.get(0).get(0).getObjectPath().equals(it.get(0).get(0).getObjectPath())){
objectPropertyInfoDtoList.add(it.get(0).get(0));
}
});
thisList.add(objectPropertyInfoDtoList);
}
});
//筛选按钮
Boolean flag = false;
List<List<List<ObjectPropertyInfoDto>>> newlists = new ArrayList();
List<List<ObjectPropertyInfoDto>> itList = new ArrayList<>();
int size = lists.size();
for (int i = 0; i < size; i++) {
if (!CommonUtil.isEmpty(lists.get(i).get(0).get(0).getControl()) && !lists.get(i).get(0).get(0).getControl().equals("8")){
newlists.add(lists.get(i));
flag = true;
}else {
if(i+1 < size){
itList.add(lists.get(i).get(0));
if(!CommonUtil.isEmpty(lists.get(i+1).get(0).get(0).getControl()) && !lists.get(i+1).get(0).get(0).getControl().equals("8")){
newlists.add(itList);
itList = new ArrayList<>();
}
} else {
itList.add(lists.get(i).get(0));
newlists.add(itList);
}
}
}
//剔除为7的列表
if(!CommonUtil.isEmpty(newlists)) {
List<List<List<ObjectPropertyInfoDto>>> collect = newlists.stream().filter(i ->!CommonUtil.isEmpty(i.get(0).get(0).getControl()) && !i.get(0).get(0).getControl().equals("7")).collect(Collectors.toList());
List<List<List<ObjectPropertyInfoDto>>> list = collect.stream().filter(it -> it.size() != 0).collect(Collectors.toList());
if(!CommonUtil.isEmpty(list)) {
list.get(0).get(0).get(0).setExt1(vo.getName());
list.get(0).get(0).get(0).setExt2(vo.getTypeId());
listss.add(list);
}
}
}
}
}
}
/*if(!CommonUtil.isEmpty(displayAccess) && (displayAccess.equals(vo.getDisplayAccess()) || vo.getDisplayAccess().equals("1")) || displayAccess.equals("all")){*/
/* }*/
});
return listss;
}
@Override
public List<List<List<ObjectPropertyInfoDto>>> goTabView(HttpServletRequest request, String id) {
List<List<List<ObjectPropertyInfoDto>>> lists = new ArrayList<>();
//获取对象信息
List<ObjectPropertyInfoDto> arrayList = tabTemplateFeign.queryObjectPropertyInfoDtoTabId(id);
//排序
List<ObjectPropertyInfoDto> orderList = arrayList.stream().sorted((o1, o2) -> Integer.valueOf(o1.getOrderNumber()).compareTo(Integer.valueOf(o2.getOrderNumber()))).collect(Collectors.toList());
//组装数据
orderList.forEach(it -> {
List<List<ObjectPropertyInfoDto>> list = new ArrayList<>();
List<ObjectPropertyInfoDto> dtos = new ArrayList<>();
dtos.add(it);
list.add(dtos);
lists.add(list);
});
//出现表格格式,二次组装
lists.forEach(thisList -> {
if (thisList.get(0).get(0).getControl().equals("6")){
List<ObjectPropertyInfoDto> objectPropertyInfoDtoList = new ArrayList<>();
lists.forEach(it -> {
if (it.get(0).get(0).getControl().equals("7") && thisList.get(0).get(0).getDataSourceId().equals(it.get(0).get(0).getDataSourceId()) && thisList.get(0).get(0).getObjectPath().equals(it.get(0).get(0).getObjectPath())){
objectPropertyInfoDtoList.add(it.get(0).get(0));
}
});
thisList.add(objectPropertyInfoDtoList);
}
});
//筛选按钮
Boolean flag = false;
List<List<List<ObjectPropertyInfoDto>>> newlists = new ArrayList();
List<List<ObjectPropertyInfoDto>> itList = new ArrayList<>();
int size = lists.size();
for (int i = 0; i < size; i++) {
if (!lists.get(i).get(0).get(0).getControl().equals("8")){
newlists.add(lists.get(i));
flag = true;
}else {
if(i+1 < size){
itList.add(lists.get(i).get(0));
if(!lists.get(i+1).get(0).get(0).getControl().equals("8")){
newlists.add(itList);
itList = new ArrayList<>();
}
} else {
itList.add(lists.get(i).get(0));
newlists.add(itList);
}
}
}
//剔除为7的列表
List<List<List<ObjectPropertyInfoDto>>> collect = newlists.stream().filter(i -> !i.get(0).get(0).getControl().equals("7")).collect(Collectors.toList());
List<List<List<ObjectPropertyInfoDto>>> list = collect.stream().filter(it -> it.size() != 0).collect(Collectors.toList());
return list;
}
public List<List<Integer>> getA(Integer[] data){
List<List<Integer>> list = new ArrayList<>();
ArrayList<Integer> group = null;
for (int i = 0; i < data.length; i++) {
group = new ArrayList<Integer>();
group.add(data[i]);
while (i+1<data.length && data[i+1] == data[i] + 1){
group.add(data[++i]);
}
list.add(group);
}
return list;
}
}
| 22,846 | 0.523383 | 0.515947 | 483 | 45.219463 | 40.817341 | 257 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.542443 | false | false | 9 |
136b1b923a137ada389d0d00b517d60fa399730c | 30,468,498,036,474 | ad0a3c4c6bab13e6b18a13bd5d9063d173acb044 | /src/com/opensolution/view/TableComponent.java | 266f94183b3454512c5790f7ee11846b8713a420 | [] | no_license | sghaierbs/SEPA-XML-CONVERTER | https://github.com/sghaierbs/SEPA-XML-CONVERTER | 5d4f3f6fc58d7326fd3887f38c4e502cd7269d56 | e971b9473a99b9771dbdb7773176454a7dcfa266 | refs/heads/master | 2020-07-30T07:29:38.243000 | 2019-09-22T11:27:05 | 2019-09-22T11:27:05 | 210,135,297 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Decompiled with CFR 0.146.
*/
package com.opensolution.view;
import java.awt.Component;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
public class TableComponent
extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value instanceof JButton) {
return (JButton)value;
}
if (value instanceof JComboBox) {
return (JComboBox)value;
}
return this;
}
}
| UTF-8 | Java | 653 | java | TableComponent.java | Java | [] | null | [] | /*
* Decompiled with CFR 0.146.
*/
package com.opensolution.view;
import java.awt.Component;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
public class TableComponent
extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value instanceof JButton) {
return (JButton)value;
}
if (value instanceof JComboBox) {
return (JComboBox)value;
}
return this;
}
}
| 653 | 0.70291 | 0.696784 | 24 | 26.208334 | 27.619406 | 139 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.583333 | false | false | 9 |
bb65a04dd56603f10e908e2fbd9897a884dd5d7a | 25,563,645,379,100 | 9d1e7809d53f2ae16d2bcb1643d91f8cdbf8982d | /overledger-sdk-ethereum/src/main/java/network/quant/ethereum/EthGasStation.java | 359b643acb51a0fddf1c58068f5eeab4f806fa2e | [
"Apache-2.0"
] | permissive | spinnyroe/overledger-sdk-java | https://github.com/spinnyroe/overledger-sdk-java | db5a19770961932ab6889025a70ad601c41ead14 | 8e4b5cd16460c23e4b33dc6f06e8e2e3873c6d0f | refs/heads/master | 2023-03-01T05:11:31.843000 | 2020-10-20T11:23:23 | 2020-10-20T11:23:23 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package network.quant.ethereum;
import network.quant.api.FEE_POLICY;
import network.quant.ethereum.exception.EthGasStationRequestFailedException;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.client.WebClient;
import java.math.BigInteger;
/**
* Helper class for calculating Ethereum gas
*/
@FieldDefaults(level = AccessLevel.PRIVATE)
@Slf4j
public class EthGasStation implements FeePolicy {
private static final String GAS_URL = "https://ethgasstation.info/json/ethgasAPI.json";
private static final long REFRESH_TIME = 1000 * 60;
private static EthGasStation I;
long lastUpdate = -1;
WebClient webClient = WebClient.create(GAS_URL);
BigInteger priority = new BigInteger("230");
BigInteger normal = new BigInteger("125");
BigInteger economy = new BigInteger("120");
private EthGasStation() {}
private void getGases() {
EthGasAPI ethGasAPI = this.webClient.get().retrieve()
.onStatus(HttpStatus::is4xxClientError, clientResponse -> clientResponse
.bodyToMono(ByteArrayResource.class)
.map(ByteArrayResource::getByteArray)
.map(String::new)
.map(EthGasStationRequestFailedException::new)
)
.onStatus(HttpStatus::is5xxServerError, clientResponse -> clientResponse
.bodyToMono(ByteArrayResource.class)
.map(ByteArrayResource::getByteArray)
.map(String::new)
.map(EthGasStationRequestFailedException::new)
)
.bodyToMono(EthGasAPI.class).block();
if (null != ethGasAPI) {
this.priority = BigInteger.valueOf(ethGasAPI.getFastest().longValue());
this.normal = BigInteger.valueOf(ethGasAPI.getFast().longValue());
this.economy = BigInteger.valueOf(ethGasAPI.getAverage().longValue());
}
}
private void updateGases() {
long now = System.currentTimeMillis();
if (this.lastUpdate < 0 || now - this.lastUpdate > REFRESH_TIME) {
try {
this.getGases();
} catch (Exception e) {
e.printStackTrace();
}
this.lastUpdate = now;
}
}
@Override
public BigInteger calculate(FEE_POLICY fee_policy) {
try {
this.updateGases();
} catch (Exception e) {
log.warn("Unable to connect to ethgasstation service", e);
}
switch (fee_policy) {
case PRIORITY: return this.priority;
case NORMAL: return this.normal;
case ECONOMY: return this.economy;
default: return this.normal;
}
}
static EthGasStation getInstance() {
if (null == I) {
I = new EthGasStation();
}
return I;
}
}
| UTF-8 | Java | 3,112 | java | EthGasStation.java | Java | [] | null | [] | package network.quant.ethereum;
import network.quant.api.FEE_POLICY;
import network.quant.ethereum.exception.EthGasStationRequestFailedException;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.client.WebClient;
import java.math.BigInteger;
/**
* Helper class for calculating Ethereum gas
*/
@FieldDefaults(level = AccessLevel.PRIVATE)
@Slf4j
public class EthGasStation implements FeePolicy {
private static final String GAS_URL = "https://ethgasstation.info/json/ethgasAPI.json";
private static final long REFRESH_TIME = 1000 * 60;
private static EthGasStation I;
long lastUpdate = -1;
WebClient webClient = WebClient.create(GAS_URL);
BigInteger priority = new BigInteger("230");
BigInteger normal = new BigInteger("125");
BigInteger economy = new BigInteger("120");
private EthGasStation() {}
private void getGases() {
EthGasAPI ethGasAPI = this.webClient.get().retrieve()
.onStatus(HttpStatus::is4xxClientError, clientResponse -> clientResponse
.bodyToMono(ByteArrayResource.class)
.map(ByteArrayResource::getByteArray)
.map(String::new)
.map(EthGasStationRequestFailedException::new)
)
.onStatus(HttpStatus::is5xxServerError, clientResponse -> clientResponse
.bodyToMono(ByteArrayResource.class)
.map(ByteArrayResource::getByteArray)
.map(String::new)
.map(EthGasStationRequestFailedException::new)
)
.bodyToMono(EthGasAPI.class).block();
if (null != ethGasAPI) {
this.priority = BigInteger.valueOf(ethGasAPI.getFastest().longValue());
this.normal = BigInteger.valueOf(ethGasAPI.getFast().longValue());
this.economy = BigInteger.valueOf(ethGasAPI.getAverage().longValue());
}
}
private void updateGases() {
long now = System.currentTimeMillis();
if (this.lastUpdate < 0 || now - this.lastUpdate > REFRESH_TIME) {
try {
this.getGases();
} catch (Exception e) {
e.printStackTrace();
}
this.lastUpdate = now;
}
}
@Override
public BigInteger calculate(FEE_POLICY fee_policy) {
try {
this.updateGases();
} catch (Exception e) {
log.warn("Unable to connect to ethgasstation service", e);
}
switch (fee_policy) {
case PRIORITY: return this.priority;
case NORMAL: return this.normal;
case ECONOMY: return this.economy;
default: return this.normal;
}
}
static EthGasStation getInstance() {
if (null == I) {
I = new EthGasStation();
}
return I;
}
}
| 3,112 | 0.613753 | 0.606684 | 87 | 34.770115 | 25.102869 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.448276 | false | false | 9 |
ea594a415c656394002ea8a761e4c1ab39e3024e | 7,473,243,115,317 | b2a21103c21999e373bc311e6cb14ab81c4900d3 | /src/main/java/org/rdlopes/dashboard/ui/DashboardUI.java | 4ebd6e140ed61ec20c010e8c567c6a33f6eca92e | [] | no_license | rdlopes/dashboard | https://github.com/rdlopes/dashboard | c1e08f606d55f9da60372af3b3f7de51720ecf75 | ac42f943993e35bf06b155266ab4ec0347b55b10 | refs/heads/master | 2016-09-13T19:50:12.205000 | 2016-05-18T06:50:01 | 2016-05-18T06:50:01 | 59,089,504 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.rdlopes.dashboard.ui;
import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.factories.ComponentFactory;
import com.jgoodies.forms.factories.DefaultComponentFactory;
import com.jgoodies.forms.factories.Paddings;
import com.jidesoft.swing.FontUtils;
import javax.swing.*;
import java.awt.*;
import static com.jidesoft.icons.IconsFactory.getTintedImageIcon;
import static java.awt.Font.BOLD;
import static java.awt.Font.ITALIC;
import static javax.swing.SwingConstants.CENTER;
import static javax.swing.SwingConstants.LEADING;
/**
* Created by rui on 17/05/2016.
*/
public class DashboardUI {
public static final Color COLOR1 = new Color(0, 83, 62);
public static final Color COLOR2 = new Color(0, 120, 86);
public static final Color COLOR3 = new Color(224, 243, 119);
public static final Color FOREGROUND_COLOR = COLOR1;
public static final Color BACKGROUND_COLOR = Color.white;
public static final ImageIcon ICON = getTintedImageIcon(DashboardUI.class, "/icons/17-bar-chart.png", COLOR1);
private static DashboardComponentFactory COMPONENT_FACTORY = new DashboardComponentFactory();
private DashboardUI() {
super();
}
public static FormBuilder mainForm() {
return FormBuilder.create()
.factory(COMPONENT_FACTORY)
.opaque(true)
.background(BACKGROUND_COLOR)
.padding(Paddings.DIALOG);
}
public static FormBuilder nestedForm() {
return FormBuilder.create()
.factory(COMPONENT_FACTORY)
.opaque(false);
}
public static FormBuilder cellForm() {
return FormBuilder.create()
.factory(COMPONENT_FACTORY)
.opaque(false);
}
public static ComponentFactory factory() {
return COMPONENT_FACTORY;
}
private static class DashboardComponentFactory extends DefaultComponentFactory {
@Override
public JLabel createLabel(String textWithMnemonic) {
JLabel label = super.createLabel(textWithMnemonic);
label.setForeground(FOREGROUND_COLOR);
return label;
}
@Override
public JLabel createTitle(String textWithMnemonic) {
JLabel label = super.createTitle(textWithMnemonic);
label.setHorizontalAlignment(CENTER);
label.setForeground(FOREGROUND_COLOR);
label.setFont(FontUtils.getCachedDerivedFont(label.getFont(), BOLD, 18));
return label;
}
@Override
public JLabel createHeaderLabel(String markedText) {
JLabel label = super.createHeaderLabel(markedText);
label.setHorizontalAlignment(LEADING);
label.setForeground(FOREGROUND_COLOR);
label.setFont(FontUtils.getCachedDerivedFont(label.getFont(), ITALIC, 14));
return label;
}
}
}
| UTF-8 | Java | 2,929 | java | DashboardUI.java | Java | [
{
"context": "x.swing.SwingConstants.LEADING;\n\n/**\n * Created by rui on 17/05/2016.\n */\npublic class DashboardUI {\n\n ",
"end": 580,
"score": 0.9992916584014893,
"start": 577,
"tag": "USERNAME",
"value": "rui"
}
] | null | [] | package org.rdlopes.dashboard.ui;
import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.factories.ComponentFactory;
import com.jgoodies.forms.factories.DefaultComponentFactory;
import com.jgoodies.forms.factories.Paddings;
import com.jidesoft.swing.FontUtils;
import javax.swing.*;
import java.awt.*;
import static com.jidesoft.icons.IconsFactory.getTintedImageIcon;
import static java.awt.Font.BOLD;
import static java.awt.Font.ITALIC;
import static javax.swing.SwingConstants.CENTER;
import static javax.swing.SwingConstants.LEADING;
/**
* Created by rui on 17/05/2016.
*/
public class DashboardUI {
public static final Color COLOR1 = new Color(0, 83, 62);
public static final Color COLOR2 = new Color(0, 120, 86);
public static final Color COLOR3 = new Color(224, 243, 119);
public static final Color FOREGROUND_COLOR = COLOR1;
public static final Color BACKGROUND_COLOR = Color.white;
public static final ImageIcon ICON = getTintedImageIcon(DashboardUI.class, "/icons/17-bar-chart.png", COLOR1);
private static DashboardComponentFactory COMPONENT_FACTORY = new DashboardComponentFactory();
private DashboardUI() {
super();
}
public static FormBuilder mainForm() {
return FormBuilder.create()
.factory(COMPONENT_FACTORY)
.opaque(true)
.background(BACKGROUND_COLOR)
.padding(Paddings.DIALOG);
}
public static FormBuilder nestedForm() {
return FormBuilder.create()
.factory(COMPONENT_FACTORY)
.opaque(false);
}
public static FormBuilder cellForm() {
return FormBuilder.create()
.factory(COMPONENT_FACTORY)
.opaque(false);
}
public static ComponentFactory factory() {
return COMPONENT_FACTORY;
}
private static class DashboardComponentFactory extends DefaultComponentFactory {
@Override
public JLabel createLabel(String textWithMnemonic) {
JLabel label = super.createLabel(textWithMnemonic);
label.setForeground(FOREGROUND_COLOR);
return label;
}
@Override
public JLabel createTitle(String textWithMnemonic) {
JLabel label = super.createTitle(textWithMnemonic);
label.setHorizontalAlignment(CENTER);
label.setForeground(FOREGROUND_COLOR);
label.setFont(FontUtils.getCachedDerivedFont(label.getFont(), BOLD, 18));
return label;
}
@Override
public JLabel createHeaderLabel(String markedText) {
JLabel label = super.createHeaderLabel(markedText);
label.setHorizontalAlignment(LEADING);
label.setForeground(FOREGROUND_COLOR);
label.setFont(FontUtils.getCachedDerivedFont(label.getFont(), ITALIC, 14));
return label;
}
}
}
| 2,929 | 0.672584 | 0.659269 | 90 | 31.544445 | 26.522175 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 9 |
690e93e466bf34fa79f47b0a1dcae3261fb5a29e | 30,459,908,094,283 | 46fb3df5fedb7c997743cec780ca1c9bfdab58de | /Tables/src/com/main/GameStates.java | 93702a85c616f1c8d349fc9dd40c8236e7a5ecd5 | [
"BSD-3-Clause"
] | permissive | Craigspaz/Flying-Ferris-Wheel-Engine | https://github.com/Craigspaz/Flying-Ferris-Wheel-Engine | 1968dc54b063e6847f6b1764267423428c0edeca | 4900c4e70d953c6a08679a03dd4bb656ef00efba | refs/heads/master | 2023-06-03T21:57:13.043000 | 2021-06-23T01:38:22 | 2021-06-23T01:38:22 | 82,255,990 | 0 | 0 | null | false | 2017-11-20T01:38:50 | 2017-02-17T04:08:18 | 2017-03-01T20:32:27 | 2017-11-20T01:38:50 | 39,692 | 0 | 0 | 20 | Java | false | null | package com.main;
/**
* Stores information about the states of the game
* @author Craig Ferris
*
*/
public enum GameStates
{
SPLASH, MAIN_MENU, LOADING, GAME, OPTIONS, PAUSE
}
| UTF-8 | Java | 182 | java | GameStates.java | Java | [
{
"context": "nformation about the states of the game\n * @author Craig Ferris\n *\n */\npublic enum GameStates\n{\n\tSPLASH, MAIN_MEN",
"end": 97,
"score": 0.9997916221618652,
"start": 85,
"tag": "NAME",
"value": "Craig Ferris"
}
] | null | [] | package com.main;
/**
* Stores information about the states of the game
* @author <NAME>
*
*/
public enum GameStates
{
SPLASH, MAIN_MENU, LOADING, GAME, OPTIONS, PAUSE
}
| 176 | 0.703297 | 0.703297 | 11 | 15.545455 | 18.011934 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false | 9 |
28ccf5fdee6eaa4e491ee560403830df0f9d898b | 8,778,913,193,254 | 0d010436b503ef811b75f0df8f14a6a13ca09a66 | /Unit-2/Module-9/practice-projects/hotel-booking-project/solution/hotel-booking-service/src/test/java/com/trilogyed/hotelbookingservice/service/ServiceLayerTest.java | 8fdb781f36dd6f7c447ea534243117d8947bedbd | [] | no_license | MichaelBrown1998/new_repo | https://github.com/MichaelBrown1998/new_repo | b3160217fec6452866589623a6d3a6276db32701 | fd2bbd10d75c0980e4a9129172674e058a955ea1 | refs/heads/main | 2023-02-23T18:41:06.270000 | 2021-05-23T17:32:08 | 2021-05-23T17:32:08 | 335,058,008 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.trilogyed.hotelbookingservice.service;
import com.trilogyed.hotelbookingservice.domain.Rewards;
import com.trilogyed.hotelbookingservice.domain.Room;
import com.trilogyed.hotelbookingservice.domain.RoomRateAndRewards;
import com.trilogyed.hotelbookingservice.util.feign.RewardsService;
import com.trilogyed.hotelbookingservice.util.feign.RoomService;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
public class ServiceLayerTest {
private ServiceLayer service;
private RoomService roomService;
private RewardsService rewardsService;
private static final Integer ROOM_NUMBER = new Integer(1234);
private static final String ROOM_TYPE = "deluxe";
private static final Float DEFAULT_BASE_RATE = new Float(300);
private static final Integer DEFAULT_BASE_REWARDS_POINTS = new Integer(250);
private static final Boolean DEFAULT_CAN_DOUBLE = Boolean.TRUE;
private static final Float DEFAULT_MEMBER_DISCOUNT = new Float(0.25);
@Before
public void setUp() throws Exception {
setUpRoomServiceMock();
setUpRewardsServiceMock();
service = new ServiceLayer(roomService, rewardsService);
}
private void setUpRoomServiceMock() {
roomService = mock(RoomService.class);
Room room = new Room();
room.setNumber(ROOM_NUMBER);
room.setBaseRate(DEFAULT_BASE_RATE);
room.setRoomType(ROOM_TYPE);
doReturn(room).when(roomService).getRoom(ROOM_NUMBER);
}
private void setUpRewardsServiceMock() {
rewardsService = mock(RewardsService.class);
Rewards rewards = new Rewards();
rewards.setCanDouble(DEFAULT_CAN_DOUBLE);
rewards.setDiscount(DEFAULT_MEMBER_DISCOUNT);
rewards.setId(10);
rewards.setPoints(DEFAULT_BASE_REWARDS_POINTS);
rewards.setRoomType(ROOM_TYPE);
doReturn(rewards).when(rewardsService).getRewardsInformationForRoomType(ROOM_TYPE);
}
@Test
public void shouldProperlyPopulateOutputWhenHappyPath() {
// arrange
boolean doubleBonusDay = false;
boolean isRewardsMember = false;
RoomRateAndRewards whatWeExpect = new RoomRateAndRewards();
whatWeExpect.setDoubleBonusDay(doubleBonusDay);
whatWeExpect.setTotalRewardsPoints(0);
whatWeExpect.setRewardsMember(isRewardsMember);
whatWeExpect.setBaseRate(DEFAULT_BASE_RATE);
whatWeExpect.setBaseRewardsPoints(DEFAULT_BASE_REWARDS_POINTS);
whatWeExpect.setCanDouble(DEFAULT_CAN_DOUBLE);
whatWeExpect.setFinalCost(DEFAULT_BASE_RATE);
whatWeExpect.setMemberDiscount(DEFAULT_MEMBER_DISCOUNT);
whatWeExpect.setRoomNumber(ROOM_NUMBER);
whatWeExpect.setRoomType(ROOM_TYPE);
// act
RoomRateAndRewards whatWeGot = service.gatherRoomRateAndRewards(ROOM_NUMBER, isRewardsMember, doubleBonusDay);
//assert
assertEquals(whatWeExpect, whatWeGot);
}
@Test
public void shouldGiveMemberDiscountWhenIsRewardsMemberIsTrue() {
Float baseRate = 150f;
Float discountRate = 0.25f;
Float whatWeGot = service.calculateFinalCost(true, baseRate, discountRate);
assertEquals((float) baseRate * (1 - discountRate), (float) whatWeGot, 0.00001);
}
@Test
public void shouldNotGiveMemberDiscountWhenRewardsMemberIsFalse() {
Float baseRate = 150f;
Float discountRate = 0.25f;
Float whatWeGot = service.calculateFinalCost(false, baseRate, discountRate);
assertEquals(baseRate, whatWeGot);
}
@Test
public void shouldGiveZeroPointsWhenRewardsMemberIsFalse() {
Integer whatWeGot = service.calculateRewardsPoints(false, 100, true, false);
assertEquals(new Integer(0), whatWeGot);
}
@Test
public void shouldGiveSinglePointsWhenCanDoubleIsFalse() {
Integer basePoints = 1000;
Integer whatWeGot = service.calculateRewardsPoints(true, basePoints, false, true);
assertEquals(basePoints, whatWeGot);
}
@Test
public void shouldGiveSinglePointsWhenIsNotDoubleBonusDay() {
Integer basePoints = 1111;
Integer whatWeGot = service.calculateRewardsPoints(true, basePoints, true, false);
assertEquals(basePoints, whatWeGot);
}
@Test
public void shouldGiveDoublePointsWhenCanDoubleAndIsDoubleBonusDay() {
Integer basePoints = 123;
Integer whatWeGot = service.calculateRewardsPoints(true, basePoints, true, true);
assertEquals((Integer) (basePoints * 2), whatWeGot);
}
}
| UTF-8 | Java | 4,688 | java | ServiceLayerTest.java | Java | [] | null | [] | package com.trilogyed.hotelbookingservice.service;
import com.trilogyed.hotelbookingservice.domain.Rewards;
import com.trilogyed.hotelbookingservice.domain.Room;
import com.trilogyed.hotelbookingservice.domain.RoomRateAndRewards;
import com.trilogyed.hotelbookingservice.util.feign.RewardsService;
import com.trilogyed.hotelbookingservice.util.feign.RoomService;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
public class ServiceLayerTest {
private ServiceLayer service;
private RoomService roomService;
private RewardsService rewardsService;
private static final Integer ROOM_NUMBER = new Integer(1234);
private static final String ROOM_TYPE = "deluxe";
private static final Float DEFAULT_BASE_RATE = new Float(300);
private static final Integer DEFAULT_BASE_REWARDS_POINTS = new Integer(250);
private static final Boolean DEFAULT_CAN_DOUBLE = Boolean.TRUE;
private static final Float DEFAULT_MEMBER_DISCOUNT = new Float(0.25);
@Before
public void setUp() throws Exception {
setUpRoomServiceMock();
setUpRewardsServiceMock();
service = new ServiceLayer(roomService, rewardsService);
}
private void setUpRoomServiceMock() {
roomService = mock(RoomService.class);
Room room = new Room();
room.setNumber(ROOM_NUMBER);
room.setBaseRate(DEFAULT_BASE_RATE);
room.setRoomType(ROOM_TYPE);
doReturn(room).when(roomService).getRoom(ROOM_NUMBER);
}
private void setUpRewardsServiceMock() {
rewardsService = mock(RewardsService.class);
Rewards rewards = new Rewards();
rewards.setCanDouble(DEFAULT_CAN_DOUBLE);
rewards.setDiscount(DEFAULT_MEMBER_DISCOUNT);
rewards.setId(10);
rewards.setPoints(DEFAULT_BASE_REWARDS_POINTS);
rewards.setRoomType(ROOM_TYPE);
doReturn(rewards).when(rewardsService).getRewardsInformationForRoomType(ROOM_TYPE);
}
@Test
public void shouldProperlyPopulateOutputWhenHappyPath() {
// arrange
boolean doubleBonusDay = false;
boolean isRewardsMember = false;
RoomRateAndRewards whatWeExpect = new RoomRateAndRewards();
whatWeExpect.setDoubleBonusDay(doubleBonusDay);
whatWeExpect.setTotalRewardsPoints(0);
whatWeExpect.setRewardsMember(isRewardsMember);
whatWeExpect.setBaseRate(DEFAULT_BASE_RATE);
whatWeExpect.setBaseRewardsPoints(DEFAULT_BASE_REWARDS_POINTS);
whatWeExpect.setCanDouble(DEFAULT_CAN_DOUBLE);
whatWeExpect.setFinalCost(DEFAULT_BASE_RATE);
whatWeExpect.setMemberDiscount(DEFAULT_MEMBER_DISCOUNT);
whatWeExpect.setRoomNumber(ROOM_NUMBER);
whatWeExpect.setRoomType(ROOM_TYPE);
// act
RoomRateAndRewards whatWeGot = service.gatherRoomRateAndRewards(ROOM_NUMBER, isRewardsMember, doubleBonusDay);
//assert
assertEquals(whatWeExpect, whatWeGot);
}
@Test
public void shouldGiveMemberDiscountWhenIsRewardsMemberIsTrue() {
Float baseRate = 150f;
Float discountRate = 0.25f;
Float whatWeGot = service.calculateFinalCost(true, baseRate, discountRate);
assertEquals((float) baseRate * (1 - discountRate), (float) whatWeGot, 0.00001);
}
@Test
public void shouldNotGiveMemberDiscountWhenRewardsMemberIsFalse() {
Float baseRate = 150f;
Float discountRate = 0.25f;
Float whatWeGot = service.calculateFinalCost(false, baseRate, discountRate);
assertEquals(baseRate, whatWeGot);
}
@Test
public void shouldGiveZeroPointsWhenRewardsMemberIsFalse() {
Integer whatWeGot = service.calculateRewardsPoints(false, 100, true, false);
assertEquals(new Integer(0), whatWeGot);
}
@Test
public void shouldGiveSinglePointsWhenCanDoubleIsFalse() {
Integer basePoints = 1000;
Integer whatWeGot = service.calculateRewardsPoints(true, basePoints, false, true);
assertEquals(basePoints, whatWeGot);
}
@Test
public void shouldGiveSinglePointsWhenIsNotDoubleBonusDay() {
Integer basePoints = 1111;
Integer whatWeGot = service.calculateRewardsPoints(true, basePoints, true, false);
assertEquals(basePoints, whatWeGot);
}
@Test
public void shouldGiveDoublePointsWhenCanDoubleAndIsDoubleBonusDay() {
Integer basePoints = 123;
Integer whatWeGot = service.calculateRewardsPoints(true, basePoints, true, true);
assertEquals((Integer) (basePoints * 2), whatWeGot);
}
}
| 4,688 | 0.718003 | 0.707125 | 128 | 35.625 | 28.336979 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.765625 | false | false | 9 |
edf99cc143b5a2936519450fa3043421d66de21d | 33,019,708,632,866 | 3940fabeb4f5e077ef8ae5554ca925c4525d2588 | /console-domain/src/main/java/com/founder/domain/dailyadmin/BusinessOtherEquipment.java | b186116dd5a8553ee7222643682eba1977e79d86 | [] | no_license | yyi/console-parent | https://github.com/yyi/console-parent | 621e5d17c59c3a4c3bcd129b20137752470354fa | 1a1d1e8ec58590657339c60f760a4f4fbbabacab | refs/heads/master | 2018-02-07T13:18:28.549000 | 2017-12-21T02:39:55 | 2017-12-21T02:39:55 | 95,870,592 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.founder.domain.dailyadmin;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "T_BUSINESS_OTHER_EQUIPMENT")
@Data
public class BusinessOtherEquipment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name="BUSINESS_ID")
private Business business;
@ManyToOne
@JoinColumn(name="ELEMENT_ID")
private Element element;
private String isExists;
private String brandType;
private Date purchaseTime = new Date();
private String operationSystem;
private String deploySoftware;
private String backupType;
private String remark;
private String rsrvStr1;
private String rsrvStr2;
private String rsrvStr3;
private String rsrvStr4;
}
| UTF-8 | Java | 811 | java | BusinessOtherEquipment.java | Java | [] | null | [] | package com.founder.domain.dailyadmin;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "T_BUSINESS_OTHER_EQUIPMENT")
@Data
public class BusinessOtherEquipment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name="BUSINESS_ID")
private Business business;
@ManyToOne
@JoinColumn(name="ELEMENT_ID")
private Element element;
private String isExists;
private String brandType;
private Date purchaseTime = new Date();
private String operationSystem;
private String deploySoftware;
private String backupType;
private String remark;
private String rsrvStr1;
private String rsrvStr2;
private String rsrvStr3;
private String rsrvStr4;
}
| 811 | 0.717633 | 0.7127 | 42 | 18.309525 | 15.663862 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 9 |
9502dbfb6b41e2c6f741943f51119c5799e6a211 | 1,099,511,678,951 | bf4e9c03535d4ac7b726947c12ffdf84852e35cd | /sample-api/src/main/java/org/openmrs/module/sample/api/dao/SamplePatientDao.java | 3dfdcb4d4541b96c7f7fa4bcb5abef9166868809 | [] | no_license | mddubey/openmrs-sample-module | https://github.com/mddubey/openmrs-sample-module | 80350c08702a01d32e82bf219bec438e6ed3a0d1 | 31c136ae85b03c1bec06649691652792d9d6e6ae | refs/heads/master | 2021-07-09T07:26:36.221000 | 2019-08-06T11:18:43 | 2019-08-06T11:18:43 | 200,661,403 | 1 | 1 | null | false | 2019-08-30T09:54:36 | 2019-08-05T13:32:20 | 2019-08-19T13:50:15 | 2019-08-06T11:36:45 | 20 | 1 | 1 | 1 | Java | false | false | package org.openmrs.module.sample.api.dao;
import org.hibernate.SessionFactory;
import org.openmrs.module.sample.api.model.SamplePatient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class SamplePatientDao {
private SessionFactory sessionFactory;
@Autowired
public SamplePatientDao(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public void save(SamplePatient samplePatient) {
sessionFactory.getCurrentSession().save(samplePatient);
}
public SamplePatient find(int id) {
return (SamplePatient) sessionFactory.getCurrentSession().get(SamplePatient.class, id);
}
}
| UTF-8 | Java | 737 | java | SamplePatientDao.java | Java | [] | null | [] | package org.openmrs.module.sample.api.dao;
import org.hibernate.SessionFactory;
import org.openmrs.module.sample.api.model.SamplePatient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class SamplePatientDao {
private SessionFactory sessionFactory;
@Autowired
public SamplePatientDao(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public void save(SamplePatient samplePatient) {
sessionFactory.getCurrentSession().save(samplePatient);
}
public SamplePatient find(int id) {
return (SamplePatient) sessionFactory.getCurrentSession().get(SamplePatient.class, id);
}
}
| 737 | 0.769335 | 0.769335 | 24 | 29.708334 | 26.794712 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.416667 | false | false | 9 |
739e6a473b7e7d18c12d78fef8b9e80770ec5bc2 | 4,587,025,107,741 | 0f22fbcafea73dab6357233efcd4b964b6d08f13 | /src/main/protocols/org/darkstorm/darkbot/minecraftbot/protocol/v78/packets/Packet23VehicleSpawn.java | 804ddef343dde1143fccb15180053d99675e8a42 | [
"BSD-2-Clause"
] | permissive | ViRb3/DarkBot-reborn | https://github.com/ViRb3/DarkBot-reborn | c0378ce19e75faaa502c6e36e9ab1d6a058c1d07 | ca22d51ac8124efe39a3463ac5ca613e32da4678 | refs/heads/master | 2021-01-22T07:39:46.564000 | 2014-07-02T22:04:38 | 2014-07-02T22:04:38 | 102,308,843 | 4 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.darkstorm.darkbot.minecraftbot.protocol.v78.packets;
import java.io.*;
import org.darkstorm.darkbot.minecraftbot.protocol.*;
public class Packet23VehicleSpawn extends AbstractPacket implements ReadablePacket {
public int entityId;
public int xPosition;
public int yPosition;
public int zPosition;
public int speedX;
public int speedY;
public int speedZ;
public int yaw;
public int pitch;
public int type;
public int throwerEntityId;
public Packet23VehicleSpawn() {
}
@Override
public void readData(DataInputStream in) throws IOException {
entityId = in.readInt();
type = in.readByte();
xPosition = in.readInt();
yPosition = in.readInt();
zPosition = in.readInt();
yaw = in.readByte();
pitch = in.readByte();
throwerEntityId = in.readInt();
if(throwerEntityId > 0) {
speedX = in.readShort();
speedY = in.readShort();
speedZ = in.readShort();
}
}
@Override
public int getId() {
return 23;
}
}
| UTF-8 | Java | 962 | java | Packet23VehicleSpawn.java | Java | [] | null | [] | package org.darkstorm.darkbot.minecraftbot.protocol.v78.packets;
import java.io.*;
import org.darkstorm.darkbot.minecraftbot.protocol.*;
public class Packet23VehicleSpawn extends AbstractPacket implements ReadablePacket {
public int entityId;
public int xPosition;
public int yPosition;
public int zPosition;
public int speedX;
public int speedY;
public int speedZ;
public int yaw;
public int pitch;
public int type;
public int throwerEntityId;
public Packet23VehicleSpawn() {
}
@Override
public void readData(DataInputStream in) throws IOException {
entityId = in.readInt();
type = in.readByte();
xPosition = in.readInt();
yPosition = in.readInt();
zPosition = in.readInt();
yaw = in.readByte();
pitch = in.readByte();
throwerEntityId = in.readInt();
if(throwerEntityId > 0) {
speedX = in.readShort();
speedY = in.readShort();
speedZ = in.readShort();
}
}
@Override
public int getId() {
return 23;
}
}
| 962 | 0.717256 | 0.7079 | 47 | 19.468084 | 17.982084 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.617021 | false | false | 9 |
d25586ed2d0d19a584fdaeea85e4c1cc9b74a98e | 17,523,466,609,615 | 3ddcced21bf3cdc45b97ae6541b49d5dde74dd42 | /app/src/main/java/david/bicilock/CheckBikeActivity.java | 40123f2a7967a88b225dd9a26d202eb38c124a63 | [] | no_license | deividjg/BiciLock | https://github.com/deividjg/BiciLock | 110a6a687958126b546c8770b49901e7a6c995b2 | 81cb308081d39e66a3ad100d51355728595d0ca0 | refs/heads/master | 2021-01-19T19:44:15.878000 | 2017-06-23T07:50:02 | 2017-06-23T07:50:02 | 88,436,274 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package david.bicilock;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
public class CheckBikeActivity extends AppCompatActivity {
private String serialNumber;
private JSONArray jSONArray;
private ReturnJSON returnJSON;
private Bike bike;
private EditText etSerialNumberCheckBike;
private ArrayList<Bike> arrayBikes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_check_bike);
etSerialNumberCheckBike = (EditText)findViewById(R.id.etSerialNumberCheckBike);
returnJSON = new ReturnJSON();
}
public void checkSerialNumber(View view){
if(isEmpty(etSerialNumberCheckBike)){
Toast.makeText(this, R.string.enter_sn, Toast.LENGTH_SHORT).show();
} else {
serialNumber = etSerialNumberCheckBike.getText().toString();
new CheckBike().execute();
}
}
///////Task for check serial number
class CheckBike extends AsyncTask<String, String, JSONArray> {
private ProgressDialog pDialog;
@Override
protected void onPreExecute() {
pDialog = new ProgressDialog(CheckBikeActivity.this);
pDialog.setMessage(getString(R.string.charging));
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected JSONArray doInBackground(String... args) {
try {
HashMap<String, String> parametrosPost = new HashMap<>();
parametrosPost.put("ins_sql", "SELECT * FROM bikes WHERE SerialNumber='" + serialNumber + "'");
jSONArray = returnJSON.sendRequest(Parameters.URL_DOWNLOAD, parametrosPost);
if (jSONArray != null) {
return jSONArray;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(JSONArray json) {
if (pDialog != null && pDialog.isShowing()) {
pDialog.dismiss();
}
if (json != null) {
arrayBikes = new ArrayList<Bike>();
long id;
for (int i = 0; i < json.length(); i++) {
id = i;
try {
JSONObject jsonObject = json.getJSONObject(i);
bike = new Bike();
bike.setId(id);
bike.setSerialNumber(jsonObject.getString("SerialNumber"));
bike.setBrand(jsonObject.getString("Brand"));
bike.setModel(jsonObject.getString("Model"));
bike.setColor(jsonObject.getString("Color"));
bike.setYear(jsonObject.getString("Year"));
bike.setStolen(jsonObject.getInt("Stolen"));
bike.setDetails("Details");
arrayBikes.add(bike);
} catch (JSONException e) {
e.printStackTrace();
}
}
if (arrayBikes.size() > 0) {
if (bike.stolen == 1) {
confirmScreen();
} else {
Toast.makeText(CheckBikeActivity.this, "Esta bicicleta no está denunciada", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(CheckBikeActivity.this, "La bicicleta no se encuentra en la base de datos", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(CheckBikeActivity.this, "Error", Toast.LENGTH_LONG).show();
}
}
}
protected void confirmScreen(){
Intent intent = new Intent (this, ConfirmBikeActivity.class);
intent.putExtra("serialNumber", serialNumber);
startActivity(intent);
finish();
}
public boolean isEmpty(EditText editText) {
return editText.getText().toString().trim().length() == 0;
}
public void cancel(View view){
finish();
}
@Override
public void onBackPressed(){
finish();
}
}
| UTF-8 | Java | 4,753 | java | CheckBikeActivity.java | Java | [] | null | [] | package david.bicilock;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
public class CheckBikeActivity extends AppCompatActivity {
private String serialNumber;
private JSONArray jSONArray;
private ReturnJSON returnJSON;
private Bike bike;
private EditText etSerialNumberCheckBike;
private ArrayList<Bike> arrayBikes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_check_bike);
etSerialNumberCheckBike = (EditText)findViewById(R.id.etSerialNumberCheckBike);
returnJSON = new ReturnJSON();
}
public void checkSerialNumber(View view){
if(isEmpty(etSerialNumberCheckBike)){
Toast.makeText(this, R.string.enter_sn, Toast.LENGTH_SHORT).show();
} else {
serialNumber = etSerialNumberCheckBike.getText().toString();
new CheckBike().execute();
}
}
///////Task for check serial number
class CheckBike extends AsyncTask<String, String, JSONArray> {
private ProgressDialog pDialog;
@Override
protected void onPreExecute() {
pDialog = new ProgressDialog(CheckBikeActivity.this);
pDialog.setMessage(getString(R.string.charging));
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected JSONArray doInBackground(String... args) {
try {
HashMap<String, String> parametrosPost = new HashMap<>();
parametrosPost.put("ins_sql", "SELECT * FROM bikes WHERE SerialNumber='" + serialNumber + "'");
jSONArray = returnJSON.sendRequest(Parameters.URL_DOWNLOAD, parametrosPost);
if (jSONArray != null) {
return jSONArray;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(JSONArray json) {
if (pDialog != null && pDialog.isShowing()) {
pDialog.dismiss();
}
if (json != null) {
arrayBikes = new ArrayList<Bike>();
long id;
for (int i = 0; i < json.length(); i++) {
id = i;
try {
JSONObject jsonObject = json.getJSONObject(i);
bike = new Bike();
bike.setId(id);
bike.setSerialNumber(jsonObject.getString("SerialNumber"));
bike.setBrand(jsonObject.getString("Brand"));
bike.setModel(jsonObject.getString("Model"));
bike.setColor(jsonObject.getString("Color"));
bike.setYear(jsonObject.getString("Year"));
bike.setStolen(jsonObject.getInt("Stolen"));
bike.setDetails("Details");
arrayBikes.add(bike);
} catch (JSONException e) {
e.printStackTrace();
}
}
if (arrayBikes.size() > 0) {
if (bike.stolen == 1) {
confirmScreen();
} else {
Toast.makeText(CheckBikeActivity.this, "Esta bicicleta no está denunciada", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(CheckBikeActivity.this, "La bicicleta no se encuentra en la base de datos", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(CheckBikeActivity.this, "Error", Toast.LENGTH_LONG).show();
}
}
}
protected void confirmScreen(){
Intent intent = new Intent (this, ConfirmBikeActivity.class);
intent.putExtra("serialNumber", serialNumber);
startActivity(intent);
finish();
}
public boolean isEmpty(EditText editText) {
return editText.getText().toString().trim().length() == 0;
}
public void cancel(View view){
finish();
}
@Override
public void onBackPressed(){
finish();
}
}
| 4,753 | 0.566498 | 0.565446 | 138 | 33.434784 | 26.767099 | 138 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.615942 | false | false | 9 |
4bd92a4a477f08e2a2a5655c892eb01eac175b04 | 25,658,134,679,978 | c6506e4c6206e5b227b5f284f484167c5b2ab345 | /tile/web/src/main/java/com/dt/tarmag/interceptor/AutoLoginInterceptor.java | da4dca3325a9fa8041adeccf8d193ed58aea16b3 | [] | no_license | yranibee/exercise | https://github.com/yranibee/exercise | 2fd765af9b61eef321605c9ce83b7378a05fcb1d | af1a6bd6626595b22505fd9d11be61639e2812cd | refs/heads/master | 2021-07-09T16:28:18.636000 | 2017-10-10T06:46:49 | 2017-10-10T06:46:49 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dt.tarmag.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import com.dt.framework.util.ActionUtil;
import com.dt.framework.util.Constant;
import com.dt.framework.util.CookieUtil;
import com.dt.tarmag.model.Customer;
import com.dt.tarmag.service.ICustomerService;
/**
* @author wei
*/
public class AutoLoginInterceptor extends AbstractHandlerInterceptor {
@Autowired
private ICustomerService customerService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HttpSession session = ActionUtil.getSession();
Customer _customer = (Customer) session.getAttribute(Constant.SESSION_USER);
if(_customer != null) {
return true;
}
String userName = CookieUtil.getUserFromCookie();
if(userName != null) {
Customer customer = customerService.getCustomerByUserName(userName);
if(customer != null) {
session.setAttribute(Constant.SESSION_USER_ID, customer.getId());
session.setAttribute(Constant.SESSION_USER, customer);
}
}
return true;
}
}
| UTF-8 | Java | 1,277 | java | AutoLoginInterceptor.java | Java | [
{
"context": "mag.service.ICustomerService;\r\n\r\n\r\n/**\r\n * @author wei\r\n */\r\npublic class AutoLoginInterceptor extends A",
"end": 474,
"score": 0.9987207055091858,
"start": 471,
"tag": "USERNAME",
"value": "wei"
}
] | null | [] | package com.dt.tarmag.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import com.dt.framework.util.ActionUtil;
import com.dt.framework.util.Constant;
import com.dt.framework.util.CookieUtil;
import com.dt.tarmag.model.Customer;
import com.dt.tarmag.service.ICustomerService;
/**
* @author wei
*/
public class AutoLoginInterceptor extends AbstractHandlerInterceptor {
@Autowired
private ICustomerService customerService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HttpSession session = ActionUtil.getSession();
Customer _customer = (Customer) session.getAttribute(Constant.SESSION_USER);
if(_customer != null) {
return true;
}
String userName = CookieUtil.getUserFromCookie();
if(userName != null) {
Customer customer = customerService.getCustomerByUserName(userName);
if(customer != null) {
session.setAttribute(Constant.SESSION_USER_ID, customer.getId());
session.setAttribute(Constant.SESSION_USER, customer);
}
}
return true;
}
}
| 1,277 | 0.751762 | 0.751762 | 43 | 27.697674 | 27.755188 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.581395 | false | false | 9 |
c6dc4a12aa2afa4b8d823eb38ce774556b374d5a | 25,658,134,682,205 | a38059bfc86c33f63595025d0546cba96b72d46e | /src/main/java/com/octopus/bamboo/plugins/task/pack/PackTaskConfigurator.java | cbd8dae64402b99cdee5ce9c9aaa6ccf060049e2 | [
"Apache-2.0"
] | permissive | OctopusDeploy/Octopus-Bamboo | https://github.com/OctopusDeploy/Octopus-Bamboo | 9757dd9f37623f4061c300a0258d2e3da453bbaa | fc3fbea0aadeacb57fb03198db8d7af72de8eedd | refs/heads/main | 2023-04-14T12:34:27.425000 | 2023-03-09T02:45:41 | 2023-03-09T02:45:41 | 90,926,510 | 6 | 3 | NOASSERTION | false | 2023-03-24T06:13:40 | 2017-05-11T02:05:55 | 2022-11-17T12:42:34 | 2023-03-24T06:13:39 | 3,264 | 7 | 5 | 7 | Java | false | false | package com.octopus.bamboo.plugins.task.pack;
import com.atlassian.bamboo.collections.ActionParametersMap;
import com.atlassian.bamboo.task.AbstractTaskConfigurator;
import com.atlassian.bamboo.task.TaskDefinition;
import com.atlassian.bamboo.utils.error.ErrorCollection;
import com.atlassian.plugin.spring.scanner.annotation.export.ExportAsService;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.struts.TextProvider;
import com.octopus.constants.OctoConstants;
import com.octopus.services.impl.BaseConfigurator;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.Arrays;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Task configuration, where we save and validate the settings applied
* to the plugin.
*/
@Component
@ExportAsService(AbstractTaskConfigurator.class)
@Named("packTaskConfigurator")
public class PackTaskConfigurator extends BaseConfigurator {
@ComponentImport
private final TextProvider textProvider;
@Inject
public PackTaskConfigurator(@NotNull final TextProvider textProvider,
@NotNull final ApplicationContext applicationContext) {
super(applicationContext);
this.textProvider = checkNotNull(textProvider, "textProvider cannot be null");
}
@Override
public Map<String, String> generateTaskConfigMap(@NotNull final ActionParametersMap params,
@Nullable final TaskDefinition previousTaskDefinition) {
checkNotNull(params);
final Map<String, String> config = super.generateTaskConfigMap(params, previousTaskDefinition);
config.put(OctoConstants.PACK_BASE_PATH_NAME, params.getString(OctoConstants.PACK_BASE_PATH_NAME));
config.put(OctoConstants.PACK_FORMAT_NAME, params.getString(OctoConstants.PACK_FORMAT_NAME));
config.put(OctoConstants.PACK_ID_NAME, params.getString(OctoConstants.PACK_ID_NAME));
config.put(OctoConstants.PACK_VERSION_NAME, params.getString(OctoConstants.PACK_VERSION_NAME));
config.put(OctoConstants.PACK_INCLUDE_NAME, params.getString(OctoConstants.PACK_INCLUDE_NAME));
config.put(OctoConstants.PACK_OUT_FOLDER_NAME, params.getString(OctoConstants.PACK_OUT_FOLDER_NAME));
config.put(OctoConstants.PACK_OVERWRITE_NAME, params.getString(OctoConstants.PACK_OVERWRITE_NAME));
config.put(OctoConstants.VERBOSE_LOGGING, params.getString(OctoConstants.VERBOSE_LOGGING));
config.put(OctoConstants.ADDITIONAL_COMMAND_LINE_ARGS_NAME, params.getString(OctoConstants.ADDITIONAL_COMMAND_LINE_ARGS_NAME));
config.put(OctoConstants.OCTOPUS_CLI, params.getString(OctoConstants.OCTOPUS_CLI));
return config;
}
@Override
public void populateContextForCreate(@NotNull final Map<String, Object> context) {
context.put(OctoConstants.UI_CONFIG_BEAN, this.getUIConfigSupport());
context.put(OctoConstants.PACK_FORMAT_NAME, OctoConstants.PACK_ZIP_FORMAT);
context.put(OctoConstants.PACK_FORMATS_LIST, Arrays.asList(OctoConstants.PACK_ZIP_FORMAT, OctoConstants.PACK_NUGET_FORMAT));
}
@Override
public void populateContextForEdit(@NotNull final Map<String, Object> context,
@NotNull final TaskDefinition taskDefinition) {
checkNotNull(context);
checkNotNull(taskDefinition);
super.populateContextForEdit(context, taskDefinition);
context.put(OctoConstants.PACK_BASE_PATH_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_BASE_PATH_NAME));
context.put(OctoConstants.PACK_FORMAT_NAME, StringUtils.defaultIfBlank(
taskDefinition.getConfiguration().get(OctoConstants.PACK_FORMAT_NAME),
OctoConstants.PACK_ZIP_FORMAT));
context.put(OctoConstants.PACK_ID_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_ID_NAME));
context.put(OctoConstants.PACK_VERSION_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_VERSION_NAME));
context.put(OctoConstants.PACK_INCLUDE_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_INCLUDE_NAME));
context.put(OctoConstants.PACK_OUT_FOLDER_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_OUT_FOLDER_NAME));
context.put(OctoConstants.PACK_OVERWRITE_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_OVERWRITE_NAME));
context.put(OctoConstants.VERBOSE_LOGGING, taskDefinition.getConfiguration().get(OctoConstants.VERBOSE_LOGGING));
context.put(OctoConstants.ADDITIONAL_COMMAND_LINE_ARGS_NAME, taskDefinition.getConfiguration().get(OctoConstants.ADDITIONAL_COMMAND_LINE_ARGS_NAME));
context.put(OctoConstants.OCTOPUS_CLI, taskDefinition.getConfiguration().get(OctoConstants.OCTOPUS_CLI));
context.put(OctoConstants.UI_CONFIG_BEAN, this.getUIConfigSupport());
context.put(OctoConstants.PACK_FORMATS_LIST, Arrays.asList(OctoConstants.PACK_ZIP_FORMAT, OctoConstants.PACK_NUGET_FORMAT));
}
@Override
public void validate(@NotNull final ActionParametersMap params,
@NotNull final ErrorCollection errorCollection) {
checkNotNull(params);
checkNotNull(errorCollection);
super.validate(params, errorCollection);
final String pushPattern = params.getString(OctoConstants.PACK_ID_NAME);
if (StringUtils.isEmpty(pushPattern)) {
errorCollection.addError(OctoConstants.PACK_ID_NAME, textProvider.getText(OctoConstants.PACK_ID_ERROR_KEY));
}
final String octopusCli = params.getString(OctoConstants.OCTOPUS_CLI);
if (StringUtils.isEmpty(octopusCli)) {
errorCollection.addError(OctoConstants.OCTOPUS_CLI, textProvider.getText(OctoConstants.OCTOPUS_CLI_ERROR_KEY));
}
final String packFormat = params.getString(OctoConstants.PACK_FORMAT_NAME);
if (StringUtils.isEmpty(packFormat)) {
errorCollection.addError(OctoConstants.PACK_FORMAT_NAME, textProvider.getText(OctoConstants.PACK_FORMAT_ERROR_KEY));
}
}
}
| UTF-8 | Java | 6,418 | java | PackTaskConfigurator.java | Java | [] | null | [] | package com.octopus.bamboo.plugins.task.pack;
import com.atlassian.bamboo.collections.ActionParametersMap;
import com.atlassian.bamboo.task.AbstractTaskConfigurator;
import com.atlassian.bamboo.task.TaskDefinition;
import com.atlassian.bamboo.utils.error.ErrorCollection;
import com.atlassian.plugin.spring.scanner.annotation.export.ExportAsService;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.struts.TextProvider;
import com.octopus.constants.OctoConstants;
import com.octopus.services.impl.BaseConfigurator;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.Arrays;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Task configuration, where we save and validate the settings applied
* to the plugin.
*/
@Component
@ExportAsService(AbstractTaskConfigurator.class)
@Named("packTaskConfigurator")
public class PackTaskConfigurator extends BaseConfigurator {
@ComponentImport
private final TextProvider textProvider;
@Inject
public PackTaskConfigurator(@NotNull final TextProvider textProvider,
@NotNull final ApplicationContext applicationContext) {
super(applicationContext);
this.textProvider = checkNotNull(textProvider, "textProvider cannot be null");
}
@Override
public Map<String, String> generateTaskConfigMap(@NotNull final ActionParametersMap params,
@Nullable final TaskDefinition previousTaskDefinition) {
checkNotNull(params);
final Map<String, String> config = super.generateTaskConfigMap(params, previousTaskDefinition);
config.put(OctoConstants.PACK_BASE_PATH_NAME, params.getString(OctoConstants.PACK_BASE_PATH_NAME));
config.put(OctoConstants.PACK_FORMAT_NAME, params.getString(OctoConstants.PACK_FORMAT_NAME));
config.put(OctoConstants.PACK_ID_NAME, params.getString(OctoConstants.PACK_ID_NAME));
config.put(OctoConstants.PACK_VERSION_NAME, params.getString(OctoConstants.PACK_VERSION_NAME));
config.put(OctoConstants.PACK_INCLUDE_NAME, params.getString(OctoConstants.PACK_INCLUDE_NAME));
config.put(OctoConstants.PACK_OUT_FOLDER_NAME, params.getString(OctoConstants.PACK_OUT_FOLDER_NAME));
config.put(OctoConstants.PACK_OVERWRITE_NAME, params.getString(OctoConstants.PACK_OVERWRITE_NAME));
config.put(OctoConstants.VERBOSE_LOGGING, params.getString(OctoConstants.VERBOSE_LOGGING));
config.put(OctoConstants.ADDITIONAL_COMMAND_LINE_ARGS_NAME, params.getString(OctoConstants.ADDITIONAL_COMMAND_LINE_ARGS_NAME));
config.put(OctoConstants.OCTOPUS_CLI, params.getString(OctoConstants.OCTOPUS_CLI));
return config;
}
@Override
public void populateContextForCreate(@NotNull final Map<String, Object> context) {
context.put(OctoConstants.UI_CONFIG_BEAN, this.getUIConfigSupport());
context.put(OctoConstants.PACK_FORMAT_NAME, OctoConstants.PACK_ZIP_FORMAT);
context.put(OctoConstants.PACK_FORMATS_LIST, Arrays.asList(OctoConstants.PACK_ZIP_FORMAT, OctoConstants.PACK_NUGET_FORMAT));
}
@Override
public void populateContextForEdit(@NotNull final Map<String, Object> context,
@NotNull final TaskDefinition taskDefinition) {
checkNotNull(context);
checkNotNull(taskDefinition);
super.populateContextForEdit(context, taskDefinition);
context.put(OctoConstants.PACK_BASE_PATH_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_BASE_PATH_NAME));
context.put(OctoConstants.PACK_FORMAT_NAME, StringUtils.defaultIfBlank(
taskDefinition.getConfiguration().get(OctoConstants.PACK_FORMAT_NAME),
OctoConstants.PACK_ZIP_FORMAT));
context.put(OctoConstants.PACK_ID_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_ID_NAME));
context.put(OctoConstants.PACK_VERSION_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_VERSION_NAME));
context.put(OctoConstants.PACK_INCLUDE_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_INCLUDE_NAME));
context.put(OctoConstants.PACK_OUT_FOLDER_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_OUT_FOLDER_NAME));
context.put(OctoConstants.PACK_OVERWRITE_NAME, taskDefinition.getConfiguration().get(OctoConstants.PACK_OVERWRITE_NAME));
context.put(OctoConstants.VERBOSE_LOGGING, taskDefinition.getConfiguration().get(OctoConstants.VERBOSE_LOGGING));
context.put(OctoConstants.ADDITIONAL_COMMAND_LINE_ARGS_NAME, taskDefinition.getConfiguration().get(OctoConstants.ADDITIONAL_COMMAND_LINE_ARGS_NAME));
context.put(OctoConstants.OCTOPUS_CLI, taskDefinition.getConfiguration().get(OctoConstants.OCTOPUS_CLI));
context.put(OctoConstants.UI_CONFIG_BEAN, this.getUIConfigSupport());
context.put(OctoConstants.PACK_FORMATS_LIST, Arrays.asList(OctoConstants.PACK_ZIP_FORMAT, OctoConstants.PACK_NUGET_FORMAT));
}
@Override
public void validate(@NotNull final ActionParametersMap params,
@NotNull final ErrorCollection errorCollection) {
checkNotNull(params);
checkNotNull(errorCollection);
super.validate(params, errorCollection);
final String pushPattern = params.getString(OctoConstants.PACK_ID_NAME);
if (StringUtils.isEmpty(pushPattern)) {
errorCollection.addError(OctoConstants.PACK_ID_NAME, textProvider.getText(OctoConstants.PACK_ID_ERROR_KEY));
}
final String octopusCli = params.getString(OctoConstants.OCTOPUS_CLI);
if (StringUtils.isEmpty(octopusCli)) {
errorCollection.addError(OctoConstants.OCTOPUS_CLI, textProvider.getText(OctoConstants.OCTOPUS_CLI_ERROR_KEY));
}
final String packFormat = params.getString(OctoConstants.PACK_FORMAT_NAME);
if (StringUtils.isEmpty(packFormat)) {
errorCollection.addError(OctoConstants.PACK_FORMAT_NAME, textProvider.getText(OctoConstants.PACK_FORMAT_ERROR_KEY));
}
}
}
| 6,418 | 0.749766 | 0.749766 | 116 | 54.327587 | 43.411777 | 157 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.922414 | false | false | 9 |
ec2112c783c332adbbd37b4c592c29c2ec1a42f5 | 2,757,369,031,118 | b8c982b16fbf4ca5deaa4e12439294096d48b39b | /T2104E_Java1/src/Buoi4/TruongHoc.java | f629ee9780b182b628d48bb70f7f38052702a1f5 | [] | no_license | Tranthanhhai281/thanhhai | https://github.com/Tranthanhhai281/thanhhai | 6df9c92cee16683e0169e125c709dcf7d9ab8318 | 1b2c1f3afd94ae96cfb4c29e872825107ef692b6 | refs/heads/master | 2021-11-24T02:19:22.177000 | 2021-11-06T06:09:00 | 2021-11-06T06:09:00 | 198,537,367 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Buoi4;
import java.util.Scanner;
public class TruongHoc {
//b1: tao cac bien in
private String tenTruong;
private String diaChi;
private int namThanhLap;
private String trucThuoc;
private String heDaoTao;
//b2:
public TruongHoc() {
super();
}
public TruongHoc(String tenTruong, String diaChi, int namThanhLap, String trucThuoc, String heDaoTao) {
super();
this.tenTruong = tenTruong;
this.diaChi = diaChi;
this.namThanhLap = namThanhLap;
this.trucThuoc = trucThuoc;
this.heDaoTao = heDaoTao;
}
//b3:
public String getTenTruong() {
return tenTruong;
}
public void setTenTruong(String tenTruong) {
this.tenTruong = tenTruong;
}
public String getDiaChi() {
return diaChi;
}
public void setDiaChi(String diaChi) {
this.diaChi = diaChi;
}
public int getNamThanhLap() {
return namThanhLap;
}
public void setNamThanhLap(int namThanhLap) {
this.namThanhLap = namThanhLap;
}
public String getTrucThuoc() {
return trucThuoc;
}
public void setTrucThuoc(String trucThuoc) {
this.trucThuoc = trucThuoc;
}
public String getHeDaoTao() {
return heDaoTao;
}
public void setHeDaoTao(String heDaoTao) {
this.heDaoTao = heDaoTao;
}
//b4:
public void nhapTT(){
System.out.println("Nhap thong tin truong hoc: ");
Scanner sc = new Scanner(System.in);
System.out.println("Ten Truong: ");
this.tenTruong = sc.nextLine();
}
@Override
public String toString() {
return "TruongHoc{" +
"tenTruong='" + tenTruong + '\'' +
", diaChi='" + diaChi + '\'' +
", namThanhLap=" + namThanhLap +
", trucThuoc='" + trucThuoc + '\'' +
", heDaoTao='" + heDaoTao + '\'' +
'}';
}
}
| UTF-8 | Java | 1,985 | java | TruongHoc.java | Java | [] | null | [] | package Buoi4;
import java.util.Scanner;
public class TruongHoc {
//b1: tao cac bien in
private String tenTruong;
private String diaChi;
private int namThanhLap;
private String trucThuoc;
private String heDaoTao;
//b2:
public TruongHoc() {
super();
}
public TruongHoc(String tenTruong, String diaChi, int namThanhLap, String trucThuoc, String heDaoTao) {
super();
this.tenTruong = tenTruong;
this.diaChi = diaChi;
this.namThanhLap = namThanhLap;
this.trucThuoc = trucThuoc;
this.heDaoTao = heDaoTao;
}
//b3:
public String getTenTruong() {
return tenTruong;
}
public void setTenTruong(String tenTruong) {
this.tenTruong = tenTruong;
}
public String getDiaChi() {
return diaChi;
}
public void setDiaChi(String diaChi) {
this.diaChi = diaChi;
}
public int getNamThanhLap() {
return namThanhLap;
}
public void setNamThanhLap(int namThanhLap) {
this.namThanhLap = namThanhLap;
}
public String getTrucThuoc() {
return trucThuoc;
}
public void setTrucThuoc(String trucThuoc) {
this.trucThuoc = trucThuoc;
}
public String getHeDaoTao() {
return heDaoTao;
}
public void setHeDaoTao(String heDaoTao) {
this.heDaoTao = heDaoTao;
}
//b4:
public void nhapTT(){
System.out.println("Nhap thong tin truong hoc: ");
Scanner sc = new Scanner(System.in);
System.out.println("Ten Truong: ");
this.tenTruong = sc.nextLine();
}
@Override
public String toString() {
return "TruongHoc{" +
"tenTruong='" + tenTruong + '\'' +
", diaChi='" + diaChi + '\'' +
", namThanhLap=" + namThanhLap +
", trucThuoc='" + trucThuoc + '\'' +
", heDaoTao='" + heDaoTao + '\'' +
'}';
}
}
| 1,985 | 0.565743 | 0.563224 | 86 | 22.081396 | 19.306713 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.430233 | false | false | 9 |
877d9b504e4f2469744d537225a18bd46b197268 | 29,918,742,215,039 | 6c4022e183ae6adc5a593de49bf40a856200ebdd | /rpc-netty-protocal/src/main/java/ml/wpxm/java/rpc/netty/advance/protocol/NettyClient.java | 34346fe8b126a778240bb8f05585a6ab245a5ef2 | [] | no_license | waintang/rpc-netty-advance | https://github.com/waintang/rpc-netty-advance | f1994d02e7d630c04187424c3f5c5a503966272a | 00c7cdca22bcf3d42f2a799b54509129dcd2457a | refs/heads/main | 2023-08-14T11:18:44.675000 | 2021-09-21T13:32:34 | 2021-09-21T13:32:34 | 408,353,052 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ml.wpxm.java.rpc.netty.advance.protocol;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.extern.slf4j.Slf4j;
import ml.wpxm.java.rpc.netty.advance.core.RpcProtocol;
import ml.wpxm.java.rpc.netty.advance.core.RpcRequest;
import ml.wpxm.java.rpc.netty.advance.handler.RpcClientInitializer;
@Slf4j
public class NettyClient {
private final Bootstrap bootstrap;
private final EventLoopGroup eventLoopGroup= new NioEventLoopGroup();
private ChannelFuture channelFuture =null;
private String serverAddress;
private int serverPort;
public NettyClient(String serverAddress,int serverPort){
this.serverAddress = serverAddress;
this.serverPort = serverPort;
bootstrap = new Bootstrap();
bootstrap.group(eventLoopGroup)
.channel(NioSocketChannel.class)
.handler(new RpcClientInitializer());
}
public void sendRequest(RpcProtocol<RpcRequest> rpcProtocol) throws InterruptedException {
this.channelFuture = bootstrap.connect(this.serverAddress,this.serverPort).sync();
channelFuture.addListener(listener->{
if(channelFuture.isSuccess()){
log.info("connect rpc server {} sucess",this.serverAddress);
}else{
log.error("connect rpc server {} failed",this.serverAddress);
channelFuture.cause().printStackTrace();
eventLoopGroup.shutdownGracefully();
}
});
log.info("begin transfer data");
channelFuture.channel().writeAndFlush(rpcProtocol);
}
public void closeClient(){
if(this.channelFuture != null){
this.channelFuture.channel().closeFuture();
}
}
}
| UTF-8 | Java | 1,908 | java | NettyClient.java | Java | [] | null | [] | package ml.wpxm.java.rpc.netty.advance.protocol;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.extern.slf4j.Slf4j;
import ml.wpxm.java.rpc.netty.advance.core.RpcProtocol;
import ml.wpxm.java.rpc.netty.advance.core.RpcRequest;
import ml.wpxm.java.rpc.netty.advance.handler.RpcClientInitializer;
@Slf4j
public class NettyClient {
private final Bootstrap bootstrap;
private final EventLoopGroup eventLoopGroup= new NioEventLoopGroup();
private ChannelFuture channelFuture =null;
private String serverAddress;
private int serverPort;
public NettyClient(String serverAddress,int serverPort){
this.serverAddress = serverAddress;
this.serverPort = serverPort;
bootstrap = new Bootstrap();
bootstrap.group(eventLoopGroup)
.channel(NioSocketChannel.class)
.handler(new RpcClientInitializer());
}
public void sendRequest(RpcProtocol<RpcRequest> rpcProtocol) throws InterruptedException {
this.channelFuture = bootstrap.connect(this.serverAddress,this.serverPort).sync();
channelFuture.addListener(listener->{
if(channelFuture.isSuccess()){
log.info("connect rpc server {} sucess",this.serverAddress);
}else{
log.error("connect rpc server {} failed",this.serverAddress);
channelFuture.cause().printStackTrace();
eventLoopGroup.shutdownGracefully();
}
});
log.info("begin transfer data");
channelFuture.channel().writeAndFlush(rpcProtocol);
}
public void closeClient(){
if(this.channelFuture != null){
this.channelFuture.channel().closeFuture();
}
}
}
| 1,908 | 0.692872 | 0.6913 | 53 | 35 | 25.221285 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.603774 | false | false | 9 |
333248df4c945108d972ae415271a1493602e313 | 12,704,513,316,666 | 0dfd694d269eef76918f466ab7e75b932b2e8f8e | /foodie-dev-service/src/main/java/cn/lovingliu/service/impl/UserServiceImpl.java | 99ec36350e0b43adbb4509beba22020af9e042fe | [] | no_license | LovingLiuMeMe/foodie | https://github.com/LovingLiuMeMe/foodie | 3703bd6e07a5867be86a561b9f56c434b7b3b9b8 | 0404ec0603e2352865ea3ad286e5fcd6f94ce1bf | refs/heads/master | 2022-07-15T13:17:29.377000 | 2020-01-08T16:51:42 | 2020-01-08T16:51:42 | 230,721,890 | 0 | 0 | null | false | 2022-06-21T02:32:44 | 2019-12-29T08:10:27 | 2020-01-08T16:52:19 | 2022-06-21T02:32:42 | 64,205 | 0 | 0 | 1 | Java | false | false | package cn.lovingliu.service.impl;
import cn.lovingliu.pojo.bo.UserBO;
import cn.lovingliu.common.enums.Sex;
import cn.lovingliu.common.util.DateUtil;
import cn.lovingliu.common.util.MD5Util;
import cn.lovingliu.mapper.UsersMapper;
import cn.lovingliu.pojo.Users;
import cn.lovingliu.service.UserService;
import org.n3r.idworker.Sid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Service
public class UserServiceImpl implements UserService {
private static final String DEFAULT_USERS_FACE = "http://pic4.zhimg.com/50/v2-848b1a190d937e270e8d062d00865493_hd.jpg";
@Autowired
private UsersMapper usersMapper;
@Autowired
private Sid sid;
@Transactional(propagation = Propagation.SUPPORTS)
public boolean queryUsernameIsExist(String username){
Users users = usersMapper.selectByUsername(username);
return users != null;
}
@Transactional(propagation = Propagation.REQUIRED)
public Users createUser(UserBO userBO){
String usersId = sid.nextShort();
Users users = new Users();
users.setId(usersId);
users.setUsername(userBO.getUsername());
users.setPassword(MD5Util.MD5EncodeUtf8(userBO.getPassword()));
users.setNickname(userBO.getUsername());
users.setFace(DEFAULT_USERS_FACE);
users.setBirthday(DateUtil.getCurrentDateTime());
users.setSex(Sex.SECRET.type);
users.setCreatedTime(DateUtil.getCurrentDateTime());
users.setUpdatedTime(DateUtil.getCurrentDateTime());
usersMapper.insertSelective(users);
return users;
}
/**
* 检索用户名密码是否存在
* @param username
* @param password
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS)
public Users queryUserForLogin(String username,String password) {
return usersMapper.selectByUsernameAndPassword(username,MD5Util.MD5EncodeUtf8(password));
}
}
| UTF-8 | Java | 2,123 | java | UserServiceImpl.java | Java | [
{
"context": "(userBO.getUsername());\n users.setPassword(MD5Util.MD5EncodeUtf8(userBO.getPassword()));\n use",
"end": 1350,
"score": 0.7596736550331116,
"start": 1343,
"tag": "PASSWORD",
"value": "MD5Util"
},
{
"context": "getUsername());\n users.setPassword(MD5Util.MD5EncodeUtf8(userBO.getPassword()));\n users.setNickname",
"end": 1364,
"score": 0.7538460493087769,
"start": 1351,
"tag": "PASSWORD",
"value": "MD5EncodeUtf8"
}
] | null | [] | package cn.lovingliu.service.impl;
import cn.lovingliu.pojo.bo.UserBO;
import cn.lovingliu.common.enums.Sex;
import cn.lovingliu.common.util.DateUtil;
import cn.lovingliu.common.util.MD5Util;
import cn.lovingliu.mapper.UsersMapper;
import cn.lovingliu.pojo.Users;
import cn.lovingliu.service.UserService;
import org.n3r.idworker.Sid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Service
public class UserServiceImpl implements UserService {
private static final String DEFAULT_USERS_FACE = "http://pic4.zhimg.com/50/v2-848b1a190d937e270e8d062d00865493_hd.jpg";
@Autowired
private UsersMapper usersMapper;
@Autowired
private Sid sid;
@Transactional(propagation = Propagation.SUPPORTS)
public boolean queryUsernameIsExist(String username){
Users users = usersMapper.selectByUsername(username);
return users != null;
}
@Transactional(propagation = Propagation.REQUIRED)
public Users createUser(UserBO userBO){
String usersId = sid.nextShort();
Users users = new Users();
users.setId(usersId);
users.setUsername(userBO.getUsername());
users.setPassword(<PASSWORD>.<PASSWORD>(userBO.getPassword()));
users.setNickname(userBO.getUsername());
users.setFace(DEFAULT_USERS_FACE);
users.setBirthday(DateUtil.getCurrentDateTime());
users.setSex(Sex.SECRET.type);
users.setCreatedTime(DateUtil.getCurrentDateTime());
users.setUpdatedTime(DateUtil.getCurrentDateTime());
usersMapper.insertSelective(users);
return users;
}
/**
* 检索用户名密码是否存在
* @param username
* @param password
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS)
public Users queryUserForLogin(String username,String password) {
return usersMapper.selectByUsernameAndPassword(username,MD5Util.MD5EncodeUtf8(password));
}
}
| 2,123 | 0.737744 | 0.720133 | 58 | 35.224136 | 25.406382 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.586207 | false | false | 9 |
3de314fc7f32249be09eee97d6ab3bf0db39e459 | 17,179,935,307 | 8cf081c471719873e811676e1e9de1419e88b942 | /src/main/java/com/yggdrasilgaming/interview/shop/service/ProductService.java | ee5f0ca2689c46c8794ab163ade2c0f3d67cc066 | [] | no_license | Max-Levitskiy/com.yggdrasilgaming.interview.shop | https://github.com/Max-Levitskiy/com.yggdrasilgaming.interview.shop | 2ea800ea016307ec806c610c303992f14ad00b7b | 16bd78faab5ea3038e5cc0be0cf66fc4b42c55a6 | refs/heads/master | 2021-05-30T22:18:37.453000 | 2015-10-14T17:44:50 | 2015-10-14T17:44:50 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.yggdrasilgaming.interview.shop.service;
/**
* @author Maxim
* @date $ {DATE}.
*/
public class ProductService {
}
| UTF-8 | Java | 129 | java | ProductService.java | Java | [
{
"context": "asilgaming.interview.shop.service;\n\n/**\n * @author Maxim\n * @date $ {DATE}.\n */\npublic class ProductServic",
"end": 73,
"score": 0.9995741844177246,
"start": 68,
"tag": "NAME",
"value": "Maxim"
}
] | null | [] | package com.yggdrasilgaming.interview.shop.service;
/**
* @author Maxim
* @date $ {DATE}.
*/
public class ProductService {
}
| 129 | 0.689922 | 0.689922 | 8 | 15.125 | 16.62406 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.125 | false | false | 9 |
ac017c3a10b607c4c7101e245c7443a24abad503 | 19,335,942,826,497 | 97ffc2db9a9c85e5a3a935a0ef5b177471811506 | /CF4A/src/Main.java | 1be6e25f03a89fdddd1a1301ef1539391a15deea | [] | no_license | philiprodriguez/CodeforcesDump | https://github.com/philiprodriguez/CodeforcesDump | f29a848aaf52b1f0b3a3b8e7dc67cfd7caeac20f | 736eeedbba350ee81350f91d99fa82b2ac35e57e | refs/heads/master | 2016-09-17T09:04:27.191000 | 2016-08-08T17:00:18 | 2016-08-08T17:00:18 | 60,919,300 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner;
/*
PROBLEM:
A. Watermelon
time limit per test1 second
memory limit per test64 megabytes
inputstandard input
outputstandard output
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the
biggest and the ripest one, in their opinion. After that the watermelon was weighed, and
the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the
berry, however they faced a hard problem.
Pete and Billy are great fans of even numbers, that's why they want to divide the
watermelon in such a way that each of the two parts weighs even number of kilos, at the
same time it is not obligatory that the parts are equal. The boys are extremely tired
and want to start their meal as soon as possible, that's why you should help them and find
out, if they can divide the watermelon in the way they want. For sure, each of them should
get a part of positive weight.
Input
The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of
the watermelon bought by the boys.
Output
Print YES, if the boys can divide the watermelon into two parts, each of them weighing even
number of kilos; and NO in the opposite case.
*/
/**
* Created by Philip Rodriguez on 6/11/2016 at 4:10 PM.
*/
public class Main {
//Key insight: Since the definition of even is 2k for k in Z,
// it can be shown that any two even numbers added
// together yields an even number in all cases.
// Similarly, an even and odd summed yields an
// odd in all cases, and two odds summed togehter
// always yield an even.
//
// Thus, for all input over 2, the answer is only YES
// if the weight is even, since an odd weight means it
// is impossible to get two evens that sum to it.
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int input = scan.nextInt();
System.out.println((input%2 == 0 && input > 2) ? "YES" : "NO");
}
}
| UTF-8 | Java | 2,113 | java | Main.java | Java | [
{
"context": "ard input\noutputstandard output\nOne hot summer day Pete and his friend Billy decided to buy a watermelon.",
"end": 180,
"score": 0.9988220930099487,
"start": 176,
"tag": "NAME",
"value": "Pete"
},
{
"context": "dard output\nOne hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the\nbigge",
"end": 201,
"score": 0.9995388984680176,
"start": 196,
"tag": "NAME",
"value": "Billy"
},
{
"context": "de the\nberry, however they faced a hard problem.\n\nPete and Billy are great fans of even numbers, that's ",
"end": 470,
"score": 0.9830636978149414,
"start": 466,
"tag": "NAME",
"value": "Pete"
},
{
"context": "erry, however they faced a hard problem.\n\nPete and Billy are great fans of even numbers, that's why they w",
"end": 480,
"score": 0.9811673760414124,
"start": 475,
"tag": "NAME",
"value": "Billy"
},
{
"context": "nd NO in the opposite case.\n */\n\n/**\n * Created by Philip Rodriguez on 6/11/2016 at 4:10 PM.\n */\npublic class Main {\n",
"end": 1254,
"score": 0.9997949004173279,
"start": 1238,
"tag": "NAME",
"value": "Philip Rodriguez"
}
] | null | [] | import java.util.Scanner;
/*
PROBLEM:
A. Watermelon
time limit per test1 second
memory limit per test64 megabytes
inputstandard input
outputstandard output
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the
biggest and the ripest one, in their opinion. After that the watermelon was weighed, and
the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the
berry, however they faced a hard problem.
Pete and Billy are great fans of even numbers, that's why they want to divide the
watermelon in such a way that each of the two parts weighs even number of kilos, at the
same time it is not obligatory that the parts are equal. The boys are extremely tired
and want to start their meal as soon as possible, that's why you should help them and find
out, if they can divide the watermelon in the way they want. For sure, each of them should
get a part of positive weight.
Input
The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of
the watermelon bought by the boys.
Output
Print YES, if the boys can divide the watermelon into two parts, each of them weighing even
number of kilos; and NO in the opposite case.
*/
/**
* Created by <NAME> on 6/11/2016 at 4:10 PM.
*/
public class Main {
//Key insight: Since the definition of even is 2k for k in Z,
// it can be shown that any two even numbers added
// together yields an even number in all cases.
// Similarly, an even and odd summed yields an
// odd in all cases, and two odds summed togehter
// always yield an even.
//
// Thus, for all input over 2, the answer is only YES
// if the weight is even, since an odd weight means it
// is impossible to get two evens that sum to it.
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int input = scan.nextInt();
System.out.println((input%2 == 0 && input > 2) ? "YES" : "NO");
}
}
| 2,103 | 0.686517 | 0.676036 | 53 | 38.603775 | 32.865273 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.433962 | false | false | 9 |
c27f966f4300aa9550b6bb33dc1c04678bd58e7a | 32,212,254,770,309 | 89902669ca38ec2411f362c846c6a2be2f89412c | /course_android/LittleDemo/View/src/main/java/better/learn/view/custom/matrix/view/MatrixOperatingView.java | 33cc292782084fae14791bd2a08bdb4aaeddc58c | [] | no_license | 471448446/DAndroid | https://github.com/471448446/DAndroid | 23e31881db0ac0396cdde2714c60c67d4aa9593e | 20c557e5859a89979f8d841dabac84f22d20e0a7 | refs/heads/master | 2023-06-07T22:08:40.515000 | 2023-06-07T08:35:19 | 2023-06-07T08:35:19 | 65,447,030 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package better.learn.view.custom.matrix.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.os.Handler;
import android.os.Message;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import better.learn.view.R;
import better.learn.view.custom.ICustomView;
/**
* 基本的四个操作,以及对应的set、post、pre
* 除了translate之外,rotate,scale,skew都是相对坐标原点来操作的
* :
* 将图片居中
* 演示四个操作
* Created by better on 2017/9/28 11:16.
*/
public class MatrixOperatingView extends View implements ICustomView {
Bitmap mBitmap, mBitmapBg, mTestBitMap;
Matrix mMatrix = new Matrix();
Matrix mMatrixBg = new Matrix();
Paint mPaint = new Paint();
int currentTag = 0;
android.os.Handler mHandler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
currentTag++;
invalidate();
return false;
}
});
public MatrixOperatingView(Context context) {
super(context);
init();
}
public MatrixOperatingView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init();
}
public MatrixOperatingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mBitmap.recycle();
mBitmapBg.recycle();
mHandler.removeCallbacksAndMessages(null);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
currentTag = 0;
}
@Override
public void init() {
mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.explore_column_day);
mBitmapBg = BitmapFactory.decodeResource(getResources(), R.drawable.test_pic);
refresh();
}
private void refresh() {
mHandler.sendEmptyMessageDelayed(currentTag, 1000);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
canvas.clipRect(0, 0, getWidth(), getHeight() / 3);
canvas.drawBitmap(mBitmapBg, 0, 0, mPaint);
mMatrixBg.reset();
//因为本身图片就比当前画布大,所以这样按中心点缩放是放不到正中间的
mMatrixBg.postScale(0.3f, 0.3f, getWidth() / 2, getHeight() / 3 / 2);
canvas.drawBitmap(mBitmapBg, mMatrixBg, mPaint);
canvas.restore();
//按画布正中心缩放,此时图片刚刚好就是画布大小
canvas.save();
canvas.translate(0, getHeight() / 3 * 2);
if (null == mTestBitMap) {
mTestBitMap = Bitmap.createBitmap(mBitmapBg, 0, 0, getWidth(), getHeight() / 3);
}
canvas.drawBitmap(mTestBitMap, 0, 0, mPaint);
mMatrixBg.reset();
mMatrixBg.postScale(0.3f, 0.3f, getWidth() / 2, getHeight() / 3 / 2);
canvas.drawBitmap(mTestBitMap, mMatrixBg, mPaint);
canvas.restore();
// 看一下四个操作是怎么回事
if (currentTag == 0) return;
canvas.save();
canvas.translate(getWidth() / 2, getHeight() / 2);
canvas.drawLine(-getWidth() / 2, 0f, getWidth() / 2, 0f, mPaint);
canvas.drawLine(0, getHeight() / 6, 0, -getHeight() / 6, mPaint);
switch (currentTag) {
case 1:
translate(canvas);
refresh();
break;
case 2:
translate(canvas);
scale(canvas);
refresh();
break;
case 3:
translate(canvas);
scale(canvas);
rotate(canvas);
refresh();
break;
case 4:
translate(canvas);
scale(canvas);
rotate(canvas);
skew(canvas);
break;
}
canvas.restore();
}
private void skew(Canvas canvas) {
mMatrix.reset();
mMatrix.preSkew(0.5f, 0.5f);
canvas.drawBitmap(mBitmap, mMatrix, mPaint);
}
private void rotate(Canvas canvas) {
mMatrix.reset();
mMatrix.preRotate(120);
canvas.drawBitmap(mBitmap, mMatrix, mPaint);
}
private void scale(Canvas canvas) {
mMatrix.reset();
mMatrix.preScale(0.5f, 0.5f);
canvas.drawBitmap(mBitmap, mMatrix, mPaint);
}
private void translate(Canvas canvas) {
mMatrix.reset();
mMatrix.preTranslate(100, 100);
canvas.drawBitmap(mBitmap, mMatrix, mPaint);
}
}
| UTF-8 | Java | 4,975 | java | MatrixOperatingView.java | Java | [
{
"context": "都是相对坐标原点来操作的\n * :\n * 将图片居中\n * 演示四个操作\n * Created by better on 2017/9/28 11:16.\n */\n\npublic class MatrixOpera",
"end": 595,
"score": 0.9468838572502136,
"start": 589,
"tag": "USERNAME",
"value": "better"
}
] | null | [] | package better.learn.view.custom.matrix.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.os.Handler;
import android.os.Message;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import better.learn.view.R;
import better.learn.view.custom.ICustomView;
/**
* 基本的四个操作,以及对应的set、post、pre
* 除了translate之外,rotate,scale,skew都是相对坐标原点来操作的
* :
* 将图片居中
* 演示四个操作
* Created by better on 2017/9/28 11:16.
*/
public class MatrixOperatingView extends View implements ICustomView {
Bitmap mBitmap, mBitmapBg, mTestBitMap;
Matrix mMatrix = new Matrix();
Matrix mMatrixBg = new Matrix();
Paint mPaint = new Paint();
int currentTag = 0;
android.os.Handler mHandler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
currentTag++;
invalidate();
return false;
}
});
public MatrixOperatingView(Context context) {
super(context);
init();
}
public MatrixOperatingView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init();
}
public MatrixOperatingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mBitmap.recycle();
mBitmapBg.recycle();
mHandler.removeCallbacksAndMessages(null);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
currentTag = 0;
}
@Override
public void init() {
mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.explore_column_day);
mBitmapBg = BitmapFactory.decodeResource(getResources(), R.drawable.test_pic);
refresh();
}
private void refresh() {
mHandler.sendEmptyMessageDelayed(currentTag, 1000);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
canvas.clipRect(0, 0, getWidth(), getHeight() / 3);
canvas.drawBitmap(mBitmapBg, 0, 0, mPaint);
mMatrixBg.reset();
//因为本身图片就比当前画布大,所以这样按中心点缩放是放不到正中间的
mMatrixBg.postScale(0.3f, 0.3f, getWidth() / 2, getHeight() / 3 / 2);
canvas.drawBitmap(mBitmapBg, mMatrixBg, mPaint);
canvas.restore();
//按画布正中心缩放,此时图片刚刚好就是画布大小
canvas.save();
canvas.translate(0, getHeight() / 3 * 2);
if (null == mTestBitMap) {
mTestBitMap = Bitmap.createBitmap(mBitmapBg, 0, 0, getWidth(), getHeight() / 3);
}
canvas.drawBitmap(mTestBitMap, 0, 0, mPaint);
mMatrixBg.reset();
mMatrixBg.postScale(0.3f, 0.3f, getWidth() / 2, getHeight() / 3 / 2);
canvas.drawBitmap(mTestBitMap, mMatrixBg, mPaint);
canvas.restore();
// 看一下四个操作是怎么回事
if (currentTag == 0) return;
canvas.save();
canvas.translate(getWidth() / 2, getHeight() / 2);
canvas.drawLine(-getWidth() / 2, 0f, getWidth() / 2, 0f, mPaint);
canvas.drawLine(0, getHeight() / 6, 0, -getHeight() / 6, mPaint);
switch (currentTag) {
case 1:
translate(canvas);
refresh();
break;
case 2:
translate(canvas);
scale(canvas);
refresh();
break;
case 3:
translate(canvas);
scale(canvas);
rotate(canvas);
refresh();
break;
case 4:
translate(canvas);
scale(canvas);
rotate(canvas);
skew(canvas);
break;
}
canvas.restore();
}
private void skew(Canvas canvas) {
mMatrix.reset();
mMatrix.preSkew(0.5f, 0.5f);
canvas.drawBitmap(mBitmap, mMatrix, mPaint);
}
private void rotate(Canvas canvas) {
mMatrix.reset();
mMatrix.preRotate(120);
canvas.drawBitmap(mBitmap, mMatrix, mPaint);
}
private void scale(Canvas canvas) {
mMatrix.reset();
mMatrix.preScale(0.5f, 0.5f);
canvas.drawBitmap(mBitmap, mMatrix, mPaint);
}
private void translate(Canvas canvas) {
mMatrix.reset();
mMatrix.preTranslate(100, 100);
canvas.drawBitmap(mBitmap, mMatrix, mPaint);
}
}
| 4,975 | 0.594782 | 0.578792 | 162 | 28.339506 | 21.599373 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.932099 | false | false | 9 |
d9a1f8bdebb65bf4df33169b11e71c3f3d4b6421 | 13,520,557,091,133 | a63dca73432256f6f3c233dc44da37c67c4e678f | /AppNote/app/src/main/java/com/horical/appnote/LocalStorage/DAO/NoteReminderDAO.java | f6a4b2bf324fb626b96a63918284c2e9ad8d0a7d | [
"MIT"
] | permissive | eaglecs/Android | https://github.com/eaglecs/Android | 63f4c6a58fefc01a306ab4b0bfe695698e43c5c2 | c3d56d24da42db6373f805c9fa320cd459dce369 | refs/heads/master | 2020-04-02T06:09:39.415000 | 2018-07-07T15:42:47 | 2018-07-07T15:42:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.horical.appnote.LocalStorage.DAO;
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import com.horical.appnote.DTO.NoteDTO.NoteReminder;
import com.horical.appnote.LocalStorage.ApplicationSharedData;
import com.horical.appnote.LocalStorage.ApplicationStorage;
import java.util.ArrayList;
/**
* Created by Phuong on 26/08/2015.
*/
public class NoteReminderDAO extends BaseDAO {
private NoteReminder mNoteReminder;
public NoteReminderDAO(Activity activity) {
this.init(activity);
}
public NoteReminderDAO(Activity activity, NoteReminder noteReminder) {
this.init(activity);
this.mNoteReminder = noteReminder;
}
public boolean insertNoteReminder() {
String user_id = ApplicationSharedData.getUserID();
if (!getAllRemindersByTime(mNoteReminder.getTimeComplete()).isEmpty()) {
return false;
} else {
ContentValues contentValues = new ContentValues();
contentValues.put(ApplicationStorage.NoteReminderTable.TIME, mNoteReminder.getTimeComplete());
contentValues.put(ApplicationStorage.NoteReminderTable.CONTENT, mNoteReminder.getContent());
contentValues.put(ApplicationStorage.NoteReminderTable.NOTE_ID, mNoteReminder.getNoteId());
contentValues.put(ApplicationStorage.NoteReminderTable.USER_ID, user_id);
contentValues.put(ApplicationStorage.NoteReminderTable.REMIND_VOICE, mNoteReminder.getVoice());
contentValues.put(ApplicationStorage.NoteReminderTable.UPLOADED, "false");
Uri uriResult = this.mContentResolver.insert(ApplicationStorage.getUriNOTE_REMINDERS(), contentValues);
return uriResult != null;
}
}
public ArrayList<NoteReminder> getAllRemindersByTime(String dateSpecified) {
String[] user_id = new String[1];
user_id[0] = ApplicationSharedData.getUserID();
String uri = ApplicationStorage.getNoteRemindersUri();
if (dateSpecified != null && !dateSpecified.equals("")) {
uri = ApplicationStorage.getNoteRemindersUri() + "/reminder_time/" + dateSpecified;
}
ArrayList<NoteReminder> noteReminders = new ArrayList<>();
Cursor cursor = this.mContentResolver.query
(Uri.parse(uri), null, ApplicationStorage.NoteReminderTable.USER_ID + " = ?", user_id, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
NoteReminder noteReminder = new NoteReminder();
noteReminder.setReminderID(Integer.parseInt(cursor.getString(cursor.getColumnIndex(ApplicationStorage.NoteReminderTable.ID))));
noteReminder.setNoteId(Integer.parseInt(cursor.getString(cursor.getColumnIndex(ApplicationStorage.NoteReminderTable.NOTE_ID))));
noteReminder.setContent(cursor.getString(cursor.getColumnIndex(ApplicationStorage.NoteReminderTable.CONTENT)));
noteReminder.setTimeComplete(cursor.getString(cursor.getColumnIndex(ApplicationStorage.NoteReminderTable.TIME)));
noteReminder.setVoice(cursor.getString(cursor.getColumnIndex(ApplicationStorage.NoteReminderTable.REMIND_VOICE)));
noteReminders.add(noteReminder);
} while (cursor.moveToNext());
}
cursor.close();
}
return noteReminders;
}
public ArrayList<NoteReminder> getAllReminders() {
return this.getAllRemindersByTime(null);
}
public boolean deleteReminder(int id) {
String uri = ApplicationStorage.getNoteRemindersUri() + "/" + id;
int result = this.mContentResolver.delete(Uri.parse(uri), null, null);
return result > 0;
}
@Override
public void Send() {
}
@Override
public void Receive() {
}
@Override
public void Parse() {
}
}
| UTF-8 | Java | 3,984 | java | NoteReminderDAO.java | Java | [
{
"context": "e;\n\nimport java.util.ArrayList;\n\n/**\n * Created by Phuong on 26/08/2015.\n */\npublic class NoteReminderDAO e",
"end": 401,
"score": 0.8268716931343079,
"start": 395,
"tag": "USERNAME",
"value": "Phuong"
}
] | null | [] | package com.horical.appnote.LocalStorage.DAO;
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import com.horical.appnote.DTO.NoteDTO.NoteReminder;
import com.horical.appnote.LocalStorage.ApplicationSharedData;
import com.horical.appnote.LocalStorage.ApplicationStorage;
import java.util.ArrayList;
/**
* Created by Phuong on 26/08/2015.
*/
public class NoteReminderDAO extends BaseDAO {
private NoteReminder mNoteReminder;
public NoteReminderDAO(Activity activity) {
this.init(activity);
}
public NoteReminderDAO(Activity activity, NoteReminder noteReminder) {
this.init(activity);
this.mNoteReminder = noteReminder;
}
public boolean insertNoteReminder() {
String user_id = ApplicationSharedData.getUserID();
if (!getAllRemindersByTime(mNoteReminder.getTimeComplete()).isEmpty()) {
return false;
} else {
ContentValues contentValues = new ContentValues();
contentValues.put(ApplicationStorage.NoteReminderTable.TIME, mNoteReminder.getTimeComplete());
contentValues.put(ApplicationStorage.NoteReminderTable.CONTENT, mNoteReminder.getContent());
contentValues.put(ApplicationStorage.NoteReminderTable.NOTE_ID, mNoteReminder.getNoteId());
contentValues.put(ApplicationStorage.NoteReminderTable.USER_ID, user_id);
contentValues.put(ApplicationStorage.NoteReminderTable.REMIND_VOICE, mNoteReminder.getVoice());
contentValues.put(ApplicationStorage.NoteReminderTable.UPLOADED, "false");
Uri uriResult = this.mContentResolver.insert(ApplicationStorage.getUriNOTE_REMINDERS(), contentValues);
return uriResult != null;
}
}
public ArrayList<NoteReminder> getAllRemindersByTime(String dateSpecified) {
String[] user_id = new String[1];
user_id[0] = ApplicationSharedData.getUserID();
String uri = ApplicationStorage.getNoteRemindersUri();
if (dateSpecified != null && !dateSpecified.equals("")) {
uri = ApplicationStorage.getNoteRemindersUri() + "/reminder_time/" + dateSpecified;
}
ArrayList<NoteReminder> noteReminders = new ArrayList<>();
Cursor cursor = this.mContentResolver.query
(Uri.parse(uri), null, ApplicationStorage.NoteReminderTable.USER_ID + " = ?", user_id, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
NoteReminder noteReminder = new NoteReminder();
noteReminder.setReminderID(Integer.parseInt(cursor.getString(cursor.getColumnIndex(ApplicationStorage.NoteReminderTable.ID))));
noteReminder.setNoteId(Integer.parseInt(cursor.getString(cursor.getColumnIndex(ApplicationStorage.NoteReminderTable.NOTE_ID))));
noteReminder.setContent(cursor.getString(cursor.getColumnIndex(ApplicationStorage.NoteReminderTable.CONTENT)));
noteReminder.setTimeComplete(cursor.getString(cursor.getColumnIndex(ApplicationStorage.NoteReminderTable.TIME)));
noteReminder.setVoice(cursor.getString(cursor.getColumnIndex(ApplicationStorage.NoteReminderTable.REMIND_VOICE)));
noteReminders.add(noteReminder);
} while (cursor.moveToNext());
}
cursor.close();
}
return noteReminders;
}
public ArrayList<NoteReminder> getAllReminders() {
return this.getAllRemindersByTime(null);
}
public boolean deleteReminder(int id) {
String uri = ApplicationStorage.getNoteRemindersUri() + "/" + id;
int result = this.mContentResolver.delete(Uri.parse(uri), null, null);
return result > 0;
}
@Override
public void Send() {
}
@Override
public void Receive() {
}
@Override
public void Parse() {
}
}
| 3,984 | 0.681978 | 0.679217 | 100 | 38.84 | 38.77002 | 148 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.58 | false | false | 9 |
fdd6b6cb51a2d4dfcce57c226ae2377de67b5846 | 13,245,679,178,654 | 33ee587e7c70dad2478dcd0f9df0ac9250c33d35 | /app/src/main/java/cn/zcbdqn/commoninventory/activity/MainActivity.java | 76553ed095cc0c9222dabafd7ee87c527a341fb8 | [] | no_license | gumuyun/cn.zcbdqn.commoninventory1 | https://github.com/gumuyun/cn.zcbdqn.commoninventory1 | cab13f26fef8295278e3f7daed96040c4a8910c4 | f97084abeeb96b83809347c824f00716d1f66d26 | refs/heads/master | 2020-03-28T20:17:00.201000 | 2018-09-17T02:01:14 | 2018-09-17T02:01:14 | 149,055,196 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.zcbdqn.commoninventory.activity;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Window;
import android.widget.TextView;
import com.uhf.uhf.Common.Comm;
import com.uhf.uhf.UHF1.UHF1Function.SPconfig;
import cn.zcbdqn.commoninventory.R;
import cn.zcbdqn.commoninventory.constvalue.DrugSystemConst;
import cn.zcbdqn.commoninventory.context.MyApplication;
import cn.zcbdqn.commoninventory.db.RfidDataOpenHelper;
import cn.zcbdqn.commoninventory.entity.NetworkConfig;
import cn.zcbdqn.commoninventory.entity.RfidWarehouse;
import cn.zcbdqn.commoninventory.entity.User;
import cn.zcbdqn.commoninventory.utils.AlertUtil;
import cn.zcbdqn.commoninventory.utils.TextUtils;
public class MainActivity extends Activity {
private RfidDataOpenHelper rfidDataOpenHelper;
/**
* 显示版本
*/
private TextView tv_version;
/**
*
*/
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyApplication.getInstance().addActivity(this);
requestWindowFeature(Window.FEATURE_NO_TITLE); // 设置无标题
setContentView(R.layout.activity_main);
rfidDataOpenHelper=new RfidDataOpenHelper(this);
//获得显示版本的TextView
tv_version = (TextView) findViewById(R.id.tv_version);
sp = getSharedPreferences("InvenConfig", MODE_PRIVATE);
//获得包管理器,获得版本信息,设置信息
PackageManager manager = this.getPackageManager();
PackageInfo info;
try {
info = manager.getPackageInfo(this.getPackageName(), 0);
String version = info.versionName;
tv_version.setText(AlertUtil.getString(R.string.versionV) + version);
Log.e("gumy",AlertUtil.getString(R.string.versionV) + version);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
//如果非销邦设备,退出程序
/*if (!Build.MANUFACTURER.equals("SUPOIN")){
AlertUtil.showAlert(MainActivity.this,
"警告", "你的设备是"+Build.MANUFACTURER+",请选择销邦设备安装!",
"确定", new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertUtil.dismissDialog();
finish();
}
});
return;
}*/
//初始化系统配置......
//网络配置
NetworkConfig networkConfig = rfidDataOpenHelper.queryNetworkConfig();
if(networkConfig==null){
networkConfig=new NetworkConfig(null, "http://gumuyun.vicp.net", 51336, "/jeesite", "0", null, "", "");
}
MyApplication.applicationMap.put("networkConfig", networkConfig);
Log.e("gumy","networkConfig:"+networkConfig.toUrl());
//获得设置的黙认打印机
String defaultBluePrintAddress=sp.getString("defaultBluePrintAddress", null);
MyApplication.applicationMap.put("defaultBluePrintAddress", defaultBluePrintAddress);
Log.e("gumy","defaultBluePrintAddress:"+defaultBluePrintAddress);
//判断是否已登录
User user=new User("aaaa");
MyApplication.applicationMap.put("user", user);
Log.e("gumy","currentUser:"+user.getId());
//黙认货位
String warehouseId = sp.getString(DrugSystemConst.warehouseId, "1");
String warehouseName = sp.getString(DrugSystemConst.warehouseName, "黙认商档");
Log.e("gumy","warehouseId:"+warehouseId);
RfidWarehouse warehouse=new RfidWarehouse(warehouseId,warehouseName);
MyApplication.applicationMap.put("warehouse", warehouse);
//两秒后进入主菜单界面
openDateOrNextActivity();
}
@Override
protected void onDestroy() {
super.onDestroy();
// 结束Activity&从栈中移除该Activity
MyApplication.getInstance().finishActivity(this);
}
//两秒后进入主菜单界面
private void openDateOrNextActivity() {
new Handler().postDelayed(new Runnable() {
public void run() {
Intent intent = new Intent();
intent.setClass(MainActivity.this, MainMenuActivity.class);
startActivity(intent);
finish();
}
}, 5000);
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
}
@Override
protected void onResume() {
super.onResume();
initDevice();
}
public void release() {
try {
if (Comm.isrun){
Comm.stopScan();
}
//关闭rfid扫描电源
Comm.powerDown();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 初始化rfid扫描
*/
public void initDevice() {
Comm.repeatSound=true;
Comm.app = getApplication();
Comm.spConfig = new SPconfig(this);
Comm.context = this;
Comm.soundPool = new SoundPool(10, AudioManager.STREAM_SYSTEM, 5);
Comm.soundPool.load(this, R.raw.beep51, 1);
Comm.checkDevice();
Comm.initWireless(Comm.app);
Comm.connecthandler = connectH;
Comm.Connect();
Log.e("gumy", "connect");
}
public Handler connectH = new Handler() {
@Override
public void handleMessage(Message msg) {
try {
//cb_is6btag.setEnabled(false);
// UHF001.mhandler = uhfhandler;
// if (null != rfidOperate) {
// rfidOperate.mHandler = uhfhandler;
// cb_is6btag.setEnabled(true);
// }
// if (null != Comm.uhf6)
// Comm.uhf6.UHF6handler = uhfhandler;
//Comm.mInventoryHandler= uhfhandler;
Bundle bd = msg.getData();
String strMsg = bd.get("Msg").toString();
if (!TextUtils.isEmpty(strMsg)) {
//tv_state.setText(strMsg);
Comm.SetInventoryTid(false);
Log.e("gumy", strMsg);
} else{
//模块初始化失败
//tv_state.setText("模块初始化失败");
Log.e("gumy", strMsg);
}
} catch (Exception e) {
e.printStackTrace();
Log.e("gumy", e.getMessage());
}
}
};
}
| UTF-8 | Java | 6,137 | java | MainActivity.java | Java | [] | null | [] | package cn.zcbdqn.commoninventory.activity;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Window;
import android.widget.TextView;
import com.uhf.uhf.Common.Comm;
import com.uhf.uhf.UHF1.UHF1Function.SPconfig;
import cn.zcbdqn.commoninventory.R;
import cn.zcbdqn.commoninventory.constvalue.DrugSystemConst;
import cn.zcbdqn.commoninventory.context.MyApplication;
import cn.zcbdqn.commoninventory.db.RfidDataOpenHelper;
import cn.zcbdqn.commoninventory.entity.NetworkConfig;
import cn.zcbdqn.commoninventory.entity.RfidWarehouse;
import cn.zcbdqn.commoninventory.entity.User;
import cn.zcbdqn.commoninventory.utils.AlertUtil;
import cn.zcbdqn.commoninventory.utils.TextUtils;
public class MainActivity extends Activity {
private RfidDataOpenHelper rfidDataOpenHelper;
/**
* 显示版本
*/
private TextView tv_version;
/**
*
*/
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyApplication.getInstance().addActivity(this);
requestWindowFeature(Window.FEATURE_NO_TITLE); // 设置无标题
setContentView(R.layout.activity_main);
rfidDataOpenHelper=new RfidDataOpenHelper(this);
//获得显示版本的TextView
tv_version = (TextView) findViewById(R.id.tv_version);
sp = getSharedPreferences("InvenConfig", MODE_PRIVATE);
//获得包管理器,获得版本信息,设置信息
PackageManager manager = this.getPackageManager();
PackageInfo info;
try {
info = manager.getPackageInfo(this.getPackageName(), 0);
String version = info.versionName;
tv_version.setText(AlertUtil.getString(R.string.versionV) + version);
Log.e("gumy",AlertUtil.getString(R.string.versionV) + version);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
//如果非销邦设备,退出程序
/*if (!Build.MANUFACTURER.equals("SUPOIN")){
AlertUtil.showAlert(MainActivity.this,
"警告", "你的设备是"+Build.MANUFACTURER+",请选择销邦设备安装!",
"确定", new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertUtil.dismissDialog();
finish();
}
});
return;
}*/
//初始化系统配置......
//网络配置
NetworkConfig networkConfig = rfidDataOpenHelper.queryNetworkConfig();
if(networkConfig==null){
networkConfig=new NetworkConfig(null, "http://gumuyun.vicp.net", 51336, "/jeesite", "0", null, "", "");
}
MyApplication.applicationMap.put("networkConfig", networkConfig);
Log.e("gumy","networkConfig:"+networkConfig.toUrl());
//获得设置的黙认打印机
String defaultBluePrintAddress=sp.getString("defaultBluePrintAddress", null);
MyApplication.applicationMap.put("defaultBluePrintAddress", defaultBluePrintAddress);
Log.e("gumy","defaultBluePrintAddress:"+defaultBluePrintAddress);
//判断是否已登录
User user=new User("aaaa");
MyApplication.applicationMap.put("user", user);
Log.e("gumy","currentUser:"+user.getId());
//黙认货位
String warehouseId = sp.getString(DrugSystemConst.warehouseId, "1");
String warehouseName = sp.getString(DrugSystemConst.warehouseName, "黙认商档");
Log.e("gumy","warehouseId:"+warehouseId);
RfidWarehouse warehouse=new RfidWarehouse(warehouseId,warehouseName);
MyApplication.applicationMap.put("warehouse", warehouse);
//两秒后进入主菜单界面
openDateOrNextActivity();
}
@Override
protected void onDestroy() {
super.onDestroy();
// 结束Activity&从栈中移除该Activity
MyApplication.getInstance().finishActivity(this);
}
//两秒后进入主菜单界面
private void openDateOrNextActivity() {
new Handler().postDelayed(new Runnable() {
public void run() {
Intent intent = new Intent();
intent.setClass(MainActivity.this, MainMenuActivity.class);
startActivity(intent);
finish();
}
}, 5000);
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
}
@Override
protected void onResume() {
super.onResume();
initDevice();
}
public void release() {
try {
if (Comm.isrun){
Comm.stopScan();
}
//关闭rfid扫描电源
Comm.powerDown();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 初始化rfid扫描
*/
public void initDevice() {
Comm.repeatSound=true;
Comm.app = getApplication();
Comm.spConfig = new SPconfig(this);
Comm.context = this;
Comm.soundPool = new SoundPool(10, AudioManager.STREAM_SYSTEM, 5);
Comm.soundPool.load(this, R.raw.beep51, 1);
Comm.checkDevice();
Comm.initWireless(Comm.app);
Comm.connecthandler = connectH;
Comm.Connect();
Log.e("gumy", "connect");
}
public Handler connectH = new Handler() {
@Override
public void handleMessage(Message msg) {
try {
//cb_is6btag.setEnabled(false);
// UHF001.mhandler = uhfhandler;
// if (null != rfidOperate) {
// rfidOperate.mHandler = uhfhandler;
// cb_is6btag.setEnabled(true);
// }
// if (null != Comm.uhf6)
// Comm.uhf6.UHF6handler = uhfhandler;
//Comm.mInventoryHandler= uhfhandler;
Bundle bd = msg.getData();
String strMsg = bd.get("Msg").toString();
if (!TextUtils.isEmpty(strMsg)) {
//tv_state.setText(strMsg);
Comm.SetInventoryTid(false);
Log.e("gumy", strMsg);
} else{
//模块初始化失败
//tv_state.setText("模块初始化失败");
Log.e("gumy", strMsg);
}
} catch (Exception e) {
e.printStackTrace();
Log.e("gumy", e.getMessage());
}
}
};
}
| 6,137 | 0.688839 | 0.684039 | 208 | 27.04327 | 21.950842 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.240385 | false | false | 9 |
eb8f40093a11b0a2204754f40477b04f8824c764 | 3,874,060,510,166 | cac29c6cf17d6e755e8cc42467af97748c08e8c9 | /Java/LeetCode_57/src/wzm/Interval.java | 73ee0a56e418e82041979232001e2bf22bfeea86 | [] | no_license | mysticwzm/LeetCodeSolutions | https://github.com/mysticwzm/LeetCodeSolutions | 111bebe4f7b7cdb671180d17657ae29e715c5c5a | 033f072d9c3c93e27fd2d219cce4b280762232b5 | refs/heads/master | 2021-01-10T06:58:04.034000 | 2016-02-13T06:17:11 | 2016-02-13T06:17:11 | 46,115,026 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package wzm;
public class Interval implements Comparable<Interval> {
int start;
int end;
Interval() {
start = 0;
end = 0;
}
Interval(int s, int e) {
start = s;
end = e;
}
public int compareTo(Interval anotherInterval) {
if (this.start != anotherInterval.start) {
return this.start - anotherInterval.start;
}
return this.end - anotherInterval.end;
}
}
| UTF-8 | Java | 382 | java | Interval.java | Java | [] | null | [] | package wzm;
public class Interval implements Comparable<Interval> {
int start;
int end;
Interval() {
start = 0;
end = 0;
}
Interval(int s, int e) {
start = s;
end = e;
}
public int compareTo(Interval anotherInterval) {
if (this.start != anotherInterval.start) {
return this.start - anotherInterval.start;
}
return this.end - anotherInterval.end;
}
}
| 382 | 0.662304 | 0.657068 | 25 | 14.28 | 17.36553 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.4 | false | false | 9 |
66d75d321a4463539c143881fd55199247942dce | 30,262,339,625,940 | a95e84502633298b078e0de642d8457a63aba5ae | /BasicCalculator/src/edu/cmu/lloyddsilva/Calculator.java | 751b9988562355b6297df2530b125fe7898f4bb0 | [] | no_license | lloyddsilva/codingprep | https://github.com/lloyddsilva/codingprep | ecb08a18c071014aca6dea741b44633d17de6b19 | 6874379b09f80b0af4ae3496782e331b03f27e47 | refs/heads/master | 2020-04-18T12:11:29.013000 | 2015-08-12T00:09:29 | 2015-08-12T00:09:29 | 38,467,230 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package edu.cmu.lloyddsilva;
import java.util.ArrayList;
import java.util.Stack;
import java.util.StringTokenizer;
public class Calculator {
public static void main(String[] args) {
System.out.println(calculate("2-4-(8+2-6+(8+4-(1)+8-10))"));
System.out.println(calculate("(7)-(0)+(4)"));
System.out.println(calculate("1 + 1"));
System.out.println(calculate(" 2-1 + 2"));
System.out.println(calculate("2-(5-6)"));
System.out.println(calculate("(1+(4+5+2)-3)+(6+8)"));
System.out.println(calculate("10 + 11"));
System.out.println(calculate("2147483647"));
}
public static int calculate(String s) {
s = s.replaceAll(" ", "");
StringTokenizer st = new StringTokenizer(s, "+-()", true);
int total = 0;
Stack<String> stack = new Stack<String>();
while(st.hasMoreTokens()) {
String next = st.nextToken();
switch(next) {
case "(" : stack.push(next);
break;
case ")" :
ArrayList<String> t = new ArrayList<String>();
String item = stack.pop();
while(!stack.empty() && !item.equals("(")) {
t.add(0,item);
item = stack.pop();
}
stack.push("" + eval(t));
break;
case "+" : stack.push(next);
break;
case "-" : stack.push(next);
break;
default:
stack.push(next);
break;
}
}
//Final math should be left to right
ArrayList<String> t = new ArrayList<String>();
while (!stack.isEmpty()) {
String elem = stack.pop();
t.add(0, elem);
}
total = eval(t);
return total;
}
public static int eval(ArrayList<String> t) {
int temp = 0;
for (int i = t.size() - 1; i > 0; i = i - 2) {
if (t.get(i - 1).equals("-")) {
temp += 0 - Integer.valueOf(t.get(i));
} else {
temp += Integer.valueOf(t.get(i));
}
}
temp += Integer.valueOf(t.get(0));
return temp;
}
}
| UTF-8 | Java | 1,833 | java | Calculator.java | Java | [] | null | [] | package edu.cmu.lloyddsilva;
import java.util.ArrayList;
import java.util.Stack;
import java.util.StringTokenizer;
public class Calculator {
public static void main(String[] args) {
System.out.println(calculate("2-4-(8+2-6+(8+4-(1)+8-10))"));
System.out.println(calculate("(7)-(0)+(4)"));
System.out.println(calculate("1 + 1"));
System.out.println(calculate(" 2-1 + 2"));
System.out.println(calculate("2-(5-6)"));
System.out.println(calculate("(1+(4+5+2)-3)+(6+8)"));
System.out.println(calculate("10 + 11"));
System.out.println(calculate("2147483647"));
}
public static int calculate(String s) {
s = s.replaceAll(" ", "");
StringTokenizer st = new StringTokenizer(s, "+-()", true);
int total = 0;
Stack<String> stack = new Stack<String>();
while(st.hasMoreTokens()) {
String next = st.nextToken();
switch(next) {
case "(" : stack.push(next);
break;
case ")" :
ArrayList<String> t = new ArrayList<String>();
String item = stack.pop();
while(!stack.empty() && !item.equals("(")) {
t.add(0,item);
item = stack.pop();
}
stack.push("" + eval(t));
break;
case "+" : stack.push(next);
break;
case "-" : stack.push(next);
break;
default:
stack.push(next);
break;
}
}
//Final math should be left to right
ArrayList<String> t = new ArrayList<String>();
while (!stack.isEmpty()) {
String elem = stack.pop();
t.add(0, elem);
}
total = eval(t);
return total;
}
public static int eval(ArrayList<String> t) {
int temp = 0;
for (int i = t.size() - 1; i > 0; i = i - 2) {
if (t.get(i - 1).equals("-")) {
temp += 0 - Integer.valueOf(t.get(i));
} else {
temp += Integer.valueOf(t.get(i));
}
}
temp += Integer.valueOf(t.get(0));
return temp;
}
}
| 1,833 | 0.578287 | 0.549373 | 78 | 22.5 | 17.633556 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.076923 | false | false | 9 |
6e1956e7600b080f9ac67e2b7399da86eed80a1a | 22,780,506,553,031 | 7ba46bde7622a787efced5a8e473422a6640b327 | /gate_three/gate_three-core/src/main/java/com/econstruction/gate_three/common/model/CPSBean.java | 5502ba6d7afac3985fd4d13e532269db287f4c78 | [] | no_license | szhou2015/gatethree_trunk_test | https://github.com/szhou2015/gatethree_trunk_test | d736ef3683f3be3b09ae1def37bfc85a11738a83 | f802393c2a5ee79777ab76a3f5f28612c42e2304 | refs/heads/master | 2016-09-16T09:45:54.009000 | 2015-04-09T19:25:56 | 2015-04-09T19:25:56 | 33,679,651 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* EllisDon,
* Copyright 2008, EllisDon., and individual contributors as indicated
* by the @authors tag.
*
* This program is copyright protected and belongs to EllisDon. All rights are
* reserved.
*
* This software 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.
*/
package com.econstruction.gate_three.common.model;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import com.econstruction.gate_three.dto.CNFUserDTO;
import com.econstruction.gate_three.dto.CNFWorkflowStageDTO;
import com.econstruction.gate_three.dto.CPSPrequalSummaryDTO;
import com.econstruction.gate_three.dto.ContactDTO;
/**
* CPSBean Class
*/
public class CPSBean extends ListStatusBean {
private Integer iDCompany;
private String ratingExpiryDate;
private BigDecimal maxSingleContract;
private BigDecimal maxAggregateExposure;
private List prequalForm;
private List supportingDocument;
private BigDecimal aggregateContractValue;
private String workRegion;
private String bankName;
private String bondingCompany;
private String companyRating;
private List<ContactDTO> contactDTOCollection;
private HashMap revertNotificationMap;
private String dynamicPrequalURL;
private Integer primaryContactID;
private Integer secondaryContactID;
private List<ContactDTO> cpsPrimaryContact;
private List<ContactDTO> cpsSecondaryContact;
private String sentToEmailAddress;
private String sentComment;
private String cpsAction;
private Integer iDCPSRating;
private Boolean isEmailNotify;
private Integer emailContactID;
private CPSPrequalSummaryDTO cpsPrequalSummaryWIP;
private List<CPSPrequalSummaryDTO> prequalSummaryHistory;
private List<String> prequalSummaryLabels;
private List<Date> historicalPrequalSummaryDates;
private CNFWorkflowStageDTO fKCPSWorkflowStage;
private String workflowStageName;
private String method;
private String mode;
private int transactionID;
private List<FileUploadBean> prequalWIPAttachment;
private List prequalHistoryAttachment;
private UserInfo userInfo;
private Integer updatedBy;
private Date updatedDate;
private String cpsStatus;
private Date ratingExpiryPeriod;
private Integer cpsStatusID;
private Boolean notifyRatingFlag;
private String prequalURL;
/* [Start] GateThree-R1 - Fix for JIRA-CPS-157 */
private Boolean isDocumentAvailable;
private String evaluatedBy;
private String evaluatedDate;
private List<CNFUserDTO> ratingUserList;
public CPSBean(){
super();
}
public String getEvaluatedBy() {
return evaluatedBy;
}
public void setEvaluatedBy(String evaluatedBy) {
this.evaluatedBy = evaluatedBy;
}
public String getEvaluatedDate() {
return evaluatedDate;
}
public void setEvaluatedDate(String evaluatedDate) {
this.evaluatedDate = evaluatedDate;
}
public List<CNFUserDTO> getRatingUserList() {
return ratingUserList;
}
public void setRatingUserList(List<CNFUserDTO> ratingUserList) {
this.ratingUserList = ratingUserList;
}
/* [End] GateThree-R1 - Fix for JIRA-CPS-157 */
public UserInfo getUserInfoToChangeSure() {
return userInfo;
}
/**
*
* @return String
*/
public int getTransactionID() {
return transactionID;
}
/**
*
* @param transactionID
*/
public void setTransactionID(int transactionID) {
this.transactionID = transactionID;
}
/**
*
* @return Integer
*/
public Integer getEmailContactID() {
return emailContactID;
}
/**
*
* @param emailContactID
*/
public void setEmailContactID(Integer emailContactID) {
this.emailContactID = emailContactID;
}
/**
*
* @return Boolean
*/
public Boolean getIsEmailNotify() {
return isEmailNotify;
}
/**
*
* @param isEmailNotify
*/
public void setIsEmailNotify(Boolean isEmailNotify) {
this.isEmailNotify = isEmailNotify;
}
/**
*
* @return Integer
*/
public Integer getIDCPSRating() {
return iDCPSRating;
}
/**
*
* @param rating
*/
public void setIDCPSRating(Integer rating) {
iDCPSRating = rating;
}
/**
*
* @return Integer
*/
public Integer getPrimaryContactID() {
return primaryContactID;
}
/**
*
* @param primaryContactID
*/
public void setPrimaryContactID(Integer primaryContactID) {
this.primaryContactID = primaryContactID;
}
/**
*
* @return Integer
*/
public Integer getSecondaryContactID() {
return secondaryContactID;
}
/**
*
* @param secondaryContactID
*/
public void setSecondaryContactID(Integer secondaryContactID) {
this.secondaryContactID = secondaryContactID;
}
/**
*
* @return List
*/
public List<ContactDTO> getCpsPrimaryContact() {
return cpsPrimaryContact;
}
/**
*
* @param cpsPrimaryContact
*/
public void setCpsPrimaryContact(List<ContactDTO> cpsPrimaryContact) {
this.cpsPrimaryContact = cpsPrimaryContact;
}
/**
*
* @return List
*/
public List<ContactDTO> getCpsSecondaryContact() {
return cpsSecondaryContact;
}
/**
*
* @param cpsSecondaryContact
*/
public void setCpsSecondaryContact(List<ContactDTO> cpsSecondaryContact) {
this.cpsSecondaryContact = cpsSecondaryContact;
}
/**
*
* @return Integer
*/
public Integer getIDCompany() {
return iDCompany;
}
/**
*
* @param company
*/
public void setIDCompany(Integer company) {
iDCompany = company;
}
/**
*
* @return String
*/
public String getRatingExpiryDate() {
return ratingExpiryDate;
}
/**
*
* @param ratingExpiryDate
*/
public void setRatingExpiryDate(String ratingExpiryDate) {
this.ratingExpiryDate = ratingExpiryDate;
}
/**
*
* @return BigDecimal
*/
public BigDecimal getMaxSingleContract() {
return maxSingleContract;
}
/**
*
* @param maxSingleContract
*/
public void setMaxSingleContract(BigDecimal maxSingleContract) {
this.maxSingleContract = maxSingleContract;
}
/**
*
* @return BigDecimal
*/
public BigDecimal getMaxAggregateExposure() {
return maxAggregateExposure;
}
/**
*
* @param maxAggregateExposure
*/
public void setMaxAggregateExposure(BigDecimal maxAggregateExposure) {
this.maxAggregateExposure = maxAggregateExposure;
}
/**
*
* @return List
*/
public List getPrequalForm() {
return prequalForm;
}
/**
*
* @param prequalForm
*/
public void setPrequalForm(List prequalForm) {
this.prequalForm = prequalForm;
}
/**
*
* @return List
*/
public List getSupportingDocument() {
return supportingDocument;
}
/**
*
* @param supportingDocument
*/
public void setSupportingDocument(List supportingDocument) {
this.supportingDocument = supportingDocument;
}
/**
*
* @return BigDecimal
*/
public BigDecimal getAggregateContractValue() {
return aggregateContractValue;
}
/**
*
* @param aggregateContractValue
*/
public void setAggregateContractValue(BigDecimal aggregateContractValue) {
this.aggregateContractValue = aggregateContractValue;
}
/**
*
* @return String
*/
public String getWorkRegion() {
return workRegion;
}
/**
*
* @param workRegion
*/
public void setWorkRegion(String workRegion) {
this.workRegion = workRegion;
}
/**
*
* @return String
*/
public String getBankName() {
return bankName;
}
/**
*
* @param bankName
*/
public void setBankName(String bankName) {
this.bankName = bankName;
}
/**
*
* @return String
*/
public String getBondingCompany() {
return bondingCompany;
}
/**
*
* @param bondingCompany
*/
public void setBondingCompany(String bondingCompany) {
this.bondingCompany = bondingCompany;
}
/**
*
* @return String
*/
public String getCompanyRating() {
return companyRating;
}
/**
*
* @param companyRating
*/
public void setCompanyRating(String companyRating) {
this.companyRating = companyRating;
}
/**
*
* @return List
*/
public List<ContactDTO> getContactDTOCollection() {
return contactDTOCollection;
}
/**
*
* @param contactDTOCollection
*/
public void setContactDTOCollection(List<ContactDTO> contactDTOCollection) {
this.contactDTOCollection = contactDTOCollection;
}
/**
*
* @return String
*/
public String getSentToEmailAddress() {
return sentToEmailAddress;
}
/**
*
* @param sentToEmailAddress
*/
public void setSentToEmailAddress(String sentToEmailAddress) {
this.sentToEmailAddress = sentToEmailAddress;
}
/**
*
* @return String
*/
public String getSentComment() {
return sentComment;
}
/**
*
* @param sentComment
*/
public void setSentComment(String sentComment) {
this.sentComment = sentComment;
}
/**
*
* @return String
*/
public String getCpsAction() {
return cpsAction;
}
/**
*
* @param cpsAction
*/
public void setCpsAction(String cpsAction) {
this.cpsAction = cpsAction;
}
/**
*
* @return CPSPrequalSummaryDTO
*/
public CPSPrequalSummaryDTO getCpsPrequalSummaryWIP() {
return cpsPrequalSummaryWIP;
}
/**
*
* @param cpsPrequalSummaryWIP
*/
public void setCpsPrequalSummaryWIP(CPSPrequalSummaryDTO cpsPrequalSummaryWIP) {
this.cpsPrequalSummaryWIP = cpsPrequalSummaryWIP;
}
/**
*
* @return List
*/
public List<CPSPrequalSummaryDTO> getPrequalSummaryHistory() {
return prequalSummaryHistory;
}
/**
*
* @param prequalSummaryHistory
*/
public void setPrequalSummaryHistory(List<CPSPrequalSummaryDTO> prequalSummaryHistory) {
this.prequalSummaryHistory = prequalSummaryHistory;
}
/**
*
* @return List
*/
public List<String> getPrequalSummaryLabels() {
return prequalSummaryLabels;
}
/**
*
* @param prequalSummaryLabels
*/
public void setPrequalSummaryLabels(List<String> prequalSummaryLabels) {
this.prequalSummaryLabels = prequalSummaryLabels;
}
/**
*
* @return List
*/
public List<Date> getHistoricalPrequalSummaryDates() {
return historicalPrequalSummaryDates;
}
/**
*
* @param historicalPrequalSummaryDates
*/
public void setHistoricalPrequalSummaryDates(List<Date> historicalPrequalSummaryDates) {
this.historicalPrequalSummaryDates = historicalPrequalSummaryDates;
}
/**
*
* @return Integer
*/
public CNFWorkflowStageDTO getFKCPSWorkflowStage() {
return fKCPSWorkflowStage;
}
/**
*
* @param workflowStage
*/
public void setFKCPSWorkflowStage(CNFWorkflowStageDTO workflowStage) {
fKCPSWorkflowStage = workflowStage;
}
/**
*
* @return List
*/
public void setMethod(String method) {
this.method = method;
}
public String getMethod() {
return method;
}
/**
*
* @param mode
*/
public void setMode(String mode) {
this.mode = mode;
}
/**
*
* @return String
*/
public String getMode() {
return mode;
}
public List<FileUploadBean> getPrequalWIPAttachment() {
return prequalWIPAttachment;
}
/**
*
* @param prequalWIPAttachment
*/
public void setPrequalWIPAttachment(List<FileUploadBean> prequalWIPAttachment) {
this.prequalWIPAttachment = prequalWIPAttachment;
}
/**
*
* @return List
*/
public List getPrequalHistoryAttachment() {
return prequalHistoryAttachment;
}
/**
*
* @param prequalHistoryAttachment
*/
public void setPrequalHistoryAttachment(List prequalHistoryAttachment) {
this.prequalHistoryAttachment = prequalHistoryAttachment;
}
/**
*
* @return Integer
*/
public Integer getUpdatedBy() {
return updatedBy;
}
/**
*
* @return Date
*/
public Date getUpdatedDate() {
return updatedDate;
}
/**
*
* @return HashMap
*/
public HashMap getRevertNotificationMap() {
return revertNotificationMap;
}
/**
*
* @param revertNotificationMap
*/
public void setRevertNotificationMap(HashMap revertNotificationMap) {
this.revertNotificationMap = revertNotificationMap;
}
/**
* @return String
*/
public String getCpsStatus() {
return cpsStatus;
}
/**
*
* @param cpsStatus
*/
public void setCpsStatus(String cpsStatus) {
this.cpsStatus = cpsStatus;
}
/**
*
* @return Date
*/
public Date getRatingExpiryPeriod() {
return ratingExpiryPeriod;
}
/**
*
* @param ratingExpiryPeriod
*/
public void setRatingExpiryPeriod(Date ratingExpiryPeriod) {
this.ratingExpiryPeriod = ratingExpiryPeriod;
}
/**
* @param dynamicPrequalURL
* the dynamicPrequalURL to set
*/
public void setDynamicPrequalURL(String dynamicPrequalURL) {
this.dynamicPrequalURL = dynamicPrequalURL;
}
/**
* @return the dynamicPrequalURL
*/
public String getDynamicPrequalURL() {
return dynamicPrequalURL;
}
/**
*
* @return Integer
*/
public Integer getCpsStatusID() {
return cpsStatusID;
}
/**
*
* @param cpsStatusID
*/
public void setCpsStatusID(Integer cpsStatusID) {
this.cpsStatusID = cpsStatusID;
}
/**
*
* @return Boolean
*/
public Boolean getNotifyRatingFlag() {
return notifyRatingFlag;
}
/**
*
* @param notifyRatingFlag
*/
public void setNotifyRatingFlag(Boolean notifyRatingFlag) {
this.notifyRatingFlag = notifyRatingFlag;
}
/* [Start] GateThree-R1 - Fix for JIRA-CPS-157 */
public void setIsDocumentAvailable(Boolean isDocumentAvailable) {
this.isDocumentAvailable = isDocumentAvailable;
}
/**
*
* @return Boolean
*/
public Boolean getIsDocumentAvailable() {
return isDocumentAvailable;
}
/* [End] GateThree-R1 - Fix for JIRA-CPS-157 */
public String getWorkflowStageName() {
return workflowStageName;
}
/**
*
* @param workflowStageName
*/
public void setWorkflowStageName(String workflowStageName) {
this.workflowStageName = workflowStageName;
}
/**
*
* @return String
*/
public String getPrequalURL() {
return prequalURL;
}
/**
*
* @param prequalURL
*/
public void setPrequalURL(String prequalURL) {
this.prequalURL = prequalURL;
}
} | UTF-8 | Java | 13,861 | java | CPSBean.java | Java | [
{
"context": "/**\n * EllisDon,\n * Copyright 2008, EllisDon., and individual con",
"end": 15,
"score": 0.9482253789901733,
"start": 7,
"tag": "NAME",
"value": "EllisDon"
},
{
"context": "/**\n * EllisDon,\n * Copyright 2008, EllisDon., and individual contributors as indicated\n * by th",
"end": 44,
"score": 0.8770227432250977,
"start": 36,
"tag": "NAME",
"value": "EllisDon"
}
] | null | [] | /**
* EllisDon,
* Copyright 2008, EllisDon., and individual contributors as indicated
* by the @authors tag.
*
* This program is copyright protected and belongs to EllisDon. All rights are
* reserved.
*
* This software 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.
*/
package com.econstruction.gate_three.common.model;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import com.econstruction.gate_three.dto.CNFUserDTO;
import com.econstruction.gate_three.dto.CNFWorkflowStageDTO;
import com.econstruction.gate_three.dto.CPSPrequalSummaryDTO;
import com.econstruction.gate_three.dto.ContactDTO;
/**
* CPSBean Class
*/
public class CPSBean extends ListStatusBean {
private Integer iDCompany;
private String ratingExpiryDate;
private BigDecimal maxSingleContract;
private BigDecimal maxAggregateExposure;
private List prequalForm;
private List supportingDocument;
private BigDecimal aggregateContractValue;
private String workRegion;
private String bankName;
private String bondingCompany;
private String companyRating;
private List<ContactDTO> contactDTOCollection;
private HashMap revertNotificationMap;
private String dynamicPrequalURL;
private Integer primaryContactID;
private Integer secondaryContactID;
private List<ContactDTO> cpsPrimaryContact;
private List<ContactDTO> cpsSecondaryContact;
private String sentToEmailAddress;
private String sentComment;
private String cpsAction;
private Integer iDCPSRating;
private Boolean isEmailNotify;
private Integer emailContactID;
private CPSPrequalSummaryDTO cpsPrequalSummaryWIP;
private List<CPSPrequalSummaryDTO> prequalSummaryHistory;
private List<String> prequalSummaryLabels;
private List<Date> historicalPrequalSummaryDates;
private CNFWorkflowStageDTO fKCPSWorkflowStage;
private String workflowStageName;
private String method;
private String mode;
private int transactionID;
private List<FileUploadBean> prequalWIPAttachment;
private List prequalHistoryAttachment;
private UserInfo userInfo;
private Integer updatedBy;
private Date updatedDate;
private String cpsStatus;
private Date ratingExpiryPeriod;
private Integer cpsStatusID;
private Boolean notifyRatingFlag;
private String prequalURL;
/* [Start] GateThree-R1 - Fix for JIRA-CPS-157 */
private Boolean isDocumentAvailable;
private String evaluatedBy;
private String evaluatedDate;
private List<CNFUserDTO> ratingUserList;
public CPSBean(){
super();
}
public String getEvaluatedBy() {
return evaluatedBy;
}
public void setEvaluatedBy(String evaluatedBy) {
this.evaluatedBy = evaluatedBy;
}
public String getEvaluatedDate() {
return evaluatedDate;
}
public void setEvaluatedDate(String evaluatedDate) {
this.evaluatedDate = evaluatedDate;
}
public List<CNFUserDTO> getRatingUserList() {
return ratingUserList;
}
public void setRatingUserList(List<CNFUserDTO> ratingUserList) {
this.ratingUserList = ratingUserList;
}
/* [End] GateThree-R1 - Fix for JIRA-CPS-157 */
public UserInfo getUserInfoToChangeSure() {
return userInfo;
}
/**
*
* @return String
*/
public int getTransactionID() {
return transactionID;
}
/**
*
* @param transactionID
*/
public void setTransactionID(int transactionID) {
this.transactionID = transactionID;
}
/**
*
* @return Integer
*/
public Integer getEmailContactID() {
return emailContactID;
}
/**
*
* @param emailContactID
*/
public void setEmailContactID(Integer emailContactID) {
this.emailContactID = emailContactID;
}
/**
*
* @return Boolean
*/
public Boolean getIsEmailNotify() {
return isEmailNotify;
}
/**
*
* @param isEmailNotify
*/
public void setIsEmailNotify(Boolean isEmailNotify) {
this.isEmailNotify = isEmailNotify;
}
/**
*
* @return Integer
*/
public Integer getIDCPSRating() {
return iDCPSRating;
}
/**
*
* @param rating
*/
public void setIDCPSRating(Integer rating) {
iDCPSRating = rating;
}
/**
*
* @return Integer
*/
public Integer getPrimaryContactID() {
return primaryContactID;
}
/**
*
* @param primaryContactID
*/
public void setPrimaryContactID(Integer primaryContactID) {
this.primaryContactID = primaryContactID;
}
/**
*
* @return Integer
*/
public Integer getSecondaryContactID() {
return secondaryContactID;
}
/**
*
* @param secondaryContactID
*/
public void setSecondaryContactID(Integer secondaryContactID) {
this.secondaryContactID = secondaryContactID;
}
/**
*
* @return List
*/
public List<ContactDTO> getCpsPrimaryContact() {
return cpsPrimaryContact;
}
/**
*
* @param cpsPrimaryContact
*/
public void setCpsPrimaryContact(List<ContactDTO> cpsPrimaryContact) {
this.cpsPrimaryContact = cpsPrimaryContact;
}
/**
*
* @return List
*/
public List<ContactDTO> getCpsSecondaryContact() {
return cpsSecondaryContact;
}
/**
*
* @param cpsSecondaryContact
*/
public void setCpsSecondaryContact(List<ContactDTO> cpsSecondaryContact) {
this.cpsSecondaryContact = cpsSecondaryContact;
}
/**
*
* @return Integer
*/
public Integer getIDCompany() {
return iDCompany;
}
/**
*
* @param company
*/
public void setIDCompany(Integer company) {
iDCompany = company;
}
/**
*
* @return String
*/
public String getRatingExpiryDate() {
return ratingExpiryDate;
}
/**
*
* @param ratingExpiryDate
*/
public void setRatingExpiryDate(String ratingExpiryDate) {
this.ratingExpiryDate = ratingExpiryDate;
}
/**
*
* @return BigDecimal
*/
public BigDecimal getMaxSingleContract() {
return maxSingleContract;
}
/**
*
* @param maxSingleContract
*/
public void setMaxSingleContract(BigDecimal maxSingleContract) {
this.maxSingleContract = maxSingleContract;
}
/**
*
* @return BigDecimal
*/
public BigDecimal getMaxAggregateExposure() {
return maxAggregateExposure;
}
/**
*
* @param maxAggregateExposure
*/
public void setMaxAggregateExposure(BigDecimal maxAggregateExposure) {
this.maxAggregateExposure = maxAggregateExposure;
}
/**
*
* @return List
*/
public List getPrequalForm() {
return prequalForm;
}
/**
*
* @param prequalForm
*/
public void setPrequalForm(List prequalForm) {
this.prequalForm = prequalForm;
}
/**
*
* @return List
*/
public List getSupportingDocument() {
return supportingDocument;
}
/**
*
* @param supportingDocument
*/
public void setSupportingDocument(List supportingDocument) {
this.supportingDocument = supportingDocument;
}
/**
*
* @return BigDecimal
*/
public BigDecimal getAggregateContractValue() {
return aggregateContractValue;
}
/**
*
* @param aggregateContractValue
*/
public void setAggregateContractValue(BigDecimal aggregateContractValue) {
this.aggregateContractValue = aggregateContractValue;
}
/**
*
* @return String
*/
public String getWorkRegion() {
return workRegion;
}
/**
*
* @param workRegion
*/
public void setWorkRegion(String workRegion) {
this.workRegion = workRegion;
}
/**
*
* @return String
*/
public String getBankName() {
return bankName;
}
/**
*
* @param bankName
*/
public void setBankName(String bankName) {
this.bankName = bankName;
}
/**
*
* @return String
*/
public String getBondingCompany() {
return bondingCompany;
}
/**
*
* @param bondingCompany
*/
public void setBondingCompany(String bondingCompany) {
this.bondingCompany = bondingCompany;
}
/**
*
* @return String
*/
public String getCompanyRating() {
return companyRating;
}
/**
*
* @param companyRating
*/
public void setCompanyRating(String companyRating) {
this.companyRating = companyRating;
}
/**
*
* @return List
*/
public List<ContactDTO> getContactDTOCollection() {
return contactDTOCollection;
}
/**
*
* @param contactDTOCollection
*/
public void setContactDTOCollection(List<ContactDTO> contactDTOCollection) {
this.contactDTOCollection = contactDTOCollection;
}
/**
*
* @return String
*/
public String getSentToEmailAddress() {
return sentToEmailAddress;
}
/**
*
* @param sentToEmailAddress
*/
public void setSentToEmailAddress(String sentToEmailAddress) {
this.sentToEmailAddress = sentToEmailAddress;
}
/**
*
* @return String
*/
public String getSentComment() {
return sentComment;
}
/**
*
* @param sentComment
*/
public void setSentComment(String sentComment) {
this.sentComment = sentComment;
}
/**
*
* @return String
*/
public String getCpsAction() {
return cpsAction;
}
/**
*
* @param cpsAction
*/
public void setCpsAction(String cpsAction) {
this.cpsAction = cpsAction;
}
/**
*
* @return CPSPrequalSummaryDTO
*/
public CPSPrequalSummaryDTO getCpsPrequalSummaryWIP() {
return cpsPrequalSummaryWIP;
}
/**
*
* @param cpsPrequalSummaryWIP
*/
public void setCpsPrequalSummaryWIP(CPSPrequalSummaryDTO cpsPrequalSummaryWIP) {
this.cpsPrequalSummaryWIP = cpsPrequalSummaryWIP;
}
/**
*
* @return List
*/
public List<CPSPrequalSummaryDTO> getPrequalSummaryHistory() {
return prequalSummaryHistory;
}
/**
*
* @param prequalSummaryHistory
*/
public void setPrequalSummaryHistory(List<CPSPrequalSummaryDTO> prequalSummaryHistory) {
this.prequalSummaryHistory = prequalSummaryHistory;
}
/**
*
* @return List
*/
public List<String> getPrequalSummaryLabels() {
return prequalSummaryLabels;
}
/**
*
* @param prequalSummaryLabels
*/
public void setPrequalSummaryLabels(List<String> prequalSummaryLabels) {
this.prequalSummaryLabels = prequalSummaryLabels;
}
/**
*
* @return List
*/
public List<Date> getHistoricalPrequalSummaryDates() {
return historicalPrequalSummaryDates;
}
/**
*
* @param historicalPrequalSummaryDates
*/
public void setHistoricalPrequalSummaryDates(List<Date> historicalPrequalSummaryDates) {
this.historicalPrequalSummaryDates = historicalPrequalSummaryDates;
}
/**
*
* @return Integer
*/
public CNFWorkflowStageDTO getFKCPSWorkflowStage() {
return fKCPSWorkflowStage;
}
/**
*
* @param workflowStage
*/
public void setFKCPSWorkflowStage(CNFWorkflowStageDTO workflowStage) {
fKCPSWorkflowStage = workflowStage;
}
/**
*
* @return List
*/
public void setMethod(String method) {
this.method = method;
}
public String getMethod() {
return method;
}
/**
*
* @param mode
*/
public void setMode(String mode) {
this.mode = mode;
}
/**
*
* @return String
*/
public String getMode() {
return mode;
}
public List<FileUploadBean> getPrequalWIPAttachment() {
return prequalWIPAttachment;
}
/**
*
* @param prequalWIPAttachment
*/
public void setPrequalWIPAttachment(List<FileUploadBean> prequalWIPAttachment) {
this.prequalWIPAttachment = prequalWIPAttachment;
}
/**
*
* @return List
*/
public List getPrequalHistoryAttachment() {
return prequalHistoryAttachment;
}
/**
*
* @param prequalHistoryAttachment
*/
public void setPrequalHistoryAttachment(List prequalHistoryAttachment) {
this.prequalHistoryAttachment = prequalHistoryAttachment;
}
/**
*
* @return Integer
*/
public Integer getUpdatedBy() {
return updatedBy;
}
/**
*
* @return Date
*/
public Date getUpdatedDate() {
return updatedDate;
}
/**
*
* @return HashMap
*/
public HashMap getRevertNotificationMap() {
return revertNotificationMap;
}
/**
*
* @param revertNotificationMap
*/
public void setRevertNotificationMap(HashMap revertNotificationMap) {
this.revertNotificationMap = revertNotificationMap;
}
/**
* @return String
*/
public String getCpsStatus() {
return cpsStatus;
}
/**
*
* @param cpsStatus
*/
public void setCpsStatus(String cpsStatus) {
this.cpsStatus = cpsStatus;
}
/**
*
* @return Date
*/
public Date getRatingExpiryPeriod() {
return ratingExpiryPeriod;
}
/**
*
* @param ratingExpiryPeriod
*/
public void setRatingExpiryPeriod(Date ratingExpiryPeriod) {
this.ratingExpiryPeriod = ratingExpiryPeriod;
}
/**
* @param dynamicPrequalURL
* the dynamicPrequalURL to set
*/
public void setDynamicPrequalURL(String dynamicPrequalURL) {
this.dynamicPrequalURL = dynamicPrequalURL;
}
/**
* @return the dynamicPrequalURL
*/
public String getDynamicPrequalURL() {
return dynamicPrequalURL;
}
/**
*
* @return Integer
*/
public Integer getCpsStatusID() {
return cpsStatusID;
}
/**
*
* @param cpsStatusID
*/
public void setCpsStatusID(Integer cpsStatusID) {
this.cpsStatusID = cpsStatusID;
}
/**
*
* @return Boolean
*/
public Boolean getNotifyRatingFlag() {
return notifyRatingFlag;
}
/**
*
* @param notifyRatingFlag
*/
public void setNotifyRatingFlag(Boolean notifyRatingFlag) {
this.notifyRatingFlag = notifyRatingFlag;
}
/* [Start] GateThree-R1 - Fix for JIRA-CPS-157 */
public void setIsDocumentAvailable(Boolean isDocumentAvailable) {
this.isDocumentAvailable = isDocumentAvailable;
}
/**
*
* @return Boolean
*/
public Boolean getIsDocumentAvailable() {
return isDocumentAvailable;
}
/* [End] GateThree-R1 - Fix for JIRA-CPS-157 */
public String getWorkflowStageName() {
return workflowStageName;
}
/**
*
* @param workflowStageName
*/
public void setWorkflowStageName(String workflowStageName) {
this.workflowStageName = workflowStageName;
}
/**
*
* @return String
*/
public String getPrequalURL() {
return prequalURL;
}
/**
*
* @param prequalURL
*/
public void setPrequalURL(String prequalURL) {
this.prequalURL = prequalURL;
}
} | 13,861 | 0.711853 | 0.71041 | 701 | 18.774609 | 19.610704 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.285307 | false | false | 9 |
a28a012f38dd072343a548b343a28c81c597ae16 | 13,262,859,011,179 | 647782bfcb474d72c3be5940afbf4d1d759d14c7 | /src/main/java/com/eoh/asset/service/AssetService.java | 7d01d3f346dc4211e837cb15ab1c8fd5a34f98c3 | [] | no_license | dmuziga/AssetManagementSystem | https://github.com/dmuziga/AssetManagementSystem | a4e49d46a88cf2f8c5d27467c12f718fafcbfc0f | 92e95052d062b8b5b53c2d2291e4c34e6e3a90af | refs/heads/master | 2020-03-27T15:42:36.435000 | 2018-09-23T16:03:45 | 2018-09-23T16:03:45 | 146,734,232 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.eoh.asset.service;
import com.eoh.asset.entity.Asset;
import java.util.List;
public interface AssetService {
public void saveAsset(Asset theAsset);
public List<Asset> listAssets();
public Asset getAsset(int id);
public void deleteAsset(int id);
}
| UTF-8 | Java | 279 | java | AssetService.java | Java | [] | null | [] | package com.eoh.asset.service;
import com.eoh.asset.entity.Asset;
import java.util.List;
public interface AssetService {
public void saveAsset(Asset theAsset);
public List<Asset> listAssets();
public Asset getAsset(int id);
public void deleteAsset(int id);
}
| 279 | 0.734767 | 0.734767 | 13 | 20.461538 | 16.574379 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.538462 | false | false | 9 |
1fcbaa4448f3cf80dea9d3d10c304b5bf1b2e96d | 32,933,809,292,574 | 3d4ad9ad34bf51644bd9dba845ded770feef4b8d | /SpringSource/CastorWithSpring/com/castorWithSpring/Catalog.java | 356c98fa443361f309c994799aaaea1a3a9908be | [] | no_license | developerideas5/Tutor | https://github.com/developerideas5/Tutor | 44b524b8781c0d18f5164d02d765cdc931984976 | 20b52be3de2f8bb7b9f8b412dfc744b93c293088 | refs/heads/master | 2022-12-19T21:49:19.287000 | 2020-02-28T13:52:20 | 2020-02-28T13:52:20 | 65,913,497 | 0 | 0 | null | false | 2022-12-16T02:35:41 | 2016-08-17T14:19:05 | 2020-02-28T13:52:25 | 2022-12-16T02:35:38 | 9,879 | 0 | 0 | 20 | JavaScript | false | false | package com.castorWithSpring;
import java.util.ArrayList;
import java.util.List;
public class Catalog
{
private int id;
private List<Book> books = new ArrayList<Book>();
public int getId() {
return id;
}
public void addBook(Book book)
{
books.add(book);
}
public void setId(int id) {
this.id = id;
}
public void setBooks(List<Book> books)
{
this.books = books;
}
public List<Book> getBooks()
{
return books;
}
}
| UTF-8 | Java | 445 | java | Catalog.java | Java | [] | null | [] | package com.castorWithSpring;
import java.util.ArrayList;
import java.util.List;
public class Catalog
{
private int id;
private List<Book> books = new ArrayList<Book>();
public int getId() {
return id;
}
public void addBook(Book book)
{
books.add(book);
}
public void setId(int id) {
this.id = id;
}
public void setBooks(List<Book> books)
{
this.books = books;
}
public List<Book> getBooks()
{
return books;
}
}
| 445 | 0.669663 | 0.669663 | 30 | 13.833333 | 13.555032 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.233333 | false | false | 9 |
a9b5470c44dc06a7c240f7bc0ed59730489c5e43 | 6,287,832,147,206 | 5a98979e4410cd588f9f61688bbc658222fcfe8c | /interview-sheduller/src/main/java/com/softserveinc/ita/service/impl/AppointmentServiceImpl.java | 15403afd7fbad2c9ecbf3b1f776aca0dfde64e01 | [] | no_license | combats/ITA-java | https://github.com/combats/ITA-java | 26938fd444e5980ba779562c184ba0b85910f48f | ece46935bab2027ea2da22f6dd37caf5cc57766f | refs/heads/develop | 2021-01-15T10:47:36.063000 | 2014-08-11T12:55:10 | 2014-08-11T12:55:10 | 20,289,616 | 0 | 3 | null | false | 2014-08-09T10:07:57 | 2014-05-29T09:57:49 | 2014-07-23T18:08:28 | 2014-08-09T10:07:56 | 86,908 | 0 | 0 | 0 | Java | null | null | package com.softserveinc.ita.service.impl;
import com.softserveinc.ita.dao.AppointmentDAO;
import com.softserveinc.ita.entity.Appointment;
import com.softserveinc.ita.service.AppointmentService;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class AppointmentServiceImpl implements AppointmentService {
@Autowired
private AppointmentDAO appointmentDAO;
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public String putAppointment(Appointment appointment) {
return appointmentDAO.putAppointment(appointment);
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public List<Appointment> getAppointmentByApplicantId(String applicantId) {
return appointmentDAO.getAppointmentByApplicantId(applicantId);
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public void removeAppointmentById(String appointmentId) {
appointmentDAO.removeAppointmentById(appointmentId);
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public Appointment getAppointmentByAppointmentId(String appointmentId) {
return appointmentDAO.getAppointmentByAppointmentId(appointmentId);
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public List<Appointment> getAppointmentsByDate(long date) {
DateTime dateTime = new DateTime(date);
DateTime startOfDay = dateTime.withTime(0, 0, 0, 0);
DateTime endOfDay = dateTime.withTime(23, 59, 59, 999);
return appointmentDAO.getAppointmentsByDate(startOfDay.getMillis(), endOfDay.getMillis());
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public Appointment updateAppointment(Appointment appointment) {
return appointmentDAO.updateAppointment(appointment);
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public String getAppointmentIdByGroupIdAndApplicantId(String groupId, String applicantId) {
return appointmentDAO.getAppointmentIdByGroupIdAndApplicantId(groupId,applicantId);
}
}
| UTF-8 | Java | 2,371 | java | AppointmentServiceImpl.java | Java | [] | null | [] | package com.softserveinc.ita.service.impl;
import com.softserveinc.ita.dao.AppointmentDAO;
import com.softserveinc.ita.entity.Appointment;
import com.softserveinc.ita.service.AppointmentService;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class AppointmentServiceImpl implements AppointmentService {
@Autowired
private AppointmentDAO appointmentDAO;
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public String putAppointment(Appointment appointment) {
return appointmentDAO.putAppointment(appointment);
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public List<Appointment> getAppointmentByApplicantId(String applicantId) {
return appointmentDAO.getAppointmentByApplicantId(applicantId);
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public void removeAppointmentById(String appointmentId) {
appointmentDAO.removeAppointmentById(appointmentId);
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public Appointment getAppointmentByAppointmentId(String appointmentId) {
return appointmentDAO.getAppointmentByAppointmentId(appointmentId);
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public List<Appointment> getAppointmentsByDate(long date) {
DateTime dateTime = new DateTime(date);
DateTime startOfDay = dateTime.withTime(0, 0, 0, 0);
DateTime endOfDay = dateTime.withTime(23, 59, 59, 999);
return appointmentDAO.getAppointmentsByDate(startOfDay.getMillis(), endOfDay.getMillis());
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public Appointment updateAppointment(Appointment appointment) {
return appointmentDAO.updateAppointment(appointment);
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public String getAppointmentIdByGroupIdAndApplicantId(String groupId, String applicantId) {
return appointmentDAO.getAppointmentIdByGroupIdAndApplicantId(groupId,applicantId);
}
}
| 2,371 | 0.773513 | 0.76803 | 63 | 36.634922 | 29.567411 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.47619 | false | false | 9 |
8dab3a14235ceddf0e506fb9e3805fd4a913e48c | 3,023,657,031,783 | 6eb3f116078ee9dd68883b71eca4d8437ab0a9c8 | /src/main/java/PyramidLayers/HighQualityLayer.java | 4bf2207e4ac63c9802d056fba20c6b414b31a0e4 | [] | no_license | KhalidElKhamlichi/Pyramid-challenge | https://github.com/KhalidElKhamlichi/Pyramid-challenge | 52510b2d3d0604a9a511719d507b31c88f285965 | ee6980b619ed731a48f6310831eec298f3283ad9 | refs/heads/master | 2021-04-09T15:41:42.136000 | 2018-03-19T09:14:37 | 2018-03-19T09:14:37 | 125,510,907 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package PyramidLayers;
public class HighQualityLayer extends Layer {
private final String block = "X";
HighQualityLayer(int length) {
super(length);
super.setBlock(block);
}
public boolean canHold(Layer layer) {
return layer.getLength() <= this.length;
}
}
| UTF-8 | Java | 306 | java | HighQualityLayer.java | Java | [] | null | [] | package PyramidLayers;
public class HighQualityLayer extends Layer {
private final String block = "X";
HighQualityLayer(int length) {
super(length);
super.setBlock(block);
}
public boolean canHold(Layer layer) {
return layer.getLength() <= this.length;
}
}
| 306 | 0.643791 | 0.643791 | 16 | 18.125 | 18.023855 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3125 | false | false | 9 |
d98b8cd4662cc38e934462a01b62ecc8150f118a | 2,044,404,501,753 | a0c3d5bf4b7ff2e25a82b4ecb25bef35e8bc6dcc | /src/main/com/intellij/lang/jsgraphql/ide/editor/GraphQLIntrospectionResultToSchema.java | b37d2cc841dbadd2c1b8b486a8e0e1f316ff9955 | [
"MIT"
] | permissive | Andrea-MariaDB-2/js-graphql-intellij-plugin | https://github.com/Andrea-MariaDB-2/js-graphql-intellij-plugin | 6f7b03cc8488a9136acf83d2ad58f2209a9d8c84 | cec6914136aa3aa743d280fe0d7d2177f8e3b397 | refs/heads/master | 2023-07-25T15:19:19.665000 | 2021-08-06T23:43:36 | 2021-08-06T23:43:36 | 389,835,354 | 0 | 0 | MIT | true | 2021-09-06T21:42:58 | 2021-07-27T03:22:54 | 2021-08-06T23:43:43 | 2021-09-06T21:42:56 | 31,549 | 0 | 0 | 1 | Java | false | false | package com.intellij.lang.jsgraphql.ide.editor;
import com.google.common.collect.Lists;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.lang.jsgraphql.types.PublicApi;
import com.intellij.lang.jsgraphql.types.language.*;
import com.intellij.lang.jsgraphql.types.schema.idl.ScalarInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.stream.Collectors;
import static com.intellij.lang.jsgraphql.types.Assert.*;
@SuppressWarnings("unchecked")
@PublicApi
public class GraphQLIntrospectionResultToSchema {
/**
* Returns a IDL Document that represents the schema as defined by the introspection result map
*
* @param introspectionResult the result of an introspection query on a schema
* @return a IDL Document of the schema
*/
@SuppressWarnings("unchecked")
public Document createSchemaDefinition(@NotNull Map<String, Object> introspectionResult) {
assertTrue(introspectionResult.get("__schema") != null, () -> "__schema expected");
Map<String, Object> schema = (Map<String, Object>) introspectionResult.get("__schema");
Map<String, Object> queryType = (Map<String, Object>) schema.get("queryType");
assertNotNull(queryType, () -> "queryType expected");
TypeName query = TypeName.newTypeName().name((String) queryType.get("name")).build();
boolean nonDefaultQueryName = !"Query".equals(query.getName());
SchemaDefinition.Builder schemaDefinition = SchemaDefinition.newSchemaDefinition();
schemaDefinition.operationTypeDefinition(OperationTypeDefinition.newOperationTypeDefinition().name("query").typeName(query).build());
Map<String, Object> mutationType = (Map<String, Object>) schema.get("mutationType");
boolean nonDefaultMutationName = false;
if (mutationType != null) {
TypeName mutation = TypeName.newTypeName().name((String) mutationType.get("name")).build();
nonDefaultMutationName = !"Mutation".equals(mutation.getName());
schemaDefinition.operationTypeDefinition(OperationTypeDefinition.newOperationTypeDefinition().name("mutation").typeName(mutation).build());
}
Map<String, Object> subscriptionType = (Map<String, Object>) schema.get("subscriptionType");
boolean nonDefaultSubscriptionName = false;
if (subscriptionType != null) {
TypeName subscription = TypeName.newTypeName().name(((String) subscriptionType.get("name"))).build();
nonDefaultSubscriptionName = !"Subscription".equals(subscription.getName());
schemaDefinition.operationTypeDefinition(OperationTypeDefinition.newOperationTypeDefinition().name("subscription").typeName(subscription).build());
}
Document.Builder document = Document.newDocument();
if (nonDefaultQueryName || nonDefaultMutationName || nonDefaultSubscriptionName) {
document.definition(schemaDefinition.build());
}
List<Map<String, Object>> types = (List<Map<String, Object>>) schema.get("types");
if (types != null) {
for (Map<String, Object> type : types) {
if (type == null) continue;
TypeDefinition<?> typeDefinition = createTypeDefinition(type);
if (typeDefinition == null) continue;
document.definition(typeDefinition);
}
}
return document.build();
}
@Nullable
private TypeDefinition<?> createTypeDefinition(@NotNull Map<String, Object> type) {
String kind = assertNotNull((String) type.get("kind"), () -> String.format("null object kind: %s", type.toString()));
String name = (String) type.get("name");
if (name.startsWith("__")) return null;
switch (kind) {
case "INTERFACE":
return createInterface(type);
case "OBJECT":
return createObject(type);
case "UNION":
return createUnion(type);
case "ENUM":
return createEnum(type);
case "INPUT_OBJECT":
return createInputObject(type);
case "SCALAR":
return createScalar(type);
default:
return assertShouldNeverHappen("unexpected kind %s", kind);
}
}
@Nullable
private static TypeDefinition<?> createScalar(@NotNull Map<String, Object> input) {
String name = (String) input.get("name");
if (ScalarInfo.isGraphqlSpecifiedScalar(name)) {
return null;
}
return ScalarTypeDefinition.newScalarTypeDefinition().name(name).description(getDescription(input)).build();
}
@SuppressWarnings("unchecked")
@NotNull
static UnionTypeDefinition createUnion(@NotNull Map<String, Object> input) {
assertTrue(Objects.equals(input.get("kind"), "UNION"), () -> "wrong input");
final List<Map<String, Object>> possibleTypes = (List<Map<String, Object>>) input.get("possibleTypes");
final List<Type> memberTypes = Lists.newArrayList();
if (possibleTypes != null) {
for (Map<String, Object> possibleType : possibleTypes) {
if (possibleType == null) continue;
TypeName typeName = new TypeName((String) possibleType.get("name"));
memberTypes.add(typeName);
}
}
return UnionTypeDefinition.newUnionTypeDefinition()
.name((String) input.get("name"))
.description(getDescription(input))
.memberTypes(memberTypes)
.build();
}
@SuppressWarnings("unchecked")
@NotNull
static EnumTypeDefinition createEnum(@NotNull Map<String, Object> input) {
assertTrue(Objects.equals(input.get("kind"), "ENUM"), () -> "wrong input");
final List<Map<String, Object>> enumValues = (List<Map<String, Object>>) input.get("enumValues");
final List<EnumValueDefinition> enumValueDefinitions = Lists.newArrayList();
if (enumValues != null) {
for (Map<String, Object> enumValue : enumValues) {
if (enumValue == null) continue;
EnumValueDefinition enumValueDefinition = EnumValueDefinition.newEnumValueDefinition()
.name((String) enumValue.get("name"))
.description(getDescription(enumValue))
.directives(createDeprecatedDirective(enumValue))
.build();
enumValueDefinitions.add(enumValueDefinition);
}
}
return EnumTypeDefinition.newEnumTypeDefinition()
.name((String) input.get("name"))
.description(getDescription(input))
.enumValueDefinitions(enumValueDefinitions)
.build();
}
@SuppressWarnings("unchecked")
@NotNull
InterfaceTypeDefinition createInterface(@NotNull Map<String, Object> input) {
assertTrue(Objects.equals(input.get("kind"), "INTERFACE"), () -> "wrong input");
final List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("fields");
return InterfaceTypeDefinition.newInterfaceTypeDefinition()
.name((String) input.get("name"))
.description(getDescription(input))
.definitions(createFields(fields))
.build();
}
@SuppressWarnings("unchecked")
@NotNull
InputObjectTypeDefinition createInputObject(@NotNull Map<String, Object> input) {
assertTrue(Objects.equals(input.get("kind"), "INPUT_OBJECT"), () -> "wrong input");
final List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("inputFields");
return InputObjectTypeDefinition.newInputObjectDefinition()
.name((String) input.get("name"))
.description(getDescription(input))
.inputValueDefinitions(createInputValueDefinitions(fields))
.build();
}
@SuppressWarnings("unchecked")
@NotNull
ObjectTypeDefinition createObject(@NotNull Map<String, Object> input) {
assertTrue(Objects.equals(input.get("kind"), "OBJECT"), () -> "wrong input");
ObjectTypeDefinition.Builder builder = ObjectTypeDefinition.newObjectTypeDefinition()
.name((String) input.get("name"))
.description(getDescription(input));
if (input.containsKey("interfaces")) {
builder.implementz(
((List<Map<String, Object>>) input.get("interfaces")).stream()
.map(GraphQLIntrospectionResultToSchema::createTypeIndirection)
.collect(Collectors.toList())
);
}
List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("fields");
builder.fieldDefinitions(createFields(fields));
return builder.build();
}
@NotNull
private List<FieldDefinition> createFields(@Nullable List<Map<String, Object>> fields) {
if (fields == null) return ContainerUtil.emptyList();
List<FieldDefinition> result = new ArrayList<>();
for (Map<String, Object> field : fields) {
if (field == null) continue;
List<Map<String, Object>> args = (List<Map<String, Object>>) field.get("args");
List<InputValueDefinition> inputValueDefinitions = createInputValueDefinitions(args);
FieldDefinition fieldDefinition = FieldDefinition.newFieldDefinition()
.name((String) field.get("name"))
.description(getDescription(field))
.type(createTypeIndirection((Map<String, Object>) field.get("type")))
.inputValueDefinitions(inputValueDefinitions)
.directives(createDeprecatedDirective(field))
.build();
result.add(fieldDefinition);
}
return result;
}
@NotNull
private static List<Directive> createDeprecatedDirective(@NotNull Map<String, Object> field) {
if ((Boolean) field.get("isDeprecated")) {
String reason = (String) field.get("deprecationReason");
if (reason == null) {
reason = "No longer supported"; // default according to spec
}
Argument reasonArg = new Argument("reason", new StringValue(reason));
return Collections.singletonList(new Directive("deprecated", Collections.singletonList(reasonArg)));
}
return Collections.emptyList();
}
@SuppressWarnings("unchecked")
@NotNull
private static List<InputValueDefinition> createInputValueDefinitions(@Nullable List<Map<String, Object>> args) {
if (args == null) return ContainerUtil.emptyList();
List<InputValueDefinition> result = new ArrayList<>();
for (Map<String, Object> arg : args) {
if (arg == null) continue;
Type argType = createTypeIndirection((Map<String, Object>) arg.get("type"));
String valueLiteral = (String) arg.get("defaultValue");
Value defaultValue = valueLiteral != null ? AstValueHelper.valueFromAst(valueLiteral) : null;
InputValueDefinition inputValueDefinition = InputValueDefinition.newInputValueDefinition()
.name((String) arg.get("name"))
.type(argType)
.description(getDescription(arg))
.defaultValue(defaultValue)
.build();
result.add(inputValueDefinition);
}
return result;
}
@SuppressWarnings("unchecked")
@Nullable
private static Type createTypeIndirection(@Nullable Map<String, Object> type) {
if (type == null) return null;
String kind = (String) type.get("kind");
switch (kind) {
case "INTERFACE":
case "OBJECT":
case "UNION":
case "ENUM":
case "INPUT_OBJECT":
case "SCALAR":
return TypeName.newTypeName().name((String) type.get("name")).build();
case "NON_NULL":
Type ofType = createTypeIndirection((Map<String, Object>) type.get("ofType"));
if (ofType == null) return null;
return NonNullType.newNonNullType().type(ofType).build();
case "LIST":
return ListType.newListType().type(createTypeIndirection((Map<String, Object>) type.get("ofType"))).build();
default:
return assertShouldNeverHappen("Unknown kind %s", kind);
}
}
@Nullable
private static Description getDescription(@Nullable Map<String, Object> descriptionAware) {
if (descriptionAware == null) return null;
final Object rawDescription = descriptionAware.get("description");
if (rawDescription instanceof String) {
String description = (String) rawDescription;
if (!description.trim().isEmpty()) {
final boolean multiLine = description.contains("\n");
if (multiLine) {
// ensures the description stands on separate lines from the triple quotes
description = "\n" + description.trim() + "\n";
}
return new Description(description, new SourceLocation(1, 1), multiLine);
}
}
return null;
}
}
| UTF-8 | Java | 13,418 | java | GraphQLIntrospectionResultToSchema.java | Java | [] | null | [] | package com.intellij.lang.jsgraphql.ide.editor;
import com.google.common.collect.Lists;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.lang.jsgraphql.types.PublicApi;
import com.intellij.lang.jsgraphql.types.language.*;
import com.intellij.lang.jsgraphql.types.schema.idl.ScalarInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.stream.Collectors;
import static com.intellij.lang.jsgraphql.types.Assert.*;
@SuppressWarnings("unchecked")
@PublicApi
public class GraphQLIntrospectionResultToSchema {
/**
* Returns a IDL Document that represents the schema as defined by the introspection result map
*
* @param introspectionResult the result of an introspection query on a schema
* @return a IDL Document of the schema
*/
@SuppressWarnings("unchecked")
public Document createSchemaDefinition(@NotNull Map<String, Object> introspectionResult) {
assertTrue(introspectionResult.get("__schema") != null, () -> "__schema expected");
Map<String, Object> schema = (Map<String, Object>) introspectionResult.get("__schema");
Map<String, Object> queryType = (Map<String, Object>) schema.get("queryType");
assertNotNull(queryType, () -> "queryType expected");
TypeName query = TypeName.newTypeName().name((String) queryType.get("name")).build();
boolean nonDefaultQueryName = !"Query".equals(query.getName());
SchemaDefinition.Builder schemaDefinition = SchemaDefinition.newSchemaDefinition();
schemaDefinition.operationTypeDefinition(OperationTypeDefinition.newOperationTypeDefinition().name("query").typeName(query).build());
Map<String, Object> mutationType = (Map<String, Object>) schema.get("mutationType");
boolean nonDefaultMutationName = false;
if (mutationType != null) {
TypeName mutation = TypeName.newTypeName().name((String) mutationType.get("name")).build();
nonDefaultMutationName = !"Mutation".equals(mutation.getName());
schemaDefinition.operationTypeDefinition(OperationTypeDefinition.newOperationTypeDefinition().name("mutation").typeName(mutation).build());
}
Map<String, Object> subscriptionType = (Map<String, Object>) schema.get("subscriptionType");
boolean nonDefaultSubscriptionName = false;
if (subscriptionType != null) {
TypeName subscription = TypeName.newTypeName().name(((String) subscriptionType.get("name"))).build();
nonDefaultSubscriptionName = !"Subscription".equals(subscription.getName());
schemaDefinition.operationTypeDefinition(OperationTypeDefinition.newOperationTypeDefinition().name("subscription").typeName(subscription).build());
}
Document.Builder document = Document.newDocument();
if (nonDefaultQueryName || nonDefaultMutationName || nonDefaultSubscriptionName) {
document.definition(schemaDefinition.build());
}
List<Map<String, Object>> types = (List<Map<String, Object>>) schema.get("types");
if (types != null) {
for (Map<String, Object> type : types) {
if (type == null) continue;
TypeDefinition<?> typeDefinition = createTypeDefinition(type);
if (typeDefinition == null) continue;
document.definition(typeDefinition);
}
}
return document.build();
}
@Nullable
private TypeDefinition<?> createTypeDefinition(@NotNull Map<String, Object> type) {
String kind = assertNotNull((String) type.get("kind"), () -> String.format("null object kind: %s", type.toString()));
String name = (String) type.get("name");
if (name.startsWith("__")) return null;
switch (kind) {
case "INTERFACE":
return createInterface(type);
case "OBJECT":
return createObject(type);
case "UNION":
return createUnion(type);
case "ENUM":
return createEnum(type);
case "INPUT_OBJECT":
return createInputObject(type);
case "SCALAR":
return createScalar(type);
default:
return assertShouldNeverHappen("unexpected kind %s", kind);
}
}
@Nullable
private static TypeDefinition<?> createScalar(@NotNull Map<String, Object> input) {
String name = (String) input.get("name");
if (ScalarInfo.isGraphqlSpecifiedScalar(name)) {
return null;
}
return ScalarTypeDefinition.newScalarTypeDefinition().name(name).description(getDescription(input)).build();
}
@SuppressWarnings("unchecked")
@NotNull
static UnionTypeDefinition createUnion(@NotNull Map<String, Object> input) {
assertTrue(Objects.equals(input.get("kind"), "UNION"), () -> "wrong input");
final List<Map<String, Object>> possibleTypes = (List<Map<String, Object>>) input.get("possibleTypes");
final List<Type> memberTypes = Lists.newArrayList();
if (possibleTypes != null) {
for (Map<String, Object> possibleType : possibleTypes) {
if (possibleType == null) continue;
TypeName typeName = new TypeName((String) possibleType.get("name"));
memberTypes.add(typeName);
}
}
return UnionTypeDefinition.newUnionTypeDefinition()
.name((String) input.get("name"))
.description(getDescription(input))
.memberTypes(memberTypes)
.build();
}
@SuppressWarnings("unchecked")
@NotNull
static EnumTypeDefinition createEnum(@NotNull Map<String, Object> input) {
assertTrue(Objects.equals(input.get("kind"), "ENUM"), () -> "wrong input");
final List<Map<String, Object>> enumValues = (List<Map<String, Object>>) input.get("enumValues");
final List<EnumValueDefinition> enumValueDefinitions = Lists.newArrayList();
if (enumValues != null) {
for (Map<String, Object> enumValue : enumValues) {
if (enumValue == null) continue;
EnumValueDefinition enumValueDefinition = EnumValueDefinition.newEnumValueDefinition()
.name((String) enumValue.get("name"))
.description(getDescription(enumValue))
.directives(createDeprecatedDirective(enumValue))
.build();
enumValueDefinitions.add(enumValueDefinition);
}
}
return EnumTypeDefinition.newEnumTypeDefinition()
.name((String) input.get("name"))
.description(getDescription(input))
.enumValueDefinitions(enumValueDefinitions)
.build();
}
@SuppressWarnings("unchecked")
@NotNull
InterfaceTypeDefinition createInterface(@NotNull Map<String, Object> input) {
assertTrue(Objects.equals(input.get("kind"), "INTERFACE"), () -> "wrong input");
final List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("fields");
return InterfaceTypeDefinition.newInterfaceTypeDefinition()
.name((String) input.get("name"))
.description(getDescription(input))
.definitions(createFields(fields))
.build();
}
@SuppressWarnings("unchecked")
@NotNull
InputObjectTypeDefinition createInputObject(@NotNull Map<String, Object> input) {
assertTrue(Objects.equals(input.get("kind"), "INPUT_OBJECT"), () -> "wrong input");
final List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("inputFields");
return InputObjectTypeDefinition.newInputObjectDefinition()
.name((String) input.get("name"))
.description(getDescription(input))
.inputValueDefinitions(createInputValueDefinitions(fields))
.build();
}
@SuppressWarnings("unchecked")
@NotNull
ObjectTypeDefinition createObject(@NotNull Map<String, Object> input) {
assertTrue(Objects.equals(input.get("kind"), "OBJECT"), () -> "wrong input");
ObjectTypeDefinition.Builder builder = ObjectTypeDefinition.newObjectTypeDefinition()
.name((String) input.get("name"))
.description(getDescription(input));
if (input.containsKey("interfaces")) {
builder.implementz(
((List<Map<String, Object>>) input.get("interfaces")).stream()
.map(GraphQLIntrospectionResultToSchema::createTypeIndirection)
.collect(Collectors.toList())
);
}
List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("fields");
builder.fieldDefinitions(createFields(fields));
return builder.build();
}
@NotNull
private List<FieldDefinition> createFields(@Nullable List<Map<String, Object>> fields) {
if (fields == null) return ContainerUtil.emptyList();
List<FieldDefinition> result = new ArrayList<>();
for (Map<String, Object> field : fields) {
if (field == null) continue;
List<Map<String, Object>> args = (List<Map<String, Object>>) field.get("args");
List<InputValueDefinition> inputValueDefinitions = createInputValueDefinitions(args);
FieldDefinition fieldDefinition = FieldDefinition.newFieldDefinition()
.name((String) field.get("name"))
.description(getDescription(field))
.type(createTypeIndirection((Map<String, Object>) field.get("type")))
.inputValueDefinitions(inputValueDefinitions)
.directives(createDeprecatedDirective(field))
.build();
result.add(fieldDefinition);
}
return result;
}
@NotNull
private static List<Directive> createDeprecatedDirective(@NotNull Map<String, Object> field) {
if ((Boolean) field.get("isDeprecated")) {
String reason = (String) field.get("deprecationReason");
if (reason == null) {
reason = "No longer supported"; // default according to spec
}
Argument reasonArg = new Argument("reason", new StringValue(reason));
return Collections.singletonList(new Directive("deprecated", Collections.singletonList(reasonArg)));
}
return Collections.emptyList();
}
@SuppressWarnings("unchecked")
@NotNull
private static List<InputValueDefinition> createInputValueDefinitions(@Nullable List<Map<String, Object>> args) {
if (args == null) return ContainerUtil.emptyList();
List<InputValueDefinition> result = new ArrayList<>();
for (Map<String, Object> arg : args) {
if (arg == null) continue;
Type argType = createTypeIndirection((Map<String, Object>) arg.get("type"));
String valueLiteral = (String) arg.get("defaultValue");
Value defaultValue = valueLiteral != null ? AstValueHelper.valueFromAst(valueLiteral) : null;
InputValueDefinition inputValueDefinition = InputValueDefinition.newInputValueDefinition()
.name((String) arg.get("name"))
.type(argType)
.description(getDescription(arg))
.defaultValue(defaultValue)
.build();
result.add(inputValueDefinition);
}
return result;
}
@SuppressWarnings("unchecked")
@Nullable
private static Type createTypeIndirection(@Nullable Map<String, Object> type) {
if (type == null) return null;
String kind = (String) type.get("kind");
switch (kind) {
case "INTERFACE":
case "OBJECT":
case "UNION":
case "ENUM":
case "INPUT_OBJECT":
case "SCALAR":
return TypeName.newTypeName().name((String) type.get("name")).build();
case "NON_NULL":
Type ofType = createTypeIndirection((Map<String, Object>) type.get("ofType"));
if (ofType == null) return null;
return NonNullType.newNonNullType().type(ofType).build();
case "LIST":
return ListType.newListType().type(createTypeIndirection((Map<String, Object>) type.get("ofType"))).build();
default:
return assertShouldNeverHappen("Unknown kind %s", kind);
}
}
@Nullable
private static Description getDescription(@Nullable Map<String, Object> descriptionAware) {
if (descriptionAware == null) return null;
final Object rawDescription = descriptionAware.get("description");
if (rawDescription instanceof String) {
String description = (String) rawDescription;
if (!description.trim().isEmpty()) {
final boolean multiLine = description.contains("\n");
if (multiLine) {
// ensures the description stands on separate lines from the triple quotes
description = "\n" + description.trim() + "\n";
}
return new Description(description, new SourceLocation(1, 1), multiLine);
}
}
return null;
}
}
| 13,418 | 0.626248 | 0.626099 | 310 | 42.283871 | 34.558552 | 159 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.590323 | false | false | 9 |
c086a2c76bd1e1a9f4cdc7485e26c30f809c8480 | 34,686,155,895,575 | 74f7fa87a335c5d6b2ada60006cd96bf0d3673a9 | /hppc-template-processor/src/main/java/com/carrotsearch/hppc/generator/intrinsics/Numeric.java | c71ec3eef571972d4c6846f7030ec0a22fa86853 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | carrotsearch/hppc | https://github.com/carrotsearch/hppc | c806cd33810f9f23b2447b3228491272fa04ec92 | c9497dfabff240787aa0f5ac7a8f4ad70117ea72 | refs/heads/master | 2023-08-02T13:18:59.433000 | 2023-08-01T10:31:10 | 2023-08-01T10:31:10 | 1,397,974 | 891 | 155 | Apache-2.0 | false | 2023-08-01T10:34:03 | 2011-02-22T15:14:20 | 2023-07-29T13:16:03 | 2023-08-01T10:31:10 | 49,581 | 924 | 154 | 6 | Java | false | false | /*
* HPPC
*
* Copyright (C) 2010-2022 Carrot Search s.c.
* All rights reserved.
*
* Refer to the full license file "LICENSE.txt":
* https://github.com/carrotsearch/hppc/blob/master/LICENSE.txt
*/
package com.carrotsearch.hppc.generator.intrinsics;
import com.carrotsearch.hppc.generator.TemplateOptions;
import com.carrotsearch.hppc.generator.Type;
import java.util.ArrayList;
import java.util.regex.Matcher;
public class Numeric extends AbstractIntrinsicMethod {
@Override
public void invoke(
Matcher m,
StringBuilder sb,
TemplateOptions templateOptions,
String genericCast,
ArrayList<String> params) {
expectArgumentCount(m, params, 1);
if (inferTemplateType(m, templateOptions, genericCast) == Type.GENERIC) {
throw new RuntimeException("Can't get the numeric value of generic types: " + m.group());
}
sb.append(params.get(0));
}
}
| UTF-8 | Java | 903 | java | Numeric.java | Java | [
{
"context": "/*\n * HPPC\n *\n * Copyright (C) 2010-2022 Carrot Search s.c.\n * All rights reserved.\n *\n * Refer to the f",
"end": 54,
"score": 0.9988681674003601,
"start": 41,
"tag": "NAME",
"value": "Carrot Search"
},
{
"context": "license file \"LICENSE.txt\":\n * https://github.com/carrotsearch/hppc/blob/master/LICENSE.txt\n */\npackage com.carr",
"end": 170,
"score": 0.9995929598808289,
"start": 158,
"tag": "USERNAME",
"value": "carrotsearch"
}
] | null | [] | /*
* HPPC
*
* Copyright (C) 2010-2022 <NAME> s.c.
* All rights reserved.
*
* Refer to the full license file "LICENSE.txt":
* https://github.com/carrotsearch/hppc/blob/master/LICENSE.txt
*/
package com.carrotsearch.hppc.generator.intrinsics;
import com.carrotsearch.hppc.generator.TemplateOptions;
import com.carrotsearch.hppc.generator.Type;
import java.util.ArrayList;
import java.util.regex.Matcher;
public class Numeric extends AbstractIntrinsicMethod {
@Override
public void invoke(
Matcher m,
StringBuilder sb,
TemplateOptions templateOptions,
String genericCast,
ArrayList<String> params) {
expectArgumentCount(m, params, 1);
if (inferTemplateType(m, templateOptions, genericCast) == Type.GENERIC) {
throw new RuntimeException("Can't get the numeric value of generic types: " + m.group());
}
sb.append(params.get(0));
}
}
| 896 | 0.719823 | 0.708749 | 31 | 28.129032 | 24.306831 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.516129 | false | false | 9 |
6af9b309b56e7a9914d51bd09cc1e0a0ee3b04c0 | 20,280,835,595,374 | 384ec4abdb0b895e47e72e8b410eadd0e0308c29 | /src/ConverttoDot.java | d4f8bbc8611a3815ae43f13e0028f6ecc7812f97 | [] | no_license | lchen10/PolicyVisualization | https://github.com/lchen10/PolicyVisualization | c81fe4dd85f8d0e70f602e024cd82df3651fbd9b | 6d48c171dc1aae1cd266dab0c01eaad242ce0ff4 | refs/heads/master | 2020-12-02T06:43:58.055000 | 2017-07-11T12:17:27 | 2017-07-11T12:17:27 | 96,889,533 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.alexmerz.graphviz.objects.Edge;
import com.alexmerz.graphviz.objects.Graph;
import com.alexmerz.graphviz.objects.Id;
import com.alexmerz.graphviz.objects.Node;
import com.alexmerz.graphviz.objects.PortNode;
public class ConverttoDot {
public static void main(String[] args) throws IOException {
convertToDot("C:\\Users\\xsxiao\\Documents\\Projects\\policy-visualization\\malicious.txt", "graph.dot");
}
public static Graph convertToDot(String path, String outputPath) throws FileNotFoundException, IOException {
// TODO Auto-generated method stub
FileInputStream in = new FileInputStream(path);
// ~/Documents/workspace/Convert2Gexf/malicious.txt
BufferedReader br = new BufferedReader(new InputStreamReader(in));
// double delta = 1;
String strLine = null;
String[] mystring = new String[4];
HashMap<String, String> objectMap = new HashMap<String, String>();
HashMap<String, Node> objectNodeMap = new HashMap<String, Node>();
HashMap<String, String> permissionMap = new HashMap<String, String>();
HashMap<String, String> subjectMap = new HashMap<String, String>();
HashMap<String, Node> subjectNodeMap = new HashMap<String, Node>();
int accessPatternCount = 0;
int objectId = 1;
int permissionId = 1;
int subjectId = 1;
System.out.println("=======START HERE=======");
// scan the file to index all the subjects, permissions and objects,
// load them into hashmaps.
int objectcount = 0;
int subjectcount = 0;
Graph g = new Graph();
Id id = new Id();
g.setType(Graph.DIRECTED);
g.setId(id);
while ((strLine = br.readLine()) != null) {
strLine = strLine.trim();
mystring = strLine.split(" ");
// System.out.println("mystring length is: " + mystring.length);
if (mystring.length != 4) {
System.out.println("the string length is NOT 4!!!");
continue;
}
accessPatternCount++;
String object = mystring[0] + ": " + mystring[2];
System.out.println("object is: " + object);
String permission = mystring[1];
System.out.println("permission is: " + permission);
String subject = mystring[3];
System.out.println("subject is: " + subject);
System.out.println();
if (!objectMap.containsKey(object)) {
String objectId_s = "o" + String.valueOf(objectId);
objectMap.put(object, objectId_s);
objectId++;
Node n = new Node();
Id nid = new Id();
n.setId(nid);
nid.setId("\"" + objectId_s + "\"");
n.setAttribute("label", object + "");
n.setAttribute("shape", "box");
g.addNode(n);
objectNodeMap.put(objectId_s + "", n);
objectcount++;
}
if (!permissionMap.containsKey(permission)) {
String permissionId_s = "p" + String.valueOf(permissionId);
permissionMap.put(permission, permissionId_s);
permissionId++;
}
if (!subjectMap.containsKey(subject)) {
String subjectId_s = "s" + String.valueOf(subjectId);
subjectMap.put(subject, subjectId_s);
subjectId++;
Node n = new Node();
Id nid = new Id();
n.setId(nid);
nid.setId("\"" + subjectId_s + "\"");
n.setAttribute("label", "\"" + subject + "\"");
g.addNode(n);
subjectNodeMap.put(subjectId_s + "", n);
subjectcount++;
}
String source = subjectMap.get(subject);
String target = objectMap.get(object);
Node sourceNode = subjectNodeMap.get(source);
Node targetNode = objectNodeMap.get(target);
Edge e = new Edge(new PortNode(sourceNode),
new PortNode(targetNode), Graph.DIRECTED);
e.setAttribute("label", "\"" + permission + "\"");
g.addEdge(e);
}
System.out.println("accesspatternCount is: " + accessPatternCount);
in.close();
PrintWriter out = new PrintWriter(outputPath);
out.println(g.toString());
out.close();
return g;
}
}
| UTF-8 | Java | 4,948 | java | ConverttoDot.java | Java | [
{
"context": "ws IOException {\n convertToDot(\"C:\\\\Users\\\\xsxiao\\\\Documents\\\\Projects\\\\policy-visualization\\\\malic",
"end": 727,
"score": 0.998775064945221,
"start": 721,
"tag": "USERNAME",
"value": "xsxiao"
}
] | null | [] |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.alexmerz.graphviz.objects.Edge;
import com.alexmerz.graphviz.objects.Graph;
import com.alexmerz.graphviz.objects.Id;
import com.alexmerz.graphviz.objects.Node;
import com.alexmerz.graphviz.objects.PortNode;
public class ConverttoDot {
public static void main(String[] args) throws IOException {
convertToDot("C:\\Users\\xsxiao\\Documents\\Projects\\policy-visualization\\malicious.txt", "graph.dot");
}
public static Graph convertToDot(String path, String outputPath) throws FileNotFoundException, IOException {
// TODO Auto-generated method stub
FileInputStream in = new FileInputStream(path);
// ~/Documents/workspace/Convert2Gexf/malicious.txt
BufferedReader br = new BufferedReader(new InputStreamReader(in));
// double delta = 1;
String strLine = null;
String[] mystring = new String[4];
HashMap<String, String> objectMap = new HashMap<String, String>();
HashMap<String, Node> objectNodeMap = new HashMap<String, Node>();
HashMap<String, String> permissionMap = new HashMap<String, String>();
HashMap<String, String> subjectMap = new HashMap<String, String>();
HashMap<String, Node> subjectNodeMap = new HashMap<String, Node>();
int accessPatternCount = 0;
int objectId = 1;
int permissionId = 1;
int subjectId = 1;
System.out.println("=======START HERE=======");
// scan the file to index all the subjects, permissions and objects,
// load them into hashmaps.
int objectcount = 0;
int subjectcount = 0;
Graph g = new Graph();
Id id = new Id();
g.setType(Graph.DIRECTED);
g.setId(id);
while ((strLine = br.readLine()) != null) {
strLine = strLine.trim();
mystring = strLine.split(" ");
// System.out.println("mystring length is: " + mystring.length);
if (mystring.length != 4) {
System.out.println("the string length is NOT 4!!!");
continue;
}
accessPatternCount++;
String object = mystring[0] + ": " + mystring[2];
System.out.println("object is: " + object);
String permission = mystring[1];
System.out.println("permission is: " + permission);
String subject = mystring[3];
System.out.println("subject is: " + subject);
System.out.println();
if (!objectMap.containsKey(object)) {
String objectId_s = "o" + String.valueOf(objectId);
objectMap.put(object, objectId_s);
objectId++;
Node n = new Node();
Id nid = new Id();
n.setId(nid);
nid.setId("\"" + objectId_s + "\"");
n.setAttribute("label", object + "");
n.setAttribute("shape", "box");
g.addNode(n);
objectNodeMap.put(objectId_s + "", n);
objectcount++;
}
if (!permissionMap.containsKey(permission)) {
String permissionId_s = "p" + String.valueOf(permissionId);
permissionMap.put(permission, permissionId_s);
permissionId++;
}
if (!subjectMap.containsKey(subject)) {
String subjectId_s = "s" + String.valueOf(subjectId);
subjectMap.put(subject, subjectId_s);
subjectId++;
Node n = new Node();
Id nid = new Id();
n.setId(nid);
nid.setId("\"" + subjectId_s + "\"");
n.setAttribute("label", "\"" + subject + "\"");
g.addNode(n);
subjectNodeMap.put(subjectId_s + "", n);
subjectcount++;
}
String source = subjectMap.get(subject);
String target = objectMap.get(object);
Node sourceNode = subjectNodeMap.get(source);
Node targetNode = objectNodeMap.get(target);
Edge e = new Edge(new PortNode(sourceNode),
new PortNode(targetNode), Graph.DIRECTED);
e.setAttribute("label", "\"" + permission + "\"");
g.addEdge(e);
}
System.out.println("accesspatternCount is: " + accessPatternCount);
in.close();
PrintWriter out = new PrintWriter(outputPath);
out.println(g.toString());
out.close();
return g;
}
}
| 4,948 | 0.5673 | 0.564268 | 140 | 34.335712 | 24.781794 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.85 | false | false | 9 |
f8f7736c34b8fbfb108ba48c31ad357ec9975f5c | 19,894,288,564,806 | d77377ed91ff791419eee2dee4c1602360597100 | /config/src/main/java/com/vmware/config/section/GithubConfig.java | 180f70ed7cc9200ce5c2e5e50929a17f11912464 | [
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"LicenseRef-scancode-other-permissive",
"Apache-2.0"
] | permissive | vmware/workflowTools | https://github.com/vmware/workflowTools | ee5d8aa6198d56b4b896b6f4a64369337e183eaa | b76efd9a8e067c5dab77f8ddc7dbd7ea72b0356f | refs/heads/master | 2023-08-31T18:03:46.701000 | 2023-08-29T02:46:18 | 2023-08-29T02:46:22 | 21,996,028 | 25 | 14 | Apache-2.0 | false | 2023-05-19T00:20:21 | 2014-07-18T22:16:00 | 2022-09-03T05:30:30 | 2023-05-19T00:20:20 | 4,945 | 20 | 10 | 0 | Java | false | false | package com.vmware.config.section;
import com.vmware.config.ConfigurableProperty;
public class GithubConfig {
@ConfigurableProperty(help = "Api url for github site")
public String githubUrl;
@ConfigurableProperty(help = "Github release url for workflow tools")
public String workflowGithubReleasePath;
}
| UTF-8 | Java | 324 | java | GithubConfig.java | Java | [] | null | [] | package com.vmware.config.section;
import com.vmware.config.ConfigurableProperty;
public class GithubConfig {
@ConfigurableProperty(help = "Api url for github site")
public String githubUrl;
@ConfigurableProperty(help = "Github release url for workflow tools")
public String workflowGithubReleasePath;
}
| 324 | 0.771605 | 0.771605 | 12 | 26 | 24.86631 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 9 |
272006939567bb24a4359aa76520fda70e16eabd | 25,761,213,862,077 | dc98f915864995fdd4882156043ad80006a9c846 | /StreamLearning/src/main/java/com/test/TestFunctionalnterfaces.java | 3059655846c915b44e139ab07bc6b7a8ede47d72 | [] | no_license | VigneshR32/StreamLearning | https://github.com/VigneshR32/StreamLearning | c36905d3dbd55fb4c748f69a217f453898e702ca | 79a56161bad1549c0fc19a05f5772afd4e2369ff | refs/heads/master | 2023-04-10T08:21:35.491000 | 2021-04-20T18:48:05 | 2021-04-20T18:48:05 | 359,099,459 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.test;
import com.selenium.functionalinterface.DriverFactory;
import com.selenium.functionalinterface.TableFactory;
import com.table.TableClass;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.annotations.*;
import java.util.List;
import java.util.Locale;
import java.util.function.Predicate;
public class TestFunctionalnterfaces {
public WebDriver webDriver;
@BeforeTest
@Parameters("browser")
public void setupBrowser(@Optional("chrome")String browser){
DriverFactory driverFactory = new DriverFactory();
this.webDriver = driverFactory.getWebDrier(browser);
}
@Test(dataProvider = "predicateprovider")
public void openGoogle(Predicate<List<WebElement>> predicate){
this.webDriver.get("https://vins-udemy.s3.amazonaws.com/java/html/java8-stream-table.html");
// List<WebElement> webElementList = this.webDriver.findElements(By.tagName("a"));
// Predicate<WebElement> predicateFilters = (e)->e.getText().trim().contains("s");
// Predicate<WebElement> predicate = (e)->e.getText().trim().length()==0;
// webElementList.removeIf(predicate);
// webElementList.removeIf(predicateFilters);
// webElementList.forEach(e->System.out.println(e.getText()));
// this.webDriver.findElements(By.tagName("a")).stream().filter(e->e.getText().trim().length()>0 && !e.getText().toLowerCase().contains("s"))
// .map(e->e.getText().toUpperCase())
// .forEach(System.out::println);
TableClass tableClass = new TableClass(this.webDriver);
tableClass.clickCheckBox(predicate);
}
@DataProvider(name = "predicateprovider")
public Object[] dataProvider(){
TableFactory tableFactory = new TableFactory();
return new Object[]{
tableFactory.getPredicate("AU"),
tableFactory.getPredicate("USA"),
tableFactory.getPredicate("male"),
tableFactory.getPredicate("female"),
tableFactory.getPredicate("maleAU"),
tableFactory.getPredicate("femaleAU")
};
}
@AfterTest
public void endTest(){
this.webDriver.quit();
}
}
| UTF-8 | Java | 2,282 | java | TestFunctionalnterfaces.java | Java | [] | null | [] | package com.test;
import com.selenium.functionalinterface.DriverFactory;
import com.selenium.functionalinterface.TableFactory;
import com.table.TableClass;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.annotations.*;
import java.util.List;
import java.util.Locale;
import java.util.function.Predicate;
public class TestFunctionalnterfaces {
public WebDriver webDriver;
@BeforeTest
@Parameters("browser")
public void setupBrowser(@Optional("chrome")String browser){
DriverFactory driverFactory = new DriverFactory();
this.webDriver = driverFactory.getWebDrier(browser);
}
@Test(dataProvider = "predicateprovider")
public void openGoogle(Predicate<List<WebElement>> predicate){
this.webDriver.get("https://vins-udemy.s3.amazonaws.com/java/html/java8-stream-table.html");
// List<WebElement> webElementList = this.webDriver.findElements(By.tagName("a"));
// Predicate<WebElement> predicateFilters = (e)->e.getText().trim().contains("s");
// Predicate<WebElement> predicate = (e)->e.getText().trim().length()==0;
// webElementList.removeIf(predicate);
// webElementList.removeIf(predicateFilters);
// webElementList.forEach(e->System.out.println(e.getText()));
// this.webDriver.findElements(By.tagName("a")).stream().filter(e->e.getText().trim().length()>0 && !e.getText().toLowerCase().contains("s"))
// .map(e->e.getText().toUpperCase())
// .forEach(System.out::println);
TableClass tableClass = new TableClass(this.webDriver);
tableClass.clickCheckBox(predicate);
}
@DataProvider(name = "predicateprovider")
public Object[] dataProvider(){
TableFactory tableFactory = new TableFactory();
return new Object[]{
tableFactory.getPredicate("AU"),
tableFactory.getPredicate("USA"),
tableFactory.getPredicate("male"),
tableFactory.getPredicate("female"),
tableFactory.getPredicate("maleAU"),
tableFactory.getPredicate("femaleAU")
};
}
@AfterTest
public void endTest(){
this.webDriver.quit();
}
}
| 2,282 | 0.668712 | 0.666959 | 61 | 36.409836 | 29.413601 | 148 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.52459 | false | false | 9 |
30b787b12785df8c3996e03711b950d70b17f4bc | 10,806,137,763,464 | 5596d17b8368603481a7fcecc1748bc2b5438772 | /DesignPattern-Factory/src/Factory_Ex1/FactoryPatternDemo.java | fb9df7ed65b7e80bcb7834cbe85303f1a868752a | [] | no_license | OliverZott/Java | https://github.com/OliverZott/Java | 2f9f6e31dafd10048c6e0c58c4dfbf691f083f47 | 2bd0070cc065d829619c36d6ea428b89882c0340 | refs/heads/master | 2021-06-26T22:32:27.907000 | 2021-01-04T16:03:56 | 2021-01-04T16:03:56 | 200,233,645 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Factory_Ex1;
public class FactoryPatternDemo {
public static void main( String[] args ) {
ShapeFactory shapefac = new ShapeFactory();
// get circle object and call draw method
Shape shape1 = shapefac.getShape( "circle" );
shape1.draw();
}
}
| UTF-8 | Java | 272 | java | FactoryPatternDemo.java | Java | [] | null | [] | package Factory_Ex1;
public class FactoryPatternDemo {
public static void main( String[] args ) {
ShapeFactory shapefac = new ShapeFactory();
// get circle object and call draw method
Shape shape1 = shapefac.getShape( "circle" );
shape1.draw();
}
}
| 272 | 0.683824 | 0.672794 | 15 | 17.133333 | 18.782497 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.4 | false | false | 9 |
2009c78a4fb17f5e5ecc8999db894d1a12a7ecfd | 9,835,475,155,742 | b6acb787a644ab293e5a4c7a711ac7cdfca5d0df | /pgkernelgateway/src/main/java/com/electron/mfs/pg/gateway/service/mapper/TransactionPropertyMapper.java | e9fcc12fb9608cbca9482371f24a09d757d7cf44 | [] | no_license | fsfish/electron-backend | https://github.com/fsfish/electron-backend | 3440089550a5222cfa5fa4855302a2404fa34577 | dff5634d0f8e75c090eca3c66aad3c76883b1edd | refs/heads/master | 2021-05-22T00:27:37.984000 | 2020-03-30T18:16:03 | 2020-03-30T18:16:03 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.electron.mfs.pg.gateway.service.mapper;
import com.electron.mfs.pg.gateway.domain.*;
import com.electron.mfs.pg.gateway.service.dto.TransactionPropertyDTO;
import org.mapstruct.*;
/**
* Mapper for the entity {@link TransactionProperty} and its DTO {@link TransactionPropertyDTO}.
*/
@Mapper(componentModel = "spring", uses = {})
public interface TransactionPropertyMapper extends EntityMapper<TransactionPropertyDTO, TransactionProperty> {
default TransactionProperty fromId(Long id) {
if (id == null) {
return null;
}
TransactionProperty transactionProperty = new TransactionProperty();
transactionProperty.setId(id);
return transactionProperty;
}
}
| UTF-8 | Java | 731 | java | TransactionPropertyMapper.java | Java | [] | null | [] | package com.electron.mfs.pg.gateway.service.mapper;
import com.electron.mfs.pg.gateway.domain.*;
import com.electron.mfs.pg.gateway.service.dto.TransactionPropertyDTO;
import org.mapstruct.*;
/**
* Mapper for the entity {@link TransactionProperty} and its DTO {@link TransactionPropertyDTO}.
*/
@Mapper(componentModel = "spring", uses = {})
public interface TransactionPropertyMapper extends EntityMapper<TransactionPropertyDTO, TransactionProperty> {
default TransactionProperty fromId(Long id) {
if (id == null) {
return null;
}
TransactionProperty transactionProperty = new TransactionProperty();
transactionProperty.setId(id);
return transactionProperty;
}
}
| 731 | 0.725034 | 0.725034 | 24 | 29.458334 | 32.049416 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.416667 | false | false | 9 |
82c0670c5ec70ada37a396dec48a0dd796823831 | 4,234,837,803,793 | bf81c2eccee52bc297f755d4734a176fdc9bebe3 | /movies/src/main/java/com/tikal/movies/view/mvp/BasePresenter.java | 343b993afbe583695064a8867d1e27d6c6c59919 | [] | no_license | yaelbe/tikal101 | https://github.com/yaelbe/tikal101 | d3a1b6a0f3659218169c8e15b06fd335ca0fd0d5 | 17088a1c1927897463a9b00c202268070dfffd49 | refs/heads/master | 2021-01-25T07:50:29.335000 | 2017-06-07T21:03:28 | 2017-06-07T21:03:28 | 93,678,043 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tikal.movies.view.mvp;
public interface BasePresenter {
void createView();
void destroyView();
}
| UTF-8 | Java | 119 | java | BasePresenter.java | Java | [] | null | [] | package com.tikal.movies.view.mvp;
public interface BasePresenter {
void createView();
void destroyView();
}
| 119 | 0.714286 | 0.714286 | 7 | 16 | 14.152233 | 34 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 9 |
ced44eef3c8bc553bc1e923ea3214457d30d0b65 | 4,234,837,805,219 | 1e5be6f4dd529d4d00d026a675fb2b24d711640c | /source/TetrisBlock.java | 8cffb77c3482de66fb0572531c5f54cca377c2f0 | [] | no_license | YUJI-Nakazawa/JavaTetris_Swing | https://github.com/YUJI-Nakazawa/JavaTetris_Swing | 509a2309aef2317c7eece553dd68c5ecd1a6a35a | ae53eeb1ca29db857828a0e31690585c9f4cce17 | refs/heads/master | 2021-09-01T14:18:11.649000 | 2017-12-27T12:15:56 | 2017-12-27T12:15:56 | 115,517,611 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /***********************************************************
TetrisBlock
このクラスは、テトリスのブロックに関するクラスです。
***********************************************************/
import java.math.*;
public class TetrisBlock {
public int x;
public int y;
public int[][] block;
public int[][] block2;
protected int FieldRows;
protected int FieldCols;
//protected TetrisBlock CopyBlk;
//コンストラクタ(通常版)
public TetrisBlock(){
//newBlock();
FieldRows = TetrisIni.FieldRows;
FieldCols = TetrisIni.FieldCols;
//CopyBlk = new TetrisBlock();
}//end of TetrisBlock()
//コンストラクタ(block配列サイズのコピー版)
public TetrisBlock(TetrisBlock fromBlk){
FieldRows = TetrisIni.FieldRows;
FieldCols = TetrisIni.FieldCols;
//x = b.x;
//y = b.y;
block = new int[fromBlk.block.length][fromBlk.block.length];
block2 = new int[fromBlk.block2.length][fromBlk.block2.length];
//block = b.copy();
}
public static void valueCopy(TetrisBlock fromBlk, TetrisBlock toBlk){
//b.x = this.x;
//b.y = this.y;
toBlk.x = fromBlk.x;
toBlk.y = fromBlk.y;
//b.block = new int[this.block.length][this.block.length];
//this.copy(b.block = new int[this.block.length][this.block.length]);
//b.block = this.copy();
blockArrayCopy(fromBlk.block, toBlk.block);
blockArrayCopy(fromBlk.block2, toBlk.block2);
}
//新規ブロック
public void newBlock(){
//1〜7の乱数を発生させて、ブロックの種類を決めます
int n = (int)(7 * Math.random() + 1.0);
switch(n){
case 1 :
block = new int[][] { {0, n, 0},
{n, n, n},
{0, 0, 0} };
x=(int)((FieldCols - block.length)/2);
y=0;
break;
case 2 :
block = new int[][] { {n, n, 0},
{0, n, n},
{0, 0, 0} };
x=4;
y=0;
break;
case 3 :
block = new int[][] { {0, n, n},
{n, n, 0},
{0, 0, 0} };
x=4;
y=0;
break;
case 4 :
block = new int[][] { {0, 0, n},
{n, n, n},
{0, 0, 0} };
x=4;
y=0;
break;
case 5 :
block = new int[][] { {n, 0, 0},
{n, n, n},
{0, 0, 0} };
x=4;
y=0;
break;
case 6 :
block = new int[][] { {n, n},
{n, n} };
x=4;
y=0;
break;
case 7 :
block = new int[][] { {0, 0, 0, 0},
{n, n, n, n},
{0, 0, 0, 0},
{0, 0, 0, 0} };
x=3;
y=0;
break;
}//end of switch()
block2 = new int[block.length][block.length];
x=(int)((FieldCols - block.length)/2);
y=0;
}//end of new()
//下移動
public void moveDown(){
y++;
}
//右移動
public void moveRight(){
x++;
}
//左移動
public void moveLeft(){
x--;
}
//右回転
public void turnRight(){
//int[][] block2 = new int[block.length][block.length];
//copy(block2 = new int[block.length][block.length]);
//block2 = copy();
blockArrayCopy(block, block2);
for(int row = 0; row < block.length; row++){
for(int col = 0; col < block.length; col++){
block[col][block.length - 1 - row] = block2[row][col]; //右回転:定式
}
}
}
//左回転
public void turnLeft(){
//int[][] block2 = new int[block.length][block.length];
//copy(block2 = new int[block.length][block.length]);
//block2 = copy();
blockArrayCopy(block, block2);
for(int row = 0; row < block.length; row++){
for(int col = 0; col < block.length; col++){
block[block.length - 1 - col][row] = block2[row][col]; //左回転:定式
}
}
}
//blockをクリア
public void clear(){
//block = new int[][] {{0}};
block = new int[0][0];
}
//blockをコピー
public static void blockArrayCopy(int[][] from_block, int[][] to_block){
//int[][] block2 = new int[block.length][block.length];
//int [][] tmp_block = new int[block.length][block.length];
for(int row=0; row < from_block.length; row++){
for(int col=0; col < from_block.length; col++){
to_block[row][col] = from_block[row][col];
}
}
return;
}
/*
public void blockArrayCopyFrom(TetrisBlock fromBlock){
//int[][] block2 = new int[block.length][block.length];
//int [][] tmp_block = new int[block.length][block.length];
for(int row=0; row < fromBlock.block.length; row++){
for(int col=0; col < fromBlock.block.length; col++){
block[row][col] = fromBlock.block[row][col];
}
}
return;
}
*/
/*
protected void finalize(){
try{
super.finalize();
System.out.println("finalize:" + this);
}
catch(Throwable ex){
}
}
*/
}//end class TetrisBlock
| SHIFT_JIS | Java | 4,899 | java | TetrisBlock.java | Java | [] | null | [] | /***********************************************************
TetrisBlock
このクラスは、テトリスのブロックに関するクラスです。
***********************************************************/
import java.math.*;
public class TetrisBlock {
public int x;
public int y;
public int[][] block;
public int[][] block2;
protected int FieldRows;
protected int FieldCols;
//protected TetrisBlock CopyBlk;
//コンストラクタ(通常版)
public TetrisBlock(){
//newBlock();
FieldRows = TetrisIni.FieldRows;
FieldCols = TetrisIni.FieldCols;
//CopyBlk = new TetrisBlock();
}//end of TetrisBlock()
//コンストラクタ(block配列サイズのコピー版)
public TetrisBlock(TetrisBlock fromBlk){
FieldRows = TetrisIni.FieldRows;
FieldCols = TetrisIni.FieldCols;
//x = b.x;
//y = b.y;
block = new int[fromBlk.block.length][fromBlk.block.length];
block2 = new int[fromBlk.block2.length][fromBlk.block2.length];
//block = b.copy();
}
public static void valueCopy(TetrisBlock fromBlk, TetrisBlock toBlk){
//b.x = this.x;
//b.y = this.y;
toBlk.x = fromBlk.x;
toBlk.y = fromBlk.y;
//b.block = new int[this.block.length][this.block.length];
//this.copy(b.block = new int[this.block.length][this.block.length]);
//b.block = this.copy();
blockArrayCopy(fromBlk.block, toBlk.block);
blockArrayCopy(fromBlk.block2, toBlk.block2);
}
//新規ブロック
public void newBlock(){
//1〜7の乱数を発生させて、ブロックの種類を決めます
int n = (int)(7 * Math.random() + 1.0);
switch(n){
case 1 :
block = new int[][] { {0, n, 0},
{n, n, n},
{0, 0, 0} };
x=(int)((FieldCols - block.length)/2);
y=0;
break;
case 2 :
block = new int[][] { {n, n, 0},
{0, n, n},
{0, 0, 0} };
x=4;
y=0;
break;
case 3 :
block = new int[][] { {0, n, n},
{n, n, 0},
{0, 0, 0} };
x=4;
y=0;
break;
case 4 :
block = new int[][] { {0, 0, n},
{n, n, n},
{0, 0, 0} };
x=4;
y=0;
break;
case 5 :
block = new int[][] { {n, 0, 0},
{n, n, n},
{0, 0, 0} };
x=4;
y=0;
break;
case 6 :
block = new int[][] { {n, n},
{n, n} };
x=4;
y=0;
break;
case 7 :
block = new int[][] { {0, 0, 0, 0},
{n, n, n, n},
{0, 0, 0, 0},
{0, 0, 0, 0} };
x=3;
y=0;
break;
}//end of switch()
block2 = new int[block.length][block.length];
x=(int)((FieldCols - block.length)/2);
y=0;
}//end of new()
//下移動
public void moveDown(){
y++;
}
//右移動
public void moveRight(){
x++;
}
//左移動
public void moveLeft(){
x--;
}
//右回転
public void turnRight(){
//int[][] block2 = new int[block.length][block.length];
//copy(block2 = new int[block.length][block.length]);
//block2 = copy();
blockArrayCopy(block, block2);
for(int row = 0; row < block.length; row++){
for(int col = 0; col < block.length; col++){
block[col][block.length - 1 - row] = block2[row][col]; //右回転:定式
}
}
}
//左回転
public void turnLeft(){
//int[][] block2 = new int[block.length][block.length];
//copy(block2 = new int[block.length][block.length]);
//block2 = copy();
blockArrayCopy(block, block2);
for(int row = 0; row < block.length; row++){
for(int col = 0; col < block.length; col++){
block[block.length - 1 - col][row] = block2[row][col]; //左回転:定式
}
}
}
//blockをクリア
public void clear(){
//block = new int[][] {{0}};
block = new int[0][0];
}
//blockをコピー
public static void blockArrayCopy(int[][] from_block, int[][] to_block){
//int[][] block2 = new int[block.length][block.length];
//int [][] tmp_block = new int[block.length][block.length];
for(int row=0; row < from_block.length; row++){
for(int col=0; col < from_block.length; col++){
to_block[row][col] = from_block[row][col];
}
}
return;
}
/*
public void blockArrayCopyFrom(TetrisBlock fromBlock){
//int[][] block2 = new int[block.length][block.length];
//int [][] tmp_block = new int[block.length][block.length];
for(int row=0; row < fromBlock.block.length; row++){
for(int col=0; col < fromBlock.block.length; col++){
block[row][col] = fromBlock.block[row][col];
}
}
return;
}
*/
/*
protected void finalize(){
try{
super.finalize();
System.out.println("finalize:" + this);
}
catch(Throwable ex){
}
}
*/
}//end class TetrisBlock
| 4,899 | 0.509349 | 0.488502 | 217 | 19.423964 | 18.904684 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.253456 | false | false | 9 |
dac2a9e1a79a74b2f490908811fae567a8f73713 | 18,451,179,535,056 | 4d09b7e6e45e8d7623afaabc8757e5d23af4e26d | /Unit07/src/Triples.java | 91fc0bb2d6a281f12027d9ee1d6f8b7f19eb2852 | [] | no_license | mayarosenbaum/rosenbaum_maya_apcsa-2021 | https://github.com/mayarosenbaum/rosenbaum_maya_apcsa-2021 | 9139e8f75b61543a1a1f901a16a2ec42b3f84b84 | d4ba5201efb4c28e00929bde8171d72039d63c1d | refs/heads/master | 2023-05-27T17:27:06.149000 | 2021-06-10T06:37:22 | 2021-06-10T06:37:22 | 333,548,688 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | //(c) A+ Computer Science
// www.apluscompsci.com
//Name -
import static java.lang.System.*;
import java.lang.Math.*;
public class Triples
{
private int number;
public Triples()
{
this(0);
}
public Triples(int num)
{
number = num;
}
public void setNum(int num)
{
number = num;
}
private int greatestCommonFactor(int a, int b, int c)
{
int limit = Math.min(a, b);
limit = Math.min(limit, c);
for(int n = limit; n >= 2; n--)
{
if ( (a % n == 0) && (b % n == 0) && (c % n == 0) ) {
return n;
}
}
return 1;
}
public String toString()
{
String output="";
int a, b, c;
int max = number;
for(a = 1; a <= max; a++)
{
for(b = a +1; b <= max; b++)
{
for(c = b + 1; c <= max; c++)
{
if(Math.pow(a, 2)+ Math.pow(b, 2)== Math.pow(c, 2))
{
if((a%2==1 && b%2==0)|| (a%2==0 && b%2==1))
{
if(a%2<=1 && b%2<=1 && c%2<=1)
{
if (greatestCommonFactor(a, b, c) == 1) {
output += a + " " + b + " " + c + "\n";
}
}
}
}
}
}
}
return output+"\n";
}
} | UTF-8 | Java | 1,344 | java | Triples.java | Java | [] | null | [] | //(c) A+ Computer Science
// www.apluscompsci.com
//Name -
import static java.lang.System.*;
import java.lang.Math.*;
public class Triples
{
private int number;
public Triples()
{
this(0);
}
public Triples(int num)
{
number = num;
}
public void setNum(int num)
{
number = num;
}
private int greatestCommonFactor(int a, int b, int c)
{
int limit = Math.min(a, b);
limit = Math.min(limit, c);
for(int n = limit; n >= 2; n--)
{
if ( (a % n == 0) && (b % n == 0) && (c % n == 0) ) {
return n;
}
}
return 1;
}
public String toString()
{
String output="";
int a, b, c;
int max = number;
for(a = 1; a <= max; a++)
{
for(b = a +1; b <= max; b++)
{
for(c = b + 1; c <= max; c++)
{
if(Math.pow(a, 2)+ Math.pow(b, 2)== Math.pow(c, 2))
{
if((a%2==1 && b%2==0)|| (a%2==0 && b%2==1))
{
if(a%2<=1 && b%2<=1 && c%2<=1)
{
if (greatestCommonFactor(a, b, c) == 1) {
output += a + " " + b + " " + c + "\n";
}
}
}
}
}
}
}
return output+"\n";
}
} | 1,344 | 0.369048 | 0.348958 | 70 | 18.214285 | 18.171322 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.571429 | false | false | 9 |
703887da33125c463db43822938055470038359f | 19,189,913,938,510 | f73c55c1a55b39acf971e1b8df3bc66f3aa26884 | /src/main/java/org/hawklithm/magneto/server/Server.java | 199566b106373f8d4cdf96d1196c143ed005a871 | [] | no_license | hawklithm/Magneto | https://github.com/hawklithm/Magneto | 5f48e3ef54fd51b8044badfdcc762860a30201f0 | e7f88638b08c30b2d7140c6de74e5d7c508bdfe0 | refs/heads/master | 2021-03-12T22:03:44.990000 | 2014-05-15T09:03:21 | 2014-05-15T09:03:21 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.hawklithm.magneto.server;
import java.io.IOException;
import java.net.SocketAddress;
import org.apache.zookeeper.KeeperException;
import org.hawklithm.h2db.dataobject.RPCRegistInfoDO;
import org.hawklithm.magneto.dataobject.RPCCallInfoDO;
import org.hawklithm.magneto.dataobject.RemoteCallCommunicationProtocol;
import org.hawklithm.magneto.global.MagnetoConstant;
import org.hawklithm.magneto.utils.HessianUtils;
import org.hawklithm.magneto.utils.Jsoner;
import org.hawklithm.magneto.zookeeper.ZookeeperConnectorImpl;
import org.hawklithm.netty.handler.impl.TcpNettyHandler;
import org.hawklithm.netty.server.TcpNettyServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
public class Server extends TcpNettyServer {
@Autowired @Qualifier("connector")
private ZookeeperConnectorImpl connector;
public Server(int port) {
super(port);
setNettyHandler(new TcpNettyHandler(){
@Override
public String onMessageReceived(String message, SocketAddress remoteAddress){
RemoteCallCommunicationProtocol protocol=Jsoner.fromJson(message, RemoteCallCommunicationProtocol.class);
protocol.countPlus();
switch(protocol.getOperateType()){
case MagnetoConstant.RPC_OPERATION_TYPE_REGIST:
// 注册RPC
//TODO 从protocol.getMessage里面检查权限
try {
protocol.setMessage(Jsoner.toJson(HessianUtils.serialize(connector)));
return Jsoner.toJson(protocol);
} catch (IOException e1) {
e1.printStackTrace();
}
break;
case MagnetoConstant.RPC_OPERATION_TYPE_CALL:
// 调用rpc
RPCCallInfoDO callInfo=Jsoner.fromJson(protocol.getMessage(),RPCCallInfoDO.class);
RPCRegistInfoDO registInfo=getServiceInfo(callInfo.getInterfaceName(),callInfo.getVersion());
//TODO 检查权限
/**
* 重组数据并将调用信息回传给客户端
*/
callInfo.setAddress(registInfo.getProviderAddress());
callInfo.setLastVersionTime(registInfo.getTime());
protocol.setMessage(Jsoner.toJson(callInfo));
String result=Jsoner.toJson(protocol);
protocol.setMessage(result);
if (result!=null){
return Jsoner.toJson(protocol);
}
break;
}
return null;
}
});
}
/**
*
* @param serviceName
* @param version
* @return
*/
public RPCRegistInfoDO getServiceInfo(String serviceName,String version){
try {
return connector.getService(serviceName+"/"+version);
} catch (KeeperException | InterruptedException e) {
e.printStackTrace();
return null;
}
}
/**
* @return the connector
*/
public ZookeeperConnectorImpl getConnector() {
return connector;
}
/**
* @param connector the connector to set
*/
public void setConnector(ZookeeperConnectorImpl connector) {
this.connector = connector;
}
}
| UTF-8 | Java | 2,877 | java | Server.java | Java | [] | null | [] | package org.hawklithm.magneto.server;
import java.io.IOException;
import java.net.SocketAddress;
import org.apache.zookeeper.KeeperException;
import org.hawklithm.h2db.dataobject.RPCRegistInfoDO;
import org.hawklithm.magneto.dataobject.RPCCallInfoDO;
import org.hawklithm.magneto.dataobject.RemoteCallCommunicationProtocol;
import org.hawklithm.magneto.global.MagnetoConstant;
import org.hawklithm.magneto.utils.HessianUtils;
import org.hawklithm.magneto.utils.Jsoner;
import org.hawklithm.magneto.zookeeper.ZookeeperConnectorImpl;
import org.hawklithm.netty.handler.impl.TcpNettyHandler;
import org.hawklithm.netty.server.TcpNettyServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
public class Server extends TcpNettyServer {
@Autowired @Qualifier("connector")
private ZookeeperConnectorImpl connector;
public Server(int port) {
super(port);
setNettyHandler(new TcpNettyHandler(){
@Override
public String onMessageReceived(String message, SocketAddress remoteAddress){
RemoteCallCommunicationProtocol protocol=Jsoner.fromJson(message, RemoteCallCommunicationProtocol.class);
protocol.countPlus();
switch(protocol.getOperateType()){
case MagnetoConstant.RPC_OPERATION_TYPE_REGIST:
// 注册RPC
//TODO 从protocol.getMessage里面检查权限
try {
protocol.setMessage(Jsoner.toJson(HessianUtils.serialize(connector)));
return Jsoner.toJson(protocol);
} catch (IOException e1) {
e1.printStackTrace();
}
break;
case MagnetoConstant.RPC_OPERATION_TYPE_CALL:
// 调用rpc
RPCCallInfoDO callInfo=Jsoner.fromJson(protocol.getMessage(),RPCCallInfoDO.class);
RPCRegistInfoDO registInfo=getServiceInfo(callInfo.getInterfaceName(),callInfo.getVersion());
//TODO 检查权限
/**
* 重组数据并将调用信息回传给客户端
*/
callInfo.setAddress(registInfo.getProviderAddress());
callInfo.setLastVersionTime(registInfo.getTime());
protocol.setMessage(Jsoner.toJson(callInfo));
String result=Jsoner.toJson(protocol);
protocol.setMessage(result);
if (result!=null){
return Jsoner.toJson(protocol);
}
break;
}
return null;
}
});
}
/**
*
* @param serviceName
* @param version
* @return
*/
public RPCRegistInfoDO getServiceInfo(String serviceName,String version){
try {
return connector.getService(serviceName+"/"+version);
} catch (KeeperException | InterruptedException e) {
e.printStackTrace();
return null;
}
}
/**
* @return the connector
*/
public ZookeeperConnectorImpl getConnector() {
return connector;
}
/**
* @param connector the connector to set
*/
public void setConnector(ZookeeperConnectorImpl connector) {
this.connector = connector;
}
}
| 2,877 | 0.744227 | 0.743162 | 100 | 27.15 | 25.512104 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.66 | false | false | 9 |
284adf84c1dfcb9672a4ea3993a424c649914837 | 34,626,026,352,673 | 688ca780155712cc9d39e7729704acf6e656bf40 | /Cook&Fridge/app/src/main/java/com/example/bddprojet/Ingredient_Recette.java | dedbc6d77ac932e224cebfab6fbb770668a317cc | [] | no_license | luciedrd/Cook-FridgeAndroid | https://github.com/luciedrd/Cook-FridgeAndroid | 76e2b895d94880bba44ca8605c48d6589346b51b | b1407c7fa44875baf47e27b0a2a330fe5ca53cc6 | refs/heads/main | 2023-01-20T08:07:02.509000 | 2020-11-29T18:32:12 | 2020-11-29T18:32:12 | 316,554,018 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.bddprojet;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import com.example.bddprojet.Models.Ingredient;
import com.example.bddprojet.Models.MonFrigo;
import com.example.bddprojet.Models.Recette;
import com.example.bddprojet.Relations.ingredientAvecRecette;
import com.example.bddprojet.Relations.monFrigoAvecIngredient;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
* Use the {@link Ingredient_Recette#newInstance} factory method to
* create an instance of this fragment.
*/
public class Ingredient_Recette extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String TAG = "Hello";
private ListView liste_recette;
private List<String> recettes=new ArrayList<>();
private List<Integer> recettes_id=new ArrayList<>();
private HashMap recette_map= new HashMap();
private int num_recette;
private Button bt_retour;
public Ingredient_Recette() {
// Required empty public constructor
}
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view =inflater.inflate(R.layout.fragment_ingredient__recette, container, false);
liste_recette=view.findViewById(R.id.liste_recette);
bt_retour=view.findViewById(R.id.button_retour5);
MonFrigo monFrigo = MainActivity.db.monFrigoDao().getMonFrigo();
int frigoID = monFrigo.getFrigoId();
List<monFrigoAvecIngredient> frigoIngredient = MainActivity.db.monFrigoAvecIngredientDao().getMonFrigoIDAvecIngredients(frigoID);
List<Ingredient> ingredients = frigoIngredient.get(0).ingredients;
List <ingredientAvecRecette> ingreRecette=new ArrayList<>();
//Récupère toute les recettes associé au ingrédient présent dans le frigo et on les met dans une liste
for (Ingredient ing : ingredients) {
int i = 0;
ingreRecette = MainActivity.db.ingredientAvecRecetteDao().getRecetteByIngredientID(ing.getIngredientId());
Log.i(TAG, "Dans mon Frigo, il y a les ingrédients suivants: " + ingreRecette);
for (ingredientAvecRecette rec : ingreRecette) {
if (i <= rec.recetteList.size() - 1) {
String r = rec.recetteList.get(i).getNomRecette();
int rec_id = rec.recetteList.get(i).getRecetteId();
Log.i(TAG, "nom Recette: " + r + " id :" + rec_id);
recette_map.putIfAbsent(rec_id,r);
i++;
}
else {
i=0;
}
}
}
Log.i(TAG, "nom Recette: " + recette_map);
recettes.addAll(recette_map.values());
Log.i(TAG, "nom Recette: " + recettes);
ArrayAdapter<String> arrayAdapter_cat=new ArrayAdapter<String>(this.getActivity(),android.R.layout.simple_list_item_1,recettes);
liste_recette.setAdapter(arrayAdapter_cat);
//On récupère l'id de la recette sélectionné que l'on envoie dans un bundle pour le transmettre au fragment recette
liste_recette.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String itemvalue=(String) liste_recette.getItemAtPosition(position);
num_recette= recette_map.keySet().toArray()[position].hashCode();
Log.i(TAG, "nom Recette: " + itemvalue+" id :"+recette_map.keySet().toArray()[position]);
Bundle bundle=new Bundle();
bundle.putInt("ID",num_recette);
FragmentManager fragmentManager=getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
Recette_fragment recette_fragment=new Recette_fragment();
recette_fragment.setArguments(bundle);
fragmentTransaction.replace(R.id.fragment_container,recette_fragment);
fragmentTransaction.commit();
}
});
bt_retour.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MainActivity.fragmentManager.beginTransaction().replace(R.id.fragment_container,new FrigoFragment()).addToBackStack(null).commit();
}
});
return view;
}
@Override
public void onStart()
{
super.onStart();
Log.i(TAG, "on start " + getClass().getSimpleName());
}
@Override
public void onResume()
{
super.onResume();
Log.i(TAG, "on resume " + getClass().getSimpleName());
}
@Override
public void onPause()
{
super.onPause();
Log.i(TAG, "on pause " + getClass().getSimpleName());
}
@Override
public void onStop()
{
super.onStop();
Log.i(TAG, "on stop " + getClass().getSimpleName());
}
@Override
public void onDestroy()
{
super.onDestroy();
Log.i(TAG, "on destroy " + getClass().getSimpleName());
}
@Override
public void onAttach(Context context)
{
super.onAttach(context);
Log.i(TAG, "on attach " + getClass().getSimpleName());
}
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
Log.i(TAG, "on activity created " + getClass().getSimpleName());
}
@Override
public void onDestroyView()
{
super.onDestroyView();
Log.i(TAG, "on destroy view " + getClass().getSimpleName());
}
@Override
public void onDetach()
{
super.onDetach();
Log.i(TAG, "on detach " + getClass().getSimpleName());
}
}
| UTF-8 | Java | 6,747 | java | Ingredient_Recette.java | Java | [] | null | [] | package com.example.bddprojet;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import com.example.bddprojet.Models.Ingredient;
import com.example.bddprojet.Models.MonFrigo;
import com.example.bddprojet.Models.Recette;
import com.example.bddprojet.Relations.ingredientAvecRecette;
import com.example.bddprojet.Relations.monFrigoAvecIngredient;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
* Use the {@link Ingredient_Recette#newInstance} factory method to
* create an instance of this fragment.
*/
public class Ingredient_Recette extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String TAG = "Hello";
private ListView liste_recette;
private List<String> recettes=new ArrayList<>();
private List<Integer> recettes_id=new ArrayList<>();
private HashMap recette_map= new HashMap();
private int num_recette;
private Button bt_retour;
public Ingredient_Recette() {
// Required empty public constructor
}
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view =inflater.inflate(R.layout.fragment_ingredient__recette, container, false);
liste_recette=view.findViewById(R.id.liste_recette);
bt_retour=view.findViewById(R.id.button_retour5);
MonFrigo monFrigo = MainActivity.db.monFrigoDao().getMonFrigo();
int frigoID = monFrigo.getFrigoId();
List<monFrigoAvecIngredient> frigoIngredient = MainActivity.db.monFrigoAvecIngredientDao().getMonFrigoIDAvecIngredients(frigoID);
List<Ingredient> ingredients = frigoIngredient.get(0).ingredients;
List <ingredientAvecRecette> ingreRecette=new ArrayList<>();
//Récupère toute les recettes associé au ingrédient présent dans le frigo et on les met dans une liste
for (Ingredient ing : ingredients) {
int i = 0;
ingreRecette = MainActivity.db.ingredientAvecRecetteDao().getRecetteByIngredientID(ing.getIngredientId());
Log.i(TAG, "Dans mon Frigo, il y a les ingrédients suivants: " + ingreRecette);
for (ingredientAvecRecette rec : ingreRecette) {
if (i <= rec.recetteList.size() - 1) {
String r = rec.recetteList.get(i).getNomRecette();
int rec_id = rec.recetteList.get(i).getRecetteId();
Log.i(TAG, "nom Recette: " + r + " id :" + rec_id);
recette_map.putIfAbsent(rec_id,r);
i++;
}
else {
i=0;
}
}
}
Log.i(TAG, "nom Recette: " + recette_map);
recettes.addAll(recette_map.values());
Log.i(TAG, "nom Recette: " + recettes);
ArrayAdapter<String> arrayAdapter_cat=new ArrayAdapter<String>(this.getActivity(),android.R.layout.simple_list_item_1,recettes);
liste_recette.setAdapter(arrayAdapter_cat);
//On récupère l'id de la recette sélectionné que l'on envoie dans un bundle pour le transmettre au fragment recette
liste_recette.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String itemvalue=(String) liste_recette.getItemAtPosition(position);
num_recette= recette_map.keySet().toArray()[position].hashCode();
Log.i(TAG, "nom Recette: " + itemvalue+" id :"+recette_map.keySet().toArray()[position]);
Bundle bundle=new Bundle();
bundle.putInt("ID",num_recette);
FragmentManager fragmentManager=getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
Recette_fragment recette_fragment=new Recette_fragment();
recette_fragment.setArguments(bundle);
fragmentTransaction.replace(R.id.fragment_container,recette_fragment);
fragmentTransaction.commit();
}
});
bt_retour.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MainActivity.fragmentManager.beginTransaction().replace(R.id.fragment_container,new FrigoFragment()).addToBackStack(null).commit();
}
});
return view;
}
@Override
public void onStart()
{
super.onStart();
Log.i(TAG, "on start " + getClass().getSimpleName());
}
@Override
public void onResume()
{
super.onResume();
Log.i(TAG, "on resume " + getClass().getSimpleName());
}
@Override
public void onPause()
{
super.onPause();
Log.i(TAG, "on pause " + getClass().getSimpleName());
}
@Override
public void onStop()
{
super.onStop();
Log.i(TAG, "on stop " + getClass().getSimpleName());
}
@Override
public void onDestroy()
{
super.onDestroy();
Log.i(TAG, "on destroy " + getClass().getSimpleName());
}
@Override
public void onAttach(Context context)
{
super.onAttach(context);
Log.i(TAG, "on attach " + getClass().getSimpleName());
}
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
Log.i(TAG, "on activity created " + getClass().getSimpleName());
}
@Override
public void onDestroyView()
{
super.onDestroyView();
Log.i(TAG, "on destroy view " + getClass().getSimpleName());
}
@Override
public void onDetach()
{
super.onDetach();
Log.i(TAG, "on detach " + getClass().getSimpleName());
}
}
| 6,747 | 0.652813 | 0.651922 | 182 | 36.016483 | 30.80575 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.653846 | false | false | 9 |
84b2afe7de9af2444e35db2d0c1f543a2fb30a3e | 32,650,341,424,623 | ad1935cbc7cd44045b78d93205f047aa8338ba1e | /flow/app/flow-auth/src/main/java/me/codetalk/messaging/rabbit/aspect/PostMessageAspect.java | 7c73990d28a050c5c9a45fcb6c85fc1ce9aa374c | [] | no_license | guobxu/codetalk-depecrated | https://github.com/guobxu/codetalk-depecrated | 07f7a9f1128de540f495d429547c95ed35873470 | 58ff7d2f7751f8815193a4ed343f4110c892f4f1 | refs/heads/master | 2021-08-19T07:51:14.073000 | 2017-11-25T08:55:22 | 2017-11-25T08:55:22 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package me.codetalk.messaging.rabbit.aspect;
//import org.aspectj.lang.annotation.AfterReturning;
//import org.aspectj.lang.annotation.Aspect;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//
//import me.codetalk.messaging.Message;
//import me.codetalk.messaging.rabbit.aspect.annotation.PostMessage;
//import me.codetalk.util.JsonUtils;
//@Aspect
//@Configuration
public class PostMessageAspect {
// @Autowired
// private RabbitTemplate rabbitTemplate;
//
// @AfterReturning(value = "execution(@me.codetalk.amqp.aspect.annotation.PostMessage * *(..)) "
// + "&& @annotation(annot)",
// returning = "ret")
// public void postSendMsg(PostMessage annot, Object ret) {
// Message mesg = new Message();
// mesg.setApp(annot.app());
// mesg.setModule(annot.module());
// mesg.setData(JsonUtils.toMap(ret));
//
// rabbitTemplate.convertAndSend(annot.value(), null, mesg);
// }
}
| UTF-8 | Java | 1,035 | java | PostMessageAspect.java | Java | [] | null | [] | package me.codetalk.messaging.rabbit.aspect;
//import org.aspectj.lang.annotation.AfterReturning;
//import org.aspectj.lang.annotation.Aspect;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//
//import me.codetalk.messaging.Message;
//import me.codetalk.messaging.rabbit.aspect.annotation.PostMessage;
//import me.codetalk.util.JsonUtils;
//@Aspect
//@Configuration
public class PostMessageAspect {
// @Autowired
// private RabbitTemplate rabbitTemplate;
//
// @AfterReturning(value = "execution(@me.codetalk.amqp.aspect.annotation.PostMessage * *(..)) "
// + "&& @annotation(annot)",
// returning = "ret")
// public void postSendMsg(PostMessage annot, Object ret) {
// Message mesg = new Message();
// mesg.setApp(annot.app());
// mesg.setModule(annot.module());
// mesg.setData(JsonUtils.toMap(ret));
//
// rabbitTemplate.convertAndSend(annot.value(), null, mesg);
// }
}
| 1,035 | 0.742029 | 0.742029 | 32 | 31.34375 | 25.090597 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.375 | false | false | 9 |
25bc90eb7e416c648b2e51e4db49f32a3fad38e0 | 32,650,341,422,898 | ccff0dae9840433fb6d785e1e24f2e591628aac1 | /QQ/src/com/chj/tencent/goo/GooView.java | 5360c0a9f442c377e9793b673f2f832acc9d0c13 | [
"Apache-2.0"
] | permissive | chenhuoju/QQ-5.0 | https://github.com/chenhuoju/QQ-5.0 | 740e0679c536227d5e64a627907360deb7a45d34 | 4c66c9a3424bef993f58306a64309f2704a76708 | refs/heads/master | 2021-01-18T13:54:15.996000 | 2015-08-21T13:28:16 | 2015-08-21T13:28:16 | 41,025,317 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.chj.tencent.goo;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.OvershootInterpolator;
import com.chj.tencent.util.GeometryUtil;
import com.chj.tencent.util.Utils;
import com.nineoldandroids.animation.ValueAnimator;
import com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener;
/**
* @包名:com.chj.tencent.goo
* @类名:GooView
* @作者:陈火炬
* @时间:2015-8-21 下午3:58:06
*
* @描述:粘性控件
*
* @SVN版本号:$Rev$
* @更新人:$Author$
* @更新描述:TODO
*
*/
public class GooView extends View {
private static final String TAG = "GooView";
private Paint mPaint; // 画笔
public GooView(Context context) {
this(context, null);
}
public GooView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public GooView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// 做初始化操作
initView();
}
/**
* 初始化视图
*/
private void initView() {
mPaint = new Paint();
mPaint.setFlags(Paint.ANTI_ALIAS_FLAG);// 去除锯齿
mPaint.setColor(Color.RED);// 设置画笔颜色
}
// 固定圆的坐标
PointF[] mStickPoints = new PointF[]{new PointF(250f, 250f), new PointF(250f, 350f)};
// 拖拽圆的坐标
PointF[] mDragPoints = new PointF[]{new PointF(50f, 250f), new PointF(50f, 350f)};
// 控制点的坐标
PointF mControlPoint = new PointF(150f, 300f);
PointF mDragCenter = new PointF(80f, 80f); // 拖拽圆的圆心
float mDragRadius = 14f; // 拖拽圆的半径
PointF mStickCenter = new PointF(150f, 150f); // 固定圆的圆心
float mStickRadius = 12f; // 固定圆的半径
private int statusBarHeight;// 状态栏高度
float farestDistance = 80f;// 最远距离
private boolean isOutofRange;// 是否超出范围
private boolean isDisappear;// 是否消失
/**
* 绘制方法
*/
@Override
protected void onDraw(Canvas canvas) {
// 计算连接点值, 控制点, 固定圆半径
// 1. 获取固定圆半径(根据两圆圆心距离)
float tempStickRadius = getTempStickRadius();// 临时半径
// 2. 获取直线与圆的交点
float yOffset = mStickCenter.y - mDragCenter.y;
float xOffset = mStickCenter.x - mDragCenter.x;
Double lineK = null;
if (xOffset != 0) {
lineK = (double) (yOffset / xOffset);
}
// 通过几何图形工具获取交点坐标
mDragPoints = GeometryUtil.getIntersectionPoints(mDragCenter, mDragRadius, lineK);
mStickPoints = GeometryUtil.getIntersectionPoints(mStickCenter, tempStickRadius, lineK);
// 3. 获取控制点坐标
mControlPoint = GeometryUtil.getMiddlePoint(mDragCenter, mStickCenter);
// 保存画布状态
canvas.save();
canvas.translate(0, -statusBarHeight);
// 画出最大范围(参考用)
mPaint.setStyle(Style.STROKE);//设置画笔样式
canvas.drawCircle(mStickCenter.x, mStickCenter.y, farestDistance, mPaint);
mPaint.setStyle(Style.FILL);
if(!isDisappear){
if(!isOutofRange){
// Ⅲ.画连接部分
Path path = new Path();
// ①跳到点1
path.moveTo(mStickPoints[0].x, mStickPoints[0].y);
// ②画曲线1 -> 2(前两个参数是控制点坐标,后两个参数是结束点坐标)
path.quadTo(mControlPoint.x, mControlPoint.y, mDragPoints[0].x, mDragPoints[0].y);
// ③画直线2 -> 3
path.lineTo(mDragPoints[1].x, mDragPoints[1].y);
// ④画曲线3 -> 4
path.quadTo(mControlPoint.x, mControlPoint.y, mStickPoints[1].x, mStickPoints[1].y);
path.close();
canvas.drawPath(path, mPaint);
// 画附着点(参考用)
mPaint.setColor(Color.BLUE);
canvas.drawCircle(mDragPoints[0].x, mDragPoints[0].y, 3f, mPaint);
canvas.drawCircle(mDragPoints[1].x, mDragPoints[1].y, 3f, mPaint);
canvas.drawCircle(mStickPoints[0].x, mStickPoints[0].y, 3f, mPaint);
canvas.drawCircle(mStickPoints[1].x, mStickPoints[1].y, 3f, mPaint);
mPaint.setColor(Color.RED);
// Ⅱ.画固定圆
canvas.drawCircle(mStickCenter.x, mStickCenter.y, tempStickRadius, mPaint);
}
// Ⅰ.画拖拽圆
canvas.drawCircle(mDragCenter.x, mDragCenter.y, mDragRadius, mPaint);
}
// 恢复上次的保存状态
canvas.restore();
}
/**
* 获取固定圆半径(根据两圆圆心距离)
*
* @return
*/
private float getTempStickRadius() {
// 两点之间的距离
float distance = GeometryUtil.getDistanceBetween2Points(mDragCenter, mStickCenter);
// if(distance>farestDistance){
// distance=farestDistance;
// }
// 优化之后(求最小值)
distance = Math.min(distance, farestDistance);
// 0.0f -> 1.0f >>> 1.0 -> 0.0
float percent = distance / farestDistance;
Log.d(TAG, "percent:" + percent);
// percent , 100% -> 20%
return evaluate(percent, mStickRadius, mStickRadius * 0.2f);
}
/**
* 估值器
*
* @param fraction
* @param startValue
* @param endValue
* @return
*/
public Float evaluate(float fraction, Number startValue, Number endValue) {
float startFloat = startValue.floatValue();
return startFloat + fraction * (endValue.floatValue() - startFloat);
}
/**
* 处理触摸事件
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
float x;
float y;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN :// 手指按下
isOutofRange = false;
isDisappear=false;
x = event.getRawX();
y = event.getRawY();
updateDragCenter(x, y);
break;
case MotionEvent.ACTION_MOVE :// 手指触摸滑动
x = event.getRawX();
y = event.getRawY();
updateDragCenter(x, y);
// 处理断开事件
float distance = GeometryUtil.getDistanceBetween2Points(mDragCenter, mStickCenter);
if(distance > farestDistance){
// 断开
isOutofRange = true;
invalidate();
}
break;
case MotionEvent.ACTION_UP :// 手指松开
if(isOutofRange){
float newDistance=GeometryUtil.getDistanceBetween2Points(mDragCenter, mStickCenter);
if(newDistance>farestDistance){
// a. 拖拽超出范围,断开, 松手, 消失
isDisappear=true;
invalidate();
}else {
// b. 拖拽超出范围,断开,放回去了,恢复
updateDragCenter(mStickCenter.x, mStickCenter.y);
}
}else {
// c. 拖拽没超出范围, 松手,弹回去
final PointF tempDragCenter=new PointF(mDragCenter.x, mDragCenter.y);// 临时坐标
ValueAnimator mValueAnimator = ValueAnimator.ofFloat(1.0f);
mValueAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
// 0.0 -> 1.0f
float percent=valueAnimator.getAnimatedFraction();
PointF pointF = GeometryUtil.getPointByPercent(tempDragCenter, mStickCenter, percent);
updateDragCenter(pointF.x, pointF.y);
}
});
mValueAnimator.setInterpolator(new OvershootInterpolator(4));// 差值器
mValueAnimator.setDuration(500);
mValueAnimator.start();
}
break;
default :
break;
}
return true;
}
/**
* 更新拖拽圆圆心坐标,并重绘界面
*
* @param x
* @param y
*/
private void updateDragCenter(float x, float y) {
mDragCenter.set(x, y);// 设置坐标
invalidate();// 重绘
}
/**
* 当尺寸发生变化时,此方法调用
*/
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
// 获取状态栏高度
statusBarHeight = Utils.getStatusBarHeight(this);
}
}
| GB18030 | Java | 7,881 | java | GooView.java | Java | [
{
"context": "\n * @包名:com.chj.tencent.goo\n * @类名:GooView\n * @作者:陈火炬\n * @时间:2015-8-21 下午3:58:06\n * \n * @描述:粘性控件\n * \n *",
"end": 688,
"score": 0.9965367317199707,
"start": 685,
"tag": "NAME",
"value": "陈火炬"
}
] | null | [] | package com.chj.tencent.goo;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.OvershootInterpolator;
import com.chj.tencent.util.GeometryUtil;
import com.chj.tencent.util.Utils;
import com.nineoldandroids.animation.ValueAnimator;
import com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener;
/**
* @包名:com.chj.tencent.goo
* @类名:GooView
* @作者:陈火炬
* @时间:2015-8-21 下午3:58:06
*
* @描述:粘性控件
*
* @SVN版本号:$Rev$
* @更新人:$Author$
* @更新描述:TODO
*
*/
public class GooView extends View {
private static final String TAG = "GooView";
private Paint mPaint; // 画笔
public GooView(Context context) {
this(context, null);
}
public GooView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public GooView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// 做初始化操作
initView();
}
/**
* 初始化视图
*/
private void initView() {
mPaint = new Paint();
mPaint.setFlags(Paint.ANTI_ALIAS_FLAG);// 去除锯齿
mPaint.setColor(Color.RED);// 设置画笔颜色
}
// 固定圆的坐标
PointF[] mStickPoints = new PointF[]{new PointF(250f, 250f), new PointF(250f, 350f)};
// 拖拽圆的坐标
PointF[] mDragPoints = new PointF[]{new PointF(50f, 250f), new PointF(50f, 350f)};
// 控制点的坐标
PointF mControlPoint = new PointF(150f, 300f);
PointF mDragCenter = new PointF(80f, 80f); // 拖拽圆的圆心
float mDragRadius = 14f; // 拖拽圆的半径
PointF mStickCenter = new PointF(150f, 150f); // 固定圆的圆心
float mStickRadius = 12f; // 固定圆的半径
private int statusBarHeight;// 状态栏高度
float farestDistance = 80f;// 最远距离
private boolean isOutofRange;// 是否超出范围
private boolean isDisappear;// 是否消失
/**
* 绘制方法
*/
@Override
protected void onDraw(Canvas canvas) {
// 计算连接点值, 控制点, 固定圆半径
// 1. 获取固定圆半径(根据两圆圆心距离)
float tempStickRadius = getTempStickRadius();// 临时半径
// 2. 获取直线与圆的交点
float yOffset = mStickCenter.y - mDragCenter.y;
float xOffset = mStickCenter.x - mDragCenter.x;
Double lineK = null;
if (xOffset != 0) {
lineK = (double) (yOffset / xOffset);
}
// 通过几何图形工具获取交点坐标
mDragPoints = GeometryUtil.getIntersectionPoints(mDragCenter, mDragRadius, lineK);
mStickPoints = GeometryUtil.getIntersectionPoints(mStickCenter, tempStickRadius, lineK);
// 3. 获取控制点坐标
mControlPoint = GeometryUtil.getMiddlePoint(mDragCenter, mStickCenter);
// 保存画布状态
canvas.save();
canvas.translate(0, -statusBarHeight);
// 画出最大范围(参考用)
mPaint.setStyle(Style.STROKE);//设置画笔样式
canvas.drawCircle(mStickCenter.x, mStickCenter.y, farestDistance, mPaint);
mPaint.setStyle(Style.FILL);
if(!isDisappear){
if(!isOutofRange){
// Ⅲ.画连接部分
Path path = new Path();
// ①跳到点1
path.moveTo(mStickPoints[0].x, mStickPoints[0].y);
// ②画曲线1 -> 2(前两个参数是控制点坐标,后两个参数是结束点坐标)
path.quadTo(mControlPoint.x, mControlPoint.y, mDragPoints[0].x, mDragPoints[0].y);
// ③画直线2 -> 3
path.lineTo(mDragPoints[1].x, mDragPoints[1].y);
// ④画曲线3 -> 4
path.quadTo(mControlPoint.x, mControlPoint.y, mStickPoints[1].x, mStickPoints[1].y);
path.close();
canvas.drawPath(path, mPaint);
// 画附着点(参考用)
mPaint.setColor(Color.BLUE);
canvas.drawCircle(mDragPoints[0].x, mDragPoints[0].y, 3f, mPaint);
canvas.drawCircle(mDragPoints[1].x, mDragPoints[1].y, 3f, mPaint);
canvas.drawCircle(mStickPoints[0].x, mStickPoints[0].y, 3f, mPaint);
canvas.drawCircle(mStickPoints[1].x, mStickPoints[1].y, 3f, mPaint);
mPaint.setColor(Color.RED);
// Ⅱ.画固定圆
canvas.drawCircle(mStickCenter.x, mStickCenter.y, tempStickRadius, mPaint);
}
// Ⅰ.画拖拽圆
canvas.drawCircle(mDragCenter.x, mDragCenter.y, mDragRadius, mPaint);
}
// 恢复上次的保存状态
canvas.restore();
}
/**
* 获取固定圆半径(根据两圆圆心距离)
*
* @return
*/
private float getTempStickRadius() {
// 两点之间的距离
float distance = GeometryUtil.getDistanceBetween2Points(mDragCenter, mStickCenter);
// if(distance>farestDistance){
// distance=farestDistance;
// }
// 优化之后(求最小值)
distance = Math.min(distance, farestDistance);
// 0.0f -> 1.0f >>> 1.0 -> 0.0
float percent = distance / farestDistance;
Log.d(TAG, "percent:" + percent);
// percent , 100% -> 20%
return evaluate(percent, mStickRadius, mStickRadius * 0.2f);
}
/**
* 估值器
*
* @param fraction
* @param startValue
* @param endValue
* @return
*/
public Float evaluate(float fraction, Number startValue, Number endValue) {
float startFloat = startValue.floatValue();
return startFloat + fraction * (endValue.floatValue() - startFloat);
}
/**
* 处理触摸事件
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
float x;
float y;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN :// 手指按下
isOutofRange = false;
isDisappear=false;
x = event.getRawX();
y = event.getRawY();
updateDragCenter(x, y);
break;
case MotionEvent.ACTION_MOVE :// 手指触摸滑动
x = event.getRawX();
y = event.getRawY();
updateDragCenter(x, y);
// 处理断开事件
float distance = GeometryUtil.getDistanceBetween2Points(mDragCenter, mStickCenter);
if(distance > farestDistance){
// 断开
isOutofRange = true;
invalidate();
}
break;
case MotionEvent.ACTION_UP :// 手指松开
if(isOutofRange){
float newDistance=GeometryUtil.getDistanceBetween2Points(mDragCenter, mStickCenter);
if(newDistance>farestDistance){
// a. 拖拽超出范围,断开, 松手, 消失
isDisappear=true;
invalidate();
}else {
// b. 拖拽超出范围,断开,放回去了,恢复
updateDragCenter(mStickCenter.x, mStickCenter.y);
}
}else {
// c. 拖拽没超出范围, 松手,弹回去
final PointF tempDragCenter=new PointF(mDragCenter.x, mDragCenter.y);// 临时坐标
ValueAnimator mValueAnimator = ValueAnimator.ofFloat(1.0f);
mValueAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
// 0.0 -> 1.0f
float percent=valueAnimator.getAnimatedFraction();
PointF pointF = GeometryUtil.getPointByPercent(tempDragCenter, mStickCenter, percent);
updateDragCenter(pointF.x, pointF.y);
}
});
mValueAnimator.setInterpolator(new OvershootInterpolator(4));// 差值器
mValueAnimator.setDuration(500);
mValueAnimator.start();
}
break;
default :
break;
}
return true;
}
/**
* 更新拖拽圆圆心坐标,并重绘界面
*
* @param x
* @param y
*/
private void updateDragCenter(float x, float y) {
mDragCenter.set(x, y);// 设置坐标
invalidate();// 重绘
}
/**
* 当尺寸发生变化时,此方法调用
*/
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
// 获取状态栏高度
statusBarHeight = Utils.getStatusBarHeight(this);
}
}
| 7,881 | 0.678404 | 0.660798 | 274 | 24.70438 | 23.558674 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.843066 | false | false | 9 |
a1309409b8fa6a5071201889e56a72548bf079a6 | 24,979,529,820,759 | 366ddff737c8264dd401d66228d352bd464b8371 | /mapbox/src/main/java/com/mapbox/mapboxsdk/views/MapViewScaleGestureDetectorListener.java | d3648665d256b78d4f8148d5ec47e60849caf91e | [] | no_license | EniasCailliau/ActivityFeedback-RSLTC | https://github.com/EniasCailliau/ActivityFeedback-RSLTC | 2278ace84f5d2579eeeac48f56957f83c2e2479f | 72d504d3300773fa988ad15b9dba663044bf1974 | refs/heads/master | 2017-05-17T12:29:43.673000 | 2016-06-14T22:17:58 | 2016-06-14T22:17:58 | 53,212,560 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* */ package com.mapbox.mapboxsdk.views;
/* */
/* */ import android.view.ScaleGestureDetector;
/* */ import android.view.ScaleGestureDetector.OnScaleGestureListener;
/* */ import java.util.concurrent.atomic.AtomicBoolean;
/* */ import java.util.concurrent.atomic.AtomicInteger;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class MapViewScaleGestureDetectorListener
/* */ implements ScaleGestureDetector.OnScaleGestureListener
/* */ {
/* */ private float lastFocusX;
/* */ private float lastFocusY;
/* */ private float firstSpan;
/* */ private final MapView mapView;
/* */ private boolean scaling;
/* */ private float currentScale;
/* */
/* */ public MapViewScaleGestureDetectorListener(MapView mv)
/* */ {
/* 30 */ this.mapView = mv;
/* */ }
/* */
/* */ public boolean onScaleBegin(ScaleGestureDetector detector)
/* */ {
/* 35 */ this.lastFocusX = detector.getFocusX();
/* 36 */ this.lastFocusY = detector.getFocusY();
/* 37 */ this.firstSpan = detector.getCurrentSpan();
/* 38 */ this.currentScale = 1.0F;
/* 39 */ if (!this.mapView.isAnimating()) {
/* 40 */ this.mapView.mIsAnimating.set(true);
/* 41 */ this.mapView.getController().aboutToStartAnimation(this.lastFocusX, this.lastFocusY);
/* 42 */ this.scaling = true;
/* */ }
/* 44 */ return true;
/* */ }
/* */
/* */ public boolean onScale(ScaleGestureDetector detector)
/* */ {
/* 49 */ if (!this.scaling) {
/* 50 */ return true;
/* */ }
/* 52 */ this.currentScale = (detector.getCurrentSpan() / this.firstSpan);
/* */
/* 54 */ float focusX = detector.getFocusX();
/* 55 */ float focusY = detector.getFocusY();
/* */
/* 57 */ this.mapView.setScale(this.currentScale);
/* 58 */ this.mapView.getController().offsetDeltaScroll(this.lastFocusX - focusX, this.lastFocusY - focusY);
/* */
/* 60 */ this.mapView.getController().panBy(this.lastFocusX - focusX, this.lastFocusY - focusY, true);
/* */
/* */
/* 63 */ this.lastFocusX = focusX;
/* 64 */ this.lastFocusY = focusY;
/* 65 */ return true;
/* */ }
/* */
/* */ public void onScaleEnd(ScaleGestureDetector detector)
/* */ {
/* 70 */ if (!this.scaling) {
/* 71 */ return;
/* */ }
/* 73 */ float preZoom = this.mapView.getZoomLevel(false);
/* 74 */ float newZoom = (float)(Math.log(this.currentScale) / Math.log(2.0D) + preZoom);
/* 75 */ this.mapView.mTargetZoomLevel.set(Float.floatToIntBits(newZoom));
/* 76 */ this.mapView.getController().onAnimationEnd();
/* 77 */ this.scaling = false;
/* */ }
/* */
/* 80 */ private static String TAG = "Mapbox scaleDetector";
/* */ }
/* Location: /home/enias/Downloads/jar/mapbox-android-sdk-0.4.0.jar!/com/mapbox/mapboxsdk/views/MapViewScaleGestureDetectorListener.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | UTF-8 | Java | 3,113 | java | MapViewScaleGestureDetectorListener.java | Java | [
{
"context": "or\";\n/* */ }\n\n\n/* Location: /home/enias/Downloads/jar/mapbox-android-sdk-0.4.0.jar!/com/m",
"end": 2929,
"score": 0.9991298913955688,
"start": 2924,
"tag": "USERNAME",
"value": "enias"
}
] | null | [] | /* */ package com.mapbox.mapboxsdk.views;
/* */
/* */ import android.view.ScaleGestureDetector;
/* */ import android.view.ScaleGestureDetector.OnScaleGestureListener;
/* */ import java.util.concurrent.atomic.AtomicBoolean;
/* */ import java.util.concurrent.atomic.AtomicInteger;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class MapViewScaleGestureDetectorListener
/* */ implements ScaleGestureDetector.OnScaleGestureListener
/* */ {
/* */ private float lastFocusX;
/* */ private float lastFocusY;
/* */ private float firstSpan;
/* */ private final MapView mapView;
/* */ private boolean scaling;
/* */ private float currentScale;
/* */
/* */ public MapViewScaleGestureDetectorListener(MapView mv)
/* */ {
/* 30 */ this.mapView = mv;
/* */ }
/* */
/* */ public boolean onScaleBegin(ScaleGestureDetector detector)
/* */ {
/* 35 */ this.lastFocusX = detector.getFocusX();
/* 36 */ this.lastFocusY = detector.getFocusY();
/* 37 */ this.firstSpan = detector.getCurrentSpan();
/* 38 */ this.currentScale = 1.0F;
/* 39 */ if (!this.mapView.isAnimating()) {
/* 40 */ this.mapView.mIsAnimating.set(true);
/* 41 */ this.mapView.getController().aboutToStartAnimation(this.lastFocusX, this.lastFocusY);
/* 42 */ this.scaling = true;
/* */ }
/* 44 */ return true;
/* */ }
/* */
/* */ public boolean onScale(ScaleGestureDetector detector)
/* */ {
/* 49 */ if (!this.scaling) {
/* 50 */ return true;
/* */ }
/* 52 */ this.currentScale = (detector.getCurrentSpan() / this.firstSpan);
/* */
/* 54 */ float focusX = detector.getFocusX();
/* 55 */ float focusY = detector.getFocusY();
/* */
/* 57 */ this.mapView.setScale(this.currentScale);
/* 58 */ this.mapView.getController().offsetDeltaScroll(this.lastFocusX - focusX, this.lastFocusY - focusY);
/* */
/* 60 */ this.mapView.getController().panBy(this.lastFocusX - focusX, this.lastFocusY - focusY, true);
/* */
/* */
/* 63 */ this.lastFocusX = focusX;
/* 64 */ this.lastFocusY = focusY;
/* 65 */ return true;
/* */ }
/* */
/* */ public void onScaleEnd(ScaleGestureDetector detector)
/* */ {
/* 70 */ if (!this.scaling) {
/* 71 */ return;
/* */ }
/* 73 */ float preZoom = this.mapView.getZoomLevel(false);
/* 74 */ float newZoom = (float)(Math.log(this.currentScale) / Math.log(2.0D) + preZoom);
/* 75 */ this.mapView.mTargetZoomLevel.set(Float.floatToIntBits(newZoom));
/* 76 */ this.mapView.getController().onAnimationEnd();
/* 77 */ this.scaling = false;
/* */ }
/* */
/* 80 */ private static String TAG = "Mapbox scaleDetector";
/* */ }
/* Location: /home/enias/Downloads/jar/mapbox-android-sdk-0.4.0.jar!/com/mapbox/mapboxsdk/views/MapViewScaleGestureDetectorListener.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | 3,113 | 0.569547 | 0.546418 | 87 | 34.793102 | 28.77704 | 150 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.471264 | false | false | 9 |
6ec8fd6bb5ece6f5aefc1d5afddb6820e6dcff13 | 9,706,626,100,052 | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.mm/classes.jar/coil/memory/RequestDelegate.java | b4134236a316f770436b47d78135a327aea5a42c | [] | no_license | tsuzcx/qq_apk | https://github.com/tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651000 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | false | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | 2022-01-31T06:56:43 | 2022-01-31T09:46:26 | 167,304 | 0 | 1 | 1 | Java | false | false | package coil.memory;
import androidx.lifecycle.e;
import androidx.lifecycle.q;
import kotlin.Metadata;
import kotlin.g.b.s;
@Metadata(d1={""}, d2={"Lcoil/memory/RequestDelegate;", "Landroidx/lifecycle/DefaultLifecycleObserver;", "()V", "complete", "", "dispose", "onDestroy", "owner", "Landroidx/lifecycle/LifecycleOwner;", "Lcoil/memory/BaseRequestDelegate;", "Lcoil/memory/ViewTargetRequestDelegate;", "coil-base_release"}, k=1, mv={1, 5, 1}, xi=48)
public abstract class RequestDelegate
implements e
{
public void GK() {}
public void dispose() {}
public final void onDestroy(q paramq)
{
s.u(paramq, "owner");
dispose();
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mm\classes3.jar
* Qualified Name: coil.memory.RequestDelegate
* JD-Core Version: 0.7.0.1
*/ | UTF-8 | Java | 853 | java | RequestDelegate.java | Java | [] | null | [] | package coil.memory;
import androidx.lifecycle.e;
import androidx.lifecycle.q;
import kotlin.Metadata;
import kotlin.g.b.s;
@Metadata(d1={""}, d2={"Lcoil/memory/RequestDelegate;", "Landroidx/lifecycle/DefaultLifecycleObserver;", "()V", "complete", "", "dispose", "onDestroy", "owner", "Landroidx/lifecycle/LifecycleOwner;", "Lcoil/memory/BaseRequestDelegate;", "Lcoil/memory/ViewTargetRequestDelegate;", "coil-base_release"}, k=1, mv={1, 5, 1}, xi=48)
public abstract class RequestDelegate
implements e
{
public void GK() {}
public void dispose() {}
public final void onDestroy(q paramq)
{
s.u(paramq, "owner");
dispose();
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mm\classes3.jar
* Qualified Name: coil.memory.RequestDelegate
* JD-Core Version: 0.7.0.1
*/ | 853 | 0.665885 | 0.650645 | 31 | 25.709677 | 57.975632 | 327 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.967742 | false | false | 9 |
e1b26462d898864da43095a2ef5969d049c69cbf | 22,497,038,737,029 | 5b55d1da0700c0312ea352b11783221c0d3a8a69 | /src/main/java/com/epam/rd/java/basic/repairagency/web/command/impl/base/RedirectToUrlPatternPostCommand.java | f9b2b014ffe45747c36f44426beaab7259fd9aeb | [] | no_license | ArtemKnysh/RepairAgency | https://github.com/ArtemKnysh/RepairAgency | fe3712b34a9a81e4c09511175142b9275ef90388 | 13aba7f06ac1419575209b597ba15b08e9eeb9f3 | refs/heads/master | 2023-08-15T07:05:35.964000 | 2021-09-27T21:07:45 | 2021-09-27T21:07:45 | 409,984,342 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.epam.rd.java.basic.repairagency.web.command.impl.base;
import com.epam.rd.java.basic.repairagency.util.web.WebUtil;
import com.epam.rd.java.basic.repairagency.web.command.Command;
import com.epam.rd.java.basic.repairagency.web.command.Method;
import com.epam.rd.java.basic.repairagency.web.command.annotation.ProcessMethods;
import com.epam.rd.java.basic.repairagency.web.command.annotation.ProcessUrlPatterns;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ProcessUrlPatterns({"/admin/user/list",
"/customer/repair-request/list",
"/customer/user/list",
"/manager/customer/view",
"/manager/master/view",
"/manager/repair-request/list",
"/manager/repair-request/view",
"/master/customer/view",
"/master/repair-request/list",
"/master/repair-request/view"})
@ProcessMethods(Method.POST)
public class RedirectToUrlPatternPostCommand implements Command {
private static final Logger log = LogManager.getLogger(RedirectToUrlPatternPostCommand.class);
@Override
public void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log.info("{}: {}", request.getMethod(), WebUtil.getUrlPattern(request));
String address = WebUtil.getAppName(request) + WebUtil.getUrlPattern(request);
response.sendRedirect(address);
}
}
| UTF-8 | Java | 1,589 | java | RedirectToUrlPatternPostCommand.java | Java | [] | null | [] | package com.epam.rd.java.basic.repairagency.web.command.impl.base;
import com.epam.rd.java.basic.repairagency.util.web.WebUtil;
import com.epam.rd.java.basic.repairagency.web.command.Command;
import com.epam.rd.java.basic.repairagency.web.command.Method;
import com.epam.rd.java.basic.repairagency.web.command.annotation.ProcessMethods;
import com.epam.rd.java.basic.repairagency.web.command.annotation.ProcessUrlPatterns;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ProcessUrlPatterns({"/admin/user/list",
"/customer/repair-request/list",
"/customer/user/list",
"/manager/customer/view",
"/manager/master/view",
"/manager/repair-request/list",
"/manager/repair-request/view",
"/master/customer/view",
"/master/repair-request/list",
"/master/repair-request/view"})
@ProcessMethods(Method.POST)
public class RedirectToUrlPatternPostCommand implements Command {
private static final Logger log = LogManager.getLogger(RedirectToUrlPatternPostCommand.class);
@Override
public void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log.info("{}: {}", request.getMethod(), WebUtil.getUrlPattern(request));
String address = WebUtil.getAppName(request) + WebUtil.getUrlPattern(request);
response.sendRedirect(address);
}
}
| 1,589 | 0.753933 | 0.752675 | 38 | 40.815788 | 29.753244 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.763158 | false | false | 9 |
45077e7b9d59fe19b9cbaf66b04af2ef5fba2f60 | 19,567,871,022,128 | facce2ebb263d9e7b37cc08462d19b3dd86e0df9 | /ex03.java | 07fc709b0fe60ea9513b0f8b0bd90e18a79a7f3a | [] | no_license | TiagoFigueiredoAfonso/LP1-IFMS | https://github.com/TiagoFigueiredoAfonso/LP1-IFMS | 0941c25f5faed8993da95225c79b07e34df17916 | e83ed2e72824c9d8ae16ac53f9a85460e23b21fb | refs/heads/main | 2023-08-17T17:05:57.512000 | 2021-09-14T17:32:27 | 2021-09-14T17:32:27 | 405,227,533 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
3. Faça um programa que calcule a média aritmética das notas de 10 alunos de uma disciplina e
determine o número de alunos que tiveram nota superior à média calculadao
*/
import java.util.Scanner;
public class ex03 {
public static void main(String[] args) {
Scanner leia = new Scanner(System.in);
double vet[] = new double[5], acumul = 0.0, media = 0.0;
int aluno = 0;
for (int i = 0; i < vet.length; i++) {
System.out.println((i + 1) + "º nota: ");
vet[i] = leia.nextDouble();
acumul += vet[i];
media = acumul / 5;
}
for (int i = 0; i < vet.length; i++) {
if (vet[i] > media) {
aluno++;
}
}
System.out.printf("Média: %.1f%n" , media);
System.out.println("Quantidade de alunos acima da média: " + aluno);
}
}
| UTF-8 | Java | 896 | java | ex03.java | Java | [] | null | [] | /*
3. Faça um programa que calcule a média aritmética das notas de 10 alunos de uma disciplina e
determine o número de alunos que tiveram nota superior à média calculadao
*/
import java.util.Scanner;
public class ex03 {
public static void main(String[] args) {
Scanner leia = new Scanner(System.in);
double vet[] = new double[5], acumul = 0.0, media = 0.0;
int aluno = 0;
for (int i = 0; i < vet.length; i++) {
System.out.println((i + 1) + "º nota: ");
vet[i] = leia.nextDouble();
acumul += vet[i];
media = acumul / 5;
}
for (int i = 0; i < vet.length; i++) {
if (vet[i] > media) {
aluno++;
}
}
System.out.printf("Média: %.1f%n" , media);
System.out.println("Quantidade de alunos acima da média: " + aluno);
}
}
| 896 | 0.531003 | 0.512965 | 31 | 27.612904 | 25.862761 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.580645 | false | false | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.