blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
list | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
list | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3cc945b8139eb620171b6bc2b4fd0c1f5550ee42 | 8,735,963,542,171 | 8f9bb6763d4313851d071f666bb5dd3e287d0d45 | /conciliasolucoes-services/conciliasolucoes-services-dominio/src/main/java/br/com/conciliasolucoes/service/impl/SistemasServiceImpl.java | 168badcf4d8c452cfb7956faf7239c4d91174294 | []
| no_license | linocodes/conciliasolucoes | https://github.com/linocodes/conciliasolucoes | 8c9231fe3061b629b44a7e5718edb60d99159d30 | a156b0188abf8941ee4c688a07c089137c90c1cc | refs/heads/master | 2018-12-22T19:58:54.949000 | 2018-10-03T09:21:25 | 2018-10-03T09:21:25 | 149,699,530 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.conciliasolucoes.service.impl;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import br.com.conciliasolucoes.model.Sistemas;
import br.com.conciliasolucoes.repository.SistemasRepository;
import br.com.conciliasolucoes.service.SistemasService;
@Service
@Transactional
public class SistemasServiceImpl implements SistemasService {
private SistemasRepository repository;
@Autowired
public SistemasServiceImpl(SistemasRepository repository) {
this.repository = repository;
}
@Override
public Page<Sistemas> listAllByPage(Pageable pageable) {
return repository.findAll(pageable);
}
}
| UTF-8 | Java | 812 | java | SistemasServiceImpl.java | Java | []
| null | []
| package br.com.conciliasolucoes.service.impl;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import br.com.conciliasolucoes.model.Sistemas;
import br.com.conciliasolucoes.repository.SistemasRepository;
import br.com.conciliasolucoes.service.SistemasService;
@Service
@Transactional
public class SistemasServiceImpl implements SistemasService {
private SistemasRepository repository;
@Autowired
public SistemasServiceImpl(SistemasRepository repository) {
this.repository = repository;
}
@Override
public Page<Sistemas> listAllByPage(Pageable pageable) {
return repository.findAll(pageable);
}
}
| 812 | 0.832512 | 0.832512 | 30 | 26.066668 | 23.954031 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.766667 | false | false | 2 |
831587971138778d0b443144dfa7d76ca2cc23dd | 14,474,039,790,705 | 660795e76b4dab28ea8978f9c269c6621cbc9bda | /src/test/java/homework_1/tests/SubtractTest.java | e52ab371c7ad5d7e040ee160a4b0754d20fc5663 | []
| no_license | BraveLittleTapok/DinaraShabanova | https://github.com/BraveLittleTapok/DinaraShabanova | bc9d3dd193adb4c39f7ccd4ae796f3fdc8b53ff3 | abcc01b9556a10ada04b875bbc08783a5e639c13 | refs/heads/master | 2021-06-25T00:28:11.805000 | 2019-12-10T11:23:21 | 2019-12-10T11:23:21 | 221,260,671 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package homework_1.tests;
import homework_1.dataproviders.SubtractDataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
/**
* Created by dinar on 14.11.2019.
*/
public class SubtractTest extends AbstractBaseTest {
@Test(dataProvider = "SubtractDataProviderUnderMax",
dataProviderClass = SubtractDataProvider.class)
public void subtractTestNumberUnderMaxValue(long a, long b, long expected) {
long actual = calculator.sub(a, b);
assertEquals(actual, expected);
}
@Test(dataProvider = "SubtractDataProviderOverMax",
dataProviderClass = SubtractDataProvider.class)
public void subtractTestNumberOverMaxValue(long a, long b, long expected) {
long actual = calculator.sub(a, b);
assertEquals(actual, expected);
}
}
| UTF-8 | Java | 840 | java | SubtractTest.java | Java | [
{
"context": "org.testng.Assert.assertEquals;\n\n/**\n * Created by dinar on 14.11.2019.\n */\npublic class SubtractTest exte",
"end": 188,
"score": 0.9993668794631958,
"start": 183,
"tag": "USERNAME",
"value": "dinar"
}
]
| null | []
| package homework_1.tests;
import homework_1.dataproviders.SubtractDataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
/**
* Created by dinar on 14.11.2019.
*/
public class SubtractTest extends AbstractBaseTest {
@Test(dataProvider = "SubtractDataProviderUnderMax",
dataProviderClass = SubtractDataProvider.class)
public void subtractTestNumberUnderMaxValue(long a, long b, long expected) {
long actual = calculator.sub(a, b);
assertEquals(actual, expected);
}
@Test(dataProvider = "SubtractDataProviderOverMax",
dataProviderClass = SubtractDataProvider.class)
public void subtractTestNumberOverMaxValue(long a, long b, long expected) {
long actual = calculator.sub(a, b);
assertEquals(actual, expected);
}
}
| 840 | 0.721429 | 0.709524 | 27 | 30.111111 | 26.272551 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 2 |
504a007d24e4f07f404c64ba4fe6d0319556dd41 | 5,583,457,556,574 | 9a927a01aeb869b054b1160c8e03290b4e8b1a88 | /src/main/java/dp/pages/AnyPage.java | adcc9f929a5ae27a0a4b73c2fc0c5a9136894df8 | []
| no_license | order12a/SelenideSampleTest | https://github.com/order12a/SelenideSampleTest | 4f9bcc22a244b037871db2a4993410d6dc96166b | 40d5fa5e9b7ebca668ad02f1488c360fb197b488 | refs/heads/master | 2021-01-23T07:33:50.191000 | 2016-02-22T20:43:01 | 2016-02-22T20:43:01 | 42,118,155 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package dp.pages;
import com.codeborne.selenide.SelenideElement;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$;
public class AnyPage extends Page {
public AnyPage(WebDriver driver) {
super(driver);
}
SelenideElement livechatLink = $(".livechat-link");
SelenideElement cartCounter = $(By.xpath("(//a/i[contains(@class,'shopping-cart-counter')])[2]"));
public boolean ensurePageLoaded(){
waitForAjax(driver);
waitElementLoadedAndVisible(livechatLink.toWebElement());
return livechatLink.isDisplayed();
}
public boolean isCartIndexIncreased(){
cartCounter.waitUntil(visible, WAIT_SECONDS);
return cartCounter.getAttribute("data-value").length() > 0;
}
public int getCartCounter(){
cartCounter.waitUntil(visible, WAIT_SECONDS);
return new Integer(cartCounter.text());
}
}
| UTF-8 | Java | 1,006 | java | AnyPage.java | Java | []
| null | []
| package dp.pages;
import com.codeborne.selenide.SelenideElement;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$;
public class AnyPage extends Page {
public AnyPage(WebDriver driver) {
super(driver);
}
SelenideElement livechatLink = $(".livechat-link");
SelenideElement cartCounter = $(By.xpath("(//a/i[contains(@class,'shopping-cart-counter')])[2]"));
public boolean ensurePageLoaded(){
waitForAjax(driver);
waitElementLoadedAndVisible(livechatLink.toWebElement());
return livechatLink.isDisplayed();
}
public boolean isCartIndexIncreased(){
cartCounter.waitUntil(visible, WAIT_SECONDS);
return cartCounter.getAttribute("data-value").length() > 0;
}
public int getCartCounter(){
cartCounter.waitUntil(visible, WAIT_SECONDS);
return new Integer(cartCounter.text());
}
}
| 1,006 | 0.704771 | 0.702783 | 33 | 29.484848 | 25.416674 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.575758 | false | false | 2 |
233d5cd17b4184eebc7429d94f89ca921b60564e | 21,449,066,677,777 | aa39bb14adc3eed5803901c9fde8efe03dd471e8 | /app/src/main/java/emremedia/onlinquiz/BroadcastReceiver/AlarmReceiver.java | 20ddf2e3167c6f69af928fd9d4db214cfb1142d2 | []
| no_license | EMREERGN/Monster-Quizz | https://github.com/EMREERGN/Monster-Quizz | 22322b485f517dee63cc9b8fe7a9bad6d4809626 | ff728b39bd05ac5128c1994eb2cf1fec0c63b3c8 | refs/heads/master | 2021-08-31T13:25:22.307000 | 2017-12-21T13:16:23 | 2017-12-21T13:16:23 | 114,991,288 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package emremedia.onlinquiz.BroadcastReceiver;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import emremedia.onlinquiz.Common.Common;
import emremedia.onlinquiz.MainActivity;
import emremedia.onlinquiz.R;
/**
* Created by EMRE on 13.12.2017.
*/
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent ıntent) {
long when=System.currentTimeMillis();
NotificationManager notificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent=new Intent(context, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent=PendingIntent.getActivity(context,0,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
android.support.v4.app.NotificationCompat.Builder builder=new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.blue_monster)
.setContentTitle("Mosnter Quiz")
.setContentText("Hey ! "+ Common.currentUser.getUserName()+" Hadi Biraz Soru Çöz Bakalım")
.setSound(alarmSound)
.setAutoCancel(true)
.setWhen(when)
.setContentIntent(pendingIntent)
.setVibrate(new long[]{1000,1000,1000,1000,1000});
notificationManager.notify(0,builder.build());
}
}
| UTF-8 | Java | 1,775 | java | AlarmReceiver.java | Java | [
{
"context": ";\nimport emremedia.onlinquiz.R;\n\n/**\n * Created by EMRE on 13.12.2017.\n */\n\npublic class AlarmReceiver ex",
"end": 476,
"score": 0.9996525049209595,
"start": 472,
"tag": "USERNAME",
"value": "EMRE"
},
{
"context": "tText(\"Hey ! \"+ Common.currentUser.getUserName()+\" Hadi Biraz Soru Çöz Bakalım\")\n .setSound(alarmSound)\n ",
"end": 1478,
"score": 0.9984652996063232,
"start": 1451,
"tag": "NAME",
"value": "Hadi Biraz Soru Çöz Bakalım"
}
]
| null | []
| package emremedia.onlinquiz.BroadcastReceiver;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import emremedia.onlinquiz.Common.Common;
import emremedia.onlinquiz.MainActivity;
import emremedia.onlinquiz.R;
/**
* Created by EMRE on 13.12.2017.
*/
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent ıntent) {
long when=System.currentTimeMillis();
NotificationManager notificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent=new Intent(context, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent=PendingIntent.getActivity(context,0,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
android.support.v4.app.NotificationCompat.Builder builder=new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.blue_monster)
.setContentTitle("Mosnter Quiz")
.setContentText("Hey ! "+ Common.currentUser.getUserName()+" <NAME>")
.setSound(alarmSound)
.setAutoCancel(true)
.setWhen(when)
.setContentIntent(pendingIntent)
.setVibrate(new long[]{1000,1000,1000,1000,1000});
notificationManager.notify(0,builder.build());
}
}
| 1,751 | 0.732919 | 0.71485 | 50 | 34.419998 | 33.837902 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 2 |
5facf9402221d35c273a9a26f7e4629b450ebf82 | 24,996,709,730,408 | 4c30f171ef7204955b778d46f21382e773cc23a9 | /src/project/applications/controllers/general/MainController.java | 28fc097c525f3dd390c873913175d8bb0551830f | []
| no_license | jacedw1/CSC3380 | https://github.com/jacedw1/CSC3380 | b1119b27166e8f7262cdf766b30f9314f7f1e3d1 | 6558b56ff2caf2d51b350a6d46d3bc97d511dce1 | refs/heads/master | 2023-03-31T12:45:43.037000 | 2021-04-09T01:30:24 | 2021-04-09T01:30:24 | 346,885,435 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package project.applications.controllers.general;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import project.Main;
import java.io.IOException;
public class MainController {
public void signupBtnAction(MouseEvent event) throws IOException {
Parent root = FXMLLoader.load(Main.class.getResource("applications/resources/fxml/patient/signupscreen.fxml"));
Main.getPrimaryStage().setTitle("Signup Screen");
Main.getPrimaryStage().setScene(new Scene(root, root.prefWidth(500), root.prefHeight(500)));
}
public void loginBtnAction(MouseEvent event) throws IOException {
Parent root = FXMLLoader.load(Main.class.getResource("applications/resources/fxml/general/loginscreen.fxml"));
Main.getPrimaryStage().setTitle("Login Screen");
Main.getPrimaryStage().setScene(new Scene(root, root.prefWidth(500), root.prefHeight(500)));
}
}
| UTF-8 | Java | 969 | java | MainController.java | Java | []
| null | []
| package project.applications.controllers.general;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import project.Main;
import java.io.IOException;
public class MainController {
public void signupBtnAction(MouseEvent event) throws IOException {
Parent root = FXMLLoader.load(Main.class.getResource("applications/resources/fxml/patient/signupscreen.fxml"));
Main.getPrimaryStage().setTitle("Signup Screen");
Main.getPrimaryStage().setScene(new Scene(root, root.prefWidth(500), root.prefHeight(500)));
}
public void loginBtnAction(MouseEvent event) throws IOException {
Parent root = FXMLLoader.load(Main.class.getResource("applications/resources/fxml/general/loginscreen.fxml"));
Main.getPrimaryStage().setTitle("Login Screen");
Main.getPrimaryStage().setScene(new Scene(root, root.prefWidth(500), root.prefHeight(500)));
}
}
| 969 | 0.752322 | 0.739938 | 24 | 39.375 | 38.197746 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.708333 | false | false | 2 |
9070df5b338ff13071bcb266f39bf2d4f44dd0ee | 32,401,233,308,019 | e7f0b1cefaf9199c123082cabe0df7f71add1c7d | /src/main/java/com/moonkin/task/Fy2ETask.java | 3197e7b3b236e1bad663d9e8d337892cb4836365 | []
| no_license | fc13240/datafactory | https://github.com/fc13240/datafactory | 96f33e03a4a8f4c0c205d4fba5d4b2b364559d50 | 748e39c1179690639db9a5df2c2eed88b7c7e949 | refs/heads/master | 2020-05-02T06:32:17.349000 | 2018-12-06T13:54:39 | 2018-12-06T13:54:39 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.moonkin.task;
import com.moonkin.ui.MainWindow;
import com.moonkin.util.FileUtil;
import com.moonkin.util.JarToolUtil;
import org.quartz.JobDataMap;
import java.io.*;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
/**
* xuduo
* 2018/9/26
*/
public class Fy2ETask extends BaseTask {
private static DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
@Override
protected void config() {
setTaskId("fy2e_task");
setTaskName("风云2E数据分通道");
}
@Override
protected void doWork(JobDataMap dataMap) {
String statusFileName = JarToolUtil.getJarDir() + File.separator + "fy2e.txt";
byte[] b = new byte[2];
b[0] = 0x0d;
b[1] = 0x0a;
String c_string = new String(b);
String sourceFolder = MainWindow.mainWindow.getFy2eSourceTextField().getText().trim();
String destFolder = MainWindow.mainWindow.getFy2eDestTextField().getText().trim();
//脚本位置
File srcDir = new File(sourceFolder);
if (!srcDir.exists()) {
return;
}
if (srcDir.exists() && srcDir.isDirectory()) {
File statusFile = new File(statusFileName);
// 状态文件2小时重写
if (statusFile.exists()) {
statusFile.delete();
}
//文件不存在创建状态记录文件
if (!statusFile.exists()) {
System.out.println("正在初始化状态文件 " + statusFileName + "... ...");
String[] fileNames = srcDir.list();
// 由于文件量过大,先获取文件名称列表,写入状态文件,再处理。
StringBuilder logsb = new StringBuilder();
int n = 0;
for (int i = 0; i < fileNames.length; i ++) { //文件名 状态 时间戳 初始化时间最早
if (fileNames[i].endsWith("_lbt_fy2e.jpg")) {
logsb.append(fileNames[i]).append(" ").append("0").append(" ").append(LocalDateTime.now().minusHours(3).format(dtf)).append(c_string);
n++;
if(n > 500) {
break;
}
}
}
FileUtil.write(statusFileName, logsb.toString(), "UTF-8");
}
BufferedReader br;
try {
br = new BufferedReader(new FileReader(JarToolUtil.getJarDir() + File.separator + "fy2e.txt"));
String line;
StringBuilder sb = new StringBuilder();
while (null != (line = br.readLine())) {
String[] status = line.split("\\s+");
if (status.length == 3) { //文件名 状态 时间
long last = new File(sourceFolder + File.separator + status[0]).lastModified();
//当状态是0 或者文件的修改时间晚于记录时间时,则处理文件
if (status[1].equals("0")) { //只处理状态是 0 的文件
if (!MainWindow.mainWindow.getOutputTextArea().getText().isEmpty()) {
sb.append(MainWindow.mainWindow.getOutputTextArea().getText()).append(c_string);
}
if (sb.length() >= 1000) { //清空
MainWindow.mainWindow.getOutputTextArea().setText("");
sb.delete(0, sb.length());
}
sb.append("[风云2E]");
sb.append("[").append(LocalDateTime.now().toString()).append("]:").append("正在处理文件")
.append(sourceFolder).append(",转换后文件为").append(destFolder).append(c_string);
MainWindow.mainWindow.getOutputTextArea().setText(sb.toString());
//201809131532_ch6_lbt_fy2e.kj
//换名
String temp = status[0].replaceAll("_lbt_fy2e.jpg", "");
temp = temp.substring(temp.indexOf("_") + 1);
File destFile = new File(destFolder + "/" + temp + "/" + status[0]);
try {
FileUtil.fileChannelCopy(new File(srcDir + File.separator + status[0]), destFile);
} catch (IOException e) {
e.printStackTrace();
}
sb.append("[").append(LocalDateTime.now().toString()).append("]:").append("文件")
.append(status[0]).append("处理完毕");
MainWindow.mainWindow.getOutputTextArea().setText(sb.toString());
//修改对应的记录行
FileUtil.modifyFileContent(statusFileName, line, status[0] + " " + "1" + " " + LocalDateTime.ofInstant(Instant.ofEpochMilli(last), ZoneId.systemDefault()).format(dtf));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
| UTF-8 | Java | 5,409 | java | Fy2ETask.java | Java | [
{
"context": "\nimport java.time.format.DateTimeFormatter;\n/**\n * xuduo\n * 2018/9/26\n */\npublic class Fy2ETask extends Ba",
"end": 319,
"score": 0.999401867389679,
"start": 314,
"tag": "USERNAME",
"value": "xuduo"
}
]
| null | []
| package com.moonkin.task;
import com.moonkin.ui.MainWindow;
import com.moonkin.util.FileUtil;
import com.moonkin.util.JarToolUtil;
import org.quartz.JobDataMap;
import java.io.*;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
/**
* xuduo
* 2018/9/26
*/
public class Fy2ETask extends BaseTask {
private static DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
@Override
protected void config() {
setTaskId("fy2e_task");
setTaskName("风云2E数据分通道");
}
@Override
protected void doWork(JobDataMap dataMap) {
String statusFileName = JarToolUtil.getJarDir() + File.separator + "fy2e.txt";
byte[] b = new byte[2];
b[0] = 0x0d;
b[1] = 0x0a;
String c_string = new String(b);
String sourceFolder = MainWindow.mainWindow.getFy2eSourceTextField().getText().trim();
String destFolder = MainWindow.mainWindow.getFy2eDestTextField().getText().trim();
//脚本位置
File srcDir = new File(sourceFolder);
if (!srcDir.exists()) {
return;
}
if (srcDir.exists() && srcDir.isDirectory()) {
File statusFile = new File(statusFileName);
// 状态文件2小时重写
if (statusFile.exists()) {
statusFile.delete();
}
//文件不存在创建状态记录文件
if (!statusFile.exists()) {
System.out.println("正在初始化状态文件 " + statusFileName + "... ...");
String[] fileNames = srcDir.list();
// 由于文件量过大,先获取文件名称列表,写入状态文件,再处理。
StringBuilder logsb = new StringBuilder();
int n = 0;
for (int i = 0; i < fileNames.length; i ++) { //文件名 状态 时间戳 初始化时间最早
if (fileNames[i].endsWith("_lbt_fy2e.jpg")) {
logsb.append(fileNames[i]).append(" ").append("0").append(" ").append(LocalDateTime.now().minusHours(3).format(dtf)).append(c_string);
n++;
if(n > 500) {
break;
}
}
}
FileUtil.write(statusFileName, logsb.toString(), "UTF-8");
}
BufferedReader br;
try {
br = new BufferedReader(new FileReader(JarToolUtil.getJarDir() + File.separator + "fy2e.txt"));
String line;
StringBuilder sb = new StringBuilder();
while (null != (line = br.readLine())) {
String[] status = line.split("\\s+");
if (status.length == 3) { //文件名 状态 时间
long last = new File(sourceFolder + File.separator + status[0]).lastModified();
//当状态是0 或者文件的修改时间晚于记录时间时,则处理文件
if (status[1].equals("0")) { //只处理状态是 0 的文件
if (!MainWindow.mainWindow.getOutputTextArea().getText().isEmpty()) {
sb.append(MainWindow.mainWindow.getOutputTextArea().getText()).append(c_string);
}
if (sb.length() >= 1000) { //清空
MainWindow.mainWindow.getOutputTextArea().setText("");
sb.delete(0, sb.length());
}
sb.append("[风云2E]");
sb.append("[").append(LocalDateTime.now().toString()).append("]:").append("正在处理文件")
.append(sourceFolder).append(",转换后文件为").append(destFolder).append(c_string);
MainWindow.mainWindow.getOutputTextArea().setText(sb.toString());
//201809131532_ch6_lbt_fy2e.kj
//换名
String temp = status[0].replaceAll("_lbt_fy2e.jpg", "");
temp = temp.substring(temp.indexOf("_") + 1);
File destFile = new File(destFolder + "/" + temp + "/" + status[0]);
try {
FileUtil.fileChannelCopy(new File(srcDir + File.separator + status[0]), destFile);
} catch (IOException e) {
e.printStackTrace();
}
sb.append("[").append(LocalDateTime.now().toString()).append("]:").append("文件")
.append(status[0]).append("处理完毕");
MainWindow.mainWindow.getOutputTextArea().setText(sb.toString());
//修改对应的记录行
FileUtil.modifyFileContent(statusFileName, line, status[0] + " " + "1" + " " + LocalDateTime.ofInstant(Instant.ofEpochMilli(last), ZoneId.systemDefault()).format(dtf));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
| 5,409 | 0.486152 | 0.473384 | 110 | 45.281818 | 35.332737 | 196 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.581818 | false | false | 2 |
927c5fb8a1035f2ebd61a6bca6afd40e087c78ae | 17,617,955,848,819 | e2a4331b3673729d3730a72bf44224de41f5737f | /app/src/main/java/com/bw/ynf/views/adapter/homeadapters/ZhuanTiRecyclerAdapter.java | 63ad0cab15a3f9f25111e8c6599d9a0d0cb5bcf4 | []
| no_license | FieryDream/YNF | https://github.com/FieryDream/YNF | 03258c4c542462a2a478f117ad72a35c77be2f7c | e7a4d888d79378fd1c6c1700707cb9b19398f8a3 | refs/heads/master | 2020-06-11T01:06:26.520000 | 2016-12-18T10:32:18 | 2016-12-18T10:32:18 | 75,826,702 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.bw.ynf.views.adapter.homeadapters;
import android.support.v7.widget.RecyclerView;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.StrikethroughSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bw.ynf.R;
import com.bw.ynf.bean.homebean.HotZhuanTi;
import com.bw.ynf.views.activity.ReMenActivity;
import java.util.ArrayList;
/**
* Created by GaoJun on 2016/12/14 0014.
*/
public class ZhuanTiRecyclerAdapter extends RecyclerView.Adapter<ZhuanTiRecyclerAdapter.ViewHodler>{
private ReMenActivity context;
private ArrayList<HotZhuanTi> subjects;
private int pos;
private ZhuTiOnItemClick zhuTiOnItemClick;
public ZhuanTiRecyclerAdapter(ReMenActivity context, ArrayList<HotZhuanTi> subjects, int pos) {
this.context=context;
this.subjects=subjects;
this.pos=pos;
}
@Override
public ViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
//加载Adapter布局文件
View view = LayoutInflater.from(context).inflate(R.layout.zhuanti_recycler_peizhi, parent, false);
//把布局设置给ViewHolder
ViewHodler hodler = new ViewHodler(view);
return hodler;
}
@Override
public void onBindViewHolder(final ViewHodler holder, final int position) {
//加载大图
Glide.with(context).load(subjects.get(pos).getGoodsList().get(position).getGoods_img()).into(holder.bigImage);
//加载小图
Glide.with(context).load(subjects.get(pos).getGoodsList().get(position).getWatermarkUrl()).into(holder.simImage);
//设置Efficacy的字体
holder.tvEfficacy.setText(subjects.get(pos).getGoodsList().get(position).getEfficacy());
//设置产品介绍
holder.tvName.setText(subjects.get(pos).getGoodsList().get(position).getGoods_name());
//设置出售价格
holder.tvShop_price.setText(subjects.get(pos).getGoodsList().get(position).getShop_price()+"");
//获得原价,并转换成字符串
String Market_price = subjects.get(pos).getGoodsList().get(position).getMarket_price() + "";
//实例化SpannableString对象,并把原价的字符串放进去
SpannableString span = new SpannableString(Market_price);
//设置中划线/删除线
span.setSpan(new StrikethroughSpan(),0,Market_price.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
//将处理好后的字符串设置进字体
holder.tvMarket_price.setText(span);
//条目点击事件
if (zhuTiOnItemClick != null) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int position = holder.getLayoutPosition();
zhuTiOnItemClick.onItemClick(position);
}
});
}
}
@Override
public int getItemCount() {
return subjects.size();
}
public class ViewHodler extends RecyclerView.ViewHolder {
private final ImageView bigImage;
private final ImageView simImage;
private final TextView tvEfficacy;
private final TextView tvName;
private final TextView tvShop_price;
private final TextView tvMarket_price;
public ViewHodler(View itemView) {
super(itemView);
bigImage = (ImageView) itemView.findViewById(R.id.zhuti_recycler_bigImage);
simImage = (ImageView) itemView.findViewById(R.id.zhuti_recycler_simImage);
tvEfficacy = (TextView) itemView.findViewById(R.id.zhuti_recycler_efficacy);
tvName = (TextView) itemView.findViewById(R.id.zhuti_recycler_name);
tvShop_price = (TextView) itemView.findViewById(R.id.zhuti_recycler_shop_price);
tvMarket_price = (TextView) itemView.findViewById(R.id.zhuti_recycler_market_price);
}
}
public interface ZhuTiOnItemClick{
void onItemClick(int position);
}
public void setZhuTiOnItemClick(ZhuTiOnItemClick zhuTiOnItemClick){
this.zhuTiOnItemClick=zhuTiOnItemClick;
}
}
| UTF-8 | Java | 4,320 | java | ZhuanTiRecyclerAdapter.java | Java | [
{
"context": "y;\n\nimport java.util.ArrayList;\n\n/**\n * Created by GaoJun on 2016/12/14 0014.\n */\n\npublic class ZhuanTiRecy",
"end": 565,
"score": 0.9812822341918945,
"start": 559,
"tag": "NAME",
"value": "GaoJun"
}
]
| null | []
| package com.bw.ynf.views.adapter.homeadapters;
import android.support.v7.widget.RecyclerView;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.StrikethroughSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bw.ynf.R;
import com.bw.ynf.bean.homebean.HotZhuanTi;
import com.bw.ynf.views.activity.ReMenActivity;
import java.util.ArrayList;
/**
* Created by GaoJun on 2016/12/14 0014.
*/
public class ZhuanTiRecyclerAdapter extends RecyclerView.Adapter<ZhuanTiRecyclerAdapter.ViewHodler>{
private ReMenActivity context;
private ArrayList<HotZhuanTi> subjects;
private int pos;
private ZhuTiOnItemClick zhuTiOnItemClick;
public ZhuanTiRecyclerAdapter(ReMenActivity context, ArrayList<HotZhuanTi> subjects, int pos) {
this.context=context;
this.subjects=subjects;
this.pos=pos;
}
@Override
public ViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
//加载Adapter布局文件
View view = LayoutInflater.from(context).inflate(R.layout.zhuanti_recycler_peizhi, parent, false);
//把布局设置给ViewHolder
ViewHodler hodler = new ViewHodler(view);
return hodler;
}
@Override
public void onBindViewHolder(final ViewHodler holder, final int position) {
//加载大图
Glide.with(context).load(subjects.get(pos).getGoodsList().get(position).getGoods_img()).into(holder.bigImage);
//加载小图
Glide.with(context).load(subjects.get(pos).getGoodsList().get(position).getWatermarkUrl()).into(holder.simImage);
//设置Efficacy的字体
holder.tvEfficacy.setText(subjects.get(pos).getGoodsList().get(position).getEfficacy());
//设置产品介绍
holder.tvName.setText(subjects.get(pos).getGoodsList().get(position).getGoods_name());
//设置出售价格
holder.tvShop_price.setText(subjects.get(pos).getGoodsList().get(position).getShop_price()+"");
//获得原价,并转换成字符串
String Market_price = subjects.get(pos).getGoodsList().get(position).getMarket_price() + "";
//实例化SpannableString对象,并把原价的字符串放进去
SpannableString span = new SpannableString(Market_price);
//设置中划线/删除线
span.setSpan(new StrikethroughSpan(),0,Market_price.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
//将处理好后的字符串设置进字体
holder.tvMarket_price.setText(span);
//条目点击事件
if (zhuTiOnItemClick != null) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int position = holder.getLayoutPosition();
zhuTiOnItemClick.onItemClick(position);
}
});
}
}
@Override
public int getItemCount() {
return subjects.size();
}
public class ViewHodler extends RecyclerView.ViewHolder {
private final ImageView bigImage;
private final ImageView simImage;
private final TextView tvEfficacy;
private final TextView tvName;
private final TextView tvShop_price;
private final TextView tvMarket_price;
public ViewHodler(View itemView) {
super(itemView);
bigImage = (ImageView) itemView.findViewById(R.id.zhuti_recycler_bigImage);
simImage = (ImageView) itemView.findViewById(R.id.zhuti_recycler_simImage);
tvEfficacy = (TextView) itemView.findViewById(R.id.zhuti_recycler_efficacy);
tvName = (TextView) itemView.findViewById(R.id.zhuti_recycler_name);
tvShop_price = (TextView) itemView.findViewById(R.id.zhuti_recycler_shop_price);
tvMarket_price = (TextView) itemView.findViewById(R.id.zhuti_recycler_market_price);
}
}
public interface ZhuTiOnItemClick{
void onItemClick(int position);
}
public void setZhuTiOnItemClick(ZhuTiOnItemClick zhuTiOnItemClick){
this.zhuTiOnItemClick=zhuTiOnItemClick;
}
}
| 4,320 | 0.685382 | 0.681994 | 111 | 36.225224 | 31.949478 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.558559 | false | false | 2 |
04ffaa74e0c98c8f3ca726b6026f1cbc64b94673 | 33,741,263,101,329 | 657540792bf6f05a023285458541f6e03b817943 | /src/main/java/com/content/pdf/storage/StorageProperties.java | 2f766e70a21006de962fcf3a0a8f6e29d777c645 | []
| no_license | imrecetin/pdf-merger | https://github.com/imrecetin/pdf-merger | aa9e017492a63b65f229efa655eb1e4eb8ff29f6 | 9903af56ebbfe954ccfa333e0f35ae1f92301075 | refs/heads/master | 2021-08-16T22:23:44.667000 | 2020-05-08T16:56:00 | 2020-05-08T16:56:00 | 143,330,643 | 0 | 0 | null | false | 2021-06-15T15:55:19 | 2018-08-02T18:21:34 | 2020-05-08T16:56:03 | 2021-06-15T15:55:17 | 56 | 0 | 0 | 2 | Java | false | false | package com.content.pdf.storage;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource("classpath:storage.properties")
@ConfigurationProperties("storage")
public class StorageProperties {
private String uploadLocation ;
public String getUploadLocation() {
return uploadLocation;
}
public void setUploadLocation(String uploadLocation) {
this.uploadLocation = uploadLocation;
}
}
| UTF-8 | Java | 574 | java | StorageProperties.java | Java | []
| null | []
| package com.content.pdf.storage;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource("classpath:storage.properties")
@ConfigurationProperties("storage")
public class StorageProperties {
private String uploadLocation ;
public String getUploadLocation() {
return uploadLocation;
}
public void setUploadLocation(String uploadLocation) {
this.uploadLocation = uploadLocation;
}
}
| 574 | 0.818815 | 0.818815 | 23 | 23.956522 | 23.844566 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.695652 | false | false | 2 |
e6f61ad91923f4d95c8fde9cad92c474e20f4d6b | 6,047,314,019,012 | e0bc2cee6f37569f0ffbcc4b884365f7e068663f | /app/src/main/java/in/psgroup/psgroup/Models/TopPropertyBean.java | fbe6a20d79816bb6db9499f8b856759ac0d30f2e | []
| no_license | Mouneshwara/PSGroup | https://github.com/Mouneshwara/PSGroup | ce4acdeef793a805580b63cbfea46b86208b4567 | c00d4c5e2c5dade9430656db502c1617a3c21fa2 | refs/heads/master | 2023-04-03T17:01:13.070000 | 2021-04-09T14:26:18 | 2021-04-09T14:26:18 | 356,293,983 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package in.psgroup.psgroup.Models;
public class TopPropertyBean {
String title,description,laying;
int milestone_max,milestone_min;
int seekbarMax,seekbarMin;
public TopPropertyBean(String title, String description, String laying, int milestone_max, int milestone_min, int seekbarMax, int seekbarMin) {
this.title = title;
this.description = description;
this.laying = laying;
this.milestone_max = milestone_max;
this.milestone_min = milestone_min;
this.seekbarMax = seekbarMax;
this.seekbarMin = seekbarMin;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLaying() {
return laying;
}
public void setLaying(String laying) {
this.laying = laying;
}
public int getMilestone_max() {
return milestone_max;
}
public void setMilestone_max(int milestone_max) {
this.milestone_max = milestone_max;
}
public int getMilestone_min() {
return milestone_min;
}
public void setMilestone_min(int milestone_min) {
this.milestone_min = milestone_min;
}
public int getSeekbarMax() {
return seekbarMax;
}
public void setSeekbarMax(int seekbarMax) {
this.seekbarMax = seekbarMax;
}
public int getSeekbarMin() {
return seekbarMin;
}
public void setSeekbarMin(int seekbarMin) {
this.seekbarMin = seekbarMin;
}
}
| UTF-8 | Java | 1,719 | java | TopPropertyBean.java | Java | []
| null | []
| package in.psgroup.psgroup.Models;
public class TopPropertyBean {
String title,description,laying;
int milestone_max,milestone_min;
int seekbarMax,seekbarMin;
public TopPropertyBean(String title, String description, String laying, int milestone_max, int milestone_min, int seekbarMax, int seekbarMin) {
this.title = title;
this.description = description;
this.laying = laying;
this.milestone_max = milestone_max;
this.milestone_min = milestone_min;
this.seekbarMax = seekbarMax;
this.seekbarMin = seekbarMin;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLaying() {
return laying;
}
public void setLaying(String laying) {
this.laying = laying;
}
public int getMilestone_max() {
return milestone_max;
}
public void setMilestone_max(int milestone_max) {
this.milestone_max = milestone_max;
}
public int getMilestone_min() {
return milestone_min;
}
public void setMilestone_min(int milestone_min) {
this.milestone_min = milestone_min;
}
public int getSeekbarMax() {
return seekbarMax;
}
public void setSeekbarMax(int seekbarMax) {
this.seekbarMax = seekbarMax;
}
public int getSeekbarMin() {
return seekbarMin;
}
public void setSeekbarMin(int seekbarMin) {
this.seekbarMin = seekbarMin;
}
}
| 1,719 | 0.63409 | 0.63409 | 75 | 21.92 | 22.802784 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.466667 | false | false | 2 |
21afe3ab1592b3b34441b122f8d7b5552dcd6d75 | 7,481,833,035,552 | 68433be819016fd500024de79f844fd2af1e5eac | /src/test/java/ch/ethz/idsc/retina/u3/LabjackAdcFrameTest.java | 25333bbb6d1ad3b60c80aeb69e9d9e56ec8413a1 | []
| no_license | Forrest-Z/retina | https://github.com/Forrest-Z/retina | 379fdd15d5e500e8d8adf017f7585571ab59410e | 16d7ba760759d92aa4dcfcd4ffcde96ee33f91a4 | refs/heads/master | 2020-05-23T21:54:11.818000 | 2019-05-16T03:15:24 | 2019-05-16T03:15:24 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // code by jph
package ch.ethz.idsc.retina.u3;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import junit.framework.TestCase;
public class LabjackAdcFrameTest extends TestCase {
public void testBPFalse() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 0f, 0f, 0f, 0f, 0f });
assertEquals(labjackAdcFrame.getADC_V(0), 0f);
}
public void testBPTrue() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 0f, 0f, 0f, 0f, 2.4f });
assertEquals(labjackAdcFrame.getADC_V(4), 2.4f);
}
public void testThrottle() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 0f, 0f, 2.5f, 0f, 0f });
assertEquals(labjackAdcFrame.getADC_V(2), 2.5f);
}
public void testThrottleMax() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 0f, 0f, 5.3f, 0f, 0f });
assertEquals(labjackAdcFrame.getADC_V(2), 5.3f);
}
public void testThrottleNegative() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 0f, 0f, 2.5f, 0f, 2f });
assertEquals(labjackAdcFrame.getADC_V(2), 2.5f);
assertEquals(labjackAdcFrame.getADC_V(4), 2f);
}
public void testEncoding() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 1.2f, 2.9f, 3f, 4f, -5.23f });
byte[] array = labjackAdcFrame.asArray();
ByteBuffer byteBuffer = ByteBuffer.wrap(array);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
assertEquals(byteBuffer.getFloat(), 1.2f);
assertEquals(byteBuffer.getFloat(), 2.9f);
assertEquals(byteBuffer.getFloat(), 3f);
assertEquals(byteBuffer.getFloat(), 4f);
assertEquals(byteBuffer.getFloat(), -5.23f);
byteBuffer.rewind();
labjackAdcFrame = new LabjackAdcFrame(byteBuffer);
assertEquals(labjackAdcFrame.getADC_V(0), 1.2f);
assertEquals(labjackAdcFrame.getADC_V(1), 2.9f);
assertEquals(labjackAdcFrame.getADC_V(2), 3.0f);
assertEquals(labjackAdcFrame.getADC_V(3), 4.0f);
assertEquals(labjackAdcFrame.getADC_V(4), -5.23f);
}
}
| UTF-8 | Java | 2,040 | java | LabjackAdcFrameTest.java | Java | [
{
"context": "// code by jph\npackage ch.ethz.idsc.retina.u3;\n\nimport java.nio.",
"end": 14,
"score": 0.9969980716705322,
"start": 11,
"tag": "USERNAME",
"value": "jph"
}
]
| null | []
| // code by jph
package ch.ethz.idsc.retina.u3;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import junit.framework.TestCase;
public class LabjackAdcFrameTest extends TestCase {
public void testBPFalse() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 0f, 0f, 0f, 0f, 0f });
assertEquals(labjackAdcFrame.getADC_V(0), 0f);
}
public void testBPTrue() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 0f, 0f, 0f, 0f, 2.4f });
assertEquals(labjackAdcFrame.getADC_V(4), 2.4f);
}
public void testThrottle() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 0f, 0f, 2.5f, 0f, 0f });
assertEquals(labjackAdcFrame.getADC_V(2), 2.5f);
}
public void testThrottleMax() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 0f, 0f, 5.3f, 0f, 0f });
assertEquals(labjackAdcFrame.getADC_V(2), 5.3f);
}
public void testThrottleNegative() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 0f, 0f, 2.5f, 0f, 2f });
assertEquals(labjackAdcFrame.getADC_V(2), 2.5f);
assertEquals(labjackAdcFrame.getADC_V(4), 2f);
}
public void testEncoding() {
LabjackAdcFrame labjackAdcFrame = new LabjackAdcFrame(new float[] { 1.2f, 2.9f, 3f, 4f, -5.23f });
byte[] array = labjackAdcFrame.asArray();
ByteBuffer byteBuffer = ByteBuffer.wrap(array);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
assertEquals(byteBuffer.getFloat(), 1.2f);
assertEquals(byteBuffer.getFloat(), 2.9f);
assertEquals(byteBuffer.getFloat(), 3f);
assertEquals(byteBuffer.getFloat(), 4f);
assertEquals(byteBuffer.getFloat(), -5.23f);
byteBuffer.rewind();
labjackAdcFrame = new LabjackAdcFrame(byteBuffer);
assertEquals(labjackAdcFrame.getADC_V(0), 1.2f);
assertEquals(labjackAdcFrame.getADC_V(1), 2.9f);
assertEquals(labjackAdcFrame.getADC_V(2), 3.0f);
assertEquals(labjackAdcFrame.getADC_V(3), 4.0f);
assertEquals(labjackAdcFrame.getADC_V(4), -5.23f);
}
}
| 2,040 | 0.706863 | 0.667647 | 54 | 36.777779 | 29.012556 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.314815 | false | false | 2 |
4629bccd65934bd4f699d2de9d38d7702af6ba13 | 17,789,754,559,520 | 2b0413453df4774822e75ae5b3a638dc06a3dbfc | /javayum-pattern-app-springboot-web/src/main/java/net/javayum/pattern/app/springboot/web/ApplicationConfiguration.java | 9845de31ea89c093990f3ba357b70657c2455bcd | []
| no_license | javayum/net.javayum.pattern | https://github.com/javayum/net.javayum.pattern | 71f2523976e85e346929e91d115d11291f23cf91 | 5304b9143846f8d318d765124101865620c38f69 | refs/heads/master | 2021-01-01T06:09:52.918000 | 2017-07-17T19:56:16 | 2017-07-17T19:56:16 | 97,376,143 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.javayum.pattern.app.springboot.web;
import net.javayum.pattern.ws.SpringRESTConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@Configuration
@Import(
SpringRESTConfiguration.class
)
public class ApplicationConfiguration {
}
| UTF-8 | Java | 326 | java | ApplicationConfiguration.java | Java | []
| null | []
| package net.javayum.pattern.app.springboot.web;
import net.javayum.pattern.ws.SpringRESTConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@Configuration
@Import(
SpringRESTConfiguration.class
)
public class ApplicationConfiguration {
}
| 326 | 0.831288 | 0.831288 | 12 | 26.166666 | 23.219364 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 2 |
ec6f400a74ebd84ecb376aac23f3a1d3e5f1495c | 15,625,091,040,073 | 2290519fa02987fba83b9636292120bdc80cbe40 | /Core 8 Features/10-ExceptionHandlingInLambda/src/com/test/CheckedException.java | 20c3051fe8aeeecf40d1ca35fab172525fb9d9ad | []
| no_license | rksharma2180/Main | https://github.com/rksharma2180/Main | ad341b8aeec62c858bc741b3390fc4a913cf213e | f91dfc4ea0528e274019918693ccec4a3e30d129 | refs/heads/master | 2018-11-22T09:19:12.038000 | 2018-10-18T10:12:48 | 2018-10-18T10:12:48 | 147,292,598 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.test;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
public class CheckedException {
public static void main(String[] args) throws IOException{
List<Integer> numbers = Arrays.asList(3,9,7,5,8,5,4,8);
//1st way
/*
numbers.forEach(i->{
try {
writeToFile(i);
} catch (IOException e) {
throw new RuntimeException(e);
//e.printStackTrace();
}
});
*/
numbers.forEach(throwingConsumerWrapper(i->writeToFile(i)));
}
public static Object writeToFile(int i) throws IOException {
return null;
}
public static<T> Consumer<T> throwingConsumerWrapper(ThrowingConsumer<T, Exception> throwingConsumer){
return i->{
try {
throwingConsumer.accept(i);
}catch(Exception e) {
throw new RuntimeException(e);
}
};
}
}
| UTF-8 | Java | 856 | java | CheckedException.java | Java | []
| null | []
| package com.test;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
public class CheckedException {
public static void main(String[] args) throws IOException{
List<Integer> numbers = Arrays.asList(3,9,7,5,8,5,4,8);
//1st way
/*
numbers.forEach(i->{
try {
writeToFile(i);
} catch (IOException e) {
throw new RuntimeException(e);
//e.printStackTrace();
}
});
*/
numbers.forEach(throwingConsumerWrapper(i->writeToFile(i)));
}
public static Object writeToFile(int i) throws IOException {
return null;
}
public static<T> Consumer<T> throwingConsumerWrapper(ThrowingConsumer<T, Exception> throwingConsumer){
return i->{
try {
throwingConsumer.accept(i);
}catch(Exception e) {
throw new RuntimeException(e);
}
};
}
}
| 856 | 0.678738 | 0.668224 | 44 | 18.454546 | 21.891731 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.204545 | false | false | 2 |
80adcfd9d7d80665860c64f03a5a52b0b13b3dfd | 15,625,091,038,110 | 6b7b96ba85556e4c427fe54a17745f2130a79faf | /src/main/java/uy/edu/cei/AmazonCEI/ShoppingCart/controllers/ShoppingCartController.java | c8c1e77a0e68932d2d36acd5d2cda5fd9f1e7fdb | []
| no_license | TomasAtrat/AmazonCEI | https://github.com/TomasAtrat/AmazonCEI | 0696ffb3ee33e2495649996346374bc84827e20b | 496032875188de67f981d9f6cbe99bdfd93c8596 | refs/heads/main | 2023-07-14T07:21:57.753000 | 2021-08-16T16:35:43 | 2021-08-16T16:35:43 | 394,077,682 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package uy.edu.cei.AmazonCEI.ShoppingCart.controllers;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import uy.edu.cei.AmazonCEI.ShoppingCart.services.ShoppingCartServices;
import uy.edu.cei.AmazonCEI.common.models.Item;
import uy.edu.cei.AmazonCEI.common.models.ItemInShoppingCart;
import uy.edu.cei.AmazonCEI.common.models.ItemsInCartWrapper;
import uy.edu.cei.AmazonCEI.common.models.ShoppingCart;
import java.util.List;
@RestController
@RequestMapping("/ShoppingCart")
@AllArgsConstructor
public class ShoppingCartController {
private final ShoppingCartServices shoppingCartServices;
@GetMapping("/{uuid_user}")
public List<Item>listShowItem(@PathVariable("uuid_user") String uuidCarrito) {
return this.shoppingCartServices.getListCart(uuidCarrito);
}
@GetMapping("/foreign1/{uuid_user}")
public ShoppingCart getElementByUserUUID(@PathVariable("uuid_user") final String uuid_user){
return this.shoppingCartServices.getElementByUserUUID(uuid_user);
}
@GetMapping("/foreign2/{uuid_cart}")
public ItemsInCartWrapper getItemsInCart(@PathVariable("uuid_cart") final String uuid_cart){
ItemsInCartWrapper wrapper= new ItemsInCartWrapper();
wrapper.setItemsInCart(shoppingCartServices.getItemsInCart(uuid_cart));
return wrapper;
}
@PostMapping("/{uuid_user}")
public void createMesaggeAddItemCart(@PathVariable("uuid_user") String uuid_user,
@RequestBody final ItemInShoppingCart item)
{
this.shoppingCartServices.addItemCart(uuid_user, item);
}
@DeleteMapping("/{uuidUser}")
public void deleteCartMessage(@PathVariable("uuidUser") final String uuidUser,
@RequestBody final Item item)
{
this.shoppingCartServices.messageDeleteCart(uuidUser, item);
}
}
| UTF-8 | Java | 1,911 | java | ShoppingCartController.java | Java | []
| null | []
| package uy.edu.cei.AmazonCEI.ShoppingCart.controllers;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import uy.edu.cei.AmazonCEI.ShoppingCart.services.ShoppingCartServices;
import uy.edu.cei.AmazonCEI.common.models.Item;
import uy.edu.cei.AmazonCEI.common.models.ItemInShoppingCart;
import uy.edu.cei.AmazonCEI.common.models.ItemsInCartWrapper;
import uy.edu.cei.AmazonCEI.common.models.ShoppingCart;
import java.util.List;
@RestController
@RequestMapping("/ShoppingCart")
@AllArgsConstructor
public class ShoppingCartController {
private final ShoppingCartServices shoppingCartServices;
@GetMapping("/{uuid_user}")
public List<Item>listShowItem(@PathVariable("uuid_user") String uuidCarrito) {
return this.shoppingCartServices.getListCart(uuidCarrito);
}
@GetMapping("/foreign1/{uuid_user}")
public ShoppingCart getElementByUserUUID(@PathVariable("uuid_user") final String uuid_user){
return this.shoppingCartServices.getElementByUserUUID(uuid_user);
}
@GetMapping("/foreign2/{uuid_cart}")
public ItemsInCartWrapper getItemsInCart(@PathVariable("uuid_cart") final String uuid_cart){
ItemsInCartWrapper wrapper= new ItemsInCartWrapper();
wrapper.setItemsInCart(shoppingCartServices.getItemsInCart(uuid_cart));
return wrapper;
}
@PostMapping("/{uuid_user}")
public void createMesaggeAddItemCart(@PathVariable("uuid_user") String uuid_user,
@RequestBody final ItemInShoppingCart item)
{
this.shoppingCartServices.addItemCart(uuid_user, item);
}
@DeleteMapping("/{uuidUser}")
public void deleteCartMessage(@PathVariable("uuidUser") final String uuidUser,
@RequestBody final Item item)
{
this.shoppingCartServices.messageDeleteCart(uuidUser, item);
}
}
| 1,911 | 0.726845 | 0.725798 | 48 | 38.75 | 30.60535 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4375 | false | false | 2 |
948271f5bfab9d7dcfd0873e938a6d2895213d2f | 28,372,553,970,956 | 38142c683d5c0393d31695fa143b1ec7fbc4bf1e | /api/src/main/java/nl/phazebroek/fida/bookkeeping/BookkeepingController.java | b23499fa4e57da10fd0b22d2da212158b35469c0 | []
| no_license | phazebroek/fida2 | https://github.com/phazebroek/fida2 | d526082c98d8c2c4386a6254af7419932e403c45 | f6402f371b53bad6d6da5e29db654c2f356d4491 | refs/heads/develop | 2021-01-09T05:25:08.375000 | 2017-10-26T14:00:30 | 2017-10-26T14:00:30 | 80,766,285 | 0 | 0 | null | false | 2017-06-14T18:42:19 | 2017-02-02T20:35:36 | 2017-02-21T15:23:12 | 2017-06-14T18:42:18 | 666 | 0 | 0 | 1 | TypeScript | null | null | package nl.phazebroek.fida.bookkeeping;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RestController
public class BookkeepingController {
private final BookkeepingService bookkeepingService;
@GetMapping("bookkeepings")
public List<Bookkeeping> getBookkeepings() {
return bookkeepingService.getBookkeepings();
}
@PutMapping("bookkeepings")
public Bookkeeping addBookkeeping(@RequestBody Bookkeeping bookkeeping) {
return bookkeepingService.saveBookkeeping(bookkeeping);
}
@DeleteMapping("/bookkeepings/{id}")
public void deleteBookkeeping(@PathVariable final Long id) {
this.bookkeepingService.deleteBookkeeping(id);
}
}
| UTF-8 | Java | 1,193 | java | BookkeepingController.java | Java | []
| null | []
| package nl.phazebroek.fida.bookkeeping;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RestController
public class BookkeepingController {
private final BookkeepingService bookkeepingService;
@GetMapping("bookkeepings")
public List<Bookkeeping> getBookkeepings() {
return bookkeepingService.getBookkeepings();
}
@PutMapping("bookkeepings")
public Bookkeeping addBookkeeping(@RequestBody Bookkeeping bookkeeping) {
return bookkeepingService.saveBookkeeping(bookkeeping);
}
@DeleteMapping("/bookkeepings/{id}")
public void deleteBookkeeping(@PathVariable final Long id) {
this.bookkeepingService.deleteBookkeeping(id);
}
}
| 1,193 | 0.794635 | 0.794635 | 34 | 34.088234 | 25.770899 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.411765 | false | false | 2 |
c81d207248dd06d4c48a5d6a63c56d3cd20e300e | 5,506,148,133,057 | 542ee046c08dd49cb17bd17b6fe0d52abb635d50 | /src/main/java/com/example/demo/repository/LoginRepository.java | a14e5d6615d4355a3fdc66a0a0459ab9de40538e | []
| no_license | kmi17/reservation | https://github.com/kmi17/reservation | 4a9f9020e9916762896734de4a98f8f2c779c60d | 96889c1ba0a9c901140a9cde6b49bf2dec4d6f3f | refs/heads/master | 2022-10-08T23:20:24.325000 | 2022-09-30T02:52:20 | 2022-09-30T02:52:20 | 226,472,020 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.demo.repository;
import com.example.demo.entities.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface LoginRepository extends JpaRepository<User, Long> {
Optional<User> findByEmail(String username);
}
| UTF-8 | Java | 351 | java | LoginRepository.java | Java | []
| null | []
| package com.example.demo.repository;
import com.example.demo.entities.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface LoginRepository extends JpaRepository<User, Long> {
Optional<User> findByEmail(String username);
}
| 351 | 0.820513 | 0.820513 | 13 | 26 | 24.494898 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.538462 | false | false | 2 |
3f8a82474298a6bb01a0ae3c8efa548b0ab6994f | 14,834,817,070,105 | d5ba0c7a3c87038c993a92fed8e326ec2435b5ab | /src/main/java/pe/edu/upc/matriculaweb/models/repositories/SeccionRepository.java | a4001e3018b995056ecdc3c9907b2a850d8447b4 | []
| no_license | Jason280/matriculaweb-spring | https://github.com/Jason280/matriculaweb-spring | 1dc7ad5cb7923066329e3dd03a66f9221ba286da | 60d7c3d299757fbea899a8f09d6726c0ff733ea0 | refs/heads/main | 2023-05-28T10:22:40.125000 | 2021-06-12T18:48:13 | 2021-06-12T18:48:13 | 376,360,042 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pe.edu.upc.matriculaweb.models.repositories;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import pe.edu.upc.matriculaweb.models.entities.Seccion;
public interface SeccionRepository extends JpaRepository<Seccion, Integer> {
Optional<Seccion> findByTxSeccion(String txSeccion) throws Exception;
}
| UTF-8 | Java | 353 | java | SeccionRepository.java | Java | []
| null | []
| package pe.edu.upc.matriculaweb.models.repositories;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import pe.edu.upc.matriculaweb.models.entities.Seccion;
public interface SeccionRepository extends JpaRepository<Seccion, Integer> {
Optional<Seccion> findByTxSeccion(String txSeccion) throws Exception;
}
| 353 | 0.832861 | 0.832861 | 12 | 28.416666 | 30.431503 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.583333 | false | false | 2 |
074ad1deea3cf966d131e4dbf5e643a038102f7c | 2,576,980,447,135 | 375fbb9637d69865519fdfb69fb1d4134323e083 | /src/pja10_19032020/livingThing.java | d712f5f7ccf65f9668f5ba3b0262307d9ab233da | [
"Apache-2.0"
]
| permissive | Andi-IM/javaOOP | https://github.com/Andi-IM/javaOOP | b38afd62d2b00d6cc51baf6332ed135c53a2cd99 | 9a5884166898055bf5914a90a0476b8201986a13 | refs/heads/master | 2021-03-16T22:54:32.630000 | 2020-06-16T16:21:47 | 2020-06-16T16:21:47 | 246,950,658 | 0 | 0 | Apache-2.0 | false | 2020-05-16T17:20:04 | 2020-03-12T23:44:52 | 2020-05-14T06:31:06 | 2020-05-16T17:20:04 | 193 | 0 | 0 | 0 | Java | false | false | /*
* 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 pja10_19032020;
/**
*
* @author Andi
*/
public abstract class livingThing{
public void breath(){
System.out.println("Living Thing breathing...");
}
public void eat(){
System.out.println("Living Thing eating...");
}
/**
* abstract mehod walk
* Kita ingin mehthod ini di-overidden oleh subclasses
*/
public abstract void walk();
}
| UTF-8 | Java | 595 | java | livingThing.java | Java | [
{
"context": "or.\n */\npackage pja10_19032020;\n\n/**\n *\n * @author Andi\n */\npublic abstract class livingThing{\n public",
"end": 232,
"score": 0.9992313981056213,
"start": 228,
"tag": "NAME",
"value": "Andi"
}
]
| null | []
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pja10_19032020;
/**
*
* @author Andi
*/
public abstract class livingThing{
public void breath(){
System.out.println("Living Thing breathing...");
}
public void eat(){
System.out.println("Living Thing eating...");
}
/**
* abstract mehod walk
* Kita ingin mehthod ini di-overidden oleh subclasses
*/
public abstract void walk();
}
| 595 | 0.635294 | 0.618487 | 26 | 21.884615 | 22.424791 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.269231 | false | false | 2 |
d9808402f055c780605fc91fddc6c5c88d61585e | 20,057,497,307,010 | 2f312e18cdb2278224a6b1222a20d2a4a54abc8a | /src/AIPlayer.java | 4f26133516cb65e1bc8b697693cd7cf6ab6b8bcf | []
| no_license | zsoltpocsai/the_peculiar_expedition | https://github.com/zsoltpocsai/the_peculiar_expedition | 5f44f73a780d931749951a8f63876d9c4dfd52e8 | 60c30f987c0468ad613192c517e41c34ea89a5bf | refs/heads/master | 2021-07-19T10:26:27.101000 | 2020-08-19T13:59:07 | 2020-08-19T13:59:07 | 204,017,191 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class AIPlayer implements Famous, Comparable<Famous> {
private String name;
private int fame;
public AIPlayer(String name) {
this.name = name;
fame = 0;
}
public String getName() {
return name;
}
public void gainFame(int fame) {
this.fame += fame;
}
public int getFame() {
return fame;
}
public int compareTo(Famous player) {
return Famous.super.compareTo(player);
}
}
| UTF-8 | Java | 479 | java | AIPlayer.java | Java | []
| null | []
|
public class AIPlayer implements Famous, Comparable<Famous> {
private String name;
private int fame;
public AIPlayer(String name) {
this.name = name;
fame = 0;
}
public String getName() {
return name;
}
public void gainFame(int fame) {
this.fame += fame;
}
public int getFame() {
return fame;
}
public int compareTo(Famous player) {
return Famous.super.compareTo(player);
}
}
| 479 | 0.578288 | 0.5762 | 26 | 17.384615 | 16.597212 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.346154 | false | false | 2 |
b81ff7c33eae846ec00b5d41565565117488ea46 | 20,057,497,306,369 | d8cb688422ab9637b93bd7ca675f87352cc4748f | /app/src/main/java/com/example/lonse/util/AppSettingPopup.java | 169e226b29ac27b34884518b5890220b93cb7d40 | []
| no_license | Donwy/lonse | https://github.com/Donwy/lonse | ebee72c5b25c43b7d7dabe94935af75b54202103 | 7f99a39df3c28be3fd11a2ae44874210840b3843 | refs/heads/master | 2020-06-26T05:59:06.889000 | 2019-09-18T11:36:57 | 2019-09-18T11:36:57 | 199,552,867 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.lonse.util;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.lonse.R;
import com.example.lonse.view.BaseCustomPopup;
/**
* Created by dk on 2018/1/16.
*/
@SuppressWarnings("UnusedReturnValue")
public class AppSettingPopup extends BaseCustomPopup {
private LinearLayout content1;
private TextView sure, cancel, popTitle, content2, permissionTips;
private Context context;
private boolean isClick = false;
public AppSettingPopup(Context context) {
super(context);
this.context = context;
}
@Override
protected void initAttributes() {
setContentView(R.layout.app_setting_pop_layout,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
.setAnimationStyle(R.style.popo_show_from_center)
//是否允许点击PopupWindow之外的地方消失
.setFocusAndOutsideEnable(false)
//允许背景变暗
.setBackgroundDimEnable(true)
//变暗的透明度(0-1),0为完全透明
.setDimValue(0.5f)
//变暗的背景颜色
.setDimColor(Color.BLACK);
}
@Override
protected void initViews(View view) {
sure = getView(R.id.sure);
cancel = getView(R.id.cancel);
popTitle = getView(R.id.pop_title);
content1 = getView(R.id.content1);
content2 = getView(R.id.content2);
permissionTips = getView(R.id.permiss_tip);
content2.setMovementMethod(ScrollingMovementMethod.getInstance());
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
public AppSettingPopup sureTextOnClickListener(View.OnClickListener listener) {
if (listener != null) {
sure.setOnClickListener(listener);
}
return this;
}
public AppSettingPopup cancelTextOnClickListener(View.OnClickListener listener) {
if (listener != null) {
cancel.setOnClickListener(listener);
}
return this;
}
public AppSettingPopup setTitleText(String str) {
if (!TextUtils.isEmpty(str)) {
popTitle.setText(str);
}
return this;
}
public AppSettingPopup noTitle(){
if (popTitle != null){
popTitle.setText("");
popTitle.setVisibility(View.INVISIBLE);
}
return this;
}
public AppSettingPopup setSureText(String str) {
if (!TextUtils.isEmpty(str)) {
sure.setText(str);
}
return this;
}
public AppSettingPopup setContentText(String str) {
if (!TextUtils.isEmpty(str)) {
content1.setVisibility(View.GONE);
content2.setVisibility(View.VISIBLE);
content2.setText(str);
}
return this;
}
// public AppSettingPopup scroll(){
// if (content2 != null){
// content2.setMovementMethod(ScrollingMovementMethod.getInstance());
// }
// return this;
// }
public AppSettingPopup setPermissText(String str) {
if (!TextUtils.isEmpty(str)) {
permissionTips.setText(str);
}
return this;
}
public AppSettingPopup setOneButton(boolean b) {
if (b){
cancel.setVisibility(View.GONE);
}else {
cancel.setVisibility(View.VISIBLE);
}
return this;
}
public AppSettingPopup agreement(){
if (popTitle != null){
popTitle.setVisibility(View.GONE);
}
if (content1 != null){
content1.setVisibility(View.GONE);
}
if (content2 != null){
content2.setVisibility(View.VISIBLE);
}
return this;
}
public TextView getContentTextView(){
return content2;
}
public boolean isClick() {
return isClick;
}
public void setClick(boolean click) {
isClick = click;
}
}
| UTF-8 | Java | 4,362 | java | AppSettingPopup.java | Java | [
{
"context": "ple.lonse.view.BaseCustomPopup;\n\n/**\n * Created by dk on 2018/1/16.\n */\n\n@SuppressWarnings(\"UnusedRetur",
"end": 401,
"score": 0.9992629885673523,
"start": 399,
"tag": "USERNAME",
"value": "dk"
}
]
| null | []
| package com.example.lonse.util;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.lonse.R;
import com.example.lonse.view.BaseCustomPopup;
/**
* Created by dk on 2018/1/16.
*/
@SuppressWarnings("UnusedReturnValue")
public class AppSettingPopup extends BaseCustomPopup {
private LinearLayout content1;
private TextView sure, cancel, popTitle, content2, permissionTips;
private Context context;
private boolean isClick = false;
public AppSettingPopup(Context context) {
super(context);
this.context = context;
}
@Override
protected void initAttributes() {
setContentView(R.layout.app_setting_pop_layout,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
.setAnimationStyle(R.style.popo_show_from_center)
//是否允许点击PopupWindow之外的地方消失
.setFocusAndOutsideEnable(false)
//允许背景变暗
.setBackgroundDimEnable(true)
//变暗的透明度(0-1),0为完全透明
.setDimValue(0.5f)
//变暗的背景颜色
.setDimColor(Color.BLACK);
}
@Override
protected void initViews(View view) {
sure = getView(R.id.sure);
cancel = getView(R.id.cancel);
popTitle = getView(R.id.pop_title);
content1 = getView(R.id.content1);
content2 = getView(R.id.content2);
permissionTips = getView(R.id.permiss_tip);
content2.setMovementMethod(ScrollingMovementMethod.getInstance());
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
public AppSettingPopup sureTextOnClickListener(View.OnClickListener listener) {
if (listener != null) {
sure.setOnClickListener(listener);
}
return this;
}
public AppSettingPopup cancelTextOnClickListener(View.OnClickListener listener) {
if (listener != null) {
cancel.setOnClickListener(listener);
}
return this;
}
public AppSettingPopup setTitleText(String str) {
if (!TextUtils.isEmpty(str)) {
popTitle.setText(str);
}
return this;
}
public AppSettingPopup noTitle(){
if (popTitle != null){
popTitle.setText("");
popTitle.setVisibility(View.INVISIBLE);
}
return this;
}
public AppSettingPopup setSureText(String str) {
if (!TextUtils.isEmpty(str)) {
sure.setText(str);
}
return this;
}
public AppSettingPopup setContentText(String str) {
if (!TextUtils.isEmpty(str)) {
content1.setVisibility(View.GONE);
content2.setVisibility(View.VISIBLE);
content2.setText(str);
}
return this;
}
// public AppSettingPopup scroll(){
// if (content2 != null){
// content2.setMovementMethod(ScrollingMovementMethod.getInstance());
// }
// return this;
// }
public AppSettingPopup setPermissText(String str) {
if (!TextUtils.isEmpty(str)) {
permissionTips.setText(str);
}
return this;
}
public AppSettingPopup setOneButton(boolean b) {
if (b){
cancel.setVisibility(View.GONE);
}else {
cancel.setVisibility(View.VISIBLE);
}
return this;
}
public AppSettingPopup agreement(){
if (popTitle != null){
popTitle.setVisibility(View.GONE);
}
if (content1 != null){
content1.setVisibility(View.GONE);
}
if (content2 != null){
content2.setVisibility(View.VISIBLE);
}
return this;
}
public TextView getContentTextView(){
return content2;
}
public boolean isClick() {
return isClick;
}
public void setClick(boolean click) {
isClick = click;
}
}
| 4,362 | 0.599393 | 0.592627 | 156 | 26.47436 | 20.028648 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.397436 | false | false | 2 |
1b3cf2c7dfeac2e6ecddcd789c3f14101d2c6cd7 | 2,697,239,467,982 | c821b509c125c63f7c64223433a0e82a32770acb | /NeosoftTraining/src/SeleniumSessions/MouseMovementConcept.java | ad1ed09e861621095cbf5f8003ee0ec31e8c58a9 | []
| no_license | farhaan7/basic | https://github.com/farhaan7/basic | 133f802b8a5a361e034dfc472f77dea83e8bd456 | 23d766262e7f50730283e169c26b959cc92066c3 | refs/heads/master | 2023-08-17T16:51:44.028000 | 2021-10-04T10:41:33 | 2021-10-04T10:41:33 | 413,377,667 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package SeleniumSessions;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
public class MouseMovementConcept {
public static void main(String[] args) throws InterruptedException
{
System.setProperty("webdriver.chrome.driver", "C:\\Users\\user\\Downloads\\chromedriver_win32\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
//used to disable notifications like block and allow
//Add chrome switch to disable notification - "**--disable-notifications**"
options.addArguments("--disable-notifications");//to disable popup notifications
WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.get("https://www.bewakoof.com/");
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
Thread.sleep(5000);
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.linkText("MEN"))).build().perform();
Thread.sleep(3000);
driver.findElement(By.xpath("//span[normalize-space()='Full Sleeve T-Shirts']")).click();
driver.findElement(By.xpath("//img[@title=\"Men's Full Sleeve T-shirt Pack of 2(Black & Grey )-Front Bewakoof\"]")).click();
driver.findElement(By.xpath("//span[normalize-space()='M']")).click();
driver.findElement(By.xpath("//span[normalize-space()='ADD TO BAG']")).click();
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.findElement(By.xpath("//a[@hreflang='en-us']//span//i[@class='icon_bag']")).click();
}
}
| UTF-8 | Java | 1,819 | java | MouseMovementConcept.java | Java | []
| null | []
| package SeleniumSessions;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
public class MouseMovementConcept {
public static void main(String[] args) throws InterruptedException
{
System.setProperty("webdriver.chrome.driver", "C:\\Users\\user\\Downloads\\chromedriver_win32\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
//used to disable notifications like block and allow
//Add chrome switch to disable notification - "**--disable-notifications**"
options.addArguments("--disable-notifications");//to disable popup notifications
WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.get("https://www.bewakoof.com/");
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
Thread.sleep(5000);
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.linkText("MEN"))).build().perform();
Thread.sleep(3000);
driver.findElement(By.xpath("//span[normalize-space()='Full Sleeve T-Shirts']")).click();
driver.findElement(By.xpath("//img[@title=\"Men's Full Sleeve T-shirt Pack of 2(Black & Grey )-Front Bewakoof\"]")).click();
driver.findElement(By.xpath("//span[normalize-space()='M']")).click();
driver.findElement(By.xpath("//span[normalize-space()='ADD TO BAG']")).click();
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.findElement(By.xpath("//a[@hreflang='en-us']//span//i[@class='icon_bag']")).click();
}
}
| 1,819 | 0.725124 | 0.715778 | 52 | 33.98077 | 34.414047 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.903846 | false | false | 2 |
b5d0f6a7df44f81c3c928e3eb720514ad30d977a | 2,697,239,470,749 | 7f4407a49614b0149fcbddeee5286267f9990b82 | /app/src/main/java/com/wen_wen/firstsee/mvp/ui/fragment/ListenFragment.java | 9b7df69164b6f0b67b7e1528f7bfedab1025b1f8 | []
| no_license | CallHarryUp/FirstSee | https://github.com/CallHarryUp/FirstSee | 0dd5c24a47a96bc11d56591e18f609f3cbc73e8f | a84ea6caaad8fc6b14f39d6755e73855ab12835e | refs/heads/master | 2021-05-06T07:49:31.824000 | 2017-12-18T07:26:19 | 2017-12-18T07:26:19 | 113,966,874 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wen_wen.firstsee.mvp.ui.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.wen_wen.firstsee.R;
import com.wen_wen.firstsee.mvp.ui.adapter.TabAdapter;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
/**
* A simple {@link Fragment} subclass.
*/
public class ListenFragment extends BaseFragment {
@BindView(R.id.listen_tab)
TabLayout listenTab;
@BindView(R.id.listen_pager)
ViewPager listenPager;
private Unbinder unbind;
private List<String> tabList;
public ListenFragment() {
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initData();
}
private void initData() {
tabList = new ArrayList<>();
tabList.add("美图美句");
tabList.add("纸上心情");
tabList.add("电影对白");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_listen, container, false);
unbind = ButterKnife.bind(this, view);
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initView();
}
private void initView() {
listenTab.setTabMode(TabLayout.MODE_FIXED);
TabAdapter adapter = new TabAdapter(getFragmentManager(), tabList, "listen");
listenPager.setAdapter(adapter);
listenTab.setupWithViewPager(listenPager);
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbind.unbind();
}
}
| UTF-8 | Java | 2,081 | java | ListenFragment.java | Java | []
| null | []
| package com.wen_wen.firstsee.mvp.ui.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.wen_wen.firstsee.R;
import com.wen_wen.firstsee.mvp.ui.adapter.TabAdapter;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
/**
* A simple {@link Fragment} subclass.
*/
public class ListenFragment extends BaseFragment {
@BindView(R.id.listen_tab)
TabLayout listenTab;
@BindView(R.id.listen_pager)
ViewPager listenPager;
private Unbinder unbind;
private List<String> tabList;
public ListenFragment() {
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initData();
}
private void initData() {
tabList = new ArrayList<>();
tabList.add("美图美句");
tabList.add("纸上心情");
tabList.add("电影对白");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_listen, container, false);
unbind = ButterKnife.bind(this, view);
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initView();
}
private void initView() {
listenTab.setTabMode(TabLayout.MODE_FIXED);
TabAdapter adapter = new TabAdapter(getFragmentManager(), tabList, "listen");
listenPager.setAdapter(adapter);
listenTab.setupWithViewPager(listenPager);
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbind.unbind();
}
}
| 2,081 | 0.689353 | 0.688381 | 77 | 25.714285 | 21.419651 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.597403 | false | false | 2 |
f1b7aa411988380de6897d8a1291d90a63c4eaf3 | 7,258,494,737,384 | f0bd96edee770ddf256a5f6c326e6f24bad7a97f | /Analyse/wb/analyse1/util/Path.java | 7b6c1b53d725e0e4d7f91bf84fa39283effd81fe | []
| no_license | HajbaXC/VirtuHos-1 | https://github.com/HajbaXC/VirtuHos-1 | 8d516d0b1716dfc2e82f40addb999bcab553e12e | 6609c739e04bb8fb67022cad1425a279eb01c613 | refs/heads/master | 2023-02-21T00:14:23.571000 | 2021-01-18T02:48:09 | 2021-01-18T02:48:09 | 329,949,479 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package wb.analyse1.util;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Path stores a path of nodes of type N
*
* @param <N> type
*/
public class Path<N> {
private N startNode = null;
private N goalNode = null;
private ArrayList<N> path = new ArrayList<>();
// TODO maybe add a copy constructor
public Path() {
}
public Path(N start) {
this.startNode = start;
this.goalNode = start;
this.path.add(start);
}
public Path(ArrayList<N> path) {
this.startNode = path.get(0);
this.goalNode = path.get(path.size() - 1);
this.path = path;
}
public Path(N[] path) {
this.startNode = path[0];
this.goalNode = path[path.length - 1];
this.path.addAll(Arrays.asList(path));
}
/**
* Adds new node to the end of path and updates goal node.
*
* @param e node to insert
*/
public void addToPath(N e) {
if (this.startNode == null) {
this.startNode = e;
}
this.path.add(e);
this.goalNode = e;
}
public N getStart() {
return this.startNode;
}
public N getGoal() {
return this.goalNode;
}
public N get(int i) {
return this.path.get(i);
}
public int length() {
return this.path.size();
}
}
| UTF-8 | Java | 1,359 | java | Path.java | Java | []
| null | []
| package wb.analyse1.util;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Path stores a path of nodes of type N
*
* @param <N> type
*/
public class Path<N> {
private N startNode = null;
private N goalNode = null;
private ArrayList<N> path = new ArrayList<>();
// TODO maybe add a copy constructor
public Path() {
}
public Path(N start) {
this.startNode = start;
this.goalNode = start;
this.path.add(start);
}
public Path(ArrayList<N> path) {
this.startNode = path.get(0);
this.goalNode = path.get(path.size() - 1);
this.path = path;
}
public Path(N[] path) {
this.startNode = path[0];
this.goalNode = path[path.length - 1];
this.path.addAll(Arrays.asList(path));
}
/**
* Adds new node to the end of path and updates goal node.
*
* @param e node to insert
*/
public void addToPath(N e) {
if (this.startNode == null) {
this.startNode = e;
}
this.path.add(e);
this.goalNode = e;
}
public N getStart() {
return this.startNode;
}
public N getGoal() {
return this.goalNode;
}
public N get(int i) {
return this.path.get(i);
}
public int length() {
return this.path.size();
}
}
| 1,359 | 0.547461 | 0.543782 | 69 | 18.695652 | 16.089699 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.318841 | false | false | 2 |
76fb597e793b5e52ce175f1e53120f66ef1f175c | 28,716,151,380,110 | 6baf1fe00541560788e78de5244ae17a7a2b375a | /hollywood/com.oculus.socialplatform-base/sources/X/AnonymousClass1O7.java | 36230af2f5a4e803bfb8911689a4ba2296c20ec0 | []
| no_license | phwd/quest-tracker | https://github.com/phwd/quest-tracker | 286e605644fc05f00f4904e51f73d77444a78003 | 3d46fbb467ba11bee5827f7cae7dfeabeb1fd2ba | refs/heads/main | 2023-03-29T20:33:10.959000 | 2021-04-10T22:14:11 | 2021-04-10T22:14:11 | 357,185,040 | 4 | 2 | null | true | 2021-04-12T12:28:09 | 2021-04-12T12:28:08 | 2021-04-10T22:15:44 | 2021-04-10T22:15:39 | 116,441 | 0 | 0 | 0 | null | false | false | package X;
import com.facebook.msys.mci.network.common.DataTaskListener;
import com.facebook.msys.mci.network.common.UrlRequest;
import com.facebook.msys.mci.network.common.UrlResponse;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/* renamed from: X.1O7 reason: invalid class name */
public final class AnonymousClass1O7 {
public int A00;
public final DataTaskListener A01 = new AnonymousClass1O4(this);
public final File A02;
public final String A03;
public final ExecutorService A04 = Executors.newFixedThreadPool(6, new AnonymousClass1OP(this));
public AnonymousClass1O7(String str, File file) {
this.A03 = str;
this.A02 = file;
}
public static UrlResponse A00(AnonymousClass1O7 r11, String str, UrlRequest urlRequest, AnonymousClass1O1 r14, OutputStream outputStream, boolean z, boolean z2) throws IOException {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(urlRequest.getUrl()).openConnection();
httpURLConnection.setDoInput(true);
int i = r11.A00;
if (i > 0) {
httpURLConnection.setConnectTimeout(i);
httpURLConnection.setReadTimeout(r11.A00);
}
try {
byte[] httpBody = urlRequest.getHttpBody();
Map<String, String> httpHeaders = urlRequest.getHttpHeaders();
if (httpBody != null) {
httpURLConnection.setDoOutput(true);
httpURLConnection.setFixedLengthStreamingMode(httpBody.length);
}
httpURLConnection.setRequestMethod(urlRequest.getHttpMethod());
for (Map.Entry<String, String> entry : httpHeaders.entrySet()) {
httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
}
httpURLConnection.setRequestProperty("User-Agent", r11.A03);
if (httpBody != null && httpURLConnection.getDoOutput()) {
OutputStream outputStream2 = httpURLConnection.getOutputStream();
try {
int length = httpBody.length;
int i2 = length;
int i3 = 0;
while (i3 < length) {
int min = Math.min(10240, i2);
outputStream2.write(httpBody, i3, min);
i2 -= min;
i3 += min;
if (z) {
r14.executeInNetworkContext(new AnonymousClass1O5(r11, r14, str, min, i3, httpBody));
}
}
if (outputStream2 != null) {
outputStream2.close();
}
} catch (Throwable unused) {
}
}
try {
InputStream inputStream = httpURLConnection.getInputStream();
try {
int contentLength = httpURLConnection.getContentLength();
byte[] bArr = new byte[10240];
int i4 = 0;
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
break;
}
outputStream.write(bArr, 0, read);
i4 += read;
if (z2) {
r14.executeInNetworkContext(new AnonymousClass1O6(r11, r14, str, read, i4, contentLength));
}
}
inputStream.close();
} catch (Throwable unused2) {
}
} catch (IOException unused3) {
int responseCode = httpURLConnection.getResponseCode();
if (responseCode >= 400 && responseCode <= 500) {
InputStream errorStream = httpURLConnection.getErrorStream();
String format = String.format(null, "[HTTP status=%d] Error Content = ", Integer.valueOf(responseCode));
if (errorStream != null) {
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr2 = new byte[1024];
while (true) {
int read2 = errorStream.read(bArr2);
if (read2 == -1) {
break;
}
byteArrayOutputStream.write(bArr2, 0, read2);
}
format = AnonymousClass006.A07(format, byteArrayOutputStream.toString());
} catch (IOException unused4) {
} catch (Throwable th) {
errorStream.close();
throw th;
}
}
errorStream.close();
throw new IOException(format);
}
}
int responseCode2 = httpURLConnection.getResponseCode();
Map<String, List<String>> headerFields = httpURLConnection.getHeaderFields();
HashMap hashMap = new HashMap();
for (Map.Entry<String, List<String>> entry2 : headerFields.entrySet()) {
if (entry2.getKey() != null) {
List<String> value = entry2.getValue();
if (value.size() == 1) {
hashMap.put(entry2.getKey(), entry2.getValue().get(0));
} else if (value.size() > 1) {
StringBuilder sb = new StringBuilder(value.size() << 4);
for (int i5 = 1; i5 < value.size(); i5++) {
sb.append(',');
sb.append(value.get(i5));
}
hashMap.put(entry2.getKey(), sb.toString());
}
}
}
UrlResponse urlResponse = new UrlResponse(urlRequest, responseCode2, hashMap);
httpURLConnection.getResponseCode();
return urlResponse;
throw th;
throw th;
} finally {
httpURLConnection.disconnect();
}
}
}
| UTF-8 | Java | 6,656 | java | AnonymousClass1O7.java | Java | []
| null | []
| package X;
import com.facebook.msys.mci.network.common.DataTaskListener;
import com.facebook.msys.mci.network.common.UrlRequest;
import com.facebook.msys.mci.network.common.UrlResponse;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/* renamed from: X.1O7 reason: invalid class name */
public final class AnonymousClass1O7 {
public int A00;
public final DataTaskListener A01 = new AnonymousClass1O4(this);
public final File A02;
public final String A03;
public final ExecutorService A04 = Executors.newFixedThreadPool(6, new AnonymousClass1OP(this));
public AnonymousClass1O7(String str, File file) {
this.A03 = str;
this.A02 = file;
}
public static UrlResponse A00(AnonymousClass1O7 r11, String str, UrlRequest urlRequest, AnonymousClass1O1 r14, OutputStream outputStream, boolean z, boolean z2) throws IOException {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(urlRequest.getUrl()).openConnection();
httpURLConnection.setDoInput(true);
int i = r11.A00;
if (i > 0) {
httpURLConnection.setConnectTimeout(i);
httpURLConnection.setReadTimeout(r11.A00);
}
try {
byte[] httpBody = urlRequest.getHttpBody();
Map<String, String> httpHeaders = urlRequest.getHttpHeaders();
if (httpBody != null) {
httpURLConnection.setDoOutput(true);
httpURLConnection.setFixedLengthStreamingMode(httpBody.length);
}
httpURLConnection.setRequestMethod(urlRequest.getHttpMethod());
for (Map.Entry<String, String> entry : httpHeaders.entrySet()) {
httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
}
httpURLConnection.setRequestProperty("User-Agent", r11.A03);
if (httpBody != null && httpURLConnection.getDoOutput()) {
OutputStream outputStream2 = httpURLConnection.getOutputStream();
try {
int length = httpBody.length;
int i2 = length;
int i3 = 0;
while (i3 < length) {
int min = Math.min(10240, i2);
outputStream2.write(httpBody, i3, min);
i2 -= min;
i3 += min;
if (z) {
r14.executeInNetworkContext(new AnonymousClass1O5(r11, r14, str, min, i3, httpBody));
}
}
if (outputStream2 != null) {
outputStream2.close();
}
} catch (Throwable unused) {
}
}
try {
InputStream inputStream = httpURLConnection.getInputStream();
try {
int contentLength = httpURLConnection.getContentLength();
byte[] bArr = new byte[10240];
int i4 = 0;
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
break;
}
outputStream.write(bArr, 0, read);
i4 += read;
if (z2) {
r14.executeInNetworkContext(new AnonymousClass1O6(r11, r14, str, read, i4, contentLength));
}
}
inputStream.close();
} catch (Throwable unused2) {
}
} catch (IOException unused3) {
int responseCode = httpURLConnection.getResponseCode();
if (responseCode >= 400 && responseCode <= 500) {
InputStream errorStream = httpURLConnection.getErrorStream();
String format = String.format(null, "[HTTP status=%d] Error Content = ", Integer.valueOf(responseCode));
if (errorStream != null) {
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr2 = new byte[1024];
while (true) {
int read2 = errorStream.read(bArr2);
if (read2 == -1) {
break;
}
byteArrayOutputStream.write(bArr2, 0, read2);
}
format = AnonymousClass006.A07(format, byteArrayOutputStream.toString());
} catch (IOException unused4) {
} catch (Throwable th) {
errorStream.close();
throw th;
}
}
errorStream.close();
throw new IOException(format);
}
}
int responseCode2 = httpURLConnection.getResponseCode();
Map<String, List<String>> headerFields = httpURLConnection.getHeaderFields();
HashMap hashMap = new HashMap();
for (Map.Entry<String, List<String>> entry2 : headerFields.entrySet()) {
if (entry2.getKey() != null) {
List<String> value = entry2.getValue();
if (value.size() == 1) {
hashMap.put(entry2.getKey(), entry2.getValue().get(0));
} else if (value.size() > 1) {
StringBuilder sb = new StringBuilder(value.size() << 4);
for (int i5 = 1; i5 < value.size(); i5++) {
sb.append(',');
sb.append(value.get(i5));
}
hashMap.put(entry2.getKey(), sb.toString());
}
}
}
UrlResponse urlResponse = new UrlResponse(urlRequest, responseCode2, hashMap);
httpURLConnection.getResponseCode();
return urlResponse;
throw th;
throw th;
} finally {
httpURLConnection.disconnect();
}
}
}
| 6,656 | 0.506611 | 0.486028 | 147 | 44.278912 | 28.692074 | 185 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.843537 | false | false | 2 |
775d6d60023f6c84f7278a8b06f0106345ea06e7 | 1,116,691,501,654 | 6219f6b43cf0dc307506f66e1df147893071abcc | /redis/src/main/java/com/springbootexample/redis/model/TestVO.java | 6b9ea17688aad3b48cccd5c8c357acfa87de6b9d | []
| no_license | mypiece/springboot-example | https://github.com/mypiece/springboot-example | 7d890caddf874cd58ac20a09ae1e11e524c26114 | 53375302fc841b8b1c6ae240ca716f26fbf5b2c0 | refs/heads/master | 2023-04-01T22:20:08.690000 | 2021-04-22T23:44:22 | 2021-04-22T23:44:22 | 348,615,470 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.springbootexample.redis.model;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
@Getter
@EqualsAndHashCode
@ToString
@NoArgsConstructor
public class TestVO {
private String name;
private int age;
@Builder
public TestVO(String name, int age) {
this.name = name;
this.age = age;
}
}
| UTF-8 | Java | 392 | java | TestVO.java | Java | []
| null | []
| package com.springbootexample.redis.model;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
@Getter
@EqualsAndHashCode
@ToString
@NoArgsConstructor
public class TestVO {
private String name;
private int age;
@Builder
public TestVO(String name, int age) {
this.name = name;
this.age = age;
}
}
| 392 | 0.77551 | 0.77551 | 23 | 16.043478 | 12.291667 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.869565 | false | false | 2 |
7a5c7c3d5e4e520c64ba32a11c50d73c85bc9cf6 | 32,255,204,423,409 | a51bcad981d3efae2354c48e5e73de007073e35a | /back-end/src/main/java/com/security/demospringsecurity/service/impl/QuestionServiceImpl.java | 7a158c98b95c35839fb66a4fd1cad43adfb4c83a | []
| no_license | nguyenanhptit/BlueBird-Hackathon | https://github.com/nguyenanhptit/BlueBird-Hackathon | 84d6cc8726a9204c5922864462300d31c75881e6 | 588bb8dce22782fff3f6e4fe696ff15848e825d0 | refs/heads/master | 2023-01-20T03:29:01.483000 | 2019-06-15T16:19:16 | 2019-06-15T16:19:16 | 190,947,811 | 0 | 0 | null | false | 2023-01-07T06:12:51 | 2019-06-09T00:26:34 | 2019-06-15T16:19:50 | 2023-01-07T06:12:51 | 45,707 | 0 | 0 | 27 | Java | false | false | package com.security.demospringsecurity.service.impl;
import com.security.demospringsecurity.model.Question;
import com.security.demospringsecurity.repository.QuestionRepository;
import com.security.demospringsecurity.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class QuestionServiceImpl implements QuestionService {
@Autowired
QuestionRepository questionRepository;
@Override
public Iterable<Question> findAll() {
return questionRepository.findAll();
}
@Override
public Question findById(Long id) {
return questionRepository.findById(id).get();
}
} | UTF-8 | Java | 710 | java | QuestionServiceImpl.java | Java | []
| null | []
| package com.security.demospringsecurity.service.impl;
import com.security.demospringsecurity.model.Question;
import com.security.demospringsecurity.repository.QuestionRepository;
import com.security.demospringsecurity.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class QuestionServiceImpl implements QuestionService {
@Autowired
QuestionRepository questionRepository;
@Override
public Iterable<Question> findAll() {
return questionRepository.findAll();
}
@Override
public Question findById(Long id) {
return questionRepository.findById(id).get();
}
} | 710 | 0.787324 | 0.787324 | 25 | 27.440001 | 25.037699 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.36 | false | false | 2 |
db5bca6a189dd68cbbd376bf340afb9d65f6fc3f | 10,101,763,100,045 | c56c7d79260ec17fa605664dbb2a16ee0926ed96 | /hero/src/main/java/com/herocorp/ui/activities/DSEapp/models/Tehsil.java | 319c36361517f55f780ca0726c38fac40e5837a9 | []
| no_license | Raul345/MyHeroCorp | https://github.com/Raul345/MyHeroCorp | e7a154687357a47a4e36b4e3caaa384f5f0cfe20 | fff98a7c1691973b8f2d017d10e5188c54d743b7 | refs/heads/master | 2020-12-02T22:19:56.331000 | 2017-07-16T06:13:42 | 2017-07-16T06:13:42 | 74,053,239 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.herocorp.ui.activities.DSEapp.models;
/**
* Created by rsawh on 30-Sep-16.
*/
public class Tehsil {
String id;
String tehsil;
String district_id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDistrict_id() {
return district_id;
}
public void setDistrict_id(String district_id) {
this.district_id = district_id;
}
public String getTehsil() {
return tehsil;
}
public void setTehsil(String tehsil) {
this.tehsil = tehsil;
}
public String toString() {
return tehsil;
}
public Tehsil(String district_id, String id, String tehsil) {
this.district_id = district_id;
this.id = id;
this.tehsil = tehsil;
}
}
| UTF-8 | Java | 834 | java | Tehsil.java | Java | [
{
"context": "rp.ui.activities.DSEapp.models;\n\n/**\n * Created by rsawh on 30-Sep-16.\n */\npublic class Tehsil {\n Strin",
"end": 74,
"score": 0.9992644190788269,
"start": 69,
"tag": "USERNAME",
"value": "rsawh"
}
]
| null | []
| package com.herocorp.ui.activities.DSEapp.models;
/**
* Created by rsawh on 30-Sep-16.
*/
public class Tehsil {
String id;
String tehsil;
String district_id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDistrict_id() {
return district_id;
}
public void setDistrict_id(String district_id) {
this.district_id = district_id;
}
public String getTehsil() {
return tehsil;
}
public void setTehsil(String tehsil) {
this.tehsil = tehsil;
}
public String toString() {
return tehsil;
}
public Tehsil(String district_id, String id, String tehsil) {
this.district_id = district_id;
this.id = id;
this.tehsil = tehsil;
}
}
| 834 | 0.582734 | 0.577938 | 45 | 17.533333 | 16.817451 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.355556 | false | false | 2 |
9140700712c4e6a3a068bdbe5a6c6cf1c2c57c63 | 35,107,062,681,118 | faef3621016d4cd93a94fac193644d176880138f | /src/Tutorial74_76.java | 70511454d1cbe606aacac718b9b33510104b7159 | []
| no_license | pablotebb/BuckyJavaPrincipiantesComentado | https://github.com/pablotebb/BuckyJavaPrincipiantesComentado | 17ce3dd80ab8e82f37ab055b4a895f9f510f9bae | 65d6dfba2d5a8aab83aee7a92a351292f186d021 | refs/heads/master | 2016-09-06T18:13:45.928000 | 2014-02-25T12:56:56 | 2014-02-25T12:56:56 | 17,172,787 | 2 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Tutorial74_76 extends JFrame{
private JPanel mousePanel;
private JLabel statusBar;
public static void main(String args[ ]) { // método principal
Tutorial74_76 gui = new Tutorial74_76();
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gui.setSize(350, 200);
gui.setVisible(true);
}
/**
* Constructor
*/
Tutorial74_76() { // Constructor
super("Title: mouse actions");
mousePanel = new JPanel(); // creamos JPanel...
mousePanel.setBackground(Color.BLUE); // aplicamos color de fonod azul al JPanel...
add(mousePanel, BorderLayout.CENTER); // añadimos JPanel al JFrame (aplicandole un diseño y situandolo en su centro)
statusBar = new JLabel("Go on - do something"); // creamos JLabel...
add(statusBar, BorderLayout.SOUTH); // añadimos JLabel al JFrame (aplicándole diseño y situándolo abajo)
HandlerClass handler = new HandlerClass(); // instanciamos clase...
mousePanel.addMouseListener(handler); // añadimos vigilante, pasándole la clase...
mousePanel.addMouseMotionListener(handler); // idem...
}
/**
* clase: HandlerClass
*
* @implements: MouseListener, MouseMotionListener
*
*/
private class HandlerClass implements MouseListener, MouseMotionListener {
/**
* métodos implementados del interface MouseListener
*/
public void mouseClicked(MouseEvent event) {
statusBar.setText(String.format("Mouse clicked at %d, %d", event.getX(), event.getY()));
}
public void mouseEntered(MouseEvent event) { // cuando entra el ratón, el fondo se pone rojo
mousePanel.setBackground(Color.RED);
}
public void mouseExited(MouseEvent event) { // cuando sale el ratón, el fondo se pone azul
mousePanel.setBackground(Color.BLUE);
}
public void mousePressed(MouseEvent event) {
statusBar.setText("You pressed the button");
}
public void mouseReleased(MouseEvent event) {
statusBar.setText("You have released the button");
}
/**
* métodos implementados del interface MouseMotionListener
*/
public void mouseDragged(MouseEvent event) {
statusBar.setText("You are dragging the mouse");
}
public void mouseMoved(MouseEvent event) {
statusBar.setText("You moved the mouse");
}
}
}
| ISO-8859-1 | Java | 2,850 | java | Tutorial74_76.java | Java | []
| null | []
| import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Tutorial74_76 extends JFrame{
private JPanel mousePanel;
private JLabel statusBar;
public static void main(String args[ ]) { // método principal
Tutorial74_76 gui = new Tutorial74_76();
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gui.setSize(350, 200);
gui.setVisible(true);
}
/**
* Constructor
*/
Tutorial74_76() { // Constructor
super("Title: mouse actions");
mousePanel = new JPanel(); // creamos JPanel...
mousePanel.setBackground(Color.BLUE); // aplicamos color de fonod azul al JPanel...
add(mousePanel, BorderLayout.CENTER); // añadimos JPanel al JFrame (aplicandole un diseño y situandolo en su centro)
statusBar = new JLabel("Go on - do something"); // creamos JLabel...
add(statusBar, BorderLayout.SOUTH); // añadimos JLabel al JFrame (aplicándole diseño y situándolo abajo)
HandlerClass handler = new HandlerClass(); // instanciamos clase...
mousePanel.addMouseListener(handler); // añadimos vigilante, pasándole la clase...
mousePanel.addMouseMotionListener(handler); // idem...
}
/**
* clase: HandlerClass
*
* @implements: MouseListener, MouseMotionListener
*
*/
private class HandlerClass implements MouseListener, MouseMotionListener {
/**
* métodos implementados del interface MouseListener
*/
public void mouseClicked(MouseEvent event) {
statusBar.setText(String.format("Mouse clicked at %d, %d", event.getX(), event.getY()));
}
public void mouseEntered(MouseEvent event) { // cuando entra el ratón, el fondo se pone rojo
mousePanel.setBackground(Color.RED);
}
public void mouseExited(MouseEvent event) { // cuando sale el ratón, el fondo se pone azul
mousePanel.setBackground(Color.BLUE);
}
public void mousePressed(MouseEvent event) {
statusBar.setText("You pressed the button");
}
public void mouseReleased(MouseEvent event) {
statusBar.setText("You have released the button");
}
/**
* métodos implementados del interface MouseMotionListener
*/
public void mouseDragged(MouseEvent event) {
statusBar.setText("You are dragging the mouse");
}
public void mouseMoved(MouseEvent event) {
statusBar.setText("You moved the mouse");
}
}
}
| 2,850 | 0.631301 | 0.623546 | 78 | 35.371796 | 30.388977 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.974359 | false | false | 2 |
977ba1aac61c57977451e9eed8dfcae295c1ebb9 | 2,774,548,911,702 | cde102f00a743d7b92d99598c02235022efb5557 | /Application/back-end/Java/gceval/src/main/java/br/com/GCEval/resource/UserTypeResource.java | 1dd724a3f2a5900aa74bf02c06b586ef4827680c | [
"Apache-2.0"
]
| permissive | magnocarvalho/CSM-Seknow | https://github.com/magnocarvalho/CSM-Seknow | bf8144d3cb5c4da62cb3889cba23a29bfb7e61a0 | e4f315e2d7be024a7caea9dfe9d4461afd33402f | refs/heads/master | 2022-07-21T03:07:45.096000 | 2022-06-14T17:37:04 | 2022-06-14T17:37:04 | 255,673,105 | 0 | 0 | null | true | 2020-04-14T17:09:03 | 2020-04-14T17:09:02 | 2020-04-14T16:33:13 | 2019-07-16T13:09:07 | 2,706 | 0 | 0 | 0 | null | false | false | package br.com.GCEval.resource;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import br.com.GCEval.model.Section;
import br.com.GCEval.model.Usertype;
import br.com.GCEval.repository.UserTypeRepository;
@RestController
@RequestMapping("/usertypes")
public class UserTypeResource {
@Autowired
private UserTypeRepository userTypeRepository;
@GetMapping
public List<Usertype> findAll() {
return userTypeRepository.findAll();
}
@GetMapping("/{id}")
public Optional<Usertype> findById(@PathVariable Integer id) {
Optional<Usertype> usertypes = userTypeRepository.findById(id);
return usertypes;
}
}
| UTF-8 | Java | 943 | java | UserTypeResource.java | Java | []
| null | []
| package br.com.GCEval.resource;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import br.com.GCEval.model.Section;
import br.com.GCEval.model.Usertype;
import br.com.GCEval.repository.UserTypeRepository;
@RestController
@RequestMapping("/usertypes")
public class UserTypeResource {
@Autowired
private UserTypeRepository userTypeRepository;
@GetMapping
public List<Usertype> findAll() {
return userTypeRepository.findAll();
}
@GetMapping("/{id}")
public Optional<Usertype> findById(@PathVariable Integer id) {
Optional<Usertype> usertypes = userTypeRepository.findById(id);
return usertypes;
}
}
| 943 | 0.797455 | 0.797455 | 39 | 23.179487 | 23.151531 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.974359 | false | false | 2 |
6a5b75fe762beef11bb79b0d2666a41fda88691e | 13,426,067,790,378 | 57640c7c2fdeb4f776e2ec915f7ec26e82890cd2 | /src/main/java/com/spring/projektKsiegarnia/demo_ksiegarnia/ksiazka/URLController.java | 7f5f637b1212a86dff3bbc8b800827b653199fef | []
| no_license | Gabriela-Kowalczuk/Bookstore-Gabi | https://github.com/Gabriela-Kowalczuk/Bookstore-Gabi | 0a83377826bc85e8496dbb50c4abfb1d251f4803 | be264f21eb60991ce249d907b3e19416e092c556 | refs/heads/master | 2023-02-28T11:57:46.288000 | 2021-02-07T19:03:56 | 2021-02-07T19:03:56 | 336,868,175 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.spring.projektKsiegarnia.demo_ksiegarnia.ksiazka;
import com.spring.projektKsiegarnia.demo_ksiegarnia.ksiazka.Ksiazka;
import com.spring.projektKsiegarnia.demo_ksiegarnia.ksiazka.KsiazkaRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.Optional;
@Controller
public class URLController {
private KsiazkaRepository ksiazkaRepository;
@Autowired
public URLController(KsiazkaRepository itemRepository) {
this.ksiazkaRepository = itemRepository;
}
@GetMapping("/ksiazka/{id}")
public String getKsiazka(@PathVariable Long id, Model model) {
Optional<Ksiazka> ksiazka = ksiazkaRepository.findById(id);
ksiazka.ifPresent(it -> model.addAttribute("ksiazka", it));
return ksiazka.map(it -> "ksiazka").orElse("redirect:/");
}
}
| UTF-8 | Java | 1,046 | java | URLController.java | Java | []
| null | []
| package com.spring.projektKsiegarnia.demo_ksiegarnia.ksiazka;
import com.spring.projektKsiegarnia.demo_ksiegarnia.ksiazka.Ksiazka;
import com.spring.projektKsiegarnia.demo_ksiegarnia.ksiazka.KsiazkaRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.Optional;
@Controller
public class URLController {
private KsiazkaRepository ksiazkaRepository;
@Autowired
public URLController(KsiazkaRepository itemRepository) {
this.ksiazkaRepository = itemRepository;
}
@GetMapping("/ksiazka/{id}")
public String getKsiazka(@PathVariable Long id, Model model) {
Optional<Ksiazka> ksiazka = ksiazkaRepository.findById(id);
ksiazka.ifPresent(it -> model.addAttribute("ksiazka", it));
return ksiazka.map(it -> "ksiazka").orElse("redirect:/");
}
}
| 1,046 | 0.774379 | 0.774379 | 30 | 33.866665 | 27.84808 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.533333 | false | false | 2 |
e49f77a06c766bd442ad8f9aad01042d0cdf2e8a | 14,705,968,029,476 | 3ff9294aea0c2aae14ef2dffaee575f81e7bf234 | /src/listeners/HitListener.java | 13ec04f8c529a2edbbef2f6f74dff16c70bfd42a | []
| no_license | sarahdepaz/Vintage_Game_Arkanoid | https://github.com/sarahdepaz/Vintage_Game_Arkanoid | d34288860ef025812949d15e5da98109218276ce | 67699efcf8196f9814d09a0e31e70b15f71f4daa | refs/heads/master | 2022-02-27T15:12:54.884000 | 2019-11-08T11:32:05 | 2019-11-08T11:32:05 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package listeners;
import elements.Ball;
import elements.Block;
/**
* Interface of a HitListener.
*
* @author sarah de paz
*/
public interface HitListener {
/**
* function that called whenever the beingHit object is hit the hitter
* parameter is the Ball that's doing the hitting.
*
* @param beingHit
* the beingHit object
* @param hitter
* the hitter parameter
*/
void hitEvent(Block beingHit, Ball hitter);
} | UTF-8 | Java | 486 | java | HitListener.java | Java | [
{
"context": "\n\n/**\n * Interface of a HitListener.\n *\n * @author sarah de paz\n */\npublic interface HitListener {\n /**\n *",
"end": 127,
"score": 0.9998329281806946,
"start": 115,
"tag": "NAME",
"value": "sarah de paz"
}
]
| null | []
| package listeners;
import elements.Ball;
import elements.Block;
/**
* Interface of a HitListener.
*
* @author <NAME>
*/
public interface HitListener {
/**
* function that called whenever the beingHit object is hit the hitter
* parameter is the Ball that's doing the hitting.
*
* @param beingHit
* the beingHit object
* @param hitter
* the hitter parameter
*/
void hitEvent(Block beingHit, Ball hitter);
} | 480 | 0.631687 | 0.631687 | 22 | 21.136364 | 19.31155 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.227273 | false | false | 2 |
6aa3da9fb34c7d91d285b6081ed335a47d3e2714 | 25,890,062,872,530 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/13/13_968825b3bc8eef2abf085bf4ee676944c090ca8a/bFundamentals/13_968825b3bc8eef2abf085bf4ee676944c090ca8a_bFundamentals_s.java | 0453b8f10ec4e6c32748282eab00ea1d3865d694 | []
| no_license | zhongxingyu/Seer | https://github.com/zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516000 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | false | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | 2023-06-21T00:53:27 | 2023-06-22T07:55:57 | 2,849,868 | 2 | 2 | 0 | null | false | false | package uk.codingbadgers.bFundamentals;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import uk.codingbadgers.bFundamentals.module.Module;
public class bFundamentals extends JavaPlugin {
private static bFundamentals m_instance;
private static final Logger log = Logger.getLogger("bFundamentals");
private ModuleLoader m_moduleLoader = null;
@Override
public void onEnable() {
m_instance = this;
getConfig().options().copyDefaults(true);
saveConfig();
// load the modules in
m_moduleLoader = new ModuleLoader();
m_moduleLoader.load();
m_moduleLoader.enable();
bFundamentals.log(Level.INFO, "bFundamentals Loaded.");
}
@Override
public void onDisable() {
bFundamentals.log(Level.INFO, "bFundamentals Disabled.");
m_moduleLoader.disable();
}
public static bFundamentals getInstance() {
return m_instance;
}
public static void log(Level level, String msg) {
log.log(level, "[" + m_instance.getDescription().getName() +"] " + msg);
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("bfundamentals")) {
handleCommand(sender, cmd, label, args);
return true;
}
if (label.equalsIgnoreCase("modules")) {
handleModulesCommand(sender);
return true;
}
return m_moduleLoader.onCommand(sender, cmd, label, args);
}
private void handleModulesCommand(CommandSender sender) {
List<Module> modules = m_moduleLoader.getModules();
String moduleString = "";
boolean first = true;
for (Module module : modules)
moduleString += (first ? "" : ", ") + module.getName();
sender.sendMessage(moduleString);
}
private void handleCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length > 1) {
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "/bFundamentals");
return;
}
if (args[0].equalsIgnoreCase("reload")) {
this.getPluginLoader().disablePlugin(this);
this.getPluginLoader().enablePlugin(this);
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "Reloading plugin");
return;
}
if (args[0].equalsIgnoreCase("module")) {
if (args.length < 2) {
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "use /bFundamentals <reload/load>");
return;
}
if (args[1].equalsIgnoreCase("unload")) {
m_moduleLoader.unload();
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "UnLoaded all modules");
return;
}
if (args[1].equalsIgnoreCase("load")) {
m_moduleLoader.load();
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "Loaded all modules");
return;
}
if (args[1].equalsIgnoreCase("reload")) {
m_moduleLoader.unload();
m_moduleLoader.load();
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "Reloaded all modules");
return;
}
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "use /bFundamentals <reload/load>");
return;
}
}
public void disable(Module module) {
m_moduleLoader.unload(module);
}
}
| UTF-8 | Java | 3,670 | java | 13_968825b3bc8eef2abf085bf4ee676944c090ca8a_bFundamentals_s.java | Java | []
| null | []
| package uk.codingbadgers.bFundamentals;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import uk.codingbadgers.bFundamentals.module.Module;
public class bFundamentals extends JavaPlugin {
private static bFundamentals m_instance;
private static final Logger log = Logger.getLogger("bFundamentals");
private ModuleLoader m_moduleLoader = null;
@Override
public void onEnable() {
m_instance = this;
getConfig().options().copyDefaults(true);
saveConfig();
// load the modules in
m_moduleLoader = new ModuleLoader();
m_moduleLoader.load();
m_moduleLoader.enable();
bFundamentals.log(Level.INFO, "bFundamentals Loaded.");
}
@Override
public void onDisable() {
bFundamentals.log(Level.INFO, "bFundamentals Disabled.");
m_moduleLoader.disable();
}
public static bFundamentals getInstance() {
return m_instance;
}
public static void log(Level level, String msg) {
log.log(level, "[" + m_instance.getDescription().getName() +"] " + msg);
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("bfundamentals")) {
handleCommand(sender, cmd, label, args);
return true;
}
if (label.equalsIgnoreCase("modules")) {
handleModulesCommand(sender);
return true;
}
return m_moduleLoader.onCommand(sender, cmd, label, args);
}
private void handleModulesCommand(CommandSender sender) {
List<Module> modules = m_moduleLoader.getModules();
String moduleString = "";
boolean first = true;
for (Module module : modules)
moduleString += (first ? "" : ", ") + module.getName();
sender.sendMessage(moduleString);
}
private void handleCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length > 1) {
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "/bFundamentals");
return;
}
if (args[0].equalsIgnoreCase("reload")) {
this.getPluginLoader().disablePlugin(this);
this.getPluginLoader().enablePlugin(this);
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "Reloading plugin");
return;
}
if (args[0].equalsIgnoreCase("module")) {
if (args.length < 2) {
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "use /bFundamentals <reload/load>");
return;
}
if (args[1].equalsIgnoreCase("unload")) {
m_moduleLoader.unload();
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "UnLoaded all modules");
return;
}
if (args[1].equalsIgnoreCase("load")) {
m_moduleLoader.load();
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "Loaded all modules");
return;
}
if (args[1].equalsIgnoreCase("reload")) {
m_moduleLoader.unload();
m_moduleLoader.load();
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "Reloaded all modules");
return;
}
sender.sendMessage(ChatColor.DARK_AQUA + "[bFundamentals] " + ChatColor.WHITE + "use /bFundamentals <reload/load>");
return;
}
}
public void disable(Module module) {
m_moduleLoader.unload(module);
}
}
| 3,670 | 0.648501 | 0.646594 | 122 | 28.073771 | 29.521364 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.557377 | false | false | 2 |
31f6a625823227ca284d207662d4bd9ea968e154 | 29,446,295,787,642 | 9fcf05729b131e40eedb8bbc1b2e04dbf6f02c98 | /Java/Examples/zombiedefence(0.5)/src/org/test/zombiedefence/BloodSplatter.java | e9f227cea70c461dcd875fe1c3488ed92087b278 | [
"Apache-2.0"
]
| permissive | choiyongwoo/LGame | https://github.com/choiyongwoo/LGame | 68661774ca4c913e8fae8378a2f291939430fa37 | f007cee4c017702d5dd3d7966cb99b3c69bec616 | refs/heads/master | 2020-05-29T13:39:00.447000 | 2019-05-28T01:30:53 | 2019-05-28T01:30:53 | 189,168,503 | 1 | 0 | null | true | 2019-05-29T06:59:15 | 2019-05-29T06:59:14 | 2019-05-28T01:30:39 | 2019-05-28T01:30:37 | 778,634 | 0 | 0 | 0 | null | false | false | package org.test.zombiedefence;
import loon.LTexture;
import loon.action.sprite.SpriteBatch;
import loon.geom.Vector2f;
public class BloodSplatter extends DrawableObject
{
public BloodSplatter(LTexture texture, Vector2f position)
{
super(texture, position);
}
@Override
public void Draw(SpriteBatch batch)
{
super.Draw(batch);
}
@Override
public void Update()
{
super.Update();
}
} | UTF-8 | Java | 405 | java | BloodSplatter.java | Java | []
| null | []
| package org.test.zombiedefence;
import loon.LTexture;
import loon.action.sprite.SpriteBatch;
import loon.geom.Vector2f;
public class BloodSplatter extends DrawableObject
{
public BloodSplatter(LTexture texture, Vector2f position)
{
super(texture, position);
}
@Override
public void Draw(SpriteBatch batch)
{
super.Draw(batch);
}
@Override
public void Update()
{
super.Update();
}
} | 405 | 0.74938 | 0.744417 | 25 | 15.16 | 16.715693 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.04 | false | false | 2 |
720b9350ec6e76c573fcebb4e47ce1416f8d9e69 | 146,028,899,832 | 228b2f2d8caacc0758abdffa158c3b2ebd2a4433 | /src/main/java/com/home/controller/UpstreamMessageCommunicatorController.java | f788e179145903216e975ded667ffa12580929ff | []
| no_license | azafty468/upstream-rest-service | https://github.com/azafty468/upstream-rest-service | 66b1769ab254d1856598234993f6f7a9402937ad | 9d561a67325ee4b37041f67a0de3dcabd4090880 | refs/heads/master | 2017-12-05T22:31:45.043000 | 2017-01-26T20:46:27 | 2017-01-26T20:46:27 | 80,153,537 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.home.controller;
import com.home.service.RESTMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by Andrew on 1/16/2017.
*
* Primary controller that handles all the of the /message endpoints. I'm a bit lazy here because I'm using Spring's
* automatic JSON representations for errors & exceptions, and yet my own responses are simple strings.
*/
@RestController
public class UpstreamMessageCommunicatorController {
@Autowired
private RESTMessageService localService;
@RequestMapping(value = "/talk-to-message-system", method = RequestMethod.GET)
public String getMessage() {
String messageResult = localService.getMessage();
return messageResult;
}
}
| UTF-8 | Java | 997 | java | UpstreamMessageCommunicatorController.java | Java | [
{
"context": "bind.annotation.RestController;\n\n/**\n * Created by Andrew on 1/16/2017.\n *\n * Primary controller that handl",
"end": 410,
"score": 0.991640567779541,
"start": 404,
"tag": "NAME",
"value": "Andrew"
}
]
| null | []
| package com.home.controller;
import com.home.service.RESTMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by Andrew on 1/16/2017.
*
* Primary controller that handles all the of the /message endpoints. I'm a bit lazy here because I'm using Spring's
* automatic JSON representations for errors & exceptions, and yet my own responses are simple strings.
*/
@RestController
public class UpstreamMessageCommunicatorController {
@Autowired
private RESTMessageService localService;
@RequestMapping(value = "/talk-to-message-system", method = RequestMethod.GET)
public String getMessage() {
String messageResult = localService.getMessage();
return messageResult;
}
}
| 997 | 0.782347 | 0.775326 | 27 | 35.925926 | 32.727749 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 2 |
6f108417284076eea63c877cd59c1101886fecaf | 22,668,837,410,747 | e19c40a0e6a8fc898680172b65e82d1ca6f4294d | /Asignacio5/src/asignacio5/Crearcuenta.java | 54cc1bd5c1b8ee4ad676a8055e48ab292b0d1f99 | []
| no_license | luisdgd07/practicasjava | https://github.com/luisdgd07/practicasjava | 60aad42e9a8174c979198420ef0f4cefb6e43839 | 8d34b84443b80afd9064561d4289e4f602e6320a | refs/heads/master | 2022-04-08T00:00:27.854000 | 2020-03-04T01:56:47 | 2020-03-04T01:56:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package asignacio5;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
/**
*
* @author Gonzalez Duerto
*/
public class Crearcuenta extends javax.swing.JFrame {
/**
* Creates new form crearcuenta
*/
public Crearcuenta() {
initComponents();
setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
nombre = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
apellido = new javax.swing.JTextField();
email = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
contra = new javax.swing.JPasswordField();
crear = new javax.swing.JButton();
datos = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
edad = new javax.swing.JSpinner();
genero = new javax.swing.JComboBox<>();
tipo = new javax.swing.JComboBox<>();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setUndecorated(true);
jPanel1.setBackground(new java.awt.Color(0, 120, 215));
jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 5));
jLabel1.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Nombre:");
jLabel2.setBackground(new java.awt.Color(255, 255, 255));
jLabel2.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel2.setText("Apellido:");
jLabel4.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setText("Genero:");
jLabel5.setBackground(new java.awt.Color(0, 120, 215));
jLabel5.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel5.setForeground(new java.awt.Color(255, 255, 255));
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel5.setText("Email:");
jLabel6.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel6.setForeground(new java.awt.Color(255, 255, 255));
jLabel6.setText("Tipo de Cuenta:");
jLabel7.setFont(new java.awt.Font("Comic Sans MS", 1, 24)); // NOI18N
jLabel7.setForeground(new java.awt.Color(255, 255, 255));
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel7.setText("Crear Cuenta");
nombre.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
nombre.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
jLabel8.setBackground(new java.awt.Color(0, 120, 215));
jLabel8.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel8.setForeground(new java.awt.Color(255, 255, 255));
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel8.setText("Contraseña:");
apellido.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
apellido.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
apellido.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
apellidoActionPerformed(evt);
}
});
email.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
email.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
email.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
emailActionPerformed(evt);
}
});
jLabel10.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel10.setForeground(new java.awt.Color(255, 255, 255));
jLabel10.setText("Edad:");
contra.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
contra.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
contra.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
contraActionPerformed(evt);
}
});
crear.setBackground(new java.awt.Color(18, 110, 183));
crear.setForeground(new java.awt.Color(255, 255, 255));
crear.setText("Crear Cuenta");
crear.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
crear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
crearActionPerformed(evt);
}
});
datos.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
datos.setForeground(new java.awt.Color(255, 255, 255));
edad.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
edad.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
genero.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
genero.setForeground(new java.awt.Color(0, 120, 215));
genero.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Masculino", "Femenino" }));
genero.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
genero.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
generoActionPerformed(evt);
}
});
tipo.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
tipo.setForeground(new java.awt.Color(0, 120, 215));
tipo.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Ahorro", "Corriente"}));
tipo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
jButton1.setBackground(new java.awt.Color(203, 22, 37));
jButton1.setForeground(new java.awt.Color(255, 255, 255));
jButton1.setText("Cancelar");
jButton1.setBorder(null);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(nombre, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE))
.addGap(54, 54, 54)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(apellido, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(edad, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(65, 65, 65))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(crear, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(181, 181, 181))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(65, 65, 65)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4)
.addComponent(genero, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(97, 97, 97))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(316, 316, 316)
.addComponent(jLabel6))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(email, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(140, 140, 140)
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(29, 29, 29)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(contra, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(datos)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(39, 39, 39))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(12, 12, 12)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel1)
.addComponent(jLabel10))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(edad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(44, 44, 44)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(genero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(38, 38, 38)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel8))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(contra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
.addComponent(crear, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(datos)
.addGap(69, 69, 69))
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
email.getAccessibleContext().setAccessibleName("");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void crearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_crearActionPerformed
// TODO add your handling code here:
try{
if(nombre.getText().equals("")||apellido.getText().equals("")||email.getText().equals("")||contra.getPassword().equals("")){
datos.setText("Debe introducir todos los datos");
}
int agno=(int) edad.getValue();
if(agno<18){
datos.setText("Debe de ser mayor de edad");
}
else{
int ncuenta=343400000+(int) Math.round(Math.random()*1000);
File banco=new File(ncuenta+".txt");
banco.createNewFile();
BufferedWriter escribir=new BufferedWriter(new FileWriter(banco));
escribir.write(contra.getPassword());
escribir.newLine();
escribir.write(email.getText());
escribir.newLine();
escribir.write(nombre.getText());
escribir.newLine();
escribir.write(apellido.getText());
escribir.newLine();
escribir.write(edad.getValue().toString());
escribir.newLine();
escribir.write(genero.getSelectedItem().toString());
escribir.newLine();
escribir.write(tipo.getSelectedItem().toString());
escribir.close();
File dinero=new File(ncuenta+"d.txt");
dinero.createNewFile();
BufferedWriter escribird=new BufferedWriter(new FileWriter(dinero));
escribird.write("0");
escribird.close();
File bancor=new File(ncuenta+"r.txt");
bancor.createNewFile();
BufferedWriter escribirr=new BufferedWriter(new FileWriter(bancor));
escribirr.write("Ha creado una cuenta");
escribirr.newLine();
escribirr.close();
Menu m=new Menu();
m.setsubtitulo(email.getText());
m.setVisible(true);
setVisible(false);
Email e=new Email();
String correo=email.getText();
String contrase=contra.getText();
e.iniciar(correo,contrase);
e.enviar(correo,contrase,"su numero de cuenta es: "+ncuenta+" gracias por preferirnos");
}
}catch(Exception e){
System.out.println("Error");
}
}//GEN-LAST:event_crearActionPerformed
private void apellidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_apellidoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_apellidoActionPerformed
private void emailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emailActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_emailActionPerformed
private void contraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_contraActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_contraActionPerformed
private void generoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_generoActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
Menu m=new Menu();
m.setVisible(true);
setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Crearcuenta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Crearcuenta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Crearcuenta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Crearcuenta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Crearcuenta().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField apellido;
private javax.swing.JPasswordField contra;
private javax.swing.JButton crear;
private javax.swing.JLabel datos;
private javax.swing.JSpinner edad;
private javax.swing.JTextField email;
private javax.swing.JComboBox<String> genero;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTextField nombre;
private javax.swing.JComboBox<String> tipo;
// End of variables declaration//GEN-END:variables
}
| UTF-8 | Java | 23,624 | java | Crearcuenta.java | Java | [
{
"context": "ile;\nimport java.io.FileWriter;\n\n/**\n *\n * @author Gonzalez Duerto\n */\npublic class Crearcuenta extends javax.swing.",
"end": 319,
"score": 0.9998446702957153,
"start": 304,
"tag": "NAME",
"value": "Gonzalez Duerto"
}
]
| null | []
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package asignacio5;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
/**
*
* @author <NAME>
*/
public class Crearcuenta extends javax.swing.JFrame {
/**
* Creates new form crearcuenta
*/
public Crearcuenta() {
initComponents();
setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
nombre = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
apellido = new javax.swing.JTextField();
email = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
contra = new javax.swing.JPasswordField();
crear = new javax.swing.JButton();
datos = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
edad = new javax.swing.JSpinner();
genero = new javax.swing.JComboBox<>();
tipo = new javax.swing.JComboBox<>();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setUndecorated(true);
jPanel1.setBackground(new java.awt.Color(0, 120, 215));
jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 5));
jLabel1.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Nombre:");
jLabel2.setBackground(new java.awt.Color(255, 255, 255));
jLabel2.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel2.setText("Apellido:");
jLabel4.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setText("Genero:");
jLabel5.setBackground(new java.awt.Color(0, 120, 215));
jLabel5.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel5.setForeground(new java.awt.Color(255, 255, 255));
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel5.setText("Email:");
jLabel6.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel6.setForeground(new java.awt.Color(255, 255, 255));
jLabel6.setText("Tipo de Cuenta:");
jLabel7.setFont(new java.awt.Font("Comic Sans MS", 1, 24)); // NOI18N
jLabel7.setForeground(new java.awt.Color(255, 255, 255));
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel7.setText("Crear Cuenta");
nombre.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
nombre.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
jLabel8.setBackground(new java.awt.Color(0, 120, 215));
jLabel8.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel8.setForeground(new java.awt.Color(255, 255, 255));
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel8.setText("Contraseña:");
apellido.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
apellido.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
apellido.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
apellidoActionPerformed(evt);
}
});
email.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
email.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
email.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
emailActionPerformed(evt);
}
});
jLabel10.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel10.setForeground(new java.awt.Color(255, 255, 255));
jLabel10.setText("Edad:");
contra.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
contra.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
contra.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
contraActionPerformed(evt);
}
});
crear.setBackground(new java.awt.Color(18, 110, 183));
crear.setForeground(new java.awt.Color(255, 255, 255));
crear.setText("Crear Cuenta");
crear.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
crear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
crearActionPerformed(evt);
}
});
datos.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
datos.setForeground(new java.awt.Color(255, 255, 255));
edad.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
edad.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
genero.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
genero.setForeground(new java.awt.Color(0, 120, 215));
genero.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Masculino", "Femenino" }));
genero.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
genero.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
generoActionPerformed(evt);
}
});
tipo.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
tipo.setForeground(new java.awt.Color(0, 120, 215));
tipo.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Ahorro", "Corriente"}));
tipo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 99, 177), 3));
jButton1.setBackground(new java.awt.Color(203, 22, 37));
jButton1.setForeground(new java.awt.Color(255, 255, 255));
jButton1.setText("Cancelar");
jButton1.setBorder(null);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(nombre, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE))
.addGap(54, 54, 54)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(apellido, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(edad, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(65, 65, 65))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(crear, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(181, 181, 181))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(65, 65, 65)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4)
.addComponent(genero, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(97, 97, 97))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(316, 316, 316)
.addComponent(jLabel6))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(email, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(140, 140, 140)
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(29, 29, 29)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(contra, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(datos)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(39, 39, 39))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(12, 12, 12)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel1)
.addComponent(jLabel10))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(edad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(44, 44, 44)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(genero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(38, 38, 38)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel8))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(contra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
.addComponent(crear, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(datos)
.addGap(69, 69, 69))
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
email.getAccessibleContext().setAccessibleName("");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void crearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_crearActionPerformed
// TODO add your handling code here:
try{
if(nombre.getText().equals("")||apellido.getText().equals("")||email.getText().equals("")||contra.getPassword().equals("")){
datos.setText("Debe introducir todos los datos");
}
int agno=(int) edad.getValue();
if(agno<18){
datos.setText("Debe de ser mayor de edad");
}
else{
int ncuenta=343400000+(int) Math.round(Math.random()*1000);
File banco=new File(ncuenta+".txt");
banco.createNewFile();
BufferedWriter escribir=new BufferedWriter(new FileWriter(banco));
escribir.write(contra.getPassword());
escribir.newLine();
escribir.write(email.getText());
escribir.newLine();
escribir.write(nombre.getText());
escribir.newLine();
escribir.write(apellido.getText());
escribir.newLine();
escribir.write(edad.getValue().toString());
escribir.newLine();
escribir.write(genero.getSelectedItem().toString());
escribir.newLine();
escribir.write(tipo.getSelectedItem().toString());
escribir.close();
File dinero=new File(ncuenta+"d.txt");
dinero.createNewFile();
BufferedWriter escribird=new BufferedWriter(new FileWriter(dinero));
escribird.write("0");
escribird.close();
File bancor=new File(ncuenta+"r.txt");
bancor.createNewFile();
BufferedWriter escribirr=new BufferedWriter(new FileWriter(bancor));
escribirr.write("Ha creado una cuenta");
escribirr.newLine();
escribirr.close();
Menu m=new Menu();
m.setsubtitulo(email.getText());
m.setVisible(true);
setVisible(false);
Email e=new Email();
String correo=email.getText();
String contrase=contra.getText();
e.iniciar(correo,contrase);
e.enviar(correo,contrase,"su numero de cuenta es: "+ncuenta+" gracias por preferirnos");
}
}catch(Exception e){
System.out.println("Error");
}
}//GEN-LAST:event_crearActionPerformed
private void apellidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_apellidoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_apellidoActionPerformed
private void emailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emailActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_emailActionPerformed
private void contraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_contraActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_contraActionPerformed
private void generoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_generoActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
Menu m=new Menu();
m.setVisible(true);
setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Crearcuenta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Crearcuenta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Crearcuenta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Crearcuenta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Crearcuenta().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField apellido;
private javax.swing.JPasswordField contra;
private javax.swing.JButton crear;
private javax.swing.JLabel datos;
private javax.swing.JSpinner edad;
private javax.swing.JTextField email;
private javax.swing.JComboBox<String> genero;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTextField nombre;
private javax.swing.JComboBox<String> tipo;
// End of variables declaration//GEN-END:variables
}
| 23,615 | 0.648182 | 0.622825 | 427 | 54.323185 | 38.838387 | 168 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.046838 | false | false | 2 |
f97a2f255a23e530158272cda05fd3ea7f8608e1 | 20,547,123,560,498 | cfae717f89f1ba73f5038d9ecd74397088eec9fb | /OJ/src/com/kc345ws/leetcode/_0945使数组唯一的最小增量.java | 093d6c52d6ed6c6149edc14b2d5648708d7d0b2b | []
| no_license | kc345ws/MyDemos | https://github.com/kc345ws/MyDemos | db3b61e230ec8204d7a9ed72288b883e0e5f62ad | 7ff5f39c545927cf6edfe95ebc1d791e74d09a2c | refs/heads/master | 2022-12-27T18:25:04.705000 | 2020-03-24T11:21:24 | 2020-03-24T11:21:24 | 210,615,069 | 0 | 0 | null | false | 2022-12-16T15:28:20 | 2019-09-24T13:51:51 | 2020-03-24T11:21:41 | 2022-12-16T15:28:18 | 49,844 | 0 | 0 | 13 | Java | false | false | package com.kc345ws.leetcode;
/*
* 给定整数数组 A,每次 move 操作将会选择任意 A[i],并将其递增 1。
返回使 A 中的每个值都是唯一的最少操作次数。
示例 1:
输入:[1,2,2]
输出:1
解释:经过一次 move 操作,数组将变为 [1, 2, 3]。
示例 2:
输入:[3,2,1,2,1,7]
输出:6
解释:经过 6 次 move 操作,数组将变为 [3, 4, 1, 2, 5, 7]。
可以看出 5 次或 5 次以下的 move 操作是不能让数组的每个值唯一的。
提示:
0 <= A.length <= 40000
0 <= A[i] < 40000
* */
public class _0945使数组唯一的最小增量 {
//V2.0桶排序优化
public int minIncrementForUnique(int[] A) {
if(A.length == 0) return 0;
int ans = 0;
int []bucket = new int[40001];
for(int item : A){
bucket[item]++;
}
for(int i = 0 ; i < 40000 ; i++){
if(bucket[i] > 1){
int movenum = bucket[i] - 1;//移动元素数量
bucket[i+1] += movenum;
bucket[i] = 1;
ans += movenum;
}
}
//可能会堆积在最后一个元素,将最后一个元素向后移动
for(int i = bucket[bucket.length-1] ; i > 1 ; i--){
ans +=i-1;
}
return ans;
}
}
/*
* //V1.0桶排序
public int minIncrementForUnique(int[] A) {
if(A.length == 0) return 0;
int ans = 0;
int []bucket = new int[40001];
int len = A.length;
for(int i = 0 ; i < len ; i++){
bucket[A[i]]++;
}
for(int i = 0 ; i < 40000 ; i++){
while(bucket[i] > 1){
bucket[i]--;
bucket[i+1]++;
ans++;
}
}
//可能会堆积在最后一个元素,将最后一个元素向后移动
for(int i = bucket[bucket.length-1] ; i > 1 ; i--){
ans += i-1;
}
return ans;
}
* */
| UTF-8 | Java | 1,974 | java | _0945使数组唯一的最小增量.java | Java | []
| null | []
| package com.kc345ws.leetcode;
/*
* 给定整数数组 A,每次 move 操作将会选择任意 A[i],并将其递增 1。
返回使 A 中的每个值都是唯一的最少操作次数。
示例 1:
输入:[1,2,2]
输出:1
解释:经过一次 move 操作,数组将变为 [1, 2, 3]。
示例 2:
输入:[3,2,1,2,1,7]
输出:6
解释:经过 6 次 move 操作,数组将变为 [3, 4, 1, 2, 5, 7]。
可以看出 5 次或 5 次以下的 move 操作是不能让数组的每个值唯一的。
提示:
0 <= A.length <= 40000
0 <= A[i] < 40000
* */
public class _0945使数组唯一的最小增量 {
//V2.0桶排序优化
public int minIncrementForUnique(int[] A) {
if(A.length == 0) return 0;
int ans = 0;
int []bucket = new int[40001];
for(int item : A){
bucket[item]++;
}
for(int i = 0 ; i < 40000 ; i++){
if(bucket[i] > 1){
int movenum = bucket[i] - 1;//移动元素数量
bucket[i+1] += movenum;
bucket[i] = 1;
ans += movenum;
}
}
//可能会堆积在最后一个元素,将最后一个元素向后移动
for(int i = bucket[bucket.length-1] ; i > 1 ; i--){
ans +=i-1;
}
return ans;
}
}
/*
* //V1.0桶排序
public int minIncrementForUnique(int[] A) {
if(A.length == 0) return 0;
int ans = 0;
int []bucket = new int[40001];
int len = A.length;
for(int i = 0 ; i < len ; i++){
bucket[A[i]]++;
}
for(int i = 0 ; i < 40000 ; i++){
while(bucket[i] > 1){
bucket[i]--;
bucket[i+1]++;
ans++;
}
}
//可能会堆积在最后一个元素,将最后一个元素向后移动
for(int i = bucket[bucket.length-1] ; i > 1 ; i--){
ans += i-1;
}
return ans;
}
* */
| 1,974 | 0.442911 | 0.386449 | 71 | 21.450705 | 15.759449 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.661972 | false | false | 2 |
9d68586c4249ecb48cb9f3444e1b6a94f97ceb05 | 4,312,147,172,860 | fdd4cc6f8b5a473c0081af5302cb19c34433a0cf | /src/modules/agrega/empaquetadorbasico/src/main/java/es/pode/empaquetador/negocio/servicio/CacheEmpaquetacion.java | 04a766ec9e5b94b4995cdf3240380d44bf979450 | []
| no_license | nwlg/Colony | https://github.com/nwlg/Colony | 0170b0990c1f592500d4869ec8583a1c6eccb786 | 07c908706991fc0979e4b6c41d30812d861776fb | refs/heads/master | 2021-01-22T05:24:40.082000 | 2010-12-23T14:49:00 | 2010-12-23T14:49:00 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* Agrega es una federación de repositorios de objetos digitales educativos formada por todas las Comunidades Autónomas propiedad de Red.es. Este código ha sido desarrollado por la Entidad Pública Empresarial red.es adscrita al Ministerio de Industria,Turismo y Comercio a través de la Secretaría de Estado de Telecomunicaciones y para la Sociedad de la Información, dentro del Programa Internet en el Aula, que se encuadra dentro de las actuaciones previstas en el Plan Avanza (Plan 2006-2010 para el desarrollo de la Sociedad de la Información y de Convergencia con Europa y entre Comunidades Autónomas y Ciudades Autónomas) y ha sido cofinanciado con fondos FEDER del Programa Operativo FEDER 2000-2006 “Sociedad de la Información”
This program is free software: you can redistribute it and/or modify it under the terms of the European Union Public Licence (EUPL v.1.0). This program 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 European Union Public Licence (EUPL v.1.0). You should have received a copy of the EUPL licence along with this program. If not, see http://ec.europa.eu/idabc/en/document/7330.
*/
/**
*
*/
package es.pode.empaquetador.negocio.servicio;
import java.util.HashMap;
import org.apache.log4j.Logger;
import es.pode.parseadorXML.castor.Manifest;
//import org.apache.log4j.Logger;
//
//import es.pode.parseadorXML.castor.Manifest;
/**
* @author dgonzalezd
*
*/
public class CacheEmpaquetacion {
private static Logger logger = Logger.getLogger(CacheEmpaquetacion.class);
private HashMap<String, Object> cacheEmpaquetacion = new HashMap<String, Object>(10);
// private static Logger logger = Logger.getLogger(CacheEmpaquetacion.class);
/**
* Recupera objeto de la caché
* @param identificador String identificador del objeto a recuperar
* @return Objeto recuperado, null si no se encontró
*/
public Object get(String identificador) {
return cacheEmpaquetacion.get(identificador);
}
/**
* Elimina objeto de la caché
* @param identificador String identificador del objeto a eliminar
* @return Objeto eliminado, null si no se encontró
*/
public Object remove(String identificador) {
return cacheEmpaquetacion.remove(identificador);
}
/**
* Añadir objeto a la caché
* @param key String identificador del objeto a añadir
* @param value Objeto a añadir
* @return Objeto previamente asociado al identificador, null si no había
*/
public Object put(String key, Object value) {
return cacheEmpaquetacion.put(key, value);
}
/* Al final no le veo mucho sentido tenerlo aquí, pues me parece no muy ligado
* a esta clase. En los métodos de SrvGestorManifestServiceImpl que se llama a
* métodos de esta clase se llama a este método, pero no en todos los métodos
* que lo llaman se usan métodos de esta clase.
*/
public Manifest comprobarManifest(String identificador)
throws java.lang.Exception {
Manifest manifest = null;
Object obj = get(identificador);
if (obj instanceof es.pode.parseadorXML.castor.Manifest) {
logger.debug("El objeto " + obj + " es de tipo manifest");
manifest = (Manifest) obj;
} else if (obj != null) {
logger.error("El objeto " + obj + " no es de tipo manifest");
throw new AlmacenamientoException("El objeto no es de tipo manifest");
}
return manifest;
}
}
| WINDOWS-1252 | Java | 3,464 | java | CacheEmpaquetacion.java | Java | [
{
"context": "pode.parseadorXML.castor.Manifest;\n\n/**\n * @author dgonzalezd\n *\n */\npublic class CacheEmpaquetacion {\n\t\n\t\n\tpri",
"end": 1523,
"score": 0.9996533393859863,
"start": 1513,
"tag": "USERNAME",
"value": "dgonzalezd"
}
]
| null | []
| /* Agrega es una federación de repositorios de objetos digitales educativos formada por todas las Comunidades Autónomas propiedad de Red.es. Este código ha sido desarrollado por la Entidad Pública Empresarial red.es adscrita al Ministerio de Industria,Turismo y Comercio a través de la Secretaría de Estado de Telecomunicaciones y para la Sociedad de la Información, dentro del Programa Internet en el Aula, que se encuadra dentro de las actuaciones previstas en el Plan Avanza (Plan 2006-2010 para el desarrollo de la Sociedad de la Información y de Convergencia con Europa y entre Comunidades Autónomas y Ciudades Autónomas) y ha sido cofinanciado con fondos FEDER del Programa Operativo FEDER 2000-2006 “Sociedad de la Información”
This program is free software: you can redistribute it and/or modify it under the terms of the European Union Public Licence (EUPL v.1.0). This program 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 European Union Public Licence (EUPL v.1.0). You should have received a copy of the EUPL licence along with this program. If not, see http://ec.europa.eu/idabc/en/document/7330.
*/
/**
*
*/
package es.pode.empaquetador.negocio.servicio;
import java.util.HashMap;
import org.apache.log4j.Logger;
import es.pode.parseadorXML.castor.Manifest;
//import org.apache.log4j.Logger;
//
//import es.pode.parseadorXML.castor.Manifest;
/**
* @author dgonzalezd
*
*/
public class CacheEmpaquetacion {
private static Logger logger = Logger.getLogger(CacheEmpaquetacion.class);
private HashMap<String, Object> cacheEmpaquetacion = new HashMap<String, Object>(10);
// private static Logger logger = Logger.getLogger(CacheEmpaquetacion.class);
/**
* Recupera objeto de la caché
* @param identificador String identificador del objeto a recuperar
* @return Objeto recuperado, null si no se encontró
*/
public Object get(String identificador) {
return cacheEmpaquetacion.get(identificador);
}
/**
* Elimina objeto de la caché
* @param identificador String identificador del objeto a eliminar
* @return Objeto eliminado, null si no se encontró
*/
public Object remove(String identificador) {
return cacheEmpaquetacion.remove(identificador);
}
/**
* Añadir objeto a la caché
* @param key String identificador del objeto a añadir
* @param value Objeto a añadir
* @return Objeto previamente asociado al identificador, null si no había
*/
public Object put(String key, Object value) {
return cacheEmpaquetacion.put(key, value);
}
/* Al final no le veo mucho sentido tenerlo aquí, pues me parece no muy ligado
* a esta clase. En los métodos de SrvGestorManifestServiceImpl que se llama a
* métodos de esta clase se llama a este método, pero no en todos los métodos
* que lo llaman se usan métodos de esta clase.
*/
public Manifest comprobarManifest(String identificador)
throws java.lang.Exception {
Manifest manifest = null;
Object obj = get(identificador);
if (obj instanceof es.pode.parseadorXML.castor.Manifest) {
logger.debug("El objeto " + obj + " es de tipo manifest");
manifest = (Manifest) obj;
} else if (obj != null) {
logger.error("El objeto " + obj + " no es de tipo manifest");
throw new AlmacenamientoException("El objeto no es de tipo manifest");
}
return manifest;
}
}
| 3,464 | 0.758008 | 0.749854 | 81 | 41.395061 | 97.566269 | 734 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.271605 | false | false | 2 |
ada40811109b6eb17f433fedf203c493c13138da | 4,312,147,173,151 | 362a3185542df3750918abc735f1a38487273cd8 | /src/src/main/java/com/jeecms/cms/service/SearchWordsCache.java | 103f77b293a7d6f5a584b1b274ad3c8dc4424a45 | [
"Apache-2.0"
]
| permissive | zhangzlyuyx/jeecms81 | https://github.com/zhangzlyuyx/jeecms81 | a4517d02453de641c262bb276c34a2b4d40785ca | b7f5633114b3a1283f096fd8da9e5efe3ddf575d | refs/heads/master | 2022-12-26T12:29:41.143000 | 2020-04-17T02:27:08 | 2020-04-17T02:27:08 | 248,179,752 | 0 | 1 | Apache-2.0 | false | 2022-12-16T08:19:03 | 2020-03-18T08:45:54 | 2020-04-17T02:27:34 | 2022-12-16T08:19:02 | 19,940 | 0 | 1 | 15 | Java | false | false | package com.jeecms.cms.service;
/**
* 搜索词缓存接口
*/
public interface SearchWordsCache {
/**
* 搜索词汇缓存
*
* @param id
*/
public void cacheWord(String name);
}
| UTF-8 | Java | 195 | java | SearchWordsCache.java | Java | []
| null | []
| package com.jeecms.cms.service;
/**
* 搜索词缓存接口
*/
public interface SearchWordsCache {
/**
* 搜索词汇缓存
*
* @param id
*/
public void cacheWord(String name);
}
| 195 | 0.627219 | 0.627219 | 14 | 11.071428 | 12.617812 | 36 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.571429 | false | false | 2 |
acd51467627d156da49e9e12796b00605603698a | 4,801,773,444,862 | 096e862f59cf0d2acf0ce05578f913a148cc653d | /code/apps/Note/src/com/sprd/note/utils/LogUtils.java | 115d1479084b805aa28f9c3b851912dcfac68e08 | []
| no_license | Phenix-Collection/Android-6.0-packages | https://github.com/Phenix-Collection/Android-6.0-packages | e2ba7f7950c5df258c86032f8fbdff42d2dfc26a | ac1a67c36f90013ac1de82309f84bd215d5fdca9 | refs/heads/master | 2021-10-10T20:52:24.087000 | 2017-05-27T05:52:42 | 2017-05-27T05:52:42 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sprd.note.utils;
public class LogUtils {
public static final boolean DEBUG = true;
}
| UTF-8 | Java | 103 | java | LogUtils.java | Java | []
| null | []
| package com.sprd.note.utils;
public class LogUtils {
public static final boolean DEBUG = true;
}
| 103 | 0.728155 | 0.728155 | 6 | 16.166666 | 17.179607 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 2 |
d598253b1ab8ce0ec1ea8a98709f814df8ef09f5 | 22,771,916,612,084 | 9579dab89f0776f31f3694b5f1c8d16471bdcace | /solution/src/P51_P100/P67_subsets_II.java | a33db6d71c3252bc05efb7e157acb2b838239c17 | []
| no_license | SiyuanXing/leetcode | https://github.com/SiyuanXing/leetcode | 143ed461210117aa71efd61c197a9d710de299cc | 7994485ee982a952c8304cc4076c642ae07fb309 | refs/heads/master | 2020-12-30T09:37:55.054000 | 2014-04-06T22:32:45 | 2014-04-06T22:32:45 | 17,197,716 | 3 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | package P51_P100;
import java.util.ArrayList;
import java.util.Arrays;
public class P67_subsets_II {
public ArrayList<ArrayList<Integer>> subsetsWithDup(int[] num) {
if (num.length==0){
return new ArrayList<ArrayList<Integer>>();
}
Arrays.sort(num);
int index = 0;
int SwithTime[][] = new int[num.length][2];
SwithTime[0][0] = 1;
SwithTime[0][1] = num[0];
for (int i=1;i<num.length;i++){
if(num[i-1]!=num[i]){
index++;
SwithTime[index][0] = 1;
SwithTime[index][1] = num[i];
}
else {
SwithTime[index][0]++;
}
}
return generateSubset(SwithTime,index);
}
public ArrayList<ArrayList<Integer>> generateSubset(int[][] S,int length) {
ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
if (length == 0){
ArrayList<Integer> t1 = new ArrayList<Integer>();
result.add(t1);
ArrayList<Integer> t2 = new ArrayList<Integer>();
for (int i = 0;i<S[length][0];i++){
t2.add(S[length][1]);
result.add(new ArrayList<Integer>(t2));
}
}
else {
result = generateSubset(S,length-1);
int k = result.size();
for(int i=0;i<k;i++) {
ArrayList<Integer> temp = new ArrayList<Integer>();
temp.addAll(result.get(i));
for (int j = 0;j<S[length][0];j++){
temp.add(S[length][1]);
result.add(new ArrayList<Integer>(temp));
}
}
}
return result;
}
}
| UTF-8 | Java | 1,749 | java | P67_subsets_II.java | Java | []
| null | []
| package P51_P100;
import java.util.ArrayList;
import java.util.Arrays;
public class P67_subsets_II {
public ArrayList<ArrayList<Integer>> subsetsWithDup(int[] num) {
if (num.length==0){
return new ArrayList<ArrayList<Integer>>();
}
Arrays.sort(num);
int index = 0;
int SwithTime[][] = new int[num.length][2];
SwithTime[0][0] = 1;
SwithTime[0][1] = num[0];
for (int i=1;i<num.length;i++){
if(num[i-1]!=num[i]){
index++;
SwithTime[index][0] = 1;
SwithTime[index][1] = num[i];
}
else {
SwithTime[index][0]++;
}
}
return generateSubset(SwithTime,index);
}
public ArrayList<ArrayList<Integer>> generateSubset(int[][] S,int length) {
ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
if (length == 0){
ArrayList<Integer> t1 = new ArrayList<Integer>();
result.add(t1);
ArrayList<Integer> t2 = new ArrayList<Integer>();
for (int i = 0;i<S[length][0];i++){
t2.add(S[length][1]);
result.add(new ArrayList<Integer>(t2));
}
}
else {
result = generateSubset(S,length-1);
int k = result.size();
for(int i=0;i<k;i++) {
ArrayList<Integer> temp = new ArrayList<Integer>();
temp.addAll(result.get(i));
for (int j = 0;j<S[length][0];j++){
temp.add(S[length][1]);
result.add(new ArrayList<Integer>(temp));
}
}
}
return result;
}
}
| 1,749 | 0.481418 | 0.460835 | 54 | 31.388889 | 20.751989 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.722222 | false | false | 2 |
24bce9ad8b482dbbd5f18c38eb61145a2f2adf60 | 29,059,748,730,205 | a31d4d705e38e84a6da6e491a811599d813d56a0 | /ntu_3_1/src/com/company/MyComplex.java | 7ca784bbf5befe3d9850c3d23f18177aa77ba367 | []
| no_license | rabiefw/Java_Examples_NTU | https://github.com/rabiefw/Java_Examples_NTU | ea97330e2d8aabc03a9d8b97693ece475a3ccee1 | c653bb6fab68f2246b13378a7aba0f58e1ad76a1 | refs/heads/main | 2023-06-14T04:07:49.284000 | 2021-07-16T15:44:36 | 2021-07-16T15:44:36 | 384,429,520 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.company;
public class MyComplex {
private double real = 0.0;
private double imag = 0.0;
public MyComplex() {
this.real = 0.0;
this.imag = 0.0;
}
public MyComplex(double real, double imag) {
this.real = real;
this.imag = imag;
}
public double getReal() {
return real;
}
public void setReal(double real) {
this.real = real;
}
public double getImag() {
return imag;
}
public void setImag(double imag) {
this.imag = imag;
}
public void setValue(double real, double imag) {
this.real = real;
this.imag = imag;
}
@Override
public String toString() {
return "MyComplex{" +
real +
"+" + imag + "i" +
'}';
}
public boolean isReal() {
return (imag == 0);
}
public boolean isImaginary() {
return (imag != 0);
}
public boolean equals(double real, double imag) {
return (this.real == real && this.imag == imag);
}
public boolean equals(MyComplex myComplex) {
return (this.real == myComplex.real && this.imag == myComplex.imag);
}
public double magnitude() {
return Math.sqrt(real * real + imag * imag);
}
public MyComplex addInto (MyComplex right){
this.real += right.real;
this.imag += right.imag;
return this;
}
public MyComplex addNew(MyComplex right){
return new MyComplex(right.real, right.imag);
}
}
| UTF-8 | Java | 1,562 | java | MyComplex.java | Java | []
| null | []
| package com.company;
public class MyComplex {
private double real = 0.0;
private double imag = 0.0;
public MyComplex() {
this.real = 0.0;
this.imag = 0.0;
}
public MyComplex(double real, double imag) {
this.real = real;
this.imag = imag;
}
public double getReal() {
return real;
}
public void setReal(double real) {
this.real = real;
}
public double getImag() {
return imag;
}
public void setImag(double imag) {
this.imag = imag;
}
public void setValue(double real, double imag) {
this.real = real;
this.imag = imag;
}
@Override
public String toString() {
return "MyComplex{" +
real +
"+" + imag + "i" +
'}';
}
public boolean isReal() {
return (imag == 0);
}
public boolean isImaginary() {
return (imag != 0);
}
public boolean equals(double real, double imag) {
return (this.real == real && this.imag == imag);
}
public boolean equals(MyComplex myComplex) {
return (this.real == myComplex.real && this.imag == myComplex.imag);
}
public double magnitude() {
return Math.sqrt(real * real + imag * imag);
}
public MyComplex addInto (MyComplex right){
this.real += right.real;
this.imag += right.imag;
return this;
}
public MyComplex addNew(MyComplex right){
return new MyComplex(right.real, right.imag);
}
}
| 1,562 | 0.537772 | 0.53137 | 76 | 19.552631 | 17.968828 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.355263 | false | false | 2 |
2a07a938d4225639a35830e0a0ea629c1846586a | 12,017,318,509,134 | f4dfcf3a54a3112ae661b0d75301da255fa564aa | /src/ServerPackage/GameplayServer.java | 72e48abc3a8992eb4b968de2db2ccf3ff98dc4c9 | []
| no_license | Dred95/Server | https://github.com/Dred95/Server | df8c7a58ada853c70e61f9112f5e485c6b8a8c3e | 28b1c357465ab0da8e14b65773db4a81f7cb9b6f | refs/heads/master | 2016-08-08T13:12:25.193000 | 2015-07-24T16:29:35 | 2015-07-24T16:29:35 | 38,829,822 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ServerPackage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
import GameplayPackage.Circle;
import GameplayPackage.Mob;
import GameplayPackage.Planet;
public final class GameplayServer {
private MessageServer messageServer;
// private Stack<Planet> planets;
private Map<Integer, Mob> mobs = new HashMap<Integer, Mob>();
private Map<Integer, Planet> planets;
private int[] playerValue;
private ArrayList<Integer> selectedID = new ArrayList<Integer>();
private float mobRadius, HP, reloadTime, attackRadius, damage;
private float planetRadius, timeToControl, timeToRespawn;
private float deltaTime;
private int size = 20;
public Utils utils;
private long time,ping1,ping2;
private Timer myTimer = new Timer(); // Создаем таймер
private final class timerUpdate extends TimerTask {
@Override
public void run()
{
update(0.033f);
}
}
public void SetPing(int ID)
{
if(ID == 1)
{
ping1 = System.currentTimeMillis() - time;
System.out.println("Player 1 ping = "+ping1);
}else if( ID == 2)
{
ping2 = System.currentTimeMillis() - time;
} else
{
System.out.println("SetPing: wrong id: "+ID);
System.out.println("Player 2 ping = "+ping2);
}
}
public float getPlanetRadius() {
return planetRadius;
}
public Map<Integer, Mob> getMobs(){
return mobs;
}
public Map<Integer, Planet> getPlanets() {
return planets;
}
/**
* Constructor
* @param game - super game class
*/
public GameplayServer(MessageServer messageServer){
this.messageServer = messageServer;
deltaTime = 0;
//Mob's variables
mobRadius = 5;
HP = 100;
reloadTime = 5;
attackRadius = 50;
damage = 50;
//Planet's variables
planetRadius = 30;
timeToControl = 5;
timeToRespawn = 10;
playerValue = new int[2];
for(int i = 0; i < playerValue.length; i++){
playerValue[i] = 0;
}
}
/**
* Start actions(Server part!)
*/
public void startGame(){
utils = new Utils();
ArrayList<Add> add = new ArrayList<Add>();
planets = new HashMap<Integer, Planet>();
int planetID = utils.GetNewPlanetID();
planets.put(planetID, new Planet(200, 200, planetRadius, timeToControl, timeToRespawn, 1));
add.add(new Add(planetID, 1, 200, 200, planetRadius));
planetID = utils.GetNewPlanetID();
planets.put(planetID, new Planet(600, 200, planetRadius, timeToControl, timeToRespawn, 2));
add.add(new Add(planetID, 2, 600, 200, planetRadius));
planetID = utils.GetNewPlanetID();
planets.put(planetID, new Planet(300, 400, planetRadius, timeToControl, timeToRespawn, Utils.NEUTRAL_OWNER_ID));
add.add(new Add(planetID, Utils.NEUTRAL_OWNER_ID, 300, 400, planetRadius));
planetID = utils.GetNewPlanetID();
planets.put(planetID, new Planet(300, 100, planetRadius, timeToControl, timeToRespawn, Utils.NEUTRAL_OWNER_ID));
add.add(new Add(planetID, Utils.NEUTRAL_OWNER_ID, 300, 100, planetRadius));
for (Planet planet: planets.values()){
for (int i = 0; i < size; i++){
double angle = (2*Math.PI)/size*i;
float radius = planet.getFigure().radius + 2*mobRadius;
float posX = (float) (planet.getFigure().x + radius*Math.cos(angle));
float posY = (float) (planet.getFigure().y + radius*Math.sin(angle));
mobs.put(mobs.size() + 50, new Mob(posX, posY, mobRadius, HP, reloadTime, attackRadius, damage, planet.getOwnerID()));
add.add(new Add(mobs.size() + 50, planet.getOwnerID(), posX, posY, mobRadius));
}
}
StartConfiguration setupConfig = new StartConfiguration(add, 1, 1024, 600);
messageServer.SendTo(1, utils.createOutputString(setupConfig));
setupConfig.receiverID = 2;
messageServer.SendTo(2, utils.createOutputString(setupConfig));
time = System.currentTimeMillis();
messageServer.SendTo(1, utils.createOutputString(new PingCommand(1)));
myTimer.schedule(new timerUpdate(), 0, 33);
}
/**
* Update method
* @param delta - delta time
*/
public void update(float delta) {
for(int i = 0; i < playerValue.length; i++){
playerValue[i] = 0;
}
for (Map.Entry<Integer, Planet> planet: planets.entrySet()) {
planet.getValue().update(this, delta);
if(planet.getValue().isNewMobRespawn()){
respawnToPlanet(planet.getValue());
}
planet.getValue().setInvader(whoIsInvader(planet.getValue()));
if(planet.getValue().isNewOwner()){
messageServer.addToOutputQueue(utils.createOutputString(new NewOwner(planet.getKey(), planet.getValue().getOwnerID())));
planet.getValue().setNewOwner(false);
}
if(planet.getValue().getOwnerID() != Utils.NEUTRAL_OWNER_ID){
playerValue[planet.getValue().getOwnerID()-1]++;
}
}
Iterator<Map.Entry<Integer, Mob>> iterator = mobs.entrySet().iterator();
while (iterator.hasNext())
{
Entry<Integer, Mob> mob = iterator.next();
if(mob.getValue().isRemove()){
messageServer.addToOutputQueue(utils.createOutputString(new Remove(mob.getKey())));
iterator.remove();
} else {
if(mob.getValue().isAttack()){
mob.getValue().setAttack(false);
messageServer.addToOutputQueue(utils.createOutputString(new Attack(mob.getValue().getAttackedMob(), mob.getKey())));
}
mob.getValue().update(this, delta);
}
if(mob.getValue().getOwnerID() != Utils.NEUTRAL_OWNER_ID){
playerValue[mob.getValue().getOwnerID()-1]++;
}
}
deltaTime += delta;
if(deltaTime >= 2){
deltaTime = 0;
ArrayList<Integer> id = new ArrayList<>();
ArrayList<Float> xPosition = new ArrayList<>();
ArrayList<Float> yPosition = new ArrayList<>();
for (Map.Entry<Integer, Planet> planet: planets.entrySet()) {
id.add(planet.getKey());
xPosition.add(planet.getValue().getFigure().x);
yPosition.add(planet.getValue().getFigure().y);
}
for (Map.Entry<Integer, Mob> mob: mobs.entrySet()) {
id.add(mob.getKey());
xPosition.add(mob.getValue().getFigure().x);
yPosition.add(mob.getValue().getFigure().y);
}
messageServer.addToOutputQueue(utils.createOutputString(new DeltaUpdate(id, xPosition, yPosition)));
}
}
private void respawnToPlanet(Planet planet){
planet.resetMobRestpawn();
float radius = planet.getFigure().radius + 2*mobRadius;
boolean isAdded = false;
int number = 0;
while(!isAdded) {
if(number%size==0){
radius += 4*mobRadius;
}
isAdded = true;
double angle = (2 * Math.PI) / size * number;
float posX = (float) (planet.getFigure().x + radius * Math.cos(angle));
float posY = (float) (planet.getFigure().y + radius * Math.sin(angle));
for(Map.Entry<Integer, Mob> mob: mobs.entrySet()){
if(mob.getValue().getFigure().overlaps(new Circle(posX, posY, mobRadius))){
number++;
isAdded = false;
break;
}
}
if(isAdded) {
Mob newMob = new Mob(posX, posY, mobRadius, HP, reloadTime, attackRadius, damage, planet.getOwnerID());
int id = utils.GetNewMobID();
messageServer.addToOutputQueue(utils.createOutputString(new Add(id, planet.getOwnerID(), posX, posY, mobRadius)));
mobs.put(id, newMob);
}
}
}
/**
* If near planet only one type enemy return his name
* @param planet - our planet
* @return - enemy name
*/
private int whoIsInvader(Planet planet){
int invader = -1;
for (Mob mob: mobs.values()){
if(mob.getFigure().overlaps(new Circle(planet.getFigure().x, planet.getFigure().y, 2*planet.getFigure().radius))){
if(planet.getOwnerID() == Utils.NEUTRAL_OWNER_ID){
if(invader == -1){
invader = mob.getOwnerID();
} else if(invader != mob.getOwnerID()){
return -1;
}
} else {
if(mob.getOwnerID() != planet.getOwnerID()){
return Utils.NEUTRAL_OWNER_ID;
}
}
}
}
return invader;
}
public float getTimeToControl() {
return timeToControl;
}
public float getTimeToRespawn() {
return timeToRespawn;
}
public float getReloadTime() {
return reloadTime;
}
/**
* Move object to free point or follow for target
* @param newX - target position x
* @param newY - target position y
* @param target - target
*/
public void moveToPoint(float newX, float newY, int targetID, boolean itIsMine){
for(Integer id: selectedID){
if(mobs.containsKey(id)){
mobs.get(id).setIsSelected(true);
mobs.get(id).setNextPosition(newX, newY, targetID);
} else if(planets.containsKey(id)){
planets.get(id).setIsSelected(true);
planets.get(id).setNextPosition(newX, newY, targetID);
}
}
selectedID.clear();
}
public void setSelectedID(ArrayList<Integer> selectedID) {
this.selectedID = selectedID;
}
}
| WINDOWS-1251 | Java | 10,345 | java | GameplayServer.java | Java | []
| null | []
| package ServerPackage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
import GameplayPackage.Circle;
import GameplayPackage.Mob;
import GameplayPackage.Planet;
public final class GameplayServer {
private MessageServer messageServer;
// private Stack<Planet> planets;
private Map<Integer, Mob> mobs = new HashMap<Integer, Mob>();
private Map<Integer, Planet> planets;
private int[] playerValue;
private ArrayList<Integer> selectedID = new ArrayList<Integer>();
private float mobRadius, HP, reloadTime, attackRadius, damage;
private float planetRadius, timeToControl, timeToRespawn;
private float deltaTime;
private int size = 20;
public Utils utils;
private long time,ping1,ping2;
private Timer myTimer = new Timer(); // Создаем таймер
private final class timerUpdate extends TimerTask {
@Override
public void run()
{
update(0.033f);
}
}
public void SetPing(int ID)
{
if(ID == 1)
{
ping1 = System.currentTimeMillis() - time;
System.out.println("Player 1 ping = "+ping1);
}else if( ID == 2)
{
ping2 = System.currentTimeMillis() - time;
} else
{
System.out.println("SetPing: wrong id: "+ID);
System.out.println("Player 2 ping = "+ping2);
}
}
public float getPlanetRadius() {
return planetRadius;
}
public Map<Integer, Mob> getMobs(){
return mobs;
}
public Map<Integer, Planet> getPlanets() {
return planets;
}
/**
* Constructor
* @param game - super game class
*/
public GameplayServer(MessageServer messageServer){
this.messageServer = messageServer;
deltaTime = 0;
//Mob's variables
mobRadius = 5;
HP = 100;
reloadTime = 5;
attackRadius = 50;
damage = 50;
//Planet's variables
planetRadius = 30;
timeToControl = 5;
timeToRespawn = 10;
playerValue = new int[2];
for(int i = 0; i < playerValue.length; i++){
playerValue[i] = 0;
}
}
/**
* Start actions(Server part!)
*/
public void startGame(){
utils = new Utils();
ArrayList<Add> add = new ArrayList<Add>();
planets = new HashMap<Integer, Planet>();
int planetID = utils.GetNewPlanetID();
planets.put(planetID, new Planet(200, 200, planetRadius, timeToControl, timeToRespawn, 1));
add.add(new Add(planetID, 1, 200, 200, planetRadius));
planetID = utils.GetNewPlanetID();
planets.put(planetID, new Planet(600, 200, planetRadius, timeToControl, timeToRespawn, 2));
add.add(new Add(planetID, 2, 600, 200, planetRadius));
planetID = utils.GetNewPlanetID();
planets.put(planetID, new Planet(300, 400, planetRadius, timeToControl, timeToRespawn, Utils.NEUTRAL_OWNER_ID));
add.add(new Add(planetID, Utils.NEUTRAL_OWNER_ID, 300, 400, planetRadius));
planetID = utils.GetNewPlanetID();
planets.put(planetID, new Planet(300, 100, planetRadius, timeToControl, timeToRespawn, Utils.NEUTRAL_OWNER_ID));
add.add(new Add(planetID, Utils.NEUTRAL_OWNER_ID, 300, 100, planetRadius));
for (Planet planet: planets.values()){
for (int i = 0; i < size; i++){
double angle = (2*Math.PI)/size*i;
float radius = planet.getFigure().radius + 2*mobRadius;
float posX = (float) (planet.getFigure().x + radius*Math.cos(angle));
float posY = (float) (planet.getFigure().y + radius*Math.sin(angle));
mobs.put(mobs.size() + 50, new Mob(posX, posY, mobRadius, HP, reloadTime, attackRadius, damage, planet.getOwnerID()));
add.add(new Add(mobs.size() + 50, planet.getOwnerID(), posX, posY, mobRadius));
}
}
StartConfiguration setupConfig = new StartConfiguration(add, 1, 1024, 600);
messageServer.SendTo(1, utils.createOutputString(setupConfig));
setupConfig.receiverID = 2;
messageServer.SendTo(2, utils.createOutputString(setupConfig));
time = System.currentTimeMillis();
messageServer.SendTo(1, utils.createOutputString(new PingCommand(1)));
myTimer.schedule(new timerUpdate(), 0, 33);
}
/**
* Update method
* @param delta - delta time
*/
public void update(float delta) {
for(int i = 0; i < playerValue.length; i++){
playerValue[i] = 0;
}
for (Map.Entry<Integer, Planet> planet: planets.entrySet()) {
planet.getValue().update(this, delta);
if(planet.getValue().isNewMobRespawn()){
respawnToPlanet(planet.getValue());
}
planet.getValue().setInvader(whoIsInvader(planet.getValue()));
if(planet.getValue().isNewOwner()){
messageServer.addToOutputQueue(utils.createOutputString(new NewOwner(planet.getKey(), planet.getValue().getOwnerID())));
planet.getValue().setNewOwner(false);
}
if(planet.getValue().getOwnerID() != Utils.NEUTRAL_OWNER_ID){
playerValue[planet.getValue().getOwnerID()-1]++;
}
}
Iterator<Map.Entry<Integer, Mob>> iterator = mobs.entrySet().iterator();
while (iterator.hasNext())
{
Entry<Integer, Mob> mob = iterator.next();
if(mob.getValue().isRemove()){
messageServer.addToOutputQueue(utils.createOutputString(new Remove(mob.getKey())));
iterator.remove();
} else {
if(mob.getValue().isAttack()){
mob.getValue().setAttack(false);
messageServer.addToOutputQueue(utils.createOutputString(new Attack(mob.getValue().getAttackedMob(), mob.getKey())));
}
mob.getValue().update(this, delta);
}
if(mob.getValue().getOwnerID() != Utils.NEUTRAL_OWNER_ID){
playerValue[mob.getValue().getOwnerID()-1]++;
}
}
deltaTime += delta;
if(deltaTime >= 2){
deltaTime = 0;
ArrayList<Integer> id = new ArrayList<>();
ArrayList<Float> xPosition = new ArrayList<>();
ArrayList<Float> yPosition = new ArrayList<>();
for (Map.Entry<Integer, Planet> planet: planets.entrySet()) {
id.add(planet.getKey());
xPosition.add(planet.getValue().getFigure().x);
yPosition.add(planet.getValue().getFigure().y);
}
for (Map.Entry<Integer, Mob> mob: mobs.entrySet()) {
id.add(mob.getKey());
xPosition.add(mob.getValue().getFigure().x);
yPosition.add(mob.getValue().getFigure().y);
}
messageServer.addToOutputQueue(utils.createOutputString(new DeltaUpdate(id, xPosition, yPosition)));
}
}
private void respawnToPlanet(Planet planet){
planet.resetMobRestpawn();
float radius = planet.getFigure().radius + 2*mobRadius;
boolean isAdded = false;
int number = 0;
while(!isAdded) {
if(number%size==0){
radius += 4*mobRadius;
}
isAdded = true;
double angle = (2 * Math.PI) / size * number;
float posX = (float) (planet.getFigure().x + radius * Math.cos(angle));
float posY = (float) (planet.getFigure().y + radius * Math.sin(angle));
for(Map.Entry<Integer, Mob> mob: mobs.entrySet()){
if(mob.getValue().getFigure().overlaps(new Circle(posX, posY, mobRadius))){
number++;
isAdded = false;
break;
}
}
if(isAdded) {
Mob newMob = new Mob(posX, posY, mobRadius, HP, reloadTime, attackRadius, damage, planet.getOwnerID());
int id = utils.GetNewMobID();
messageServer.addToOutputQueue(utils.createOutputString(new Add(id, planet.getOwnerID(), posX, posY, mobRadius)));
mobs.put(id, newMob);
}
}
}
/**
* If near planet only one type enemy return his name
* @param planet - our planet
* @return - enemy name
*/
private int whoIsInvader(Planet planet){
int invader = -1;
for (Mob mob: mobs.values()){
if(mob.getFigure().overlaps(new Circle(planet.getFigure().x, planet.getFigure().y, 2*planet.getFigure().radius))){
if(planet.getOwnerID() == Utils.NEUTRAL_OWNER_ID){
if(invader == -1){
invader = mob.getOwnerID();
} else if(invader != mob.getOwnerID()){
return -1;
}
} else {
if(mob.getOwnerID() != planet.getOwnerID()){
return Utils.NEUTRAL_OWNER_ID;
}
}
}
}
return invader;
}
public float getTimeToControl() {
return timeToControl;
}
public float getTimeToRespawn() {
return timeToRespawn;
}
public float getReloadTime() {
return reloadTime;
}
/**
* Move object to free point or follow for target
* @param newX - target position x
* @param newY - target position y
* @param target - target
*/
public void moveToPoint(float newX, float newY, int targetID, boolean itIsMine){
for(Integer id: selectedID){
if(mobs.containsKey(id)){
mobs.get(id).setIsSelected(true);
mobs.get(id).setNextPosition(newX, newY, targetID);
} else if(planets.containsKey(id)){
planets.get(id).setIsSelected(true);
planets.get(id).setNextPosition(newX, newY, targetID);
}
}
selectedID.clear();
}
public void setSelectedID(ArrayList<Integer> selectedID) {
this.selectedID = selectedID;
}
}
| 10,345 | 0.567557 | 0.555556 | 298 | 33.671143 | 28.182755 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.265101 | false | false | 2 |
d8d18ae3d6bf787664755e11919a57b54dcd9814 | 1,142,461,361,585 | da18db7d2acbc1a2df0604d76f3752f8d90d7141 | /src/cn/itcast/crm/dao/ISysPopedomPrivilegeDao.java | 0c87b9517a884f9625e2714f3024472e4185f72d | []
| no_license | liaowuhen88/zhilibao | https://github.com/liaowuhen88/zhilibao | a70176c480f17844c7266b1145b352c032e10e2f | be3fc12a7c1600bb08e89635acf47c5cf3cbe1b9 | refs/heads/master | 2016-08-04T03:25:07.873000 | 2015-08-09T05:33:32 | 2015-08-09T05:33:32 | 40,425,572 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.itcast.crm.dao;
import java.util.LinkedHashMap;
import java.util.List;
import cn.itcast.crm.domain.SysPopedomPrivilege;
public interface ISysPopedomPrivilegeDao extends ICommonDao<SysPopedomPrivilege> {
public final static String SERVICE_NAME="cn.itcast.crm.dao.impl.SysMenuPrivilegeDaoImpl";
}
| UTF-8 | Java | 326 | java | ISysPopedomPrivilegeDao.java | Java | []
| null | []
| package cn.itcast.crm.dao;
import java.util.LinkedHashMap;
import java.util.List;
import cn.itcast.crm.domain.SysPopedomPrivilege;
public interface ISysPopedomPrivilegeDao extends ICommonDao<SysPopedomPrivilege> {
public final static String SERVICE_NAME="cn.itcast.crm.dao.impl.SysMenuPrivilegeDaoImpl";
}
| 326 | 0.788344 | 0.788344 | 12 | 25.166666 | 31.400194 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.583333 | false | false | 2 |
298735d7847726f437ebe9e7cdef471406fa78e3 | 14,216,341,788,190 | 41ff1148b8a4f85b5c0b92012e15f871397d4f41 | /src/main/lang/types/functions/FunctionCall.java | e1447820f66d2d2bbcaea90dc5a4e7e434f6e9d2 | []
| no_license | Yhtiyar/LISP-dialect | https://github.com/Yhtiyar/LISP-dialect | 68819372e3e07bcda302c3436a0872b1034d16db | 4c4a2910515677e44fbea209a5110607b254bd7a | refs/heads/master | 2023-03-04T14:17:41.732000 | 2021-02-18T14:50:24 | 2021-02-18T14:50:24 | 302,747,422 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package main.lang.types.functions;
import main.lang.Expression;
import java.util.ArrayList;
/**
* @author Yhtyyar created on 08.10.2020
*/
public abstract class FunctionCall implements Expression {
protected ArrayList<Expression> args;
public FunctionCall(ArrayList<Expression> args) {
this.args = args;
}
protected abstract String getName();
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append('(').append(getName());
for (var arg : args)
sb.append(' ').append(arg.toString());
return sb.append(')').toString();
}
}
| UTF-8 | Java | 642 | java | FunctionCall.java | Java | [
{
"context": "sion;\n\nimport java.util.ArrayList;\n\n/**\n * @author Yhtyyar created on 08.10.2020\n */\npublic abstract class F",
"end": 117,
"score": 0.8269205689430237,
"start": 110,
"tag": "USERNAME",
"value": "Yhtyyar"
}
]
| null | []
| package main.lang.types.functions;
import main.lang.Expression;
import java.util.ArrayList;
/**
* @author Yhtyyar created on 08.10.2020
*/
public abstract class FunctionCall implements Expression {
protected ArrayList<Expression> args;
public FunctionCall(ArrayList<Expression> args) {
this.args = args;
}
protected abstract String getName();
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append('(').append(getName());
for (var arg : args)
sb.append(' ').append(arg.toString());
return sb.append(')').toString();
}
}
| 642 | 0.641745 | 0.629283 | 29 | 21.137932 | 19.812437 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.344828 | false | false | 2 |
ad285e6a098fc784cf9a8936b436c13b6910c3c1 | 16,673,063,112,309 | 19c4d79186dd42bd06db3d0b780fab931af9d0cf | /seleniumCL/src/main/Panels/WallPanel.java | 7867b16da3a430b147b5e1b103a2d6af1710daa2 | []
| no_license | q4chu/git-experiment | https://github.com/q4chu/git-experiment | 8e994180cca4ed1d6df1a586205c08f860661ca4 | 4be3f78e3a440cedad7a1419038f1e869ae096fd | refs/heads/master | 2021-01-20T02:34:02.135000 | 2017-08-24T18:50:28 | 2017-08-24T18:50:28 | 101,326,557 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package main.Panels;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import core.driver.EnhancedBy;
import main.pages.Chatnels;
public class WallPanel extends Chatnels {
ChatnelsManager manager;
private static final String Back_Button = "[id*='wallholder'] .return";
private static final String WallPannel_Proof = "[id*='wallholder']"; //include title, settings, wall, chat lines, front desk
private static final String Add_Button = "[id*='wallholder'] .icon-plus";
private static final String Note_Item = "[id*='wallholder'] .note[class*='wallitem']";
public WallPanel(WebDriver driver, ChatnelsManager manager) {
super(driver);
this.manager = manager;
}
public EnhancedBy byBackButton(){
return BySelector(By.cssSelector(Back_Button), "back button");
}
public EnhancedBy byAddButton(){
return BySelector(By.cssSelector(Add_Button), "add button");
}
public EnhancedBy byWallPanelProof(){
return BySelector(By.cssSelector(WallPannel_Proof), "wall panel proof");
}
public EnhancedBy byWallNoteItem(){
return BySelector(By.cssSelector(Note_Item), "wall note item");
}
}
| UTF-8 | Java | 1,127 | java | WallPanel.java | Java | []
| null | []
| package main.Panels;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import core.driver.EnhancedBy;
import main.pages.Chatnels;
public class WallPanel extends Chatnels {
ChatnelsManager manager;
private static final String Back_Button = "[id*='wallholder'] .return";
private static final String WallPannel_Proof = "[id*='wallholder']"; //include title, settings, wall, chat lines, front desk
private static final String Add_Button = "[id*='wallholder'] .icon-plus";
private static final String Note_Item = "[id*='wallholder'] .note[class*='wallitem']";
public WallPanel(WebDriver driver, ChatnelsManager manager) {
super(driver);
this.manager = manager;
}
public EnhancedBy byBackButton(){
return BySelector(By.cssSelector(Back_Button), "back button");
}
public EnhancedBy byAddButton(){
return BySelector(By.cssSelector(Add_Button), "add button");
}
public EnhancedBy byWallPanelProof(){
return BySelector(By.cssSelector(WallPannel_Proof), "wall panel proof");
}
public EnhancedBy byWallNoteItem(){
return BySelector(By.cssSelector(Note_Item), "wall note item");
}
}
| 1,127 | 0.745342 | 0.745342 | 35 | 31.200001 | 31.125368 | 125 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.571429 | false | false | 2 |
edfa6d554f72f221ae87a3862d226e2c958f7589 | 25,529,285,642,404 | 183d057ee3f1255551c9f2bc6080dfcc23262639 | /app/src/main/java/com/cliffex/videomaker/videoeditor/introvd/template/editor/effects/customwatermark/C6091d.java | f8bed89c86c38612fefaf09186a684425f93cd13 | []
| no_license | datcoind/VideoMaker-1 | https://github.com/datcoind/VideoMaker-1 | 5567ff713f771b19154ba463469b97d18d0164ec | bcd6697db53b1e76ee510e6e805e46b24a4834f4 | refs/heads/master | 2023-03-19T20:33:16.016000 | 2019-09-27T13:55:07 | 2019-09-27T13:55:07 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.introvd.template.editor.effects.customwatermark;
import com.introvd.template.module.iap.C8049f;
import com.introvd.template.module.iap.C8072q;
import com.introvd.template.module.iap.business.p349a.C7825a;
/* renamed from: com.introvd.template.editor.effects.customwatermark.d */
public class C6091d {
private static volatile C6091d cJI;
private C6096h cJG;
private C6091d() {
}
public static C6091d ajW() {
if (cJI == null) {
synchronized (C6091d.class) {
if (cJI == null) {
cJI = new C6091d();
}
}
}
return cJI;
}
/* renamed from: a */
public void mo28829a(C6096h hVar) {
this.cJG = hVar;
}
public C6096h ajX() {
if (!C8049f.aBf().aBr() || C8072q.aBx().mo33072ku(C7825a.USER_WATER_MARK.getId())) {
return this.cJG;
}
return null;
}
public boolean ajY() {
return this.cJG != null;
}
}
| UTF-8 | Java | 1,008 | java | C6091d.java | Java | []
| null | []
| package com.introvd.template.editor.effects.customwatermark;
import com.introvd.template.module.iap.C8049f;
import com.introvd.template.module.iap.C8072q;
import com.introvd.template.module.iap.business.p349a.C7825a;
/* renamed from: com.introvd.template.editor.effects.customwatermark.d */
public class C6091d {
private static volatile C6091d cJI;
private C6096h cJG;
private C6091d() {
}
public static C6091d ajW() {
if (cJI == null) {
synchronized (C6091d.class) {
if (cJI == null) {
cJI = new C6091d();
}
}
}
return cJI;
}
/* renamed from: a */
public void mo28829a(C6096h hVar) {
this.cJG = hVar;
}
public C6096h ajX() {
if (!C8049f.aBf().aBr() || C8072q.aBx().mo33072ku(C7825a.USER_WATER_MARK.getId())) {
return this.cJG;
}
return null;
}
public boolean ajY() {
return this.cJG != null;
}
}
| 1,008 | 0.573413 | 0.500992 | 41 | 23.585365 | 21.475994 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.341463 | false | false | 2 |
6dad5012f5da7b2b151f994060a6a64744aef55e | 24,653,112,300,948 | 18edc4c759b5a2a3405282fe0d875f03525c60ff | /rxjava_example/src/main/java/com/hardrubic/rxjava/operator/combining/MergeOperator.java | 5bc65ed9acfe3d575c9f2786ba65166f0fb3dabf | []
| no_license | hardrubic/AndroidDemo2.0 | https://github.com/hardrubic/AndroidDemo2.0 | 2bdd15c86d8489a054fccf5729078aa294254a03 | 2cf448b6c74815631243893329dff9b50be666ff | refs/heads/master | 2019-04-30T21:12:06.709000 | 2018-07-12T00:26:41 | 2018-07-12T00:26:41 | 46,263,897 | 11 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hardrubic.rxjava.operator.combining;
import java.util.concurrent.CountDownLatch;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
/**
* 按多条流的输出顺序,组合成一条新的流
*/
public class MergeOperator {
public static void main(String[] args) throws Exception {
Observable<Long> observable1 = Observable.create(new ObservableOnSubscribe<Long>() {
@Override
public void subscribe(@NonNull ObservableEmitter<Long> emitter) throws Exception {
for (int i = 0; i < 10; i++) {
emitter.onNext(Long.valueOf(i));
try {
Thread.sleep(1000);
} catch (Exception e) {
}
//触发出错
if (i == 5) {
emitter.onError(new Exception("error"));
}
}
}
}).subscribeOn(Schedulers.newThread());
Observable<Long> observable2 = Observable.create(new ObservableOnSubscribe<Long>() {
@Override
public void subscribe(@NonNull ObservableEmitter<Long> emitter) throws Exception {
for (int i = 100; i < 110; i++) {
emitter.onNext(Long.valueOf(i));
try {
Thread.sleep(2000);
} catch (Exception e) {
}
}
}
}).subscribeOn(Schedulers.newThread());
/*
1、merge:有一个流出错后,直接error
2、mergeDelayError:有一个流出错后,这个流停止,其他流继续
*/
CountDownLatch latch = new CountDownLatch(20);
Observable.mergeDelayError(observable1, observable2)
.subscribe(new Consumer<Long>() {
@Override
public void accept(@NonNull Long aLong) throws Exception {
System.out.println(aLong);
latch.countDown();
}
}, new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
System.out.println(throwable.getMessage());
}
}, new Action() {
@Override
public void run() throws Exception {
System.out.println("complete");
}
});
latch.await();
}
}
| UTF-8 | Java | 2,814 | java | MergeOperator.java | Java | []
| null | []
| package com.hardrubic.rxjava.operator.combining;
import java.util.concurrent.CountDownLatch;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
/**
* 按多条流的输出顺序,组合成一条新的流
*/
public class MergeOperator {
public static void main(String[] args) throws Exception {
Observable<Long> observable1 = Observable.create(new ObservableOnSubscribe<Long>() {
@Override
public void subscribe(@NonNull ObservableEmitter<Long> emitter) throws Exception {
for (int i = 0; i < 10; i++) {
emitter.onNext(Long.valueOf(i));
try {
Thread.sleep(1000);
} catch (Exception e) {
}
//触发出错
if (i == 5) {
emitter.onError(new Exception("error"));
}
}
}
}).subscribeOn(Schedulers.newThread());
Observable<Long> observable2 = Observable.create(new ObservableOnSubscribe<Long>() {
@Override
public void subscribe(@NonNull ObservableEmitter<Long> emitter) throws Exception {
for (int i = 100; i < 110; i++) {
emitter.onNext(Long.valueOf(i));
try {
Thread.sleep(2000);
} catch (Exception e) {
}
}
}
}).subscribeOn(Schedulers.newThread());
/*
1、merge:有一个流出错后,直接error
2、mergeDelayError:有一个流出错后,这个流停止,其他流继续
*/
CountDownLatch latch = new CountDownLatch(20);
Observable.mergeDelayError(observable1, observable2)
.subscribe(new Consumer<Long>() {
@Override
public void accept(@NonNull Long aLong) throws Exception {
System.out.println(aLong);
latch.countDown();
}
}, new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
System.out.println(throwable.getMessage());
}
}, new Action() {
@Override
public void run() throws Exception {
System.out.println("complete");
}
});
latch.await();
}
}
| 2,814 | 0.512186 | 0.502585 | 78 | 33.717949 | 24.464993 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.397436 | false | false | 2 |
cc34f90a70a119f8db60afa3b548da7e5ed14201 | 34,376,918,237,329 | 3790827d3779d8588021879592bc0a29dac24dcb | /woody-thrift/src/main/java/com/rbkmoney/woody/thrift/impl/http/THSpawnClientBuilder.java | b8789f38dfb831bc8ebc56636d26cfaac38844a6 | [
"Apache-2.0"
]
| permissive | rbkmoney/woody_java | https://github.com/rbkmoney/woody_java | 2d0bdece94ec41c202cf60549c1b696447bb0ecb | d91add8d1e6cf8ed48d4c0d82cff4f6c8f04fc94 | refs/heads/master | 2023-06-18T03:23:57.730000 | 2021-07-16T12:31:07 | 2021-07-16T12:31:07 | 56,760,557 | 1 | 0 | Apache-2.0 | false | 2021-07-16T12:31:07 | 2016-04-21T09:24:59 | 2020-10-13T13:53:11 | 2021-07-16T12:31:07 | 507 | 1 | 0 | 5 | Java | false | false | package com.rbkmoney.woody.thrift.impl.http;
import com.rbkmoney.woody.api.WoodyInstantiationException;
import com.rbkmoney.woody.api.event.ClientEventListener;
import com.rbkmoney.woody.api.flow.error.WErrorMapper;
import com.rbkmoney.woody.api.generator.IdGenerator;
import com.rbkmoney.woody.api.proxy.InvocationTargetProvider;
import com.rbkmoney.woody.api.proxy.SpawnTargetProvider;
import com.rbkmoney.woody.api.trace.context.metadata.MetadataExtensionKit;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import java.net.URI;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
/**
* This builder provides the ability to build thread-safe clients around not thread-safe Thrift clients.
* It creates new Thrift client instance for every call which is dropped after call finishes.
*/
public class THSpawnClientBuilder extends THClientBuilder {
public THSpawnClientBuilder() {
}
@Override
public THSpawnClientBuilder withErrorMapper(WErrorMapper errorMapper) {
return (THSpawnClientBuilder) super.withErrorMapper(errorMapper);
}
@Override
public THSpawnClientBuilder withHttpClient(HttpClient httpClient) {
return (THSpawnClientBuilder) super.withHttpClient(httpClient);
}
@Override
public THSpawnClientBuilder withMetaExtensions(List<MetadataExtensionKit> extensionKits) {
return (THSpawnClientBuilder) super.withMetaExtensions(extensionKits);
}
@Override
public THSpawnClientBuilder withNetworkTimeout(int timeout) {
return (THSpawnClientBuilder) super.withNetworkTimeout(timeout);
}
@Override
public THSpawnClientBuilder withLogEnabled(boolean enabled) {
return (THSpawnClientBuilder) super.withLogEnabled(enabled);
}
@Override
public THSpawnClientBuilder withAddress(URI address) {
return (THSpawnClientBuilder) super.withAddress(address);
}
@Override
public THSpawnClientBuilder withEventListener(ClientEventListener listener) {
return (THSpawnClientBuilder) super.withEventListener(listener);
}
@Override
public THSpawnClientBuilder withIdGenerator(IdGenerator generator) {
return (THSpawnClientBuilder) super.withIdGenerator(generator);
}
@Override
public <T> T build(Class<T> iface) throws WoodyInstantiationException {
try {
return build(iface, createTargetProvider(iface));
} catch (WoodyInstantiationException e) {
throw e;
} catch (Exception e) {
throw new WoodyInstantiationException(e);
}
}
@Override
protected HttpClient createHttpClient() {
return HttpClients.createMinimal(new BasicHttpClientConnectionManager());
}
private <T> InvocationTargetProvider<T> createTargetProvider(Class<T> iface) {
return new THSpawnTargetProvider<>(
iface,
() -> createProviderClient(iface),
this::destroyProviderClient,
isCustomHttpClient());
}
private static class THSpawnTargetProvider<T> extends SpawnTargetProvider<T> {
private final boolean customClient;
private final BiConsumer<Object, Boolean> releaseConsumer;
public THSpawnTargetProvider(Class<T> targetType, Supplier<T> supplier, BiConsumer<Object, Boolean> releaseConsumer, boolean customClient) {
super(targetType, supplier);
this.customClient = customClient;
this.releaseConsumer = releaseConsumer;
}
@Override
public void releaseTarget(T target) {
releaseConsumer.accept(target, customClient);
super.releaseTarget(target);
}
}
}
| UTF-8 | Java | 3,845 | java | THSpawnClientBuilder.java | Java | []
| null | []
| package com.rbkmoney.woody.thrift.impl.http;
import com.rbkmoney.woody.api.WoodyInstantiationException;
import com.rbkmoney.woody.api.event.ClientEventListener;
import com.rbkmoney.woody.api.flow.error.WErrorMapper;
import com.rbkmoney.woody.api.generator.IdGenerator;
import com.rbkmoney.woody.api.proxy.InvocationTargetProvider;
import com.rbkmoney.woody.api.proxy.SpawnTargetProvider;
import com.rbkmoney.woody.api.trace.context.metadata.MetadataExtensionKit;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import java.net.URI;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
/**
* This builder provides the ability to build thread-safe clients around not thread-safe Thrift clients.
* It creates new Thrift client instance for every call which is dropped after call finishes.
*/
public class THSpawnClientBuilder extends THClientBuilder {
public THSpawnClientBuilder() {
}
@Override
public THSpawnClientBuilder withErrorMapper(WErrorMapper errorMapper) {
return (THSpawnClientBuilder) super.withErrorMapper(errorMapper);
}
@Override
public THSpawnClientBuilder withHttpClient(HttpClient httpClient) {
return (THSpawnClientBuilder) super.withHttpClient(httpClient);
}
@Override
public THSpawnClientBuilder withMetaExtensions(List<MetadataExtensionKit> extensionKits) {
return (THSpawnClientBuilder) super.withMetaExtensions(extensionKits);
}
@Override
public THSpawnClientBuilder withNetworkTimeout(int timeout) {
return (THSpawnClientBuilder) super.withNetworkTimeout(timeout);
}
@Override
public THSpawnClientBuilder withLogEnabled(boolean enabled) {
return (THSpawnClientBuilder) super.withLogEnabled(enabled);
}
@Override
public THSpawnClientBuilder withAddress(URI address) {
return (THSpawnClientBuilder) super.withAddress(address);
}
@Override
public THSpawnClientBuilder withEventListener(ClientEventListener listener) {
return (THSpawnClientBuilder) super.withEventListener(listener);
}
@Override
public THSpawnClientBuilder withIdGenerator(IdGenerator generator) {
return (THSpawnClientBuilder) super.withIdGenerator(generator);
}
@Override
public <T> T build(Class<T> iface) throws WoodyInstantiationException {
try {
return build(iface, createTargetProvider(iface));
} catch (WoodyInstantiationException e) {
throw e;
} catch (Exception e) {
throw new WoodyInstantiationException(e);
}
}
@Override
protected HttpClient createHttpClient() {
return HttpClients.createMinimal(new BasicHttpClientConnectionManager());
}
private <T> InvocationTargetProvider<T> createTargetProvider(Class<T> iface) {
return new THSpawnTargetProvider<>(
iface,
() -> createProviderClient(iface),
this::destroyProviderClient,
isCustomHttpClient());
}
private static class THSpawnTargetProvider<T> extends SpawnTargetProvider<T> {
private final boolean customClient;
private final BiConsumer<Object, Boolean> releaseConsumer;
public THSpawnTargetProvider(Class<T> targetType, Supplier<T> supplier, BiConsumer<Object, Boolean> releaseConsumer, boolean customClient) {
super(targetType, supplier);
this.customClient = customClient;
this.releaseConsumer = releaseConsumer;
}
@Override
public void releaseTarget(T target) {
releaseConsumer.accept(target, customClient);
super.releaseTarget(target);
}
}
}
| 3,845 | 0.725098 | 0.725098 | 110 | 33.954544 | 31.528454 | 148 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.418182 | false | false | 2 |
bd15fdc0085000b6cceb9865a252f8235f0e5fbb | 6,330,781,816,258 | 713f911c5032dfc27dfd7849c81094567bb30c71 | /SOAR/src/main/java/com/capstone/soar/domain/projections/dev/CartView.java | 95bfec4715fa2ecf8c4e1df11fb0fd180ff4efbd | [
"MIT"
]
| permissive | ckyvs/SOAR | https://github.com/ckyvs/SOAR | 941ed380c8aab3d62631dd4d98e79ba68cdfded2 | 3042476b2d37b2ea184bcdf7104c5d066f0c77ee | refs/heads/master | 2022-12-25T23:45:37.827000 | 2020-10-02T14:53:11 | 2020-10-02T14:53:11 | 296,237,050 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.capstone.soar.domain.projections.dev;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
public class CartView {
@Value("#{target.inventories")
private List<DevInventoryView> inventories;
String remarks;
public void setInventories(List<DevInventoryView> inventories) {
this.inventories = inventories;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
List<DevInventoryView> getInventories(){
return this.inventories;
}
String getRemarks() {
return this.remarks;
}
}
| UTF-8 | Java | 557 | java | CartView.java | Java | []
| null | []
| package com.capstone.soar.domain.projections.dev;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
public class CartView {
@Value("#{target.inventories")
private List<DevInventoryView> inventories;
String remarks;
public void setInventories(List<DevInventoryView> inventories) {
this.inventories = inventories;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
List<DevInventoryView> getInventories(){
return this.inventories;
}
String getRemarks() {
return this.remarks;
}
}
| 557 | 0.759426 | 0.759426 | 26 | 20.384615 | 19.701771 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.192308 | false | false | 2 |
878b918f41ab7ccd7a9a7f0e1deb17bd9216ffda | 24,275,155,163,790 | 7ab317247dd44eb99b9b6b880c9c847f3c98cf1c | /jee-parent/jee-bl/src/main/java/jee/mif/bl/services/SurveyService.java | e72e5bcf3b2d4129e3dcf5a0f1a6288576b16ca7 | []
| no_license | s33kers/jee | https://github.com/s33kers/jee | 1c302a210c55e63fb65ab930818f186ab600802a | 0ef3511c6913dccc96f95bde65b7196d1db7f839 | refs/heads/master | 2020-03-18T11:22:37.633000 | 2018-05-24T05:58:30 | 2018-05-24T05:58:30 | 134,667,496 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package jee.mif.bl.services;
import jee.mif.bl.model.Result;
import jee.mif.model.survey.BaseQuestion;
import jee.mif.model.survey.Page;
import jee.mif.model.survey.Survey;
import java.io.OutputStream;
import java.util.List;
public interface SurveyService {
Result<Survey> createNew();
Result<Page> getPage(Long surveyId, int pageNumber);
Result<Survey> createPage(Long surveyId, int pageNumber);
Result<Survey> deletePage(Long surveyId, int pageNumber);
Result<Survey> getSurvey(Long id);
Result<Survey> getSurveyForImportDetails(Long id);
Result<Survey> getSurveyForEdit(Long id);
Result<List<Survey>> getAllSurveys();
Result<Survey> createAnswering(String uuidSurvey);
Result<Survey> save(Survey survey);
Result<Survey> publish(Long id);
Result deleteSurvey(Long surveyId);
Result<Void> exportSurvey(Long surveyId, OutputStream outputStream);
}
| UTF-8 | Java | 916 | java | SurveyService.java | Java | []
| null | []
| package jee.mif.bl.services;
import jee.mif.bl.model.Result;
import jee.mif.model.survey.BaseQuestion;
import jee.mif.model.survey.Page;
import jee.mif.model.survey.Survey;
import java.io.OutputStream;
import java.util.List;
public interface SurveyService {
Result<Survey> createNew();
Result<Page> getPage(Long surveyId, int pageNumber);
Result<Survey> createPage(Long surveyId, int pageNumber);
Result<Survey> deletePage(Long surveyId, int pageNumber);
Result<Survey> getSurvey(Long id);
Result<Survey> getSurveyForImportDetails(Long id);
Result<Survey> getSurveyForEdit(Long id);
Result<List<Survey>> getAllSurveys();
Result<Survey> createAnswering(String uuidSurvey);
Result<Survey> save(Survey survey);
Result<Survey> publish(Long id);
Result deleteSurvey(Long surveyId);
Result<Void> exportSurvey(Long surveyId, OutputStream outputStream);
}
| 916 | 0.745633 | 0.745633 | 38 | 23.105263 | 22.82057 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.631579 | false | false | 2 |
99cae0f5255e4cc5aa990efab10e620a147a3159 | 22,471,268,928,572 | a827822619ab43d3d1d98f8a59589a713845a649 | /marvel-character-service/src/main/test/java/com/acacia/service/TestUtil.java | 8e2f6e025ea9d3ee67b77e49431d911726239784 | []
| no_license | nkasvosve/marvel-characters | https://github.com/nkasvosve/marvel-characters | 1f8b0b0e55b980857a42290c662d201fed27d761 | 5dd995ac7a685073927d8f9c9bb85ff7b4f3d270 | refs/heads/master | 2021-08-19T17:43:22.066000 | 2017-11-27T03:56:53 | 2017-11-27T03:56:53 | 112,112,225 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.acme.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.http.MediaType;
import java.nio.charset.Charset;
public class TestUtil {
public static String toJson(Object object) throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
return ow.writeValueAsString(object);
}
public static final MediaType APPLICATION_JSON_UTF8 =
new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
}
| UTF-8 | Java | 795 | java | TestUtil.java | Java | []
| null | []
| package com.acme.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.http.MediaType;
import java.nio.charset.Charset;
public class TestUtil {
public static String toJson(Object object) throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
return ow.writeValueAsString(object);
}
public static final MediaType APPLICATION_JSON_UTF8 =
new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
}
| 795 | 0.762264 | 0.759748 | 21 | 36.857143 | 32.794144 | 130 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 2 |
dfb4a63420f17c7725a1334cce756725cef71b86 | 6,055,903,940,989 | 889ddc436e8e53e49ef023a21258e815a03170ee | /d5_projeto_de_bloco-desenvolvimento_java/TPs/tp9/ProjetoBlocoJava/src/java/br/com/infnet/model/Registro.java | dd6c2fd61e9e423fb8093e7dd7fd8b19ac9a1026 | []
| no_license | mvaldetaro/JAVA | https://github.com/mvaldetaro/JAVA | 26502b2ed68ef0e3282ecaf87cdf51dcfc71b257 | 6e0dbd21781e40861a38f726b81b2a8c30f39c01 | refs/heads/master | 2020-03-26T11:13:39.432000 | 2018-08-14T23:02:53 | 2018-08-14T23:02:53 | 144,834,264 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.infnet.model;
import java.io.Serializable;
import java.sql.Time;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Temporal;
@Entity
public class Registro implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int idhistorico_compras;
private int ID;
private int idsessao;
private int idevento;
private int idassentos;
private String titulo;
private int preco;
@Temporal(javax.persistence.TemporalType.DATE)
private Date data;
private Time horario;
private String status;
public int getIdhistorico_compras() {
return idhistorico_compras;
}
public void setIdhistorico_compras(int idhistorico_compras) {
this.idhistorico_compras = idhistorico_compras;
}
public int getID() {
return ID;
}
public void setID(int ID) {
this.ID = ID;
}
public int getIdsessao() {
return idsessao;
}
public void setIdsessao(int idsessao) {
this.idsessao = idsessao;
}
public int getIdevento() {
return idevento;
}
public void setIdevento(int idevento) {
this.idevento = idevento;
}
public int getIdassentos() {
return idassentos;
}
public void setIdassentos(int idassentos) {
this.idassentos = idassentos;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public int getPreco() {
return preco;
}
public void setPreco(int preco) {
this.preco = preco;
}
public Date getData() {
return data;
}
public void setData(Date data) {
this.data = data;
}
public Time getHorario() {
return horario;
}
public void setHorario(Time horario) {
this.horario = horario;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
| UTF-8 | Java | 2,196 | java | Registro.java | Java | []
| null | []
| package br.com.infnet.model;
import java.io.Serializable;
import java.sql.Time;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Temporal;
@Entity
public class Registro implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int idhistorico_compras;
private int ID;
private int idsessao;
private int idevento;
private int idassentos;
private String titulo;
private int preco;
@Temporal(javax.persistence.TemporalType.DATE)
private Date data;
private Time horario;
private String status;
public int getIdhistorico_compras() {
return idhistorico_compras;
}
public void setIdhistorico_compras(int idhistorico_compras) {
this.idhistorico_compras = idhistorico_compras;
}
public int getID() {
return ID;
}
public void setID(int ID) {
this.ID = ID;
}
public int getIdsessao() {
return idsessao;
}
public void setIdsessao(int idsessao) {
this.idsessao = idsessao;
}
public int getIdevento() {
return idevento;
}
public void setIdevento(int idevento) {
this.idevento = idevento;
}
public int getIdassentos() {
return idassentos;
}
public void setIdassentos(int idassentos) {
this.idassentos = idassentos;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public int getPreco() {
return preco;
}
public void setPreco(int preco) {
this.preco = preco;
}
public Date getData() {
return data;
}
public void setData(Date data) {
this.data = data;
}
public Time getHorario() {
return horario;
}
public void setHorario(Time horario) {
this.horario = horario;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
| 2,196 | 0.633424 | 0.633424 | 109 | 19.14679 | 16.249107 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.357798 | false | false | 2 |
f29bc556d7ff882d5ef61047a4d2a3a9d30e1701 | 6,055,903,941,353 | fef06f8de6e249ec3793a0ef3721301093b807b5 | /src/main/java/com/demo/model/Device.java | 2636e8f41610211b8ce2b45ffac6c1d6d4dcae1f | []
| no_license | VelaDev/Repo | https://github.com/VelaDev/Repo | c9440e844d4ecbbf2047aa76c08f0bbd998fac11 | f02edda91b889660ab45218364e387da86d1c5d0 | refs/heads/latestBrunch | 2020-05-22T04:25:33.572000 | 2016-11-19T09:58:44 | 2016-11-19T09:58:44 | 65,330,727 | 1 | 0 | null | false | 2016-11-19T10:00:01 | 2016-08-09T21:51:23 | 2016-08-09T22:17:44 | 2016-11-19T10:00:00 | 1,162 | 0 | 0 | 1 | Java | null | null | package com.demo.model;
import java.io.Serializable;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Table(name="Products")
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class Device implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@Column(name="SERIAL_NUMBER")
private String serialNumber;
@Column(name="PRODUCT_MODEL")
private String productModel;
@Column(name="START_DATE")
private String startDate;
@Column(name="END_DATE")
private String endDate;
@Column(name="INSTALLATION_DATE")
private String installationDate;
@Column(name="DEVICE_LOCATION")
private String deviceLocation;
@ManyToOne
@JoinColumn(name="CLIENT")
private Client client;
@OneToMany(mappedBy ="device", cascade= CascadeType.ALL,fetch=FetchType.LAZY)
private Set<Accessories> accessories;
}
| UTF-8 | Java | 1,322 | java | Device.java | Java | []
| null | []
| package com.demo.model;
import java.io.Serializable;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Table(name="Products")
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class Device implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@Column(name="SERIAL_NUMBER")
private String serialNumber;
@Column(name="PRODUCT_MODEL")
private String productModel;
@Column(name="START_DATE")
private String startDate;
@Column(name="END_DATE")
private String endDate;
@Column(name="INSTALLATION_DATE")
private String installationDate;
@Column(name="DEVICE_LOCATION")
private String deviceLocation;
@ManyToOne
@JoinColumn(name="CLIENT")
private Client client;
@OneToMany(mappedBy ="device", cascade= CascadeType.ALL,fetch=FetchType.LAZY)
private Set<Accessories> accessories;
}
| 1,322 | 0.749622 | 0.748865 | 58 | 20.793104 | 15.98141 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.913793 | false | false | 2 |
b0ffddeba16edb5f72d6cc73c4f1ba7e6a0eb10e | 24,885,040,547,924 | 5bbbae00b8c0d8c2d3295065d28efbe38929bdaa | /DBCA/src/main/java/dbca/utils/DateParser.java | f095016b3d1e0e3a5c4917073fabcd1f55463814 | []
| no_license | anujroxx/DBCA | https://github.com/anujroxx/DBCA | d056ddcee2addf1428999f7f80930c367c135edc | 9c7fb735ed25ab9ab6da04449ace3ce6e75e5136 | refs/heads/master | 2020-04-12T08:28:23.703000 | 2018-12-19T22:30:16 | 2018-12-19T22:30:16 | 162,385,286 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package dbca.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateParser {
private static SimpleDateFormat sdf;
public static String formatDate(Date date) {
sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(date);
}
public static Date parseString(String string) throws ParseException {
sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.parse(string);
}
}
| UTF-8 | Java | 470 | java | DateParser.java | Java | []
| null | []
| package dbca.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateParser {
private static SimpleDateFormat sdf;
public static String formatDate(Date date) {
sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(date);
}
public static Date parseString(String string) throws ParseException {
sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.parse(string);
}
}
| 470 | 0.721277 | 0.721277 | 20 | 21.5 | 19.764868 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.2 | false | false | 2 |
3810d76fbd5f236fe220fc3ff4bb3e823d50cdab | 26,130,581,060,032 | 86e9579153cc43c92eacaec1f2f38c59463c8429 | /javajokes/src/main/java/com/example/Joke.java | ff103e4c372f513f25e30c3459d7b4ca5361fb14 | []
| no_license | shivamras304/Build-It-Bigger | https://github.com/shivamras304/Build-It-Bigger | eee0804667642f5149c119deaeaf6120ad27cea3 | 9129861188ab74d95de19b4752d196de789e98cc | refs/heads/master | 2021-01-12T15:26:39.263000 | 2016-10-26T23:51:49 | 2016-10-26T23:51:49 | 71,784,811 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example;
import java.util.Random;
//All the jokes are taken from http://www.short-funny.com/index.php
public class Joke {
String[] jokesCollection = {
"Can a kangaroo jump higher than a house? Of course, a house doesn’t jump at all.",
"Doctor: \"I'm sorry but you suffer from a terminal illness and have only 10 to live.\"\n" +
"\n" +
"Patient: \"What do you mean, 10? 10 what? Months? Weeks?!\"\n" +
"\n" +
"Doctor: \"Nine.\"",
"A man asks a farmer near a field, “Sorry sir, would you mind if I crossed your field instead of going around it? You see, I have to catch the 4:23 train.”\n" +
"\n" +
"The farmer says, “Sure, go right ahead. And if my bull sees you, you’ll even catch the 4:11 one.\"",
"Anton, do you think I’m a bad mother?\n" +
"\n" +
"My name is Paul.",
"My dog used to chase people on a bike a lot. It got so bad, finally I had to take his bike away.",
"What is the difference between a snowman and a snowwoman?\n" +
"-\n" +
"Snowballs.",
"Mother, “How was school today, Patrick?”\n" +
"\n" +
"Patrick, “It was really great mum! Today we made explosives!”\n" +
"\n" +
"Mother, “Ooh, they do very fancy stuff with you these days. And what will you do at school tomorrow?”\n" +
"\n" +
"Patrick, “What school?\"",
"\"Mom, where do tampons go?\"\n" +
"\n" +
"\"Where the babies come from, darling.\"\n" +
"\n" +
"\"In a stork???!!!\"",
"Scientists have now discovered how women keep their secrets. They do so within groups of 40.",
"My wife’s cooking is so bad we usually pray after our food.",
"Why is it a bad idea for two butt cheeks to get married? Because they part for every little shit.",
"I'd like to buy a new boomerang please. Also, can you tell me how to throw the old one away?",
"Police officer: \"Can you identify yourself, sir?\"\n" +
" \n" +
"Driver pulls out his mirror and says: \"Yes, it's me.\"",
"Coco Chanel once said that you should put perfume on places where you want to be kissed by a man. But hell does that burn!",
"A husband and a wife sit at the table, having dinner. The woman drops a bit of tomato sauce on her white top. \"Och, I look like a pig!\" \n" +
"\n" +
"The man nods, \"And you dropped tomato sauce on your top!\"",
"When my wife starts to sing I always go out and do some garden work so our neighbors can see there's no domestic violence going on.",
"\"Mother, why do people die so quickly in our family?\"\n" +
"...\n" +
"\"Mama?\"\n" +
"\"Mama?\"\n" +
"\"Maaaammaaaaaaa!\"",
"What should you put on the tomb stone of a mathematician?\n" +
"-\n" +
"He didn't count with this...",
"About 4,000 years ago:\n" +
"\n" +
"God: I shall create a great plague and every living thing on Earth will die!\n" +
"\n" +
"Fish: *Winks at God and slips him a $20 note*\n" +
"\n" +
"God: Correction, I shall create a great flood!",
"How can you tell you have a really bad case of acne? \n" +
"\n" +
"It’s when the blind try to read your face.",
"Q. What’s the worst thing about being lonely?\n" +
"\n" +
"A. Playing Frisbee.",
"Me and my wife decided that we don't want to have children anymore. " +
"So anybody who wants one can leave us their phone number and address and we will bring you one.",
"It is so cold outside I saw a politician with his hands in his own pockets.",
"After many years of studying at a university, I’ve finally become a PhD… or Pizza Hut Deliveryman as people call it.",
"There is nothing worse than child polio. No wait, there's women's soccer.",
"Q: Why did the shark keep swimming in circles?\n" +
"\n" +
"A: It had a nosebleed.",
"Pessimist: \"Things just can't get any worse!\" \n" +
"\n" +
"Optimist: \"Nah, of course they can!\"",
"I wanted to grow my own food but I couldn’t get bacon seeds anywhere.",
"I was in a restaurant once and I suddenly realized I desperately needed to pass gas. " +
"The music was really, really loud, so I timed my reliefs to the beat of the music. " +
"After just a few songs I started to feel better. I finished my coffee, " +
"and noticed that everybody was staring at me... " +
"That was when I remembered I was listening to my iPod.",
"Why do women live on average two years longer? Because the time they spend parking doesn’t count.",
"I can’t believe I forgot to go to the gym today. That’s 7 years in a row now.",
"Woke up with a dead leg this morning. I will not take out a loan with the mafia ever again.",
"A naked women robbed a bank. Nobody could remember her face.",
"The 21st century: Deleting history is often more important than making it.",
"What is short and would be very disturbing at breakfast?\n" +
"-\n" +
"\"Hitler\"",
"\"How do you tell that a crab is drunk? It walks forwards.",
"Do you know what you can hold without ever touching it?\n" +
"\n" +
"A conversation.",
"I’ve no home, I haven’t got control, I can’t see any escape. Way past the time I got a new keyboard.",
"Why do cows wear bells?\n" +
" \n" +
"Their horns don’t work.",
"Two grains of sand go through the desert. One to the other: \"I have the feeling somebody is watching me.\"",
"“You are so kind, funny and beautiful.” \n" +
"\n" +
"“Oh come on. You just want to get me to bed.” \n" +
"\n" +
"“And smart, too!”",
"Q: What do politicians and diapers have in common? \n" +
"-\n" +
"A: Both should be changed regularly, and both for the same reason.",
"I’m selling my talking parrot. Why? Because yesterday, the bastard tried to sell me.",
"Do you know why women aren’t allowed in space? \n" +
"-\n" +
"To avoid scenarios like: \"Houston, we have a problem!\" \n" +
"- \n" +
"\"What is the problem?\" \n" +
"-\n" +
"\"Yeah, great, pretend like you don’t know what I’m talking about!\"",
"What would you call a very funny mountain? \n" +
"-\n" +
"Hill Arious\""
};
public String getJoke() {
Random randomGenerator = new Random();
return jokesCollection[randomGenerator.nextInt(jokesCollection.length)];
}
}
| UTF-8 | Java | 7,891 | java | Joke.java | Java | [
{
"context": "you’ll even catch the 4:11 one.\\\"\",\n\n \"Anton, do you think I’m a bad mother?\\n\" +\n ",
"end": 897,
"score": 0.9988373517990112,
"start": 892,
"tag": "NAME",
"value": "Anton"
},
{
"context": " \"\\n\" +\n \"My name is Paul.\",\n\n \"My dog used to chase people on a",
"end": 998,
"score": 0.9996108412742615,
"start": 994,
"tag": "NAME",
"value": "Paul"
},
{
"context": "ls.\",\n\n \"Mother, “How was school today, Patrick?”\\n\" +\n \"\\n\" +\n ",
"end": 1306,
"score": 0.9981926679611206,
"start": 1299,
"tag": "NAME",
"value": "Patrick"
},
{
"context": "+\n \"\\n\" +\n \"Patrick, “It was really great mum! Today we made explosiv",
"end": 1369,
"score": 0.9989045262336731,
"start": 1362,
"tag": "NAME",
"value": "Patrick"
},
{
"context": "+\n \"\\n\" +\n \"Patrick, “What school?\\\"\",\n\n \"\\\"Mom, where do ",
"end": 1639,
"score": 0.9986101388931274,
"start": 1632,
"tag": "NAME",
"value": "Patrick"
},
{
"context": "\n \"-\\n\" +\n \"Hill Arious\\\"\"\n\n };\n\n public String getJoke() {\n ",
"end": 7638,
"score": 0.8633187413215637,
"start": 7627,
"tag": "NAME",
"value": "Hill Arious"
}
]
| null | []
| package com.example;
import java.util.Random;
//All the jokes are taken from http://www.short-funny.com/index.php
public class Joke {
String[] jokesCollection = {
"Can a kangaroo jump higher than a house? Of course, a house doesn’t jump at all.",
"Doctor: \"I'm sorry but you suffer from a terminal illness and have only 10 to live.\"\n" +
"\n" +
"Patient: \"What do you mean, 10? 10 what? Months? Weeks?!\"\n" +
"\n" +
"Doctor: \"Nine.\"",
"A man asks a farmer near a field, “Sorry sir, would you mind if I crossed your field instead of going around it? You see, I have to catch the 4:23 train.”\n" +
"\n" +
"The farmer says, “Sure, go right ahead. And if my bull sees you, you’ll even catch the 4:11 one.\"",
"Anton, do you think I’m a bad mother?\n" +
"\n" +
"My name is Paul.",
"My dog used to chase people on a bike a lot. It got so bad, finally I had to take his bike away.",
"What is the difference between a snowman and a snowwoman?\n" +
"-\n" +
"Snowballs.",
"Mother, “How was school today, Patrick?”\n" +
"\n" +
"Patrick, “It was really great mum! Today we made explosives!”\n" +
"\n" +
"Mother, “Ooh, they do very fancy stuff with you these days. And what will you do at school tomorrow?”\n" +
"\n" +
"Patrick, “What school?\"",
"\"Mom, where do tampons go?\"\n" +
"\n" +
"\"Where the babies come from, darling.\"\n" +
"\n" +
"\"In a stork???!!!\"",
"Scientists have now discovered how women keep their secrets. They do so within groups of 40.",
"My wife’s cooking is so bad we usually pray after our food.",
"Why is it a bad idea for two butt cheeks to get married? Because they part for every little shit.",
"I'd like to buy a new boomerang please. Also, can you tell me how to throw the old one away?",
"Police officer: \"Can you identify yourself, sir?\"\n" +
" \n" +
"Driver pulls out his mirror and says: \"Yes, it's me.\"",
"Coco Chanel once said that you should put perfume on places where you want to be kissed by a man. But hell does that burn!",
"A husband and a wife sit at the table, having dinner. The woman drops a bit of tomato sauce on her white top. \"Och, I look like a pig!\" \n" +
"\n" +
"The man nods, \"And you dropped tomato sauce on your top!\"",
"When my wife starts to sing I always go out and do some garden work so our neighbors can see there's no domestic violence going on.",
"\"Mother, why do people die so quickly in our family?\"\n" +
"...\n" +
"\"Mama?\"\n" +
"\"Mama?\"\n" +
"\"Maaaammaaaaaaa!\"",
"What should you put on the tomb stone of a mathematician?\n" +
"-\n" +
"He didn't count with this...",
"About 4,000 years ago:\n" +
"\n" +
"God: I shall create a great plague and every living thing on Earth will die!\n" +
"\n" +
"Fish: *Winks at God and slips him a $20 note*\n" +
"\n" +
"God: Correction, I shall create a great flood!",
"How can you tell you have a really bad case of acne? \n" +
"\n" +
"It’s when the blind try to read your face.",
"Q. What’s the worst thing about being lonely?\n" +
"\n" +
"A. Playing Frisbee.",
"Me and my wife decided that we don't want to have children anymore. " +
"So anybody who wants one can leave us their phone number and address and we will bring you one.",
"It is so cold outside I saw a politician with his hands in his own pockets.",
"After many years of studying at a university, I’ve finally become a PhD… or Pizza Hut Deliveryman as people call it.",
"There is nothing worse than child polio. No wait, there's women's soccer.",
"Q: Why did the shark keep swimming in circles?\n" +
"\n" +
"A: It had a nosebleed.",
"Pessimist: \"Things just can't get any worse!\" \n" +
"\n" +
"Optimist: \"Nah, of course they can!\"",
"I wanted to grow my own food but I couldn’t get bacon seeds anywhere.",
"I was in a restaurant once and I suddenly realized I desperately needed to pass gas. " +
"The music was really, really loud, so I timed my reliefs to the beat of the music. " +
"After just a few songs I started to feel better. I finished my coffee, " +
"and noticed that everybody was staring at me... " +
"That was when I remembered I was listening to my iPod.",
"Why do women live on average two years longer? Because the time they spend parking doesn’t count.",
"I can’t believe I forgot to go to the gym today. That’s 7 years in a row now.",
"Woke up with a dead leg this morning. I will not take out a loan with the mafia ever again.",
"A naked women robbed a bank. Nobody could remember her face.",
"The 21st century: Deleting history is often more important than making it.",
"What is short and would be very disturbing at breakfast?\n" +
"-\n" +
"\"Hitler\"",
"\"How do you tell that a crab is drunk? It walks forwards.",
"Do you know what you can hold without ever touching it?\n" +
"\n" +
"A conversation.",
"I’ve no home, I haven’t got control, I can’t see any escape. Way past the time I got a new keyboard.",
"Why do cows wear bells?\n" +
" \n" +
"Their horns don’t work.",
"Two grains of sand go through the desert. One to the other: \"I have the feeling somebody is watching me.\"",
"“You are so kind, funny and beautiful.” \n" +
"\n" +
"“Oh come on. You just want to get me to bed.” \n" +
"\n" +
"“And smart, too!”",
"Q: What do politicians and diapers have in common? \n" +
"-\n" +
"A: Both should be changed regularly, and both for the same reason.",
"I’m selling my talking parrot. Why? Because yesterday, the bastard tried to sell me.",
"Do you know why women aren’t allowed in space? \n" +
"-\n" +
"To avoid scenarios like: \"Houston, we have a problem!\" \n" +
"- \n" +
"\"What is the problem?\" \n" +
"-\n" +
"\"Yeah, great, pretend like you don’t know what I’m talking about!\"",
"What would you call a very funny mountain? \n" +
"-\n" +
"<NAME>\""
};
public String getJoke() {
Random randomGenerator = new Random();
return jokesCollection[randomGenerator.nextInt(jokesCollection.length)];
}
}
| 7,886 | 0.507993 | 0.505052 | 178 | 42.926968 | 40.68045 | 172 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.511236 | false | false | 2 |
db38bada4830c15d72930f6f5002467fbec5728a | 9,165,460,210,887 | 1393724a6f4393a92510cb417c6cc4964b790314 | /src/beginner/QuakWithLung.java | f86fc06c862f1e909e69237d9553a560b8a16b47 | []
| no_license | PlumpMath/DesignPattern-488 | https://github.com/PlumpMath/DesignPattern-488 | 2fc5615936ab855f2b5a3314b6fd243b41a99747 | ee591bba86c7be9457bc457be32bc2a73a92e57e | refs/heads/master | 2021-01-20T09:37:03.874000 | 2015-02-02T14:34:53 | 2015-02-02T14:34:53 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package beginner;
public class QuakWithLung implements QuakBehavior{
@Override
public void performQuark() {
System.out.println("gu gu gu ..");
}
}
| UTF-8 | Java | 157 | java | QuakWithLung.java | Java | []
| null | []
| package beginner;
public class QuakWithLung implements QuakBehavior{
@Override
public void performQuark() {
System.out.println("gu gu gu ..");
}
}
| 157 | 0.713376 | 0.713376 | 11 | 13.272727 | 16.771681 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.727273 | false | false | 2 |
68805a3afab325c577c1101e2856dcc8df7cc8c8 | 9,156,870,344,964 | f2678f8f2c100fd78b8d6f4e246af6756db80b02 | /JavaBasic/src/com/test/basictype/CollectionClass.java | c57a1ba56446f55e7fa952d71ea9f6d8cf4f685c | []
| no_license | ColinLoveLucky/JavaProjectDemo | https://github.com/ColinLoveLucky/JavaProjectDemo | d67af118cd1618cef8f403eb9d4a62b006623ae8 | 82681e2391ddc124224af7ca4b07d852175c6921 | refs/heads/master | 2020-03-20T23:37:23.266000 | 2018-06-19T07:35:51 | 2018-06-19T07:35:51 | 137,855,173 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.test.basictype;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
import java.util.WeakHashMap;
public class CollectionClass {
public void testArray() {
// ArrayList arrayList = new ArrayList();
// arrayList.add(1);
// arrayList.add("Hi");
// for (Object item : arrayList) {
// System.out.println(item.toString());
// List a = new ArrayList();
}
public void testList() {
List<String> list = new ArrayList<String>();
list.add("Hi");
list.add("Zhangsan");
for (String item : list) {
System.out.println("list Item:" + item);
}
LinkedList<String> listLinkList = new LinkedList<String>();
listLinkList.add("Hi");
listLinkList.add("Zhangsan");
Vector<String> vector = new Vector<String>();
vector.add("Hi");
Stack<String> stack = new Stack<String>();
}
public void testQueue() {
PriorityQueue<String> queue = new PriorityQueue<String>();
ArrayDeque<String> deque = new ArrayDeque<String>();
}
public void testSet() {
HashSet<String> hashSet = new HashSet<String>();
hashSet.add("Hi");
hashSet.add(null);
for (String item : hashSet) {
System.out.println("Item :" + item);
}
LinkedHashSet<String> linkedHashSet = new LinkedHashSet<String>();
linkedHashSet.add("Key");
TreeSet<String> treeSet = new TreeSet<String>();
treeSet.add("Hi");
treeSet.add("Body");
for (String item : treeSet) {
System.out.println("Item is:" + item);
}
// EnumSet
}
public void testHashTable() {
Hashtable<String, String> hash = new Hashtable<String, String>();
hash.put("hi", "hi");
hash.put("Hi", "HI");
System.out.println("Hi:" + hash.get("Hi"));
System.out.println("hi:" + hash.get("Hi"));
}
public void testHashMap() {
HashMap<String, String> map = new HashMap<String, String>();
map.put("Hi", "Hi");
LinkedHashMap<String, String> linkHashMap = new LinkedHashMap<String, String>();
linkHashMap.put("Hi", "Value");
TreeMap<String, String> sortMap = new TreeMap<String, String>();
IdentityHashMap<String, String> identityMap = new IdentityHashMap<String, String>();
// EnumMap<String,String> enumMap=new EnumMap<String,String>();
}
public void testWeakHashMap() {
WeakHashMap<String, String> weakHash = new WeakHashMap<String, String>();
weakHash.put("Hi", "HI");
weakHash.put("Hello", "Hello");
}
}
| UTF-8 | Java | 2,691 | java | CollectionClass.java | Java | [
{
"context": "rrayList<String>();\n\t\tlist.add(\"Hi\");\n\t\tlist.add(\"Zhangsan\");\n\t\tfor (String item : list) {\n\t\t\tSystem.out.pri",
"end": 858,
"score": 0.999107301235199,
"start": 850,
"tag": "NAME",
"value": "Zhangsan"
},
{
"context": "();\n\t\tlistLinkList.add(\"Hi\");\n\t\tlistLinkList.add(\"Zhangsan\");\n\n\t\tVector<String> vector = new Vector<String>(",
"end": 1055,
"score": 0.9990189075469971,
"start": 1047,
"tag": "NAME",
"value": "Zhangsan"
}
]
| null | []
| package com.test.basictype;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
import java.util.WeakHashMap;
public class CollectionClass {
public void testArray() {
// ArrayList arrayList = new ArrayList();
// arrayList.add(1);
// arrayList.add("Hi");
// for (Object item : arrayList) {
// System.out.println(item.toString());
// List a = new ArrayList();
}
public void testList() {
List<String> list = new ArrayList<String>();
list.add("Hi");
list.add("Zhangsan");
for (String item : list) {
System.out.println("list Item:" + item);
}
LinkedList<String> listLinkList = new LinkedList<String>();
listLinkList.add("Hi");
listLinkList.add("Zhangsan");
Vector<String> vector = new Vector<String>();
vector.add("Hi");
Stack<String> stack = new Stack<String>();
}
public void testQueue() {
PriorityQueue<String> queue = new PriorityQueue<String>();
ArrayDeque<String> deque = new ArrayDeque<String>();
}
public void testSet() {
HashSet<String> hashSet = new HashSet<String>();
hashSet.add("Hi");
hashSet.add(null);
for (String item : hashSet) {
System.out.println("Item :" + item);
}
LinkedHashSet<String> linkedHashSet = new LinkedHashSet<String>();
linkedHashSet.add("Key");
TreeSet<String> treeSet = new TreeSet<String>();
treeSet.add("Hi");
treeSet.add("Body");
for (String item : treeSet) {
System.out.println("Item is:" + item);
}
// EnumSet
}
public void testHashTable() {
Hashtable<String, String> hash = new Hashtable<String, String>();
hash.put("hi", "hi");
hash.put("Hi", "HI");
System.out.println("Hi:" + hash.get("Hi"));
System.out.println("hi:" + hash.get("Hi"));
}
public void testHashMap() {
HashMap<String, String> map = new HashMap<String, String>();
map.put("Hi", "Hi");
LinkedHashMap<String, String> linkHashMap = new LinkedHashMap<String, String>();
linkHashMap.put("Hi", "Value");
TreeMap<String, String> sortMap = new TreeMap<String, String>();
IdentityHashMap<String, String> identityMap = new IdentityHashMap<String, String>();
// EnumMap<String,String> enumMap=new EnumMap<String,String>();
}
public void testWeakHashMap() {
WeakHashMap<String, String> weakHash = new WeakHashMap<String, String>();
weakHash.put("Hi", "HI");
weakHash.put("Hello", "Hello");
}
}
| 2,691 | 0.686734 | 0.686362 | 105 | 24.628571 | 21.016663 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.866667 | false | false | 2 |
fa5b05e1ed50bdb415a898c9fa9b66546bb5229a | 28,475,633,232,146 | 2e1049ea10b12136ebb0cfd79fff37f65129667e | /bundles/engine/eu.vicci.process.model.implementations/src/main/java/eu/vicci/process/model/sofiainstance/impl/custom/TransitionInstanceImplCustom.java | 675c800f2ca5be197baee98537ee936fee1fe0f8 | []
| no_license | IoTUDresden/proteus | https://github.com/IoTUDresden/proteus | 55f3d2440fee8fef9b59a54161c10c4a296355b0 | 8b1bad9b5cdf0014ebbd4990f2749c703e6e4353 | refs/heads/master | 2022-12-01T12:18:44.078000 | 2021-12-10T07:04:48 | 2021-12-10T07:04:48 | 73,270,164 | 5 | 1 | null | false | 2022-11-16T09:30:24 | 2016-11-09T09:39:10 | 2021-12-10T07:04:55 | 2022-11-16T09:30:21 | 67,553 | 4 | 0 | 11 | Java | false | false | package eu.vicci.process.model.sofiainstance.impl.custom;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import akka.actor.ActorRef;
import eu.vicci.process.actors.ActorAssignable;
import eu.vicci.process.model.sofiainstance.DataTypeInstance;
import eu.vicci.process.model.sofiainstance.MappingUtil;
import eu.vicci.process.model.sofiainstance.impl.TransitionInstanceImpl;
import eu.vicci.process.model.sofiainstance.util.LifeCycleManager;
/**
* TransitionInstanceImplCustom is the custom implementation of
* TransitionInstance (the runtime variant of the Transition, which is only used
* for modeling). The class extends the automatically generated class
* TransitionInstanceImpl.
*
* @author Reik Mueller
*
*/
public class TransitionInstanceImplCustom extends TransitionInstanceImpl implements ActorAssignable {
private final Logger LOGGER = LoggerFactory.getLogger(getClass().getSimpleName());
private ActorRef actorReference = null;
/**
* In this context deploying means to create the instance version of the
* target port.
*
* @param mapper
* MappingUtil is needed to perform the mapping process
*/
@Override
public void deploy(MappingUtil mapper) {
deploy(mapper, null);
}
@Override
public void deploy(MappingUtil mapper, ActorRef parent) {
actorReference = LifeCycleManager.INSTANCE.createActorForTransitionSync(this, parent);
if (getTransitionType().getTargetPort() == null)
return;
setTargetPortInstance(mapper.mapPort(getTransitionType().getTargetPort()));
ActorAssignable targetPort = (ActorAssignable)getTargetPortInstance();
targetPort.deploy(mapper, parent);
}
/**
* Deactivates the target port from this transition
*/
@Override
public void deactivate() {
LOGGER.debug("{}: deactivate", getTransitionType().getName());
if (getTransitionType().getTargetPort() != null)
LifeCycleManager.INSTANCE.deactivatePort(getTargetPortInstance());
else
LOGGER.error("{} has no endport!", getTransitionType().getName());
}
/**
* Executes the Transition which basically means to activate the target port
* and passing parameters.
*
* @param parameter
* A String containing an XML document that consists all
* parameters
*/
@Override
public boolean execute(DataTypeInstance parameter) {
LOGGER.debug("{}: execute", getTransitionType().getName());
if (getTransitionType().getTargetPort() != null)
LifeCycleManager.INSTANCE.activatePortSync(getTargetPortInstance(), parameter);
else
LOGGER.error("{} has no endport!", getTransitionType().getName());
return true;
}
@Override
public ActorRef getActorReference() {
return actorReference;
}
}
| UTF-8 | Java | 2,708 | java | TransitionInstanceImplCustom.java | Java | [
{
"context": "ed class\n * TransitionInstanceImpl.\n * \n * @author Reik Mueller\n * \n */\npublic class TransitionInstanceImplCustom",
"end": 726,
"score": 0.9998143315315247,
"start": 714,
"tag": "NAME",
"value": "Reik Mueller"
}
]
| null | []
| package eu.vicci.process.model.sofiainstance.impl.custom;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import akka.actor.ActorRef;
import eu.vicci.process.actors.ActorAssignable;
import eu.vicci.process.model.sofiainstance.DataTypeInstance;
import eu.vicci.process.model.sofiainstance.MappingUtil;
import eu.vicci.process.model.sofiainstance.impl.TransitionInstanceImpl;
import eu.vicci.process.model.sofiainstance.util.LifeCycleManager;
/**
* TransitionInstanceImplCustom is the custom implementation of
* TransitionInstance (the runtime variant of the Transition, which is only used
* for modeling). The class extends the automatically generated class
* TransitionInstanceImpl.
*
* @author <NAME>
*
*/
public class TransitionInstanceImplCustom extends TransitionInstanceImpl implements ActorAssignable {
private final Logger LOGGER = LoggerFactory.getLogger(getClass().getSimpleName());
private ActorRef actorReference = null;
/**
* In this context deploying means to create the instance version of the
* target port.
*
* @param mapper
* MappingUtil is needed to perform the mapping process
*/
@Override
public void deploy(MappingUtil mapper) {
deploy(mapper, null);
}
@Override
public void deploy(MappingUtil mapper, ActorRef parent) {
actorReference = LifeCycleManager.INSTANCE.createActorForTransitionSync(this, parent);
if (getTransitionType().getTargetPort() == null)
return;
setTargetPortInstance(mapper.mapPort(getTransitionType().getTargetPort()));
ActorAssignable targetPort = (ActorAssignable)getTargetPortInstance();
targetPort.deploy(mapper, parent);
}
/**
* Deactivates the target port from this transition
*/
@Override
public void deactivate() {
LOGGER.debug("{}: deactivate", getTransitionType().getName());
if (getTransitionType().getTargetPort() != null)
LifeCycleManager.INSTANCE.deactivatePort(getTargetPortInstance());
else
LOGGER.error("{} has no endport!", getTransitionType().getName());
}
/**
* Executes the Transition which basically means to activate the target port
* and passing parameters.
*
* @param parameter
* A String containing an XML document that consists all
* parameters
*/
@Override
public boolean execute(DataTypeInstance parameter) {
LOGGER.debug("{}: execute", getTransitionType().getName());
if (getTransitionType().getTargetPort() != null)
LifeCycleManager.INSTANCE.activatePortSync(getTargetPortInstance(), parameter);
else
LOGGER.error("{} has no endport!", getTransitionType().getName());
return true;
}
@Override
public ActorRef getActorReference() {
return actorReference;
}
}
| 2,702 | 0.751108 | 0.750369 | 85 | 30.858824 | 29.245071 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.458824 | false | false | 2 |
a2934722d3b3f5a91a435de53cb1dcdb32a47d4f | 8,083,128,463,880 | 7fde88fad575d7b5376406d1fec76bc2c347f51d | /src/mythread/MyExcutorService.java | 0c223ebd6b4c3f9297506b89c6e04cd1d29dec40 | []
| no_license | renewal-2019/javaBase | https://github.com/renewal-2019/javaBase | f963093b4e8140f2dfb50305f6225fe2fb8b8794 | 4fc409b9637d6464b1569a4da9c3e5427a56223e | refs/heads/master | 2023-01-01T18:19:10.503000 | 2020-10-27T14:18:47 | 2020-10-27T14:18:47 | 307,724,584 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package mythread;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class MyExcutorService {
static MyExcutorService instance = new MyExcutorService();
static int j;
public static class Runnable1 implements Runnable {
@Override
public void run() {
while (true) {
synchronized (instance) {
j++;
System.out.println(Thread.currentThread().getName() + " " + j);
try {
Thread.sleep(1000);
instance.notify();
instance.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
public static class Runnable2 implements Runnable {
@Override
public void run() {
while (true) {
synchronized (instance) {
j--;
System.out.println(Thread.currentThread().getName() + " " + j);
try {
Thread.sleep(1000);
instance.notify();
instance.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
public static void main(String[] args) throws Exception{
Runnable1 r1 = new Runnable1();
Runnable2 r2 = new Runnable2();
ExecutorService executorService = Executors.newFixedThreadPool(4);
executorService.submit(r1);
executorService.submit(r2);
executorService.submit(r1);
executorService.submit(r2);
}
}
| UTF-8 | Java | 1,802 | java | MyExcutorService.java | Java | []
| null | []
| package mythread;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class MyExcutorService {
static MyExcutorService instance = new MyExcutorService();
static int j;
public static class Runnable1 implements Runnable {
@Override
public void run() {
while (true) {
synchronized (instance) {
j++;
System.out.println(Thread.currentThread().getName() + " " + j);
try {
Thread.sleep(1000);
instance.notify();
instance.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
public static class Runnable2 implements Runnable {
@Override
public void run() {
while (true) {
synchronized (instance) {
j--;
System.out.println(Thread.currentThread().getName() + " " + j);
try {
Thread.sleep(1000);
instance.notify();
instance.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
public static void main(String[] args) throws Exception{
Runnable1 r1 = new Runnable1();
Runnable2 r2 = new Runnable2();
ExecutorService executorService = Executors.newFixedThreadPool(4);
executorService.submit(r1);
executorService.submit(r2);
executorService.submit(r1);
executorService.submit(r2);
}
}
| 1,802 | 0.478357 | 0.466704 | 61 | 28.540983 | 21.259962 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.393443 | false | false | 2 |
5df0c1b1d5a2183d81362483249daaa25becbdbd | 32,865,089,811,696 | 2ac74657de3cb81bab734d18094e945a442a167d | /sechub-integrationtest/src/main/java/com/mercedesbenz/sechub/integrationtest/api/TestSecHubJobInfoForUser.java | 5aa457c64ff5b4c28b76818044fe3700a46f848a | [
"MIT",
"ANTLR-PD",
"LicenseRef-scancode-generic-exception",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"LGPL-2.1-only",
"GPL-1.0-or-later",
"LicenseRef-scancode-oracle-openjdk-exception-2.0",
"MPL-1.1",
"MPL-2.0",
"CC-PDDC",
"LicenseRef-scancode-warranty-disclaimer",
"EPL-2.0",
"GPL-2.0-only",
"EPL-1.0",
"CC0-1.0",
"Classpath-exception-2.0",
"Apache-2.0",
"LGPL-2.1-or-later",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-public-domain",
"GPL-2.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause",
"Apache-1.1",
"MPL-1.0",
"CDDL-1.1",
"LicenseRef-scancode-proprietary-license"
]
| permissive | de-jcup/sechub | https://github.com/de-jcup/sechub | 64055bb7ccd5496e32207c140e5812997e97583b | 488d2d23b9ae74043e8747467623d291c7371b38 | refs/heads/develop | 2023-07-22T18:01:47.280000 | 2023-07-18T15:50:27 | 2023-07-18T15:50:27 | 199,480,695 | 0 | 1 | MIT | true | 2023-03-20T03:00:02 | 2019-07-29T15:37:19 | 2022-05-06T15:46:38 | 2023-03-20T03:00:00 | 20,073 | 0 | 1 | 4 | Java | false | false | // SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.integrationtest.api;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.mercedesbenz.sechub.commons.model.SecHubConfigurationMetaData;
import com.mercedesbenz.sechub.commons.model.TrafficLight;
/**
* A simple test object to simulate SecHubJobInfoForUser (which is not available
* from classpath in integration tests)
*
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class TestSecHubJobInfoForUser {
public UUID jobUUID;
public String executedBy;
public LocalDateTime created;
public LocalDateTime started;
public LocalDateTime ended;
public String executionState;
public String executionResult;
public TrafficLight trafficLight;
public Optional<SecHubConfigurationMetaData> metaData = Optional.empty();
} | UTF-8 | Java | 931 | java | TestSecHubJobInfoForUser.java | Java | []
| null | []
| // SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.integrationtest.api;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.mercedesbenz.sechub.commons.model.SecHubConfigurationMetaData;
import com.mercedesbenz.sechub.commons.model.TrafficLight;
/**
* A simple test object to simulate SecHubJobInfoForUser (which is not available
* from classpath in integration tests)
*
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class TestSecHubJobInfoForUser {
public UUID jobUUID;
public String executedBy;
public LocalDateTime created;
public LocalDateTime started;
public LocalDateTime ended;
public String executionState;
public String executionResult;
public TrafficLight trafficLight;
public Optional<SecHubConfigurationMetaData> metaData = Optional.empty();
} | 931 | 0.792696 | 0.792696 | 37 | 24.18919 | 24.364172 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.432432 | false | false | 2 |
ec06040339681ca47d4ef974be8a42d6ba746e7f | 33,887,291,968,482 | 4d3f8647e75288f643799d95cc32671e9407e95d | /bipbip2_combine/src/com/kitri/maproute/service/MapRouteService.java | d6dc953455183b692c6599f044a91ee8c1db92eb | []
| no_license | hardkyo/bipbip2 | https://github.com/hardkyo/bipbip2 | fd5defff69b0d00bdf2eea0cbf5e68cabf4d5acc | db6a3d6f1783a88deac7fbe29c593d7ba08c117f | refs/heads/master | 2020-12-02T18:13:01.685000 | 2017-08-11T06:35:06 | 2017-08-11T06:35:06 | 96,497,886 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kitri.maproute.service;
import java.util.List;
import com.kitri.map.model.MapDto;
public interface MapRouteService {
List<MapDto> listMapArtice(int bcode,int pg,String key, String word);
}
| UTF-8 | Java | 219 | java | MapRouteService.java | Java | []
| null | []
| package com.kitri.maproute.service;
import java.util.List;
import com.kitri.map.model.MapDto;
public interface MapRouteService {
List<MapDto> listMapArtice(int bcode,int pg,String key, String word);
}
| 219 | 0.73516 | 0.73516 | 11 | 17.90909 | 22.146021 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.818182 | false | false | 2 |
826a3c1df66c3f7e996f9d763b0c6c0626db574f | 33,887,291,966,524 | 725674818bd8d40f64412c7f2becbcd5a2d4ffee | /app/src/main/java/com/saad/biit_arrival_system/GuardActivity.java | edddfe9d0451707d7d37ad1ec625a5658fecb9a8 | []
| no_license | SaadAhmed7/BIIT_Arrival_System | https://github.com/SaadAhmed7/BIIT_Arrival_System | b7d53ab27ded5078be1dbc9a541e1fb315aafa45 | 17048db59e93eceb9708868582b3edd81879e455 | refs/heads/master | 2023-08-15T02:56:08.587000 | 2021-09-25T21:15:33 | 2021-09-25T21:15:33 | 410,383,563 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.saad.biit_arrival_system;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class GuardActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_guard);
}
} | UTF-8 | Java | 343 | java | GuardActivity.java | Java | []
| null | []
| package com.saad.biit_arrival_system;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class GuardActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_guard);
}
} | 343 | 0.760933 | 0.760933 | 14 | 23.571428 | 22.231619 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.357143 | false | false | 2 |
685293f0a0f572d7bec18d0873e16baa2344505a | 7,962,869,436,567 | 8f1f9dc80f24a48dcb05dff99336c583f56056a3 | /src/main/java/com/fmi/patokas/service/EmployeePhotoService.java | 31851a441094b3b15cd28bd839561ab3a379cb02 | []
| no_license | BulkSecurityGeneratorProject/odborDeprisanti | https://github.com/BulkSecurityGeneratorProject/odborDeprisanti | 26cc633aa3333c2ad7f760b14e908dfb577954fe | 2b66a340b922483436482d8bbf0ac552e566590b | refs/heads/master | 2022-12-16T17:11:46.069000 | 2018-06-03T21:06:16 | 2018-06-03T21:06:16 | 296,603,716 | 0 | 0 | null | true | 2020-09-18T11:38:36 | 2020-09-18T11:38:36 | 2018-06-03T21:07:15 | 2018-06-03T21:07:12 | 519 | 0 | 0 | 0 | null | false | false | package com.fmi.patokas.service;
import com.fmi.patokas.domain.EmployeePhoto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
/**
* Service Interface for managing EmployeePhoto.
*/
public interface EmployeePhotoService {
/**
* Save a employeePhoto.
*
* @param employeePhoto the entity to save
* @return the persisted entity
*/
EmployeePhoto save(EmployeePhoto employeePhoto);
/**
* Get all the employeePhotos.
*
* @param pageable the pagination information
* @return the list of entities
*/
Page<EmployeePhoto> findAll(Pageable pageable);
/**
* Get the "id" employeePhoto.
*
* @param id the id of the entity
* @return the entity
*/
EmployeePhoto findOne(Long id);
/**
* Delete the "id" employeePhoto.
*
* @param id the id of the entity
*/
void delete(Long id);
}
| UTF-8 | Java | 944 | java | EmployeePhotoService.java | Java | []
| null | []
| package com.fmi.patokas.service;
import com.fmi.patokas.domain.EmployeePhoto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
/**
* Service Interface for managing EmployeePhoto.
*/
public interface EmployeePhotoService {
/**
* Save a employeePhoto.
*
* @param employeePhoto the entity to save
* @return the persisted entity
*/
EmployeePhoto save(EmployeePhoto employeePhoto);
/**
* Get all the employeePhotos.
*
* @param pageable the pagination information
* @return the list of entities
*/
Page<EmployeePhoto> findAll(Pageable pageable);
/**
* Get the "id" employeePhoto.
*
* @param id the id of the entity
* @return the entity
*/
EmployeePhoto findOne(Long id);
/**
* Delete the "id" employeePhoto.
*
* @param id the id of the entity
*/
void delete(Long id);
}
| 944 | 0.645127 | 0.645127 | 42 | 21.476191 | 18.360462 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.190476 | false | false | 2 |
0ef8ac132ce7a0c065c61396a9ad4447a4d7230a | 12,713,103,217,211 | e67540e792edf41a21cb6bbb405f91eac03f6465 | /Herr-Speck/src/com/tomatrocho/game/level/tile/RockTile.java | 81a42e78514b338132b93d84847b3354919a2e92 | [
"Apache-2.0"
]
| permissive | tomatrocho/Herr-Speck | https://github.com/tomatrocho/Herr-Speck | 13c41e72d7d54c1b2b3dabecd18a12f6925b9760 | f5041d0cb93eafac06bb88ade6afd7496508893b | refs/heads/master | 2021-05-03T12:30:09.476000 | 2016-12-06T23:20:14 | 2016-12-06T23:20:14 | 67,894,604 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tomatrocho.game.level.tile;
import com.tomatrocho.game.gfx.Art;
import com.tomatrocho.game.gfx.IAbstractScreen;
public class RockTile extends Tile {
/**
* Default constructor for the {@link StoneTile} class.
*/
public RockTile() {
this.img = 0;
}
@Override
public void render(IAbstractScreen screen) {
screen.blit(Art.rocksTiles[img & 7][img / 8], x * Tile.W, y * Tile.H);
}
}
| UTF-8 | Java | 443 | java | RockTile.java | Java | []
| null | []
| package com.tomatrocho.game.level.tile;
import com.tomatrocho.game.gfx.Art;
import com.tomatrocho.game.gfx.IAbstractScreen;
public class RockTile extends Tile {
/**
* Default constructor for the {@link StoneTile} class.
*/
public RockTile() {
this.img = 0;
}
@Override
public void render(IAbstractScreen screen) {
screen.blit(Art.rocksTiles[img & 7][img / 8], x * Tile.W, y * Tile.H);
}
}
| 443 | 0.643341 | 0.636569 | 19 | 22.31579 | 22.879669 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.368421 | false | false | 2 |
98f4ecf9dfef779208760c4bf41421f22fa6b50f | 12,713,103,219,736 | ab9b09d53ff63d4901111dfb075580f99e907b49 | /FormGWT/src/formGWT/client/Page2.java | 1fa6ab2fd3691718d6c845a935860dfd851408fc | []
| no_license | WasserX/car-gwt | https://github.com/WasserX/car-gwt | 4a9ae0bf5fa3bbee919625b64a6ad654543a1011 | c6dcf715ef757140dce36ec3cff86c7f00f7fcb9 | refs/heads/master | 2016-09-11T11:42:56.861000 | 2011-11-24T23:37:59 | 2011-11-24T23:37:59 | 2,631,323 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package formGWT.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import formGWT.client.i18n.TextTools;
import formGWT.client.i18n.Texts;
public class Page2 extends Grid{
private final String lordOfTheRingsURL = "http://ia.media-imdb.com/images/M/MV5BMjE4MjA1NTAyMV5BMl5BanBnXkFtZTcwNzM1NDQyMQ@@._V1_.jpg";
private final String hangoverURL = "http://ia.media-imdb.com/images/M/MV5BMTU1MDA1MTYwMF5BMl5BanBnXkFtZTcwMDcxMzA1Mg@@._V1_.jpg";
private final String tronURL = "http://ia.media-imdb.com/images/M/MV5BMTk4NTk4MTk1OF5BMl5BanBnXkFtZTcwNTE2MDIwNA@@._V1_.jpg";
private Grid topGrid = new Grid(2,2);
private ListBox filmNameField = new ListBox();
private Image filmImage = new Image();
public Page2(int rows, int columns)
{
super(rows,columns);
createPage();
}
/**
* Sets up the second page of the form.
*/
private void createPage() {
Texts constants = GWT.create(Texts.class);
//Form contents
clear();
topGrid.clear();
filmImage.setSize("700px", "500px");
filmImage.setVisible(false);
topGrid.setWidget(0, 0, new Label(constants.secondPage()));
topGrid.setWidget(1, 0, new Label(constants.filmName()));
topGrid.setWidget(1, 1, TextTools.fillMovies(filmNameField));
filmNameField.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
int selectedItem = filmNameField.getSelectedIndex();
if(selectedItem < 0) return;
//Texts constants = GWT.create(Texts.class);
selectedItem--; //we take away the contribution of the empty string
//Because the items are in alphabetical order, we use their index that wont change
switch(selectedItem){
case 0: //Lord of the Rings
filmImage.setVisible(true);
filmImage.setUrl(lordOfTheRingsURL);
break;
case 1: //Hangover
filmImage.setVisible(true);
filmImage.setUrl(hangoverURL);
break;
case 2: //Tron
filmImage.setVisible(true);
filmImage.setUrl(tronURL);
break;
default:
filmImage.setVisible(false);
break;
}
}
});
setWidget(0,0, topGrid);
setWidget(1,0, filmImage);
}
public void updatePage() {
Texts constants = GWT.create(Texts.class);
//Form contents
topGrid.setWidget(0, 0, new Label(constants.secondPage()));
topGrid.setWidget(1, 0, new Label(constants.filmName()));
}
}
| UTF-8 | Java | 2,611 | java | Page2.java | Java | []
| null | []
| package formGWT.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import formGWT.client.i18n.TextTools;
import formGWT.client.i18n.Texts;
public class Page2 extends Grid{
private final String lordOfTheRingsURL = "http://ia.media-imdb.com/images/M/MV5BMjE4MjA1NTAyMV5BMl5BanBnXkFtZTcwNzM1NDQyMQ@@._V1_.jpg";
private final String hangoverURL = "http://ia.media-imdb.com/images/M/MV5BMTU1MDA1MTYwMF5BMl5BanBnXkFtZTcwMDcxMzA1Mg@@._V1_.jpg";
private final String tronURL = "http://ia.media-imdb.com/images/M/MV5BMTk4NTk4MTk1OF5BMl5BanBnXkFtZTcwNTE2MDIwNA@@._V1_.jpg";
private Grid topGrid = new Grid(2,2);
private ListBox filmNameField = new ListBox();
private Image filmImage = new Image();
public Page2(int rows, int columns)
{
super(rows,columns);
createPage();
}
/**
* Sets up the second page of the form.
*/
private void createPage() {
Texts constants = GWT.create(Texts.class);
//Form contents
clear();
topGrid.clear();
filmImage.setSize("700px", "500px");
filmImage.setVisible(false);
topGrid.setWidget(0, 0, new Label(constants.secondPage()));
topGrid.setWidget(1, 0, new Label(constants.filmName()));
topGrid.setWidget(1, 1, TextTools.fillMovies(filmNameField));
filmNameField.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
int selectedItem = filmNameField.getSelectedIndex();
if(selectedItem < 0) return;
//Texts constants = GWT.create(Texts.class);
selectedItem--; //we take away the contribution of the empty string
//Because the items are in alphabetical order, we use their index that wont change
switch(selectedItem){
case 0: //Lord of the Rings
filmImage.setVisible(true);
filmImage.setUrl(lordOfTheRingsURL);
break;
case 1: //Hangover
filmImage.setVisible(true);
filmImage.setUrl(hangoverURL);
break;
case 2: //Tron
filmImage.setVisible(true);
filmImage.setUrl(tronURL);
break;
default:
filmImage.setVisible(false);
break;
}
}
});
setWidget(0,0, topGrid);
setWidget(1,0, filmImage);
}
public void updatePage() {
Texts constants = GWT.create(Texts.class);
//Form contents
topGrid.setWidget(0, 0, new Label(constants.secondPage()));
topGrid.setWidget(1, 0, new Label(constants.filmName()));
}
}
| 2,611 | 0.721563 | 0.700881 | 82 | 30.841463 | 27.946583 | 136 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.878049 | false | false | 2 |
c204243e7a023c786df198b3e0bd1f2cb33e3298 | 16,716,012,758,525 | 73e2bcaba4c6f8c07e5855a2ae051d3dfad8e221 | /DAM/PSP/eclipse/PSP_UD1/src/ud1_practicas/Practica_PSP_1_2.java | bf6dff6e493aefcd1715b7f46e41eb98fe4c4104 | []
| no_license | JoseAntonioVelasco/2DAM_Workspaces | https://github.com/JoseAntonioVelasco/2DAM_Workspaces | 07c59c1a2a726870abf9158f67bd8001a07f8b2d | 1e401bbc9cbbe4989f6cedcbdaa339cc27f6d57c | refs/heads/main | 2023-03-11T21:27:32.396000 | 2021-02-26T23:16:57 | 2021-02-26T23:16:57 | 301,367,114 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ud1_practicas;
import java.io.IOException;
/**
*
* @author Jose Antonio Velasco
*
*/
public class Practica_PSP_1_2 {
public static void main(String[] args) throws IOException{
String comando="C:\\Windows\\notepad.exe";
Runtime r = Runtime.getRuntime();
try {
Process p = r.exec(comando);
try {
Thread.sleep(5000);
p.destroy();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch(IOException e) {
System.err.println("Capturada excepcion de E/S");
System.exit(-1);
}
}
}
| UTF-8 | Java | 580 | java | Practica_PSP_1_2.java | Java | [
{
"context": "as;\nimport java.io.IOException;\n/**\n * \n * @author Jose Antonio Velasco\n *\n */\npublic class Practica_PSP_1_2 {\n\tpublic st",
"end": 90,
"score": 0.9998698830604553,
"start": 70,
"tag": "NAME",
"value": "Jose Antonio Velasco"
}
]
| null | []
| package ud1_practicas;
import java.io.IOException;
/**
*
* @author <NAME>
*
*/
public class Practica_PSP_1_2 {
public static void main(String[] args) throws IOException{
String comando="C:\\Windows\\notepad.exe";
Runtime r = Runtime.getRuntime();
try {
Process p = r.exec(comando);
try {
Thread.sleep(5000);
p.destroy();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch(IOException e) {
System.err.println("Capturada excepcion de E/S");
System.exit(-1);
}
}
}
| 566 | 0.65 | 0.636207 | 27 | 20.481482 | 16.671934 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.148148 | false | false | 2 |
d8b1d871b94240c699397a4fcf4e04b834e652d5 | 6,416,681,180,575 | c4b8d827aa3ffb1239f23f0fb6be59c1175cd298 | /leetcode/src/main/java/com/leetcode/tag/must8/three/SingleNumber2.java | dce0b7584f29b1792c8b6347253314e76a91841f | []
| no_license | xuweng/algorithm | https://github.com/xuweng/algorithm | cb8ebbd79c175103806c92fcc989bd91b737f25c | d476b9bc43dc5bd215d8e0d92ca09cc5445a69d1 | refs/heads/master | 2021-12-01T09:24:58.944000 | 2021-11-07T03:26:37 | 2021-11-07T03:26:37 | 206,908,038 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.leetcode.tag.must8.three;
/**
* 260. 只出现一次的数字 III
*/
public class SingleNumber2 {
/**
* 方法一:分组异或
*/
class Solution {
public int[] singleNumber(int[] nums) {
//先对所有数字进行一次异或,得到两个出现一次的数字的异或值。
int ret = 0;
for (int n : nums) {
ret ^= n;
}
int div = 1;
while ((div & ret) == 0) {
div <<= 1;
}
int a = 0, b = 0;
for (int n : nums) {
if ((div & n) != 0) {
a ^= n;
} else {
b ^= n;
}
}
return new int[]{a, b};
}
}
}
| UTF-8 | Java | 803 | java | SingleNumber2.java | Java | []
| null | []
| package com.leetcode.tag.must8.three;
/**
* 260. 只出现一次的数字 III
*/
public class SingleNumber2 {
/**
* 方法一:分组异或
*/
class Solution {
public int[] singleNumber(int[] nums) {
//先对所有数字进行一次异或,得到两个出现一次的数字的异或值。
int ret = 0;
for (int n : nums) {
ret ^= n;
}
int div = 1;
while ((div & ret) == 0) {
div <<= 1;
}
int a = 0, b = 0;
for (int n : nums) {
if ((div & n) != 0) {
a ^= n;
} else {
b ^= n;
}
}
return new int[]{a, b};
}
}
}
| 803 | 0.330996 | 0.314166 | 32 | 21.28125 | 12.718673 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.34375 | false | false | 2 |
d164f537aed3f4ab38efaee00f8ac3102cfbab94 | 10,067,403,354,522 | 28445c46389b83f0a8866e8525ec0550f1b89f34 | /app/main/DoSave.java | 05ce86be002b4b1efff366289f4790beffe953ce | []
| no_license | swNotJoao/PO_PROJ_1 | https://github.com/swNotJoao/PO_PROJ_1 | c39e20e674e724ed67ecc93078f1487aec10e6a8 | fd0b85cbaef55c011103b5adb351b3121e5744c0 | refs/heads/master | 2021-01-03T20:50:30.812000 | 2020-02-13T10:16:09 | 2020-02-13T10:16:09 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package sth.app.main;
import java.io.IOException;
import pt.tecnico.po.ui.Command;
import pt.tecnico.po.ui.Input;
import sth.core.SchoolManager;
import java.io.*;
/**
* 4.1.1. Save to file under current name (if unnamed, query for name).
*/
public class DoSave extends Command<SchoolManager> {
private SchoolManager _receiver;
/**
* @param receiver
*/
public DoSave(SchoolManager receiver) {
super(Label.SAVE, receiver);
_receiver = receiver;
}
/** @see pt.tecnico.po.ui.Command#execute() */
@Override
public final void execute() {
try {
FileOutputStream fileOut = new FileOutputStream("/state.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(_receiver.getSchool());
out.close();
fileOut.close();
} catch (IOException i) {
i.printStackTrace();
}
}
}
| UTF-8 | Java | 893 | java | DoSave.java | Java | []
| null | []
| package sth.app.main;
import java.io.IOException;
import pt.tecnico.po.ui.Command;
import pt.tecnico.po.ui.Input;
import sth.core.SchoolManager;
import java.io.*;
/**
* 4.1.1. Save to file under current name (if unnamed, query for name).
*/
public class DoSave extends Command<SchoolManager> {
private SchoolManager _receiver;
/**
* @param receiver
*/
public DoSave(SchoolManager receiver) {
super(Label.SAVE, receiver);
_receiver = receiver;
}
/** @see pt.tecnico.po.ui.Command#execute() */
@Override
public final void execute() {
try {
FileOutputStream fileOut = new FileOutputStream("/state.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(_receiver.getSchool());
out.close();
fileOut.close();
} catch (IOException i) {
i.printStackTrace();
}
}
}
| 893 | 0.649496 | 0.646137 | 40 | 21.325001 | 20.556492 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.425 | false | false | 2 |
e1392074f9000b82f7da51a00d36bb70ca07a292 | 7,713,761,294,047 | 6109358f9740238bc5cbaabe520f9218700bd114 | /app/src/main/java/com/example/lcy/demo/fragment/OpenTestFragment.java | b5b2ecc2d8ac610cef34c4507df0fbeeeb4dc5b2 | []
| no_license | Lcy123/GiftDemo | https://github.com/Lcy123/GiftDemo | b288316268539f1856bc671d3c62860d8434e0b1 | 8dfb0f5d6ddfe37891ffb41a6d201a7f66020d63 | refs/heads/master | 2021-01-11T02:00:41.155000 | 2016-10-13T15:44:09 | 2016-10-13T15:44:10 | 70,822,368 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.lcy.demo.fragment;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
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.ListView;
import com.example.lcy.demo.R;
import com.example.lcy.demo.adapter.GiftListAdapter;
import com.example.lcy.demo.adapter.OpenKaiFuAdapter;
import com.example.lcy.demo.adapter.OpenTestAdapter;
import com.example.lcy.demo.bean.GiftListBean;
import com.example.lcy.demo.bean.KaiFuBean;
import com.example.lcy.demo.bean.TextBean;
import com.example.lcy.demo.http.HttpUtils;
import com.example.lcy.demo.http.MyService;
import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* A simple {@link Fragment} subclass.
*/
public class OpenTestFragment extends Fragment {
@BindView(R.id.open_test_listView)
PullToRefreshListView listView;
OpenTestAdapter adapter;
public OpenTestFragment() {
// Required empty public constructor
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
getContext();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_open_test, container, false);
ButterKnife.bind(this, view);
initData();
listView.setMode(PullToRefreshBase.Mode.BOTH);
listView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
@Override
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ILoadingLayout proxy = listView.getLoadingLayoutProxy(true, false);
proxy.setRefreshingLabel("正在加载");
proxy.setLastUpdatedLabel("上次更新时间:");
listView.onRefreshComplete();
}
},1000);
}
@Override
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ILoadingLayout proxy = listView.getLoadingLayoutProxy(false, true);
proxy.setRefreshingLabel("查看更多");
proxy.setReleaseLabel("松开载入更多");
listView.onRefreshComplete();
}
},1000);
}
});
return view;
}
private void initData(){
MyService service = HttpUtils.getMyService();
service.getWebfutureTest().enqueue(new Callback<TextBean>() {
@Override
public void onResponse(Call<TextBean> call, Response<TextBean> response) {
TextBean bean = response.body();
List<TextBean.InfoBean> list = bean.getInfo();
adapter = new OpenTestAdapter(list, getContext());
listView.setAdapter(adapter);
}
@Override
public void onFailure(Call<TextBean> call, Throwable t) {
}
});
}
}
| UTF-8 | Java | 3,853 | java | OpenTestFragment.java | Java | []
| null | []
| package com.example.lcy.demo.fragment;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
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.ListView;
import com.example.lcy.demo.R;
import com.example.lcy.demo.adapter.GiftListAdapter;
import com.example.lcy.demo.adapter.OpenKaiFuAdapter;
import com.example.lcy.demo.adapter.OpenTestAdapter;
import com.example.lcy.demo.bean.GiftListBean;
import com.example.lcy.demo.bean.KaiFuBean;
import com.example.lcy.demo.bean.TextBean;
import com.example.lcy.demo.http.HttpUtils;
import com.example.lcy.demo.http.MyService;
import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* A simple {@link Fragment} subclass.
*/
public class OpenTestFragment extends Fragment {
@BindView(R.id.open_test_listView)
PullToRefreshListView listView;
OpenTestAdapter adapter;
public OpenTestFragment() {
// Required empty public constructor
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
getContext();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_open_test, container, false);
ButterKnife.bind(this, view);
initData();
listView.setMode(PullToRefreshBase.Mode.BOTH);
listView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
@Override
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ILoadingLayout proxy = listView.getLoadingLayoutProxy(true, false);
proxy.setRefreshingLabel("正在加载");
proxy.setLastUpdatedLabel("上次更新时间:");
listView.onRefreshComplete();
}
},1000);
}
@Override
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ILoadingLayout proxy = listView.getLoadingLayoutProxy(false, true);
proxy.setRefreshingLabel("查看更多");
proxy.setReleaseLabel("松开载入更多");
listView.onRefreshComplete();
}
},1000);
}
});
return view;
}
private void initData(){
MyService service = HttpUtils.getMyService();
service.getWebfutureTest().enqueue(new Callback<TextBean>() {
@Override
public void onResponse(Call<TextBean> call, Response<TextBean> response) {
TextBean bean = response.body();
List<TextBean.InfoBean> list = bean.getInfo();
adapter = new OpenTestAdapter(list, getContext());
listView.setAdapter(adapter);
}
@Override
public void onFailure(Call<TextBean> call, Throwable t) {
}
});
}
}
| 3,853 | 0.637031 | 0.633622 | 116 | 31.870689 | 24.853893 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.577586 | false | false | 2 |
45e04cab26bff73a281d83d595aaee5d2f0835f5 | 23,622,320,171,274 | a87f3aaec851d69172e0444735364f6cc29d461e | /pascal-compiler-interpreter/src/backend/BackendFactory.java | ba8d5f1c4dfd7c38f95a4f313f43737ba913f5a3 | [
"MIT"
]
| permissive | matija94/show-me-the-code | https://github.com/matija94/show-me-the-code | a8f1061bdab8d2fad60b5a37447f869b2893a76e | 7e98b15da03712e28417f2c808c4324989ce9bd7 | refs/heads/master | 2022-10-02T22:19:56.146000 | 2021-02-15T10:10:53 | 2021-02-15T10:10:53 | 96,696,196 | 1 | 0 | MIT | false | 2022-09-22T18:04:40 | 2017-07-09T16:18:13 | 2021-02-15T10:11:02 | 2022-09-22T18:04:36 | 32,176 | 1 | 0 | 3 | Jupyter Notebook | false | false | package backend;
import backend.compiler.CodeGenerator;
import backend.interpreter.Executor;
/**
*
* Backend component which is responsible for creating compiled and interpreter components
*/
public class BackendFactory {
public static Backend createBackend(String component) throws Exception {
if (component.equalsIgnoreCase("compile")) {
return new CodeGenerator();
}
else if (component.equalsIgnoreCase("interpret")) {
return new Executor();
}
else {
throw new Exception("Backend factory: Invalid component " + component);
}
}
}
| UTF-8 | Java | 564 | java | BackendFactory.java | Java | []
| null | []
| package backend;
import backend.compiler.CodeGenerator;
import backend.interpreter.Executor;
/**
*
* Backend component which is responsible for creating compiled and interpreter components
*/
public class BackendFactory {
public static Backend createBackend(String component) throws Exception {
if (component.equalsIgnoreCase("compile")) {
return new CodeGenerator();
}
else if (component.equalsIgnoreCase("interpret")) {
return new Executor();
}
else {
throw new Exception("Backend factory: Invalid component " + component);
}
}
}
| 564 | 0.739362 | 0.739362 | 24 | 22.5 | 26.744158 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.25 | false | false | 2 |
c8a3d8026eec7a402d295867925050fad8376a18 | 8,830,452,770,104 | 275a9eaadf1c3d48d4ffc02d1beb81582fe4a4c5 | /SEStudio-MedFleet-master/MissionControl/src/com/medfleet/missionControl/Main.java | 03c7d7524a8b0ea410c7ae0132c24b8f27cc2428 | [
"MIT"
]
| permissive | rooneybb/DroneCapstone | https://github.com/rooneybb/DroneCapstone | 97b0ac8e73d737a90ea89b5318060f23fb1d6e68 | e76fc3ef6203ec124bfc18d0419e374b5fced3a0 | refs/heads/master | 2021-01-11T17:55:25.436000 | 2017-01-24T04:36:36 | 2017-01-24T04:36:36 | 79,876,733 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.medfleet.missionControl;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URISyntaxException;
import java.net.URL;
import com.medfleet.missionControl.config.config;
public class Main
{
public static String ipAddress = "http://127.0.0.1:3000/";
public static void main(String[] args) throws IOException, URISyntaxException
{
config.DroneIds.add("5745b71eb8998fe93d4b16d7");
config.DroneIds.add("5745b72db8998fe93d4b16d8");
ServerSocket server = null;
try
{
server = new ServerSocket(20005);
System.out.println("Mission Control: Start at Port:20005");
Socket client = null;
boolean f = true;
while(f)
{
//waiting for connection from clients.
client = server.accept();
System.out.println("Connection Success!");
//Open a new thread for each client.
new Thread(new ServerThread(client)).start();
}
server.close();
}
finally
{
server.close();
}
}
public static HttpURLConnection getHttpURLConnection(String url) throws Exception
{
URL object=new URL(url);
HttpURLConnection con = (HttpURLConnection) object.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept", "application/json");
con.setRequestMethod("POST");
return con;
}
public static String getStringFromInputStream(InputStream is)
throws IOException
{
ByteArrayOutputStream os = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = -1;
while ((len = is.read(buffer)) != -1) {
os.write(buffer, 0, len);
}
is.close();
String state = os.toString();
os.close();
return state;
}
}
| UTF-8 | Java | 2,033 | java | Main.java | Java | [
{
"context": "ain \n{\n\n\tpublic static String ipAddress = \"http://127.0.0.1:3000/\";\n\t\n\t\n\tpublic static void main(String[] arg",
"end": 405,
"score": 0.9997057318687439,
"start": 396,
"tag": "IP_ADDRESS",
"value": "127.0.0.1"
}
]
| null | []
| package com.medfleet.missionControl;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URISyntaxException;
import java.net.URL;
import com.medfleet.missionControl.config.config;
public class Main
{
public static String ipAddress = "http://127.0.0.1:3000/";
public static void main(String[] args) throws IOException, URISyntaxException
{
config.DroneIds.add("5745b71eb8998fe93d4b16d7");
config.DroneIds.add("5745b72db8998fe93d4b16d8");
ServerSocket server = null;
try
{
server = new ServerSocket(20005);
System.out.println("Mission Control: Start at Port:20005");
Socket client = null;
boolean f = true;
while(f)
{
//waiting for connection from clients.
client = server.accept();
System.out.println("Connection Success!");
//Open a new thread for each client.
new Thread(new ServerThread(client)).start();
}
server.close();
}
finally
{
server.close();
}
}
public static HttpURLConnection getHttpURLConnection(String url) throws Exception
{
URL object=new URL(url);
HttpURLConnection con = (HttpURLConnection) object.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept", "application/json");
con.setRequestMethod("POST");
return con;
}
public static String getStringFromInputStream(InputStream is)
throws IOException
{
ByteArrayOutputStream os = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = -1;
while ((len = is.read(buffer)) != -1) {
os.write(buffer, 0, len);
}
is.close();
String state = os.toString();
os.close();
return state;
}
}
| 2,033 | 0.648449 | 0.619399 | 86 | 22.61628 | 22.07238 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.488372 | false | false | 2 |
6d33ec13d2f07d54b84d41f0538f8f61988491c5 | 3,212,635,591,524 | ec87f45f114e80ecbef9b768d397292e5d91f6ac | /src/main/java/com/ksg/workbench/shippertable/dialog/UpdateTableInOutDialog.java | 8525aedf41220e338dba8575a4704ef143deeca0 | []
| no_license | archehyun/ksg | https://github.com/archehyun/ksg | b1450f1c32f17bde20af59c7129952a58c751637 | 60f985b0080321f782b6080b08dbea6b73adbeea | refs/heads/master | 2023-08-08T01:12:58.631000 | 2022-05-17T12:47:47 | 2022-05-17T12:47:47 | 74,729,027 | 0 | 0 | null | false | 2023-03-17T02:01:47 | 2016-11-25T05:44:28 | 2022-04-08T13:18:56 | 2023-03-17T02:01:46 | 21,986 | 0 | 0 | 1 | Java | false | false | /*******************************************************************************
* Copyright (c) 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ksg.workbench.shippertable.dialog;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.StringTokenizer;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import com.ksg.common.dao.DAOManager;
import com.ksg.common.model.KSGModelManager;
import com.ksg.common.util.ViewUtil;
import com.ksg.domain.ADVData;
import com.ksg.domain.ShippersTable;
import com.ksg.service.impl.TableServiceImpl;
import com.ksg.workbench.common.comp.dialog.KSGDialog;
/**
* @author 박창현
*
*/
public class UpdateTableInOutDialog extends KSGDialog implements ActionListener{
private static final String OUT_PORT_LEFT = "OutPortLeft";
private static final String OUT_PORT_RIGHT = "OutPortRight";
private static final String IN_PORT_LEFT = "InPortLeft";
private static final String IN_PORT_RIGHT = "InPortRight";
private static final String OUT_TO_PORT_LEFT = "OutToPortLeft";
private static final String OUT_TO_PORT_RIGHT = "OutToPortRight";
private static final String IN_TO_PORT_LEFT = "InToPortLeft";
private static final String IN_TO_PORT_RIGHT = "InToPortRight";
/**
*
*/
private static final long serialVersionUID = 1L;
ShippersTable shippersTable;
JList totalPort = new JList();
JList subPort =new JList();
JList outPort = new JList();
JList inPort = new JList();
JList outToPort = new JList();
JList inToPort = new JList();
public String inPortIndex=null;
public String inToPortIndex=null;
public String outPortIndex=null;
public String outToPortIndex=null;
HashMap<Integer, ListData> inPortMap = new HashMap<Integer, ListData>();
HashMap<Integer, ListData> inToPortMap = new HashMap<Integer, ListData>();
HashMap<Integer, ListData> outPortMap = new HashMap<Integer, ListData>();
HashMap<Integer, ListData> outToPortMap = new HashMap<Integer, ListData>();
HashMap<Integer, ListData> portMap = new HashMap<Integer, ListData>();
public UpdateTableInOutDialog(ShippersTable table) {
shippersTable = table;
DAOManager manager = DAOManager.getInstance();
tableService = new TableServiceImpl();
advservice = manager.createADVService();
}
public void createAndUpdateUI() {
try{
ADVData advData=advservice.getADVData(shippersTable.getTable_id(), shippersTable.getDate_isusse());
if(advData==null)
{
JOptionPane.showMessageDialog(KSGModelManager.getInstance().frame, "광고정보가 없습니다.");
return;
}
ShippersTable tableInfo = tableService.getTableById(shippersTable.getTable_id());
String[]portList=advData.getPortArray();
for(int i=0;i<portList.length;i++)
{
ListData data = new ListData(portList[i],i+1);
portMap.put(i+1, data);
}
initMap(tableInfo.getOut_port(),outPortMap,portMap);
initMap(tableInfo.getOut_to_port(),outToPortMap,portMap);
initMap(tableInfo.getIn_port(),inPortMap,portMap);
initMap(tableInfo.getIn_to_port(),outPortMap,portMap);
initList(portMap,totalPort);
initList(outPortMap,outPort);
initList(outToPortMap,outToPort);
initList(inPortMap,inPort);
initList(inToPortMap,inToPort);
this.setTitle("In/Out 항구 등록");
this.setModal(true);
JPanel pnMain = new JPanel();
GridLayout gridLayout = new GridLayout(1,0);
gridLayout.setHgap(5);
pnMain.setLayout(gridLayout);
JTabbedPane pnMainRight = new JTabbedPane();
pnMainRight.setFont(defaultFont);
JTabbedPane pnMainLeft = new JTabbedPane();
pnMainLeft.setFont(defaultFont);
Box portLists = new Box(BoxLayout.Y_AXIS);
JLabel lblPortList = new JLabel("항구목록",JLabel.LEFT);
lblPortList.setFont(defaultFont);
JScrollPane spTotal = new JScrollPane(totalPort);
JScrollPane spSub = new JScrollPane(subPort);
portLists.add(spTotal);
JLabel lbl = new JLabel("등록항구목록",JLabel.LEFT);
lbl.setFont(defaultFont);
portLists.add(lbl);
portLists.add(spSub);
pnMainLeft.add(portLists,"항구목록");
// pnTotalNorth.add(lblPortList,BorderLayout.NORTH);
pnMain.add(pnMainLeft);
// OutPort
JPanel pnOutPort = createInOut("Outbound 국내항",OUT_PORT_RIGHT,OUT_PORT_LEFT,outPort);
// OutToPort
JPanel pnOutToPort = createInOut("Outbound 외국항",OUT_TO_PORT_RIGHT,OUT_TO_PORT_LEFT,outToPort);
//InPort
JPanel pnInPort = createInOut("Inbound 국내항",IN_PORT_RIGHT,IN_PORT_LEFT,inPort);
//InToPort
JPanel pnInToPort = createInOut("Inbound 외국항",IN_TO_PORT_RIGHT,IN_TO_PORT_LEFT,inToPort);
JPanel pnOut = new JPanel();
pnOut.setLayout(new GridLayout(0,1));
pnOut.add(pnOutPort);
pnOut.add(pnOutToPort);
JPanel pnIn = new JPanel();
pnIn.setLayout(new GridLayout(0,1));
pnIn.add(pnInPort);
pnIn.add(pnInToPort);
pnMainRight.addTab("Outbound", pnOut);
pnMainRight.addTab("Inbound",pnIn);
pnMain.add(pnMainRight);
JPanel pnControl = new JPanel();
pnControl.setLayout(new FlowLayout(FlowLayout.RIGHT));
JButton butOK = new JButton("확인");
butOK.setFont(defaultFont);
butOK.addActionListener(this);
pnControl.add(butOK);
JButton butCancel = new JButton("취소");
butCancel.setFont(defaultFont);
butCancel.addActionListener(this);
pnControl.add(butCancel);
this.getContentPane().add(pnMain,BorderLayout.CENTER);
this.getContentPane().add(pnControl,BorderLayout.SOUTH);
this.getContentPane().add(buildTitle(),BorderLayout.NORTH);
this.getContentPane().add(createLine(),BorderLayout.WEST);
this.getContentPane().add(createLine(),BorderLayout.EAST);
this.setSize(500,500);
ViewUtil.center(this, false);
this.setVisible(true);
}catch (Exception e) {
e.printStackTrace();
}
}
private Component buildTitle() {
JPanel pnMain = new JPanel();
pnMain.setLayout(new FlowLayout(FlowLayout.LEFT));
JLabel lblTitle = new JLabel("In/Out 항구를 등록합니다.");
pnMain.add(lblTitle);
pnMain.setBackground(Color.white);
return pnMain;
}
public void initMap(String ports, HashMap<Integer, ListData> outPortList2, HashMap<Integer, ListData> portMap2)
{
StringTokenizer stInport = new StringTokenizer(ports,"#");
while(stInport.hasMoreTokens())
{
try{
int index =Integer.parseInt(stInport.nextToken());
if(portMap2.containsKey(index))
{
outPortList2.put(index, portMap2.remove(index));
}
}catch (NumberFormatException e) {
// TODO: handle exception
}
}
}
private void initList(HashMap<Integer , ListData> map,JList list) {
// StringTokenizer stInport = new StringTokenizer(inPorts,"#");
Iterator iter = map.keySet().iterator();
DefaultListModel inPortListModel = new DefaultListModel();
while (iter.hasNext())
{
Integer key = (Integer) iter.next();
inPortListModel.addElement(map.get(key));
}
list.setModel(inPortListModel);
}
/**
* @param oneList
* @param twoList
* @param oneMap
* @param twoMap
*/
private void addList(JList oneList,JList twoList, HashMap<Integer, ListData> oneMap,HashMap<Integer, ListData> twoMap)
{
int index = oneList.getSelectedIndex();
if(index!=-1)
{
DefaultListModel model = (DefaultListModel) oneList.getModel();
DefaultListModel model2 = (DefaultListModel) twoList.getModel();
ListData data =(ListData) model.remove(index);
model2.addElement(data);
/**
* 정렬 기능이 추가 되어야 함
*
*/
if(oneMap.containsKey(data.index))
{
twoMap.put(data.index, oneMap.remove(data.index));
}
}
}
private JPanel createInOut(String label, String right, String left,JComponent comp)
{
JPanel pnMain = new JPanel();
pnMain.setLayout(new BorderLayout());
Box pnBox = new Box(BoxLayout.Y_AXIS);
pnBox.add(addButton("▶", right));
pnBox.add(addButton("◀", left));
JPanel pnControl = new JPanel();
pnControl.setLayout(new BorderLayout());
JLabel lblTitle = new JLabel(label);
lblTitle.setFont(defaultFont);
comp.setFont(defaultFont);
pnControl.add(pnBox,BorderLayout.CENTER);
pnMain.add(lblTitle,BorderLayout.NORTH);
pnMain.add(new JScrollPane(comp),BorderLayout.CENTER);
pnMain.add(pnControl,BorderLayout.WEST);
return pnMain;
}
public JButton addButton(String label, String command)
{
JButton but =new JButton(label);
but.setActionCommand(command);
but.addActionListener(this);
but.setFont(new Font("돋움",Font.BOLD,8));
return but;
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if(command.equals("확인"))
{
this.inPortIndex=getIndexInfo(inPortMap);
this.outPortIndex=getIndexInfo(outPortMap);
this.inToPortIndex=getIndexInfo(inToPortMap);
this.outToPortIndex=getIndexInfo(outToPortMap);
this.setVisible(false);
this.dispose();
}
else if(command.equals(OUT_PORT_LEFT))
{
addList(outPort, totalPort, outPortMap, portMap);
}
else if(command.equals(OUT_PORT_RIGHT))
{
addList(totalPort, outPort, portMap, outPortMap);
}
else if(command.equals(IN_PORT_LEFT))
{
addList(inPort, totalPort, inPortMap, portMap);
}
else if(command.equals(IN_PORT_RIGHT))
{
addList(totalPort, inPort, portMap, inPortMap);
}
else if(command.equals(OUT_TO_PORT_LEFT))
{
addList(outToPort, totalPort, outToPortMap, portMap);
}
else if(command.equals(OUT_TO_PORT_RIGHT))
{
addList(totalPort, outToPort, portMap, outToPortMap);
}
else if(command.equals(IN_TO_PORT_LEFT))
{
addList(inToPort, totalPort, inToPortMap, portMap);
}
else if(command.equals(IN_TO_PORT_RIGHT))
{
addList(totalPort, inToPort, portMap, inToPortMap);
}
else if(command.equals("취소"))
{
this.setVisible(false);
this.dispose();
}
}
private String getIndexInfo(HashMap<Integer, ListData> inPortMap) {
Set st = inPortMap.keySet();
Iterator itr = st.iterator();
StringBuffer buffer = new StringBuffer();
while (itr.hasNext())
{
ListData data=inPortMap.get(itr.next());
buffer.append(data.index);
if(itr.hasNext())
buffer.append("#");
}
return buffer.toString();
}
class ListData
{
String portName;
int index;
public ListData(String portName, int index) {
this.portName=portName;
this.index=index;
}
public String toString()
{
return index+":"+portName;
}
}
}
| UHC | Java | 11,738 | java | UpdateTableInOutDialog.java | Java | [
{
"context": "h.common.comp.dialog.KSGDialog;\r\n\r\n/**\r\n * @author 박창현\r\n *\r\n */\r\npublic class UpdateTableInOutDialog ext",
"end": 1605,
"score": 0.9998615980148315,
"start": 1602,
"tag": "NAME",
"value": "박창현"
}
]
| null | []
| /*******************************************************************************
* Copyright (c) 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ksg.workbench.shippertable.dialog;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.StringTokenizer;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import com.ksg.common.dao.DAOManager;
import com.ksg.common.model.KSGModelManager;
import com.ksg.common.util.ViewUtil;
import com.ksg.domain.ADVData;
import com.ksg.domain.ShippersTable;
import com.ksg.service.impl.TableServiceImpl;
import com.ksg.workbench.common.comp.dialog.KSGDialog;
/**
* @author 박창현
*
*/
public class UpdateTableInOutDialog extends KSGDialog implements ActionListener{
private static final String OUT_PORT_LEFT = "OutPortLeft";
private static final String OUT_PORT_RIGHT = "OutPortRight";
private static final String IN_PORT_LEFT = "InPortLeft";
private static final String IN_PORT_RIGHT = "InPortRight";
private static final String OUT_TO_PORT_LEFT = "OutToPortLeft";
private static final String OUT_TO_PORT_RIGHT = "OutToPortRight";
private static final String IN_TO_PORT_LEFT = "InToPortLeft";
private static final String IN_TO_PORT_RIGHT = "InToPortRight";
/**
*
*/
private static final long serialVersionUID = 1L;
ShippersTable shippersTable;
JList totalPort = new JList();
JList subPort =new JList();
JList outPort = new JList();
JList inPort = new JList();
JList outToPort = new JList();
JList inToPort = new JList();
public String inPortIndex=null;
public String inToPortIndex=null;
public String outPortIndex=null;
public String outToPortIndex=null;
HashMap<Integer, ListData> inPortMap = new HashMap<Integer, ListData>();
HashMap<Integer, ListData> inToPortMap = new HashMap<Integer, ListData>();
HashMap<Integer, ListData> outPortMap = new HashMap<Integer, ListData>();
HashMap<Integer, ListData> outToPortMap = new HashMap<Integer, ListData>();
HashMap<Integer, ListData> portMap = new HashMap<Integer, ListData>();
public UpdateTableInOutDialog(ShippersTable table) {
shippersTable = table;
DAOManager manager = DAOManager.getInstance();
tableService = new TableServiceImpl();
advservice = manager.createADVService();
}
public void createAndUpdateUI() {
try{
ADVData advData=advservice.getADVData(shippersTable.getTable_id(), shippersTable.getDate_isusse());
if(advData==null)
{
JOptionPane.showMessageDialog(KSGModelManager.getInstance().frame, "광고정보가 없습니다.");
return;
}
ShippersTable tableInfo = tableService.getTableById(shippersTable.getTable_id());
String[]portList=advData.getPortArray();
for(int i=0;i<portList.length;i++)
{
ListData data = new ListData(portList[i],i+1);
portMap.put(i+1, data);
}
initMap(tableInfo.getOut_port(),outPortMap,portMap);
initMap(tableInfo.getOut_to_port(),outToPortMap,portMap);
initMap(tableInfo.getIn_port(),inPortMap,portMap);
initMap(tableInfo.getIn_to_port(),outPortMap,portMap);
initList(portMap,totalPort);
initList(outPortMap,outPort);
initList(outToPortMap,outToPort);
initList(inPortMap,inPort);
initList(inToPortMap,inToPort);
this.setTitle("In/Out 항구 등록");
this.setModal(true);
JPanel pnMain = new JPanel();
GridLayout gridLayout = new GridLayout(1,0);
gridLayout.setHgap(5);
pnMain.setLayout(gridLayout);
JTabbedPane pnMainRight = new JTabbedPane();
pnMainRight.setFont(defaultFont);
JTabbedPane pnMainLeft = new JTabbedPane();
pnMainLeft.setFont(defaultFont);
Box portLists = new Box(BoxLayout.Y_AXIS);
JLabel lblPortList = new JLabel("항구목록",JLabel.LEFT);
lblPortList.setFont(defaultFont);
JScrollPane spTotal = new JScrollPane(totalPort);
JScrollPane spSub = new JScrollPane(subPort);
portLists.add(spTotal);
JLabel lbl = new JLabel("등록항구목록",JLabel.LEFT);
lbl.setFont(defaultFont);
portLists.add(lbl);
portLists.add(spSub);
pnMainLeft.add(portLists,"항구목록");
// pnTotalNorth.add(lblPortList,BorderLayout.NORTH);
pnMain.add(pnMainLeft);
// OutPort
JPanel pnOutPort = createInOut("Outbound 국내항",OUT_PORT_RIGHT,OUT_PORT_LEFT,outPort);
// OutToPort
JPanel pnOutToPort = createInOut("Outbound 외국항",OUT_TO_PORT_RIGHT,OUT_TO_PORT_LEFT,outToPort);
//InPort
JPanel pnInPort = createInOut("Inbound 국내항",IN_PORT_RIGHT,IN_PORT_LEFT,inPort);
//InToPort
JPanel pnInToPort = createInOut("Inbound 외국항",IN_TO_PORT_RIGHT,IN_TO_PORT_LEFT,inToPort);
JPanel pnOut = new JPanel();
pnOut.setLayout(new GridLayout(0,1));
pnOut.add(pnOutPort);
pnOut.add(pnOutToPort);
JPanel pnIn = new JPanel();
pnIn.setLayout(new GridLayout(0,1));
pnIn.add(pnInPort);
pnIn.add(pnInToPort);
pnMainRight.addTab("Outbound", pnOut);
pnMainRight.addTab("Inbound",pnIn);
pnMain.add(pnMainRight);
JPanel pnControl = new JPanel();
pnControl.setLayout(new FlowLayout(FlowLayout.RIGHT));
JButton butOK = new JButton("확인");
butOK.setFont(defaultFont);
butOK.addActionListener(this);
pnControl.add(butOK);
JButton butCancel = new JButton("취소");
butCancel.setFont(defaultFont);
butCancel.addActionListener(this);
pnControl.add(butCancel);
this.getContentPane().add(pnMain,BorderLayout.CENTER);
this.getContentPane().add(pnControl,BorderLayout.SOUTH);
this.getContentPane().add(buildTitle(),BorderLayout.NORTH);
this.getContentPane().add(createLine(),BorderLayout.WEST);
this.getContentPane().add(createLine(),BorderLayout.EAST);
this.setSize(500,500);
ViewUtil.center(this, false);
this.setVisible(true);
}catch (Exception e) {
e.printStackTrace();
}
}
private Component buildTitle() {
JPanel pnMain = new JPanel();
pnMain.setLayout(new FlowLayout(FlowLayout.LEFT));
JLabel lblTitle = new JLabel("In/Out 항구를 등록합니다.");
pnMain.add(lblTitle);
pnMain.setBackground(Color.white);
return pnMain;
}
public void initMap(String ports, HashMap<Integer, ListData> outPortList2, HashMap<Integer, ListData> portMap2)
{
StringTokenizer stInport = new StringTokenizer(ports,"#");
while(stInport.hasMoreTokens())
{
try{
int index =Integer.parseInt(stInport.nextToken());
if(portMap2.containsKey(index))
{
outPortList2.put(index, portMap2.remove(index));
}
}catch (NumberFormatException e) {
// TODO: handle exception
}
}
}
private void initList(HashMap<Integer , ListData> map,JList list) {
// StringTokenizer stInport = new StringTokenizer(inPorts,"#");
Iterator iter = map.keySet().iterator();
DefaultListModel inPortListModel = new DefaultListModel();
while (iter.hasNext())
{
Integer key = (Integer) iter.next();
inPortListModel.addElement(map.get(key));
}
list.setModel(inPortListModel);
}
/**
* @param oneList
* @param twoList
* @param oneMap
* @param twoMap
*/
private void addList(JList oneList,JList twoList, HashMap<Integer, ListData> oneMap,HashMap<Integer, ListData> twoMap)
{
int index = oneList.getSelectedIndex();
if(index!=-1)
{
DefaultListModel model = (DefaultListModel) oneList.getModel();
DefaultListModel model2 = (DefaultListModel) twoList.getModel();
ListData data =(ListData) model.remove(index);
model2.addElement(data);
/**
* 정렬 기능이 추가 되어야 함
*
*/
if(oneMap.containsKey(data.index))
{
twoMap.put(data.index, oneMap.remove(data.index));
}
}
}
private JPanel createInOut(String label, String right, String left,JComponent comp)
{
JPanel pnMain = new JPanel();
pnMain.setLayout(new BorderLayout());
Box pnBox = new Box(BoxLayout.Y_AXIS);
pnBox.add(addButton("▶", right));
pnBox.add(addButton("◀", left));
JPanel pnControl = new JPanel();
pnControl.setLayout(new BorderLayout());
JLabel lblTitle = new JLabel(label);
lblTitle.setFont(defaultFont);
comp.setFont(defaultFont);
pnControl.add(pnBox,BorderLayout.CENTER);
pnMain.add(lblTitle,BorderLayout.NORTH);
pnMain.add(new JScrollPane(comp),BorderLayout.CENTER);
pnMain.add(pnControl,BorderLayout.WEST);
return pnMain;
}
public JButton addButton(String label, String command)
{
JButton but =new JButton(label);
but.setActionCommand(command);
but.addActionListener(this);
but.setFont(new Font("돋움",Font.BOLD,8));
return but;
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if(command.equals("확인"))
{
this.inPortIndex=getIndexInfo(inPortMap);
this.outPortIndex=getIndexInfo(outPortMap);
this.inToPortIndex=getIndexInfo(inToPortMap);
this.outToPortIndex=getIndexInfo(outToPortMap);
this.setVisible(false);
this.dispose();
}
else if(command.equals(OUT_PORT_LEFT))
{
addList(outPort, totalPort, outPortMap, portMap);
}
else if(command.equals(OUT_PORT_RIGHT))
{
addList(totalPort, outPort, portMap, outPortMap);
}
else if(command.equals(IN_PORT_LEFT))
{
addList(inPort, totalPort, inPortMap, portMap);
}
else if(command.equals(IN_PORT_RIGHT))
{
addList(totalPort, inPort, portMap, inPortMap);
}
else if(command.equals(OUT_TO_PORT_LEFT))
{
addList(outToPort, totalPort, outToPortMap, portMap);
}
else if(command.equals(OUT_TO_PORT_RIGHT))
{
addList(totalPort, outToPort, portMap, outToPortMap);
}
else if(command.equals(IN_TO_PORT_LEFT))
{
addList(inToPort, totalPort, inToPortMap, portMap);
}
else if(command.equals(IN_TO_PORT_RIGHT))
{
addList(totalPort, inToPort, portMap, inToPortMap);
}
else if(command.equals("취소"))
{
this.setVisible(false);
this.dispose();
}
}
private String getIndexInfo(HashMap<Integer, ListData> inPortMap) {
Set st = inPortMap.keySet();
Iterator itr = st.iterator();
StringBuffer buffer = new StringBuffer();
while (itr.hasNext())
{
ListData data=inPortMap.get(itr.next());
buffer.append(data.index);
if(itr.hasNext())
buffer.append("#");
}
return buffer.toString();
}
class ListData
{
String portName;
int index;
public ListData(String portName, int index) {
this.portName=portName;
this.index=index;
}
public String toString()
{
return index+":"+portName;
}
}
}
| 11,738 | 0.68254 | 0.679607 | 405 | 26.622223 | 23.758205 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.577778 | false | false | 2 |
5a56f9ec8a330c98a5672a8110ab701d1d5d7348 | 30,408,368,493,526 | 1e1df944adbdd6c86e4c875dc485e4f55042917e | /app/src/main/java/com/example/connor/cabshare/MyActivity.java | 61bccf64cdc36b58a114c6eff6bcc7dc28fa6d7c | []
| no_license | rohitnazareth/CabShare | https://github.com/rohitnazareth/CabShare | e8510489b6409430786248c12d6756a1e1d854ea | dea95ca64546def70cde705918bd99615cbde956 | refs/heads/master | 2017-12-05T08:55:41.066000 | 2014-12-04T14:57:41 | 2014-12-04T14:57:41 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.connor.cabshare;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.firebase.client.AuthData;
import com.firebase.client.DataSnapshot;
import com.firebase.client.Firebase;
import com.firebase.client.FirebaseError;
import com.firebase.client.ValueEventListener;
import java.util.HashMap;
import java.util.Map;
/**
* This application demos the use of the Firebase Login feature. It currently supports logging in
* with Google, Facebook, Twitter, Email/Password, and Anonymous providers.
* <p/>
* The methods in this class have been divided into sections based on providers (with a few
* general methods).
* <p/>
* Email/Password is provided using {@link com.firebase.client.Firebase}
*/
public class MyActivity extends ActionBarActivity{
private TextView mLoggedInStatusTextView;
private ProgressDialog mAuthProgressDialog;
private Firebase ref;
private static AuthData authData;
public static AuthData authData2;
private static final String TAG = "CabShare";
private EditText email;
private EditText pass;
/***************************************
* PASSWORD *
***************************************/
private Button mPasswordLoginButton;
private Button newUser;
public static synchronized AuthData getInstance(){
authData2 = authData;
return authData2;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
email = (EditText)findViewById(R.id.destination);
pass = (EditText)findViewById(R.id.editText2);
newUser = (Button)findViewById(R.id.editProfile);
newUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent myIntent = new Intent(MyActivity.this, ProfileCreationPage.class);
startActivity(myIntent);
}
});
mPasswordLoginButton = (Button)findViewById(R.id.login_with_password);
mPasswordLoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
loginWithPassword();
}
});
/***************************************
* GENERAL *
***************************************/
mLoggedInStatusTextView = (TextView)findViewById(R.id.login_status);
/* Create the SimpleLogin class that is used for all authentication with Firebase */
String firebaseUrl = getResources().getString(R.string.firebase_url);
Firebase.setAndroidContext(getApplicationContext());
ref = new Firebase(firebaseUrl);
/* Setup the progress dialog that is displayed later when authenticating with Firebase */
mAuthProgressDialog = new ProgressDialog(this);
mAuthProgressDialog.setTitle("Loading");
mAuthProgressDialog.setMessage("Authenticating with Firebase...");
mAuthProgressDialog.setCancelable(false);
mAuthProgressDialog.show();
/* Check if the user is authenticated with Firebase already. If this is the case we can set the authenticated
* user and hide hide any login buttons */
ref.addAuthStateListener(new Firebase.AuthStateListener() {
@Override
public void onAuthStateChanged(AuthData authData) {
mAuthProgressDialog.hide();
setAuthenticatedUser(authData);
}
});
}
/**
* This method fires when any startActivityForResult finishes. The requestCode maps to
* the value passed into startActivityForResult.
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Map<String, String> options = new HashMap<String, String>();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
/* If a user is currently authenticated, display a logout menu */
if (this.authData != null) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
} else {
return false;
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_logout) {
logout();
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* Unauthenticate from Firebase and from providers where necessary.
*/
private void logout() {
if (this.authData != null) {
/* logout of Firebase */
ref.unauth();
/* Update authenticated user and show login buttons */
setAuthenticatedUser(null);
}
}
/**
* This method will attempt to authenticate a user to firebase given an oauth_token (and other
* necessary parameters depending on the provider)
*/
private void authWithFirebase(final String provider, Map<String, String> options) {
if (options.containsKey("error")) {
showErrorDialog(options.get("error"));
} else {
mAuthProgressDialog.show();
if (provider.equals("twitter")) {
// if the provider is twitter, we pust pass in additional options, so use the options endpoint
ref.authWithOAuthToken(provider, options, new AuthResultHandler(provider));
} else {
// if the provider is not twitter, we just need to pass in the oauth_token
ref.authWithOAuthToken(provider, options.get("oauth_token"), new AuthResultHandler(provider));
}
}
}
/**
* Once a user is logged in, take the authData provided from Firebase and "use" it.
*/
private void setAuthenticatedUser(AuthData authData) {
if (authData != null) {
/* Hide all the login buttons */
//mPasswordLoginButton.setVisibility(View.GONE);//replace with main menu intent
//newUser.setVisibility(View.GONE);
Intent callMain = new Intent(MyActivity.this, MainMenuPage.class); //prepare the intent to redirect from logging in to main menu
startActivity(callMain); //redirect to main menu
mLoggedInStatusTextView.setVisibility(View.VISIBLE);
} else {
/* No authenticated user show all the login buttons */
mPasswordLoginButton.setVisibility(View.VISIBLE);
mLoggedInStatusTextView.setVisibility(View.GONE);
newUser.setVisibility(View.VISIBLE);
}
this.authData = authData;
/* invalidate options menu to hide/show the logout button */
supportInvalidateOptionsMenu();
}
/**
* Show errors to users
*/
private void showErrorDialog(String message) {
new AlertDialog.Builder(this)
.setTitle("Error")
.setMessage(message)
.setPositiveButton(android.R.string.ok, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
/**
* Utility class for authentication results
*/
private class AuthResultHandler implements Firebase.AuthResultHandler {
private final String provider;
public AuthResultHandler(String provider) {
this.provider = provider;
}
@Override
public void onAuthenticated(AuthData authData) {
mAuthProgressDialog.hide();
Log.i(TAG, provider + " auth successful");
setAuthenticatedUser(authData);
final String userID = authData.getUid();
ref.child("users").child(authData.getUid()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
final Object userData = snapshot.getValue();
if (userData == null) {
Intent redirectToFirstTimeLogin = new Intent(MyActivity.this, FirstTimeLogin.class);
startActivity(redirectToFirstTimeLogin);
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
System.out.println("The read failed: " + firebaseError.getMessage());
}
});
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {
mAuthProgressDialog.hide();
showErrorDialog(firebaseError.toString());
}
}
public void onConnectionSuspended(int i) {
// ignore
}
/***************************************
* PASSWORD *
***************************************/
public void loginWithPassword() {
String tempEmail = email.getEditableText().toString();
String tempPass = pass.getEditableText().toString();
mAuthProgressDialog.show();
ref.authWithPassword(tempEmail, tempPass, new AuthResultHandler("password"));
}
}
| UTF-8 | Java | 9,652 | java | MyActivity.java | Java | []
| null | []
| package com.example.connor.cabshare;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.firebase.client.AuthData;
import com.firebase.client.DataSnapshot;
import com.firebase.client.Firebase;
import com.firebase.client.FirebaseError;
import com.firebase.client.ValueEventListener;
import java.util.HashMap;
import java.util.Map;
/**
* This application demos the use of the Firebase Login feature. It currently supports logging in
* with Google, Facebook, Twitter, Email/Password, and Anonymous providers.
* <p/>
* The methods in this class have been divided into sections based on providers (with a few
* general methods).
* <p/>
* Email/Password is provided using {@link com.firebase.client.Firebase}
*/
public class MyActivity extends ActionBarActivity{
private TextView mLoggedInStatusTextView;
private ProgressDialog mAuthProgressDialog;
private Firebase ref;
private static AuthData authData;
public static AuthData authData2;
private static final String TAG = "CabShare";
private EditText email;
private EditText pass;
/***************************************
* PASSWORD *
***************************************/
private Button mPasswordLoginButton;
private Button newUser;
public static synchronized AuthData getInstance(){
authData2 = authData;
return authData2;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
email = (EditText)findViewById(R.id.destination);
pass = (EditText)findViewById(R.id.editText2);
newUser = (Button)findViewById(R.id.editProfile);
newUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent myIntent = new Intent(MyActivity.this, ProfileCreationPage.class);
startActivity(myIntent);
}
});
mPasswordLoginButton = (Button)findViewById(R.id.login_with_password);
mPasswordLoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
loginWithPassword();
}
});
/***************************************
* GENERAL *
***************************************/
mLoggedInStatusTextView = (TextView)findViewById(R.id.login_status);
/* Create the SimpleLogin class that is used for all authentication with Firebase */
String firebaseUrl = getResources().getString(R.string.firebase_url);
Firebase.setAndroidContext(getApplicationContext());
ref = new Firebase(firebaseUrl);
/* Setup the progress dialog that is displayed later when authenticating with Firebase */
mAuthProgressDialog = new ProgressDialog(this);
mAuthProgressDialog.setTitle("Loading");
mAuthProgressDialog.setMessage("Authenticating with Firebase...");
mAuthProgressDialog.setCancelable(false);
mAuthProgressDialog.show();
/* Check if the user is authenticated with Firebase already. If this is the case we can set the authenticated
* user and hide hide any login buttons */
ref.addAuthStateListener(new Firebase.AuthStateListener() {
@Override
public void onAuthStateChanged(AuthData authData) {
mAuthProgressDialog.hide();
setAuthenticatedUser(authData);
}
});
}
/**
* This method fires when any startActivityForResult finishes. The requestCode maps to
* the value passed into startActivityForResult.
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Map<String, String> options = new HashMap<String, String>();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
/* If a user is currently authenticated, display a logout menu */
if (this.authData != null) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
} else {
return false;
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_logout) {
logout();
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* Unauthenticate from Firebase and from providers where necessary.
*/
private void logout() {
if (this.authData != null) {
/* logout of Firebase */
ref.unauth();
/* Update authenticated user and show login buttons */
setAuthenticatedUser(null);
}
}
/**
* This method will attempt to authenticate a user to firebase given an oauth_token (and other
* necessary parameters depending on the provider)
*/
private void authWithFirebase(final String provider, Map<String, String> options) {
if (options.containsKey("error")) {
showErrorDialog(options.get("error"));
} else {
mAuthProgressDialog.show();
if (provider.equals("twitter")) {
// if the provider is twitter, we pust pass in additional options, so use the options endpoint
ref.authWithOAuthToken(provider, options, new AuthResultHandler(provider));
} else {
// if the provider is not twitter, we just need to pass in the oauth_token
ref.authWithOAuthToken(provider, options.get("oauth_token"), new AuthResultHandler(provider));
}
}
}
/**
* Once a user is logged in, take the authData provided from Firebase and "use" it.
*/
private void setAuthenticatedUser(AuthData authData) {
if (authData != null) {
/* Hide all the login buttons */
//mPasswordLoginButton.setVisibility(View.GONE);//replace with main menu intent
//newUser.setVisibility(View.GONE);
Intent callMain = new Intent(MyActivity.this, MainMenuPage.class); //prepare the intent to redirect from logging in to main menu
startActivity(callMain); //redirect to main menu
mLoggedInStatusTextView.setVisibility(View.VISIBLE);
} else {
/* No authenticated user show all the login buttons */
mPasswordLoginButton.setVisibility(View.VISIBLE);
mLoggedInStatusTextView.setVisibility(View.GONE);
newUser.setVisibility(View.VISIBLE);
}
this.authData = authData;
/* invalidate options menu to hide/show the logout button */
supportInvalidateOptionsMenu();
}
/**
* Show errors to users
*/
private void showErrorDialog(String message) {
new AlertDialog.Builder(this)
.setTitle("Error")
.setMessage(message)
.setPositiveButton(android.R.string.ok, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
/**
* Utility class for authentication results
*/
private class AuthResultHandler implements Firebase.AuthResultHandler {
private final String provider;
public AuthResultHandler(String provider) {
this.provider = provider;
}
@Override
public void onAuthenticated(AuthData authData) {
mAuthProgressDialog.hide();
Log.i(TAG, provider + " auth successful");
setAuthenticatedUser(authData);
final String userID = authData.getUid();
ref.child("users").child(authData.getUid()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
final Object userData = snapshot.getValue();
if (userData == null) {
Intent redirectToFirstTimeLogin = new Intent(MyActivity.this, FirstTimeLogin.class);
startActivity(redirectToFirstTimeLogin);
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
System.out.println("The read failed: " + firebaseError.getMessage());
}
});
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {
mAuthProgressDialog.hide();
showErrorDialog(firebaseError.toString());
}
}
public void onConnectionSuspended(int i) {
// ignore
}
/***************************************
* PASSWORD *
***************************************/
public void loginWithPassword() {
String tempEmail = email.getEditableText().toString();
String tempPass = pass.getEditableText().toString();
mAuthProgressDialog.show();
ref.authWithPassword(tempEmail, tempPass, new AuthResultHandler("password"));
}
}
| 9,652 | 0.612308 | 0.61179 | 281 | 33.345196 | 29.138369 | 141 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.451957 | false | false | 2 |
11a6f2eff04c57e22e3c3a6562e05c37a965289a | 19,722,489,862,216 | 04993ec330462593a8d64d3cbda0275053420ace | /JHPaymentGatewayPro/src/main/java/com/jh/paymentgateway/controller/ldx/dao/LDXAreaRepository.java | b8ba82354e7896c74988d2c27a820fc4b1e3468b | []
| no_license | jsy579579/jh | https://github.com/jsy579579/jh | 60af71fada0462c45f527943f22c1a9ccd8268fd | 44858ab7fbf461cd382efe436473d9581d4c067a | refs/heads/master | 2022-05-13T22:28:16.095000 | 2020-04-29T03:20:14 | 2020-04-29T03:20:14 | 259,813,186 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jh.paymentgateway.controller.ldx.dao;
import com.jh.paymentgateway.controller.ldx.pojo.LDXArea;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface LDXAreaRepository extends JpaRepository<LDXArea, Long>, JpaSpecificationExecutor<LDXArea> {
@Query("select l from LDXArea l group by l.province")
List<LDXArea> queryAll();
@Query("select l from LDXArea l where l.city=:city")
List<LDXArea> getAllByCity(@Param("city") String city);
@Query("select l from LDXArea l where l.province=:province group by city")
List<LDXArea> getAllByProvince(@Param("province") String province);
}
| UTF-8 | Java | 911 | java | LDXAreaRepository.java | Java | []
| null | []
| package com.jh.paymentgateway.controller.ldx.dao;
import com.jh.paymentgateway.controller.ldx.pojo.LDXArea;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface LDXAreaRepository extends JpaRepository<LDXArea, Long>, JpaSpecificationExecutor<LDXArea> {
@Query("select l from LDXArea l group by l.province")
List<LDXArea> queryAll();
@Query("select l from LDXArea l where l.city=:city")
List<LDXArea> getAllByCity(@Param("city") String city);
@Query("select l from LDXArea l where l.province=:province group by city")
List<LDXArea> getAllByProvince(@Param("province") String province);
}
| 911 | 0.79034 | 0.79034 | 23 | 38.608696 | 31.351776 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.565217 | false | false | 2 |
441a7f1e677055a07ad840a537bcad131164f214 | 19,138,374,295,280 | 66feae27439c0568d550dc09081ab07a5eb2ae1e | /test/Partitioning/letterGradeByPartitioningTest.java | 2c86edc103c6a6a87c6f6c03a5af840cd3b4e967 | []
| no_license | s7130457/SE_hw4 | https://github.com/s7130457/SE_hw4 | c6faeceb2751196e22ddef8cc851f0bc71040ba9 | fb6f30f8f86a3bbd055204814fa7b12665e6d3ec | refs/heads/master | 2021-09-01T23:54:26.374000 | 2017-12-29T08:30:42 | 2017-12-29T08:30:42 | 115,622,891 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Partitioning;
import junit.framework.Assert;
import org.junit.Test;
import GradeRange.Grade;
import GradeRange.LetterGrade;
public class letterGradeByPartitioningTest {
LetterGrade grade = new LetterGrade();
@Test
public void scoreIs101() {
Assert.assertEquals('X', grade.letterGrade(101));
}
@Test
public void scoreIs95() {
Assert.assertEquals('A', grade.letterGrade(95));
}
@Test
public void scoreIs85() {
Assert.assertEquals('B', grade.letterGrade(85));
}
@Test
public void scoreIs75() {
Assert.assertEquals('C', grade.letterGrade(75));
}
@Test
public void scoreIs65() {
Assert.assertEquals('D', grade.letterGrade(65));
}
@Test
public void scoreIs55() {
Assert.assertEquals('F', grade.letterGrade(55));
}
@Test
public void scoreIsMinus5() {
Assert.assertEquals('X', grade.letterGrade(-5));
}
}
| UTF-8 | Java | 848 | java | letterGradeByPartitioningTest.java | Java | []
| null | []
| package Partitioning;
import junit.framework.Assert;
import org.junit.Test;
import GradeRange.Grade;
import GradeRange.LetterGrade;
public class letterGradeByPartitioningTest {
LetterGrade grade = new LetterGrade();
@Test
public void scoreIs101() {
Assert.assertEquals('X', grade.letterGrade(101));
}
@Test
public void scoreIs95() {
Assert.assertEquals('A', grade.letterGrade(95));
}
@Test
public void scoreIs85() {
Assert.assertEquals('B', grade.letterGrade(85));
}
@Test
public void scoreIs75() {
Assert.assertEquals('C', grade.letterGrade(75));
}
@Test
public void scoreIs65() {
Assert.assertEquals('D', grade.letterGrade(65));
}
@Test
public void scoreIs55() {
Assert.assertEquals('F', grade.letterGrade(55));
}
@Test
public void scoreIsMinus5() {
Assert.assertEquals('X', grade.letterGrade(-5));
}
}
| 848 | 0.714623 | 0.681604 | 40 | 20.200001 | 18.327848 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.425 | false | false | 2 |
32def07dbbb855b1aac72b90fa17c40f45deb703 | 21,345,987,481,299 | cc144daae4189a1c3b31f8a01d2d2865e88b5f3c | /lib/src/main/java/org/exoplatform/ldap/model/LdapConfigBean.java | 116929d1b4898de7646e4a41d4d7cd184e42d8a9 | []
| no_license | ngammoudi/ldap-configuration | https://github.com/ngammoudi/ldap-configuration | e8c8c72f2a444c0c6268ab84e32359060bf498c8 | 2c678237f2214088aaea826a33e008dfa2c2f681 | refs/heads/master | 2021-04-09T16:52:17.728000 | 2015-03-26T14:06:03 | 2015-03-26T14:06:03 | 32,526,830 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.exoplatform.ldap.model;
/**
* Created by nagui on 28/01/15.
*/
public class LdapConfigBean {
private String ldapType;
private String ldapUrl;
private String ldapAdminDN;
private String ldapAuthentication;
private String ldapUBaseDN;
private String ldapGBaseDN;
private String usersId;
private String usersFilter;
private String usersMapping;
private String usersClasses;
private String usersSearchScope;
private String groupsId;
private String groupsFilter;
private String groupsMapping;
private String groupsClasses;
private String connPool;
private String connPoolMax;
private String connPoolTimeout;
private String connPoolProtocol;
private String ldapReadOnly;
private String ldapInsensitive;
private String searchLimit;
private String groupsSearchScope;
private String ldapFileConfig;
public LdapConfigBean() {
}
public LdapConfigBean(String ldapType, String ldapUrl, String ldapAdminDN, String ldapAuthentication, String ldapUBaseDN, String ldapGBaseDN, String usersId, String usersFilter, String usersMapping, String usersClasses, String usersSearchScope, String groupsId, String groupsFilter, String groupsMapping, String groupsClasses, String connPool, String connPoolMax, String connPoolTimeout, String connPoolProtocol, String ldapReadOnly, String ldapInsensitive, String searchLimit, String groupsSearchScope) {
this.ldapType = ldapType;
this.ldapUrl = ldapUrl;
this.ldapAdminDN = ldapAdminDN;
this.ldapAuthentication = ldapAuthentication;
this.ldapUBaseDN = ldapUBaseDN;
this.ldapGBaseDN = ldapGBaseDN;
this.usersId = usersId;
this.usersFilter = usersFilter;
this.usersMapping = usersMapping;
this.usersClasses = usersClasses;
this.usersSearchScope = usersSearchScope;
this.groupsId = groupsId;
this.groupsFilter = groupsFilter;
this.groupsMapping = groupsMapping;
this.groupsClasses = groupsClasses;
this.connPool = connPool;
this.connPoolMax = connPoolMax;
this.connPoolTimeout = connPoolTimeout;
this.connPoolProtocol = connPoolProtocol;
this.ldapReadOnly = ldapReadOnly;
this.ldapInsensitive = ldapInsensitive;
this.searchLimit = searchLimit;
this.groupsSearchScope = groupsSearchScope;
}
public String getLdapType() {
return ldapType;
}
public String getLdapUrl() {
return ldapUrl;
}
public String getLdapAdminDN() {
return ldapAdminDN;
}
public String getLdapAuthentication() {
return ldapAuthentication;
}
public String getLdapUBaseDN() {
return ldapUBaseDN;
}
public String getLdapGBaseDN() {
return ldapGBaseDN;
}
public String getUsersId() {
return usersId;
}
public String getUsersFilter() {
return usersFilter;
}
public String getUsersMapping() {
return usersMapping;
}
public String getUsersClasses() {
return usersClasses;
}
public String getUsersSearchScope() {
return usersSearchScope;
}
public String getGroupsId() {
return groupsId;
}
public String getGroupsFilter() {
return groupsFilter;
}
public String getGroupsMapping() {
return groupsMapping;
}
public String getGroupsClasses() {
return groupsClasses;
}
public String getConnPool() {
return connPool;
}
public String getConnPoolMax() {
return connPoolMax;
}
public String getConnPoolTimeout() {
return connPoolTimeout;
}
public String getConnPoolProtocol() {
return connPoolProtocol;
}
public String getLdapReadOnly() {
return ldapReadOnly;
}
public String getLdapInsensitive() {
return ldapInsensitive;
}
public String getSearchLimit() {
return searchLimit;
}
public String getGroupsSearchScope() {
return groupsSearchScope;
}
public String getLdapFileConfig() {
return ldapFileConfig;
}
}
| UTF-8 | Java | 4,200 | java | LdapConfigBean.java | Java | [
{
"context": "age org.exoplatform.ldap.model;\n\n/**\n * Created by nagui on 28/01/15.\n */\npublic class LdapConfigBean {\n ",
"end": 60,
"score": 0.9994981288909912,
"start": 55,
"tag": "USERNAME",
"value": "nagui"
}
]
| null | []
| package org.exoplatform.ldap.model;
/**
* Created by nagui on 28/01/15.
*/
public class LdapConfigBean {
private String ldapType;
private String ldapUrl;
private String ldapAdminDN;
private String ldapAuthentication;
private String ldapUBaseDN;
private String ldapGBaseDN;
private String usersId;
private String usersFilter;
private String usersMapping;
private String usersClasses;
private String usersSearchScope;
private String groupsId;
private String groupsFilter;
private String groupsMapping;
private String groupsClasses;
private String connPool;
private String connPoolMax;
private String connPoolTimeout;
private String connPoolProtocol;
private String ldapReadOnly;
private String ldapInsensitive;
private String searchLimit;
private String groupsSearchScope;
private String ldapFileConfig;
public LdapConfigBean() {
}
public LdapConfigBean(String ldapType, String ldapUrl, String ldapAdminDN, String ldapAuthentication, String ldapUBaseDN, String ldapGBaseDN, String usersId, String usersFilter, String usersMapping, String usersClasses, String usersSearchScope, String groupsId, String groupsFilter, String groupsMapping, String groupsClasses, String connPool, String connPoolMax, String connPoolTimeout, String connPoolProtocol, String ldapReadOnly, String ldapInsensitive, String searchLimit, String groupsSearchScope) {
this.ldapType = ldapType;
this.ldapUrl = ldapUrl;
this.ldapAdminDN = ldapAdminDN;
this.ldapAuthentication = ldapAuthentication;
this.ldapUBaseDN = ldapUBaseDN;
this.ldapGBaseDN = ldapGBaseDN;
this.usersId = usersId;
this.usersFilter = usersFilter;
this.usersMapping = usersMapping;
this.usersClasses = usersClasses;
this.usersSearchScope = usersSearchScope;
this.groupsId = groupsId;
this.groupsFilter = groupsFilter;
this.groupsMapping = groupsMapping;
this.groupsClasses = groupsClasses;
this.connPool = connPool;
this.connPoolMax = connPoolMax;
this.connPoolTimeout = connPoolTimeout;
this.connPoolProtocol = connPoolProtocol;
this.ldapReadOnly = ldapReadOnly;
this.ldapInsensitive = ldapInsensitive;
this.searchLimit = searchLimit;
this.groupsSearchScope = groupsSearchScope;
}
public String getLdapType() {
return ldapType;
}
public String getLdapUrl() {
return ldapUrl;
}
public String getLdapAdminDN() {
return ldapAdminDN;
}
public String getLdapAuthentication() {
return ldapAuthentication;
}
public String getLdapUBaseDN() {
return ldapUBaseDN;
}
public String getLdapGBaseDN() {
return ldapGBaseDN;
}
public String getUsersId() {
return usersId;
}
public String getUsersFilter() {
return usersFilter;
}
public String getUsersMapping() {
return usersMapping;
}
public String getUsersClasses() {
return usersClasses;
}
public String getUsersSearchScope() {
return usersSearchScope;
}
public String getGroupsId() {
return groupsId;
}
public String getGroupsFilter() {
return groupsFilter;
}
public String getGroupsMapping() {
return groupsMapping;
}
public String getGroupsClasses() {
return groupsClasses;
}
public String getConnPool() {
return connPool;
}
public String getConnPoolMax() {
return connPoolMax;
}
public String getConnPoolTimeout() {
return connPoolTimeout;
}
public String getConnPoolProtocol() {
return connPoolProtocol;
}
public String getLdapReadOnly() {
return ldapReadOnly;
}
public String getLdapInsensitive() {
return ldapInsensitive;
}
public String getSearchLimit() {
return searchLimit;
}
public String getGroupsSearchScope() {
return groupsSearchScope;
}
public String getLdapFileConfig() {
return ldapFileConfig;
}
}
| 4,200 | 0.679762 | 0.678333 | 157 | 25.751593 | 41.931042 | 509 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.598726 | false | false | 2 |
dd09554fd14a759663a330b21d20a4841ba21b09 | 1,812,476,235,943 | c99517c1f3bb38f8a8474224779bf985ffcba622 | /Java/HDFS_Integration/src/main/java/storage/StorageObject.java | 364b8eaee2e2f8250346625bb61fb1c09d73235b | []
| no_license | eubr-bigsea/compss-hdfs | https://github.com/eubr-bigsea/compss-hdfs | 9a6ffc1bad80a547f9f5204242c7755b9bf2c8d4 | b1c649a8429458372afd7a5712dcadfa125055e2 | refs/heads/master | 2020-05-21T13:37:33.016000 | 2018-06-14T02:26:28 | 2018-06-14T02:26:28 | 61,330,218 | 0 | 0 | null | false | 2017-06-14T18:01:21 | 2016-06-16T22:38:45 | 2017-02-23T11:05:14 | 2017-06-14T18:01:21 | 59,947 | 0 | 0 | 0 | Java | null | null | package storage;
/**
* Abstract implementation of an Storage Object
*
*/
public class StorageObject implements StubItf {
/**
* Constructor
*
*/
public StorageObject() {
}
/**
* Constructor by alias
*
* @param alias
*/
public StorageObject(String alias) {
}
/**
* Returns the persistent object ID
*
* @return
*/
public String getID() {
throw new UnsupportedOperationException();
}
/**
* Persist the object
*
* @param id
*/
public void makePersistent(String id) {
throw new UnsupportedOperationException();
}
/**
* Deletes the persistent object occurrences
*/
public void deletePersistent() {
throw new UnsupportedOperationException();
}
}
| UTF-8 | Java | 823 | java | StorageObject.java | Java | []
| null | []
| package storage;
/**
* Abstract implementation of an Storage Object
*
*/
public class StorageObject implements StubItf {
/**
* Constructor
*
*/
public StorageObject() {
}
/**
* Constructor by alias
*
* @param alias
*/
public StorageObject(String alias) {
}
/**
* Returns the persistent object ID
*
* @return
*/
public String getID() {
throw new UnsupportedOperationException();
}
/**
* Persist the object
*
* @param id
*/
public void makePersistent(String id) {
throw new UnsupportedOperationException();
}
/**
* Deletes the persistent object occurrences
*/
public void deletePersistent() {
throw new UnsupportedOperationException();
}
}
| 823 | 0.561361 | 0.561361 | 51 | 15.137255 | 16.506706 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.078431 | false | false | 2 |
534729c41382e69e4654a6ca3302d123e4c566c5 | 6,717,328,876,999 | e7502cf2efa1ee973579c084916340bcd49e94f9 | /src/main/java/javafxdemo/Main.java | b5dc153e535a3325d3c93d81083f1bf09e66159e | []
| no_license | HristoRaykov/javafx-demo | https://github.com/HristoRaykov/javafx-demo | dfed005f4dcb3a253d7cbdea39d8e9adb5f69ad3 | 8ac7e2d0a246770c8cb14cbdf3736c8ab162c70b | refs/heads/master | 2022-08-27T12:42:26.136000 | 2020-05-26T17:22:52 | 2020-05-26T17:22:52 | 263,705,543 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package javafxdemo;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.*;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("auction_gaps.fxml"));
Parent root = loader.load();
Controller controller = loader.getController();
controller.setStage(stage);
Scene scene = new Scene(root, 300, 275);
stage.setTitle("Auction Gaps");
stage.setScene(scene);
// stage.sizeToScene();
stage.setWidth(820);
stage.setHeight(750);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
| UTF-8 | Java | 922 | java | Main.java | Java | []
| null | []
| package javafxdemo;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.*;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("auction_gaps.fxml"));
Parent root = loader.load();
Controller controller = loader.getController();
controller.setStage(stage);
Scene scene = new Scene(root, 300, 275);
stage.setTitle("Auction Gaps");
stage.setScene(scene);
// stage.sizeToScene();
stage.setWidth(820);
stage.setHeight(750);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
| 922 | 0.671367 | 0.658351 | 40 | 22.049999 | 20.208847 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.575 | false | false | 2 |
adf7cf76b6cb7ded97b4058ba65c931b8e895e21 | 9,337,258,913,716 | c18c3f3bdc51f048f662344d032f9388dfecbd9d | /ddf-parent/ddf-common-entity/src/main/java/com/ddf/entity/rent/eo/RentDemandApartmentType.java | 31463a5b5bbf43164784f40769a320dc2af4ad4f | []
| no_license | soldiers1989/my_dev | https://github.com/soldiers1989/my_dev | 88d62e4f182ac68db26be3d5d3ddc8a68e36c852 | 4250267f6d6d1660178518e71b1f588b4f3926f7 | refs/heads/master | 2020-03-27T19:39:28.191000 | 2018-02-12T02:29:51 | 2018-02-12T02:29:51 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ddf.entity.rent.eo;
public enum RentDemandApartmentType {
/**
* 枚举类型,整租whole_rent,合租share_rent
*/
whole_rent("整租"),
share_rent("合租");
private String explain;
private RentDemandApartmentType(String explain) {
this.explain = explain;
}
public String getExplain() {
return explain;
}
public void setExplain(String explain) {
this.explain = explain;
}
}
| UTF-8 | Java | 419 | java | RentDemandApartmentType.java | Java | []
| null | []
| package com.ddf.entity.rent.eo;
public enum RentDemandApartmentType {
/**
* 枚举类型,整租whole_rent,合租share_rent
*/
whole_rent("整租"),
share_rent("合租");
private String explain;
private RentDemandApartmentType(String explain) {
this.explain = explain;
}
public String getExplain() {
return explain;
}
public void setExplain(String explain) {
this.explain = explain;
}
}
| 419 | 0.69821 | 0.69821 | 24 | 15.291667 | 15.420439 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.166667 | false | false | 2 |
ae2df72e0ac5a1f51862fa2e3b4e6e27a09c56e3 | 9,337,258,913,721 | 9074bc8bfd30cf3aa21d69d63406273cdda65bef | /module-business-audio/src/main/java/com/longrise/android/moduleaudio/params/BaseParams.java | 0dc32448a1d9312980bbbb2984d8e47fa8db040b | []
| no_license | godliness-keep/AndroidModuleAudio | https://github.com/godliness-keep/AndroidModuleAudio | 298bdc6496f3d4ae96323a71288ecc5b23c397f9 | 524c399ffaa93134fe3ad406b8b90db77602c943 | refs/heads/master | 2021-04-16T09:48:19.116000 | 2021-01-21T08:06:02 | 2021-01-21T08:06:02 | 249,347,252 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.longrise.android.moduleaudio.params;
/**
* Created by godliness on 2020-03-20.
*
* @author godliness
*/
public abstract class BaseParams {
protected BaseParams(){
}
}
| UTF-8 | Java | 194 | java | BaseParams.java | Java | [
{
"context": "ise.android.moduleaudio.params;\n\n/**\n * Created by godliness on 2020-03-20.\n *\n * @author godliness\n */\npublic",
"end": 77,
"score": 0.9995946884155273,
"start": 68,
"tag": "USERNAME",
"value": "godliness"
},
{
"context": " Created by godliness on 2020-03-20.\n *\n * @author godliness\n */\npublic abstract class BaseParams {\n\n prote",
"end": 116,
"score": 0.9995875358581543,
"start": 107,
"tag": "USERNAME",
"value": "godliness"
}
]
| null | []
| package com.longrise.android.moduleaudio.params;
/**
* Created by godliness on 2020-03-20.
*
* @author godliness
*/
public abstract class BaseParams {
protected BaseParams(){
}
}
| 194 | 0.685567 | 0.64433 | 13 | 13.923077 | 16.550444 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.076923 | false | false | 2 |
58b49f4c0e53be30476077b5547e7e3f205a33c1 | 18,313,740,562,818 | 075b7337f426c4905dc5bfc3f22e9ef09ac08ed5 | /Objetos/2018-1C/2018-1C POO - Patrones de diseño 02 - Material extra/example_facade.java | 961574f1aac42370583d4de1e307e0cbfb035bbe | []
| no_license | 7510-tecnicas-de-disenio/material-clases | https://github.com/7510-tecnicas-de-disenio/material-clases | dbb5ca65453e4f0dfed1a20c4fea63ae8a5e08f0 | 75a4d84e04dfc9ba1f9f2ce5401c4b54d80b50fa | refs/heads/master | 2022-11-25T08:23:48.944000 | 2022-11-04T00:11:50 | 2022-11-04T00:11:50 | 53,327,171 | 5 | 30 | null | null | null | null | null | null | null | null | null | null | null | null | null | // Some clases modeling travel packages...
public interface Bookable { void book(); }
public class Hotel { public void book() { ... } }
public class Flight { public void book() { ... } }
public class Car { public void book() { ... } }
public class HotelBooker {
public ArrayList<Hotel> getHotelNamesFor(Date from, Date to) {
//returns hotels available in the particular date range
}
}
public class FlightBooker {
public ArrayList<Flight> getFlightsFor(Date from, Date to) {
//returns flights available in the particular date range
}
}
public class CarBooker {
public ArrayList<Car> getCarsFor(Date from, Date to) {
//returns flights available in the particular date range
}
}
public class PackageBooker {
private HotelBooker hotelBooker;
private FlightBooker flightBooker;
private CarBooker carBooker;
public List<Bookable> getFlightsAndHotels(Date from, Data to) {
ArrayList<Flight> flights = flightBooker.getFlightsFor(from, to);
ArrayList<Hotel> hotels = hotelBooker.getHotelsFor(from, to);
ArrayList<Car> cars = carBooker.getCarsFor(from, to);
//process and return
}
}
| UTF-8 | Java | 1,115 | java | example_facade.java | Java | []
| null | []
| // Some clases modeling travel packages...
public interface Bookable { void book(); }
public class Hotel { public void book() { ... } }
public class Flight { public void book() { ... } }
public class Car { public void book() { ... } }
public class HotelBooker {
public ArrayList<Hotel> getHotelNamesFor(Date from, Date to) {
//returns hotels available in the particular date range
}
}
public class FlightBooker {
public ArrayList<Flight> getFlightsFor(Date from, Date to) {
//returns flights available in the particular date range
}
}
public class CarBooker {
public ArrayList<Car> getCarsFor(Date from, Date to) {
//returns flights available in the particular date range
}
}
public class PackageBooker {
private HotelBooker hotelBooker;
private FlightBooker flightBooker;
private CarBooker carBooker;
public List<Bookable> getFlightsAndHotels(Date from, Data to) {
ArrayList<Flight> flights = flightBooker.getFlightsFor(from, to);
ArrayList<Hotel> hotels = hotelBooker.getHotelsFor(from, to);
ArrayList<Car> cars = carBooker.getCarsFor(from, to);
//process and return
}
}
| 1,115 | 0.731839 | 0.731839 | 38 | 28.342106 | 24.909601 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.052632 | false | false | 2 |
ec21a4018b6a8976b6b857bd53b07125d10b6242 | 18,313,740,565,648 | 881fcda2770f3bbf6f6ea411cbc94ef67e8da239 | /src/main/java/com/test/collections/ListToArray.java | f51ff07f49b3dcc8306194f9dd304f82a0b515e4 | [
"MIT"
]
| permissive | qiusxn/java-test | https://github.com/qiusxn/java-test | ee0dfadd891feb4adaed3f3183e06dcb52b8efe6 | 37b1d45ff0da761a20b2589adcf01ab298bbaa5a | refs/heads/master | 2023-02-22T20:45:22.594000 | 2019-05-07T00:54:28 | 2019-05-07T00:54:28 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.test.collections;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ListToArray {
public static void main(String[] args) {
List<String> letters = new ArrayList<String>();
letters.add("A");
letters.add("B");
letters.add("C");
String[] strArray = new String[letters.size()];
strArray = letters.toArray(strArray);
System.out.println(Arrays.toString(strArray));
}
}
| UTF-8 | Java | 482 | java | ListToArray.java | Java | []
| null | []
| package com.test.collections;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ListToArray {
public static void main(String[] args) {
List<String> letters = new ArrayList<String>();
letters.add("A");
letters.add("B");
letters.add("C");
String[] strArray = new String[letters.size()];
strArray = letters.toArray(strArray);
System.out.println(Arrays.toString(strArray));
}
}
| 482 | 0.639004 | 0.639004 | 20 | 23.1 | 19.315538 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.55 | false | false | 2 |
5e66f24ea390535c09b04d13fc0eda038e51a7ee | 7,404,523,652,103 | 5988f3a838a1f63576fafe09f89cb8e5db33490f | /app/src/main/java/com/example/gabriel/peluchitos/Notificar.java | 51b6583827a89ce96b3c3038210f867214bf1071 | []
| no_license | luismosi/Peluchitos | https://github.com/luismosi/Peluchitos | 72503e2fe604e52938db34a8e20a49630a4c4327 | fdaf464df352bb0a3fbacf42dde0b2f834f532d9 | refs/heads/master | 2016-09-13T20:21:32.904000 | 2016-05-11T07:18:11 | 2016-05-11T07:18:11 | 58,522,638 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.gabriel.peluchitos;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class Notificar extends AppCompatActivity {
private TextView advertencia;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notificar);
advertencia = (TextView)findViewById(R.id.advertencia);
Bundle extras = getIntent().getExtras();
advertencia.setText("Queda: " + extras.getString("Cantidad") + " Peluches " + "\n" + " De: " + extras.getString("Muñeco"));
}
public void aceptar (View view){
finish();
}
}
| UTF-8 | Java | 749 | java | Notificar.java | Java | [
{
"context": "package com.example.gabriel.peluchitos;\n\nimport android.support.v7.app.AppCom",
"end": 27,
"score": 0.9946497678756714,
"start": 20,
"tag": "USERNAME",
"value": "gabriel"
}
]
| null | []
| package com.example.gabriel.peluchitos;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class Notificar extends AppCompatActivity {
private TextView advertencia;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notificar);
advertencia = (TextView)findViewById(R.id.advertencia);
Bundle extras = getIntent().getExtras();
advertencia.setText("Queda: " + extras.getString("Cantidad") + " Peluches " + "\n" + " De: " + extras.getString("Muñeco"));
}
public void aceptar (View view){
finish();
}
}
| 749 | 0.696524 | 0.695187 | 27 | 26.703703 | 29.375998 | 131 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 2 |
eb651acbaa8e110f1b2851786df9ac015a4ce98e | 21,174,188,778,121 | 36103a2e681a9b8d34272c8110dc954b40fc87e4 | /src/mips_multiciclo/ULA.java | d4426eb7934ab25ec8ba99309b21cd4ee0215eda | []
| no_license | Thiago25879/Mips-AOC-2 | https://github.com/Thiago25879/Mips-AOC-2 | bc0138005be2da598694a34795c628ecec8b744a | 8f58399580af3549ba09bc7fe55835bf04ef250b | refs/heads/master | 2020-05-30T22:30:46.357000 | 2019-06-03T11:59:56 | 2019-06-03T11:59:56 | 189,995,019 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // ULA
package mips_multiciclo;
public class ULA {
public static int Operacao(int Opcode, int funct, int FonteA, int FonteB) {
int tipo;
if (0b100000 == (Opcode & 0b100000)) {
tipo = 0;
} else {
if ((Opcode == 0b000100) || (Opcode == 0b000101)) {
tipo = 1;
} else {
if ((funct == 0b0) || (funct == 0b10) || (funct == 0b1111)) {
tipo = 3;
} else {
tipo = 2;
}
}
}
switch (tipo) {
case 0:
return FonteA + FonteB;
case 1:
return FonteA - FonteB;
case 2:
if (funct == 0b100000 || funct == 0b1000) {
return FonteA + FonteB;
}
if (funct == 0b100010 || funct == 0b1010) {
return FonteA - FonteB;
}
if (funct == 0b100100 || funct == 0b1100) {
return FonteA & FonteB;
}
if (funct == 0b100101 || funct == 0b1101) {
return FonteA | FonteB;
}
if (funct == 0b100111) {
return (~(FonteA | FonteB));
}
case 3://Para Shifts
if (funct == 0) {
return FonteB << FonteA;
}
if (funct == 0b10) {
return FonteB >> FonteA;
}
if (funct == 0b1111) {
return FonteB << 16;
}
}
return 0;
}
}
| UTF-8 | Java | 1,677 | java | ULA.java | Java | []
| null | []
| // ULA
package mips_multiciclo;
public class ULA {
public static int Operacao(int Opcode, int funct, int FonteA, int FonteB) {
int tipo;
if (0b100000 == (Opcode & 0b100000)) {
tipo = 0;
} else {
if ((Opcode == 0b000100) || (Opcode == 0b000101)) {
tipo = 1;
} else {
if ((funct == 0b0) || (funct == 0b10) || (funct == 0b1111)) {
tipo = 3;
} else {
tipo = 2;
}
}
}
switch (tipo) {
case 0:
return FonteA + FonteB;
case 1:
return FonteA - FonteB;
case 2:
if (funct == 0b100000 || funct == 0b1000) {
return FonteA + FonteB;
}
if (funct == 0b100010 || funct == 0b1010) {
return FonteA - FonteB;
}
if (funct == 0b100100 || funct == 0b1100) {
return FonteA & FonteB;
}
if (funct == 0b100101 || funct == 0b1101) {
return FonteA | FonteB;
}
if (funct == 0b100111) {
return (~(FonteA | FonteB));
}
case 3://Para Shifts
if (funct == 0) {
return FonteB << FonteA;
}
if (funct == 0b10) {
return FonteB >> FonteA;
}
if (funct == 0b1111) {
return FonteB << 16;
}
}
return 0;
}
}
| 1,677 | 0.353608 | 0.286225 | 55 | 29.49091 | 18.623419 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.654545 | false | false | 2 |
c43e01b1541d52fb0edd3ae4b56d3d3f75635330 | 7,301,444,428,627 | 3c58674c3f78aa538a74e3d96458786e3d539251 | /baohuquan-core/src/main/java/com/baohuquan/model/MonthTemps.java | 80979c310f5983220208946470f086679bac53e9 | []
| no_license | BarneyWang/baohuquan | https://github.com/BarneyWang/baohuquan | 03ba17682c72389b3be8ad8ac58a2303ac29a06f | 8df07b6faf3aa7093a8ad76d6cea76123c42d2dc | refs/heads/master | 2021-01-17T07:10:21.288000 | 2016-07-17T07:15:08 | 2016-07-17T07:15:08 | 55,135,207 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.baohuquan.model;
import java.io.Serializable;
import java.util.Date;
/**
* Created by wangdi5 on 2016/6/19.
*/
public class MonthTemps implements Serializable {
private static final long serialVersionUID = 4403675311016156813L;
private int id;
private int babyId;
private int year;
private int month;
private String monthTemps;
private Date createTime;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getBabyId() {
return babyId;
}
public void setBabyId(int babyId) {
this.babyId = babyId;
}
public String getMonthTemps() {
return monthTemps;
}
public void setMonthTemps(String monthTemps) {
this.monthTemps = monthTemps;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
}
| UTF-8 | Java | 1,232 | java | MonthTemps.java | Java | [
{
"context": "lizable;\nimport java.util.Date;\n\n/**\n * Created by wangdi5 on 2016/6/19.\n */\npublic class MonthTemps impleme",
"end": 108,
"score": 0.9996363520622253,
"start": 101,
"tag": "USERNAME",
"value": "wangdi5"
}
]
| null | []
| package com.baohuquan.model;
import java.io.Serializable;
import java.util.Date;
/**
* Created by wangdi5 on 2016/6/19.
*/
public class MonthTemps implements Serializable {
private static final long serialVersionUID = 4403675311016156813L;
private int id;
private int babyId;
private int year;
private int month;
private String monthTemps;
private Date createTime;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getBabyId() {
return babyId;
}
public void setBabyId(int babyId) {
this.babyId = babyId;
}
public String getMonthTemps() {
return monthTemps;
}
public void setMonthTemps(String monthTemps) {
this.monthTemps = monthTemps;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
}
| 1,232 | 0.609578 | 0.587662 | 68 | 17.117647 | 16.181442 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.323529 | false | false | 2 |
5729f60244e03bcddeff54f350fb06bd9d09a01f | 19,980,187,905,344 | d4deace20e859643cb2820e06fefb4a68de79826 | /app/src/main/java/com/example/visit/explore/ExploreFragment.java | 7645a61dd8d23c0ad949ded6b71913a9cd3a1c91 | []
| no_license | ivancrg/vis.it | https://github.com/ivancrg/vis.it | 08d87e21ed67254f52e09087980134a8b20ef66b | 95640eb1828add45519b4085673d2e84cafed0df | refs/heads/main | 2023-05-12T23:08:01.456000 | 2021-06-06T22:41:19 | 2021-06-06T22:41:19 | 350,456,926 | 3 | 1 | null | false | 2021-06-06T22:16:25 | 2021-03-22T18:58:47 | 2021-06-06T21:36:19 | 2021-06-06T22:16:25 | 19,651 | 2 | 0 | 6 | Java | false | false | package com.example.visit.explore;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.bumptech.glide.Glide;
import com.example.visit.R;
import com.example.visit.recyclerView.CountryRecyclerViewAdapter;
import com.example.visit.recyclerView.CountryRecyclerViewItem;
import com.example.visit.recyclerView.HorizontalRecyclerViewAdapter;
import com.example.visit.recyclerView.HorizontalRecyclerViewItem;
import com.example.visit.recyclerView.RecyclerViewClickInterface;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Random;
import java.util.Vector;
import java.util.concurrent.ThreadLocalRandom;
public class ExploreFragment extends Fragment implements RecyclerViewClickInterface {
private RecyclerView cityView;
private RecyclerView summerView;
private RecyclerView winterView;
private RecyclerView countryView;
private static final int NUM_OF_RECYCLER_ITEMS = 5;
// Adapter is a sort of a bridge between our data (verticalItems) and the RV
// Adapter always provides as many items as we need at the time which means optimal performance
private RecyclerView.Adapter cityAdapter;
private RecyclerView.Adapter summerAdapter;
private RecyclerView.Adapter winterAdapter;
private RecyclerView.Adapter countryAdapter;
// Responsible for placing items into our list
private RecyclerView.LayoutManager cityLayoutManager;
private RecyclerView.LayoutManager summerLayoutManager;
private RecyclerView.LayoutManager winterLayoutManager;
private RecyclerView.LayoutManager countryLayoutManager;
View travelTipsArticle;
ImageButton articleButtonTop;
TextView articleTitleTop;
TextView articleSubtitleTop;
View genericArticle;
ImageButton articleButtonBottom;
TextView articleTitleBottom;
TextView articleSubtitleBottom;
View countryElement;
TextView countryCategoryTitle;
TextView countryCategoryText;
View cityElement;
TextView cityCategoryTitle;
TextView cityCategoryText;
View summerElement;
TextView summerCategoryTitle;
TextView summerCategorySubtitle;
View winterElement;
TextView winterCategoryTitle;
TextView winterCategorySubtitle;
// Recycler View items lists
ArrayList<ArticleModel> articleList;
ArrayList<CountryModel> countryList;
ArrayList<CityModel> cityList;
ArrayList<SummerAndWinterModel> summerList;
ArrayList<SummerAndWinterModel> winterList;
ArrayList<CountryRecyclerViewItem> countriesList;
ArrayList<HorizontalRecyclerViewItem> citiesList;
ArrayList<HorizontalRecyclerViewItem> summerItemList;
ArrayList<HorizontalRecyclerViewItem> winterItemList;
public ExploreFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
articleList = new ArrayList<>();
countryList = new ArrayList<>();
cityList = new ArrayList<>();
countriesList = new ArrayList<>();
citiesList = new ArrayList<>();
winterList = new ArrayList<>();
summerList = new ArrayList<>();
summerItemList = new ArrayList<>();
winterItemList = new ArrayList<>();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_explore, container, false);
setArticles();
setCountries();
setCities();
setSummerAndWinter();
// Vertical is used to represent horizontal recycler view items
cityElement = view.findViewById(R.id.explore_cities_item);
cityCategoryTitle = cityElement.findViewById(R.id.verticalRecyclerViewItemTitle);
cityCategoryText = cityElement.findViewById(R.id.verticalRecyclerViewItemText);
cityCategoryTitle.setText(R.string.cityCategoryTitle);
cityCategoryText.setText(R.string.cityCategorySubtitle);
countryElement = view.findViewById(R.id.explore_countries_item);
countryCategoryTitle = countryElement.findViewById(R.id.verticalRecyclerViewItemTitle);
countryCategoryText = countryElement.findViewById(R.id.verticalRecyclerViewItemText);
countryCategoryTitle.setText(R.string.countryCategoryTitle);
countryCategoryText.setText(R.string.countryCategorySubtitle);
summerElement = view.findViewById(R.id.explore_summer_item);
summerCategoryTitle = summerElement.findViewById(R.id.verticalRecyclerViewItemTitle);
summerCategorySubtitle = summerElement.findViewById(R.id.verticalRecyclerViewItemText);
summerCategoryTitle.setText(R.string.summerCategoryTitle);
summerCategorySubtitle.setText(R.string.summerCategorySubtitle);
winterElement = view.findViewById(R.id.explore_winter_item);
winterCategoryTitle = winterElement.findViewById(R.id.verticalRecyclerViewItemTitle);
winterCategorySubtitle = winterElement.findViewById(R.id.verticalRecyclerViewItemText);
winterCategoryTitle.setText(R.string.winterCategoryTitle);
winterCategorySubtitle.setText(R.string.winterCategorySubtitle);
cityView = cityElement.findViewById(R.id.horizontalRecyclerView);
countryView = countryElement.findViewById(R.id.horizontalRecyclerView);
summerView = summerElement.findViewById(R.id.horizontalRecyclerView);
winterView = winterElement.findViewById(R.id.horizontalRecyclerView);
// Needs to be set to true if recycler view won't change in size for performance gains
cityView.setHasFixedSize(true);
countryView.setHasFixedSize(true);
summerView.setHasFixedSize(true);
winterView.setHasFixedSize(true);
cityLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
cityAdapter = new HorizontalRecyclerViewAdapter(citiesList, getContext());
cityView.setLayoutManager(cityLayoutManager);
cityView.setAdapter(cityAdapter);
countryLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
countryAdapter = new CountryRecyclerViewAdapter(countriesList, getContext(), this);
countryView.setLayoutManager(countryLayoutManager);
countryView.setAdapter(countryAdapter);
summerLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
summerAdapter = new HorizontalRecyclerViewAdapter(summerItemList, getContext());
summerView.setLayoutManager(summerLayoutManager);
summerView.setAdapter(summerAdapter);
winterLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
winterAdapter = new HorizontalRecyclerViewAdapter(winterItemList, getContext());
winterView.setLayoutManager(winterLayoutManager);
winterView.setAdapter(winterAdapter);
//Filling the articles with data
travelTipsArticle = view.findViewById(R.id.travel_tips_article);
articleButtonTop = travelTipsArticle.findViewById(R.id.article_background_button);
articleTitleTop = travelTipsArticle.findViewById(R.id.article_title);
articleSubtitleTop = travelTipsArticle.findViewById(R.id.article_subtitle);
genericArticle = view.findViewById(R.id.generic_travel_article);
articleButtonBottom = genericArticle.findViewById(R.id.article_background_button);
articleTitleBottom = genericArticle.findViewById(R.id.article_title);
articleSubtitleBottom = genericArticle.findViewById(R.id.article_subtitle);
return view;
}
// OnClick method for articles
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
articleButtonTop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!articleList.isEmpty()) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(articleList.get(0).getArticleUrl()));
startActivity(browserIntent);
Log.d("BUTTON", "ARTICLE 1 CLICKED");
}
}
});
articleButtonBottom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!articleList.isEmpty()) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(articleList.get(1).getArticleUrl()));
startActivity(browserIntent);
Log.d("BUTTON", "ARTICLE 2 CLICKED");
}
}
});
}
// Filling the countries recycle viewer
private void setCountries() {
// Php file which returns the country data
final String URL_COUNTRIES = "https://visitcountryapi.000webhostapp.com/exploreCountries.php";
// Sending the data request
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_COUNTRIES, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
// Converting the string to json array object
JSONArray array = new JSONArray(response);
Log.d("RESPONSE", "Response COUNTRY success " + response);
// Randomly picking countries to display
Vector<Integer> countryIndexVector = new Vector<Integer>();
countryIndexVector = randomNumGen(0, array.length(), NUM_OF_RECYCLER_ITEMS);
Log.d("COUNTRY", "Country index" + countryIndexVector);
// Creating objects for the country data
for (int i = 0; i < array.length(); i++) {
JSONObject countryObject = array.getJSONObject(i);
countryList.add(new CountryModel(countryObject.getInt("country_id"),
countryObject.getString("country_name"),
countryObject.getString("country_code"),
countryObject.getString("country_flag").replace("\\", ""),
countryObject.getString("country_currency"),
countryObject.getInt("country_pop"),
countryObject.getString("country_image").replace("\\", ""),
countryObject.getDouble("bigmac_index"),
countryObject.getString("country_desc"),
countryObject.getString("country_hemisphere"),
countryObject.getString("language_top"),
countryObject.getString("capital_city"),
countryObject.getString("country_timezone"),
countryObject.getString("call_code"),
"https://visitcountryapi.000webhostapp.com/Geolocation/" + countryObject.getInt("country_id") + ".png"));
Log.d("COUNTRY POPULATION", countryObject.getString("country_name") + " POP: " + countryObject.getInt("country_pop"));
}
for (int ind : countryIndexVector) {
countriesList.add(new CountryRecyclerViewItem(countryList.get(ind).getCountry_image(), countryList.get(ind).getCountry_flag(),
countryList.get(ind).getCountry_name(), "", countryList.get(ind).getCountry_id()));
}
Log.d("CHANGED SET", "Notify dataset changed");
countryAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
Volley.newRequestQueue(getContext()).add(stringRequest);
}
// Filling the article CardView
private void setArticles() {
// Php file that returns the data
final String URL_ARTICLES = "https://visitcountryapi.000webhostapp.com/exploreArticles.php";
Log.d("RESPONSE ARTICLES", "Request started");
// Sending the data request
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_ARTICLES, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
//converting the string to json array object
JSONArray array = new JSONArray(response);
Log.d("RESPONSE", "Response ARTICLE success " + response);
// Randomly choosing two articles to display
Vector<Integer> articleIndexVector = new Vector<Integer>();
articleIndexVector = randomNumGen(0, array.length(), 2);
Log.d("RESPONSE", "Article index" + articleIndexVector);
for (int ind : articleIndexVector) {
JSONObject articleObject = array.getJSONObject(ind);
articleList.add(new ArticleModel(ind, articleObject.getString("title"),
articleObject.getString("subtitle"),
articleObject.getString("link"),
articleObject.getString("image_url").replace("\\", ""),
articleObject.getString("type")));
Log.d("TITLE", articleObject.getString("title"));
}
Log.d("RESPONSE ARTICLE", Boolean.toString(articleList.isEmpty()));
fillData();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
Volley.newRequestQueue(getContext()).add(stringRequest);
}
// Filling the article elements with data
private void fillData() {
if (!articleList.isEmpty()) {
articleTitleTop.setText(articleList.get(0).getTitle());
articleSubtitleTop.setText(articleList.get(0).getSubtitle());
Glide.with(getContext()).load(articleList.get(0).getImageUrl()).centerCrop().into(articleButtonTop);
articleTitleBottom.setText(articleList.get(1).getTitle());
articleSubtitleBottom.setText(articleList.get(1).getSubtitle());
Glide.with(getContext()).load(articleList.get(1).getImageUrl()).centerCrop().into(articleButtonBottom);
}
}
private void setCities() {
// Php file that returns the city data
final String URL_CITIES = "https://visitcountryapi.000webhostapp.com/exploreCities.php";
// Sending the data request
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_CITIES, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
//converting the string to json array object
JSONArray array = new JSONArray(response);
Log.d("RESPONSE", "Response CITY success " + response);
// Selecting random cities to display
Vector<Integer> cityIndexVector = new Vector<Integer>();
cityIndexVector = randomNumGen(0, array.length(), NUM_OF_RECYCLER_ITEMS);
Log.d("CITY", "City index" + cityIndexVector);
for (int ind : cityIndexVector) {
JSONObject cityObject = array.getJSONObject(ind);
cityList.add(new CityModel(cityObject.getInt("country_id"),
ind,
cityObject.getString("city_name"),
cityObject.getString("city_image").replace("\\", "")));
}
for (CityModel city : cityList) {
citiesList.add(new HorizontalRecyclerViewItem(city.getCity_image(), city.getCity_name(), ""));
}
Log.d("CHANGED SET", "Notify dataset changed city");
cityAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
Volley.newRequestQueue(getContext()).add(stringRequest);
}
private void setSummerAndWinter() {
// Php file which returns the Summer and Winter places data
final String URL_PLACES = "https://visitcountryapi.000webhostapp.com/exploreSummerWinter.php";
// Sending the data request
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_PLACES, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
//converting the string to json array object
JSONArray array = new JSONArray(response);
Log.d("RESPONSE", "Response SUMMER WINTER success " + response);
// Randomly selecting data to display
Vector<Integer> summerIndexVector = new Vector<Integer>();
Vector<Integer> winterIndexVector = new Vector<>();
int halfLenght = array.length() / 2;
summerIndexVector = randomNumGen(0, halfLenght, NUM_OF_RECYCLER_ITEMS);
winterIndexVector = randomNumGen(halfLenght + 1, array.length(), NUM_OF_RECYCLER_ITEMS);
Log.d("SUMMER", "Summer index" + summerIndexVector);
Log.d("WINTER", "Winter index" + winterIndexVector);
for (int ind : summerIndexVector) {
JSONObject summerObject = array.getJSONObject(ind);
summerList.add(new SummerAndWinterModel(ind,
summerObject.getInt("country_id"),
summerObject.getString("place_name"),
summerObject.getString("geo_thermal_zone"),
summerObject.getString("place_image").replace("\\", ""),
summerObject.getString("intended_temp")));
}
for (int ind : winterIndexVector) {
JSONObject winterObject = array.getJSONObject(ind);
winterList.add(new SummerAndWinterModel(ind,
winterObject.getInt("country_id"),
winterObject.getString("place_name"),
winterObject.getString("geo_thermal_zone"),
winterObject.getString("place_image").replace("\\", ""),
winterObject.getString("intended_temp")));
}
for (SummerAndWinterModel summerObj : summerList) {
summerItemList.add(new HorizontalRecyclerViewItem(summerObj.getPlace_image(), summerObj.getPlace_name(), ""));
}
for (SummerAndWinterModel winterObj : winterList) {
winterItemList.add(new HorizontalRecyclerViewItem(winterObj.getPlace_image(), winterObj.getPlace_name(), ""));
}
Log.d("CHANGED SET", "Notify dataset changed summer and winter");
summerAdapter.notifyDataSetChanged();
winterAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
Volley.newRequestQueue(getContext()).add(stringRequest);
}
// Country RecyclerView OnClick method
@Override
public void onItemClick(int position) {
Fragment countryInfoFrag = new CountryInfoFragment(countryList.get(countriesList.get(position).getId() - 1), countryList);
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, countryInfoFrag).addToBackStack(null);
transaction.commit();
}
@Override
public void onLongItemClick(int position) {
}
// Method generating random indexes, to display data
public Vector<Integer> randomNumGen(int origin, int limit, int numOfItems) {
Vector<Integer> IndexVector = new Vector<Integer>();
Random rand = new Random();
for (int i = 0; i < numOfItems; i++) {
if (IndexVector.isEmpty()) {
IndexVector.add(ThreadLocalRandom.current().nextInt(origin, limit));
} else {
int index = ThreadLocalRandom.current().nextInt(origin, limit);
while (IndexVector.contains(index)) {
index = ThreadLocalRandom.current().nextInt(origin, limit);
}
IndexVector.add(index);
}
}
return IndexVector;
}
} | UTF-8 | Java | 22,867 | java | ExploreFragment.java | Java | []
| null | []
| package com.example.visit.explore;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.bumptech.glide.Glide;
import com.example.visit.R;
import com.example.visit.recyclerView.CountryRecyclerViewAdapter;
import com.example.visit.recyclerView.CountryRecyclerViewItem;
import com.example.visit.recyclerView.HorizontalRecyclerViewAdapter;
import com.example.visit.recyclerView.HorizontalRecyclerViewItem;
import com.example.visit.recyclerView.RecyclerViewClickInterface;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Random;
import java.util.Vector;
import java.util.concurrent.ThreadLocalRandom;
public class ExploreFragment extends Fragment implements RecyclerViewClickInterface {
private RecyclerView cityView;
private RecyclerView summerView;
private RecyclerView winterView;
private RecyclerView countryView;
private static final int NUM_OF_RECYCLER_ITEMS = 5;
// Adapter is a sort of a bridge between our data (verticalItems) and the RV
// Adapter always provides as many items as we need at the time which means optimal performance
private RecyclerView.Adapter cityAdapter;
private RecyclerView.Adapter summerAdapter;
private RecyclerView.Adapter winterAdapter;
private RecyclerView.Adapter countryAdapter;
// Responsible for placing items into our list
private RecyclerView.LayoutManager cityLayoutManager;
private RecyclerView.LayoutManager summerLayoutManager;
private RecyclerView.LayoutManager winterLayoutManager;
private RecyclerView.LayoutManager countryLayoutManager;
View travelTipsArticle;
ImageButton articleButtonTop;
TextView articleTitleTop;
TextView articleSubtitleTop;
View genericArticle;
ImageButton articleButtonBottom;
TextView articleTitleBottom;
TextView articleSubtitleBottom;
View countryElement;
TextView countryCategoryTitle;
TextView countryCategoryText;
View cityElement;
TextView cityCategoryTitle;
TextView cityCategoryText;
View summerElement;
TextView summerCategoryTitle;
TextView summerCategorySubtitle;
View winterElement;
TextView winterCategoryTitle;
TextView winterCategorySubtitle;
// Recycler View items lists
ArrayList<ArticleModel> articleList;
ArrayList<CountryModel> countryList;
ArrayList<CityModel> cityList;
ArrayList<SummerAndWinterModel> summerList;
ArrayList<SummerAndWinterModel> winterList;
ArrayList<CountryRecyclerViewItem> countriesList;
ArrayList<HorizontalRecyclerViewItem> citiesList;
ArrayList<HorizontalRecyclerViewItem> summerItemList;
ArrayList<HorizontalRecyclerViewItem> winterItemList;
public ExploreFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
articleList = new ArrayList<>();
countryList = new ArrayList<>();
cityList = new ArrayList<>();
countriesList = new ArrayList<>();
citiesList = new ArrayList<>();
winterList = new ArrayList<>();
summerList = new ArrayList<>();
summerItemList = new ArrayList<>();
winterItemList = new ArrayList<>();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_explore, container, false);
setArticles();
setCountries();
setCities();
setSummerAndWinter();
// Vertical is used to represent horizontal recycler view items
cityElement = view.findViewById(R.id.explore_cities_item);
cityCategoryTitle = cityElement.findViewById(R.id.verticalRecyclerViewItemTitle);
cityCategoryText = cityElement.findViewById(R.id.verticalRecyclerViewItemText);
cityCategoryTitle.setText(R.string.cityCategoryTitle);
cityCategoryText.setText(R.string.cityCategorySubtitle);
countryElement = view.findViewById(R.id.explore_countries_item);
countryCategoryTitle = countryElement.findViewById(R.id.verticalRecyclerViewItemTitle);
countryCategoryText = countryElement.findViewById(R.id.verticalRecyclerViewItemText);
countryCategoryTitle.setText(R.string.countryCategoryTitle);
countryCategoryText.setText(R.string.countryCategorySubtitle);
summerElement = view.findViewById(R.id.explore_summer_item);
summerCategoryTitle = summerElement.findViewById(R.id.verticalRecyclerViewItemTitle);
summerCategorySubtitle = summerElement.findViewById(R.id.verticalRecyclerViewItemText);
summerCategoryTitle.setText(R.string.summerCategoryTitle);
summerCategorySubtitle.setText(R.string.summerCategorySubtitle);
winterElement = view.findViewById(R.id.explore_winter_item);
winterCategoryTitle = winterElement.findViewById(R.id.verticalRecyclerViewItemTitle);
winterCategorySubtitle = winterElement.findViewById(R.id.verticalRecyclerViewItemText);
winterCategoryTitle.setText(R.string.winterCategoryTitle);
winterCategorySubtitle.setText(R.string.winterCategorySubtitle);
cityView = cityElement.findViewById(R.id.horizontalRecyclerView);
countryView = countryElement.findViewById(R.id.horizontalRecyclerView);
summerView = summerElement.findViewById(R.id.horizontalRecyclerView);
winterView = winterElement.findViewById(R.id.horizontalRecyclerView);
// Needs to be set to true if recycler view won't change in size for performance gains
cityView.setHasFixedSize(true);
countryView.setHasFixedSize(true);
summerView.setHasFixedSize(true);
winterView.setHasFixedSize(true);
cityLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
cityAdapter = new HorizontalRecyclerViewAdapter(citiesList, getContext());
cityView.setLayoutManager(cityLayoutManager);
cityView.setAdapter(cityAdapter);
countryLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
countryAdapter = new CountryRecyclerViewAdapter(countriesList, getContext(), this);
countryView.setLayoutManager(countryLayoutManager);
countryView.setAdapter(countryAdapter);
summerLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
summerAdapter = new HorizontalRecyclerViewAdapter(summerItemList, getContext());
summerView.setLayoutManager(summerLayoutManager);
summerView.setAdapter(summerAdapter);
winterLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
winterAdapter = new HorizontalRecyclerViewAdapter(winterItemList, getContext());
winterView.setLayoutManager(winterLayoutManager);
winterView.setAdapter(winterAdapter);
//Filling the articles with data
travelTipsArticle = view.findViewById(R.id.travel_tips_article);
articleButtonTop = travelTipsArticle.findViewById(R.id.article_background_button);
articleTitleTop = travelTipsArticle.findViewById(R.id.article_title);
articleSubtitleTop = travelTipsArticle.findViewById(R.id.article_subtitle);
genericArticle = view.findViewById(R.id.generic_travel_article);
articleButtonBottom = genericArticle.findViewById(R.id.article_background_button);
articleTitleBottom = genericArticle.findViewById(R.id.article_title);
articleSubtitleBottom = genericArticle.findViewById(R.id.article_subtitle);
return view;
}
// OnClick method for articles
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
articleButtonTop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!articleList.isEmpty()) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(articleList.get(0).getArticleUrl()));
startActivity(browserIntent);
Log.d("BUTTON", "ARTICLE 1 CLICKED");
}
}
});
articleButtonBottom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!articleList.isEmpty()) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(articleList.get(1).getArticleUrl()));
startActivity(browserIntent);
Log.d("BUTTON", "ARTICLE 2 CLICKED");
}
}
});
}
// Filling the countries recycle viewer
private void setCountries() {
// Php file which returns the country data
final String URL_COUNTRIES = "https://visitcountryapi.000webhostapp.com/exploreCountries.php";
// Sending the data request
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_COUNTRIES, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
// Converting the string to json array object
JSONArray array = new JSONArray(response);
Log.d("RESPONSE", "Response COUNTRY success " + response);
// Randomly picking countries to display
Vector<Integer> countryIndexVector = new Vector<Integer>();
countryIndexVector = randomNumGen(0, array.length(), NUM_OF_RECYCLER_ITEMS);
Log.d("COUNTRY", "Country index" + countryIndexVector);
// Creating objects for the country data
for (int i = 0; i < array.length(); i++) {
JSONObject countryObject = array.getJSONObject(i);
countryList.add(new CountryModel(countryObject.getInt("country_id"),
countryObject.getString("country_name"),
countryObject.getString("country_code"),
countryObject.getString("country_flag").replace("\\", ""),
countryObject.getString("country_currency"),
countryObject.getInt("country_pop"),
countryObject.getString("country_image").replace("\\", ""),
countryObject.getDouble("bigmac_index"),
countryObject.getString("country_desc"),
countryObject.getString("country_hemisphere"),
countryObject.getString("language_top"),
countryObject.getString("capital_city"),
countryObject.getString("country_timezone"),
countryObject.getString("call_code"),
"https://visitcountryapi.000webhostapp.com/Geolocation/" + countryObject.getInt("country_id") + ".png"));
Log.d("COUNTRY POPULATION", countryObject.getString("country_name") + " POP: " + countryObject.getInt("country_pop"));
}
for (int ind : countryIndexVector) {
countriesList.add(new CountryRecyclerViewItem(countryList.get(ind).getCountry_image(), countryList.get(ind).getCountry_flag(),
countryList.get(ind).getCountry_name(), "", countryList.get(ind).getCountry_id()));
}
Log.d("CHANGED SET", "Notify dataset changed");
countryAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
Volley.newRequestQueue(getContext()).add(stringRequest);
}
// Filling the article CardView
private void setArticles() {
// Php file that returns the data
final String URL_ARTICLES = "https://visitcountryapi.000webhostapp.com/exploreArticles.php";
Log.d("RESPONSE ARTICLES", "Request started");
// Sending the data request
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_ARTICLES, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
//converting the string to json array object
JSONArray array = new JSONArray(response);
Log.d("RESPONSE", "Response ARTICLE success " + response);
// Randomly choosing two articles to display
Vector<Integer> articleIndexVector = new Vector<Integer>();
articleIndexVector = randomNumGen(0, array.length(), 2);
Log.d("RESPONSE", "Article index" + articleIndexVector);
for (int ind : articleIndexVector) {
JSONObject articleObject = array.getJSONObject(ind);
articleList.add(new ArticleModel(ind, articleObject.getString("title"),
articleObject.getString("subtitle"),
articleObject.getString("link"),
articleObject.getString("image_url").replace("\\", ""),
articleObject.getString("type")));
Log.d("TITLE", articleObject.getString("title"));
}
Log.d("RESPONSE ARTICLE", Boolean.toString(articleList.isEmpty()));
fillData();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
Volley.newRequestQueue(getContext()).add(stringRequest);
}
// Filling the article elements with data
private void fillData() {
if (!articleList.isEmpty()) {
articleTitleTop.setText(articleList.get(0).getTitle());
articleSubtitleTop.setText(articleList.get(0).getSubtitle());
Glide.with(getContext()).load(articleList.get(0).getImageUrl()).centerCrop().into(articleButtonTop);
articleTitleBottom.setText(articleList.get(1).getTitle());
articleSubtitleBottom.setText(articleList.get(1).getSubtitle());
Glide.with(getContext()).load(articleList.get(1).getImageUrl()).centerCrop().into(articleButtonBottom);
}
}
private void setCities() {
// Php file that returns the city data
final String URL_CITIES = "https://visitcountryapi.000webhostapp.com/exploreCities.php";
// Sending the data request
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_CITIES, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
//converting the string to json array object
JSONArray array = new JSONArray(response);
Log.d("RESPONSE", "Response CITY success " + response);
// Selecting random cities to display
Vector<Integer> cityIndexVector = new Vector<Integer>();
cityIndexVector = randomNumGen(0, array.length(), NUM_OF_RECYCLER_ITEMS);
Log.d("CITY", "City index" + cityIndexVector);
for (int ind : cityIndexVector) {
JSONObject cityObject = array.getJSONObject(ind);
cityList.add(new CityModel(cityObject.getInt("country_id"),
ind,
cityObject.getString("city_name"),
cityObject.getString("city_image").replace("\\", "")));
}
for (CityModel city : cityList) {
citiesList.add(new HorizontalRecyclerViewItem(city.getCity_image(), city.getCity_name(), ""));
}
Log.d("CHANGED SET", "Notify dataset changed city");
cityAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
Volley.newRequestQueue(getContext()).add(stringRequest);
}
private void setSummerAndWinter() {
// Php file which returns the Summer and Winter places data
final String URL_PLACES = "https://visitcountryapi.000webhostapp.com/exploreSummerWinter.php";
// Sending the data request
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_PLACES, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
//converting the string to json array object
JSONArray array = new JSONArray(response);
Log.d("RESPONSE", "Response SUMMER WINTER success " + response);
// Randomly selecting data to display
Vector<Integer> summerIndexVector = new Vector<Integer>();
Vector<Integer> winterIndexVector = new Vector<>();
int halfLenght = array.length() / 2;
summerIndexVector = randomNumGen(0, halfLenght, NUM_OF_RECYCLER_ITEMS);
winterIndexVector = randomNumGen(halfLenght + 1, array.length(), NUM_OF_RECYCLER_ITEMS);
Log.d("SUMMER", "Summer index" + summerIndexVector);
Log.d("WINTER", "Winter index" + winterIndexVector);
for (int ind : summerIndexVector) {
JSONObject summerObject = array.getJSONObject(ind);
summerList.add(new SummerAndWinterModel(ind,
summerObject.getInt("country_id"),
summerObject.getString("place_name"),
summerObject.getString("geo_thermal_zone"),
summerObject.getString("place_image").replace("\\", ""),
summerObject.getString("intended_temp")));
}
for (int ind : winterIndexVector) {
JSONObject winterObject = array.getJSONObject(ind);
winterList.add(new SummerAndWinterModel(ind,
winterObject.getInt("country_id"),
winterObject.getString("place_name"),
winterObject.getString("geo_thermal_zone"),
winterObject.getString("place_image").replace("\\", ""),
winterObject.getString("intended_temp")));
}
for (SummerAndWinterModel summerObj : summerList) {
summerItemList.add(new HorizontalRecyclerViewItem(summerObj.getPlace_image(), summerObj.getPlace_name(), ""));
}
for (SummerAndWinterModel winterObj : winterList) {
winterItemList.add(new HorizontalRecyclerViewItem(winterObj.getPlace_image(), winterObj.getPlace_name(), ""));
}
Log.d("CHANGED SET", "Notify dataset changed summer and winter");
summerAdapter.notifyDataSetChanged();
winterAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
Volley.newRequestQueue(getContext()).add(stringRequest);
}
// Country RecyclerView OnClick method
@Override
public void onItemClick(int position) {
Fragment countryInfoFrag = new CountryInfoFragment(countryList.get(countriesList.get(position).getId() - 1), countryList);
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, countryInfoFrag).addToBackStack(null);
transaction.commit();
}
@Override
public void onLongItemClick(int position) {
}
// Method generating random indexes, to display data
public Vector<Integer> randomNumGen(int origin, int limit, int numOfItems) {
Vector<Integer> IndexVector = new Vector<Integer>();
Random rand = new Random();
for (int i = 0; i < numOfItems; i++) {
if (IndexVector.isEmpty()) {
IndexVector.add(ThreadLocalRandom.current().nextInt(origin, limit));
} else {
int index = ThreadLocalRandom.current().nextInt(origin, limit);
while (IndexVector.contains(index)) {
index = ThreadLocalRandom.current().nextInt(origin, limit);
}
IndexVector.add(index);
}
}
return IndexVector;
}
} | 22,867 | 0.621201 | 0.619627 | 508 | 44.015747 | 33.05751 | 150 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.704724 | false | false | 2 |
a0d561564add08ec9c53132fded1eeb2f571d03d | 11,123,965,338,712 | f2e6b3f7e182f2e55cac947cd3d4d605263d7ede | /unlimited car racing game/src/designing/H_guli.java | 1ab85704f368b2c9635ce9558ebecbb279fabd3d | []
| no_license | gobinda1547/unlimited-car-racing-game | https://github.com/gobinda1547/unlimited-car-racing-game | e501810b0a74a2146a217824242106531d323560 | 718594e47664cc178f0b87d4ed0418b12b2fbbea | refs/heads/master | 2021-05-12T12:52:39.411000 | 2018-01-14T11:22:30 | 2018-01-14T11:22:30 | 117,423,840 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package designing;
import java.awt.Color;
import java.awt.Graphics;
import Running.Play;
public class H_guli implements Runnable{
public int x, y;
public boolean visible;
public static int niche_porar_speed = 2, bas = 10;
public H_guli() {
x = 0;
y = 0;
visible = false;
}
public H_guli(String str,int i, int j) {
x = i;
y = j;
visible = true;
//sounding er option ekhane thakbe
Thread newthread = new Thread(this);
newthread.start();
}
public void draw_H_guli(Graphics g) {
g.setColor(Color.BLUE);
g.fillOval(x, y, bas, bas);
}
public void run() {
if(visible){
y += niche_porar_speed;
if (y > Play.b )
visible = false;
Board.ghum();
run();
}
}
}
| UTF-8 | Java | 770 | java | H_guli.java | Java | []
| null | []
| package designing;
import java.awt.Color;
import java.awt.Graphics;
import Running.Play;
public class H_guli implements Runnable{
public int x, y;
public boolean visible;
public static int niche_porar_speed = 2, bas = 10;
public H_guli() {
x = 0;
y = 0;
visible = false;
}
public H_guli(String str,int i, int j) {
x = i;
y = j;
visible = true;
//sounding er option ekhane thakbe
Thread newthread = new Thread(this);
newthread.start();
}
public void draw_H_guli(Graphics g) {
g.setColor(Color.BLUE);
g.fillOval(x, y, bas, bas);
}
public void run() {
if(visible){
y += niche_porar_speed;
if (y > Play.b )
visible = false;
Board.ghum();
run();
}
}
}
| 770 | 0.579221 | 0.572727 | 49 | 13.714286 | 13.567669 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.795918 | false | false | 2 |
390c6c3c21c8c48457c025a8efa629d9fa7e5e70 | 23,751,169,185,807 | 32c1f8b10057dc37f8991f98f391a8bfe38321b2 | /com.io7m.jspiel.api/src/main/java/com/io7m/jspiel/api/RiffFileType.java | e1dea3d6de431c03e9505cf29ce1d6caf88bc1ac | [
"ISC"
]
| permissive | io7m/jspiel | https://github.com/io7m/jspiel | 9c4d0bb7a1d45708e086973b1ad4b61a5990f4e5 | 003976fc1e91505599a00dcedb43366cf0ee8e2a | refs/heads/master | 2023-08-29T08:38:22.941000 | 2022-04-09T17:27:50 | 2022-04-09T17:27:50 | 169,975,750 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright © 2019 Mark Raynsford <code@io7m.com> https://www.io7m.com
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package com.io7m.jspiel.api;
import java.nio.ByteOrder;
import java.util.List;
import java.util.stream.Stream;
/**
* A parsed riff file.
*/
public interface RiffFileType
{
/**
* @return The chunks contained within the file
*/
List<RiffChunkType> chunks();
/**
* @return The byte order of the underlying file
*/
ByteOrder byteOrder();
/**
* @return The list of chunks in (depth-first) order
*/
default Stream<RiffChunkType> linearizedDescendantChunks()
{
return this.chunks()
.stream()
.flatMap(RiffChunkType::linearizedDescendantChunks);
}
}
| UTF-8 | Java | 1,415 | java | RiffFileType.java | Java | [
{
"context": "/*\n * Copyright © 2019 Mark Raynsford <code@io7m.com> https://www.io7m.com\n *\n * Permis",
"end": 37,
"score": 0.9997771978378296,
"start": 23,
"tag": "NAME",
"value": "Mark Raynsford"
},
{
"context": "/*\n * Copyright © 2019 Mark Raynsford <code@io7m.com> https://www.io7m.com\n *\n * Permission to use, co",
"end": 52,
"score": 0.9999269247055054,
"start": 39,
"tag": "EMAIL",
"value": "code@io7m.com"
}
]
| null | []
| /*
* Copyright © 2019 <NAME> <<EMAIL>> https://www.io7m.com
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package com.io7m.jspiel.api;
import java.nio.ByteOrder;
import java.util.List;
import java.util.stream.Stream;
/**
* A parsed riff file.
*/
public interface RiffFileType
{
/**
* @return The chunks contained within the file
*/
List<RiffChunkType> chunks();
/**
* @return The byte order of the underlying file
*/
ByteOrder byteOrder();
/**
* @return The list of chunks in (depth-first) order
*/
default Stream<RiffChunkType> linearizedDescendantChunks()
{
return this.chunks()
.stream()
.flatMap(RiffChunkType::linearizedDescendantChunks);
}
}
| 1,401 | 0.724187 | 0.719236 | 51 | 26.725491 | 28.582922 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.352941 | false | false | 2 |
014bf25de66db9d7c15fe512917c225ae67ec67e | 841,813,590,033 | d043f6a75a07e166579e4594f2aab3a7252fcddd | /src/unidad5/ProbarAnimal.java | 40201d8109842602194c46447030467f13d3e2d2 | []
| no_license | PabloTG/ejercicios2ev | https://github.com/PabloTG/ejercicios2ev | d73a65f4c7a9acf226cab68b96f1145ed91a36f9 | 72108e460d6bc515eb60a24e398645edcdbe057a | refs/heads/master | 2023-03-23T22:58:01.297000 | 2021-03-15T18:17:46 | 2021-03-15T18:17:46 | 327,086,419 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package unidad5;
public class ProbarAnimal {
public static void main(String[] args) {
Animal gata = new Animal("Pipo", "2000-03-28");
Animal perra = new Animal("Bimba");
Animal gata2 = new Animal("Gastrolito");
gata2.setNombre("Bu");
gata2.setFecha("2010-06-15");
System.out.println(gata.toString());
System.out.println(perra.toString());
System.out.println(gata2.toString());
System.out.println("Los animales creados hasta ahora se llaman " + gata.getNombre() +
", " + perra.getNombre() + " y " + gata2.getNombre() + ".");
Animal pruebaNombre = new Animal("Prueba", "2001-01-01");
pruebaNombre.setNombre("");
System.out.println(pruebaNombre.toString());
System.out.println(pruebaNombre.getNombre() + " nació el día " + pruebaNombre.getFecha() + ".");
}
}
| ISO-8859-1 | Java | 786 | java | ProbarAnimal.java | Java | []
| null | []
| package unidad5;
public class ProbarAnimal {
public static void main(String[] args) {
Animal gata = new Animal("Pipo", "2000-03-28");
Animal perra = new Animal("Bimba");
Animal gata2 = new Animal("Gastrolito");
gata2.setNombre("Bu");
gata2.setFecha("2010-06-15");
System.out.println(gata.toString());
System.out.println(perra.toString());
System.out.println(gata2.toString());
System.out.println("Los animales creados hasta ahora se llaman " + gata.getNombre() +
", " + perra.getNombre() + " y " + gata2.getNombre() + ".");
Animal pruebaNombre = new Animal("Prueba", "2001-01-01");
pruebaNombre.setNombre("");
System.out.println(pruebaNombre.toString());
System.out.println(pruebaNombre.getNombre() + " nació el día " + pruebaNombre.getFecha() + ".");
}
}
| 786 | 0.682398 | 0.644133 | 25 | 30.360001 | 26.493591 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.56 | false | false | 2 |
e8623252ab3e8343155bacdb2f20eff727767ffa | 5,454,608,474,856 | 0aaf981c174b3a5072bd0c022494800973905567 | /src/main/java/gmms/util/NewDateUtil.java | d134cf20949c5b0859390454840e3f03929510f1 | []
| no_license | wangfushu/Java_code_epaycallT | https://github.com/wangfushu/Java_code_epaycallT | b4ea1e34d257a9344156b9554a74aea505e5639a | ed8fb7f4962ff9871f2f6c156420005a258edd78 | refs/heads/master | 2020-03-19T03:08:00.555000 | 2018-06-01T09:39:04 | 2018-06-01T09:39:04 | 135,699,002 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package gmms.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class NewDateUtil {
/**
* GIS云台控制,计算云台操作时间
*/
public static void main(String[] args) {
// long second = getSecond(fromDateStringToDate("2013-02-27 08:00:00"));
// System.out.println("当前系统时间 - 登录时间 = "+second+"秒");
// Integer date = fromDateStringToDate("2016-08-13 20:38:02.000", "2016-08-13 20:38:01.000");
// System.out.println(date);
// System.out.println(fromDateStringToDate("2015-01-25 09:12:09"));
System.out.println(NewDateUtil.fromDateStringToString("2016-08-14 21:03:00.000"));
}
@SuppressWarnings("unused")
public static long getSecond(Date endDate){
// 当前系统时间
long startT = fromDateStringToLong(dqsj());
//时间转字符串
String end = fromDateDateToString(endDate);
// 获取数据库时间
long endT = fromDateStringToLong(end);
// 共计秒数
long ss = (startT - endT) / (1000);
// 共计分钟数
int MM = (int) ss / 60;
// 共计小时数
int hh = (int) ss / 3600;
// 共计天数
int dd = (int) hh / 24;
// System.out.println("共" + dd + "天" + "\t" + "准确时间是:" + hh + " 小时 "
// + "\t" + MM + " 分钟" + "\t" + +ss + " 秒 " + "\t"+ ss
// * 1000 + " 毫秒");
return ss;
}
/**
* 字符串转长整型
* @param inVal
* @return
*/
public static long fromDateStringToLong(String inVal) {
// 此方法计算时间毫秒
Date date = null;
// 定义时间类型
SimpleDateFormat inputFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
try {
date = inputFormat.parse(inVal);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date.getTime();
// 返回毫秒数
}
/**
* 时间转字符串
* @param inVal
* @return
*/
public static String fromDateDateToString(Date inVal) {
// 此方法计算时间毫秒
String date = null;
// 定义时间类型
SimpleDateFormat inputFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
try {
date = inputFormat.format(inVal);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date;
// 返回毫秒数
}
/**
* 时间转字符串(格式化到年月日)
* @param inVal
* @return
*/
public static String fromDayDateToString(Date inVal) {
// 此方法计算时间毫秒
String date = null;
// 定义时间类型
SimpleDateFormat inputFormat = new SimpleDateFormat(
"yyyy-MM-dd");
try {
date = inputFormat.format(inVal);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date;
// 返回毫秒数
}
/**
* 字符串转时间
* @param textTime
* @return
*/
public static Date fromDateStringToDate(String textTime) {
if(StringUtils.isNullBlank(textTime)){
return null;
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
try {
date = df.parse(textTime);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date;
// 返回转换后的时间
}
/**
* 字符串转时间
* @param textTime
* @return
*/
public static Date fromDateStringToDateYmd(String textTime) {
if(StringUtils.isNullBlank(textTime)){
return null;
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
try {
date = df.parse(textTime);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date;
// 返回转换后的时间
}
/**
* 字符串转字符串时间格式
* @param textTime
* @return
*/
public static String fromDateStringToString(String textTime) {
if(StringUtils.isNullBlank(textTime)){
return null;
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String strDate = new String();
try {
date = df.parse(textTime);
strDate = df.format(date);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return strDate;
// 返回转换后的时间
}
/**
* 时间转时间格式
* @param d
* @return
*/
public static Date fromDateDateToDate(Date d) {
if(null == d){
return null;
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String strDate = new String();
Date date = new Date();
try {
strDate = df.format(d);
date = df.parse(strDate);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date;
// 返回转换后的时间
}
/**
* 比较时间大小
* @param textStartTime
* @param textEndTime
* @return
*/
public static Integer fromDateStringToDate(String textStartTime, String textEndTime){
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
try
{
c1.setTime(df.parse(textStartTime));
c2.setTime(df.parse(textEndTime));
}catch(ParseException e){
// System.err.println("格式不正确");
}
int result = c1.compareTo(c2);
if(result == 0){
// System.out.println("c1相等c2");
}else if(result < 0){
// System.out.println("c1小于c2");
}else{
// System.out.println("c1大于c2");
}
return result;
}
/**
* 比较时间大小(格式化到年月日)
* @param textStartTime
* @param textEndTime
* @return
*/
public static Integer timeComparisonYearMonthDay(String textStartTime, String textEndTime){
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Calendar start = Calendar.getInstance();
Calendar end = Calendar.getInstance();
try
{
start.setTime(df.parse(textStartTime));
end.setTime(df.parse(textEndTime));
}catch(ParseException e){
System.err.println("格式不正确");
}
int result = start.compareTo(end);
if(result == 0){
// System.out.println("格式化到年月日:c1相等c2");
}else if(result < 0){
// System.out.println("格式化到年月日:c1小于c2");
}else{
// System.out.println("格式化到年月日:c1大于c2");
}
return result;
}
/**
* 比较时间大小(格式化到年月)
* @param textStartTime
* @param textEndTime
* @return
*/
public static Integer timeComparisonYearMonth(String textStartTime, String textEndTime){
DateFormat df = new SimpleDateFormat("yyyy-MM");
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
try
{
c1.setTime(df.parse(textStartTime));
c2.setTime(df.parse(textEndTime));
}catch(ParseException e){
System.err.println("格式不正确");
}
int result = c1.compareTo(c2);
if(result == 0){
// System.out.println("格式化到年月:c1相等c2");
}else if(result < 0){
// System.out.println("格式化到年月:c1小于c2");
}else{
// System.out.println("格式化到年月:c1大于c2");
}
return result;
}
@SuppressWarnings("deprecation")
private static String dqsj() {
// 此方法用于获得当前系统时间(格式类型2007-11-6 15:10:58)
Date date = new Date();
// 实例化日期类型
String today = date.toLocaleString();
// 获取当前时间
// System.out.println("获得当前系统时间 :" + today);
// 显示
return today;
// 返回当前时间
}
/**
* 传入时间格式,当前时间加减天数,返回时间
* @param dateFormat
* @param day
*/
public static Date getCountDateFormatDate(String dateFormat, int day){
SimpleDateFormat dft = new SimpleDateFormat(dateFormat);
Date beginDate = new Date();
Calendar date = Calendar.getInstance();
date.setTime(beginDate);
date.set(Calendar.DATE, date.get(Calendar.DATE) - day);
Date endDate = null;
try {
endDate = dft.parse(dft.format(date.getTime()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return endDate;
}
/**
* 传入时间格式,当前时间加减天数,返回字符串
* @param dateFormat
* @param day
*/
public static String getCountDateFormatStr(String dateFormat, int day){
SimpleDateFormat dft = new SimpleDateFormat(dateFormat);
Date beginDate = new Date();
Calendar date = Calendar.getInstance();
date.setTime(beginDate);
date.set(Calendar.DATE, date.get(Calendar.DATE) - day);
String endDate = null;
try {
endDate = dft.format(date.getTime());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return endDate;
}
/**
* 得到两个日期之间的天数
* @param dateFormat
* @param strDate1
* @param strDate2
* @return
*/
public static int getDays(String dateFormat, String strDate1, String strDate2) {
// 天数
int days = 0;
try {
// 时间转换类
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
Date date1 = sdf.parse(strDate1);
Date date2 = sdf.parse(strDate2);
// 将转换的两个时间对象转换成Calendard对象
Calendar can1 = Calendar.getInstance();
can1.setTime(date1);
Calendar can2 = Calendar.getInstance();
can2.setTime(date2);
// 拿出两个年份
int year1 = can1.get(Calendar.YEAR);
int year2 = can2.get(Calendar.YEAR);
Calendar can = null;
// 如果can1 < can2
// 减去小的时间在这一年已经过了的天数
// 加上大的时间已过的天数
if (can1.before(can2)) {
days -= can1.get(Calendar.DAY_OF_YEAR);
days += can2.get(Calendar.DAY_OF_YEAR);
can = can1;
} else {
days -= can2.get(Calendar.DAY_OF_YEAR);
days += can1.get(Calendar.DAY_OF_YEAR);
can = can2;
}
for (int i = 0; i < Math.abs(year2 - year1); i++) {
// 获取小的时间当前年的总天数
days += can.getActualMaximum(Calendar.DAY_OF_YEAR);
// 再计算下一年。
can.add(Calendar.YEAR, 1);
}
// System.out.println("天数差:"+days);
} catch (ParseException e) {
e.printStackTrace();
}
return days;
}
/**
* 分钟转换成时、分
* @param min
* @return
*/
public static String minConvertDayHourMin(Float min) {
String html = "0分";
if (null != min) {
Float m = (Float) min;
String format;
Object[] array;
Integer days = (int) (m / (60 * 24));
Integer hours = (int) (m / (60) - days * 24);
Integer minutes = (int) (m - hours * 60 - days * 24 * 60);
if (days > 0) {
format = "%1$,d天%2$,d小时%3$,d分钟";
array = new Object[] { days, hours, minutes };
} else if (hours > 0) {
format = "%1$,d小时%2$,d分钟";
array = new Object[] { hours, minutes };
} else {
format = "%1$,d分钟";
array = new Object[] { minutes };
}
html = String.format(format, array);
}
return html;
}
/**
* 传入天、小时、秒转换成秒
* @param day
* @param hour
* @param min
* @return
*/
public static int dayHourMinConverMin(int day, int hour, int min) {
int days = day * 24 * 60;
int hours = hour * 60;
return days + hours + min;
}
/**
* 比较时间大小
* @param d1
* @param d2
* @return
*/
public static Boolean sameDate(Date d1, Date d2, String dateFormat){
SimpleDateFormat fmt = new SimpleDateFormat(dateFormat);
String format1 = fmt.format(d1);
String format2 = fmt.format(d2);
return format1.equals(format2);
}
public static Date getStartDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
public static Date getEndDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 59);
return calendar.getTime();
}
}
| UTF-8 | Java | 12,126 | java | NewDateUtil.java | Java | []
| null | []
| package gmms.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class NewDateUtil {
/**
* GIS云台控制,计算云台操作时间
*/
public static void main(String[] args) {
// long second = getSecond(fromDateStringToDate("2013-02-27 08:00:00"));
// System.out.println("当前系统时间 - 登录时间 = "+second+"秒");
// Integer date = fromDateStringToDate("2016-08-13 20:38:02.000", "2016-08-13 20:38:01.000");
// System.out.println(date);
// System.out.println(fromDateStringToDate("2015-01-25 09:12:09"));
System.out.println(NewDateUtil.fromDateStringToString("2016-08-14 21:03:00.000"));
}
@SuppressWarnings("unused")
public static long getSecond(Date endDate){
// 当前系统时间
long startT = fromDateStringToLong(dqsj());
//时间转字符串
String end = fromDateDateToString(endDate);
// 获取数据库时间
long endT = fromDateStringToLong(end);
// 共计秒数
long ss = (startT - endT) / (1000);
// 共计分钟数
int MM = (int) ss / 60;
// 共计小时数
int hh = (int) ss / 3600;
// 共计天数
int dd = (int) hh / 24;
// System.out.println("共" + dd + "天" + "\t" + "准确时间是:" + hh + " 小时 "
// + "\t" + MM + " 分钟" + "\t" + +ss + " 秒 " + "\t"+ ss
// * 1000 + " 毫秒");
return ss;
}
/**
* 字符串转长整型
* @param inVal
* @return
*/
public static long fromDateStringToLong(String inVal) {
// 此方法计算时间毫秒
Date date = null;
// 定义时间类型
SimpleDateFormat inputFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
try {
date = inputFormat.parse(inVal);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date.getTime();
// 返回毫秒数
}
/**
* 时间转字符串
* @param inVal
* @return
*/
public static String fromDateDateToString(Date inVal) {
// 此方法计算时间毫秒
String date = null;
// 定义时间类型
SimpleDateFormat inputFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
try {
date = inputFormat.format(inVal);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date;
// 返回毫秒数
}
/**
* 时间转字符串(格式化到年月日)
* @param inVal
* @return
*/
public static String fromDayDateToString(Date inVal) {
// 此方法计算时间毫秒
String date = null;
// 定义时间类型
SimpleDateFormat inputFormat = new SimpleDateFormat(
"yyyy-MM-dd");
try {
date = inputFormat.format(inVal);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date;
// 返回毫秒数
}
/**
* 字符串转时间
* @param textTime
* @return
*/
public static Date fromDateStringToDate(String textTime) {
if(StringUtils.isNullBlank(textTime)){
return null;
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
try {
date = df.parse(textTime);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date;
// 返回转换后的时间
}
/**
* 字符串转时间
* @param textTime
* @return
*/
public static Date fromDateStringToDateYmd(String textTime) {
if(StringUtils.isNullBlank(textTime)){
return null;
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
try {
date = df.parse(textTime);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date;
// 返回转换后的时间
}
/**
* 字符串转字符串时间格式
* @param textTime
* @return
*/
public static String fromDateStringToString(String textTime) {
if(StringUtils.isNullBlank(textTime)){
return null;
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String strDate = new String();
try {
date = df.parse(textTime);
strDate = df.format(date);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return strDate;
// 返回转换后的时间
}
/**
* 时间转时间格式
* @param d
* @return
*/
public static Date fromDateDateToDate(Date d) {
if(null == d){
return null;
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String strDate = new String();
Date date = new Date();
try {
strDate = df.format(d);
date = df.parse(strDate);
// 将字符型转换成日期型
} catch (Exception e) {
e.printStackTrace();
}
return date;
// 返回转换后的时间
}
/**
* 比较时间大小
* @param textStartTime
* @param textEndTime
* @return
*/
public static Integer fromDateStringToDate(String textStartTime, String textEndTime){
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
try
{
c1.setTime(df.parse(textStartTime));
c2.setTime(df.parse(textEndTime));
}catch(ParseException e){
// System.err.println("格式不正确");
}
int result = c1.compareTo(c2);
if(result == 0){
// System.out.println("c1相等c2");
}else if(result < 0){
// System.out.println("c1小于c2");
}else{
// System.out.println("c1大于c2");
}
return result;
}
/**
* 比较时间大小(格式化到年月日)
* @param textStartTime
* @param textEndTime
* @return
*/
public static Integer timeComparisonYearMonthDay(String textStartTime, String textEndTime){
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Calendar start = Calendar.getInstance();
Calendar end = Calendar.getInstance();
try
{
start.setTime(df.parse(textStartTime));
end.setTime(df.parse(textEndTime));
}catch(ParseException e){
System.err.println("格式不正确");
}
int result = start.compareTo(end);
if(result == 0){
// System.out.println("格式化到年月日:c1相等c2");
}else if(result < 0){
// System.out.println("格式化到年月日:c1小于c2");
}else{
// System.out.println("格式化到年月日:c1大于c2");
}
return result;
}
/**
* 比较时间大小(格式化到年月)
* @param textStartTime
* @param textEndTime
* @return
*/
public static Integer timeComparisonYearMonth(String textStartTime, String textEndTime){
DateFormat df = new SimpleDateFormat("yyyy-MM");
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
try
{
c1.setTime(df.parse(textStartTime));
c2.setTime(df.parse(textEndTime));
}catch(ParseException e){
System.err.println("格式不正确");
}
int result = c1.compareTo(c2);
if(result == 0){
// System.out.println("格式化到年月:c1相等c2");
}else if(result < 0){
// System.out.println("格式化到年月:c1小于c2");
}else{
// System.out.println("格式化到年月:c1大于c2");
}
return result;
}
@SuppressWarnings("deprecation")
private static String dqsj() {
// 此方法用于获得当前系统时间(格式类型2007-11-6 15:10:58)
Date date = new Date();
// 实例化日期类型
String today = date.toLocaleString();
// 获取当前时间
// System.out.println("获得当前系统时间 :" + today);
// 显示
return today;
// 返回当前时间
}
/**
* 传入时间格式,当前时间加减天数,返回时间
* @param dateFormat
* @param day
*/
public static Date getCountDateFormatDate(String dateFormat, int day){
SimpleDateFormat dft = new SimpleDateFormat(dateFormat);
Date beginDate = new Date();
Calendar date = Calendar.getInstance();
date.setTime(beginDate);
date.set(Calendar.DATE, date.get(Calendar.DATE) - day);
Date endDate = null;
try {
endDate = dft.parse(dft.format(date.getTime()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return endDate;
}
/**
* 传入时间格式,当前时间加减天数,返回字符串
* @param dateFormat
* @param day
*/
public static String getCountDateFormatStr(String dateFormat, int day){
SimpleDateFormat dft = new SimpleDateFormat(dateFormat);
Date beginDate = new Date();
Calendar date = Calendar.getInstance();
date.setTime(beginDate);
date.set(Calendar.DATE, date.get(Calendar.DATE) - day);
String endDate = null;
try {
endDate = dft.format(date.getTime());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return endDate;
}
/**
* 得到两个日期之间的天数
* @param dateFormat
* @param strDate1
* @param strDate2
* @return
*/
public static int getDays(String dateFormat, String strDate1, String strDate2) {
// 天数
int days = 0;
try {
// 时间转换类
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
Date date1 = sdf.parse(strDate1);
Date date2 = sdf.parse(strDate2);
// 将转换的两个时间对象转换成Calendard对象
Calendar can1 = Calendar.getInstance();
can1.setTime(date1);
Calendar can2 = Calendar.getInstance();
can2.setTime(date2);
// 拿出两个年份
int year1 = can1.get(Calendar.YEAR);
int year2 = can2.get(Calendar.YEAR);
Calendar can = null;
// 如果can1 < can2
// 减去小的时间在这一年已经过了的天数
// 加上大的时间已过的天数
if (can1.before(can2)) {
days -= can1.get(Calendar.DAY_OF_YEAR);
days += can2.get(Calendar.DAY_OF_YEAR);
can = can1;
} else {
days -= can2.get(Calendar.DAY_OF_YEAR);
days += can1.get(Calendar.DAY_OF_YEAR);
can = can2;
}
for (int i = 0; i < Math.abs(year2 - year1); i++) {
// 获取小的时间当前年的总天数
days += can.getActualMaximum(Calendar.DAY_OF_YEAR);
// 再计算下一年。
can.add(Calendar.YEAR, 1);
}
// System.out.println("天数差:"+days);
} catch (ParseException e) {
e.printStackTrace();
}
return days;
}
/**
* 分钟转换成时、分
* @param min
* @return
*/
public static String minConvertDayHourMin(Float min) {
String html = "0分";
if (null != min) {
Float m = (Float) min;
String format;
Object[] array;
Integer days = (int) (m / (60 * 24));
Integer hours = (int) (m / (60) - days * 24);
Integer minutes = (int) (m - hours * 60 - days * 24 * 60);
if (days > 0) {
format = "%1$,d天%2$,d小时%3$,d分钟";
array = new Object[] { days, hours, minutes };
} else if (hours > 0) {
format = "%1$,d小时%2$,d分钟";
array = new Object[] { hours, minutes };
} else {
format = "%1$,d分钟";
array = new Object[] { minutes };
}
html = String.format(format, array);
}
return html;
}
/**
* 传入天、小时、秒转换成秒
* @param day
* @param hour
* @param min
* @return
*/
public static int dayHourMinConverMin(int day, int hour, int min) {
int days = day * 24 * 60;
int hours = hour * 60;
return days + hours + min;
}
/**
* 比较时间大小
* @param d1
* @param d2
* @return
*/
public static Boolean sameDate(Date d1, Date d2, String dateFormat){
SimpleDateFormat fmt = new SimpleDateFormat(dateFormat);
String format1 = fmt.format(d1);
String format2 = fmt.format(d2);
return format1.equals(format2);
}
public static Date getStartDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
public static Date getEndDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 59);
return calendar.getTime();
}
}
| 12,126 | 0.637801 | 0.616841 | 472 | 22.04661 | 18.733126 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.351695 | false | false | 2 |
dc631b6bd6896feba13e0455832608979dd133d4 | 16,020,228,022,731 | 6449bb85ccd76e99e939230d392f38f3ecd1847f | /app/src/main/java/com/example/myfirst/AboutSavBankFragment.java | 497832ede50c4946ceac898e21463309210e2584 | []
| no_license | Ahsan-dev/FinbazApp | https://github.com/Ahsan-dev/FinbazApp | c5aab8342ce7f80852576a0aa5c365929f95e403 | 68eac20e2ef04a8f9bd17a9bb4705d6ea3ed90ea | refs/heads/master | 2023-01-07T11:31:41.358000 | 2020-11-12T17:02:01 | 2020-11-12T17:02:01 | 303,795,595 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.myfirst;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class AboutSavBankFragment extends Fragment {
private View view;
private TextView aboutText, mbValue, irValue;
//private String bankName ;
public AboutSavBankFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_about_sav_bank, container, false);
String bankName = getArguments().getString("bankNameAbout");
aboutText = view.findViewById(R.id.sav_bank_about_txt);
mbValue = view.findViewById(R.id.sav_bank_about_mb_value_id);
irValue = view.findViewById(R.id.sav_bank_about_ir_value_id);
if(bankName=="indusind"){
aboutText.setText(getResources().getString(R.string.indusind_about_string));
mbValue.setText("₹ 0");
irValue.setText("upto 6%");
}
if(bankName=="kotak"){
aboutText.setText(getResources().getString(R.string.kotak_about_string));
mbValue.setText("₹ 0");
irValue.setText("upto 4%");
}
if(bankName=="digibank"){
aboutText.setText(getResources().getString(R.string.digibank_about_string));
mbValue.setText("₹ 0");
irValue.setText("upto 5%");
}
if(bankName=="rbl"){
aboutText.setText(getResources().getString(R.string.rbl_about_string));
mbValue.setText("₹ 2,000");
irValue.setText("upto 6.75%");
}
if(bankName=="idfc"){
aboutText.setText(getResources().getString(R.string.idfc_about_string));
mbValue.setText("₹ 10,000 - 25,000");
irValue.setText("upto 7%");
}
return view;
}
} | UTF-8 | Java | 2,125 | java | AboutSavBankFragment.java | Java | []
| null | []
| package com.example.myfirst;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class AboutSavBankFragment extends Fragment {
private View view;
private TextView aboutText, mbValue, irValue;
//private String bankName ;
public AboutSavBankFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_about_sav_bank, container, false);
String bankName = getArguments().getString("bankNameAbout");
aboutText = view.findViewById(R.id.sav_bank_about_txt);
mbValue = view.findViewById(R.id.sav_bank_about_mb_value_id);
irValue = view.findViewById(R.id.sav_bank_about_ir_value_id);
if(bankName=="indusind"){
aboutText.setText(getResources().getString(R.string.indusind_about_string));
mbValue.setText("₹ 0");
irValue.setText("upto 6%");
}
if(bankName=="kotak"){
aboutText.setText(getResources().getString(R.string.kotak_about_string));
mbValue.setText("₹ 0");
irValue.setText("upto 4%");
}
if(bankName=="digibank"){
aboutText.setText(getResources().getString(R.string.digibank_about_string));
mbValue.setText("₹ 0");
irValue.setText("upto 5%");
}
if(bankName=="rbl"){
aboutText.setText(getResources().getString(R.string.rbl_about_string));
mbValue.setText("₹ 2,000");
irValue.setText("upto 6.75%");
}
if(bankName=="idfc"){
aboutText.setText(getResources().getString(R.string.idfc_about_string));
mbValue.setText("₹ 10,000 - 25,000");
irValue.setText("upto 7%");
}
return view;
}
} | 2,125 | 0.616548 | 0.605201 | 79 | 25.784811 | 27.022573 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.506329 | false | false | 2 |
a34e29c99115d69974fc6f8e285d98620b1f50d4 | 16,423,954,947,623 | 79593fa3088da6a2ad750edc91689a56e2043da6 | /src/main/java/com/example/queststore/data/contracts/StudentItemEntry.java | 84ae9d97ec992d18a05fa37a081767261f36ca71 | []
| no_license | lpelczar/Queststore-CMS | https://github.com/lpelczar/Queststore-CMS | 699d8c593efd79f95b6da5afb7c7a5c615f8f1c6 | cc7a22a8cefcfcc3d9797b8a5a092cf1109e5748 | refs/heads/master | 2023-06-25T03:53:48.543000 | 2020-08-08T13:58:54 | 2020-08-08T13:58:54 | 133,256,014 | 1 | 0 | null | false | 2023-06-14T22:28:49 | 2018-05-13T16:43:51 | 2022-03-02T19:46:59 | 2023-06-14T22:28:48 | 8,938 | 1 | 0 | 2 | Java | false | false | package com.example.queststore.data.contracts;
public class StudentItemEntry {
public static final String TABLE_NAME = "students_items";
public static final String ID_STUDENT = "id_student";
public static final String ID_ITEM = "id_item";
public static final String IS_USED = "is_used";
public static final int IS_USED_VALUE = 1;
public static final int IS_NOT_USED_VALUE = 0;
}
| UTF-8 | Java | 405 | java | StudentItemEntry.java | Java | []
| null | []
| package com.example.queststore.data.contracts;
public class StudentItemEntry {
public static final String TABLE_NAME = "students_items";
public static final String ID_STUDENT = "id_student";
public static final String ID_ITEM = "id_item";
public static final String IS_USED = "is_used";
public static final int IS_USED_VALUE = 1;
public static final int IS_NOT_USED_VALUE = 0;
}
| 405 | 0.716049 | 0.711111 | 11 | 35.81818 | 22.870459 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false | 2 |
813e12449af86f6f1ebd81ec474624772962821e | 15,599,321,230,910 | a63eb63ac02ac60f6ffd24eb73ff608194199abf | /src/javax/java/scs/javax/rdb/sql/SqlEntityHelper.java | 09e61b773e9bb68163e32cff90f1908c606f0fb4 | []
| no_license | sebcsaba/GeoResults | https://github.com/sebcsaba/GeoResults | 92ccd4b11a135c3606650efebbf9314bb10e26cf | 924b2a0366a2ef047ba651dc542a0a09badf6464 | refs/heads/master | 2016-09-06T17:18:14.920000 | 2012-10-11T22:00:23 | 2012-10-11T22:00:23 | 2,615,595 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package scs.javax.rdb.sql;
import scs.javax.collections.List;
import scs.javax.rdb.RdbException;
import scs.javax.rdb.helper.RdbEntityHelper;
import scs.javax.rdb.helper.RdbHelper;
import scs.javax.rdb.mapping.*;
import scs.javax.rdb.mapping.fields.RdbField;
import scs.javax.utils.StringUtils;
public class SqlEntityHelper implements RdbEntityHelper
{
private ClassMappingBase cm;
private String[] fieldNames;
private String fieldNameList;
private String fieldNameListWithoutAutoincrement;
private String orderByClause;
private final String sql_create_part1;
private final String sql_read_part1;
private final String sql_count_part1;
private final String sql_update_part1;
private final String sql_delete_part1;
public SqlEntityHelper ( ClassMappingBase cm )
{
this.cm = cm;
initFieldNameList();
initFieldNameListWithoutAutoincrement();
initOrderByClause();
this.sql_create_part1 = "INSERT INTO " + cm.getTableName() + " (" + fieldNameListWithoutAutoincrement + ") VALUES (";
this.sql_read_part1 = "SELECT " + fieldNameList + " FROM " + cm.getTableName() + " WHERE ";
this.sql_count_part1 = "SELECT COUNT(*) FROM " + cm.getTableName() + " WHERE ";
this.sql_update_part1 = "UPDATE " + cm.getTableName() + " SET ";
this.sql_delete_part1 = "DELETE FROM " + cm.getTableName() + " WHERE ";
}
private void initFieldNameList ()
{
fieldNames = new String[cm.getFieldCount()];
for ( int i = 0; i < cm.getFieldCount(); ++i ) {
fieldNames[i] = cm.getField( i ).getPropertyName();
}
fieldNameList = StringUtils.joinStrings( fieldNames, "," );
}
private void initFieldNameListWithoutAutoincrement()
{
PrimaryKey pk = cm.getPrimaryKey();
if (pk.isAutoIncrement()) {
List fieldNames = new List();
for (int i=0; i<cm.getFieldCount(); ++i) {
if (!pk.hasField(cm.getField(i))) {
fieldNames.add(cm.getField(i).getPropertyName());
}
}
String[] fieldNamesArray = (String[]) fieldNames.toArray(new String[fieldNames.size()]);
fieldNameListWithoutAutoincrement = StringUtils.joinStrings(fieldNamesArray, ",");
} else {
fieldNameListWithoutAutoincrement = fieldNameList;
}
}
private void initOrderByClause ()
{
SortingCondition[] sorts = cm.getSortingConditions();
if ( sorts == null || sorts.length == 0 ) {
orderByClause = "";
} else {
String[] dirs = new String[sorts.length];
for ( int i = 0; i < sorts.length; ++i ) {
dirs[i] = sorts[i].getFieldName() + ( sorts[i].isAscendent() ? " ASC" : " DESC" );
}
orderByClause = " ORDER BY " + StringUtils.joinStrings( dirs, ", " );
}
}
private String getFieldValueList ( Object entity ) throws RdbException
{
String[] fieldValues = new String[fieldNames.length];
for ( int i = 0; i < fieldNames.length; ++i ) {
fieldValues[i] = cm.getField( fieldNames[i] ).getLiteralFromEntity( entity );
}
return StringUtils.joinStrings( fieldValues, "," );
}
private String getFieldValueListWithoutAutoincrement ( Object entity ) throws RdbException
{
PrimaryKey pk = cm.getPrimaryKey();
if (pk.isAutoIncrement()) {
List fieldValues = new List();
for ( int i = 0; i < fieldNames.length; ++i ) {
RdbField field = cm.getField( fieldNames[i] );
if (!pk.hasField(field)) {
fieldValues.add( field.getLiteralFromEntity( entity ));
}
}
String[] fieldValuesArray = (String[]) fieldValues.toArray(new String[fieldValues.size()]);
return StringUtils.joinStrings( fieldValuesArray, "," );
} else {
return getFieldValueList(entity);
}
}
private String getUpdateFieldValueList ( Object entity ) throws RdbException
{
String[] fieldNamesAndValues = new String[fieldNames.length];
for ( int i = 0; i < fieldNames.length; ++i ) {
RdbField field = cm.getField( fieldNames[i] );
fieldNamesAndValues[i] = field.getPropertyName() + "=" + field.getLiteralFromEntity( entity );
}
return StringUtils.joinStrings( fieldNamesAndValues, ", " );
}
private static String getCondition ( PrimitiveRdbCondition cond )
{
return cond.getField().getPropertyName() + "=" + cond.getField().getLiteralFromValue( cond.getValue() );
}
private String getConditionFromPrimaryKeyAndEntity ( Object entity ) throws RdbException
{
RdbField[] fields = cm.getPrimaryKey().getFields();
String[] conds = new String[fields.length];
for ( int i = 0; i < fields.length; ++i ) {
conds[i] = PrimitiveRdbCondition.newInstanceFromEntity( fields[i], entity ).toString();
}
return StringUtils.joinStrings( conds, " and " );
}
public Object createCreateStatement ( Object entity ) throws RdbException
{
return sql_create_part1 + getFieldValueListWithoutAutoincrement( entity ) + ")";
}
public Object createReadStatement ( Object entity ) throws RdbException
{
return sql_read_part1 + getConditionFromPrimaryKeyAndEntity( entity );
}
public Object createUpdateStatement ( Object entity ) throws RdbException
{
return sql_update_part1 + getUpdateFieldValueList( entity ) + " WHERE " + getConditionFromPrimaryKeyAndEntity( entity );
}
public Object createDeleteStatement ( Object entity ) throws RdbException
{
return sql_delete_part1 + getConditionFromPrimaryKeyAndEntity( entity );
}
public Object createReadAllStatement () throws RdbException
{
return sql_read_part1 + "1=1";
}
public Object createReadAllFilteredStatement ( PrimitiveRdbCondition filter ) throws RdbException
{
return sql_read_part1 + getCondition( filter ) + orderByClause;
}
public Object createReadAllFilteredStatement ( PrimitiveRdbCondition[] filters ) throws RdbException
{
String[] conds = new String[filters.length];
for ( int i = 0; i < filters.length; ++i ) conds[i] = getCondition( filters[i] );
return sql_read_part1 + StringUtils.joinStrings( conds, " AND " ) + orderByClause;
}
public Object createReadListStatement ( Object keyEntity ) throws RdbException
{
String[] conds = new String[cm.getListKey().length];
for ( int i = 0; i < cm.getListKey().length; ++i ) {
RdbField field = cm.getField( cm.getListKey()[i] );
conds[i] = field.getPropertyName() + "=" + field.getLiteralFromEntity( keyEntity );
}
return sql_read_part1 + StringUtils.joinStrings( conds, " AND " ) + orderByClause;
}
public Object createCreateTableStatement () throws RdbException
{
PrimaryKey key = cm.getPrimaryKey();
StringBuffer result = new StringBuffer( "CREATE TABLE " );
result.append( cm.getTableName() ).append( " ( " );
for ( int i = 0; i < cm.getFieldCount(); ++i ) {
RdbField field = cm.getField( i );
result.append( getSqlFieldDefinition( field, key ) ).append( ", " );
}
result.append( "PRIMARY KEY (" );
for ( int i = 0; i < key.getFields().length; ++i ) {
RdbField field = key.getFields()[i];
if ( i > 0 ) result.append( ", " );
result.append( field.getPropertyName() );
}
result.append( ") ) DEFAULT CHARSET=utf8;" );
return result.toString();
}
public Object createCountAllFilteredStatement ( PrimitiveRdbCondition filter ) throws RdbException
{
return sql_count_part1 + getCondition( filter ) + orderByClause;
}
private static String getSqlFieldDefinition ( RdbField field, PrimaryKey key )
{
RdbHelper globalHelper = new SqlHelper();
StringBuffer result = new StringBuffer();
result.append( field.getPropertyName() ).append( " " ).append( field.getRdbTypeName( globalHelper ) ).append( " " );
if ( field.isNullEnabled() ) {
result.append( "NULL" );
} else {
result.append( "NOT NULL" );
}
if ( key.isAutoIncrement() && key.hasField( field ) ) {
result.append( " auto_increment" );
}
return result.toString();
}
}
| UTF-8 | Java | 8,143 | java | SqlEntityHelper.java | Java | []
| null | []
| package scs.javax.rdb.sql;
import scs.javax.collections.List;
import scs.javax.rdb.RdbException;
import scs.javax.rdb.helper.RdbEntityHelper;
import scs.javax.rdb.helper.RdbHelper;
import scs.javax.rdb.mapping.*;
import scs.javax.rdb.mapping.fields.RdbField;
import scs.javax.utils.StringUtils;
public class SqlEntityHelper implements RdbEntityHelper
{
private ClassMappingBase cm;
private String[] fieldNames;
private String fieldNameList;
private String fieldNameListWithoutAutoincrement;
private String orderByClause;
private final String sql_create_part1;
private final String sql_read_part1;
private final String sql_count_part1;
private final String sql_update_part1;
private final String sql_delete_part1;
public SqlEntityHelper ( ClassMappingBase cm )
{
this.cm = cm;
initFieldNameList();
initFieldNameListWithoutAutoincrement();
initOrderByClause();
this.sql_create_part1 = "INSERT INTO " + cm.getTableName() + " (" + fieldNameListWithoutAutoincrement + ") VALUES (";
this.sql_read_part1 = "SELECT " + fieldNameList + " FROM " + cm.getTableName() + " WHERE ";
this.sql_count_part1 = "SELECT COUNT(*) FROM " + cm.getTableName() + " WHERE ";
this.sql_update_part1 = "UPDATE " + cm.getTableName() + " SET ";
this.sql_delete_part1 = "DELETE FROM " + cm.getTableName() + " WHERE ";
}
private void initFieldNameList ()
{
fieldNames = new String[cm.getFieldCount()];
for ( int i = 0; i < cm.getFieldCount(); ++i ) {
fieldNames[i] = cm.getField( i ).getPropertyName();
}
fieldNameList = StringUtils.joinStrings( fieldNames, "," );
}
private void initFieldNameListWithoutAutoincrement()
{
PrimaryKey pk = cm.getPrimaryKey();
if (pk.isAutoIncrement()) {
List fieldNames = new List();
for (int i=0; i<cm.getFieldCount(); ++i) {
if (!pk.hasField(cm.getField(i))) {
fieldNames.add(cm.getField(i).getPropertyName());
}
}
String[] fieldNamesArray = (String[]) fieldNames.toArray(new String[fieldNames.size()]);
fieldNameListWithoutAutoincrement = StringUtils.joinStrings(fieldNamesArray, ",");
} else {
fieldNameListWithoutAutoincrement = fieldNameList;
}
}
private void initOrderByClause ()
{
SortingCondition[] sorts = cm.getSortingConditions();
if ( sorts == null || sorts.length == 0 ) {
orderByClause = "";
} else {
String[] dirs = new String[sorts.length];
for ( int i = 0; i < sorts.length; ++i ) {
dirs[i] = sorts[i].getFieldName() + ( sorts[i].isAscendent() ? " ASC" : " DESC" );
}
orderByClause = " ORDER BY " + StringUtils.joinStrings( dirs, ", " );
}
}
private String getFieldValueList ( Object entity ) throws RdbException
{
String[] fieldValues = new String[fieldNames.length];
for ( int i = 0; i < fieldNames.length; ++i ) {
fieldValues[i] = cm.getField( fieldNames[i] ).getLiteralFromEntity( entity );
}
return StringUtils.joinStrings( fieldValues, "," );
}
private String getFieldValueListWithoutAutoincrement ( Object entity ) throws RdbException
{
PrimaryKey pk = cm.getPrimaryKey();
if (pk.isAutoIncrement()) {
List fieldValues = new List();
for ( int i = 0; i < fieldNames.length; ++i ) {
RdbField field = cm.getField( fieldNames[i] );
if (!pk.hasField(field)) {
fieldValues.add( field.getLiteralFromEntity( entity ));
}
}
String[] fieldValuesArray = (String[]) fieldValues.toArray(new String[fieldValues.size()]);
return StringUtils.joinStrings( fieldValuesArray, "," );
} else {
return getFieldValueList(entity);
}
}
private String getUpdateFieldValueList ( Object entity ) throws RdbException
{
String[] fieldNamesAndValues = new String[fieldNames.length];
for ( int i = 0; i < fieldNames.length; ++i ) {
RdbField field = cm.getField( fieldNames[i] );
fieldNamesAndValues[i] = field.getPropertyName() + "=" + field.getLiteralFromEntity( entity );
}
return StringUtils.joinStrings( fieldNamesAndValues, ", " );
}
private static String getCondition ( PrimitiveRdbCondition cond )
{
return cond.getField().getPropertyName() + "=" + cond.getField().getLiteralFromValue( cond.getValue() );
}
private String getConditionFromPrimaryKeyAndEntity ( Object entity ) throws RdbException
{
RdbField[] fields = cm.getPrimaryKey().getFields();
String[] conds = new String[fields.length];
for ( int i = 0; i < fields.length; ++i ) {
conds[i] = PrimitiveRdbCondition.newInstanceFromEntity( fields[i], entity ).toString();
}
return StringUtils.joinStrings( conds, " and " );
}
public Object createCreateStatement ( Object entity ) throws RdbException
{
return sql_create_part1 + getFieldValueListWithoutAutoincrement( entity ) + ")";
}
public Object createReadStatement ( Object entity ) throws RdbException
{
return sql_read_part1 + getConditionFromPrimaryKeyAndEntity( entity );
}
public Object createUpdateStatement ( Object entity ) throws RdbException
{
return sql_update_part1 + getUpdateFieldValueList( entity ) + " WHERE " + getConditionFromPrimaryKeyAndEntity( entity );
}
public Object createDeleteStatement ( Object entity ) throws RdbException
{
return sql_delete_part1 + getConditionFromPrimaryKeyAndEntity( entity );
}
public Object createReadAllStatement () throws RdbException
{
return sql_read_part1 + "1=1";
}
public Object createReadAllFilteredStatement ( PrimitiveRdbCondition filter ) throws RdbException
{
return sql_read_part1 + getCondition( filter ) + orderByClause;
}
public Object createReadAllFilteredStatement ( PrimitiveRdbCondition[] filters ) throws RdbException
{
String[] conds = new String[filters.length];
for ( int i = 0; i < filters.length; ++i ) conds[i] = getCondition( filters[i] );
return sql_read_part1 + StringUtils.joinStrings( conds, " AND " ) + orderByClause;
}
public Object createReadListStatement ( Object keyEntity ) throws RdbException
{
String[] conds = new String[cm.getListKey().length];
for ( int i = 0; i < cm.getListKey().length; ++i ) {
RdbField field = cm.getField( cm.getListKey()[i] );
conds[i] = field.getPropertyName() + "=" + field.getLiteralFromEntity( keyEntity );
}
return sql_read_part1 + StringUtils.joinStrings( conds, " AND " ) + orderByClause;
}
public Object createCreateTableStatement () throws RdbException
{
PrimaryKey key = cm.getPrimaryKey();
StringBuffer result = new StringBuffer( "CREATE TABLE " );
result.append( cm.getTableName() ).append( " ( " );
for ( int i = 0; i < cm.getFieldCount(); ++i ) {
RdbField field = cm.getField( i );
result.append( getSqlFieldDefinition( field, key ) ).append( ", " );
}
result.append( "PRIMARY KEY (" );
for ( int i = 0; i < key.getFields().length; ++i ) {
RdbField field = key.getFields()[i];
if ( i > 0 ) result.append( ", " );
result.append( field.getPropertyName() );
}
result.append( ") ) DEFAULT CHARSET=utf8;" );
return result.toString();
}
public Object createCountAllFilteredStatement ( PrimitiveRdbCondition filter ) throws RdbException
{
return sql_count_part1 + getCondition( filter ) + orderByClause;
}
private static String getSqlFieldDefinition ( RdbField field, PrimaryKey key )
{
RdbHelper globalHelper = new SqlHelper();
StringBuffer result = new StringBuffer();
result.append( field.getPropertyName() ).append( " " ).append( field.getRdbTypeName( globalHelper ) ).append( " " );
if ( field.isNullEnabled() ) {
result.append( "NULL" );
} else {
result.append( "NOT NULL" );
}
if ( key.isAutoIncrement() && key.hasField( field ) ) {
result.append( " auto_increment" );
}
return result.toString();
}
}
| 8,143 | 0.654181 | 0.649883 | 226 | 34.030975 | 32.119438 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.707965 | false | false | 2 |
69a720520710a752bfdfef2ca1794e0b23107633 | 15,599,321,230,464 | 823e79d8599e24c5aad6f091c160749fe7988e2c | /bookmanager/src/main/java/com/example/bookmanager/mapper/UserMapper.java | cd70d477d2d795553c7d210df72b87c37e906f96 | []
| no_license | ChengHaoWang/BookManager | https://github.com/ChengHaoWang/BookManager | fd35fda831dd40ade1cafd514bb7dceb7e3685a5 | 37a319efe85375c621ef4cf4a836b2aa4dbd62fa | refs/heads/main | 2023-01-06T19:24:01.782000 | 2020-11-04T08:36:25 | 2020-11-04T08:36:25 | 306,582,843 | 0 | 0 | null | false | 2020-11-04T08:36:26 | 2020-10-23T09:02:44 | 2020-10-27T08:59:58 | 2020-11-04T08:36:26 | 65 | 0 | 0 | 0 | Java | false | false | package com.example.bookmanager.mapper;
import com.example.bookmanager.model.vo.UserVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
@Component
public interface UserMapper {
//当该函数含有多个参数时,如果不加@Param注解,XML中的Mapper会找不到变量
int register(@Param("username") String usrename, @Param("password")String password,
@Param("nickname")String nickname, @Param("phonenumber")String phonenumber);
UserVO login(@Param("username")String username,@Param("password")String password);
}
| UTF-8 | Java | 598 | java | UserMapper.java | Java | []
| null | []
| package com.example.bookmanager.mapper;
import com.example.bookmanager.model.vo.UserVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
@Component
public interface UserMapper {
//当该函数含有多个参数时,如果不加@Param注解,XML中的Mapper会找不到变量
int register(@Param("username") String usrename, @Param("password")String password,
@Param("nickname")String nickname, @Param("phonenumber")String phonenumber);
UserVO login(@Param("username")String username,@Param("password")String password);
}
| 598 | 0.766544 | 0.766544 | 13 | 40.846153 | 31.688013 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.769231 | false | false | 2 |
1405aba950d2f71da26187b8a38235224e125f77 | 21,440,476,751,374 | cfabbf67278cbd23c536bf5555598cd674b4a22b | /vertx-spring-boot-starter-kafka/src/main/java/dev/snowdrop/vertx/kafka/SnowdropKafkaTimestampType.java | be3e0962c9441881b2a8f47129ed1bdc3530d7e3 | [
"Apache-2.0"
]
| permissive | theJCrakcer/vertx-spring-boot | https://github.com/theJCrakcer/vertx-spring-boot | d0ad0fe5a872cebd5e0d2e70702607fe7218f238 | 104a14f57222933cffd6f359af33de9bdf89aef2 | refs/heads/master | 2020-09-10T06:04:01.768000 | 2019-11-14T10:08:53 | 2019-11-14T10:08:53 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package dev.snowdrop.vertx.kafka;
import java.util.Objects;
import org.apache.kafka.common.record.TimestampType;
class SnowdropKafkaTimestampType implements KafkaTimestampType {
private final TimestampType delegate;
SnowdropKafkaTimestampType(TimestampType delegate) {
this.delegate = delegate;
}
@Override
public int getId() {
return delegate.id;
}
@Override
public String getName() {
return delegate.name;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SnowdropKafkaTimestampType that = (SnowdropKafkaTimestampType) o;
return delegate == that.delegate;
}
@Override
public int hashCode() {
return Objects.hash(delegate);
}
}
| UTF-8 | Java | 895 | java | SnowdropKafkaTimestampType.java | Java | []
| null | []
| package dev.snowdrop.vertx.kafka;
import java.util.Objects;
import org.apache.kafka.common.record.TimestampType;
class SnowdropKafkaTimestampType implements KafkaTimestampType {
private final TimestampType delegate;
SnowdropKafkaTimestampType(TimestampType delegate) {
this.delegate = delegate;
}
@Override
public int getId() {
return delegate.id;
}
@Override
public String getName() {
return delegate.name;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SnowdropKafkaTimestampType that = (SnowdropKafkaTimestampType) o;
return delegate == that.delegate;
}
@Override
public int hashCode() {
return Objects.hash(delegate);
}
}
| 895 | 0.620112 | 0.620112 | 43 | 19.813953 | 19.72751 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.325581 | false | false | 2 |
c573a112fe656ec658d26f095de029a994d6538c | 21,440,476,754,707 | a56fe3f9d2cd2c821899fd22a8cce7b9ca960dcd | /src/calculadora2/Main.java | 519806df49dd40eb02ed207b135a834d48de8869 | []
| no_license | veronicajn/calculator | https://github.com/veronicajn/calculator | 65aeb5d7aa468f19929ac39041160cb411e8416c | 005cfa45edeae33fd3467c0cbb361c80b154db9a | refs/heads/master | 2022-11-22T11:28:19.684000 | 2020-07-27T16:25:25 | 2020-07-27T16:25:25 | 282,952,743 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package calculadora2;
import Controlador.Controlador;
import Vista.Vista;
/**
*
* @author veronica
*/
public class Main {
public static void main(String[] args) {
Vista v = new Vista();
Controlador c = new Controlador(v);
c.run();
}
} | UTF-8 | Java | 477 | java | Main.java | Java | [
{
"context": "ontrolador;\nimport Vista.Vista;\n\n/**\n *\n * @author veronica\n */\npublic class Main {\n\n \n \n public static",
"end": 287,
"score": 0.9995011687278748,
"start": 279,
"tag": "USERNAME",
"value": "veronica"
}
]
| null | []
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package calculadora2;
import Controlador.Controlador;
import Vista.Vista;
/**
*
* @author veronica
*/
public class Main {
public static void main(String[] args) {
Vista v = new Vista();
Controlador c = new Controlador(v);
c.run();
}
} | 477 | 0.637317 | 0.63522 | 25 | 18.120001 | 21.032013 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.36 | false | false | 2 |
f366a9daf22cacd0324e269f6079cc25e96b8412 | 8,581,344,671,601 | be94b668b8a267410c68a6994ba90a1fa2527497 | /src/modelo/Pieza.java | 4459b37b0c35bd9991e58c57a5592a09220d9a60 | []
| no_license | JosemaVR/Ajedrez | https://github.com/JosemaVR/Ajedrez | 4a710268868b7cf926a7508de8d53eea25144279 | 7621981abf692f85ffd57c8d0b7683b6cb365b3d | refs/heads/master | 2022-11-17T14:26:24.473000 | 2020-07-09T15:42:28 | 2020-07-09T15:42:28 | 257,197,620 | 0 | 0 | null | false | 2020-07-09T15:42:29 | 2020-04-20T06:58:14 | 2020-07-09T15:03:29 | 2020-07-09T15:42:29 | 1,592 | 0 | 0 | 0 | Java | false | false | package modelo;
import javax.swing.Icon;
import javax.swing.ImageIcon;
public class Pieza {
public ColorPieza colorPieza;
public TipoPieza tipoPieza;
public Integer x, y;
public Icon icono;
public Pieza() {
this.colorPieza = ColorPieza.BLANCO;
this.tipoPieza = TipoPieza.PEON;
this.x = 0;
this.y = 0;
this.icono = null;
}
public Pieza(ColorPieza colorPieza, TipoPieza tipoPieza, Integer y, Integer x) {
this.colorPieza = colorPieza;
this.tipoPieza = tipoPieza;
this.x = x;
this.y = y;
if(tipoPieza == TipoPieza.ALFIL) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Alfil_blanco.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Alfil_negro.png");
}
}
else if(tipoPieza == TipoPieza.CABALLO) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Caballo_blanco.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Caballo_negro.png");
}
}
else if(tipoPieza == TipoPieza.PEON) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Peon_blanco.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Peon_negro.png");
}
}
else if(tipoPieza == TipoPieza.TORRE) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Torre_blanca.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Torre_negra.png");
}
}
else if(tipoPieza == TipoPieza.REINA) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Reina_blanca.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Reina_negra.png");
}
}
else if(tipoPieza == TipoPieza.REY) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Rey_blanco.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Rey_negro.png");
}
}
}
public ColorPieza getColorPieza() {
return colorPieza;
}
public void setColorPieza(ColorPieza colorPieza) {
this.colorPieza = colorPieza;
}
public TipoPieza getTipoPieza() {
return tipoPieza;
}
public void setTipoPieza(TipoPieza tipoPieza) {
this.tipoPieza = tipoPieza;
}
public Integer getX() {
return x;
}
public void setX(Integer x) {
this.x = x;
}
public Integer getY() {
return y;
}
public void setY(Integer y) {
this.y = y;
}
public Icon getIcono() {
return icono;
}
public void setIcono(Icon icono) {
this.icono = icono;
}
public String toString() {
return "Es un/a " + getTipoPieza() + " de color " + getColorPieza() + ", comienza en la posicion " + getX() + ", " + getY();
}
}
| UTF-8 | Java | 3,070 | java | Pieza.java | Java | []
| null | []
| package modelo;
import javax.swing.Icon;
import javax.swing.ImageIcon;
public class Pieza {
public ColorPieza colorPieza;
public TipoPieza tipoPieza;
public Integer x, y;
public Icon icono;
public Pieza() {
this.colorPieza = ColorPieza.BLANCO;
this.tipoPieza = TipoPieza.PEON;
this.x = 0;
this.y = 0;
this.icono = null;
}
public Pieza(ColorPieza colorPieza, TipoPieza tipoPieza, Integer y, Integer x) {
this.colorPieza = colorPieza;
this.tipoPieza = tipoPieza;
this.x = x;
this.y = y;
if(tipoPieza == TipoPieza.ALFIL) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Alfil_blanco.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Alfil_negro.png");
}
}
else if(tipoPieza == TipoPieza.CABALLO) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Caballo_blanco.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Caballo_negro.png");
}
}
else if(tipoPieza == TipoPieza.PEON) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Peon_blanco.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Peon_negro.png");
}
}
else if(tipoPieza == TipoPieza.TORRE) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Torre_blanca.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Torre_negra.png");
}
}
else if(tipoPieza == TipoPieza.REINA) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Reina_blanca.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Reina_negra.png");
}
}
else if(tipoPieza == TipoPieza.REY) {
if(colorPieza == ColorPieza.BLANCO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Rey_blanco.png");
}
else if(colorPieza == ColorPieza.NEGRO) {
this.icono = new ImageIcon("imagenes/sin_fondo/Rey_negro.png");
}
}
}
public ColorPieza getColorPieza() {
return colorPieza;
}
public void setColorPieza(ColorPieza colorPieza) {
this.colorPieza = colorPieza;
}
public TipoPieza getTipoPieza() {
return tipoPieza;
}
public void setTipoPieza(TipoPieza tipoPieza) {
this.tipoPieza = tipoPieza;
}
public Integer getX() {
return x;
}
public void setX(Integer x) {
this.x = x;
}
public Integer getY() {
return y;
}
public void setY(Integer y) {
this.y = y;
}
public Icon getIcono() {
return icono;
}
public void setIcono(Icon icono) {
this.icono = icono;
}
public String toString() {
return "Es un/a " + getTipoPieza() + " de color " + getColorPieza() + ", comienza en la posicion " + getX() + ", " + getY();
}
}
| 3,070 | 0.643974 | 0.643322 | 119 | 23.798319 | 24.406082 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.193277 | false | false | 2 |
137d183c68b544e2086a988eb956e5cfcea53311 | 30,803,505,456,698 | 03771b6848625698f80dbf333a6352dfdb3f7458 | /Backend/src/com/TrackerController/TrackerControl_SocketConnector.java | 88372a8a417c94a13d7b7737eb3882b6988a986f | []
| no_license | Percelic/2019_Spring_Public_SCMS_GS | https://github.com/Percelic/2019_Spring_Public_SCMS_GS | 04a9e46efa6a0ff1c427f0d34103e0b8f05a4a34 | 97006298368052571ed63a62912c6b853b147cfa | refs/heads/main | 2023-07-14T05:36:05.416000 | 2021-08-31T00:23:04 | 2021-08-31T00:23:04 | 401,392,999 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.TrackerController;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;
import com.Common.CustomQueue;
import com.Common.Utils;
public class TrackerControl_SocketConnector {
private ServerSocket server;
private Socket socket = new Socket();
private CustomQueue<Short> PushQueue;
private CustomQueue<short[]> PopQueue;
private int Socket_port;
private Thread ServerAccept_Thread;
public TrackerControl_SocketConnector(int _port)
{
Socket_port = _port;
}
public boolean Socket_Server_Open()
{
try {
server = new ServerSocket(Socket_port);
TrackerControlManager.logger.info("[ TrackerController ] Tracker Control Server Port " + Socket_port + " Open.");
TrackerControlManager.logger.info("[ TrackerController ] Socket Server Open finished Successfully..");
return true;
} catch(Exception e) {
TrackerControlManager.logger.error("[ TrackerController ] Failed to Open Server Port :: " + e.toString());
return false;
}
}
@SuppressWarnings("unused")
public void Socket_Server_Accept() {
ServerAccept_Thread = new Thread(new Runnable() {
@Override
public void run() {
try {
while(true) {
socket = server.accept();
ThreadServerHandler handler = new ThreadServerHandler(socket, PushQueue);
//handler.interrupt(); // closing ThreadServerHandler Thread
TrackerControlManager.logger.info("[ TrackerController ] [WebSocket] " + socket.getRemoteSocketAddress().toString().replace("/", "") + " has connected");
Thread.sleep(1);
}
} catch(Exception e) {
TrackerControlManager.logger.error("[ TrackerController ] Failed to Accept From Server Port :: " + e.toString());
}
}
});
ServerAccept_Thread.start();
}
public boolean Socket_Server_Close() {
try {
server.close();
return server.isClosed();
} catch(Exception e) {
TrackerControlManager.logger.error("[ TrackerController ] Failed to Close Server Port :: " + e.toString());
return false;
}
}
public void Socket_Server_SetPushQueue(CustomQueue<Short> _nQueue)
{
PushQueue = _nQueue;
}
public void Socket_Server_SetPopQueue(CustomQueue<short[]> _nQueue)
{
PopQueue = _nQueue;
}
}
class ThreadServerHandler extends Thread {
Socket clientSocket;
CustomQueue<Short> nQueue;
public ThreadServerHandler(Socket _socket, CustomQueue<Short> _nQueue) {
clientSocket = _socket;
nQueue = _nQueue;
start();
}
@Override
public void run() {
// TODO Auto-generated method stub
try {
InputStream is = clientSocket.getInputStream();
String _szHandshake = "";
int ReadByte = 0;
byte[] _bytArr;
clientSocket.setSoTimeout(5000);
while(true) { // Step of Verify Web Socket Protocol
_szHandshake += String.format("%c",ReadByte = is.read());
if(is.available() == 0) {
//Debug
//System.out.println("_szHandshake :: " + _szHandshake);
if(WSocket_Handshaker(_szHandshake)) {
_szHandshake = "";
}
else {
clientSocket.close();
System.out.println("[ TrackerController ] Handshake failed.. client disconnected");
}
break;
}
else if(ReadByte == -1) {
TrackerControlManager.logger.debug("[ TrackerController ] WebSocket Thread for " + clientSocket.getRemoteSocketAddress().toString().replace("/", "") + " has killed.");
break;
}
}
clientSocket.setSoTimeout(600000);
while(true) {
if((ReadByte = is.read()) == -1) {
TrackerControlManager.logger.debug("[ TrackerController ] WebSocket Thread for " + clientSocket.getRemoteSocketAddress().toString().replace("/", "") + " has killed.");
break;
}
else if(is.available() > 0) {
synchronized(nQueue) {
nQueue.Enqueue((short)ReadByte);
while((is.available()) > 0) {
//ReadByte = ReadByte & 0xFF;
//System.out.println("# Socket Receive Byte :" + ReadByte);
//synchronized(nQueue) {
nQueue.Enqueue((short)is.read());
if(is.available() == 0) {
//nQueue.Enqueue((short)0x00); // ETX�� Ȯ���� �����ϱ� ���� ETX ������ null�� �߰��Ѵ�.
System.out.println();//System.out.println(clientSocket.getRemoteSocketAddress() + " has disconnected.");
}
if(this.isInterrupted()) break;
}
}
}
//System.out.println("aaa");
Thread.sleep(1);
}
} catch(Exception e) {
System.out.println("[ TrackerController ] Failed to Receive Message From Server :: " + e.toString());
if(clientSocket != null) {
try {
clientSocket.close();
} catch(Exception _e) {
_e.printStackTrace();
}
finally {
clientSocket = null;
}
}
}
}
private boolean WSocket_Handshaker(String _pkt) {
String recvMsg = "";
String[] _strArr = _pkt.split("\r\n");
try {
HashMap<String , String> Hash = new HashMap<String, String>();
for(String s : _strArr) {
String[] _sa = s.split(":");
if(_sa.length > 2) {
Hash.put(_sa[0], _sa[1] + _sa[2]);
}
else if(_sa.length == 2)
Hash.put(_sa[0],_sa[1]);
}
//System.out.println(Hash.get("Sec-WebSocket-Key").trim() + " -> " + new String(Util.EncryptWSKey(Hash.get("Sec-WebSocket-Key").trim())));
if(Hash.size() > 0 && !Hash.get("Sec-WebSocket-Key").equals(null)) {
String sendMsg = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" +
"Connection: Upgrade\r\n" +
"Sec-WebSocket-Accept: " + new String(Utils.EncryptWSKey(Hash.get("Sec-WebSocket-Key").trim())) + "\r\n" +
"Server: Tracker Control\r\n" +
"Upgrade: websocket\r\n\r\n";
//"Sec-WebSocket-Protocol: chat\r\n" + ;
//System.out.println(sendMsg);
//System.out.println("Bytes :[" + new String(sendMsg.getBytes()) + "]");
clientSocket.getOutputStream().write(sendMsg.getBytes());
}
} catch(Exception e) {
e.printStackTrace();
return false;
}
return true;
}
}
| UTF-8 | Java | 6,141 | java | TrackerControl_SocketConnector.java | Java | []
| null | []
| package com.TrackerController;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;
import com.Common.CustomQueue;
import com.Common.Utils;
public class TrackerControl_SocketConnector {
private ServerSocket server;
private Socket socket = new Socket();
private CustomQueue<Short> PushQueue;
private CustomQueue<short[]> PopQueue;
private int Socket_port;
private Thread ServerAccept_Thread;
public TrackerControl_SocketConnector(int _port)
{
Socket_port = _port;
}
public boolean Socket_Server_Open()
{
try {
server = new ServerSocket(Socket_port);
TrackerControlManager.logger.info("[ TrackerController ] Tracker Control Server Port " + Socket_port + " Open.");
TrackerControlManager.logger.info("[ TrackerController ] Socket Server Open finished Successfully..");
return true;
} catch(Exception e) {
TrackerControlManager.logger.error("[ TrackerController ] Failed to Open Server Port :: " + e.toString());
return false;
}
}
@SuppressWarnings("unused")
public void Socket_Server_Accept() {
ServerAccept_Thread = new Thread(new Runnable() {
@Override
public void run() {
try {
while(true) {
socket = server.accept();
ThreadServerHandler handler = new ThreadServerHandler(socket, PushQueue);
//handler.interrupt(); // closing ThreadServerHandler Thread
TrackerControlManager.logger.info("[ TrackerController ] [WebSocket] " + socket.getRemoteSocketAddress().toString().replace("/", "") + " has connected");
Thread.sleep(1);
}
} catch(Exception e) {
TrackerControlManager.logger.error("[ TrackerController ] Failed to Accept From Server Port :: " + e.toString());
}
}
});
ServerAccept_Thread.start();
}
public boolean Socket_Server_Close() {
try {
server.close();
return server.isClosed();
} catch(Exception e) {
TrackerControlManager.logger.error("[ TrackerController ] Failed to Close Server Port :: " + e.toString());
return false;
}
}
public void Socket_Server_SetPushQueue(CustomQueue<Short> _nQueue)
{
PushQueue = _nQueue;
}
public void Socket_Server_SetPopQueue(CustomQueue<short[]> _nQueue)
{
PopQueue = _nQueue;
}
}
class ThreadServerHandler extends Thread {
Socket clientSocket;
CustomQueue<Short> nQueue;
public ThreadServerHandler(Socket _socket, CustomQueue<Short> _nQueue) {
clientSocket = _socket;
nQueue = _nQueue;
start();
}
@Override
public void run() {
// TODO Auto-generated method stub
try {
InputStream is = clientSocket.getInputStream();
String _szHandshake = "";
int ReadByte = 0;
byte[] _bytArr;
clientSocket.setSoTimeout(5000);
while(true) { // Step of Verify Web Socket Protocol
_szHandshake += String.format("%c",ReadByte = is.read());
if(is.available() == 0) {
//Debug
//System.out.println("_szHandshake :: " + _szHandshake);
if(WSocket_Handshaker(_szHandshake)) {
_szHandshake = "";
}
else {
clientSocket.close();
System.out.println("[ TrackerController ] Handshake failed.. client disconnected");
}
break;
}
else if(ReadByte == -1) {
TrackerControlManager.logger.debug("[ TrackerController ] WebSocket Thread for " + clientSocket.getRemoteSocketAddress().toString().replace("/", "") + " has killed.");
break;
}
}
clientSocket.setSoTimeout(600000);
while(true) {
if((ReadByte = is.read()) == -1) {
TrackerControlManager.logger.debug("[ TrackerController ] WebSocket Thread for " + clientSocket.getRemoteSocketAddress().toString().replace("/", "") + " has killed.");
break;
}
else if(is.available() > 0) {
synchronized(nQueue) {
nQueue.Enqueue((short)ReadByte);
while((is.available()) > 0) {
//ReadByte = ReadByte & 0xFF;
//System.out.println("# Socket Receive Byte :" + ReadByte);
//synchronized(nQueue) {
nQueue.Enqueue((short)is.read());
if(is.available() == 0) {
//nQueue.Enqueue((short)0x00); // ETX�� Ȯ���� �����ϱ� ���� ETX ������ null�� �߰��Ѵ�.
System.out.println();//System.out.println(clientSocket.getRemoteSocketAddress() + " has disconnected.");
}
if(this.isInterrupted()) break;
}
}
}
//System.out.println("aaa");
Thread.sleep(1);
}
} catch(Exception e) {
System.out.println("[ TrackerController ] Failed to Receive Message From Server :: " + e.toString());
if(clientSocket != null) {
try {
clientSocket.close();
} catch(Exception _e) {
_e.printStackTrace();
}
finally {
clientSocket = null;
}
}
}
}
private boolean WSocket_Handshaker(String _pkt) {
String recvMsg = "";
String[] _strArr = _pkt.split("\r\n");
try {
HashMap<String , String> Hash = new HashMap<String, String>();
for(String s : _strArr) {
String[] _sa = s.split(":");
if(_sa.length > 2) {
Hash.put(_sa[0], _sa[1] + _sa[2]);
}
else if(_sa.length == 2)
Hash.put(_sa[0],_sa[1]);
}
//System.out.println(Hash.get("Sec-WebSocket-Key").trim() + " -> " + new String(Util.EncryptWSKey(Hash.get("Sec-WebSocket-Key").trim())));
if(Hash.size() > 0 && !Hash.get("Sec-WebSocket-Key").equals(null)) {
String sendMsg = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" +
"Connection: Upgrade\r\n" +
"Sec-WebSocket-Accept: " + new String(Utils.EncryptWSKey(Hash.get("Sec-WebSocket-Key").trim())) + "\r\n" +
"Server: Tracker Control\r\n" +
"Upgrade: websocket\r\n\r\n";
//"Sec-WebSocket-Protocol: chat\r\n" + ;
//System.out.println(sendMsg);
//System.out.println("Bytes :[" + new String(sendMsg.getBytes()) + "]");
clientSocket.getOutputStream().write(sendMsg.getBytes());
}
} catch(Exception e) {
e.printStackTrace();
return false;
}
return true;
}
}
| 6,141 | 0.620786 | 0.614866 | 223 | 26.269058 | 31.583321 | 173 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.695067 | false | false | 2 |
d96d0f3973a2a979a7986d9fcd304a96ee0ac54e | 33,724,083,216,937 | 881cf8e7bae187298ce4a51a7c0691a4c19fdb52 | /BreakDown-services/src/main/java/hu/unideb/inf/dandy/szd/service/dto/Competition.java | 6f68dee523894b71011d751f9488867b42fbd1a5 | []
| no_license | NDBman/BreakDownApp | https://github.com/NDBman/BreakDownApp | ee029438defc31f60f97d745edee4affaa2ab921 | f72f9802a188d849f75338345f2269c984d86608 | refs/heads/master | 2021-03-30T17:41:20.777000 | 2017-05-04T11:11:28 | 2017-05-04T11:11:28 | 83,302,713 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package hu.unideb.inf.dandy.szd.service.dto;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Competition extends AbstractEvent{
private Long id;
private List<String> diskJockeys;
private String organizerId;
private List<BreakEvent> breakEvents;
private List<SimpleEvent> simpleEvents;
private List<Long> competitorIds;
private String description;
private Location location;
private boolean finished;
private List<Winner> winners;
}
| UTF-8 | Java | 632 | java | Competition.java | Java | []
| null | []
| package hu.unideb.inf.dandy.szd.service.dto;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Competition extends AbstractEvent{
private Long id;
private List<String> diskJockeys;
private String organizerId;
private List<BreakEvent> breakEvents;
private List<SimpleEvent> simpleEvents;
private List<Long> competitorIds;
private String description;
private Location location;
private boolean finished;
private List<Winner> winners;
}
| 632 | 0.816456 | 0.816456 | 28 | 21.571428 | 13.944862 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.964286 | false | false | 2 |
32b3bb089e7c133762101d0a80a7a415456da100 | 18,236,431,149,112 | 828dd84d5adf8ade2e1ad3563662e18f1c9545d1 | /src/interpreter/DisconnectCommand.java | e1325a02674b7adc85d2c4a25996d42668ed4090 | []
| no_license | jonathanmorag/FlightSimGUI | https://github.com/jonathanmorag/FlightSimGUI | 0b1129128d86eab6e32f1a0bb49bd484ed1091b4 | 08b9063007577121b981c139909b5e87dfe2a3cc | refs/heads/master | 2021-07-23T10:38:15.544000 | 2020-06-18T14:41:58 | 2020-06-18T14:41:58 | 186,300,361 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package interpreter;
import java.io.IOException;
import java.io.PrintWriter;
public class DisconnectCommand implements Command {
@Override
public void execute(String[] line) {
try {
PrintWriter out = new PrintWriter(ConnectCommand.server.getOutputStream());
out.println("bye");
out.flush();
} catch (IOException e) {}
}
}
| UTF-8 | Java | 360 | java | DisconnectCommand.java | Java | []
| null | []
| package interpreter;
import java.io.IOException;
import java.io.PrintWriter;
public class DisconnectCommand implements Command {
@Override
public void execute(String[] line) {
try {
PrintWriter out = new PrintWriter(ConnectCommand.server.getOutputStream());
out.println("bye");
out.flush();
} catch (IOException e) {}
}
}
| 360 | 0.688889 | 0.688889 | 17 | 19.17647 | 20.734272 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.352941 | false | false | 2 |
04b6e04982eb976ce59278523a3e1c0de053117a | 18,236,431,148,294 | 08782e58e062bee08883b755c896914340b3f2d2 | /src/main/java/br/com/ml/entity/DNA.java | 4fde06530705af4efe7c3be913cc9d9d8f73e779 | []
| no_license | ricardoruas88/RecrutamentoMagneto | https://github.com/ricardoruas88/RecrutamentoMagneto | 71e13d6dd33d9b352d783b79e372ca80650a6864 | 4bbc0752eea0ae4dbd3deece43cc59e172c9a885 | refs/heads/master | 2020-04-17T00:15:12.399000 | 2019-01-17T02:29:25 | 2019-01-17T02:29:25 | 166,042,721 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.ml.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@Entity(name="DNA")
@RequiredArgsConstructor
public class DNA {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Getter
@Setter
int id;
@Getter
@Setter
@Column(name="DNA", nullable=false)
@NonNull
private String[] dna;
@Getter
@Setter
@Column(name="mutante", nullable=false)
@NonNull
private boolean mutante;
}
| UTF-8 | Java | 668 | java | DNA.java | Java | []
| null | []
| package br.com.ml.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@Entity(name="DNA")
@RequiredArgsConstructor
public class DNA {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Getter
@Setter
int id;
@Getter
@Setter
@Column(name="DNA", nullable=false)
@NonNull
private String[] dna;
@Getter
@Setter
@Column(name="mutante", nullable=false)
@NonNull
private boolean mutante;
}
| 668 | 0.751497 | 0.751497 | 45 | 13.844444 | 14.257872 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.911111 | false | false | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.