blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
332
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
50
| license_type
stringclasses 2
values | repo_name
stringlengths 7
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 557
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
684M
⌀ | star_events_count
int64 0
77.7k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 82
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
5.41M
| extension
stringclasses 11
values | content
stringlengths 7
5.41M
| authors
listlengths 1
1
| author
stringlengths 0
161
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b9a8565a59c9f2c0fd2f839c4883a81664b9590d | 99f24574bc4374472e09c78c61286ba93ac5c853 | /fit-track/src/main/java/com/revature/repos/ExerciseRepo.java | d73cec9906a602967ac7435139135f143f1c76f9 | [] | no_license | avicuna/p2-server | bd11d00aa746fa6d1374fad91a6966c8230cf050 | 7df5f5261e85daa667aba9b5587079b8c4e42c2e | refs/heads/master | 2020-03-28T11:26:16.214141 | 2018-09-25T04:28:52 | 2018-09-25T04:28:52 | 148,213,049 | 0 | 0 | null | 2018-09-25T04:28:53 | 2018-09-10T20:11:26 | Java | UTF-8 | Java | false | false | 269 | java | package com.revature.repos;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.revature.models.Exercise;
@Repository
public interface ExerciseRepo extends JpaRepository<Exercise, Integer>{
}
| [
"[email protected]"
] | |
73bfbed537549ad4e12e4f0778f7e335626881fc | c184fe3c7fd4806e28a22af491906e36a338f861 | /src/main/java/org/gogym/gim/socket/tcp/handler/nettyHandler/HeartBeatServerHandler.java | 5d2383b7d1d24d452a7f42e6c238a24b687383dc | [] | no_license | huangdehui2013/gim-all | 906ac0fa7fe49458c6b79e3deac50a8238856391 | 6e7a99a4b6afeb5930298f00abb24986fe5ed482 | refs/heads/master | 2020-11-25T15:14:22.641523 | 2019-08-08T06:29:24 | 2019-08-08T06:29:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,108 | java | package org.gogym.gim.socket.tcp.handler.nettyHandler;
import org.gogym.getty.channel.ChannelHandlerContext;
import org.gogym.getty.channel.ChannelInboundHandlerAdapter;
import org.gogym.getty.handler.timeout.IdleState;
import org.gogym.getty.handler.timeout.IdleStateEvent;
/**
* 心跳检测
*
* @ClassName HeartBeatServerHandler
* @Description TODO
* @author kokjuis [email protected]
* @date 2016-9-26
* @content
*/
public class HeartBeatServerHandler extends ChannelInboundHandlerAdapter {
private int loss_connect_time = 0;
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
throws Exception {
if (evt instanceof IdleStateEvent) {
IdleStateEvent event = (IdleStateEvent) evt;
if (event.state() == IdleState.READER_IDLE) {
loss_connect_time++;
if (loss_connect_time > 2) {
// 超过3次检测没有心跳就关闭这个连接
System.out.println("[关闭这个不活跃的channel:" + ctx.channel().remoteAddress()
+ "]");
ctx.channel().close();
}
}
} else {
super.userEventTriggered(ctx, evt);
}
}
}
| [
"[email protected]"
] | |
397857c095d379ccb441764256374db7e8f44c2a | 51b06865756d60b5c1a808152b172193e03b5204 | /app/src/main/java/com/tester/vlad/tester/manager/ITestManager.java | 8d2d924b497b6003ecaf529928cd8490c1e04129 | [] | no_license | nagibator997/android_tester | b03e817f6d570b9ca28785c212464351fac91d1d | 329266fca01a1f7eff5971271c1e0741638c675a | refs/heads/master | 2021-01-21T17:47:08.077830 | 2017-05-21T22:55:33 | 2017-05-21T22:55:33 | 91,990,371 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 775 | java | package com.tester.vlad.tester.manager;
import java.util.List;
import com.tester.vlad.tester.entity.Test;
import com.tester.vlad.tester.manager.properties.PropertiesManager;
public interface ITestManager {
int getCorrectAnswersQuantity();
boolean isTestsAvailable();
List<String> getTestNames();
void removeTest(String testName);
boolean runTest(String name);
int getCurrentTestQuestionsSize();
String getCurrentTestQuestion(int i);
List<String> getCurrentQuestionAnswers(int i);
void processAnswer(int answerNumber);
Test getCurrentTest();
boolean createTest(String testName, String email, List<String> questionsList, List<List<String>> answers, List<Integer> correctAnswers, String password);
public PropertiesManager getProperties();
}
| [
"[email protected]"
] | |
44a2bd70e26eba950d48fa1bd0a0572b0698f963 | c1040cf5e9718f344c68c43e7556e529f1c76c73 | /app/src/main/java/com/app/mybiz/tests/FixOrientation.java | 7ea01bef616069d6d86fc0b89602b66a7417fe25 | [] | no_license | HannahShulman/MyBizUpdate | 07d0cc5d7b0a8bddb609adab89d21334b1f4bfcb | 5928ec6e22d621bd52fa17f97454555710424187 | refs/heads/master | 2023-01-10T20:37:53.837630 | 2020-11-11T22:36:41 | 2020-11-11T22:36:41 | 308,770,621 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,682 | java | package com.app.mybiz.tests;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.util.Log;
import java.io.IOException;
/**
* Created by itzikalgrisi on 06/03/2017.
*/
public class FixOrientation {
public static String TAG = "FixOrientation";
public static Bitmap modifyOrientation(Bitmap bitmap, String image_absolute_path) throws IOException {
ExifInterface ei = new ExifInterface(image_absolute_path);
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
Log.d(TAG, "modifyOrientation: "+orientation);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
return rotate(bitmap, 90);
case ExifInterface.ORIENTATION_ROTATE_180:
return rotate(bitmap, 180);
case ExifInterface.ORIENTATION_ROTATE_270:
return rotate(bitmap, 270);
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
return flip(bitmap, true, false);
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
return flip(bitmap, false, true);
default:
return bitmap;
}
}
public static Bitmap rotate(Bitmap bitmap, float degrees) {
Matrix matrix = new Matrix();
matrix.postRotate(degrees);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}
public static Bitmap flip(Bitmap bitmap, boolean horizontal, boolean vertical) {
Matrix matrix = new Matrix();
matrix.preScale(horizontal ? -1 : 1, vertical ? -1 : 1);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}
public static int calculateInSampleSize(
BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height / 2;
final int halfWidth = width / 2;
// Calculate the largest inSampleSize value that is a power of 2 and keeps both
// height and width larger than the requested height and width.
while ((halfHeight / inSampleSize) >= reqHeight
&& (halfWidth / inSampleSize) >= reqWidth) {
inSampleSize *= 2;
}
}
return inSampleSize;
}
}
| [
"[email protected]"
] | |
f0d9c52e78a27f96d0dbdde7ad4bff02a81f2e2b | faedda625d5a94d831cba7f8720052de1ddeb9b9 | /src/com/ibm/logica/gestion/gPreguntas.java | a35fd893b7c3bc2714a14910e769c0730f53d443 | [] | no_license | debu66er/Game-of-Bluemix | f626d16f779949228000e4dbed7dc10593587a1e | f79f222aa31e4d003a9fb9a06d4af39d99711e5f | refs/heads/master | 2021-01-12T04:00:32.539016 | 2017-07-27T10:40:07 | 2017-07-27T10:40:07 | 77,461,650 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,873 | java | package com.ibm.logica.gestion;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.ibm.conexion.Conexion;
import com.ibm.logica.modelo.Pregunta;
public class gPreguntas {
private Connection con = null;
private Statement st = null;
private ResultSet rs = null;
public List<Pregunta> getPregunta() {
List<Pregunta> preguntas = new ArrayList<Pregunta>();
try {
con = Conexion.init();
st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = st.executeQuery("SELECT * FROM CUESTIONARIOBM");
String pregunta, resp1, resp2, resp3, resp4, oculta, workshop;
int id, correcta;
while (rs.next()) {
id = rs.getInt("id");
pregunta = rs.getString("pregunta");
resp1 = rs.getString("resp1");
resp2 = rs.getString("resp2");
resp3 = rs.getString("resp3");
resp4 = rs.getString("resp4");
correcta = rs.getInt("correcta");
oculta = rs.getString("oculta");
workshop = rs.getString("workshop");
Pregunta preg = new Pregunta(id, pregunta, resp1, resp2, resp3, resp4, correcta, oculta, workshop);
preguntas.add(preg);
}
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
return preguntas;
}
public void editarPregunta(int id, String pregunta, String resp1, String resp2, String resp3, String resp4, int correcta, String oculta, String workshop) {
String query;
try {
con = Conexion.init();
st = con.createStatement();
query = "UPDATE CUESTIONARIOBM SET PREGUNTA = '" + pregunta
+ "', RESP1 = '" + resp1
+ "', RESP2 = '" + resp2
+ "', RESP3 = '" + resp3
+ "', RESP4 = '" + resp4
+ "', CORRECTA = '" + correcta
+ "', OCULTA = '" + oculta
+ "', WORKSHOP = '" + workshop
+ "' WHERE ID = '" + id + "'";
st.executeUpdate(query);
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void eliminarPregunta(int id) {
String query;
try {
con = Conexion.init();
st = con.createStatement();
query = "DELETE FROM CUESTIONARIOBM WHERE ID='" + id + "'";
st.executeUpdate(query);
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void aniadirPregunta(String pregunta, String resp1, String resp2, String resp3, String resp4, int correcta, String oculta, String workshop) {
String query;
try {
con = Conexion.init();
st = con.createStatement();
query = "INSERT INTO CUESTIONARIOBM VALUES" + "(DEFAULT, '" + pregunta + "','" + resp1 + "','" + resp2 + "','" + resp3 + "','" + resp4 + "','" + correcta + "','" + oculta + "','"+workshop+"')";
st.executeUpdate(query);
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
32a10e5a32dad8c5f03c0370e2db119bae38f5f2 | ded842475421523d2512da578b69f3919865e72b | /app/src/main/java/com/example/zhaozhu/practisecustomview/TestRandom.java | d0c9d717ad328309e6626fac8c0a4b0b08fa77f5 | [] | no_license | zhaozhu365/PractiseCustomView | 106fa68206fb0d3cff6127afa883fde50f6b6492 | d299456bb49153191141a9a13f7ed492b845b1bf | refs/heads/master | 2020-05-22T01:43:52.407348 | 2017-09-22T06:58:20 | 2017-09-22T06:58:20 | 65,892,043 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 364 | java | package com.example.zhaozhu.practisecustomview;
import java.util.Random;
/**
* author: zhaozhu
* Created on 17/8/1
*/
public class TestRandom {
public static void main(String[] args) {
Random random = new Random();
for (int i = 0; i < 100; i++) {
int a = random.nextInt(4);
System.out.print(a);
}
}
}
| [
"[email protected]"
] | |
1d5a86a62ae9d4add4522a17ce7c2d294540e5cd | ab48fd29e636b455c94c54ba3e43a986282a2385 | /app/src/main/java/space/tsig/quizgame/Level2.java | c331a81675c59ff26c495bae93450655cc31fbfb | [] | no_license | Mihats/Quiz | d24fe563b1749cf8058be6bf63f524b63a9af894 | 9a003139f5271df56ded215b2a37c000220b79b2 | refs/heads/master | 2023-03-03T23:18:43.531322 | 2021-02-17T19:34:35 | 2021-02-17T19:34:35 | 339,835,018 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 24,578 | java | package space.tsig.quizgame;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class Level2 extends AppCompatActivity {
private static final String TAG = "1234";
Dialog dialog;
Dialog dialogEnd;
public int numQuestion;
public int answer1;
public int answer2;
public int answer3;
Array array = new Array();
Random random = new Random();
private List<List> listAnswers = new ArrayList<>();
private List<String> listQuestions= new ArrayList<>();
private List<Integer> listAnswerKeys= new ArrayList<>();
public int count = 0;
private InterstitialAd mInterstitialAd;
private InterstitialAd mInterstitialAdClose;
private AdView mAdView;
//database
private DatabaseReference mDatabase;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.level2);
//database
mDatabase = FirebaseDatabase.getInstance().getReference("level2");
mDatabase.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
for (DataSnapshot ds : dataSnapshot.getChildren()) {
QLevel2 qLevel2 = ds.getValue(QLevel2.class);
String[] subStr;
List<String> answers = new ArrayList<>();
subStr = qLevel2.answers.split(",");
for(int i = 0; i < subStr.length; i++) {
answers.add(subStr[i]);
}
listAnswers.add(answers);
listQuestions.add(qLevel2.question);
listAnswerKeys.add(qLevel2.answerKey);
}
main();
Log.d(TAG, "AnswersSize is: " + listAnswers.size());
Log.d(TAG, "QuestionSize is: " + listQuestions.size());
Log.d(TAG, "KeySize is: " + listAnswerKeys.size());
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}
});
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
// ads
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-1772797776810105/3156941333");
mInterstitialAd.loadAd(new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build());
mInterstitialAdClose = new InterstitialAd(this);
mInterstitialAdClose.setAdUnitId("ca-app-pub-1772797776810105/3156941333");
mInterstitialAdClose.loadAd(new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build());
//closeAdd
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
try {
Intent intent = new Intent(getApplicationContext(), GameLevels.class);
startActivity(intent);
finish();
} catch (Exception e) {
}
}
});
//text_levels
TextView text_levels = findViewById(R.id.text_levels);
text_levels.setText(R.string.level2);
Button button_back = (Button) findViewById(R.id.button_back);
button_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
try {
Intent intent = new Intent(getApplicationContext(), GameLevels.class);
startActivity(intent);
finish();
} catch (Exception e) {
}
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//call dialog view
dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.previewdialog);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable((Color.TRANSPARENT)));
dialog.setCancelable(false);
TextView textDescr = dialog.findViewById(R.id.textdescripyion);
textDescr.setText(R.string.leveltwo);
//close dialog
TextView btnclose = (TextView) dialog.findViewById(R.id.btnclose);
btnclose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent intent = new Intent(getApplicationContext(), GameLevels.class);
startActivity(intent);
finish();
} catch (Exception e) {
}
dialog.dismiss();
}
});
dialog.show();
//continue
Button btncontinue = (Button) dialog.findViewById(R.id.btncontinue);
btncontinue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
//___________________________________________________
//call dialog view
dialogEnd = new Dialog(this);
dialogEnd.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialogEnd.setContentView(R.layout.dialogenddialog);
dialogEnd.getWindow().setBackgroundDrawable(new ColorDrawable((Color.TRANSPARENT)));
dialogEnd.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT);
dialogEnd.setCancelable(false);
//close dialog
TextView btncloseEnd = (TextView) dialogEnd.findViewById(R.id.btnclose);
btncloseEnd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent intent = new Intent(getApplicationContext(), GameLevels.class);
startActivity(intent);
finish();
} catch (Exception e) {
}
dialogEnd.dismiss();
}
});
//continue
Button btncontinueEnd = (Button) dialogEnd.findViewById(R.id.btncontinue);
btncontinueEnd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent intent = new Intent(getApplicationContext(), Level2.class);
startActivity(intent);
finish();
} catch (Exception e) {
}
dialogEnd.dismiss();
}
});
}
public void main() {
final TextView question = findViewById(R.id.question);
final Button button_one = (Button) findViewById(R.id.button_one);
final Button button_two = (Button) findViewById(R.id.button_two);
final Button button_three = (Button) findViewById(R.id.button_three);
//array for progress
final int[] progress = {
R.id.point1, R.id.point2, R.id.point3, R.id.point4, R.id.point5
};
numQuestion = random.nextInt(listQuestions.size());
question.setText(listQuestions.get(numQuestion));
answer1 = random.nextInt(3);
button_one.setText(listAnswers.get(numQuestion).get(answer1).toString());
answer2 = random.nextInt(3);
while (answer2 == answer1) {
answer2 = random.nextInt(3);
}
button_two.setText(listAnswers.get(numQuestion).get(answer2).toString());
answer3 = random.nextInt(3);
while (answer3 == answer1 || answer3 == answer2) {
answer3 = random.nextInt(3);
}
button_three.setText(listAnswers.get(numQuestion).get(answer3).toString());
listQuestions.remove(numQuestion);
listAnswers.remove(numQuestion);
//click on answer
int correctColor = getResources().getColor(R.color.green);
int errorColor = getResources().getColor(R.color.red);
int backColor = getResources().getColor(R.color.black60);
button_one.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
button_two.setEnabled(false);
button_three.setEnabled(false);
System.out.println(answer1);
if (answer1 == listAnswerKeys.get(numQuestion)) {
button_one.setBackgroundColor(correctColor);
} else {
button_one.setBackgroundColor(errorColor);
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
if (answer1 == listAnswerKeys.get(numQuestion)) {
if (count < 5) {
count++;
}
for (int i = 0; i < 5; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points);
}
for (int i = 0; i < count; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points_green);
}
} else {
if (count > 0) {
if (count == 1) {
count = 0;
} else {
count = count - 2;
}
}
for (int i = 0; i < 4; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points);
}
for (int i = 0; i < count; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points_green);
}
}
if (count == 5) {
//exit from level
if (mInterstitialAdClose.isLoaded()) {
mInterstitialAdClose.show();
SharedPreferences save = getSharedPreferences("Save", MODE_PRIVATE);
final int level = save.getInt("Level", 1);
if (level > 1) {
//
} else {
SharedPreferences.Editor editor = save.edit();
editor.putInt("Level", 2);
editor.commit();
}
dialogEnd.show();
} else {
SharedPreferences save = getSharedPreferences("Save", MODE_PRIVATE);
final int level = save.getInt("Level", 1);
if (level > 1) {
//
} else {
SharedPreferences.Editor editor = save.edit();
editor.putInt("Level", 2);
editor.commit();
}
dialogEnd.show();
}
} else {
listAnswerKeys.remove(numQuestion);
numQuestion = random.nextInt(listQuestions.size());
question.setText(listQuestions.get(numQuestion));
answer1 = random.nextInt(3);
button_one.setText(listAnswers.get(numQuestion).get(answer1).toString());
button_one.setBackgroundColor(backColor);
answer2 = random.nextInt(3);
while (answer2 == answer1) {
answer2 = random.nextInt(3);
}
button_two.setText(listAnswers.get(numQuestion).get(answer2).toString());
answer3 = 3 - answer1 - answer2;
button_three.setText(listAnswers.get(numQuestion).get(answer3).toString());
button_two.setEnabled(true);
button_three.setEnabled(true);
listQuestions.remove(numQuestion);
listAnswers.remove(numQuestion);
}
}
return true;
}
});
button_two.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
button_one.setEnabled(false);
button_three.setEnabled(false);
System.out.println(answer2);
if (answer2 == listAnswerKeys.get(numQuestion)) {
button_two.setBackgroundColor(correctColor);
} else {
button_two.setBackgroundColor(errorColor);
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
if (answer2 == listAnswerKeys.get(numQuestion)) {
if (count < 5) {
count++;
}
for (int i = 0; i < 5; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points);
}
for (int i = 0; i < count; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points_green);
}
} else {
if (count > 0) {
if (count == 1) {
count = 0;
} else {
count = count - 2;
}
}
for (int i = 0; i < 4; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points);
}
for (int i = 0; i < count; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points_green);
}
}
if (count == 5) {
//exit
if (mInterstitialAdClose.isLoaded()) {
mInterstitialAdClose.show();
SharedPreferences save = getSharedPreferences("Save", MODE_PRIVATE);
final int level = save.getInt("Level", 1);
if (level > 1) {
//
} else {
SharedPreferences.Editor editor = save.edit();
editor.putInt("Level", 2);
editor.commit();
}
dialogEnd.show();
} else {
SharedPreferences save = getSharedPreferences("Save", MODE_PRIVATE);
final int level = save.getInt("Level", 1);
if (level > 1) {
//
} else {
SharedPreferences.Editor editor = save.edit();
editor.putInt("Level", 2);
editor.commit();
}
dialogEnd.show();
}
} else {
listAnswerKeys.remove(numQuestion);
numQuestion = random.nextInt(listQuestions.size());
question.setText(listQuestions.get(numQuestion));
answer1 = random.nextInt(3);
button_one.setText(listAnswers.get(numQuestion).get(answer1).toString());
answer2 = random.nextInt(3);
while (answer2 == answer1) {
answer2 = random.nextInt(3);
}
button_two.setText(listAnswers.get(numQuestion).get(answer2).toString());
button_two.setBackgroundColor(backColor);
answer3 = 3 - answer1 - answer2;
button_three.setText(listAnswers.get(numQuestion).get(answer3).toString());
button_one.setEnabled(true);
button_three.setEnabled(true);
listQuestions.remove(numQuestion);
listAnswers.remove(numQuestion);
}
}
return true;
}
});
button_three.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
button_two.setEnabled(false);
button_one.setEnabled(false);
System.out.println(answer3);
if (answer3 == listAnswerKeys.get(numQuestion)) {
button_three.setBackgroundColor(correctColor);
} else {
button_three.setBackgroundColor(errorColor);
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
if (answer3 == listAnswerKeys.get(numQuestion)) {
if (count < 5) {
count++;
}
for (int i = 0; i < 5; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points);
}
for (int i = 0; i < count; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points_green);
}
} else {
if (count > 0) {
if (count == 1) {
count = 0;
} else {
count = count - 2;
}
}
for (int i = 0; i < 4; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points);
}
for (int i = 0; i < count; i++) {
TextView tv = findViewById(progress[i]);
tv.setBackgroundResource(R.drawable.style_points_green);
}
}
if (count == 5) {
//exit from level
if (mInterstitialAdClose.isLoaded()) {
mInterstitialAdClose.show();
SharedPreferences save = getSharedPreferences("Save", MODE_PRIVATE);
final int level = save.getInt("Level", 1);
if (level > 1) {
//
} else {
SharedPreferences.Editor editor = save.edit();
editor.putInt("Level", 2);
editor.commit();
}
dialogEnd.show();
} else {
SharedPreferences save = getSharedPreferences("Save", MODE_PRIVATE);
final int level = save.getInt("Level", 1);
if (level > 1) {
//
} else {
SharedPreferences.Editor editor = save.edit();
editor.putInt("Level", 2);
editor.commit();
}
dialogEnd.show();
}
} else {
listAnswerKeys.remove(numQuestion);
numQuestion = random.nextInt(listQuestions.size());
question.setText(listQuestions.get(numQuestion));
answer1 = random.nextInt(3);
button_one.setText(listAnswers.get(numQuestion).get(answer1).toString());
answer2 = random.nextInt(3);
while (answer2 == answer1) {
answer2 = random.nextInt(3);
}
button_two.setText(listAnswers.get(numQuestion).get(answer2).toString());
answer3 = 3 - answer1 - answer2;
button_three.setText(listAnswers.get(numQuestion).get(answer3).toString());
button_three.setBackgroundColor(backColor);
button_two.setEnabled(true);
button_one.setEnabled(true);
listQuestions.remove(numQuestion);
listAnswers.remove(numQuestion);
}
}
return true;
}
});
}
// system back
@Override
public void onBackPressed() {
try {
Intent intent = new Intent(getApplicationContext(), GameLevels.class);
startActivity(intent);
finish();
} catch (Exception e) {
}
}
} | [
"[email protected]"
] | |
203174355e7753cf27d07addb5099fca05beef28 | eb69fbb1045c6ca8091f9a853c9cdae5fe907653 | /cpp_grammar/FoldVisitor.java | 4579558273090a10a8f8e4293c704e2554d1c822 | [] | no_license | bobbykain/402-a2 | 1fc997f5b0f343a20e0f14b438772e5f3f659919 | 0a9935a404a7adf62f722af4d16fb08d0ee1edc9 | refs/heads/master | 2020-04-26T03:04:37.696062 | 2019-03-01T07:25:30 | 2019-03-01T07:25:30 | 173,254,994 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,513 | java | package cpp_grammar;
import cpp_grammar.Absyn.*;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
/** BNFC-Generated Fold Visitor */
public abstract class FoldVisitor<R,A> implements AllVisitor<R,A> {
public abstract R leaf(A arg);
public abstract R combine(R x, R y, A arg);
/* Program */
public R visit(cpp_grammar.Absyn.Prog p, A arg) {
R r = leaf(arg);
for (Function x : p.listfunction_)
{
r = combine(x.accept(this, arg), r, arg);
}
return r;
}
/* Function */
public R visit(cpp_grammar.Absyn.Fun p, A arg) {
R r = leaf(arg);
r = combine(p.type_.accept(this, arg), r, arg);
for (Arg x : p.listarg_)
{
r = combine(x.accept(this, arg), r, arg);
}
for (Stm x : p.liststm_)
{
r = combine(x.accept(this, arg), r, arg);
}
return r;
}
/* Arg */
public R visit(cpp_grammar.Absyn.Dec p, A arg) {
R r = leaf(arg);
r = combine(p.type_.accept(this, arg), r, arg);
return r;
}
/* Stm */
public R visit(cpp_grammar.Absyn.SDecl p, A arg) {
R r = leaf(arg);
r = combine(p.arg_.accept(this, arg), r, arg);
return r;
}
public R visit(cpp_grammar.Absyn.SExp p, A arg) {
R r = leaf(arg);
r = combine(p.exp_.accept(this, arg), r, arg);
return r;
}
public R visit(cpp_grammar.Absyn.SReturn p, A arg) {
R r = leaf(arg);
r = combine(p.exp_.accept(this, arg), r, arg);
return r;
}
public R visit(cpp_grammar.Absyn.SBlock p, A arg) {
R r = leaf(arg);
for (Stm x : p.liststm_)
{
r = combine(x.accept(this, arg), r, arg);
}
return r;
}
/* Exp */
public R visit(cpp_grammar.Absyn.EInt p, A arg) {
R r = leaf(arg);
return r;
}
public R visit(cpp_grammar.Absyn.EStr p, A arg) {
R r = leaf(arg);
return r;
}
public R visit(cpp_grammar.Absyn.EId p, A arg) {
R r = leaf(arg);
return r;
}
public R visit(cpp_grammar.Absyn.ELs p, A arg) {
R r = leaf(arg);
r = combine(p.exp_1.accept(this, arg), r, arg);
r = combine(p.exp_2.accept(this, arg), r, arg);
return r;
}
public R visit(cpp_grammar.Absyn.EAss p, A arg) {
R r = leaf(arg);
r = combine(p.exp_.accept(this, arg), r, arg);
return r;
}
/* Type */
public R visit(cpp_grammar.Absyn.Tint p, A arg) {
R r = leaf(arg);
return r;
}
}
| [
"[email protected]"
] | |
27ed2ad432c6151acc921a2e14758d13840ce47e | 2869fc39e2e63d994d5dd8876476e473cb8d3986 | /Super_report/src/java/com/lvmama/report/web/sales/ListVistorDetailAction.java | 6801979b5fc62644c7497de43c3d966618d71a78 | [] | no_license | kavt/feiniu_pet | bec739de7c4e2ee896de50962dbd5fb6f1e28fe9 | 82963e2e87611442d9b338d96e0343f67262f437 | refs/heads/master | 2020-12-25T17:45:16.166052 | 2016-06-13T10:02:42 | 2016-06-13T10:02:42 | 61,026,061 | 0 | 0 | null | 2016-06-13T10:02:01 | 2016-06-13T10:02:01 | null | UTF-8 | Java | false | false | 7,812 | java | package com.lvmama.report.web.sales;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import com.lvmama.report.po.VistorDetailBasicMV;
import com.lvmama.report.service.ReportService;
import com.lvmama.report.web.BaseAction;
/**
* 游客信息Action
* @author yangchen
*/
public class ListVistorDetailAction extends BaseAction {
/**
* 序列值
*/
private static final long serialVersionUID = 832317991239553741L;
/** 查询条件map集合 **/
private Map<String, Object> searchConds = new HashMap<String, Object>();
/** 获取VistorDetailBasicMV对象的列表集合 **/
private List<VistorDetailBasicMV> analysisList = new ArrayList<VistorDetailBasicMV>();
/** 业务对象 **/
private ReportService reportService;
/**
* 单击查询
*/
public void doQuery() {
// 获取查询条件
Map<String, Object> param = this.createMap();
// 获取总条数
Long countVistor = reportService.countVistorDetailBasicMV(param);
initialPageInfoByMap(countVistor,
param);
// 获取VistorDetailBasicMV对象列表集合
if(countVistor > 0) {
analysisList = reportService.queryVistorDetailBasicMV(param,false);
} else {
analysisList = new ArrayList<VistorDetailBasicMV>();
}
}
/**
* 导出数据
*/
public void doExport() {
Map<String, Object> param = this.createMap();
// 获取数据
analysisList = reportService.queryVistorDetailBasicMV(param,true);
Map<String, Object> beans = new HashMap<String, Object>();
beans.put("excelList", analysisList);
doExcel(beans, "/WEB-INF/resources/template/vistorDetail.xls");
}
/**
* 配置searchConds查询条件
* @return 查询条件
* */
public Map<String, Object> createMap() {
Map<String, Object> param = new HashMap<String, Object>();
param.put("payStartDate", searchConds.get("payStartDate"));
param.put("payEndDate", searchConds.get("payEndDate"));
param.put("visitStartDate", searchConds.get("visitStartDate"));
param.put("visitEndDate", searchConds.get("visitEndDate"));
if (!StringUtils.isEmpty((String) searchConds.get("orderId"))) {
if (!"".equals(searchConds.get("orderId").toString().trim())) {
param.put("orderId", searchConds.get("orderId").toString().trim());
}
}
if (!StringUtils.isEmpty((String) searchConds.get("prodProductIds"))) {
String ids = searchConds.get("prodProductIds").toString().replace(" ", "");
if (!"".equals(searchConds.get("prodProductIds").toString().replace(" ", ""))) {
param.put("prodProductIds", ids.split(","));
}
}
if (!StringUtils.isEmpty((String) searchConds.get("prodProductId"))) {
if (!"".equals(searchConds.get("prodProductId").toString().trim())) {
param.put("prodProductId", searchConds.get("prodProductId")
.toString().trim());
}
}
if (!StringUtils.isEmpty((String) searchConds.get("prodName"))) {
if (!"".equals(searchConds.get("prodName").toString().trim())) {
param.put("prodName", searchConds.get("prodName").toString().trim());
}
}
if (!StringUtils.isEmpty((String) searchConds.get("realName"))) {
if (!"".equals(searchConds.get("realName").toString().trim())) {
param.put("realName", searchConds.get("realName").toString().trim());
}
}
if (!StringUtils.isEmpty((String) searchConds.get("filialeName"))) {
if (!"".equals(searchConds.get("filialeName").toString().trim())) {
param.put("filialeName", searchConds.get("filialeName").toString()
.trim());
}
}
// 获取SUB_PRODUCT_TYPE 查询条件
String sqlString = getSubProductTypeParam();
if (!"".equals(sqlString)) {
param.put("sql", sqlString);
}
return param;
}
/**
* 获取SUB_PRODUCT_TYPE 查询条件
* @return 查询类型
* */
public String getSubProductTypeParam() {
String sqlString = "";
if (searchConds.get("sTicket") != null) {
if ((Boolean) searchConds.get("sTicket")) {
if (!"".equals(sqlString)) {
sqlString += " or (PRODUCT_TYPE ='TICKET')";
} else {
sqlString += "(PRODUCT_TYPE ='TICKET')";
}
}
}
if (searchConds.get("sHotel") != null) {
if ((Boolean) searchConds.get("sHotel")) {
if (!"".equals(sqlString)) {
sqlString += " or (PRODUCT_TYPE='HOTEL')";
} else {
sqlString += "(PRODUCT_TYPE='HOTEL')";
}
}
}
if (searchConds.get("sGroup") != null) {
if ((Boolean) searchConds.get("sGroup")) {
if (!"".equals(sqlString)) {
sqlString += " or SUB_PRODUCT_TYPE='GROUP'";
} else {
sqlString += "SUB_PRODUCT_TYPE='GROUP'";
}
}
}
if (searchConds.get("sGroupLong") != null) {
if ((Boolean) searchConds.get("sGroupLong")) {
if (!"".equals(sqlString)) {
sqlString += " or SUB_PRODUCT_TYPE='GROUP_LONG'";
} else {
sqlString += "SUB_PRODUCT_TYPE='GROUP_LONG'";
}
}
}
if (searchConds.get("sGroupForeign") != null) {
if ((Boolean) searchConds.get("sGroupForeign")) {
if (!"".equals(sqlString)) {
sqlString += " or SUB_PRODUCT_TYPE='GROUP_FOREIGN'";
} else {
sqlString += "SUB_PRODUCT_TYPE='GROUP_FOREIGN'";
}
}
}
if (searchConds.get("sFree") != null) {
if ((Boolean) searchConds.get("sFree")) {
if (!"".equals(sqlString)) {
sqlString += " or SUB_PRODUCT_TYPE='FREENESS'";
} else {
sqlString += "SUB_PRODUCT_TYPE='FREENESS'";
}
}
}
if (searchConds.get("sFreeLong") != null) {
if ((Boolean) searchConds.get("sFreeLong")) {
if (!"".equals(sqlString)) {
sqlString += " or SUB_PRODUCT_TYPE='FREENESS_LONG'";
} else {
sqlString += "SUB_PRODUCT_TYPE='FREENESS_LONG'";
}
}
}
if (searchConds.get("sFreeForeign") != null) {
if ((Boolean) searchConds.get("sFreeForeign")) {
if (!"".equals(sqlString)) {
sqlString += " or SUB_PRODUCT_TYPE='FREENESS_FOREIGN'";
} else {
sqlString += "SUB_PRODUCT_TYPE='FREENESS_FOREIGN'";
}
}
}
if (searchConds.get("sSelfhelpBus") != null) {
if ((Boolean) searchConds.get("sSelfhelpBus")) {
if (!"".equals(sqlString)) {
sqlString += " or SUB_PRODUCT_TYPE='SELFHELP_BUS'";
} else {
sqlString += "SUB_PRODUCT_TYPE='SELFHELP_BUS'";
}
}
}
if (searchConds.get("sInsurance") != null) {
if ((Boolean) searchConds.get("sInsurance")) {
if (!"".equals(sqlString)) {
sqlString += " or SUB_PRODUCT_TYPE='INSURANCE'";
} else {
sqlString += "SUB_PRODUCT_TYPE='INSURANCE'";
}
}
}
if (searchConds.get("sFangCha") != null) {
if ((Boolean) searchConds.get("sFangCha")) {
if (!"".equals(sqlString)) {
sqlString += " or SUB_PRODUCT_TYPE='FANGCHA'";
} else {
sqlString += "SUB_PRODUCT_TYPE='FANGCHA'";
}
}
}
if (searchConds.get("sOther") != null) {
if ((Boolean) searchConds.get("sOther")) {
if (!"".equals(sqlString)) {
sqlString += " or SUB_PRODUCT_TYPE='OTHER'";
} else {
sqlString += "SUB_PRODUCT_TYPE='OTHER'";
}
}
}
return sqlString;
}
public Map<String, Object> getSearchConds() {
return searchConds;
}
public void setSearchConds(final Map<String, Object> searchConds) {
this.searchConds = searchConds;
}
public ReportService getReportService() {
return reportService;
}
public List<VistorDetailBasicMV> getAnalysisList() {
return analysisList;
}
public void setAnalysisList(final List<VistorDetailBasicMV> analysisList) {
this.analysisList = analysisList;
}
public void setReportService(final ReportService reportService) {
this.reportService = reportService;
}
}
| [
"[email protected]"
] | |
64e76f0cc5f0929d5e303675b1cfce6166ede5d4 | 473e2179d6da384d7607a11aaba5faa69000a853 | /processor/src/test/java/org/mapstruct/ap/test/subclassmapping/SubclassMappingTest.java | e5a77b56d3a0bde3feedcd6be7b8382ee06d130b | [
"Apache-2.0"
] | permissive | Qiu1024/mapstruct | 46aae5dfa8b19bde39cb11ebdc6b8191daf0f78e | 13bc0c023c82e40f6cb14b41f5fba462859bd308 | refs/heads/master | 2023-09-06T04:46:12.444647 | 2021-11-20T07:48:08 | 2021-11-20T07:48:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,578 | java | /*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.subclassmapping;
import org.mapstruct.ap.test.subclassmapping.mappables.Bike;
import org.mapstruct.ap.test.subclassmapping.mappables.BikeDto;
import org.mapstruct.ap.test.subclassmapping.mappables.Car;
import org.mapstruct.ap.test.subclassmapping.mappables.CarDto;
import org.mapstruct.ap.test.subclassmapping.mappables.HatchBack;
import org.mapstruct.ap.test.subclassmapping.mappables.HatchBackDto;
import org.mapstruct.ap.test.subclassmapping.mappables.Vehicle;
import org.mapstruct.ap.test.subclassmapping.mappables.VehicleCollection;
import org.mapstruct.ap.test.subclassmapping.mappables.VehicleCollectionDto;
import org.mapstruct.ap.test.subclassmapping.mappables.VehicleDto;
import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.ProcessorTest;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult;
import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic;
import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome;
import static org.assertj.core.api.Assertions.assertThat;
@IssueKey("131")
@WithClasses({
Bike.class,
BikeDto.class,
Car.class,
CarDto.class,
VehicleCollection.class,
VehicleCollectionDto.class,
Vehicle.class,
VehicleDto.class,
SimpleSubclassMapper.class,
SubclassMapperUsingExistingMappings.class,
})
public class SubclassMappingTest {
@ProcessorTest
void mappingIsDoneUsingSubclassMapping() {
VehicleCollection vehicles = new VehicleCollection();
vehicles.getVehicles().add( new Car() );
vehicles.getVehicles().add( new Bike() );
VehicleCollectionDto result = SimpleSubclassMapper.INSTANCE.map( vehicles );
assertThat( result.getVehicles() ).doesNotContainNull();
assertThat( result.getVehicles() ) // remove generic so that test works.
.extracting( vehicle -> (Class) vehicle.getClass() )
.containsExactly( CarDto.class, BikeDto.class );
}
@ProcessorTest
void existingMappingsAreUsedWhenFound() {
VehicleCollection vehicles = new VehicleCollection();
vehicles.getVehicles().add( new Car() );
VehicleCollectionDto result = SubclassMapperUsingExistingMappings.INSTANCE.map( vehicles );
assertThat( result.getVehicles() )
.extracting( VehicleDto::getName )
.containsExactly( "created through existing mapping." );
}
@ProcessorTest
void subclassMappingInheritsMapping() {
VehicleCollection vehicles = new VehicleCollection();
Car car = new Car();
car.setVehicleManufacturingCompany( "BenZ" );
vehicles.getVehicles().add( car );
VehicleCollectionDto result = SimpleSubclassMapper.INSTANCE.map( vehicles );
assertThat( result.getVehicles() )
.extracting( VehicleDto::getMaker )
.containsExactly( "BenZ" );
}
@ProcessorTest
@WithClasses({
HatchBack.class,
HatchBackDto.class,
SubclassOrderWarningMapper.class,
})
@ExpectedCompilationOutcome(value = CompilationResult.SUCCEEDED, diagnostics = {
@Diagnostic(type = SubclassOrderWarningMapper.class,
kind = javax.tools.Diagnostic.Kind.WARNING,
line = 28,
alternativeLine = 30,
message = "SubclassMapping annotation for "
+ "'org.mapstruct.ap.test.subclassmapping.mappables.HatchBackDto' found after "
+ "'org.mapstruct.ap.test.subclassmapping.mappables.CarDto', but all "
+ "'org.mapstruct.ap.test.subclassmapping.mappables.HatchBackDto' "
+ "objects are also instances of "
+ "'org.mapstruct.ap.test.subclassmapping.mappables.CarDto'.")
})
void subclassOrderWarning() {
}
@ProcessorTest
@WithClasses({ ErroneousSubclassUpdateMapper.class })
@ExpectedCompilationOutcome(value = CompilationResult.FAILED, diagnostics = {
@Diagnostic(type = ErroneousSubclassUpdateMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 21,
message = "SubclassMapping annotation can not be used for update methods."
),
@Diagnostic(type = ErroneousSubclassUpdateMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 25,
message = "SubclassMapping annotation can not be used for update methods."
)
})
void unsupportedUpdateMethod() {
}
@ProcessorTest
@WithClasses({ ErroneousSubclassMapper1.class })
@ExpectedCompilationOutcome(value = CompilationResult.FAILED, diagnostics = {
@Diagnostic(type = ErroneousSubclassMapper1.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 21,
message = "Could not find a parameter that is a superclass for "
+ "'org.mapstruct.ap.test.subclassmapping.mappables.Bike'."
),
@Diagnostic(type = ErroneousSubclassMapper1.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 21,
message = "Class 'org.mapstruct.ap.test.subclassmapping.mappables.CarDto'"
+ " is not a subclass of "
+ "'org.mapstruct.ap.test.subclassmapping.mappables.BikeDto'."
)
})
void erroneousMethodWithSourceTargetType() {
}
}
| [
"[email protected]"
] | |
bf3827b6324cd0defb2f280214c6eba7862f4b97 | fb60e44df6cc721846b25c77c94f33f5732d96cd | /app/src/main/java/com/developtech/efuelfo/ui/fragments/vehicleOwner/TrackDriverFragment.java | 4c5c2834bf94d4916abb6b17fc0a17d5b5e6ed43 | [] | no_license | roushankumararya/EfuelFSO | d681ffac9a979212e7f6740bfc3350a99ba8623a | 848c8e389cc0aac0c52f8d484affb1424ba9b835 | refs/heads/master | 2021-02-14T15:34:40.713694 | 2020-03-11T14:44:10 | 2020-03-11T14:44:10 | 244,814,795 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,993 | java | package com.developtech.efuelfo.ui.fragments.vehicleOwner;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;
import com.developtech.efuelfo.R;
import com.developtech.efuelfo.interfaces.VehicleOwnerItemClick;
import com.developtech.efuelfo.model.ResultModel;
import com.developtech.efuelfo.model.requestModel.UpdateDriverRequestModel;
import com.developtech.efuelfo.model.responseModel.DriverLocationResponseModel;
import com.developtech.efuelfo.model.responseModel.GetDriverResponseModel;
import com.developtech.efuelfo.network.NetworkListener;
import com.developtech.efuelfo.ui.adapters.vehicleOwner.TrackDriverAdapter;
import com.developtech.efuelfo.ui.adapters.vehicleOwner.TrackDriverInfoWindowAdapter;
import com.developtech.efuelfo.ui.fragments.BaseFragment;
import com.developtech.efuelfo.util.SPUtils;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class TrackDriverFragment extends BaseFragment implements VehicleOwnerItemClick, OnMapReadyCallback {
@BindView(R.id.recycleTrackDriver)
RecyclerView recycleTrackDriver;
@BindView(R.id.ivMapList)
public ImageView ivMapList;
SupportMapFragment supportMapFragment;
GoogleMap map;
boolean showMap;
TrackDriverAdapter adapter;
List<GetDriverResponseModel> driverList = new ArrayList<>();
GetDriverResponseModel model;
Bitmap bmNew, bmAccept, mutableBitmap;
DriverLocationResponseModel driverLoactionModel;
NetworkListener getDriverListener = new NetworkListener() {
@Override
public void onSuccess(ResultModel<?> responseBody) {
if (responseBody.getResultCode().equalsIgnoreCase(SPUtils.API_CODES.OK.toString())) {
driverList = (List<GetDriverResponseModel>) responseBody.getResutData();
if (driverList.size() > 0)
adapter.refreshData(driverList);
} else {
showMsg(rootLayout, responseBody.getMessage());
}
}
@Override
public void onError(String msg) {
hideProgress();
}
@Override
public void onComplete() {
hideProgress();
}
@Override
public void onStart() {
showProgress();
}
};
NetworkListener driverLocationListener = new NetworkListener() {
@Override
public void onSuccess(ResultModel<?> responseBody) {
if (responseBody.getResultCode().equalsIgnoreCase(SPUtils.API_CODES.OK.toString())) {
driverLoactionModel = (DriverLocationResponseModel) responseBody.getResutData();
if (showMap) {
addMarker();
}
}
}
@Override
public void onError(String msg) {
}
@Override
public void onComplete() {
}
@Override
public void onStart() {
}
};
private View view;
public TrackDriverFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.activity_track_driver, container, false);
ButterKnife.bind(this, view);
init(view);
initComponent();
return view;
}
public void initComponent() {
recycleTrackDriver.setLayoutManager(new LinearLayoutManager(getContext()));
adapter = new TrackDriverAdapter(getContext(), appComponent, driverList, this);
recycleTrackDriver.setAdapter(adapter);
appComponent.getServiceCaller().callService(appComponent.getAllApis().getAllDriver(), getDriverListener);
supportMapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.fragmentMap);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (supportMapFragment != null) {
supportMapFragment.getView().setVisibility(View.GONE);
supportMapFragment.getMapAsync(this);
}
}
@Override
public void retry() {
}
@Override
public void onFilterClick() {
}
@Override
public void onCLick(int position) {
model = driverList.get(position);
showMap = true;
UpdateDriverRequestModel requestModel = new UpdateDriverRequestModel();
requestModel.driverId = model.getId();
appComponent.getServiceCaller().callService(appComponent.getAllApis().getDriverLocation(requestModel), driverLocationListener);
recycleTrackDriver.setVisibility(View.GONE);
supportMapFragment.getView().setVisibility(View.VISIBLE);
ivMapList.setVisibility(View.VISIBLE);
}
@OnClick({R.id.ivMapList})
void onClick(View view) {
switch (view.getId()) {
case R.id.ivMapList: {
showMap = false;
supportMapFragment.getView().setVisibility(View.GONE);
ivMapList.setVisibility(View.GONE);
recycleTrackDriver.setVisibility(View.VISIBLE);
}
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap;
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 104);
return;
}
}
@SuppressLint("MissingPermission")
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 104) {
if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(getContext(), "Allow Permission to use this feature", Toast.LENGTH_SHORT).show();
return;
} else if (map != null) {
}
}
}
private void addMarker() {
if (map != null) {
map.clear();
if (bmNew == null) {
bmNew = Bitmap.createBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.location_marker_black));
}
Double lat = Double.parseDouble(driverLoactionModel.getLatitude());
Double lng = Double.parseDouble(driverLoactionModel.getLongitude());
LatLng latLng = new LatLng(lat, lng);
MarkerOptions userIndicator = new MarkerOptions().position(latLng);
mutableBitmap = bmNew.copy(Bitmap.Config.ARGB_8888, true);
userIndicator.icon(BitmapDescriptorFactory.fromBitmap(mutableBitmap)).anchor(0.5f, 1f);
Marker marker = map.addMarker(userIndicator);
model.setVehicleNumber(driverLoactionModel.getVehicleNumber());
marker.setTag(model);
LatLngBounds.Builder builder = LatLngBounds.builder();
builder.include(marker.getPosition());
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 150);
map.setMaxZoomPreference(15f);
map.animateCamera(cu);
}
map.setInfoWindowAdapter(new TrackDriverInfoWindowAdapter(getContext(), appComponent));
}
}
| [
"[email protected]"
] | |
6db58be65effb848e72aaa90aef846b624ed9445 | a722a2dc4373684325e437078f9bb8d6fa9b9a0c | /dailyLearning/src/main/java/com/slowgenius/thread/PlayThread.java | 777cff983b6a1dc4b5b62730cd07f44dcbb435e0 | [] | no_license | slowgenius/paceOfLearning | 42e1976ceaa1b2af6c8685bbe3fe16c13fc49b9d | 6a972c94387215ce770386e792f85d96a8f29dae | refs/heads/master | 2022-07-08T07:35:40.004947 | 2020-02-28T04:00:02 | 2020-02-28T04:00:02 | 227,969,076 | 1 | 0 | null | 2022-06-21T02:52:40 | 2019-12-14T05:05:15 | Java | UTF-8 | Java | false | false | 242 | java | package com.slowgenius.thread;
/**
* @author slowgenius
* @date 2/14/2020 2:58 PM
* @description
*/
public class PlayThread implements Runnable {
@Override
public void run() {
System.out.println("i am playing");
}
}
| [
"[email protected]"
] | |
239362c6ae79b700318c7db31d070ae76cd7cd46 | 840beab46a947402b73426da9b722064df81349d | /lib-algo/src/lse/math/games/lcp/TableauVariables.java | 7dddef9e2805ee8573324a1d72fb38b222d4812b | [] | no_license | alfongj/gte | cbaa4321aab466a299ce9429c29a1458df1a3ec0 | d310c4f003e7edbfae466c2c8e64e1de66feaa00 | refs/heads/master | 2021-01-21T00:44:37.871688 | 2013-03-05T23:47:02 | 2013-03-05T23:47:02 | 1,837,902 | 2 | 2 | null | null | null | null | UTF-8 | Java | false | false | 5,168 | java | package lse.math.games.lcp;
// TODO: Make inner static class of Tableau
public class TableauVariables {
/* VARS = 0..2n = Z(0) .. Z(n) W(1) .. W(n) */
/* ROWCOL = 0..2n, 0 .. n-1: tabl rows (basic vars) */
/* n .. 2n: tabl cols 0..n (cobasic) */
private int[] bascobas; /* VARS -> ROWCOL */
private int[] whichvar; /* ROWCOL -> VARS, inverse of bascobas */
private int n;
/* init tableau variables: */
/* Z(0)...Z(n) nonbasic, W(1)...W(n) basic */
/* This is for setting up a complementary basis/cobasis */
public TableauVariables(int sizeBasis)
{
n = sizeBasis;
bascobas = new int[2 * n + 1];
whichvar = new int[2 * n + 1];
for (int i = 0; i <= n; i++)
{
bascobas[z(i)] = n + i;
whichvar[n + i] = z(i);
}
for (int i = 1; i <= n; i++)
{
bascobas[w(i)] = i - 1;
whichvar[i - 1] = w(i);
}
}
/* create string s representing v in VARS, e.g. "w2" */
/* return value is length of that string */
public String toString(int var)
{
if (!isZVar(var))
return String.format("w%d", var - n);
else
return String.format("z%d", var);
}
@Override
public String toString()
{
StringBuilder output = new StringBuilder();
output.append("bascobas: [");
for (int i = 0; i < bascobas.length; i++)
{
output.append(String.format(" %d", bascobas[i]));
}
output.append(" ]");
return output.toString();
}
public void swap(int enterVar, int leaveVar, int leaveRow, int enterCol)
{
bascobas[leaveVar] = enterCol + n;
whichvar[enterCol + n] = leaveVar;
bascobas[enterVar] = leaveRow;
whichvar[leaveRow] = enterVar;
}
public int z(int idx)
{
return idx;
}
public int w(int idx)
{
return idx + n;
}
public int rowVar(int row)
{
return whichvar[row];
}
int colVar(int col)
{
return whichvar[col + n];
}
int row(int var)
{
return bascobas[var];
}
int col(int var)
{
return bascobas[var] - n;
}
public boolean isBasic(int var)
{
return (bascobas[var] < n);
}
public boolean isZVar(int var)
{
return (var <= n);
}
public int size()
{
return n;
}
/**
* TODO: This might belong in the Lemke Algorithm and not here.
* complement of v in VARS, error if v==Z(0).
* this is W(i) for Z(i) and vice versa, i=1...n
*/
public int complement(int var)
{
if (var == z(0))
throw new RuntimeException("Attempt to find complement of z0."); //TODO
return (!isZVar(var)) ? z(var - n) : w(var);
}
/* assert that v in VARS is a basic variable */
/* otherwise error printing info where */
public void assertBasic(int var)
{
if (!isBasic(var))
{
String error = String.format("Cobasic variable %s should be basic.", toString(var));
throw new RuntimeException(error); //TODO
}
}
/* assert that v in VARS is a cobasic variable */
/* otherwise error printing info where */
public void assertNotBasic(int var)
{
if (isBasic(var))
{
String error = String.format("Basic variable %s should be cobasic.", toString(var));
throw new RuntimeException(error); //TODO
}
}
/* test tableau variables: error => msg only, continue */
//MKE: should this be put in a unit test and be removed from runtime?
public void testTablVars()
{
String newline = System.getProperty("line.separator");
for (int i = 0; i <= 2 * n; i++) { /* check if somewhere tableauvars wrong */
if (bascobas[whichvar[i]] != i || whichvar[bascobas[i]] != i) { /* found an inconsistency, print everything */
StringBuilder output = new StringBuilder();
output.append("Inconsistent tableau variables:");
output.append(newline);
for (int j = 0; j <= 2 * n; j++) {
output.append(String.format(
"var j:%3d bascobas:%3d whichvar:%3d b[w[j]]==j: %1d w[b[j]]==j: %1d",
j, bascobas[j], whichvar[j], bascobas[whichvar[j]] == j, whichvar[bascobas[j]] == j));
output.append(newline);
}
//throw new Exception(output.ToString());
System.err.print(output.toString());
break;
}
}
}
}
| [
"[email protected]"
] | |
d746452d9b4aa6d8a3adc71dd95036a5ac16ba5c | c3b4a7cd75651de864efc87825bfc3c3f40f6195 | /GestioneSegreteriaLezione/src/main/java/it/unical/mat/webcomp21/model/CorsoDiLaurea.java | 29fec2977ddbb11f92ab536fb32f08a81b5b326b | [] | no_license | KristianReale/WebComp21 | f3373a1c040760eb7f080d40e69795e8775bf236 | 13dfe5316fd5c67c0b6929d409fb1289d6ca97c0 | refs/heads/master | 2023-02-04T04:29:00.396019 | 2020-12-24T11:40:32 | 2020-12-24T11:40:32 | 308,559,021 | 0 | 11 | null | 2021-09-21T18:25:21 | 2020-10-30T07:43:48 | Java | UTF-8 | Java | false | false | 531 | java | package it.unical.mat.webcomp21.model;
import java.util.ArrayList;
public class CorsoDiLaurea {
Long id;
String nome;
ArrayList<Studente> studenti;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public ArrayList<Studente> getStudenti() {
return studenti;
}
public void setStudenti(ArrayList<Studente> studenti) {
this.studenti = studenti;
}
}
| [
"[email protected]"
] | |
9cb8e630ae296cd57adce7b0d6a81fb86dbe52f7 | fa90ca291e1a5c55a281e4903298a052e9aae78a | /src/main/java/collections/TestMyList.java | 5f3f1c6090e1b34c8bd8edc13acd278fcf2aff2d | [] | no_license | makoJohn/DailyWork | b28d7f57e91ab9f492834f495a48c0f84c2f1e04 | 5bc749aad33cad4c1b1da1ff18ef25d3e8fa0a9f | refs/heads/master | 2021-08-30T02:27:29.632131 | 2017-12-15T18:06:15 | 2017-12-15T18:06:15 | 114,398,070 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 589 | java | package collections;
/**
*
*/
public class TestMyList {
public static void main(String[] args) {
// MyList<Integer> list = new MyArrayList<Integer>(100);
MyList<Integer> list = newMyList();
MyList<String> stringMyList = newMyList();
list.add(1);
list.add(2);
list.add(3);
MyArrayList<String> stringMyArrayList = TestMyList.newMyList();
System.out.println(list.size());
System.out.println(list.get(50));
}
public static <T> MyArrayList<T> newMyList() {
return new MyArrayList<T>();
}
}
| [
"[email protected]"
] | |
a23a3f86ae9f1fe5a591819cbc7414feeee57d8b | e1b07df88455888fa383d555cebd399415cfa93d | /src/main/java/app/ui/activity/Capitals.java | 2f742a9075c527402e79fd7b29f18913cc0b6f12 | [
"Apache-2.0"
] | permissive | weimaowu/Tool | 692fd4e61b9225e34a9638f236bbadd1c7b1c943 | 9bf1533164dcae460481c88df08ec1b736652cc3 | refs/heads/master | 2021-01-19T07:07:26.664401 | 2017-04-07T10:45:54 | 2017-04-07T10:45:54 | 87,524,527 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,107 | java | package app.ui.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import app.model.imple.NumberToCN;
/**
* Created by HSAEE on 2016/9/6.
*/
public class Capitals extends Activity implements View.OnClickListener {
String number1="";
TextView text1,text2;
ImageButton menu;
Button ac,one,two,three,four,five,six,seven,eight,nine,zero,dian;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.capitals);
text1=(TextView) findViewById(R.id.daxie1);
text2=(TextView) findViewById(R.id.daxie2);
ac=(Button) findViewById(R.id.D_ac);
one=(Button) findViewById(R.id.D_one);
two=(Button) findViewById(R.id.D_two);
three=(Button) findViewById(R.id.D_three);
four=(Button) findViewById(R.id.D_four);
five=(Button) findViewById(R.id.D_five);
six=(Button) findViewById(R.id.D_six);
seven=(Button) findViewById(R.id.D_seven);
eight=(Button) findViewById(R.id.D_eight);
nine=(Button) findViewById(R.id.D_nine);
zero=(Button) findViewById(R.id.D_zero);
dian=(Button) findViewById(R.id.D_dian);
menu= (ImageButton) findViewById(R.id.menu_D);
one.setOnClickListener(this);
two.setOnClickListener(this);
three.setOnClickListener(this);
four.setOnClickListener(this);
five.setOnClickListener(this);
six.setOnClickListener(this);
seven.setOnClickListener(this);
eight.setOnClickListener(this);
nine.setOnClickListener(this);
zero.setOnClickListener(this);
ac.setOnClickListener(this);
dian.setOnClickListener(this);
text1.setOnClickListener(this);
text2.setOnClickListener(this);
menu.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.D_one:
settext("1");
break;
case R.id.D_two:
settext("2");
break;
case R.id.D_three:
settext("3");
break;
case R.id.D_four:
settext("4");
break;
case R.id.D_five:
settext("5");
break;
case R.id.D_six:
settext("6");
break;
case R.id.D_seven:
settext("7");
break;
case R.id.D_eight:
settext("8");
break;
case R.id.D_nine:
settext("9");
break;
case R.id.D_zero:
settext("0");
break;
case R.id.D_dian:
if (number1.equals("")){settext("0.");
}else {if (!number1.contains(".")) {settext(".");}
}
break;
case R.id.D_ac:
number1="";
text1.setText("");
text2.setText("");
break;
case R.id.menu_D:
Intent intent = new Intent();
intent.setClass(Capitals.this,MainActivity.class);
startActivity(intent);
Capitals.this.finish();
break;
}
}
public void settext(String str){
number1=number1+str;
text1.setText(number1);
NumberToCN numberToCN=new NumberToCN(number1);
text2.setText(numberToCN.Transformation());
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode==KeyEvent.KEYCODE_BACK){
Intent intent=new Intent();
intent.setClass(Capitals.this,MainActivity.class);
startActivity(intent);
Capitals.this.finish();
}
return true;
}
}
| [
"[email protected]"
] | |
5bce1cebf676e601befe2f1a9c21255eabc5364e | 5741045375dcbbafcf7288d65a11c44de2e56484 | /reddit-decompilada/com/reddit/frontpage/presentation/modtools/modlist/ModListPagerScreen$DeepLinker$$Parcelable.java | 81f5331b50426620b3586cc4edb959eeeb1ff9b6 | [] | no_license | miarevalo10/ReporteReddit | 18dd19bcec46c42ff933bb330ba65280615c281c | a0db5538e85e9a081bf268cb1590f0eeb113ed77 | refs/heads/master | 2020-03-16T17:42:34.840154 | 2018-05-11T10:16:04 | 2018-05-11T10:16:04 | 132,843,706 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,899 | java | package com.reddit.frontpage.presentation.modtools.modlist;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import com.reddit.frontpage.presentation.modtools.modlist.ModListPagerScreen.DeepLinker;
import org.parceler.IdentityCollection;
import org.parceler.ParcelWrapper;
import org.parceler.ParcelerRuntimeException;
public class ModListPagerScreen$DeepLinker$$Parcelable implements Parcelable, ParcelWrapper<DeepLinker> {
public static final Creator<ModListPagerScreen$DeepLinker$$Parcelable> CREATOR = new C18621();
private DeepLinker deepLinker$$0;
/* compiled from: ModListPagerScreen$DeepLinker$$Parcelable */
static class C18621 implements Creator<ModListPagerScreen$DeepLinker$$Parcelable> {
C18621() {
}
public final /* bridge */ /* synthetic */ Object[] newArray(int i) {
return new ModListPagerScreen$DeepLinker$$Parcelable[i];
}
public final /* synthetic */ Object createFromParcel(Parcel parcel) {
return new ModListPagerScreen$DeepLinker$$Parcelable(ModListPagerScreen$DeepLinker$$Parcelable.read(parcel, new IdentityCollection()));
}
}
public int describeContents() {
return 0;
}
public ModListPagerScreen$DeepLinker$$Parcelable(DeepLinker deepLinker) {
this.deepLinker$$0 = deepLinker;
}
public void writeToParcel(Parcel parcel, int i) {
write(this.deepLinker$$0, parcel, i, new IdentityCollection());
}
public static void write(DeepLinker deepLinker, Parcel parcel, int i, IdentityCollection identityCollection) {
i = identityCollection.m28663b((Object) deepLinker);
if (i != -1) {
parcel.writeInt(i);
return;
}
parcel.writeInt(identityCollection.m28660a((Object) deepLinker));
parcel.writeString(deepLinker.subredditName);
}
public DeepLinker getParcel() {
return this.deepLinker$$0;
}
public static DeepLinker read(Parcel parcel, IdentityCollection identityCollection) {
int readInt = parcel.readInt();
if (!identityCollection.m28662a(readInt)) {
int a = identityCollection.m28660a(IdentityCollection.f27202a);
DeepLinker deepLinker = new DeepLinker();
identityCollection.m28661a(a, deepLinker);
deepLinker.subredditName = parcel.readString();
identityCollection.m28661a(readInt, deepLinker);
return deepLinker;
} else if (identityCollection.m28664b(readInt) == null) {
return (DeepLinker) identityCollection.m28665c(readInt);
} else {
throw new ParcelerRuntimeException("An instance loop was detected whild building Parcelable and deseralization cannot continue. This error is most likely due to using @ParcelConstructor or @ParcelFactory.");
}
}
}
| [
"[email protected]"
] | |
7a1fd32c9ddcc95e2d94ea32ae5e4ad96410788b | 68a7acc92e7312b4db75a4adc79469473d8dcc52 | /src/effectiveJava/NutritionFacts.java | 27f216cbf2157af5e0ddbb6858454c3f793e116d | [] | no_license | vasanthsubram/JavaCookBook | e83f95a9a08d6227455ebd213d216837ec1c97b5 | 3fb2dfc38a4bb56f21f329b0dbc8283609412840 | refs/heads/master | 2022-12-16T00:13:31.515018 | 2019-06-24T03:12:11 | 2019-06-24T03:12:11 | 30,102,351 | 0 | 0 | null | 2022-12-13T19:13:55 | 2015-01-31T04:39:51 | Java | UTF-8 | Java | false | false | 1,875 | java | package effectiveJava;
public class NutritionFacts {
private final int servingSize;
private final int servings;
private final int calories;
private final int fat;
private final int sodium;
private final int carbohydrate;
public static class Builder {
// Required parameters
private final int servingSize;
private final int servings;
// Optional parameters - initialized to default values
private int calories = 0;
private int fat = 0;
private int carbohydrate = 0;
private int sodium = 0;
public Builder(int servingSize, int servings) {
this.servingSize = servingSize;
this.servings = servings;
}
public Builder calories(int val)
{ calories = val; return this; }
public Builder fat(int val)
{ fat = val; return this; }
public Builder carbohydrate(int val)
{ carbohydrate = val; return this; }
public Builder sodium(int val)
{ sodium = val; return this; }
public NutritionFacts build() {
return new NutritionFacts(this);
}
}
private NutritionFacts(Builder builder) {
servingSize = builder.servingSize;
servings = builder.servings;
calories = builder.calories;
fat = builder.fat;
sodium = builder.sodium;
carbohydrate = builder.carbohydrate;
}
public String toString(){
return "calories = " +this.calories + ", Servings = " + this.servings;
}
public static void main(String args[]){
NutritionFacts cocaCola = new NutritionFacts.Builder(240, 8).
calories(100).sodium(35).carbohydrate(27).build();
System.out.println(cocaCola.toString());
}
}
| [
"[email protected]"
] | |
8a822247ae44d5ab7f93a1441e0e253ad94aa61c | 9f549b78ff78d3c98ecb82670cfa23318d6e9a0f | /wind-master/wind-master/wind-server/wind-web/wind-vue/src/main/java/com/sunseagear/wind/modules/task/entity/ScheduleJobLog.java | 9a16329def6a7b222b28e95a8c0f1379eebaf19e | [
"Apache-2.0"
] | permissive | shawnwong84/nuxt | cdd77993b5fa068f617c13104500011dcbe25806 | 80a4c7d9835afc0752b06cb567cf5cf6fad2be91 | refs/heads/master | 2023-08-14T18:21:23.669228 | 2021-09-29T06:46:38 | 2021-09-29T06:46:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,336 | java | package com.sunseagear.wind.modules.task.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sunseagear.common.mvc.entity.AbstractEntity;
import java.util.Date;
/**
* All rights Reserved, Designed By www.sunseagear.com
*
* @version V1.0
* @package com.sunseagear.wind.modules.task.entity
* @title: 任务日志实体
* @description: 任务日志实体 * @date: 2018-09-17 14:25:19
* @copyright: 2018 www.sunseagear.com Inc. All rights reserved.
*/
@TableName("task_schedule_job_log")
@SuppressWarnings("serial")
public class ScheduleJobLog extends AbstractEntity<String> {
public static final String SCHEDULE_JOB_LOG_RUN_SUCCESS = "1";
public static final String SCHEDULE_JOB_LOG_RUN_NOMAL = "0";
public static final String SCHEDULE_JOB_LOG_RUN_FAIL = "-1";
/**
* 任务日志ID
*/
@TableId(value = "id", type = IdType.UUID)
private String id;
/**
* 任务名称
*/
@TableField(value = "job_name")
private String jobName;
/**
* 任务组名
*/
@TableField(value = "job_group")
private String jobGroup;
/**
* Spring bean
*/
@TableField(value = "execute_class")
private String executeClass;
/**
* 任务方法
*/
@TableField(value = "method_name")
private String methodName;
/**
* 方法参数
*/
@TableField(value = "method_params")
private String methodParams;
/**
* 日志信息
*/
@TableField(value = "job_message")
private String jobMessage;
/**
* 执行状态(0正常 1失败)
*/
@TableField(value = "status")
private String status;
/**
* 异常信息
*/
@TableField(value = "exception_info")
private String exceptionInfo;
/**
* 创建时间
*/
@TableField(value = "create_time")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 获取 id
*
* @return String 任务日志ID
*/
public String getId() {
return this.id;
}
/**
* 设置 id
*
* @param id 任务日志ID
*/
public void setId(String id) {
this.id = id;
}
/**
* 获取 jobName
*
* @return String 任务名称
*/
public String getJobName() {
return this.jobName;
}
/**
* 设置 jobName
*
* @param jobName 任务名称
*/
public void setJobName(String jobName) {
this.jobName = jobName;
}
/**
* 获取 jobGroup
*
* @return String 任务组名
*/
public String getJobGroup() {
return this.jobGroup;
}
/**
* 设置 jobGroup
*
* @param jobGroup 任务组名
*/
public void setJobGroup(String jobGroup) {
this.jobGroup = jobGroup;
}
public String getExecuteClass() {
return executeClass;
}
public void setExecuteClass(String executeClass) {
this.executeClass = executeClass;
}
/**
* 获取 methodName
*
* @return String 任务方法
*/
public String getMethodName() {
return this.methodName;
}
/**
* 设置 methodName
*
* @param methodName 任务方法
*/
public void setMethodName(String methodName) {
this.methodName = methodName;
}
/**
* 获取 methodParams
*
* @return String 方法参数
*/
public String getMethodParams() {
return this.methodParams;
}
/**
* 设置 methodParams
*
* @param methodParams 方法参数
*/
public void setMethodParams(String methodParams) {
this.methodParams = methodParams;
}
/**
* 获取 jobMessage
*
* @return String 日志信息
*/
public String getJobMessage() {
return this.jobMessage;
}
/**
* 设置 jobMessage
*
* @param jobMessage 日志信息
*/
public void setJobMessage(String jobMessage) {
this.jobMessage = jobMessage;
}
/**
* 获取 status
*
* @return String 执行状态(0正常 1失败)
*/
public String getStatus() {
return this.status;
}
/**
* 设置 status
*
* @param status 执行状态(0正常 1失败)
*/
public void setStatus(String status) {
this.status = status;
}
/**
* 获取 exceptionInfo
*
* @return String 异常信息
*/
public String getExceptionInfo() {
return this.exceptionInfo;
}
/**
* 设置 exceptionInfo
*
* @param exceptionInfo 异常信息
*/
public void setExceptionInfo(String exceptionInfo) {
this.exceptionInfo = exceptionInfo;
}
/**
* 获取 createTime
*
* @return Date 创建时间
*/
public Date getCreateTime() {
return this.createTime;
}
/**
* 设置 createTime
*
* @param createTime 创建时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
| [
"[email protected]"
] | |
f6bea951c2264d165048a7e8e011cf5a39bb85e4 | 627e53c2a811d802c3c0c55da7bec521e24624ec | /src/main/java/com/vote/demo/entity/Total.java | f62dd4a0f08013fc535fd9a48ba2535e37470237 | [] | no_license | teerakitt/exam_mvc | 88b9e3267a0b9586573ba8a2b305fc40c22e674c | 533234214795e55f68724eafebb00e5f95a481e2 | refs/heads/master | 2023-03-21T19:02:14.387660 | 2021-03-20T18:18:53 | 2021-03-20T18:18:53 | 349,800,664 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 973 | java | package com.vote.demo.entity;
import com.sun.istack.Nullable;
import javax.persistence.*;
@Entity
@Table(name = "total")
public class Total {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private int stuId;
private int subId;
@Nullable
private int vote;
@Nullable
private int score;
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getStuId() {
return stuId;
}
public void setStuId(int stuId) {
this.stuId = stuId;
}
public int getSubId() {
return subId;
}
public void setSubId(int subid) {
this.subId = subid;
}
public int getVote() {
return vote;
}
public void setVote(int vote) {
this.vote = vote;
}
}
| [
"Landslot20"
] | Landslot20 |
62dfd084c69d8fb17015bbd112efb794052a334d | ac0b06d8ab9414a0b0c114ee76043d7cccb26523 | /quiz-backend/src/test/java/com/lukaklacar/quiz/security/jwt/TokenProviderTest.java | 03c15ca51ad725ae4f132c01df8b55025e1c3b10 | [] | no_license | BulkSecurityGeneratorProject1/quiz | d7060f198d22406bfed389535f34a0623e5022ef | a5f20a4cebae9fab739574f22b88e5e6e4ae454d | refs/heads/master | 2022-12-22T07:52:13.838949 | 2019-02-04T14:59:38 | 2019-02-04T14:59:38 | 296,579,104 | 0 | 0 | null | 2020-09-18T09:41:58 | 2020-09-18T09:41:57 | null | UTF-8 | Java | false | false | 3,974 | java | package com.lukaklacar.quiz.security.jwt;
import com.lukaklacar.quiz.security.AuthoritiesConstants;
import java.security.Key;
import java.util.*;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.test.util.ReflectionTestUtils;
import io.github.jhipster.config.JHipsterProperties;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
import static org.assertj.core.api.Assertions.assertThat;
public class TokenProviderTest {
private final long ONE_MINUTE = 60000;
private Key key;
private JHipsterProperties jHipsterProperties;
private TokenProvider tokenProvider;
@Before
public void setup() {
jHipsterProperties = Mockito.mock(JHipsterProperties.class);
tokenProvider = new TokenProvider(jHipsterProperties);
key = Keys.hmacShaKeyFor(Decoders.BASE64
.decode("fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8"));
ReflectionTestUtils.setField(tokenProvider, "key", key);
ReflectionTestUtils.setField(tokenProvider, "tokenValidityInMilliseconds", ONE_MINUTE);
}
@Test
public void testReturnFalseWhenJWThasInvalidSignature() {
boolean isTokenValid = tokenProvider.validateToken(createTokenWithDifferentSignature());
assertThat(isTokenValid).isEqualTo(false);
}
@Test
public void testReturnFalseWhenJWTisMalformed() {
Authentication authentication = createAuthentication();
String token = tokenProvider.createToken(authentication, false);
String invalidToken = token.substring(1);
boolean isTokenValid = tokenProvider.validateToken(invalidToken);
assertThat(isTokenValid).isEqualTo(false);
}
@Test
public void testReturnFalseWhenJWTisExpired() {
ReflectionTestUtils.setField(tokenProvider, "tokenValidityInMilliseconds", -ONE_MINUTE);
Authentication authentication = createAuthentication();
String token = tokenProvider.createToken(authentication, false);
boolean isTokenValid = tokenProvider.validateToken(token);
assertThat(isTokenValid).isEqualTo(false);
}
@Test
public void testReturnFalseWhenJWTisUnsupported() {
String unsupportedToken = createUnsupportedToken();
boolean isTokenValid = tokenProvider.validateToken(unsupportedToken);
assertThat(isTokenValid).isEqualTo(false);
}
@Test
public void testReturnFalseWhenJWTisInvalid() {
boolean isTokenValid = tokenProvider.validateToken("");
assertThat(isTokenValid).isEqualTo(false);
}
private Authentication createAuthentication() {
Collection<GrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority(AuthoritiesConstants.ANONYMOUS));
return new UsernamePasswordAuthenticationToken("anonymous", "anonymous", authorities);
}
private String createUnsupportedToken() {
return Jwts.builder()
.setPayload("payload")
.signWith(key, SignatureAlgorithm.HS512)
.compact();
}
private String createTokenWithDifferentSignature() {
Key otherKey = Keys.hmacShaKeyFor(Decoders.BASE64
.decode("Xfd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8"));
return Jwts.builder()
.setSubject("anonymous")
.signWith(otherKey, SignatureAlgorithm.HS512)
.setExpiration(new Date(new Date().getTime() + ONE_MINUTE))
.compact();
}
}
| [
"[email protected]"
] | |
4e9dd6a68a11571f1f565d419d8997b1d6554d2e | f9639c02d97ab6eab1e42624f62e207d1315f17e | /src/main/controllers/OpenTimeslotsForTimeResponse.java | 4762487889bb2136f4357dd310650e6fe0aefcf7 | [] | no_license | kmgumienny/AWS-Software-Engineering | 389d864a9424c754911d847d22a5f9fac114af1d | 38c634f156ca1b066ec13d47bd7e58c7db9e71eb | refs/heads/master | 2020-04-05T05:13:33.958290 | 2018-12-15T03:35:57 | 2018-12-15T03:35:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 429 | java | package main.controllers;
public class OpenTimeslotsForTimeResponse {
String message;
int httpCode;
public OpenTimeslotsForTimeResponse (String message, int code) {
this.message = message;
this.httpCode = code;
}
// 200 means success
public OpenTimeslotsForTimeResponse (String message) {
this.message = message;
this.httpCode = 200;
}
public String toString() {
return "Response(" + message + ")";
}
}
| [
"[email protected]"
] | |
b6f02f4ecf3fd1f15f06766338ac2d1f69c115b2 | 23e56a77b85757b0d07051ff65583b198cbc2143 | /CC.java | fb62047716060edd4d8eb255d0e0e00c94840c28 | [] | no_license | shwethahitha/shwetha1 | ead0c6043ebca4d792a36b6140f5fa4b686a6711 | 69973cc190d042ff48d259cea3bea256517aa747 | refs/heads/master | 2020-04-02T16:31:22.066661 | 2018-10-25T05:48:05 | 2018-10-25T05:48:05 | 154,616,056 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 265 | java | package Training;
public class CC {
public static void main(String[] args) {
int i, j;
for(i=0; i<=5; i++) {
for(j=0; j<=5; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
/*******
******
******
******
******
******
*/ | [
"[email protected]"
] | |
c99fb41996be12d436a022ca300434aa7049a5ed | 62e4df675410ef5b39746461ad707b500998046c | /src/test/java/com/qa/hubspot/tests/HomePageTest.java | 6d33320f8785d444cf6b64bbaf713e94a308fef3 | [] | no_license | muraribec/MarchPOMFramework | 4ee3a1eae3d579edb227f219452bafd055a8108a | ef20fcee9b0c211fbe68824335c7b023857b0f93 | refs/heads/master | 2022-07-06T21:13:33.759055 | 2020-06-02T05:57:17 | 2020-06-02T05:57:17 | 245,322,429 | 0 | 0 | null | 2022-06-29T18:21:33 | 2020-03-06T03:33:18 | HTML | UTF-8 | Java | false | false | 1,307 | java | package com.qa.hubspot.tests;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.qa.hubspot.base.BasePage;
import com.qa.hubspot.constants.Constants;
import com.qa.hubspot.pages.HomePage;
import com.qa.hubspot.pages.LoginPage;
public class HomePageTest {
WebDriver driver;
BasePage basePage;
Properties prop;
LoginPage loginPage;
HomePage homePage;
@BeforeMethod
public void setUp(){
basePage=new BasePage();
prop = basePage.initialize_Properties();
driver = basePage.initialize_driver(prop);
loginPage = new LoginPage(driver);
homePage=loginPage.doLogin(prop.getProperty("username"), prop.getProperty("password"));
}
@Test(priority=1)
public void verifyHomePageTitleTest(){
String title = homePage.getHomePageTitle();
System.out.println("homepage title is " + title);
Assert.assertEquals(title, Constants.HOME_PAGE_TITLE);
}
@Test(priority=2)
public void verifyHomePageHeaderTest(){
Assert.assertTrue(homePage.verifyHomePageHeader());
Assert.assertEquals(homePage.getHomePageHeaderText(), Constants.HOME_PAGE_HEADER);
}
@AfterMethod
public void tearDown(){
driver.quit();
}
}
| [
"[email protected]"
] | |
9c0f8b4136bdde4523314ab6fc648661783ea77e | f6c9a8ac13417b1b6daae97309291acac85a0b04 | /JAVA/src/main/java/com/sandu/xinye/api/font/FontController.java | 35a10423a75d2ba00a8a5ad9d222aa19725e7378 | [] | no_license | huanghtang/Hello | 55bbbdea49fcd65fb5ceefe09762a00812988963 | 4275fae16b9f59638474218ed799d8454e9720c9 | refs/heads/master | 2020-05-02T10:38:56.792669 | 2019-03-27T03:03:28 | 2019-03-27T03:03:28 | 177,902,746 | 0 | 0 | null | 2019-03-27T02:36:57 | 2019-03-27T02:21:07 | null | UTF-8 | Java | false | false | 584 | java | package com.sandu.xinye.api.font;
import com.jfinal.aop.Clear;
import com.sandu.xinye.common.controller.AppController;
import com.sandu.xinye.common.kit.RetKit;
public class FontController extends AppController {
/***
*
* @Title 获取字体列表
* @Description
* @param text pageNumber 1
* @param text pageSize 10
* @return
*
*/
@Clear
public void getFont(){
RetKit ret = FontService.me.getFont();
renderJson(ret);
}
@Clear
public void downloadFont(){
int fontId = getParaToInt("fontId");
renderFile(FontService.me.downloadFile(fontId));
}
}
| [
"[email protected]"
] | |
2e636cea2b595de470692aadfecc3ca56345851c | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/apache--zeppelin/4d398ef2a6471614cebd6b0177a08333114f5802/before/ClassloaderInterpreter.java | 8389da2e5094fa314b8a0c519963b340f0d35f12 | [] | no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,709 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.zeppelin.interpreter;
import java.net.URL;
import java.util.List;
import java.util.Properties;
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.scheduler.Scheduler;
/**
* Add to the classpath interpreters.
*
*/
public class ClassloaderInterpreter
extends Interpreter
implements WrappedInterpreter {
private ClassLoader cl;
private Interpreter intp;
public ClassloaderInterpreter(Interpreter intp, ClassLoader cl) {
super(new Properties());
this.cl = cl;
this.intp = intp;
}
@Override
public Interpreter getInnerInterpreter() {
return intp;
}
public ClassLoader getClassloader() {
return cl;
}
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
return intp.interpret(st, context);
} catch (InterpreterException e) {
throw e;
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public void open() {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
intp.open();
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public void close() {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
intp.close();
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public void cancel(InterpreterContext context) {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
intp.cancel(context);
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public FormType getFormType() {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
return intp.getFormType();
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public int getProgress(InterpreterContext context) {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
return intp.getProgress(context);
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public Scheduler getScheduler() {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
return intp.getScheduler();
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public List<InterpreterCompletion> completion(String buf, int cursor) {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
List completion = intp.completion(buf, cursor);
return completion;
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public String getClassName() {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
return intp.getClassName();
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public void setInterpreterGroup(InterpreterGroup interpreterGroup) {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
intp.setInterpreterGroup(interpreterGroup);
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public InterpreterGroup getInterpreterGroup() {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
return intp.getInterpreterGroup();
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public void setClassloaderUrls(URL [] urls) {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
intp.setClassloaderUrls(urls);
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public URL [] getClassloaderUrls() {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
return intp.getClassloaderUrls();
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public void setProperty(Properties property) {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
intp.setProperty(property);
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public Properties getProperty() {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
return intp.getProperty();
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
@Override
public String getProperty(String key) {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try {
return intp.getProperty(key);
} catch (Exception e) {
throw new InterpreterException(e);
} finally {
cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(oldcl);
}
}
} | [
"[email protected]"
] | |
fa07955eeaa5cd7a9ffea07271264634f21a9291 | 8a317d3a5754b35ae23929b4b2a8d3c55e5e33e7 | /src/main/java/dregsmod/patches/stances/AbstractStancePatch.java | 473c1503bd6c4ae8009e9785b53a97ce25c1e957 | [
"MIT"
] | permissive | arasmus8/DregsMod | 14a1116078c9b5a21543f1507c23ebc6640ea1c0 | 0bff2dd82d4a6f4bc7e791966c507e183db32828 | refs/heads/master | 2022-11-16T17:54:36.857700 | 2022-11-08T17:17:25 | 2022-11-08T17:17:25 | 234,659,791 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 795 | java | package dregsmod.patches.stances;
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;
import com.evacipated.cardcrawl.modthespire.lib.SpireReturn;
import com.megacrit.cardcrawl.stances.AbstractStance;
import dregsmod.stances.AcceptanceStance;
import dregsmod.stances.DenialStance;
@SpirePatch(
clz = AbstractStance.class,
method = "getStanceFromName"
)
public class AbstractStancePatch {
public static SpireReturn<AbstractStance> Prefix(String name) {
if (name.equals(AcceptanceStance.STANCE_ID)) {
return SpireReturn.Return(new AcceptanceStance());
} else if (name.equals(DenialStance.STANCE_ID)) {
return SpireReturn.Return(new DenialStance());
} else {
return SpireReturn.Continue();
}
}
}
| [
"[email protected]"
] | |
f8b9ff7e0e58ab296dec73ecca69a8e5eefb5849 | bee163d14944995a50e3a07bbf631ec0a665046a | /src/main/java/de/hsa/inf/ml/tictactoe/player/CheatingPlayer.java | a710adba3fd6853a2fcf42704859d52f68e5592f | [] | no_license | 999eagle/tictactoe | 38320b121d8fc65d35f0be4809e77955360c3d1c | fa962d360a678fd584133bdba0cd6c42c4d29f69 | refs/heads/master | 2021-01-19T21:47:51.049024 | 2017-05-31T06:33:07 | 2017-05-31T06:33:07 | 88,708,449 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 629 | java | package de.hsa.inf.ml.tictactoe.player;
import de.hsa.inf.ml.tictactoe.Board;
import java.lang.reflect.Field;
import java.util.List;
/**
* Created by erik on 2017-04-19.
*/
public class CheatingPlayer extends Player {
@Override
public int move(Board board) {
try
{
Field stateField = board.getClass().getDeclaredField("state");
stateField.setAccessible(true);
List<Integer> state = (List<Integer>) stateField.get(board);
state.set(0, 0);
for(int i = 1; i < board.getSize(); i++) {
state.set(i, this.getId());
}
stateField.set(board, state);
}
catch (Exception e)
{
}
return 0;
}
}
| [
"[email protected]"
] | |
52b1cf44285369215876bd965fd26849d76f4b02 | 8940a415592aee3d3aaaff93f12f267f738f629b | /LearnCodePractice/src/SEGMENT_TREE_LAZY/Main.java | 38968bc165d4d7a4dd6ca97666b0925e4b59eef0 | [] | no_license | bala1074/winner2019 | f32c0983b41ef36d23ae4a72262f81dc0ae94ffc | 829b19111d708643f58ec8718368aadc50b8fd80 | refs/heads/master | 2020-05-22T06:10:44.966028 | 2019-06-10T05:54:15 | 2019-06-10T05:54:15 | 186,248,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,601 | java | package SEGMENT_TREE_LAZY;
public class Main {
public static void main(String[] args) {
}
public static void build(int arr[], int s, int e, int tree[], int treeNode) {
if (s > e)
return;
if (s == e) {
tree[treeNode] = arr[s];
return;
}
int mid = (s + e) / 2;
build(arr, s, mid, tree, 2 * treeNode);
build(arr, mid + 1, e, tree, 2 * treeNode + 1);
tree[treeNode] = tree[2 * treeNode] + tree[2 * treeNode + 1];
}
public static void update(int arr[], int s, int e, int tree[], int lazy[], int treeNode, int ul, int ur, int val) {
if (s > e)
return;
if (lazy[treeNode] != 0) {
tree[treeNode] += lazy[treeNode];
if (s != e) {
lazy[2 * treeNode] += lazy[treeNode];
lazy[2 * treeNode + 1] += lazy[treeNode];
}
lazy[treeNode] = 0;
}
// no overlap
if (s > ur || e < ul)
return;
// complete overlap
if (s >= ul && e <= ur) {
tree[treeNode] += val;
if (s != e) {
lazy[2 * treeNode] += val;
lazy[2 * treeNode + 1] += val;
}
return;
}
// partial
int mid = (s + e) / 2;
update(arr, mid + 1, e, tree, lazy, 2 * treeNode + 1, ul, ur, val);
update(arr, s, mid, tree, lazy, 2 * treeNode, ul, ur, val);
tree[treeNode] = Math.min(tree[2 * treeNode], tree[2 * treeNode + 1]);
}
public static int query(int tree[], int s, int e, int treeNode, int l, int r) {
if (s > r || e < l)
return 0;
if (s >= l && e <= r)
return tree[treeNode];
int mid = (s + e) / 2;
int ans1 = query(tree, s, mid, 2 * treeNode, l, r);
int ans2 = query(tree, mid + 1, e, 2 * treeNode + 1, l, r);
return ans1 + ans2;
}
}
| [
"[email protected]"
] | |
95587e611c96e9249554908f09734cefc6b9c4a4 | 11bff337afbc83abcba4da1b24cd9eefc840371e | /src/main/java/com/siwoo/p1000/P1748.java | e4bb627c3810b3e423a01ef512f3f937fffd810f | [] | no_license | Siwoo-Kim/algorithm2020 | e090cb34a522e65e2ad16b11d580ab1407b3aa28 | c02e21382764cd003bc9252bda4fec82e56cba07 | refs/heads/master | 2023-02-11T22:16:01.316314 | 2020-12-25T17:53:32 | 2020-12-25T17:53:32 | 297,472,354 | 0 | 0 | null | 2020-10-02T23:12:26 | 2020-09-21T22:10:28 | Java | UTF-8 | Java | false | false | 811 | java | package com.siwoo.p1000;
import com.siwoo.util.Algorithm;
import com.siwoo.util.Used;
import java.util.Scanner;
/**
* 1 의 자리수 -> 갯수 (10-1) * 1
* 2 의 자리수 -> 갯수 (100-1 - (10+1)) * 2
* 3 의 자리수 -> 갯수 (1000-1 - (100+1)) * 3
*
* O(length(N))
*/
@Used(algorithm = Algorithm.BRUTE_FORCE)
public class P1748 {
private static int N;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
N = scanner.nextInt();
int len = 1, start=1;
long cnt = 0;
while (start <= N) {
int last = start * 10 -1;
if (last > N)
last = N;
cnt += (last - start + 1) * len;
start *= 10;
len++;
}
System.out.println(cnt);
}
}
| [
"[email protected]"
] | |
b14bb071d9442ef96e73672e87e8763080d75c3b | 20dc30aeec04a8223286480bfaa130e11b651638 | /src/main/java/me/wook/springboot/movie/service/MovieServiceImpl.java | 50ed2d161e06981ec6adbeb8281adf13aafb2337 | [] | no_license | tanbinh123/spring-boot-theater | 13a1ff2795118a76ced359f0c437f05c34085908 | d6160a4fae6f4e2007842747359c077455eb2036 | refs/heads/master | 2023-03-18T04:27:07.327353 | 2020-02-09T14:45:05 | 2020-02-09T14:45:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,792 | java | package me.wook.springboot.movie.service;
import java.util.Optional;
import me.wook.springboot.exception.MovieException;
import me.wook.springboot.movie.entity.Movie;
import me.wook.springboot.movie.factory.MovieFactory;
import me.wook.springboot.movie.repository.MovieRepository;
import me.wook.springboot.web.dto.MovieDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@Service
public class MovieServiceImpl implements MovieService {
private MovieRepository movieRepository;
@Autowired
public MovieServiceImpl(MovieRepository movieRepository) {
this.movieRepository = movieRepository;
}
@Override
public Page<Movie> list(final Pageable pageable) {
return movieRepository.findAll(pageable);
}
@Override
public Movie detail(final long id) {
return movieRepository.findById(id)
.orElseThrow(() -> new MovieException("{id: " + id + "}"));
}
@Override
public boolean add(final MovieDTO movieDto) {
return Optional.of(movieRepository.save(MovieFactory.movie(movieDto))).isPresent();
}
@Override
public boolean update(final long id, final MovieDTO movieDTO) {
movieRepository.findById(id).ifPresent(movie -> {
movie = MovieFactory.movie(id, movieDTO);
Optional.of(movieRepository.save(movie))
.orElseThrow(() -> new MovieException(movieDTO));
});
return movieRepository.findById(id).isPresent();
}
@Override
public boolean delete(final long id) {
movieRepository.findById(id).ifPresent(movie -> {
movie.setId(id);
movieRepository.delete(movie);
});
return movieRepository.findById(id).isPresent() == false;
}
} | [
"[email protected]"
] | |
bcc5996fc58aaa0791f691ba5de40cb495c75d8a | f0587ab5ea5d482d7848876ace944863f3c0641d | /src/com/mao/service/ExportExcelService.java | e124d740ed70eb7ceacd24345b2cd9611075a020 | [] | no_license | heiyun1992/LabEquMagSystem3.2 | 21f7077315c19c4c2451c3e22ca74e9c41acab2b | 13a82a7157bfb70dc6b0f6d1ecaca051d37e7e0a | refs/heads/master | 2021-01-22T10:17:38.931499 | 2015-07-15T09:12:44 | 2015-07-15T09:12:44 | 39,123,695 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 336 | java | package com.mao.service;
import java.util.List;
import javax.servlet.ServletOutputStream;
import com.mao.pojo.EquipmentUsed;
/**
* Created by maozhongzhen on 2015年5月28日.
*/
public interface ExportExcelService {
public void exportExcel(List<EquipmentUsed> equipmentList,String [] titles,ServletOutputStream outputStream);
}
| [
"[email protected]"
] | |
93cf4fe98bc377d5e2910fc3e5ebcbd51c71c60d | 21843bdca3d2140b9e469b1e6846fa706de2376f | /daviscahtech_bookmanagement/dao/DatabaseConnection.java | 743b4764216b9dde4569408f6b1a6ba770361ff1 | [] | no_license | DavisDeco/bookStoreInventoryManagement | 1cd04a00fd98339a6671670760222275f8a8e5b3 | bb2f10009acef46dd0dc8f264efb97ad49cbb976 | refs/heads/master | 2020-03-24T00:06:14.398946 | 2018-07-25T08:53:38 | 2018-07-25T08:53:38 | 142,273,466 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,496 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package daviscahtech_bookmanagement.dao;
import daviscahtech_bookmanagement.Preferences.LocalServerPreference;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javafx.scene.control.Alert;
/**
*
* @author davis
*/
public class DatabaseConnection {
public static Connection connectDb(){
LocalServerPreference preference = LocalServerPreference.getPreferences();
Connection con = null;
try {
String url= "jdbc:mysql://localhost:3306/com.daviscahtech.bookmanagement";
String username = preference.getE();
String password =preference.getD();
Class.forName("com.mysql.jdbc.Driver");// load the mysql driver
con = DriverManager.getConnection(url,username,password);
return con;
} catch (ClassNotFoundException | SQLException e) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Database-system Connetion Error!");
alert.setHeaderText(null);
alert.setContentText("Connection to the database Failed. \n Activate Database \n");
alert.showAndWait();
return null;
}
}
}
| [
"[email protected]"
] | |
88a94d529fd22f061d49d5b8a0c8f1547ea18005 | 92a70682b466e167d908811532b8ea6a588e68f7 | /src/main/java/com/walter/dao/CategoryDao.java | 5238d07c01a0017b7e8bfe6f4015945d1ca0caa9 | [] | no_license | mingyu-lee/spring4Blog | 10c8d6e11d9a19d0ead1017df7403db6bf593af8 | 6a8987870f8638b0d711cf852263e5a4099c5d0c | refs/heads/master | 2020-03-22T02:52:22.755601 | 2018-05-22T14:33:32 | 2018-05-22T14:33:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 513 | java | package com.walter.dao;
import com.walter.model.CategoryVO;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
/**
* Created by yhwang131 on 2016-10-04.
*/
@Component
public interface CategoryDao {
List<CategoryVO> getCategoryList();
CategoryVO getCategoryItemByCd(int category_cd);
int getCategoryCountByName(String category_name);
int insCategoryItem(CategoryVO categoryVO);
int modCategoryItem(HashMap paramMap);
int delCategoryItem(int categoryCd);
}
| [
"[email protected]"
] | |
9738ed4ca2579d501c42fef1414ac06eb0b177c5 | fa4ccc1aaadfb4ab68807c86ac3d750aa435d0f5 | /QRTracker/app/src/main/java/daielchom/qrtracker/fragmentList.java | 2dcf2b3fba92f24854009f9b16b6ba0e953b84f9 | [] | no_license | DaielChom/QRTrackerApp | f958167e50fdec4fb524518f73d069be66f8955a | 18779b9a0239ab82041cdbb54d3ad9f6037b8487 | refs/heads/master | 2020-12-02T17:49:46.408913 | 2017-07-24T20:42:03 | 2017-07-24T20:42:03 | 96,435,638 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,873 | java | package daielchom.qrtracker;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static android.R.attr.data;
/**
* Created by daielchom on 8/07/17.
*/
public class fragmentList extends Fragment {
private ListView listPackage;
private View view;
private packageAdapter adapter;
public fragmentList(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
view = inflater.inflate(R.layout.fragment_list, container, false);
listPackage = (ListView) view.findViewById(R.id.listPackage);
QRTrackerService api = retrofitClient.getClient().create(QRTrackerService.class);
Map<String, String> options = new HashMap<>();
options.put("state","BodegaANDRecogido");
Call<paqueteList> call = api.getPackageList(options);
call.enqueue(new Callback<paqueteList>(){
@Override
public void onResponse(Call<paqueteList> call, Response<paqueteList> response) {
adapter = new packageAdapter(getContext(),response.body().getPaqueteList());
listPackage.setAdapter(adapter);
}
@Override
public void onFailure(Call<paqueteList> call, Throwable t) {
//Toast.makeText(fragmentList.this,"Error", Toast.LENGTH_SHORT).show();
Log.d("x",t.toString());
}
});
return view;
}
}
| [
"[email protected]"
] | |
629cd0af799d8b7941ac260b65b481d21a2335b5 | d1e745af2aa33e86b11f0f81373d7cff4923454f | /app/src/test/java/com/anythingintellect/mydeliveries/ExampleUnitTest.java | 8e263270965bd13dc92ea1461b302dd67b1727bb | [] | no_license | SaulRiglez/my-deliveries | 91cc83c3bd6902519cd39c9881ed19cd76047095 | e5d044a4cac528cccdd1d8c84ecdfc16253c6394 | refs/heads/master | 2021-04-05T23:50:29.948594 | 2017-09-05T10:22:32 | 2017-09-05T10:22:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 412 | java | package com.anythingintellect.mydeliveries;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
4275bb558c6d8aa8f6f3acebcf48006c752909fc | 563b14d611ecffc69201c9a6cd422b4115df6ad8 | /src/edu/wit/cs/comp1050/PA4d.java | 30bccc8f9b817368df6e73749c62c065eae9df01 | [] | no_license | adamcrussell/comp1050-pa4-oop2-student | 99af158d11ee8c163d30a46ece12070dcb2be93f | 1236d0af5c1d15d7894aeb2459a45d19204a781c | refs/heads/master | 2023-03-23T22:37:46.531103 | 2019-11-15T18:10:03 | 2019-11-15T18:10:03 | 347,373,860 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 417 | java | package edu.wit.cs.comp1050;
import java.util.Scanner;
import edu.wit.cs.comp1050.TriangleObject;
//TODO: document this class
public class PA4d {
/**
* Reads triangle sides from the keyboard and
* outputs various properties of that triangle to console
*
* @param args command-line arguments, ignored
*/
public static void main(String[] args) {
// TODO: write your code here
}
}
| [
"[email protected]"
] | |
2fa28d6966bcc32ef353ffb6f252ebd466e9baaa | ace3866b9e81df756cf37f2e0790cdfa8e61b02b | /src/main/java/com/kd/App.java | 912fcf624b4e7c1dba5cc55e2644388e4aeaef44 | [] | no_license | gowreswaran/sample-sonar-test | 1e968ddc0ad1ab90a1f69b8ee69d5122ed1e8f20 | 80d07793fdcbe9b05379ab4839c32114e21f77da | refs/heads/master | 2022-12-28T17:32:04.369557 | 2020-06-22T06:20:40 | 2020-06-22T06:20:40 | 274,052,709 | 0 | 0 | null | 2020-10-13T22:58:43 | 2020-06-22T06:01:28 | Java | UTF-8 | Java | false | false | 669 | java | package com.kd;
/**
* Hello world!
*
*/
public class App {
public static void main(String[] args) {
boolean a = true;
if (a) {
m1(5);
} else {
m2();
m3(5);
}
m2();
m3(5);
}
private static String m2() {
String name = "hello";
switch (name) {
case "hello":
return name.toUpperCase();
case "hello1":
return name;
default:
return name.toLowerCase();
}
}
private static void m1(int a) {
System.out.println("Hello");
}
private static int m3(int a) {
System.out.println("Hello");
if (a == 5) {
return 25 * a;
}
if (a == 5) {
return 25 * a;
}
if (a == 10) {
return 25 * a;
}
return 75;
}
}
| [
"[email protected]"
] | |
0ba6bd261360f067b548f57cb921ba0f4b13bbd9 | 37992a7083efea148c66381a2e7c988f59de712b | /chit/chit_data/src/main/java/ru/ppr/chit/data/db/DbMigrationManager.java | 1ee6a2c0aa1439764bd9e0465190ab995792f16f | [] | no_license | RVC3/PTK | 5ab897d6abee1f7f7be3ba49c893b97e719085e9 | 1052b2bfa8f565c96a85d5c5928ed6c938a20543 | refs/heads/master | 2022-12-22T22:11:40.231298 | 2020-07-01T09:45:38 | 2020-07-01T09:45:38 | 259,278,530 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 339 | java | package ru.ppr.chit.data.db;
import ru.ppr.database.Database;
/**
* Менеджер, осуществляющий миграцию на новую версию структуры локальной БД.
*
* @author Aleksandr Brazhkin
*/
public interface DbMigrationManager {
void upgradeIfNeed(Database db) throws Exception;
}
| [
"[email protected]"
] | |
c79d77d89b42069d2c41abe2428fd92fde03a737 | e77e9f41e9ff6522dbceec1f7d9b97582252a10e | /CharacterCount.java | 6a2896044f623d77cb219d90ffffc423d26afc74 | [] | no_license | RanjithDevi/JavaTrainings | 0d3e377a23df56a85eb1c96def6c7042d2ae3931 | aa0f13dac15ff1b313f6901648c1164a03f53819 | refs/heads/master | 2022-12-22T03:05:48.596651 | 2020-10-01T09:51:30 | 2020-10-01T09:51:30 | 300,228,144 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 544 | java | package Trainings;
import java.util.LinkedHashMap;
import java.util.Map;
public class CharacterCount {
public static void main(String[] args) {
String text="God is love";
int s=0, len=text.length();
Map<Character, Integer> map = new LinkedHashMap<Character, Integer>();
{
for (int i=0;i<=len-1;i++)
{
s=0;
for (int j=0; j<len-1;i++)
{
if (text.charAt(i)==text.charAt(j))
{
s=s+1;
map.put(text.charAt(i),s);
}
System.out.println(map);
}
}
}
}
}
| [
"[email protected]"
] | |
492222c56f772830da1dd3aabd75a26b0878feeb | aee724fd0f4ff98b3b0cd094ada4694d0f4d6a0b | /core/src/test/java/com/expediagroup/streamplatform/streamregistry/core/services/ConsumerServiceTest.java | 24a959a2f128c49ccbc25915c683d8c0a8219ce6 | [
"Apache-2.0"
] | permissive | ExpediaGroup/stream-registry | 2b549d469d07d56af41cb75c7f27a3dd5edf7f87 | 2f235d732d10d6d84abfd202a03e626bb3974a5e | refs/heads/master | 2023-06-20T21:19:01.039022 | 2023-04-20T07:42:07 | 2023-04-20T07:42:07 | 159,537,834 | 63 | 37 | Apache-2.0 | 2023-06-14T22:29:30 | 2018-11-28T17:12:11 | Java | UTF-8 | Java | false | false | 6,655 | java | /**
* Copyright (C) 2018-2021 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.expediagroup.streamplatform.streamregistry.core.services;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import com.expediagroup.streamplatform.streamregistry.core.handlers.HandlerService;
import com.expediagroup.streamplatform.streamregistry.core.validators.ConsumerValidator;
import com.expediagroup.streamplatform.streamregistry.core.views.ConsumerBindingView;
import com.expediagroup.streamplatform.streamregistry.core.views.ConsumerView;
import com.expediagroup.streamplatform.streamregistry.model.Consumer;
import com.expediagroup.streamplatform.streamregistry.model.ConsumerBinding;
import com.expediagroup.streamplatform.streamregistry.model.Specification;
import com.expediagroup.streamplatform.streamregistry.model.Status;
import com.expediagroup.streamplatform.streamregistry.model.keys.ConsumerBindingKey;
import com.expediagroup.streamplatform.streamregistry.model.keys.ConsumerKey;
import com.expediagroup.streamplatform.streamregistry.repository.ConsumerBindingRepository;
import com.expediagroup.streamplatform.streamregistry.repository.ConsumerRepository;
@RunWith(MockitoJUnitRunner.class)
public class ConsumerServiceTest {
@Mock
private HandlerService handlerService;
@Mock
private ConsumerValidator consumerValidator;
@Mock
private ConsumerRepository consumerRepository;
@Mock
private ConsumerBindingService consumerBindingService;
@Mock
private ConsumerBindingRepository consumerBindingRepository;
private ConsumerService consumerService;
@Before
public void before() {
consumerService = new ConsumerService(
new ConsumerView(consumerRepository),
handlerService,
consumerValidator,
consumerRepository,
consumerBindingService,
new ConsumerBindingView(consumerBindingRepository)
);
}
@Test
public void create() {
final ConsumerKey key = mock(ConsumerKey.class);
final Specification specification = mock(Specification.class);
final Consumer entity = mock(Consumer.class);
when(entity.getKey()).thenReturn(key);
when(consumerRepository.findById(key)).thenReturn(Optional.empty());
doNothing().when(consumerValidator).validateForCreate(entity);
when(handlerService.handleInsert(entity)).thenReturn(specification);
when(consumerRepository.save(entity)).thenReturn(entity);
consumerService.create(entity);
verify(entity).getKey();
verify(consumerRepository).findById(key);
verify(consumerValidator).validateForCreate(entity);
verify(handlerService).handleInsert(entity);
verify(consumerRepository).save(entity);
}
@Test
public void update() {
final ConsumerKey key = mock(ConsumerKey.class);
final Specification specification = mock(Specification.class);
final Consumer entity = mock(Consumer.class);
final Consumer existingEntity = mock(Consumer.class);
when(entity.getKey()).thenReturn(key);
when(consumerRepository.findById(key)).thenReturn(Optional.of(existingEntity));
doNothing().when(consumerValidator).validateForUpdate(entity, existingEntity);
when(handlerService.handleUpdate(entity, existingEntity)).thenReturn(specification);
when(consumerRepository.save(entity)).thenReturn(entity);
consumerService.update(entity);
verify(entity).getKey();
verify(consumerRepository).findById(key);
verify(consumerValidator).validateForUpdate(entity, existingEntity);
verify(handlerService).handleUpdate(entity, existingEntity);
verify(consumerRepository).save(entity);
}
@Test
public void updateStatus() {
final Status status = mock(Status.class);
final Consumer entity = mock(Consumer.class);
when(consumerRepository.save(entity)).thenReturn(entity);
consumerService.updateStatus(entity, status);
verify(consumerRepository).save(entity);
}
@Test
public void delete() {
final ConsumerKey key = mock(ConsumerKey.class);
final Consumer entity = mock(Consumer.class);
when(entity.getKey()).thenReturn(key);
final ConsumerBindingKey bindingKey = mock(ConsumerBindingKey.class);
final ConsumerBinding binding = mock(ConsumerBinding.class);
when(bindingKey.getConsumerKey()).thenReturn(key);
when(binding.getKey()).thenReturn(bindingKey);
when(consumerBindingRepository.findAll()).thenReturn(asList(binding));
consumerService.delete(entity);
verify(consumerBindingService).delete(binding);
verify(consumerRepository).delete(entity);
}
@Test
public void delete_noChildren() {
final Consumer entity = mock(Consumer.class);
when(consumerBindingRepository.findAll()).thenReturn(emptyList());
consumerService.delete(entity);
verify(consumerBindingService, never()).delete(any());
verify(consumerRepository).delete(entity);
}
@Test
public void delete_multi() {
final ConsumerKey key = mock(ConsumerKey.class);
final Consumer entity = mock(Consumer.class);
when(entity.getKey()).thenReturn(key);
final ConsumerBindingKey bindingKey1 = mock(ConsumerBindingKey.class);
final ConsumerBinding binding1 = mock(ConsumerBinding.class);
when(bindingKey1.getConsumerKey()).thenReturn(key);
when(binding1.getKey()).thenReturn(bindingKey1);
final ConsumerBindingKey bindingKey2 = mock(ConsumerBindingKey.class);
final ConsumerBinding binding2 = mock(ConsumerBinding.class);
when(bindingKey2.getConsumerKey()).thenReturn(key);
when(binding2.getKey()).thenReturn(bindingKey2);
when(consumerBindingRepository.findAll()).thenReturn(asList(binding1, binding2));
consumerService.delete(entity);
verify(consumerBindingService).delete(binding1);
verify(consumerBindingService).delete(binding2);
verify(consumerRepository).delete(entity);
}
}
| [
"[email protected]"
] | |
8c4952c18e8f155d94212b3162e94eb512456981 | 072688c090cc096ba274f376ab84b76c0d2ad222 | /src/main/java/com/books/dao/TbPinglunMapper.java | c94d0bc01d1a10cb3f0030dc7f76bf04e62a6a3f | [] | no_license | GreyHuu/Books-2 | 11552c6f864a8fad78dcb8c878e28018e57c733e | 7e263e177fc3a77964d0f7dee68f7dcdf710376a | refs/heads/master | 2022-12-24T03:41:58.985739 | 2019-06-27T10:33:30 | 2019-06-27T10:33:30 | 193,827,044 | 0 | 0 | null | 2022-12-16T07:46:14 | 2019-06-26T04:03:06 | JavaScript | UTF-8 | Java | false | false | 421 | java | package com.books.dao;
import com.books.entity.TbPinglun;
public interface TbPinglunMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbPinglun record);
int insertSelective(TbPinglun record);
TbPinglun selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbPinglun record);
int updateByPrimaryKeyWithBLOBs(TbPinglun record);
int updateByPrimaryKey(TbPinglun record);
} | [
"[email protected]"
] | |
6877c2d5cb28b1f2316efc74a2aed1172930c84e | cec6df48c2c5e8f4501f69c1acb580f8b1e6b30b | /src/main/java/android/rothe/emily/project/afinal/quizapp4/ListFragment.java | 070009e88e503cb9d2458284fb44e20ef3f0b4c0 | [] | no_license | rainbowrachel96/quiz-app | 96372d4eeefe2b2454bf86bd6bad6d3c9b5892d0 | cb10ecd9adcef63e9c3b447f4e08477c05b0bc7e | refs/heads/master | 2021-01-12T02:08:11.668821 | 2017-01-09T22:46:56 | 2017-01-09T22:46:56 | 78,476,125 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,421 | java | package android.rothe.emily.project.afinal.quizapp4;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.rothe.emily.project.afinal.quizapp4.Database.DataBaseHelper;
import android.rothe.emily.project.afinal.quizapp4.Database.QuestionCursorWrapper;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
/**
* Created by EmilyHP on 1/8/2017.
*/
public class ListFragment extends FragmentActivity {
private SQLiteDatabase mDatabase;
private QuestionFetcher mQuestionFetcher = new QuestionFetcher(getApplicationContext());
private CheckBox mCheckBox;
private CheckBox mCheckBox2;
private CheckBox mCheckBox3;
private CheckBox mCheckBox4;
private CheckBox mCheckBox5;
private CheckBox mCheckBox6;
private CheckBox mCheckBox7;
private CheckBox mCheckBox8;
private CheckBox mCheckBox9;
private CheckBox mCheckBox10;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_list_questions, container, false);
mCheckBox = (CheckBox) v.findViewById(R.id.checkBox);
mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Question question = new Question(1, R.string.question1, true, isChecked);
mQuestionFetcher.updateQuestion(question);
}
});
mCheckBox2 = (CheckBox) v.findViewById(R.id.checkBox2);
mCheckBox2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Question question = new Question(2, R.string.question2, false, isChecked);
mQuestionFetcher.updateQuestion(question);
}
});
mCheckBox3 = (CheckBox) v.findViewById(R.id.checkBox3);
mCheckBox3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Question question = new Question(3, R.string.question3, false, isChecked);
mQuestionFetcher.updateQuestion(question);
}
});
mCheckBox4 = (CheckBox) v.findViewById(R.id.checkBox4);
mCheckBox4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Question question = new Question(4, R.string.question4, true, isChecked);
mQuestionFetcher.updateQuestion(question);
}
});
mCheckBox5 = (CheckBox) v.findViewById(R.id.checkBox5);
mCheckBox5.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Question question = new Question(5, R.string.question5, true, isChecked);
mQuestionFetcher.updateQuestion(question);
}
});
mCheckBox6 = (CheckBox) v.findViewById(R.id.checkBox6);
mCheckBox6.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Question question = new Question(6, R.string.question6, false, isChecked);
mQuestionFetcher.updateQuestion(question);
}
});
mCheckBox7 = (CheckBox) v.findViewById(R.id.checkBox7);
mCheckBox7.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Question question = new Question(7, R.string.question7, true, isChecked);
mQuestionFetcher.updateQuestion(question);
}
});
mCheckBox8 = (CheckBox) v.findViewById(R.id.checkBox8);
mCheckBox8.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Question question = new Question(8, R.string.question8, true, isChecked);
mQuestionFetcher.updateQuestion(question);
}
});
mCheckBox9 = (CheckBox) v.findViewById(R.id.checkBox9);
mCheckBox9.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Question question = new Question(9, R.string.question9, false, isChecked);
mQuestionFetcher.updateQuestion(question);
}
});
mCheckBox10 = (CheckBox) v.findViewById(R.id.checkBox10);
mCheckBox10.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Question question = new Question(10, R.string.question10, false, isChecked);
mQuestionFetcher.updateQuestion(question);
}
});
return v;
}
private QuestionCursorWrapper queryQuestions(String whereClause, String[] whereArgs) {
Cursor cursor = mDatabase.query(
DataBaseHelper.QuestionTable.NAME,
null,
whereClause,
whereArgs,
null, null, null
);
return new QuestionCursorWrapper(cursor);
}
}
| [
"[email protected]"
] | |
a4f061bd2eaed853182f084ae4c55b23ef3ef18f | c878f0547b0495e29043cf9f867c3a938425a090 | /src/main/java/hu/elte/lesson06/ThreadedServer.java | 4a4c9632d970aa76ca1951e5da8f0914fbed6a72 | [] | no_license | szybogi/elte-or | 41227783b76cc860603cf8d40f0d45796f62ae18 | 69eab67bb53ac354c6356d70cd79ca13a4fb68ef | refs/heads/master | 2020-04-27T08:44:13.971822 | 2019-05-12T21:51:02 | 2019-05-12T21:51:02 | 174,183,381 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 787 | java | package hu.elte.lesson06;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.LinkedList;
public class ThreadedServer {
public static void main(String[] args) {
final int serverPort = Integer.parseInt(args[0]);
ConnectionManager mgr = new ConnectionManager();
try (
ServerSocket serverSocket = new ServerSocket(serverPort);
) {
while(true) {
ClientConnection newConnection = new ClientConnection(serverSocket.accept(), mgr);
newConnection.run();
}
} catch (Exception e) {
e.printStackTrace();
}
}
} | [
"[email protected]"
] | |
30ca08c886df9d1e34d2674c478b6ecea2712b5b | 3e0d19bef8dcff053ceb7a2acb5b366f64e7ab61 | /src/com/jpmorgan/model/TradeParams.java | 9bd2ab5f03d0400bda59dee01a17bd2e71b40c28 | [] | no_license | KratikaAgrawal14/JP_Morgan_Tech_Test | 443d70454225ca54be5da6fed300121a7fd60860 | 64a9f5a67024ddac663fa2bca85206190695f2c3 | refs/heads/master | 2020-03-26T04:02:39.959482 | 2018-08-12T18:38:51 | 2018-08-12T18:38:51 | 144,483,233 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,229 | java | /**
*
*/
package com.jpmorgan.model;
import java.util.HashMap;
import java.util.Map;
/**
* @author kmac
*
*/
public class TradeParams {
public static final Map<String, Integer> daysMap = createDaysMap();
/**
* method to create map of days in the week
* @return days map
*/
private static final Map<String, Integer> createDaysMap() {
Map<String, Integer> daysMap = new HashMap<>();
daysMap.put("SUNDAY", 0);
daysMap.put("MONDAY", 1);
daysMap.put("TUESDAY", 2);
daysMap.put("WEDNESDAY", 3);
daysMap.put("THURSDAY", 4);
daysMap.put("FRIDAY", 5);
daysMap.put("SATURDAY", 6);
return daysMap;
}
/**
* method to return the actual working day
* @param currency
* @param current day
* @return index for the working day e.g 1 for Monday
*/
public static int getWorkingDay(String currency, String day) {
int numOfDay = daysMap.get(day);
if (currency.equalsIgnoreCase("AED") || currency.equalsIgnoreCase("SAR")) {
if (numOfDay >= 0 && numOfDay <= 4) {
return 0;
} else if (numOfDay == 5) {
return 2;
} else
return 1;
} else {
if (numOfDay >= 1 && numOfDay <= 5) {
return 0;
} else if (numOfDay == 6) {
return 2;
} else
return 1;
}
}
}
| [
"[email protected]"
] | |
488aecc5dad42a36b71aaef43c01e0a78c18d49d | 73fbe6cf96aa95e7fd2feb1851c4d0ea3ecd50f6 | /src/main/java/walkingkooka/tree/patch/NodePatchNotEmptyNodePatchVisitor.java | 7dcb03ee404958ba5e3f0ffdead834275dea76ea | [
"Apache-2.0"
] | permissive | mP1/walkingkooka-tree-patch | 0e453513bed89717344de38cfa4a67244c72d620 | 5f0069e239413e94a422aa253dc5a3bc88992a82 | refs/heads/master | 2023-02-26T11:02:17.678363 | 2023-02-08T11:00:12 | 2023-02-08T11:00:12 | 192,153,680 | 0 | 0 | Apache-2.0 | 2023-02-08T11:00:15 | 2019-06-16T05:26:46 | Java | UTF-8 | Java | false | false | 6,817 | java | /*
* Copyright 2019 Miroslav Pokorny (github.com/mP1)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package walkingkooka.tree.patch;
import walkingkooka.naming.Name;
import walkingkooka.tree.Node;
import walkingkooka.tree.json.JsonNode;
import walkingkooka.tree.json.JsonObject;
import walkingkooka.tree.json.JsonPropertyName;
import walkingkooka.tree.json.JsonString;
import walkingkooka.tree.json.marshall.JsonNodeUnmarshallContext;
import walkingkooka.tree.pointer.NodePointer;
import walkingkooka.visit.Visitor;
import java.util.function.BiFunction;
/**
* A visitor used by all {@link NodePatch} sub classes to build a {@link NodePatch} from a {@link JsonNode}.
*/
abstract class NodePatchNotEmptyNodePatchVisitor extends Visitor<JsonNode> {
NodePatchNotEmptyNodePatchVisitor(final JsonObject patch,
final NodePatchFromJsonFormat format,
final JsonNodeUnmarshallContext context) {
super();
this.patch = patch;
this.format = format;
this.context = context;
}
@Override
public final void accept(final JsonNode node) {
this.format.accept(this, node.objectOrFail());
}
final void acceptJsonPatch(final JsonObject node) {
for (JsonNode property : node.children()) {
final JsonPropertyName propertyName = property.name();
switch (propertyName.value()) {
case NodePatch.OP:
break;
case NodePatch.FROM:
this.visitFrom(property.stringOrFail());
break;
case NodePatch.PATH:
this.visitPath(property.stringOrFail());
break;
case NodePatch.VALUE:
this.visitValue(property);
break;
default:
JsonNodeUnmarshallContext.unknownPropertyPresent(propertyName, property.removeParent());
}
}
}
final void acceptNodePatch(final JsonObject node) {
for (JsonNode property : node.children()) {
final JsonPropertyName propertyName = property.name();
switch (propertyName.value()) {
case NodePatch.OP:
break;
case NodePatch.PATH_NAME_TYPE:
this.visitPathNameType(property);
break;
case NodePatch.FROM:
this.visitFrom(property.stringOrFail());
break;
case NodePatch.PATH:
this.visitPath(property.stringOrFail());
break;
case NodePatch.VALUE_TYPE:
this.visitValueType(property);
break;
case NodePatch.VALUE:
this.visitValue(property);
break;
default:
JsonNodeUnmarshallContext.unknownPropertyPresent(propertyName, property.removeParent());
}
}
}
// PATH NAME TYPE .............................................................................................
private void visitPathNameType(final JsonNode pathNameType) {
pathNameType.stringOrFail();
}
/**
* Getter that returns a factory that assumes {@link NodePatch#PATH_NAME_TYPE_PROPERTY} holds the type name.
*/
final BiFunction<JsonNode, JsonNodeUnmarshallContext, Name> pathNameFactory(final JsonNodeUnmarshallContext context) {
if (null == this.pathNameFactory) {
this.pathNameFactory = context.unmarshallWithType(NodePatch.PATH_NAME_TYPE_PROPERTY, this.patch, Name.class);
}
return this.pathNameFactory;
}
private BiFunction<JsonNode, JsonNodeUnmarshallContext, Name> pathNameFactory;
// FROM ........................................................................................................
abstract void visitFrom(final String from);
// PATH ........................................................................................................
private void visitPath(final String path) {
this.path = path;
}
final NodePointer<?, ?> path() {
return this.pathOrFail(this.path, NodePatch.PATH_PROPERTY);
}
/**
* Once all properties are visited this will be converted into a {@link NodePointer}
*/
private String path;
/**
* Creates a {@link NodePointer} from the {@link JsonString} using the property name in any error messages.
*/
@SuppressWarnings("unchecked")
final NodePointer<?, ?> pathOrFail(final String path,
final JsonPropertyName property) {
try {
return NodePointer.parse(path,
this.format.nameFactory(this, this.context),
Node.class);
} catch (final RuntimeException cause) {
throw new IllegalArgumentException("Invalid " + property + " in " + this.patch, cause);
}
}
final JsonNodeUnmarshallContext context;
// VALUE ........................................................................................................
abstract void visitValueType(final JsonNode valueType);
abstract void visitValue(final JsonNode value);
// HELPER ...........................................................................................................
/**
* Helper that fails if the value is null using the property name in the message detail.
*/
final <T> T valueOrFail(final T value) {
if (null == value) {
throw new IllegalArgumentException("Required property " + NodePatch.VALUE_PROPERTY + " missing " + this.patch);
}
return value;
}
/**
* Reports that an unknown property is present.
*/
final void unknownPropertyPresent(final JsonPropertyName property) {
JsonNodeUnmarshallContext.unknownPropertyPresent(property, this.patch);
}
/**
* The json object representing the patch.
*/
final JsonObject patch;
final NodePatchFromJsonFormat format;
@Override
public final String toString() {
return this.patch.toString();
}
}
| [
"[email protected]"
] | |
e609e77c75e4995cf90c7934826933e9fb6e68c9 | c0c0af7d154c43cbf7dd7e94dead7f26e969c7c8 | /src/test/java/Zadanie6/KatalonFormStepsTest.java | 47967f2c61c06ac8b031b47bdf7b5d7ece118ac0 | [] | no_license | oktawia10/ProjektKoncowy | f41b991c8dee37a9f6b45f3e614f4b9265991436 | 6a3f9dc6313f9960640ff67ccc4739f0820285c9 | refs/heads/master | 2021-06-16T16:54:25.001496 | 2019-08-07T20:28:46 | 2019-08-07T20:28:46 | 199,190,538 | 0 | 0 | null | 2021-04-26T19:23:39 | 2019-07-27T16:44:02 | Java | UTF-8 | Java | false | false | 317 | java | package Zadanie6;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(features = "/home/oktawia/Pulpit/ProjektKoncowy/src/test/java/Zadanie6",
plugin = {"pretty","html:out"})
public class KatalonFormStepsTest {
} | [
"[email protected]"
] | |
97b4764c35d5b53e9b0d10e13606c0f1083197b6 | 4c86279c2b99862abfad79d44085ca4e0267cc6d | /Offseason2015/src/org/usfirst/frc/team6587/robot/subsystems/ClawSubsystem.java | ce73e99f3cf5230df2d653803c259a58e6653474 | [] | no_license | xeldridge18/AwtyOffseason2015 | f30234423164fda46c5cfabff288b9a007371e97 | d43a89b98fbcc03717913ee499f71b60eed4834c | refs/heads/master | 2021-01-25T10:16:41.528773 | 2015-06-18T18:19:10 | 2015-06-18T18:19:10 | 37,403,713 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 810 | java | package org.usfirst.frc.team6587.robot.subsystems;
import edu.wpi.first.wpilibj.command.Subsystem;
import org.usfirst.frc.team6587.robot.*;
import edu.wpi.first.wpilibj.Solenoid;
public class ClawSubsystem extends Subsystem {
// Put methods for controlling this subsystem
// here. Call these from Commands.
private Solenoid clawSolenoid;
public ClawSubsystem(){
clawSolenoid = new Solenoid(HW.clawSolenoidIn,HW.clawSolenoidOut);
clawSolenoid.set(false);
}
public void initDefaultCommand() {
// Set the default command for a subsystem here.
//setDefaultCommand(new MySpecialCommand());
}
public void setClaw(boolean clawState){
clawSolenoid.set(clawState);
}
public boolean getClawState(){
return clawSolenoid.get();
}
}
| [
"[email protected]"
] | |
4a3de7e08d40e28cb2316ca4e8af994301678e61 | 7c5da8614c82cc228e8b965aa7a8bc02caaf5073 | /Example/Library/src/main/java/com/swcguild/library/model/HBook.java | d43e6b55a0ba01ea70f19827bc9bfaa7a5c8db3c | [] | no_license | oneillsp96/JavaProjects | 810fe886627f4bc0f5702bb49bd19930e8c5522a | 53add15b222cfac034943e7bbbc03210180b7945 | refs/heads/master | 2021-01-21T09:03:49.242817 | 2014-12-16T20:23:26 | 2014-12-16T20:23:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,608 | java |
package com.swcguild.library.model;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "books")
public class HBook {
//any Id will have these 3 annotations
@Id
@GeneratedValue
@Column(name = "book_id")
private int bookId;
@Column(name = "isbn")
private String isbn;
@Column(name = "title")
private String title;
@ManyToOne
@JoinColumn(name = "publisher_id") //publisher_id is foreign key
private Publisher publisher;
@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL}) //fetch type eager -get all author objects when query is run //cascade all- if i update book, update authors
@JoinTable(name = "books_authors", //join table=bridge table
joinColumns = {
@JoinColumn(name = "book_id")},
inverseJoinColumns = {
@JoinColumn(name = "author_id")})
private Set<Author> authors; //Set can't have multiples
@Column(name = "price")
private BigDecimal price;
@Column(name = "publish_date")
private Date publishDate;
public int getBookId() {
return bookId;
}
public void setBookId(int bookId) {
this.bookId = bookId;
}
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Publisher getPublisher() {
return publisher;
}
public void setPublisher(Publisher publisher) {
this.publisher = publisher;
}
public Set<Author> getAuthors() {
return authors;
}
public void setAuthors(Set<Author> authors) {
this.authors = authors;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public Date getPublishDate() {
return publishDate;
}
public void setPublishDate(Date publishDate) {
this.publishDate = publishDate;
}
} | [
"[email protected]"
] | |
1de034cf0fad1208d4ed40d807eae0ad240af89b | 5920503431adfdc8e20f229e4902e5ee9000a997 | /sql/sql-integration-test/src/test/java/ExpectInsertTest.java | ad30d2f655fe7d0e7fa36348b1975c027d857991 | [
"Apache-2.0"
] | permissive | balaaagi/quickperf | 08abc224851f012ffe4188f5ea2ed2a16f5feb16 | 7343c12536fe8a42667ac8910629f4bdcc4eb879 | refs/heads/master | 2020-12-28T17:59:30.548404 | 2020-02-02T17:51:00 | 2020-02-02T17:51:00 | 238,431,583 | 1 | 0 | Apache-2.0 | 2020-02-05T11:11:51 | 2020-02-05T11:11:50 | null | UTF-8 | Java | false | false | 2,200 | java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright 2019-2019 the original author or authors.
*/
import org.junit.Test;
import org.junit.experimental.results.PrintableResult;
import org.junit.runner.RunWith;
import org.quickperf.junit4.QuickPerfJUnitRunner;
import org.quickperf.sql.Book;
import org.quickperf.sql.annotation.ExpectInsert;
import javax.persistence.EntityManager;
import static org.assertj.core.api.Assertions.assertThat;
public class ExpectInsertTest {
@RunWith(QuickPerfJUnitRunner.class)
public static class SqlInsert extends SqlTestBase {
@ExpectInsert(5)
@Test
public void execute_one_insert_but_five_inserts_expected() {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Book effectiveJava = new Book();
effectiveJava.setIsbn("effectiveJavaIsbn");
effectiveJava.setTitle("Effective Java");
em.persist(effectiveJava);
em.getTransaction().commit();
}
}
@Test public void
should_fail_if_the_number_of_insert_statements_is_not_equal_to_the_number_expected() {
// GIVEN
Class<?> testClass = SqlInsert.class;
// WHEN
PrintableResult printableResult = PrintableResult.testResult(testClass);
// THEN
assertThat(printableResult.failureCount()).isEqualTo(1);
assertThat(printableResult.toString())
.contains("Expected number of INSERT statements <5> but is <1>")
.contains("insert")
.contains("into")
.contains("Book")
.contains("isbn, title, id)");
}
}
| [
"[email protected]"
] | |
af29d19f9b47215d685f7c2427e6b81c323635e7 | 082e26b011e30dc62a62fae95f375e4f87d9e99c | /docs/weixin_7.0.4_source/反编译源码/反混淆后/src/main/java/com/tencent/p177mm/plugin/voip/model/C29495b.java | 7bf775a2c108f155b775f1818d520772d88a5aa9 | [] | no_license | xsren/AndroidReverseNotes | 9631a5aabc031006e795a112b7ac756a8edd4385 | 9202c276fe9f04a978e4e08b08e42645d97ca94b | refs/heads/master | 2021-04-07T22:50:51.072197 | 2019-07-16T02:24:43 | 2019-07-16T02:24:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 195 | java | package com.tencent.p177mm.plugin.voip.model;
/* renamed from: com.tencent.mm.plugin.voip.model.b */
public interface C29495b {
/* renamed from: N */
int mo45518N(byte[] bArr, int i);
}
| [
"[email protected]"
] | |
34102c52b81b3763713b4287713701caeaccc870 | 72ef72232593f8713108366546119cdb7e7724d2 | /src/OOPConceptPart1/CallByValAndCallByRef.java | 03dc63bdf7280498602a8d5e2b680741177a8549 | [] | no_license | pratimaranga/JavaTrainingSession | c95505656cd1dfeb882181dcb7589786d318c78b | 0a091f5944c5d50586a85c889d602c157cc4f9b7 | refs/heads/master | 2023-02-23T01:44:04.751210 | 2021-01-29T01:24:58 | 2021-01-29T01:24:58 | 333,757,686 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 610 | java | package OOPConceptPart1;
public class CallByValAndCallByRef {
int p;
int q;
public static void main(String[] args) {
CallByValAndCallByRef obj = new CallByValAndCallByRef();
int x =10;
int y = 20;
obj.testSum(x,y);//call by value or pass by value
obj.p =50;
obj.q =60;
obj.swap(obj);
System.out.println(obj.p);
System.out.println(obj.q);
}
public int testSum(int a, int b) {
a =30;
b= 40;
int c= a+b;
return c;
}
public void swap(CallByValAndCallByRef t) {
int temp;
temp = t.p; //temp=50
t.p =t.q; //t.p= 60
t.q =temp; //t.q=60
}
}
| [
"[email protected]"
] | |
ce27a9b301c6baf502776f260df35b8a3418cb35 | 2699ec42a788a4014c3a440cd2e3d54fcb070148 | /src/main/java/de/tutego/appliances/StaticConstant.java | 1409dba67a43e782ebdf55d25a44683b6a607079 | [] | no_license | dennishangithub/java-held-lectures-material | ce4190cfc519760f95acd6d25df0a2dcaf00d6e0 | 39791be16672006208624a0e3a1a16790b14c388 | refs/heads/master | 2023-04-10T14:08:53.941637 | 2021-04-14T18:02:36 | 2021-04-14T18:02:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 333 | java | package de.tutego.appliances;
/**
* Lernziel: Statische Attribute und Methoden
* - Statische Attribute (Konstanten)
* - Utility-Methoden
*
* @see Enumerations
*/
public class StaticConstant {
public static void main( String[] args ) {
System.out.println( Math.PI );
System.out.println( Math.max( 10, 3000 ) );
}
}
| [
"[email protected]"
] | |
defca07134b477639ee36083155215c39b2f935c | 94693278dd25dc0504dedd2b1e5f57b4a2bb75c3 | /Switch_Debug/app/src/main/java/jtp/c/dendai/ac/jp/switch_test/StageSelect.java | 3ebf2e280c88c03619cb67bbb1a836b4fa8a65d3 | [] | no_license | suke123/Android_Games | 876ed5e2ed8053bd87909a0d2485737c87ce6f1d | afc2a20ec572c9b64db5794190ec758574ce384e | refs/heads/master | 2021-01-19T23:05:28.267832 | 2018-12-25T21:37:50 | 2018-12-25T21:37:50 | 88,918,980 | 2 | 3 | null | null | null | null | UTF-8 | Java | false | false | 1,771 | java | package jtp.c.dendai.ac.jp.switch_test;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
public class StageSelect extends AppCompatActivity {
private Button stage1,stage2,stage3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stage_select);
setButtonId();
setOnClickListener();
}
private void setOnClickListener() {
stage1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplication(), GameActivity.class);
intent.putExtra("Stagename", "STAGE1");
startActivity(intent);
}
});
stage2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplication(), GameActivity.class);
intent.putExtra("Stagename", "STAGE2");
startActivity(intent);
}
});
stage3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplication(), GameActivity.class);
intent.putExtra("Stagename", "STAGE3");
startActivity(intent);
}
});
}
private void setButtonId() {
stage1 = (Button)findViewById(R.id.button1);
stage2 = (Button)findViewById(R.id.button2);
stage3 = (Button)findViewById(R.id.button3);
}
}
| [
"[email protected]"
] | |
9de7dbfe780b9302152a142cabc84fb649e369a6 | 8bc27daf6b8efa3e05b2623df09af203c20396cb | /src/lesson4/Main.java | 7813f0b361ee4cbf8a992638ed987f065500a2e1 | [] | no_license | Pavel-Novoselov/Algoritms | 61e94ff15ea289300b0cb9ebfb348c09c125d4f9 | aab036ef2a9983ee44bc968dfbb0b5adb3b06ccd | refs/heads/master | 2020-11-25T03:04:26.767007 | 2020-01-25T20:27:06 | 2020-01-25T20:27:06 | 228,470,098 | 0 | 0 | null | 2020-01-26T13:39:48 | 2019-12-16T20:29:48 | Java | UTF-8 | Java | false | false | 1,768 | java | package lesson4;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class Main {
public static void main(String[] args) {
// MyLinkedList<String> mll = new MyLinkedList<>();
// mll.insertFirst("Katia");
// mll.insertFirst("Maria");
// mll.insertFirst("Luba");
// mll.insertFirst("Luba");
// mll.insertFirst("Luba");
//// System.out.println(mll.contains("Maria"));
//// System.out.println(mll.indexOf("Luba"));
//// System.out.println(mll);
//// mll.insert(1,"Petia");
//
// System.out.println(mll);
// mll.insertLast("Sania");
// System.out.println(mll);
//
// mll.insert(3, "Petia");
// System.out.println(mll);
//
// mll.remove("Luba");
// System.out.println(mll);
//
// for (String s : mll) {
// System.out.print(s + " ");
// }
MyLinkedQueue<String> mlq = new MyLinkedQueue<>();
mlq.enqueue("Tetya");
mlq.enqueue("Dadya");
mlq.enqueue("Igor");
mlq.enqueue("Lena");
System.out.println(mlq.dequeue());
System.out.println(mlq.dequeue());
System.out.println(mlq.dequeue());
System.out.println(mlq.dequeue());
// System.out.println(mlq.dequeue());
// Iterator<String> iterator = mll.iterator();
// while(iterator.hasNext()){
// System.out.print(iterator.next()+" ");
// }
// mll.removeLast();
// mll.removeFirst();
// System.out.println(mll);
// System.out.println(mll.remove("Luba"));
// System.out.println(mll);
// for (int i = 0; i < 3 ; i++) {
// System.out.print(mll.removeFirst()+" ");
// }
}
}
| [
"[email protected]"
] | |
40f50e4be788bf49e2648c495702ad4f7b7acbea | 8f3bdeb205e35c52b2d70175285d64a65363aa4a | /FXCM_java/trading_sdk/trading_sdk/tradestation/src/fxts/stations/util/preferences/IEditor.java | 24a4e152862099e47029cf59503d8a8dd7fdab33 | [] | no_license | tihomirski/trendkill-IntelliJ | 008faaa0e807e806a22baedd363904f913f5b2b7 | f6c18274f08cf799627ea4c359403b27e3098493 | refs/heads/master | 2023-01-30T04:19:29.993993 | 2020-12-17T01:00:39 | 2020-12-17T01:00:39 | 308,491,226 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,069 | java | /*
* Copyright 2006 FXCM LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fxts.stations.util.preferences;
import java.awt.*;
/**
* Interface of editor for abstract data type.
*/
public interface IEditor {
/**
* Returns component for placing on editor dialog.
*/
Component getComponent();
/**
* Returns current value.
*/
Object getValue();
/**
* Sets new value to editor.
*
* @param aValue new value
*/
void setValue(Object aValue);
} | [
"[email protected]"
] | |
94e09aa2c20eda8831642b5aec252a212788dd79 | f2a5398b84cfaa46fde61a6e180c9abeb92c1a5f | /modules/datastore/geotk-datastore-core/src/main/java/org/geotoolkit/data/memory/GenericMaxFeatureIterator.java | 5d9711447a8964e38fadb8532bd9651baff8d32a | [] | no_license | glascaleia/geotoolkit-pending | 32b3a15ff0c82508af6fc3ee99033724bf0bc85e | e3908e9dfefc415169f80787cff8c94af4afce17 | refs/heads/master | 2020-05-20T11:09:44.894361 | 2012-03-29T14:43:34 | 2012-03-29T14:43:34 | 3,219,051 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,623 | java | /*
* Geotoolkit - An Open Source Java GIS Toolkit
* http://www.geotoolkit.org
*
* (C) 2003-2008, Open Source Geospatial Foundation (OSGeo)
* (C) 2009, Geomatys
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotoolkit.data.memory;
import java.util.NoSuchElementException;
import org.geotoolkit.data.FeatureIterator;
import org.geotoolkit.data.FeatureReader;
import org.geotoolkit.data.FeatureWriter;
import org.geotoolkit.data.DataStoreRuntimeException;
import org.geotoolkit.data.FeatureCollection;
import org.geotoolkit.factory.Hints;
import org.geotoolkit.util.converter.Classes;
import org.opengis.feature.Feature;
import org.opengis.feature.type.FeatureType;
/**
* Basic support for a FeatureIterator that limits itself to a given number of features.
*
* @author Chris Holmes
* @author Johann Sorel (Geomatys)
* @module pending
*/
public class GenericMaxFeatureIterator<F extends Feature, R extends FeatureIterator<F>>
implements FeatureIterator<F> {
protected final R iterator;
protected final int maxFeatures;
private int counter = 0;
/**
* Creates a new instance of GenericMaxFeatureIterator
*
* @param iterator FeatureReader to limit
* @param maxFeatures maximum number of feature
*/
private GenericMaxFeatureIterator(final R iterator, final int maxFeatures) {
this.iterator = iterator;
this.maxFeatures = maxFeatures;
}
/**
* {@inheritDoc }
*/
@Override
public F next() throws DataStoreRuntimeException {
if (hasNext()) {
counter++;
return iterator.next();
} else {
throw new NoSuchElementException("No such Feature exists");
}
}
/**
* {@inheritDoc }
*/
@Override
public void close() throws DataStoreRuntimeException {
iterator.close();
}
/**
* @return <code>true</code> if the featureReader has not passed the max
* and still has more features.
* @throws IOException If the reader we are filtering encounters a problem
*/
@Override
public boolean hasNext() throws DataStoreRuntimeException {
return ((counter < maxFeatures) && iterator.hasNext());
}
/**
* {@inheritDoc }
*/
@Override
public void remove() {
iterator.remove();
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(Classes.getShortClassName(this));
sb.append("[Max=").append(maxFeatures).append("]\n");
String subIterator = "\u2514\u2500\u2500" + iterator.toString(); //move text to the right
subIterator = subIterator.replaceAll("\n", "\n\u00A0\u00A0\u00A0"); //move text to the right
sb.append(subIterator);
return sb.toString();
}
/**
* Wrap a FeatureReader with a max limit.
*
* @param <T> extends FeatureType
* @param <F> extends Feature
* @param <R> extends FeatureReader<T,F>
*/
private static final class GenericMaxFeatureReader<T extends FeatureType, F extends Feature, R extends FeatureReader<T,F>>
extends GenericMaxFeatureIterator<F,R> implements FeatureReader<T,F>{
private GenericMaxFeatureReader(final R reader,final int limit){
super(reader,limit);
}
@Override
public T getFeatureType() {
return iterator.getFeatureType();
}
}
/**
* Wrap a FeatureWriter with a max limit.
*
* @param <T> extends FeatureType
* @param <F> extends Feature
* @param <R> extends FeatureWriter<T,F>
*/
private static final class GenericMaxFeatureWriter<T extends FeatureType, F extends Feature, R extends FeatureWriter<T,F>>
extends GenericMaxFeatureIterator<F,R> implements FeatureWriter<T,F>{
private GenericMaxFeatureWriter(final R writer,final int limit){
super(writer,limit);
}
@Override
public T getFeatureType() {
return iterator.getFeatureType();
}
@Override
public void write() throws DataStoreRuntimeException {
iterator.write();
}
}
private static final class GenericMaxFeatureCollection extends WrapFeatureCollection{
private final int max;
private GenericMaxFeatureCollection(final FeatureCollection original, final int max){
super(original);
this.max = max;
}
@Override
public FeatureIterator iterator(final Hints hints) throws DataStoreRuntimeException {
return wrap(getOriginalFeatureCollection().iterator(hints), max);
}
@Override
protected Feature modify(Feature original) throws DataStoreRuntimeException {
throw new UnsupportedOperationException("should not have been called.");
}
}
/**
* Wrap a FeatureReader with a max limit.
*/
public static <F extends Feature> FeatureIterator<F> wrap(final FeatureIterator<F> reader, final int limit){
if(reader instanceof FeatureReader){
return wrap((FeatureReader)reader,limit);
}else if(reader instanceof FeatureWriter){
return wrap((FeatureWriter)reader,limit);
}else{
return new GenericMaxFeatureIterator(reader, limit);
}
}
/**
* Wrap a FeatureReader with a max limit.
*/
public static <T extends FeatureType, F extends Feature> FeatureReader<T,F> wrap(final FeatureReader<T,F> reader, final int limit){
return new GenericMaxFeatureReader(reader, limit);
}
/**
* Wrap a FeatureWriter with a max limit.
*/
public static <T extends FeatureType, F extends Feature> FeatureWriter<T,F> wrap(final FeatureWriter<T,F> writer, final int limit){
return new GenericMaxFeatureWriter(writer, limit);
}
/**
* Create an limited FeatureCollection wrapping the given collection.
*/
public static FeatureCollection wrap(final FeatureCollection original, final int max){
return new GenericMaxFeatureCollection(original, max);
}
}
| [
"[email protected]"
] | |
953dd26c82b3832568ef1d026e79bdf6fc15b2a4 | 66afd8fd5ac219d050e5c72a9134d5e9affebcbb | /23.merge-k-sorted-lists.java | 118fc9d972a1ff3a9aee814eb0ed17fcbdd78568 | [] | no_license | ZehaoXU/leetcode-everyday | c4ac100f671001d15eb6a157ea797ddfd2cabcce | a12c3f40df4d9f56018073262c7d29561ec84d07 | refs/heads/master | 2020-03-23T17:31:45.334152 | 2019-09-02T14:53:15 | 2019-09-02T14:53:15 | 141,863,430 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,866 | java | /*
* @lc app=leetcode id=23 lang=java
*
* [23] Merge k Sorted Lists
*/
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
/**
* 采用分治法,最终用两个列表合并解决问题
* 时间复杂度 O(N*logk)
* Your runtime beats 84.82 % of java submissions
* Your memory usage beats 75.11 % of java submissions (39.4 MB)
* 可以不用新建列表,而采用原列表l1 l2穿线来减少空间使用
* @param l1
* @param l2
* @return
*/
public ListNode mergeTwoLists(ListNode l1, ListNode l2){
ListNode head = new ListNode(0);
ListNode pointer = head;
while (l1 != null && l2 != null){
if (l1.val > l2.val){
pointer.next = new ListNode(l2.val);
l2 = l2.next;
}
else {
pointer.next = new ListNode(l1.val);
l1 = l1.next;
}
pointer = pointer.next;
}
if (l1 == null) pointer.next = l2;
if (l2 == null) pointer.next = l1;
return head.next;
}
public ListNode divedeLists(ListNode[] lists, int left, int right){
if (left >= right) return right < 0 ? null : lists[left];
else if (left + 1 == right) return mergeTwoLists(lists[left], lists[right]);
else {
int mid = (left + right) / 2;
ListNode leftList = divedeLists(lists, left, mid);
ListNode rightList = divedeLists(lists, mid + 1, right);
return mergeTwoLists(leftList, rightList);
}
}
public ListNode mergeKLists(ListNode[] lists) {
return divedeLists(lists, 0, lists.length - 1);
}
}
| [
"[email protected]"
] | |
c69f867334c8e27cba856ac8a2921f71dc8df71c | 3a688b9b422e1b3c61d516ba397594dbe1781b2b | /Android/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/PoseEstimationProfile.java | db4aa8571c75116b9c90821aafd0509879a904dc | [
"MIT"
] | permissive | DeviceConnect/DeviceConnect-Old | b7f1699e0e6e4e6e52dd0ffc0a2e44657665668f | 93a7c5a68a85d24788b8be75d8f503004f668b53 | refs/heads/main | 2022-01-26T12:15:16.804324 | 2022-01-13T02:11:10 | 2022-01-13T02:11:10 | 191,665,424 | 0 | 3 | MIT | 2022-01-13T02:11:11 | 2019-06-13T00:59:27 | Java | UTF-8 | Java | false | false | 2,813 | java | /*
PoseEstimationProfile.java
Copyright (c) 2016 NTT DOCOMO,INC.
Released under the MIT license
http://opensource.org/licenses/mit-license.php
*/
package org.deviceconnect.android.profile;
import android.content.Intent;
import android.os.Bundle;
import org.deviceconnect.profile.PoseEstimationProfileConstants;
/**
* PoseEstimation プロファイル.
*
* <p>
* スマートデバイスに対しての姿勢推定機能を提供するAPI.<br/>
* スマートデバイスに対しての姿勢推定機能を提供するデバイスプラグインは当クラスを継承し、対応APIを実装すること。 <br/>
* </p>
*
* <h1>各API提供メソッド</h1>
* <p>
* Pose Estimation Profile の各APIへのリクエストに対し、以下のコールバックメソッド群が自動的に呼び出される。<br/>
* サブクラスは以下のメソッド群からデバイスプラグインが提供するAPI用のメソッドをオーバーライドし、機能を実装すること。<br/>
* オーバーライドされていない機能は自動的に非対応APIとしてレスポンスを返す。
* </p>
* @author NTT DOCOMO, INC.
*/
public class PoseEstimationProfile extends DConnectProfile implements PoseEstimationProfileConstants {
@Override
public final String getProfileName() {
return PROFILE_NAME;
}
// ------------------------------------
// セッターメソッド群
// ------------------------------------
/**
* レスポンスにPoseを設定する.
*
* @param response レスポンス
* @param stress Poseオブジェクト
*/
public static void setPose(final Intent response, final Bundle stress) {
response.putExtra(PARAM_STRESS, stress);
}
/**
* レスポンスに姿勢状態を設定する.
*
* @param response レスポンス
* @param state 姿勢
*/
public static void setState(final Bundle response, final String state) {
response.putString(PARAM_STATE, state);
}
/**
* レスポンスにTimeStamp値を設定する.
*
* @param response レスポンス
* @param timeStamp TimeStamp
*/
public static void setTimestamp(final Bundle response, final long timeStamp) {
response.putLong(PARAM_TIMESTAMP, timeStamp);
}
/**
* レスポンスにTimeStampString値を設定する.
*
* @param response レスポンス
* @param timeStampString TimeStampString
*/
public static void setTimestampString(final Bundle response, final String timeStampString) {
response.putString(PARAM_TIMESTAMP_STRING, timeStampString);
}
// ------------------------------------
// ゲッターメソッド群
// ------------------------------------
}
| [
"[email protected]"
] | |
a55de5a565abe52a3cd825f7b1571a62d65801d1 | 855d2882ac8d4a65ea261675177f6f76e7da6e67 | /sgic-internal-services/product-service/src/main/java/com/sgic/internal/product/controller/dto/converter/PrivilegeDetailConverter.java | 383bc89611a16dcf24b1f14053b5e7c24f752946 | [] | no_license | DefectTracker-InvictaInnovation/Defect-Tracker-Final-Backend | c79a44ef03980020114ae75a4d7ebbc6ca1549c6 | d2936e65c116cbed3ba3bca5a94e53737abb7a98 | refs/heads/master | 2023-04-28T07:06:51.391621 | 2019-11-26T07:44:23 | 2019-11-26T07:44:23 | 224,125,481 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,345 | java | package com.sgic.internal.product.controller.dto.converter;
import java.util.ArrayList;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
import com.sgic.internal.product.controller.dto.PrivilegeDetailDto;
import com.sgic.internal.product.entities.Privilege;
import com.sgic.internal.product.entities.PrivilegeDetail;
import com.sgic.internal.product.entities.Role;
@Service
public class PrivilegeDetailConverter {
private static Logger logger = LogManager.getLogger(PrivilegeDetailDto.class);
// Convert All List PrivilegeDetail Entity to Dto
public static List<PrivilegeDetailDto> PrivilegeDetailEntityToPrivilegeDetailDtoList(List<PrivilegeDetail> privilegedetaillist) {
if (privilegedetaillist != null) {
logger.info("Privilege Converter => Convert Lists To Entity");
List<PrivilegeDetailDto> listPrivilegedetailDto = new ArrayList<>();
for (PrivilegeDetail privilegeDetail : privilegedetaillist) {
PrivilegeDetailDto privilegeDetailDto = new PrivilegeDetailDto();
privilegeDetailDto.setId(privilegeDetail.getId());
privilegeDetailDto.setPrivilegeId(privilegeDetail.getPrivillage().getPrivilegeId());
privilegeDetailDto.setPrivilegeName(privilegeDetail.getPrivillage().getPrivilegeName());
privilegeDetailDto.setRoleId(privilegeDetail.getRole().getRoleId());
privilegeDetailDto.setRoleName(privilegeDetail.getRole().getRoleName());
listPrivilegedetailDto.add(privilegeDetailDto);
}
return listPrivilegedetailDto;
}
return null;
}
// Convert PrivilegeDetailDtO to PrivilegeDetail Entity
public static PrivilegeDetail PrivilegeDetailDtoToPrivilegeDetail(PrivilegeDetailDto privilegeDetailDto) {
PrivilegeDetail privilegeDetail = new PrivilegeDetail();
if (privilegeDetailDto != null) {
logger.info("PrivilegeDetail Converter---> PrivilegeDetail DTO To PrivilegeDetail Entity Converte ");
privilegeDetail.setId(privilegeDetailDto.getId());
Privilege privilege = new Privilege();
privilege.setPrivilegeId(privilegeDetailDto.getPrivilegeId());
privilege.setPrivilegeName(privilegeDetailDto.getPrivilegeName());
privilegeDetail.setPrivillage(privilege);
Role role = new Role();
role.setRoleId(privilegeDetailDto.getRoleId());
role.setRoleName(privilegeDetailDto.getRoleName());
privilegeDetail.setRole(role);
return privilegeDetail;
}
return null;
}
// Convert PrivilegeDTO to PrivilegeEntity
public static PrivilegeDetailDto PrivilageDetailEntityTOPrivilegeDetailDto(PrivilegeDetail privilegeDetail) {
PrivilegeDetailDto privilegeDetailDto = new PrivilegeDetailDto();
if (privilegeDetail != null) {
logger.info("PrivilegeDetail Convert => PrivilageDetail Entity Object to PrivilageDetail Dto");
privilegeDetailDto.setId(privilegeDetail.getId());
privilegeDetailDto.setPrivilegeId(privilegeDetail.getPrivillage().getPrivilegeId());
privilegeDetailDto.setPrivilegeName(privilegeDetail.getPrivillage().getPrivilegeName());
privilegeDetailDto.setRoleId(privilegeDetail.getRole().getRoleId());
privilegeDetailDto.setRoleName(privilegeDetail.getRole().getRoleName());
return privilegeDetailDto;
}
return null;
}
}
| [
"[email protected]"
] | |
b1277bb6b539c213690097912dcf44a492357d32 | 5b07f5142cd7d0233f63ac2982d576e1bf370066 | /src/main/java/com/jianma/designyl/service/impl/UserServiceImpl.java | 28c63ceb633fee103a25149e27b41d6312f4b392 | [
"Apache-2.0"
] | permissive | jianmakeji/DesignYL | 0541b1e39349eab56eca8c5e6668d89209af3f0a | a701d01f789fe22d4f739fc6f9dd1c0f02756d51 | refs/heads/master | 2022-12-23T23:37:57.973344 | 2020-04-17T02:00:16 | 2020-04-17T02:00:16 | 136,171,875 | 0 | 0 | Apache-2.0 | 2022-12-16T07:49:30 | 2018-06-05T12:10:43 | JavaScript | UTF-8 | Java | false | false | 8,233 | java | package com.jianma.designyl.service.impl;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import javax.mail.AuthenticationFailedException;
import javax.mail.MessagingException;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jianma.designyl.dao.SendEmailDao;
import com.jianma.designyl.dao.UserDao;
import com.jianma.designyl.exception.DCException;
import com.jianma.designyl.exception.DcRedirectException;
import com.jianma.designyl.model.MailBean;
import com.jianma.designyl.model.PagingModel;
import com.jianma.designyl.model.Role;
import com.jianma.designyl.model.SendEmail;
import com.jianma.designyl.model.User;
import com.jianma.designyl.model.UserRole;
import com.jianma.designyl.service.MailService;
import com.jianma.designyl.service.UserService;
import com.jianma.designyl.util.ConfigInfo;
import com.jianma.designyl.util.PasswordHelper;
import com.jianma.designyl.util.ResponseCodeUtil;
import com.sun.mail.smtp.SMTPSendFailedException;
@Service
@Component
@Qualifier(value = "userServiceImpl")
@Transactional
public class UserServiceImpl implements UserService {
@Autowired
@Qualifier(value = "userDaoImpl")
private UserDao userDaoImpl;
@Autowired
@Qualifier(value = "mailServiceImpl")
private MailService mailServiceImpl;
@Autowired
@Qualifier(value = "configInfo")
private ConfigInfo configInfo;
@Autowired
@Qualifier(value = "sendEmailDaoImpl")
private SendEmailDao sendEmailDaoImpl;
@Override
public int createUser(User user) {
try {
Optional<User> optUser = userDaoImpl.findByEmail(user.getEmail());
if (optUser.isPresent()) {
return ResponseCodeUtil.UESR_CREATE_EXIST;
} else {
PasswordHelper.encryptAppPassword(user);
user.setActivecode(PasswordHelper.getMD5(user.getEmail()));
Set<UserRole> userRoles = new HashSet<>();
UserRole userRole = new UserRole();
userRole.setUser(user);
Role role = new Role();
role.setId(3);
userRole.setRole(role);
userRoles.add(userRole);
user.setUserRoles(userRoles);
userDaoImpl.createUser(user);
StringBuffer sBuilder = new StringBuffer("点击下面链接激活账号,48小时生效,否则重新注册账号,链接只能使用一次,请尽快激活!</br>");
sBuilder.append("<a href=\"" + configInfo.email_active_url + "/user/active?email=");
sBuilder.append(user.getEmail());
sBuilder.append("&activeCode=");
sBuilder.append(user.getActivecode());
sBuilder.append("\">激活账号:" + user.getEmail());
sBuilder.append("</a>");
MailBean mailBean = new MailBean();
mailBean.setContext(sBuilder.toString());
mailBean.setFrom(configInfo.email_active_from);
mailBean.setFromName(configInfo.email_active_from_name);
mailBean.setSubject(configInfo.email_active_subject);
mailBean.setToEmails(new String[] { user.getEmail() });
//记录邮件发送日志
SendEmail sendEmail = new SendEmail();
sendEmail.setEmail(user.getEmail());
sendEmail.setCreatetime(new Date());
try {
mailServiceImpl.sendMail(mailBean);
sendEmail.setSign((byte)1);
} catch(AuthenticationFailedException e){
sendEmail.setSign((byte)3);
sendEmail.setRemark("发送邮箱身份验证异常");
}catch(SMTPSendFailedException e){
sendEmail.setSign((byte)4);
sendEmail.setRemark("SMTPSendFailedException");
}
catch (UnsupportedEncodingException e) {
sendEmail.setSign((byte)2);
sendEmail.setRemark("不支持的内容编码格式");
} catch (MessagingException e) {
sendEmail.setRemark("MessagingException");
sendEmail.setSign((byte)2);
}catch (Exception e){
sendEmail.setRemark("其它错误");
sendEmail.setSign((byte)5);
e.printStackTrace();
}
sendEmailDaoImpl.createSendEmail(sendEmail);
return ResponseCodeUtil.UESR_OPERATION_SUCESS;
}
} catch (Exception e) {
e.printStackTrace();
return ResponseCodeUtil.UESR_OPERATION_FAILURE;
}
}
@Override
public int updateUser(User user) {
try {
userDaoImpl.updateUser(user);
return ResponseCodeUtil.UESR_OPERATION_SUCESS;
} catch (Exception e) {
return ResponseCodeUtil.UESR_OPERATION_FAILURE;
}
}
@Override
public int deleteUser(Long userId) {
try {
userDaoImpl.deleteUser(userId);
return ResponseCodeUtil.UESR_OPERATION_SUCESS;
} catch (Exception e) {
return ResponseCodeUtil.UESR_OPERATION_FAILURE;
}
}
@Override
public int correlationRoles(Long userId, Long... roleIds) {
try {
userDaoImpl.correlationRoles(userId, roleIds);
return ResponseCodeUtil.UESR_OPERATION_SUCESS;
} catch (Exception e) {
return ResponseCodeUtil.UESR_OPERATION_FAILURE;
}
}
@Override
public int uncorrelationRoles(Long userId, Long... roleIds) {
try {
userDaoImpl.uncorrelationRoles(userId, roleIds);
return ResponseCodeUtil.UESR_OPERATION_SUCESS;
} catch (Exception e) {
return ResponseCodeUtil.UESR_OPERATION_FAILURE;
}
}
@Override
public Optional<User> findOne(Long userId) {
return userDaoImpl.findOne(userId);
}
@Override
public Optional<User> findByEmail(String email) {
return userDaoImpl.findByEmail(email);
}
@Override
public Set<String> findRoles(String username) {
return userDaoImpl.findRoles(username);
}
@Override
public Set<String> findPermissions(String username) {
return userDaoImpl.findPermissions(username);
}
@Override
public void activeUser(String email, String activeCode) throws DCException {
Optional<User> user = userDaoImpl.findByEmail(email);
if (user.isPresent()) {
if (user.get().getActivesign() == 0) {
if (activeCode.equals(user.get().getActivecode())) {
userDaoImpl.updateActiveSign(email);
} else {
throw new DcRedirectException(400, "激活码不正确");
}
} else {
throw new DcRedirectException(200, "邮箱已激活,请登录!");
}
} else {
throw new DcRedirectException(500, "邮箱未注册");
}
}
@Override
public int updatePwd(String email, String password,String oldSlot) {
try {
User user = new User();
user.setPassword(password);
user.setEmail(email);
PasswordHelper.encryptAppPassword(user);
userDaoImpl.updatePwd(email, user.getPassword(), oldSlot, user.getSlot());
return ResponseCodeUtil.UESR_OPERATION_SUCESS;
} catch (Exception e) {
e.printStackTrace();
return ResponseCodeUtil.UESR_OPERATION_FAILURE;
}
}
@Override
public int resetLoginUserPwd(String password) {
try {
Subject subject = SecurityUtils.getSubject();
String email = subject.getSession().getAttribute("email").toString();
User user = new User();
user.setPassword(password);
user.setEmail(email);
PasswordHelper.encryptAppPassword(user);
userDaoImpl.resetLoginUserPwd(email, user.getPassword(), user.getSlot());
return ResponseCodeUtil.UESR_OPERATION_SUCESS;
} catch (Exception e) {
e.printStackTrace();
return ResponseCodeUtil.UESR_OPERATION_FAILURE;
}
}
@Override
public Optional<User> checkAuthc(String email) {
// TODO Auto-generated method stub
return userDaoImpl.checkAuthc(email);
}
@Override
public PagingModel getUserByPage(int offset, int limit) {
List<User> list = userDaoImpl.findUserListByPage(offset, limit);
int count = userDaoImpl.getCountUser();
PagingModel pagingModel = new PagingModel();
pagingModel.setCount(count);
pagingModel.setList(list);
return pagingModel;
}
@Override
public int updateValidSign(String email, int validValue) {
try {
userDaoImpl.updateValidSign(email, validValue);
return ResponseCodeUtil.UESR_OPERATION_SUCESS;
} catch (Exception e) {
return ResponseCodeUtil.UESR_OPERATION_FAILURE;
}
}
}
| [
"[email protected]"
] | |
51e131edffe0fcf591158c3bc0c69d308fb741bc | d4e9ba700c4a23c2e28eba4cbb2a17fcef600918 | /spring-study/suite-tool-test-1.1/src/main/java/com/zzl/demo/controller/UserController.java | 3f47725b3589ca7bd875dee67bcbfcff501af90b | [] | no_license | sun20191028/spring-space | 07d2ce4bce2451fa453b7e0ce73a85a124534785 | 56959769c7c6e5bd4b2e3d83daa3607a6f5aab4a | refs/heads/master | 2021-09-19T23:42:08.302683 | 2018-08-01T15:11:56 | 2018-08-01T15:11:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 903 | java | package com.zzl.demo.controller;
import java.util.HashMap;
import java.util.Map;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class UserController {
@RequestMapping("hello")
public String getString(){
return "Hello World";
}
/**
* 返回POJO
* @return
*/
@RequestMapping("user")
public User getUser(){
User user = new User();
return user;
}
@RequestMapping("map")
public Map getMap(){
// Map map = new HashMap();
// map.put("name", "zhangsan");
// map.put("age", 12);
// return map;
/**
* 返回基本类型json格式数据
*/
Map map = new HashMap();
User u1 = new User();
u1.setName("zhangsan");
u1.setAge(16);
User u2 = new User();
u2.setName("lisi");
u2.setAge(28);
map.put("u1", u1);
map.put("u2", u2);
return map;
}
}
| [
"zhiang082436"
] | zhiang082436 |
8bce172004e4df7bc71273698c938b0963c09697 | 8aa6eec7cdc8e8b7b9c625ae54eef2bce099e331 | /android/app/src/main/java/com/kmspembaca/MainApplication.java | 412ef8095fee0cb00dc8df7f6e6d915b5596fd49 | [] | no_license | raiwidartha/KMS-SAWIT-2020 | 506ba6ba0840b4b50adbc878a9ae5fc6e59235fa | 5295a8ace3c9b2991e92612fea605402011d897c | refs/heads/master | 2023-03-22T17:27:51.525602 | 2020-07-28T16:44:06 | 2020-07-28T16:44:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,826 | java | package com.kmspembaca;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.kishanjvaghela.cardview.RNCardViewPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*
* @param context
* @param reactInstanceManager
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.kmspembaca.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
| [
"[email protected]"
] | |
e11a0bd86be98285b8ac58cc4321b5fbad338fd6 | d3ba1a7def686a147d418aa35385d3a35ef1737a | /src/com/local/dev/FindTwoStringAnagram.java | 5195c28314d3731950dacb5581e8dae655d54e00 | [] | no_license | srinivv/data-structure-algorithms | 6a872a39843e4ff6b85b6331f2357e9a8c2bb931 | b97768db7135a67d6451be680ce55ff43fc4cfed | refs/heads/master | 2021-01-17T12:45:20.421187 | 2020-11-23T01:11:23 | 2020-11-23T01:11:23 | 56,953,097 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 434 | java | package com.local.dev;
import java.util.Arrays;
public class FindTwoStringAnagram {
public boolean isAnagram(String firstWord, String secondWord) {
char[] word1 = firstWord.replaceAll("[\\s]", "").toLowerCase().toCharArray();
char[] word2 = secondWord.replaceAll("[\\s]", "").toLowerCase().toCharArray();
Arrays.sort(word1);
Arrays.sort(word2);
return Arrays.equals(word1, word2);
}
}
| [
"[email protected]"
] | |
749d77a30cd97582277ed0ca1951d539690dfb57 | 9f4072d5daeca65ab45181902d2fd594a287041a | /src/business/model/categories/Breakfast.java | b30f3a3bf463d91f47f9449ddb4caae48c5e7186 | [] | no_license | bmviniciuss/lab-mps | 8ab2d071450ac7aa01ac9ee4a578bf4e8d471671 | 89ee06d895342521031b0b85defeda197555ffaf | refs/heads/main | 2023-01-30T04:20:48.771446 | 2020-12-14T23:54:41 | 2020-12-14T23:54:41 | 314,104,250 | 0 | 1 | null | 2020-12-14T23:54:42 | 2020-11-19T01:32:50 | Java | UTF-8 | Java | false | false | 239 | java | package business.model.categories;
import business.model.Item;
import business.model.ItemDecorator;
public class Breakfast extends ItemDecorator {
public Breakfast(Item item){
super(item);
name = "Breakfast";
}
} | [
"[email protected]"
] | |
8588536b834260538be17c687364531b0a7cf183 | 3507e99940af6aaff40403cc3fa458884e5278a6 | /pictureRequest/app/src/main/java/com/example/picrequest/RestApi/RestApi.java | 524f96c27d4a62a9c1061c753088d5415cb7bb4f | [] | no_license | AbdulsametAyyildiz/Picture-Request-Android-Java- | 8256213201ef6e93e75362679ea2767fb996d399 | 833de5e63f66b301298072d598c70b019490f22c | refs/heads/main | 2023-05-28T17:39:37.874149 | 2021-06-08T00:54:31 | 2021-06-08T00:54:31 | 374,483,427 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 258 | java | package com.example.picrequest.RestApi;
import com.example.picrequest.Models.Products;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.GET;
public interface RestApi {
@GET("/productList.php")
Call<List<Products>> getList();
}
| [
"[email protected]"
] | |
4c7b37fb4afb6d5b017f6dc3d29b2d0ed7aa0c4a | 36bbde826ff3e123716dce821020cf2a931abf6e | /plugin/src/test/java/editor/intentions/PerlModifierToStatementIntentionsTest.java | a35471c6e66e55a0250e71b5eacf686a397ec8a0 | [
"Apache-2.0"
] | permissive | Camelcade/Perl5-IDEA | 0332dd4794aab5ed91126a2c1ecd608f9c801447 | deecc3c4fcdf93b4ff35dd31b4c7045dd7285407 | refs/heads/master | 2023-08-08T07:47:31.489233 | 2023-07-27T05:18:40 | 2023-07-27T06:17:04 | 33,823,684 | 323 | 79 | NOASSERTION | 2023-09-13T04:36:15 | 2015-04-12T16:09:15 | Java | UTF-8 | Java | false | false | 1,941 | java | /*
* Copyright 2015-2019 Alexandr Evstigneev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package editor.intentions;
import com.intellij.openapi.util.io.FileUtil;
import com.perl5.PerlBundle;
import org.junit.Test;
public class PerlModifierToStatementIntentionsTest extends PerlIntentionsTestCase {
@Override
protected String getBaseDataPath() {
return FileUtil.join(super.getBaseDataPath(), "modifierToStatement");
}
@Test
public void testModifierToStatementFor() {doTest();}
@Test
public void testModifierToStatementForeach() {doTest();}
@Test
public void testModifierToStatementIf() {doTest();}
@Test
public void testModifierToStatementIfDo() {doTest();}
@Test
public void testModifierToStatementIfEmpty() {doTest(false);}
@Test
public void testModifierToStatementIfParenthesized() {doTest();}
@Test
public void testModifierToStatementUnless() {doTest();}
@Test
public void testModifierToStatementUntil() {doTest();}
@Test
public void testModifierToStatementWhen() {doTest();}
@Test
public void testModifierToStatementWhile() {doTest();}
@Test
public void testModifierToStatementWithError() {doTestNoIntention(PerlBundle.message("perl.intention.convert.to.compound"));}
private void doTest(boolean checkErrors) {
doTestIntention(PerlBundle.message("perl.intention.convert.to.compound"), checkErrors);
}
private void doTest() {doTest(true);}
}
| [
"[email protected]"
] | |
ad5b2925eb1c96ea2a2b4ba82d9b7c80ae2deb5f | ac1f5c785def4970714020360f26f635e03831c8 | /chat_backend/src/main/java/edu/sandau/chat/exception/RegisterException.java | e23692ce20d32c9b18e1ab372e80582842f46f22 | [] | no_license | 123123ll/chat | 7aa1132f2d3376908ac66748e21932c3e05bcf35 | 33762f4b02772cc3446597ba449f054574290956 | refs/heads/master | 2023-02-18T01:54:51.381456 | 2021-01-16T10:00:20 | 2021-01-16T10:00:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 194 | java | package edu.sandau.chat.exception;
/***
* 注册用户异常
*/
public class RegisterException extends RuntimeException {
public RegisterException(String message) {
super(message);
}
}
| [
"[email protected]"
] | |
6e25c707db92311712e0a14e03df3e9639fe332a | e8d2d1d5a1e6522481f8505f048c4052481f3ce0 | /src/ifpb/pi/edd/listaencadeada/ListaEncadeada.java | e56ad6106f54d285f1384c0c3f6174ccb5f09493 | [] | no_license | romulomenezesjr/estruturadedados | d3a8f37a6993f303be2efe9a74876ae56df80e01 | c762417d9590f5c5042efb4a7ea8b4bc120e188b | refs/heads/master | 2020-03-27T18:00:36.127138 | 2018-10-03T17:38:00 | 2018-10-03T17:38:00 | 146,891,878 | 1 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 3,569 | java | package ifpb.pi.edd.listaencadeada;
import ifpb.pi.edd.lista.Lista;
public class ListaEncadeada implements Lista {
private Celula primeira;
private Celula ultima;
private int totalDeElementos;
@Override
public void inicializa() {
primeira = null;
ultima = null;
totalDeElementos = 0;
}
@Override
public void adicionar(Object e) {
if (this.totalDeElementos == 0) {
adicionarNoComeco(e);
} else {
adicionaNoFinal(e);
}
}
private void adicionaNoFinal(Object e) {
Celula celulaNova = new Celula(null, e);
this.ultima.setProxima(celulaNova);
this.ultima = celulaNova;
this.totalDeElementos++;
}
@Override
public void adicionar(int posicao, Object e) {
if (posicao == 0) {
adicionarNoComeco(e);
} else if (posicao == this.totalDeElementos) {
this.adicionaNoFinal(e);
} else {
Celula anterior = pegarCelula(posicao - 1);
Celula celulaNova = new Celula(anterior.getProxima(), e);
anterior.setProxima(celulaNova);
this.totalDeElementos++;
}
}
private boolean posicaoValida(int posicao) {
return posicao >= 0 && posicao < tamanho();
}
private Celula pegarCelula(int posicao) {
if (!this.posicaoValida(posicao)) {
throw new IllegalArgumentException("Posição não existe");
}
Celula atual = primeira;
for (int i = 0; i < posicao; i++) {
atual = atual.getProxima();
}
return atual;
}
@Override
public Object recuperar(int posicao) {
return pegarCelula(posicao).getElemento();
}
@Override
public void remover(int posicao) {
if (!posicaoValida(posicao)) {
throw new IllegalArgumentException("Posição inválida");
}
if (posicao == this.totalDeElementos - 1) {
removeDoFim();
} else if (posicao == 0) {
removeDoComeco();
} else {
Celula anterior = pegarCelula(posicao - 1);
Celula atual = pegarCelula(posicao);
Celula proxima = atual.getProxima();
anterior.setProxima(proxima);
totalDeElementos--;
}
}
private void removeDoFim() {
if (!posicaoValida(this.totalDeElementos - 1)) {
throw new IllegalArgumentException("Posição inválida");
}
if (this.tamanho() == 1) {
removeDoComeco();
} else {
Celula penultima = pegarCelula(this.tamanho() - 1);
this.ultima = penultima;
this.ultima.setProxima(null);
this.totalDeElementos--;
}
}
@Override
public boolean verificar(Object e) {
for (int i = 0; i < this.totalDeElementos; i++) {
Celula atual = primeira;
if (atual.getElemento().equals(e)) {
return true;
}
atual = atual.getProxima();
}
return false;
}
@Override
public int tamanho() {
return this.totalDeElementos;
}
public void adicionarNoComeco(Object elemento) {
Celula nova = new Celula(this.primeira, elemento);
this.primeira = nova;
if (this.totalDeElementos == 0) {
this.ultima = this.primeira;
}
this.totalDeElementos++;
}
public void removeDoComeco() {
if (!this.posicaoValida(0)) {
throw new IllegalArgumentException("Posição inválida");
}
Celula proxima = this.primeira.getProxima();
this.primeira = proxima;
this.totalDeElementos--;
if (this.totalDeElementos == 0) {
this.ultima = null;
}
}
@Override
public String toString() {
if (tamanho() == 0) {
return "[]";
}
StringBuilder sb = new StringBuilder();
Celula atual = primeira;
sb.append("[ ");
for (int i = 0; i < totalDeElementos - 1; i++) {
sb.append(atual.getElemento());
sb.append(", ");
atual = atual.getProxima();
}
sb.append(atual.getElemento());
atual = atual.getProxima();
sb.append(" ]");
return sb.toString();
}
}
| [
"[email protected]"
] | |
0f0cc4ac83700e3d9e58b3fc412db77424a86884 | adf4418a1d600722a60fdf8806c02b5c0877733f | /Impact/app/src/main/java/com/example/impact/show_impact.java | 5e4238d793bc085a0c221466e1b209019566805f | [] | no_license | ayushmishra6198/GOONJ-EI | fcfc6c47402fe4f738c4e6503272bd93389abd82 | b8518526fa6eb2af769a0f9b4ec1f864d9e49f85 | refs/heads/master | 2020-05-07T15:04:45.506633 | 2019-04-10T16:21:44 | 2019-04-10T16:21:44 | 180,619,892 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,099 | java | package com.example.impact;
import android.content.Intent;
import android.support.constraint.ConstraintLayout;
import android.support.v4.widget.TextViewCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.GridLayout;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
public class show_impact extends AppCompatActivity {
ConstraintLayout r1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_impact);
Intent intent = getIntent();
String user_name = intent.getStringExtra("USER_NAME");
//TextView tv=(TextView)findViewById(R.id.textView10);
r1=(ConstraintLayout)findViewById(R.id.cl2);
GridView gv=(GridView) findViewById(R.id.gv1);
if(user_name.equals("0")==true)
{
try{
String sql="select material from t_impacts where id=1";
ConnectionClass c=new ConnectionClass();
Connection conn=c.CONN();
Statement stat=conn.createStatement();
ResultSet rs=stat.executeQuery(sql);
ArrayList data=new ArrayList();
data.add("Impacts");
while(rs.next())
{
data.add(rs.getString(1));
}
r1.setBackgroundResource(R.drawable.books);
gv.setNumColumns(1);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,data);
gv.setAdapter(adapter);
Toast.makeText(this,"Table Created",Toast.LENGTH_SHORT).show();
}
catch(Exception e)
{
Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
}
}
if(user_name.equals("1")==true)
{
try{
String sql="select material from t_impacts where id=2";
ConnectionClass c=new ConnectionClass();
Connection conn=c.CONN();
Statement stat=conn.createStatement();
ResultSet rs=stat.executeQuery(sql);
ArrayList data=new ArrayList();
data.add("Impacts");
while(rs.next())
{
data.add(rs.getString(1));
}
gv.setNumColumns(1);
r1.setBackgroundResource(R.drawable.elec);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,data);
gv.setAdapter(adapter);
Toast.makeText(this,"Table Created",Toast.LENGTH_SHORT).show();
}
catch(Exception e)
{
Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
}
}
if(user_name.equals("2")==true) {
try {
String sql = "select material from t_impacts where id=3";
ConnectionClass c = new ConnectionClass();
Connection conn = c.CONN();
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery(sql);
ArrayList data = new ArrayList();
data.add("Impacts");
while (rs.next()) {
data.add(rs.getString(1));
}
gv.setNumColumns(1);
r1.setBackgroundResource(R.drawable.rubber);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, data);
gv.setAdapter(adapter);
} catch (Exception e) {
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
}
}
if(user_name.equals("3")==true) {
try {
String sql = "select material from t_impacts where id=4";
ConnectionClass c = new ConnectionClass();
Connection conn = c.CONN();
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery(sql);
ArrayList data = new ArrayList();
data.add("Impacts");
while (rs.next()) {
data.add(rs.getString(1));
}
r1.setBackgroundResource(R.drawable.kitchen);
gv.setNumColumns(1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, data);
gv.setAdapter(adapter);
} catch (Exception e) {
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
}
}
if(user_name.equals("4")==true) {
try {
String sql = "select material from t_impacts where id=5";
ConnectionClass c = new ConnectionClass();
Connection conn = c.CONN();
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery(sql);
ArrayList data = new ArrayList();
data.add("Impacts");
while (rs.next()) {
data.add(rs.getString(1));
}
r1.setBackgroundResource(R.drawable.footwear);
gv.setNumColumns(1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, data);
gv.setAdapter(adapter);
} catch (Exception e) {
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
}
}
if(user_name.equals("5")==true) {
try {
String sql = "select material from t_impacts where id=6";
ConnectionClass c = new ConnectionClass();
Connection conn = c.CONN();
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery(sql);
ArrayList data = new ArrayList();
data.add("Impacts");
while (rs.next()) {
data.add(rs.getString(1));
}
r1.setBackgroundResource(R.drawable.clothes);
gv.setNumColumns(1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, data);
gv.setAdapter(adapter);
} catch (Exception e) {
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
}
}
if(user_name.equals("6")==true) {
try {
String sql = "select material from t_impacts where id=7";
ConnectionClass c = new ConnectionClass();
Connection conn = c.CONN();
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery(sql);
ArrayList data = new ArrayList();
data.add("Impacts");
while (rs.next()) {
data.add(rs.getString(1));
}
r1.setBackgroundResource(R.drawable.furniture);
gv.setNumColumns(1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, data);
gv.setAdapter(adapter);
} catch (Exception e) {
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
}
}
if(user_name.equals("7")==true) {
try {
String sql = "select material from t_impacts where id=8";
ConnectionClass c = new ConnectionClass();
Connection conn = c.CONN();
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery(sql);
ArrayList data = new ArrayList();
data.add("Impacts");
while (rs.next()) {
data.add(rs.getString(1));
}
r1.setBackgroundResource(R.drawable.toys);
gv.setNumColumns(1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, data);
gv.setAdapter(adapter);
} catch (Exception e) {
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
}
}
}
}
| [
"[email protected]"
] | |
8c341a696df9f83095d5f7182cf1d6f4e24a14ca | 0e418703ef032b93ed2e7d374980ffc91ba27177 | /Prep/EqualSubarrays.java | 44f2121af07a0268cd2c7ad6e2cf7d08153fb691 | [] | no_license | anant2614/codes | 165d378401ed95db3686c770f093faa9a96c279a | 28d1902be399eb7e3f677c6a14dbac3accefef1e | refs/heads/master | 2020-03-08T11:35:18.869568 | 2018-04-27T06:12:26 | 2018-04-27T06:12:26 | 128,102,022 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 662 | java | package Prep;
public class EqualSubarrays {
public static void main(String gjg[]) {
int a[] = { 6, 1, 3, 2, 5 };
System.out.println(checkForDivision(a));
}
private static boolean checkForDivision(int[] a) {
int sum = 0;
for (int i = 0; i < a.length; i++) {
sum += a[i];
}
int sum_here = 0;
for (int i = 0; i < a.length; i++) {
if (2 * sum_here + a[i] == sum) {
print(a, 0, i);
System.out.println();
print(a, i + 1, a.length);
return true;
}
sum_here += a[i];
}
return false;
}
private static void print(int[] a, int start, int end) {
for (int i = start; i < end; i++)
System.out.print(a[i] + " ");
}
}
| [
"[email protected]"
] | |
c3530759b0e011a9a2c50dc03d0a420678e52c4a | f220ffe377ef4e5e150be9be4a6ecbfe177abd72 | /Creational/AbstractFactory/src/main/java/buttons/Button.java | 5b76402b9687bf400d9a6d98690810fee3ef890d | [] | no_license | OleksandrChekalenko/Patterns | 06f5ddb45a0b44674d95ebf8134831340c0d3cbb | 5b6befc278943c187a48c07be5bb260640e479b8 | refs/heads/master | 2021-04-12T01:14:16.488519 | 2020-04-19T16:34:05 | 2020-04-19T16:34:05 | 249,073,026 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 325 | java | package buttons;
/**
* Abstract Factory assumes that you have several families of products,
* structured into separate class hierarchies (Button/Checkbox). All products of
* the same family have the common interface.
*
* This is the common interface for buttons family.
*/
public interface Button {
void paint();
} | [
"[email protected]"
] | |
7cdba0af3e174c71fc24302ec6e6bd3bb92c1d47 | f269d40c5f60d5e8d32cf021db19e330f1066917 | /Aula3/src/repositories/MotaRepository.java | ede6c7109f1052889780b2599a1575acf22f2572 | [] | no_license | ffabiollopes/Java | 5f367366cadf407e7fc1a9775bbf7975659d6bc8 | d3265be84e4d492a75aa21551355547f2b364746 | refs/heads/master | 2020-04-06T23:43:21.794456 | 2018-11-19T19:01:24 | 2018-11-19T19:01:24 | 157,879,093 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 112 | java | package repositories;
import entities.Mota;
public class MotaRepository extends VeicRepository <Mota>{
}
| [
"[email protected]"
] | |
ab0a098f6e44ccfd0fc8d6b69db48e0a70f338fe | 4285410c01a0b12dab72ec47dd395b690b130aa9 | /library/src/main/java/net/qiujuer/genius/drawable/SeekBarStatusDrawable.java | 32a626e43cb610abf6bbdd41eb3d106109a88d3b | [
"Apache-2.0"
] | permissive | Rock610/steady | 7075a8620c252b94bc3c12b4cd270181af08e007 | 21257e9c4ef73f42f421b61aba366e93774fd56c | refs/heads/master | 2021-01-10T16:14:22.582257 | 2015-11-16T07:07:20 | 2015-11-16T07:07:20 | 46,257,356 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,768 | java | /*
* Copyright (C) 2014 Qiujuer <[email protected]>
* WebSite http://www.qiujuer.net
* Created 02/20/2015
* Changed 03/01/2015
* Version 2.0.0
* Author Qiujuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.qiujuer.genius.drawable;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
/**
* A drawable that changes it's Paint and color depending on the Drawable State
* For SeekBarDrawable {@link net.qiujuer.genius.drawable.SeekBarDrawable}
*
* @Hide
*/
public abstract class SeekBarStatusDrawable extends Drawable {
private final Paint mPaint;
private int mAlpha = 255;
private ColorStateList mTrackStateList;
private int mTrackColor;
private ColorStateList mScrubberStateList;
private int mScrubberColor;
private ColorStateList mThumbStateList;
private int mThumbColor;
public SeekBarStatusDrawable(ColorStateList trackStateList, ColorStateList scrubberStateList, ColorStateList thumbStateList) {
super();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
setTrackColor(trackStateList);
setScrubberColor(scrubberStateList);
setThumbColor(thumbStateList);
}
@Override
public boolean isStateful() {
return (mTrackStateList.isStateful() && mScrubberStateList.isStateful() && mThumbStateList.isStateful()) || super.isStateful();
}
@Override
public void draw(Canvas canvas) {
final int trackAlpha = modulateAlpha(Color.alpha(mTrackColor));
final int scrubberAlpha = modulateAlpha(Color.alpha(mScrubberColor));
final int thumbAlpha = modulateAlpha(Color.alpha(mThumbColor));
draw(canvas, mPaint, mTrackColor, trackAlpha, mScrubberColor, scrubberAlpha, mThumbColor, thumbAlpha);
}
@Override
public void setAlpha(int alpha) {
mAlpha = alpha;
invalidateSelf();
}
@Override
public boolean setState(int[] stateSet) {
boolean changed = super.setState(stateSet);
changed = updateTintColor(stateSet) || changed;
return changed;
}
@Override
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
}
@Override
public int getAlpha() {
return mAlpha;
}
@Override
public void setColorFilter(ColorFilter cf) {
mPaint.setColorFilter(cf);
}
/**
* Set the Track ColorStateList
*
* @param stateList ColorStateList
*/
public void setTrackColor(ColorStateList stateList) {
mTrackStateList = stateList;
mTrackColor = mTrackStateList.getDefaultColor();
}
/**
* Set the Scrubber ColorStateList
*
* @param stateList ColorStateList
*/
public void setScrubberColor(ColorStateList stateList) {
mScrubberStateList = stateList;
mScrubberColor = mScrubberStateList.getDefaultColor();
}
/**
* Set the Thumb ColorStateList
*
* @param stateList ColorStateList
*/
public void setThumbColor(ColorStateList stateList) {
mThumbStateList = stateList;
mThumbColor = mThumbStateList.getDefaultColor();
}
/**
* Get the Tint ColorStateList
*
* @return mTintStateList
*/
public ColorStateList[] getColor() {
return new ColorStateList[]{mTrackStateList, mScrubberStateList, mThumbStateList};
}
/**
* Get The CurrentColor
*
* @return mCurrentColor
*/
public int[] getCurrentColor() {
return new int[]{mTrackColor, mScrubberColor, mThumbColor};
}
/**
* Modulate color Alpha
*
* @param alpha color alpha
* @return modulate colorAlpha and this alpha
*/
protected int modulateAlpha(int alpha) {
int scale = mAlpha + (mAlpha >> 7);
return alpha * scale >> 8;
}
/**
* Subclasses should implement this method to do the actual drawing
*
* @param canvas The current {@link android.graphics.Canvas} to draw into
* @param paint The {@link android.graphics.Paint} the Paint object that defines with the current
* {@link android.content.res.ColorStateList} color
*/
public abstract void draw(Canvas canvas, Paint paint, int trackColor, int trackAlpha, int scrubberColor, int scrubberAlpha, int thumbColor, int thumbAlpha);
/**
* Update tint color
*
* @param state tint stats
* @return is changed
*/
private boolean updateTintColor(int[] state) {
final int trackColor = mTrackStateList.getColorForState(state, mTrackColor);
final int scrubberColor = mScrubberStateList.getColorForState(state, mScrubberColor);
final int thumbColor = mThumbStateList.getColorForState(state, mThumbColor);
if (trackColor != mTrackColor || scrubberColor != mScrubberColor || thumbColor != mThumbColor) {
mTrackColor = trackColor;
mScrubberColor = scrubberColor;
mThumbColor = thumbColor;
invalidateSelf();
return true;
}
return false;
}
}
| [
"[email protected]"
] | |
bbaea429dbffa215c4ff56b86fc508e87886084c | 1d6302048ff3a5e78ab1147e8288727f8d6545a8 | /src/test/java/gitt/gitt/AppTest.java | 69478811b4b243de3328e2eadf08872a3f6648b6 | [] | no_license | shiva1198/shivarepo | 6b18c3fb71fd48fd1aec275b87dfe9624d70bf7c | 0940a564190ecf326f8c571404481ea1e8c0e14d | refs/heads/master | 2021-06-26T11:54:40.993669 | 2019-11-26T07:00:26 | 2019-11-26T07:00:26 | 224,097,490 | 0 | 0 | null | 2020-10-13T17:45:05 | 2019-11-26T03:50:40 | JavaScript | UTF-8 | Java | false | false | 675 | java | package gitt.gitt;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
| [
"[email protected]"
] | |
036e2c3ba9c55c9625847b8c3bf8e637de435dec | c60705dd7b8cad3a47498e72d1ae012932541d68 | /live_shop_server/src/main/java/cn/jjvu/xiao/pojo/Log.java | 3d5b93027b5011b507d30016c79962704c37cc6f | [] | no_license | zhangfangtaozft/liveshop | 2a30238ff9c8647bca90fd16de8121376dafd7a8 | b6bec65a54ba82e106abe0b6cca2270a30b2fed0 | refs/heads/master | 2022-11-11T01:57:13.064525 | 2020-07-04T15:40:36 | 2020-07-04T15:40:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,257 | java | package cn.jjvu.xiao.pojo;
import java.util.Date;
public class Log {
private Integer id;
private String userName;
private String operation;
private String method;
private String params;
private Long time;
private String ip;
private String createBy;
private Date createTime;
private String lastUpdateBy;
private Date lastUpdateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName == null ? null : userName.trim();
}
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation == null ? null : operation.trim();
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method == null ? null : method.trim();
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params == null ? null : params.trim();
}
public Long getTime() {
return time;
}
public void setTime(Long time) {
this.time = time;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip == null ? null : ip.trim();
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy == null ? null : createBy.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getLastUpdateBy() {
return lastUpdateBy;
}
public void setLastUpdateBy(String lastUpdateBy) {
this.lastUpdateBy = lastUpdateBy == null ? null : lastUpdateBy.trim();
}
public Date getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Date lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
} | [
"[email protected]"
] | |
7d8f218151bdaeedd1d889fd0b1a4fbc2261951f | 4abc6a9c14280d9b03fd2f84052baa299f1055f3 | /Spring_Web_2/src/main/java/com/example/Controller/controller_1.java | 93efdef0af56a7658eae2566c23409557f07ae7d | [] | no_license | VincentVanNF/Pic | b300ec012176ab1e5c29d6b13150c3392ea2cdca | 36063a490f543113dd880531bb1e95197f3520d4 | refs/heads/main | 2023-08-16T05:36:41.050710 | 2021-10-20T11:49:58 | 2021-10-20T11:49:58 | 419,297,560 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,528 | java | package com.example.Controller;
import com.example.Service.AliAPI;
import com.example.Service.DownLoadFromURL;
import com.example.Service.IsDig;
import com.example.Service.OnePic.One;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.nio.charset.StandardCharsets;
@Controller
@RequestMapping(value = "/picture")
public class controller_1 {
@Autowired
ServletContext servletContext;
@Autowired
AliAPI API;
@Autowired
One one;
byte[] temp;
@RequestMapping(value = "/test.do")
public ModelAndView test() throws IOException {
System.out.println("=====进入=====");
ModelAndView modelAndView = new ModelAndView();
String str = servletContext.getRealPath("/WEB-INF/Pics/test.txt");
temp = "Hello World".getBytes(StandardCharsets.UTF_8);
FileOutputStream fileOutputStream = new FileOutputStream(str);
fileOutputStream.write(temp);
FileInputStream fileInputStream = new FileInputStream(str);
fileInputStream.read(temp);
String msg = new String(temp);
modelAndView.addObject("msg", msg);
modelAndView.setViewName("show");
System.out.println("=====退出=====");
return modelAndView;
}
@RequestMapping(value = "/service", method = RequestMethod.POST)
public ModelAndView first(HttpServletRequest httpServletRequest,
@RequestParam(value = "person", required = false) MultipartFile person,
@RequestParam(value = "back", required = false) MultipartFile back,
@RequestParam(value = "size",required = false) String size,
@RequestParam(value = "degree",required = false) String degree) throws Exception {
System.out.println("=====进入控制器=====");
ModelAndView modelAndView = new ModelAndView();
if (person.getSize() == 0 || back == null || "".equals(degree) || "".equals(degree) ||(!IsDig.IsDigit(degree)) ) {
System.out.println("=====图片参数为空处理=====");
modelAndView.setViewName("show_400");
return modelAndView;
}
System.out.println("人物图片url:person变量 " + person);
System.out.println("背景图片url:back变量 " + back);
System.out.println("size变量 " + size);
System.out.println("degree变量 " + degree);
double sizeID = 0;
double degree_num = 0;
degree_num = Double.parseDouble(degree);
switch (size){
case "3.0":
sizeID = 3.0;
break;
case "2.5":
sizeID = 2.5;
break;
case "2.0":
sizeID = 2.0;
break;
case "1.5":
sizeID = 1.5;
break;
case "1.0":
sizeID = 1.0;
break;
case "0.75":
sizeID = 0.75;
break;
case "0.65":
sizeID = 0.65;
case "0.5":
sizeID = 0.5;
break;
case "0.35":
sizeID = 0.35;
break;
case "0.25":
sizeID = 0.25;
break;
case "0.15":
sizeID = 0.15;
break;
default:
sizeID = 1.0;
}
System.out.println("=====调用的service方法处理图片=====");
String filename = servletContext.getRealPath("/static/images/person.jpg");
File person_img = new File(filename);
person.transferTo(person_img);
System.out.println(filename);
//用户照片下载到服务器
String filename1 = servletContext.getRealPath("/static/images/back.jpg");
back.transferTo(new File(filename1));
System.out.println(filename1);
//用户背景下载到服务器
System.out.println("=====调用阿里云接口人像分割=====");
System.out.println(filename);
API.imageSeg(person_img,filename);
one.OnePic(filename,filename1,sizeID,degree_num);
modelAndView.setViewName("show_onepic");
System.out.println("=====退出控制器=====");
return modelAndView;
}
@RequestMapping(value = "/service_1", method = RequestMethod.POST)
public ModelAndView second(HttpServletRequest httpServletRequest,
@RequestParam(value = "person", required = false) MultipartFile person,
@RequestParam(value = "size", required = false) String size,
@RequestParam(value ="color" ,required = false)String color) throws Exception {
System.out.println("=====进入控制器=====");
ModelAndView modelAndView = new ModelAndView();
String spaceID;
String bkColor;
if (person.getSize() == 0 || "".equals(size) || "".equals(color)){
System.out.println("=====图片参数为空处理=====");
modelAndView.setViewName("show_400");
return modelAndView;
}
System.out.println("图片url:person变量 " + person);
System.out.println("size变量 " + size);
System.out.println("color变量 " + color);
switch (size){
case "一寸":
spaceID = "1";
break;
case "小一寸":
spaceID = "2";
break;
case "大一寸":
spaceID = "3";
break;
case "二寸":
spaceID = "4";
break;
case "小二寸":
spaceID = "5";
break;
case "大二寸":
spaceID = "6";
break;
case "身份证":
spaceID = "10";
break;
case "医保证":
spaceID = "24";
break;
case "英语四六级":
spaceID = "40";
break;
case "美国签证":
spaceID = "7";
break;
case "韩国签证":
spaceID = "76";
break;
case "日本签证":
spaceID = "8";
break;
case "马拉西亚签证":
spaceID = "82";
break;
case "新西兰签证":
spaceID = "83";
break;
case "意大利签证":
spaceID = "84";
break;
case "泰国签证":
spaceID = "77";
break;
default:
spaceID = "1";
break;
}
switch (color){
case "蓝底":
bkColor = "blue";
break;
case "红底":
bkColor = "red";
break;
case "白底":
bkColor = "white";
break;
case "蓝色渐变":
bkColor = "blue_gradual";
break;
case "红色渐变":
bkColor = "red_gradual";
break;
case "灰色渐变":
bkColor = "gray_gradual";
break;
default:
bkColor = "white";
break;
}
System.out.println("=====调用的service方法处理图片=====");
String filename = servletContext.getRealPath("/static/images/pro_person.jpg");
File person_file = new File(filename);
person.transferTo(person_file);
System.out.println(filename);
//用户照片下载到服务器
System.out.println("=====调用阿里云接口人像分割=====");
System.out.println(filename);
API.idPhotoMake(person_file,spaceID,bkColor,person_file);
modelAndView.setViewName("show_professionpic");
System.out.println("=====退出控制器=====");
return modelAndView;
}
/*
处理器方法形式参数为java对象,对象中属性值与请求名一致
框架自动创建此接收对象的参数,给属性赋值。调用setName进行赋值。
*/
// @RequestMapping(value = "/receiveObject", method = RequestMethod.POST)
// public ModelAndView first(Picture picture) {
// System.out.println("=====进入控制器=====");
// ModelAndView modelAndView = new ModelAndView();
//
// if ("".equals(picture.name) || "".equals(picture.age)) {
//
// System.out.println("=====参数为空处理=====");
// modelAndView.setViewName("show_400");
// } else {
//
// System.out.println("=====调用的service方法处理图片=====");
// modelAndView.addObject("name", picture.name);
// modelAndView.addObject("age", picture.age);
// modelAndView.addObject("picture", picture);
//
//
// modelAndView.setViewName("show1");
//
// }
// System.out.println("=====退出控制器=====");
// return modelAndView;
// }
@RequestMapping(value = "/jump1")
public String jump1(HttpServletRequest httpServletRequest) {
System.out.println("=====进入控制器,jump1请求=====");
ServletContext servletContext = httpServletRequest.getServletContext();
String str = servletContext.getRealPath("/");
System.out.println(str);
System.out.println("=====退出控制器,jump1请求=====");
return "show1";
}
@RequestMapping(value = "/jump2")
public String jump2() {
System.out.println("=====进入控制器,jump2请求=====");
System.out.println("=====退出控制器,jump2请求=====");
return "show2";
}
}
| [
"[email protected]"
] | |
b600f747654a360eccfb9e8e73eac81acbc0e192 | 3e76afc19377f5c191125a45c6fbb3315cb644d2 | /src/com/ghut/passbox/service/impl/SystemServiceImpl.java | d41ba798874b54be19a7c08e058efc5979a01455 | [] | no_license | gary5z/GPassBox-App | ef70b86db6c4ace992b00e5c99ac2327f51dac5b | 6fd21e3e8c7e08a5e7ac467fc43b392c2b49398c | refs/heads/master | 2022-04-06T00:50:02.926544 | 2020-03-07T10:07:04 | 2020-03-07T10:07:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,304 | java | package com.ghut.passbox.service.impl;
import android.content.ContentValues;
import android.database.Cursor;
import com.ghut.passbox.common.db.DBManager;
import com.ghut.passbox.service.SystemService;
import com.ghut.passbox.util.AppUtils;
import com.ghut.passbox.util.CryptoUtils;
import com.ghut.passbox.util.StringUtils;
/**
* @author Gary
*
*/
public class SystemServiceImpl implements SystemService {
private final static String TABLE_NAME = "System";
private final static String ENTER_PWD = "EnterPwd";
private final static String EMAIL = "Email";
private final static String VERSION = "Version";
private DBManager dbMgr;
public SystemServiceImpl(DBManager dbMgr) {
this.dbMgr = dbMgr;
}
@Override
public synchronized boolean hasRegistered() throws Exception {
int count = dbMgr.count(TABLE_NAME, null, null);
if (count > 0) {
return true;
}
return false;
}
private String query(String fieldName) throws Exception {
String result = null;
Cursor c = null;
try {
c = dbMgr.queryAll(TABLE_NAME, new String[] { fieldName });
if (c.moveToFirst()) {
result = c.getString(c.getColumnIndex(fieldName));
}
} catch (Exception e) {
throw e;
} finally {
dbMgr.close(c);
}
return result;
}
private long insert(String fieldName, String value) throws Exception {
long count = 0;
ContentValues cValue = new ContentValues();
cValue.put(fieldName, value);
count = dbMgr.insert(TABLE_NAME, cValue);
return count;
}
private int update(String fieldName, String value) throws Exception {
int count = 0;
ContentValues cValue = new ContentValues();
cValue.put(fieldName, value);
count = dbMgr.update(TABLE_NAME, cValue, null, null);
return count;
}
@Override
public synchronized boolean verifyPwd(String pwd) throws Exception {
boolean result = false;
String storedPwd = query(ENTER_PWD);
if (CryptoUtils.bcryptMatch(pwd, storedPwd)) {
result = true;
}
return result;
}
public synchronized String login(String pwd) throws Exception {
String result = "ok";
String storedPwd = query(ENTER_PWD);
if(StringUtils.isNotEmpty(storedPwd)) {
if (!CryptoUtils.bcryptMatch(pwd, storedPwd)) {
result = "锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷耄�";
}
} else {
String encryptedPwd = CryptoUtils.bcryptEncrypt(pwd);
if(insert(ENTER_PWD, encryptedPwd) == 0) {
result = "锟斤拷歉锟斤拷锟斤拷锟矫筹拷始锟斤拷锟斤拷失锟杰o拷锟斤拷锟斤拷锟皆o拷";
}
}
return result;
}
@Override
public synchronized String modifyPwd(String oldpwd, String newpwd)
throws Exception {
String result = "ok";
String storedPwd = query(ENTER_PWD);
if(StringUtils.isNotEmpty(storedPwd)) {
if (!CryptoUtils.bcryptMatch(oldpwd, storedPwd)) {
result = "锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷耄�";
} else {
String encryptedPwd = CryptoUtils.bcryptEncrypt(newpwd);
if (update(ENTER_PWD, encryptedPwd) == 0) {
result = "锟睫革拷失锟杰o拷锟斤拷锟斤拷锟皆o拷";
}
}
} else {
String encryptedPwd = CryptoUtils.bcryptEncrypt(newpwd);
if(insert(ENTER_PWD, encryptedPwd) == 0) {
result = "锟斤拷歉锟斤拷锟斤拷锟矫筹拷始锟斤拷锟斤拷失锟杰o拷锟斤拷锟斤拷锟皆o拷";
}
}
return result;
}
@Override
public String bindEmail(String email) throws Exception {
String result = "锟斤拷歉锟斤拷锟斤拷锟斤拷锟斤拷失锟杰o拷锟斤拷锟斤拷锟皆o拷";
String encryptedEmail = AppUtils.aesEncrypt(email);
if (update(EMAIL, encryptedEmail) > 0) {
result = "ok";
}
return result;
}
@Override
public String getEmail() throws Exception {
String result = "";
String storedEmail = query(EMAIL);
if(StringUtils.isNotEmpty(storedEmail)) {
result = AppUtils.aesDecrypt(storedEmail);
}
return result;
}
@Override
public int getVersion() {
int result = 0;
Cursor c = null;
try {
c = dbMgr.queryAll(TABLE_NAME, new String[] { VERSION });
if (c.moveToFirst()) {
result = c.getInt(c.getColumnIndex(VERSION));
}
} catch (Exception e) {
// throw e;
} finally {
dbMgr.close(c);
}
return result;
}
}
| [
"[email protected]"
] | |
e391a12411047f30fd0a041b1cad8864d0f72e16 | 5cc177adf90c85d2aed754d64021429c7f1338b7 | /main/src/net/finkn/inputspec/v050/IdLiteralsTest.java | 684dd3f054c7afb31dd87e99b6a4a33182f38469 | [
"MIT"
] | permissive | finkn/InPUTspec | f5bc3617509dc975205be25764c45b1e991bf078 | 16acbc0cee30f02d86896bf960875b49292cc769 | refs/heads/master | 2019-01-02T01:54:44.770374 | 2014-08-27T11:45:51 | 2014-08-27T11:45:51 | 17,589,374 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,041 | java | /*-- $Copyright (c) 2014 Christoffer Fink$
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package net.finkn.inputspec.v050;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import net.finkn.inputspec.tools.*;
import org.junit.Test;
import se.miun.itm.input.model.InPUTException;
import se.miun.itm.input.model.design.IDesignSpace;
/**
* Tests which IDs are legal in InPUT4j.
*
* @author Christoffer Fink
*/
public class IdLiteralsTest {
/**
* This test seems to indicate that almost any non-empty string is legal.
*/
@Test
public void almostAnyIdIsLegal() throws Throwable {
String[] ids = {
"hello",
"Hello",
"_hello",
"Hello_World",
"Hello World",
"Hello.World",
"hello123",
// Should really be illegal.
"123",
"123hello",
"! -+ 123 , hello. ~?", // Now this is just crazy. :p
" ",
"",
};
for (String id : ids) {
assertLegal(id);
}
}
/**
* An ID that only consists of a newline is invalid, probably due to XML
* parsing problems. A configuration with such an ID is legal, but the ID
* cannot subsequently be used.
*/
@Test(expected = AssertionError.class)
public void newlineIsInvalid() throws Throwable {
assertLegal("\n");
}
/**
* A {@code null} ID is illegal.
*/
@Test(expected = Exception.class)
public void nullIsAnIllegalId() throws Throwable {
assertLegal(null);
}
private void assertLegal(String id) throws InPUTException {
ParamCfg param = ParamCfg.builder().id(id).build();
IDesignSpace space = DesignSpaceCfg.builder()
.param(param)
.build()
.getDesignSpace();
assertThat(space.getSupportedParamIds(), hasItem(param.getId()));
// Checking that the ID is in the set of supported IDs should probably be
// enough. However, this demonstrates that InPUT4j can generate meaningful
// values for the parameter. This should quash any doubt.
Generator.fromDesignSpace(space, id).isVariable();
}
}
| [
"[email protected]"
] | |
0d4cdacfba0d51e4232f0229f2d156b48b69cf5a | 244cc1c39fd3b261e6b83ef6ed700da489e09f4f | /src/unidaplan/Searches.java | 283b6a4a42db4fe9d713d5a313202dc38cda897e | [
"MIT"
] | permissive | rissom/unidaplan | 79fe7518404070c8b1cfc601a4bbe793229916ec | 6358dff14f3132b5f9e8e03ec2b14e21b151dffa | refs/heads/master | 2020-06-19T09:59:56.075489 | 2019-11-16T08:08:09 | 2019-11-16T08:08:09 | 74,911,999 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,086 | java | package unidaplan;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class Searches extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Authentificator authentificator = new Authentificator();
int userID = authentificator.GetUserID(request,response);
ArrayList<String> stringkeys = new ArrayList<String>();
JSONArray searches = null;
response.setContentType("application/json");
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
DBconnection dBconn = new DBconnection();
JSONObject answer = new JSONObject();
try {
dBconn.startDB();
if (dBconn.isAdmin(userID)) {
PreparedStatement pStmt;
pStmt=dBconn.conn.prepareStatement(
"SELECT "
+"searches.id, "
+"searches.name, "
+"users.fullname AS owner, "
+"users.id AS ownerid, "
+"'w'::VARCHAR AS permission "
+"FROM searches "
+"JOIN users ON (users.id=searches.owner) ");
searches=dBconn.jsonArrayFromPreparedStmt(pStmt);
}else{
CallableStatement cs= dBconn.conn.prepareCall("{ ? = call getSearchesForUser(?)}");
cs.registerOutParameter(1, java.sql.Types.OTHER);
cs.setInt(2, userID);
cs.execute();
if (cs.getObject(1)!=null){
searches = new JSONArray(cs.getObject(1).toString());
}
cs.close();
}
// get the strings
if (searches != null){
for (int i=0; i<searches.length();i++) {
JSONObject tempObj=(JSONObject) searches.get(i);
stringkeys.add(Integer.toString(tempObj.getInt("name")));
}
}
} catch (SQLException e) {
System.err.println("Searches: Problems with SQL query");
e.printStackTrace();
response.setStatus(404);
} catch (JSONException e) {
System.err.println("Searches: JSON Problem");
response.setStatus(404);
} catch (Exception e2) {
System.err.println("Searches: Strange Problem");
e2.printStackTrace();
response.setStatus(404);
}
try {
answer.put("strings", dBconn.getStrings(stringkeys));
answer.put("searches", searches);
out.println(answer.toString());
dBconn.closeDB();
} catch (JSONException e) {
System.err.println("Searches: JSON Problem while getting Stringkeys");
response.setStatus(404);
} catch (Exception e2) {
System.err.println("Searches: Strange Problem while getting Stringkeys");
response.setStatus(404);
}
}} | [
"[email protected]"
] | |
ff410f99fd062709ddd7d98da3e9f6544546e619 | e7b78c9de72df66dc5829be61ebcf8841cfa4b77 | /app/src/main/java/app/example/com/sharetest/Show.java | 44cec2a96dfff0df57c6b8a1effef0be361001cf | [] | no_license | ddz-mark/ShareTest | dc2e9c41e3f3645150b31a33d0e181d195b49afe | e952980a5ffab80477abca8a617154bdaf7b0310 | refs/heads/master | 2021-01-16T23:22:02.644694 | 2016-08-13T15:09:20 | 2016-08-13T15:09:20 | 65,622,865 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 694 | java | package app.example.com.sharetest;
import android.app.Application;
import android.widget.Toast;
/**
* Created by Dudaizhong on 2016/7/11.
*/
public class Show
{
public static void showInfo(int id)
{
switch (id)
{
case 1:
Toast.makeText(MyApplication.getContext(),"QQ分享成功",Toast.LENGTH_SHORT).show();
break;
case 2:
Toast.makeText(MyApplication.getContext(),"取消分享",Toast.LENGTH_SHORT).show();
break;
case 3:
Toast.makeText(MyApplication.getContext(),"分享失败",Toast.LENGTH_SHORT).show();
break;
}
}
}
| [
"[email protected]"
] | |
25f2f0eaff5a8650ab8d906b024cd41b3f2a395d | 2ab10be17e530d08cd7a60782487490b1f8dfd52 | /app/src/androidTest/java/com/code19/appdemo/ExampleInstrumentationTest.java | f80450eef7d0346c87e52d7b95fb90fe4f65e9fc | [] | no_license | h4de5ing/AppDemo | c925c4b9bb0377961f39616fa96f46e3ecefbce8 | 655731783bb37adb5ed94298c71b956a558141e1 | refs/heads/master | 2020-05-21T16:25:09.063592 | 2017-01-17T10:04:54 | 2017-01-17T10:04:54 | 62,572,089 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 803 | java | package com.code19.appdemo;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@MediumTest
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentationTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.code19.appdemo", appContext.getPackageName());
}
} | [
"[email protected]"
] | |
1ce5fae46abf4c2d8ef356663605935a438bd262 | 5aea4ecde701b42436dd6bd8899a54ac8f773b9b | /src/main/java/nl/schutrup/cerina/abac/model/rule/MaximumNumberOfCustomersPerHourRule.java | be27834da4764b69a395b51d5e10e43dbfcc7c2f | [
"Apache-2.0"
] | permissive | Jarco89/Cerina | 960da17e2dbdd4f720c1a8ccc8e5889044c7f69d | 3a2a2c7517cab90103ac3eb754f39504bb50c414 | refs/heads/main | 2023-07-28T00:03:37.226327 | 2021-09-09T09:45:49 | 2021-09-09T09:45:49 | 404,663,673 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,445 | java | package nl.schutrup.cerina.abac.model.rule;
import nl.schutrup.cerina.abac.entities.Statistic;
import nl.schutrup.cerina.abac.model.action.Operation;
import nl.schutrup.cerina.abac.model.policy.PolicyResult;
import nl.schutrup.cerina.abac.model.resource.Resource;
import nl.schutrup.cerina.abac.model.subject.Subject;
import nl.schutrup.cerina.abac.repository.StatisticRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.stereotype.Component;
import java.time.Clock;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
@Component
public class MaximumNumberOfCustomersPerHourRule extends Rule {
private static final Logger LOGGER = LoggerFactory.getLogger(MaximumNumberOfCustomersPerHourRule.class);
@Autowired
private StandardEnvironment environment;
@Autowired
private StatisticRepository statisticRepository;
@Autowired
private Clock clock;
@Override
public PolicyResult evaluate(Subject subject, Resource resource, Operation operation) {
Integer maxVisitorsPerHour = environment.getProperty("max.visitors.per.hour", Integer.class);
LOGGER.info("Max. aantal bezoekers per uur = {}", maxVisitorsPerHour);
LocalDate localDate = getNow();
LocalDateTime start = localDate.atTime(LocalTime.now().getHour(),00,00);
LocalDateTime end = localDate.atTime(LocalTime.now().getHour(),59,59);
List<Statistic> statisticList = statisticRepository.findAllByVisitDateTimeBetween(start, end);
LOGGER.debug("Bezoekers tot dusver = {}",statisticList);
if (statisticList.size() >= maxVisitorsPerHour) {
LOGGER.info("Bezoekersaantal voor dit uur bereikt");
return PolicyResult.DENY;
} else {
LOGGER.info("Bezoekersaantal voor dit uur nog niet bereikt. Toegang toegestaan");
return PolicyResult.PERMIT;
}
}
public LocalDate getNow () {
return LocalDate.now(clock);
}
@Override
public String toString() {
return "MaximumNumberOfCustomersPerHourRule{" +
"environment=" + environment +
", statisticRepository=" + statisticRepository +
", clock=" + clock +
'}';
}
}
| [
"[email protected]"
] | |
c732b10f901def9c40b606cd3f9aa5a739c44631 | 07e1bfb281a00b7a55519cd98c2520c3dc04e27d | /app/src/main/java/com/example/wemeet/ShowVirusActivity.java | afca96a6d148f1c5cc588cdff3e1964d90f4a6b5 | [] | no_license | l906703447/wemeet-android | 125535448486394e960dbafcee3d297423914df5 | 9aeb749c34e54da0903086b43dba5240ae856c8e | refs/heads/master | 2021-04-01T08:11:46.160245 | 2020-05-13T09:44:41 | 2020-05-13T09:44:41 | 248,172,000 | 0 | 0 | null | 2020-03-18T08:05:17 | 2020-03-18T08:05:17 | null | UTF-8 | Java | false | false | 3,139 | java | package com.example.wemeet;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.wemeet.pojo.Bug;
import org.w3c.dom.Text;
import androidx.fragment.app.DialogFragment;
public class ShowVirusActivity extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View view;
view = inflater.inflate(R.layout.activity_bug_content,container,false);
Bundle bundle = getArguments();
assert bundle != null;
Bug bug = (Bug) bundle.getSerializable("bug");
assert bug != null;
if (bug.getBugProperty().getBugContent().getType() == 4) {
switch (bug.getVirusPoint().getStatus()){
case 1:
((TextView)view.findViewById(R.id.level)).setText("症状虫子");
break;
case 2:
((TextView)view.findViewById(R.id.level)).setText("疑似虫子");
break;
case 3:
((TextView)view.findViewById(R.id.level)).setText("确诊虫子");
break;
}
((TextView)view.findViewById(R.id.symptoms)).append(":"+bug.getVirusPoint().getSymptoms());
if(bug.getVirusPoint().getDiseaseStartTime()!=null){
((TextView)view.findViewById(R.id.symptoms_start_time)).append(":"+bug.getVirusPoint().getDiseaseStartTime().toString());
}
else{
((TextView)view.findViewById(R.id.symptoms_start_time)).append(":无");
}
((TextView)view.findViewById(R.id.note)).append(":"+bug.getVirusPoint().getDescription());
}
ImageView close = (ImageView) view.findViewById(R.id.close_button);
close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
Button changeLevel = (Button)view.findViewById(R.id.change_level);
changeLevel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
bundle.putSerializable("virusPoint",bug.getVirusPoint());
ChangeLevelActivity changeLevelActivity = new ChangeLevelActivity();
changeLevelActivity.setArguments(bundle);
changeLevelActivity.show(getFragmentManager(),"changeLevel");
dismiss();
}
});
return view;
}
@Override
public void onResume() {
ViewGroup.LayoutParams params = getDialog().getWindow().getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
getDialog().getWindow().setAttributes((WindowManager.LayoutParams) params);
super.onResume();
}
}
| [
"[email protected]"
] | |
a583ed93d8d91e749ebdaaca8f7e2d32ccbe1f22 | 3b099d474cd85050cb30c7f949896b452bf979c7 | /bigdata_parent/bigdata_netty/src/main/java/com/bigdata/bdp/netty/quanweizhinan/ch10/HttpFileServerHandler.java | cf45bf5c51e30f7a28a5c5cdb74d55a57050f916 | [] | no_license | 314649558/learing | 299d0d53fa3b21071bf39a9bbcd88da0c6fd5974 | f433ca50c924a8709d7c3eb3c5df62c3d7d6727b | refs/heads/master | 2022-10-26T00:55:20.023147 | 2021-04-03T10:34:36 | 2021-04-03T10:34:36 | 130,447,679 | 2 | 0 | null | 2022-10-12T19:52:16 | 2018-04-21T06:45:07 | Java | UTF-8 | Java | false | false | 7,804 | java | package com.bigdata.bdp.netty.quanweizhinan.ch10;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.handler.codec.http.*;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.stream.ChunkedFile;
import io.netty.util.CharsetUtil;
import org.apache.commons.lang.StringUtils;
import javax.activation.MimetypesFileTypeMap;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.regex.Pattern;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONNECTION;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
import static io.netty.handler.codec.http.HttpHeaders.Names.LOCATION;
import static io.netty.handler.codec.http.HttpResponseStatus.*;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
/**
* Created by Administrator on 2018/11/10.
*/
public class HttpFileServerHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
private final String url;
private static final Pattern INSECURE_URI = Pattern.compile(".*[<>&\"].*");
private static final Pattern ALLOWED_FILE_NAME = Pattern
.compile("[A-Za-z0-9][-_A-Za-z0-9\\.]*");
public HttpFileServerHandler(String url) {
this.url = url;
}
@Override
protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
if(!request.getDecoderResult().isSuccess()){ //解码失败
sendError(ctx,BAD_REQUEST);
return;
}
if(request.getMethod() != HttpMethod.GET){ //如果请求方法不是GET方法
sendError(ctx, METHOD_NOT_ALLOWED);
return;
}
final String uri=request.getUri();
final String path=sanitizeUrl(uri);
if(StringUtils.isEmpty(path)){
sendError(ctx, FORBIDDEN);
return;
}
File file = new File(path);
if(file.isHidden()||!file.exists()){
sendError(ctx,NOT_FOUND);
return;
}
if(file.isDirectory()){
if(uri.endsWith("/")){
sendListing(ctx,file);
}else{
sendRedirect(ctx,uri+'/');
}
return;
}
if(!file.isFile()){
sendError(ctx,FORBIDDEN);
return;
}
//对文件进行更细粒度的操作
RandomAccessFile randomAccessFile=null;
try{
randomAccessFile=new RandomAccessFile(file,"r");//以只读的方式打开文件
}catch (FileNotFoundException fnfe){
sendError(ctx,NOT_FOUND);
return;
}
long fileLength=randomAccessFile.length();
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
HttpHeaders.setContentLength(response,fileLength);
setContentTypeHeader(response,file);
//保持连接
if(HttpHeaders.isKeepAlive(request)){
response.headers().set(CONNECTION,HttpHeaders.Values.KEEP_ALIVE);
}
ctx.write(response);
ChannelFuture sendFileFuture;
sendFileFuture=ctx.write(new ChunkedFile(randomAccessFile,0,fileLength,8192),ctx.newProgressivePromise());
sendFileFuture.addListener(new ChannelProgressiveFutureListener() {
@Override
public void operationProgressed(ChannelProgressiveFuture future, long progress, long total) throws Exception {
if(total < 0){
System.err.println("Transfer progress: " + progress);
}else{
System.err.println("Transfer progress: " + progress + " / "
+ total);
}
}
@Override
public void operationComplete(ChannelProgressiveFuture future) throws Exception {
System.out.println("Transfer complete.");
}
});
ChannelFuture lastContentFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
if(!HttpHeaders.isKeepAlive(request)){
lastContentFuture.addListener(ChannelFutureListener.CLOSE);
}
}
/**
* 获取uri地址
* @param uri
* @return
*/
private String sanitizeUrl(String uri){
try{
uri= URLDecoder.decode(uri,"UTF-8");
}catch (UnsupportedEncodingException e){
try{
uri = URLDecoder.decode(uri, "ISO-8859-1");
}catch (UnsupportedEncodingException e1){
throw new Error();
}
}
if(!uri.startsWith(url)){
return null;
}
if(!uri.startsWith("/")){
return null;
}
uri = uri.replace("/", File.separator);
if(uri.contains(File.separator+'.')
||uri.contains('.'+File.separator)
||uri.startsWith(".")
||uri.endsWith(".")
||INSECURE_URI.matcher(uri).matches()){
return null;
}
return System.getProperty("user.dir") + File.separator + uri;
}
/**
* 对文件进行监听
* @param ctx
* @param dir
*/
private static void sendListing(ChannelHandlerContext ctx,File dir){
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK);
response.headers().set(CONTENT_TYPE, "text/html; charset=UTF-8");
StringBuilder buf = new StringBuilder();
String dirPath = dir.getPath();
buf.append("<!DOCTYPE html>\r\n");
buf.append("<html><head><title>");
buf.append(dirPath);
buf.append(" 目录:");
buf.append("</title></head><body>\r\n");
buf.append("<h3>");
buf.append(dirPath).append(" 目录:");
buf.append("</h3>\r\n");
buf.append("<ul>");
buf.append("<li>链接:<a href=\"../\">..</a></li>\r\n");
for (File f : dir.listFiles()) {
if (f.isHidden() || !f.canRead()) {
continue;
}
String name = f.getName();
if (!ALLOWED_FILE_NAME.matcher(name).matches()) {
continue;
}
buf.append("<li>链接:<a href=\"");
buf.append(name);
buf.append("\">");
buf.append(name);
buf.append("</a></li>\r\n");
}
buf.append("</ul></body></html>\r\n");
ByteBuf buffer = Unpooled.copiedBuffer(buf, CharsetUtil.UTF_8);
response.content().writeBytes(buffer);
buffer.release();
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
private static void sendRedirect(ChannelHandlerContext ctx, String newUri) {
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, FOUND);
response.headers().set(LOCATION, newUri);
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
private static void sendError(ChannelHandlerContext ctx, HttpResponseStatus status){
FullHttpResponse response=new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
status,
Unpooled.copiedBuffer("Failure:"+status.toString()+"\r\n",CharsetUtil.UTF_8));
response.headers().set(HttpHeaders.Names.CONTENT_TYPE,"text/plain; charset=UTF-8");
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
private static void setContentTypeHeader(HttpResponse response, File file) {
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
response.headers().set(CONTENT_TYPE,
mimeTypesMap.getContentType(file.getPath()));
}
}
| [
"[email protected]"
] | |
7cd324ebd5ca24079d4088ff95493f3639492785 | 819f2d5f5feec940d34081f58fd19582bf263b25 | /src/main/java/org/example/ClassicalMusic.java | 7e3f7984c06051f489d416d5ef1755ea75d949ea | [] | no_license | djonn79/firstprog | 52ab19a5fcd5aa03f2e1413944ccc79421b549b9 | 0b4cb20126f772a01841c72ab0134c2558d33219 | refs/heads/master | 2023-07-06T17:38:51.873119 | 2021-08-01T23:37:35 | 2021-08-01T23:37:35 | 391,617,784 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 147 | java | package org.example;
public class ClassicalMusic implements Music{
@Override
public String getSong() {
return "Rhapsody";
}
}
| [
"[email protected]"
] | |
f9ad0762538a1421c02f0daf444af496fabbd383 | 5009c198746c826917ba309ce67af4181e00ec10 | /Module2/src/case_study/model/Customer.java | 9ccc70c0366516e495f967496dee225c7d0c70a1 | [] | no_license | BBOYY217/C07212G1_NguyenVanCong_Module2 | 9809fa2e90b3bdd770ff2639ad0745a265c859c7 | a64429cb82e9b9f85246357b4268c9efae494908 | refs/heads/main | 2023-07-18T18:01:59.500729 | 2021-09-15T10:46:14 | 2021-09-15T10:46:14 | 396,563,511 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 995 | java | package case_study.model;
public class Customer extends Person{
private String customerType;
private String address;
public Customer() {
}
public Customer(int idCard, String name, String dayOfBirth, String gender, String phoneNumber, String email, String customerType, String address) {
super(idCard, name, dayOfBirth, gender, phoneNumber, email);
this.customerType = customerType;
this.address = address;
}
public String getCustomerType() {
return customerType;
}
public void setCustomerType(String customerType) {
this.customerType = customerType;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Override
public String toString() {
return "Customer{" +
"customerType='" + customerType + '\'' +
", address='" + address + '\'' +
'}';
}
}
| [
"[email protected]"
] | |
74321aa043936b5b901bc683fd4a7b4afc5b7cc8 | a58e9222ad660bfd13530b8194271af0144bc6de | /chap10/src/example/chap10_02_03/NumberFormatException.java | 1e841e0f3a8bfd325c25d2b57c97dd714d95d56c | [] | no_license | testkkj/Java-L | 4a8051c57d07107441a7c2c7b53dad8bea47c3f7 | bd65d120baad3e2111ff1c9d0c1a6bb8c57ad353 | refs/heads/master | 2020-05-13T22:32:54.889119 | 2019-04-21T06:01:59 | 2019-04-21T06:01:59 | 181,668,395 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 393 | java | package example.chap10_02_03;
public class NumberFormatException {
public static void main(String[] args) {
String data1 = "100";
String data2 = "a100";
int value1 = Integer.parseInt(data1);
int value2 = Integer.parseInt(data2); //NumberFormatException ¹ß»ý
int result = value1 + value2;
System.out.println(data1 + "+" + data2 + "=" + result);
}
}
| [
"[email protected]"
] | |
ee3abbe770ad3ee77e87c8efa1e35778c4973bc8 | 1033b25f9a0aa158bb3d554fd1bfc3d87d22338e | /src/main/java/com/sysware/cloud/security/config/WxAuthenticationEntryPoint.java | aa30cb910d8b9b57f54e71dc47fce059a9bc8f87 | [] | no_license | caoruitan/injury | 8721b2aa47f3da648c76b406eb2dc945c58c111f | e281c1c87d42692f5420966556d80eafa401c3ba | refs/heads/master | 2021-05-12T14:35:43.482132 | 2018-01-11T05:41:38 | 2018-01-11T05:41:38 | 116,960,792 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,002 | java | package com.sysware.cloud.security.config;
import com.sysware.cloud.utils.wechat.WxConstants;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
/**
* security 没有权限处理端点
* 前后台分离项目没有登录页面,通过response返回没有权限或者没有登录的状态。
* 这个抛出的异常,全局异常处理不了。
*
*/
@Component
public class WxAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable {
private static final long serialVersionUID = -8970718410437077606L;
@Override
public void commence(HttpServletRequest request,
HttpServletResponse response,
AuthenticationException authException) throws IOException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
StringBuffer url = httpRequest.getRequestURL();
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if(authentication!=null){
Object obj = authentication.getPrincipal();
}
if (httpRequest.getQueryString() != null) {
url.append('?');
url.append(httpRequest.getQueryString());
}
httpResponse.sendRedirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid="+ WxConstants.CORP_ID+"&redirect_uri=" + url.toString() + "&response_type=code&scope=snsapi_base&state=weioa#wechat_redirect");
}
}
| [
"[email protected]"
] | |
bcbf1db6bff584fa74ed2b27555bfce5168ec212 | b671f7dca26bc44af0fde6c9d98a4e16a4b71c7f | /app/src/main/java/com/xitij/tiktuk/Fragment/RelateFrags/OnBackPressListener.java | e383503b55acae192c081ff39f8d7da5ec71ef65 | [] | no_license | PasumarthiNaveen/Funmate-master | 850a6010b4aee0a97e10054dec3d8aab5000d471 | 17df07591fae0a37fb2ff047c5eccaebbc3dbfd5 | refs/heads/master | 2022-07-05T08:29:15.517092 | 2020-05-14T11:26:23 | 2020-05-14T11:26:23 | 264,244,238 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 118 | java | package com.xitij.tiktuk.Fragment.RelateFrags;
public interface OnBackPressListener {
boolean onBackPressed();
}
| [
"[email protected]"
] | |
c45d57ba1245529d61ed0985f89613d67d46f130 | 9034275583204f5e3945dc294c81c38f768811bd | /src/main/java/com/myspring/myspring/entity/Test.java | b583f62c3928c41bcdb8594ed6598b93074b4f63 | [] | no_license | jiahezhangqian/myspring | c4bdd6da3c441efa78bd274b9f96743299606804 | 0e95ca20ea3e35e138494a29d7f41f842e1c8b5c | refs/heads/master | 2022-06-25T15:58:35.831803 | 2020-02-23T06:35:51 | 2020-02-23T06:35:51 | 242,468,474 | 0 | 0 | null | 2022-06-17T02:53:50 | 2020-02-23T06:29:01 | Java | UTF-8 | Java | false | false | 134 | java | package com.myspring.myspring.entity;
import lombok.Data;
@Data
public class Test {
private Long id;
private String name;
}
| [
"[email protected]"
] | |
feff184f4fba883ff5e9eb77485cf793a1748d96 | a12debaf21e2c913df508ef912eabff2da5362b8 | /app/src/test/java/com/harmittaa/travisexample/ExampleUnitTest.java | 76deccd8df73e954c6f03bdab309c70c5190fe39 | [] | no_license | atishay-js/demo-for-travis | 32ba07f941be6f340695468da28385f2090612e7 | dab10ea480cd137580a4f59d9e1e83b24092c950 | refs/heads/master | 2020-05-05T02:29:38.134909 | 2019-04-05T07:55:32 | 2019-04-05T07:55:32 | 179,639,948 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 405 | java | package com.harmittaa.travisexample;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
a2db07a89e6480b1a323d0d6b5be05d469c44de4 | 89d70f2b45c4deb4c2b12c8637e19649f83fea67 | /app/src/androidTest/java/com/doudou/cn/testthreadmodel/TestBlockingDeque.java | 16881459ba4f92c598f53529894bae1b0822d526 | [] | no_license | jinlianglovehi/TestThreadModel | 2e927cf129ede0160561e81106bb0c3cfe309bb8 | 199cfac42f3ed01de6ae38f859163c2ae2232952 | refs/heads/master | 2022-10-23T06:21:44.917134 | 2015-12-08T05:45:18 | 2015-12-08T05:45:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,876 | java | package com.doudou.cn.testthreadmodel;
import android.util.Log;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
/**
* Created by jinliang on 15/12/8.
*/
public class TestBlockingDeque extends BaseTestCase{
private static final String TAG = TestBlockingDeque.class.getSimpleName();
@Override
protected void testSetUp() {
}
public void testDemo() throws InterruptedException {
// 双端队列、栈、队列
BlockingDeque<Integer> bDeque = new LinkedBlockingDeque<Integer>(20);
for (int i = 0; i < 20; i++) {
// 将指定元素添加到此阻塞栈中,如果没有可用空间,将一直等待(如果有必要)。
try {
// 放在队列的头部
bDeque.putFirst(i);
// 放在队列的底部
// bDeque.putLast(i);
}
catch (InterruptedException e) {
e.printStackTrace();
}
Log.i(TAG, "testDemo " + "向阻塞栈中添加了元素:" + i);
}
// Log.i(TAG, "testDemo peek:" + bDeque.peek());// 头部的查询元素
// Log.i(TAG, "testDemo task:"+ bDeque.take());// 头部拿出一个元素
// Log.i(TAG, "testDemo getFirst:" + bDeque.getFirst()); //只是获取头部的元素
// Log.i(TAG, "testDemo getLast:" + bDeque.getLast());// 获取队列foot 元素
for(int i=0; i<20 ;i++){
Log.i(TAG, "testDemo peek:" + bDeque.poll());// 只是显示第一个元素 ,但是队列中不会减少。
Log.i(TAG, "testDemo size:" + bDeque.size());
}
Log.i(TAG, "testDemo finishSize:" + bDeque.size());
Log.i(TAG, "testDemo "+"程序到此运行结束,即将退出----");
}
@Override
protected void testTearDown() {
}
}
| [
"[email protected]"
] | |
778c763124c91070b4f94cf34fe9c758684503d9 | 2bc2eadc9b0f70d6d1286ef474902466988a880f | /tags/mule-1.3-rc4/mule/src/main/java/org/mule/transaction/XaTransactionFactory.java | dabff42a09a8668a5e4da3df58493ad1f91a4d1a | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-symphonysoft"
] | permissive | OrgSmells/codehaus-mule-git | 085434a4b7781a5def2b9b4e37396081eaeba394 | f8584627c7acb13efdf3276396015439ea6a0721 | refs/heads/master | 2022-12-24T07:33:30.190368 | 2020-02-27T19:10:29 | 2020-02-27T19:10:29 | 243,593,543 | 0 | 0 | null | 2022-12-15T23:30:00 | 2020-02-27T18:56:48 | null | UTF-8 | Java | false | false | 1,690 | java | /*
* $Id$
* ------------------------------------------------------------------------------------------------------
*
* Copyright (c) SymphonySoft Limited. All rights reserved. http://www.symphonysoft.com
*
* The software in this package is published under the terms of the BSD style
* license a copy of which has been included with this distribution in the
* LICENSE.txt file.
*
*/
package org.mule.transaction;
import org.mule.config.i18n.Message;
import org.mule.config.i18n.Messages;
import org.mule.umo.TransactionException;
import org.mule.umo.UMOTransaction;
import org.mule.umo.UMOTransactionFactory;
/**
* <code>XaTransactionFactory</code> Is used to create/retreive a Transaction
* from a transaction manager configured on the MuleManager.
*
* @author <a href="mailto:[email protected]">Ross Mason</a>
* @author Guillaume Nodet
* @version $Revision$
*/
public class XaTransactionFactory implements UMOTransactionFactory
{
public XaTransactionFactory()
{
super();
}
public UMOTransaction beginTransaction() throws TransactionException
{
try {
XaTransaction xat = new XaTransaction();
xat.begin();
return xat;
} catch (Exception e) {
throw new TransactionException(new Message(Messages.TX_CANT_START_X_TRANSACTION, "XA"), e);
}
}
/**
* Determines whether this transaction factory creates transactions that are
* really transacted or if they are being used to simulate batch actions,
* such as using Jms Client Acknowledge.
*
* @return
*/
public boolean isTransacted()
{
return true;
}
}
| [
"rossmason@bf997673-6b11-0410-b953-e057580c5b09"
] | rossmason@bf997673-6b11-0410-b953-e057580c5b09 |
e5ebeea42135b07cad52d4f0e2ec086cf7e24e39 | 89a92343eb3f25dd52d3df6070992a09b8694974 | /src/main/java/view/VIEWS.java | 7ba7f6f02fc25eea51cee9693ed3e8ccf17b1d01 | [] | no_license | WilliamC07/Planner | afbf4cc3edf66bc9ce4932a7b9bf6ea75098dc98 | 264b9cf9a266ca601abe19cd0a08d8a393efe683 | refs/heads/master | 2020-03-25T13:08:32.342945 | 2019-02-19T00:28:27 | 2019-02-19T00:28:27 | 143,810,442 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 604 | java | package view;
import helper.Colors;
import javafx.scene.paint.Color;
/**
* Names of views that can be shown
*/
public enum VIEWS {
DASHBOARD(Colors.LIGHT_GRAY),
CALENDAR(Colors.ORANGE),
MONEY(Colors.LIGHT_GREEN),
QUICK(Colors.LIGHT_BLUE),
ENTERTAINMENT(Colors.LIGHT_RED);
public final Color color;
VIEWS(Color color) {
this.color = color;
}
@Override
public String toString() {
switch (this) {
case MONEY:
return "MONEY MANAGEMENT";
default:
return super.toString();
}
}
}
| [
"[email protected]"
] | |
28685390a9c2aa16f8382ebff91c01f8e33862c8 | 3d876b15f7f553aadb518819bb15f7b9e23214f6 | /src/main/java/pantheist/api/generic/model/ApiGenericModelFactory.java | 337cfca1ecc823bd1b60746b5a1112fd3ae43332 | [] | no_license | edkins/pantheist-old | 1f367b2aab449158215a4f45b257ecf421ce8134 | 8afef3b49fcf0036c4ee10f206756c278d1c04b1 | refs/heads/master | 2021-01-11T11:55:17.534109 | 2016-12-22T06:55:09 | 2016-12-22T06:55:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 614 | java | package pantheist.api.generic.model;
import java.util.Collection;
import java.util.List;
import com.google.inject.assistedinject.Assisted;
public interface ApiGenericModelFactory
{
ListResourceResponse listResourceResponse(List<ResourceMetadata> resources);
ResourceMetadata resourceMetadata(@Assisted("path") String path,
@Assisted("id") String id,
@Assisted("name") String name);
ListComponentResponse listComponentResponse(Collection<ListedComponent> components);
ListedComponent listedComponent(@Assisted("path") String path,
@Assisted("id") String id,
@Assisted("data") Object data);
}
| [
"[email protected]"
] | |
63cea653b7cf1939ce67ab2e58f2fd45ddeaad1b | 9ed6cdac577174acc0fab65f57b9088348cddf42 | /MobilePhoneChallenge/src/com/company/Main.java | 23113d7868c9dcf27529e29937a2763ad88e59d2 | [] | no_license | vitonman/IdeaProjects | e818aebea1e704a62990b1c9f0db66472990a5ad | ff177537b5e39e1d658250d7ce1e40da8197e38f | refs/heads/master | 2020-04-08T05:33:07.669274 | 2019-11-01T01:18:17 | 2019-11-01T01:18:17 | 159,065,071 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 809 | java | package com.company;
import java.util.Scanner;
public class Main {
private static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("mobile phona");
int choice = 0;
boolean off = false;
while (!off){
System.out.println("Menu:1<->2:OFF ");
choice = scanner.nextInt();
scanner.nextLine();
switch (choice){
case 1:
mobilePhone.mobileMenu();
break;
case 2:
off = true;
printOffmessage();
break;
}
}
}
public static void printOffmessage(){
System.out.println("The mobile phone turned off, bye");
}
}
| [
"[email protected]"
] | |
c115c1abe9efb8d42e5fc041705bbaf3b28da1a3 | 657608f25d1655197b5fd374cecd52e73dd2cd8b | /Season 1 LeetCode/leetcode/medium/200.number-of-islands.java | c74cf5a6055fc84a23afe89cb93df3510c67dc75 | [] | no_license | DavidHewWing/daily_challenges | f1e1e63b7ff882d55b6c818a0404c1781258706e | 69d20b5506ddef66b5a4b45dea2ec033e105cbd3 | refs/heads/master | 2023-07-23T08:08:19.904877 | 2023-07-18T15:48:22 | 2023-07-18T15:48:22 | 210,372,690 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,563 | java | /*
* @lc app=leetcode id=200 lang=java
*
* [200] Number of Islands
*/
// @lc code=start
class Solution {
public int numIslands(char[][] grid) {
if(grid.length == 0 || grid[0].length == 0) {
return 0;
}
int m = grid.length;
int n = grid[0].length;
boolean[][] visited = new boolean[m][n];
Queue<int[]> queue = new LinkedList<>();
int count = 0;
for(int i = 0; i < m; i++) {
for(int j = 0; j < n; j++) {
if(grid[i][j] == '1' && !visited[i][j]) {
visited[i][j] = true;
queue.offer(new int[]{i,j});
explore(queue, grid, visited);
count++;
}
}
}
return count;
}
private static int[][] dirs = {{0,1}, {0, -1}, {1,0}, {-1,0}};
private static void explore(Queue<int[]> queue, char[][] grid, boolean[][] visited) {
int m = grid.length;
int n = grid[0].length;
while(!queue.isEmpty()) {
int[] temp = queue.poll();
for(int[] dir : dirs) {
int tempx = dir[0] + temp[0];
int tempy = dir[1] + temp[1];
if(tempx < 0 || tempx >= m || tempy < 0 || tempy >= n || visited[tempx][tempy] || grid[tempx][tempy] == '0')
continue;
visited[tempx][tempy] = true;
queue.offer(new int[]{tempx, tempy});
}
}
}
}
// @lc code=end
| [
"[email protected]"
] | |
9973d828766b36f87f3f3885220b9bc63689be36 | 365267d7941f76c97fac8af31a788d8c0fb2d384 | /src/main/java/net/minecraft/client/model/ModelDynamite.java | 60ec2f852dd7a96465033d80a469e3e67f7cbeca | [
"MIT"
] | permissive | potomy/client | 26d8c31657485f216639efd13b2fdda67570d9b5 | c01d23eb05ed83abb4fee00f9bf603b6bc3e2e27 | refs/heads/master | 2021-06-21T16:02:26.920860 | 2017-08-02T02:03:49 | 2017-08-02T02:03:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,003 | java | package net.minecraft.client.model;
import net.minecraft.entity.Entity;
/**
* Created by David on 14/12/2016.
*/
public class ModelDynamite extends ModelBase
{
private ModelRenderer block;
private ModelRenderer block1;
public ModelDynamite()
{
this( 0.0f );
}
public ModelDynamite( float par1 )
{
block = new ModelRenderer( this, 0, 0 );
block.setTextureSize( 16, 16 );
block.addBox( -1F, -5F, -1F, 2, 10, 2);
block.setRotationPoint( 0F, 24F, 0F );
block1 = new ModelRenderer( this, 6, 0 );
block1.setTextureSize( 16, 16 );
block1.addBox( -0.5F, -0.5F, -0.5F, 1, 1, 1);
block1.setRotationPoint( 0F, 18.5F, 0F );
}
public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
{
block.rotateAngleX = 0F;
block.rotateAngleY = 0F;
block.rotateAngleZ = 0F;
block.renderWithRotation(par7);
block1.rotateAngleX = 0F;
block1.rotateAngleY = 0F;
block1.rotateAngleZ = 0F;
block1.renderWithRotation(par7);
}
}
| [
"[email protected]"
] | |
c95a1410305ad7af0aa2996dd775ee79cabba441 | a34ac0c0b15e26305bcd98de2c4be68347d2f3ca | /PDFandImage/src/PdfAndImg.java | 23a7519b44a741dba0511144c64ed2feca98d800 | [
"Apache-2.0"
] | permissive | Gitko97/Lecture-Assistant | b01a2d98b07597672faceb8d10b9c6b64f9a2563 | 87bce6f17b95c9ab4379bb2e996f814ff458ac31 | refs/heads/master | 2022-11-12T00:55:38.028680 | 2020-06-26T10:42:11 | 2020-06-26T10:44:04 | 260,855,314 | 0 | 8 | Apache-2.0 | 2020-06-26T10:44:06 | 2020-05-03T08:00:46 | Java | UTF-8 | Java | false | false | 1,923 | java | package src;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory;
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
import org.apache.pdfbox.rendering.ImageType;
import org.apache.pdfbox.rendering.PDFRenderer;
//This Class Need Apache's PDFBox library
public class PdfAndImg{
//Save the image received as parameter to filepath as pdf file
public boolean IMGtoPDF(ArrayList<BufferedImage> imgs, String filePath) {
PDDocument document = new PDDocument(); //Make New PDF document
try {
for(BufferedImage img : imgs) {
PDPage page = new PDPage(new PDRectangle(img.getWidth(), img.getHeight())); //Make Page with image
//Add page to document
document.addPage(page);
PDImageXObject pdImage = JPEGFactory.createFromImage(document, img);
PDPageContentStream contentStream = new PDPageContentStream(document, page);
contentStream.drawImage(pdImage, 0, 0, img.getWidth(), img.getHeight());
contentStream.close();
}
document.save(filePath); //document save
return true;
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
//Read PDF and return PDF's pages to images
public ArrayList<BufferedImage> PdfToImg(String filePath) throws IOException {
ArrayList<BufferedImage> imgs = new ArrayList<>();
File readFile = new File(filePath);
PDDocument document = PDDocument.load(readFile);
int pageCount = document.getNumberOfPages();
PDFRenderer pdfRenderer = new PDFRenderer(document);
for(int i=0; i<pageCount; i++) {
imgs.add(pdfRenderer.renderImageWithDPI(i, 100, ImageType.RGB));
}
document.close();
return imgs;
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.