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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9c585faa48f7cbd780f9072146b70a5244557f98 | 21,560,735,839,095 | d1b08409ae6b5492a872e0e46c9319d1a4039b0e | /ASN_Application/src/main/java/at/qe/sepm/asn_app/configs/NotificationConfig.java | 0763c520fb82fb76a2296b4867625786ca08e409 | [] | no_license | PatrikSchweigl/SEPM | https://github.com/PatrikSchweigl/SEPM | d84de5a836615221b9ca62f7f3ae284127007500 | ad4d675a09e21269ae3011c679c1798347a0c37c | refs/heads/master | 2020-12-02T18:08:24.788000 | 2017-06-22T21:28:50 | 2017-06-22T21:28:50 | 96,478,557 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package at.qe.sepm.asn_app.configs;
import at.qe.sepm.asn_app.models.UserData;
import at.qe.sepm.asn_app.models.child.Child;
import at.qe.sepm.asn_app.models.nursery.Lunch;
import at.qe.sepm.asn_app.models.nursery.Task;
import at.qe.sepm.asn_app.models.referencePerson.Parent;
import at.qe.sepm.asn_app.services.LunchService;
import at.qe.sepm.asn_app.services.MailService;
import at.qe.sepm.asn_app.services.ParentService;
import at.qe.sepm.asn_app.services.TaskService;
import at.qe.sepm.asn_app.services.UserService;
import at.qe.sepm.asn_app.ui.controllers.ReportController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by Stefan Mattersberger <stefan.mattersberger@student.uibk.ac.at> on
* 05.06.2017
*/
@Configuration
@EnableScheduling
public class NotificationConfig {
@Autowired
private MailService mailService;
@Autowired
private UserService userService;
@Autowired
private ParentService parentService;
@Autowired
private TaskService taskService;
@Autowired
private LunchService lunchService;
@Scheduled(cron = "0 0 10 * * *") // 60000 for one minute - "0 0 10 * * *"
// 10 AM everyday
public void taskReminder() {
Collection<UserData> list = userService.getParentsByNotification();
String footer = "Das Kinderkrippen-Team bedankt sich für Ihre Mitarbeit!";
Date today = new Date();
Date dateToCompare = new Date();
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Vienna"));
cal.setTime(today);
int hrs = cal.get(Calendar.HOUR_OF_DAY);
int min = cal.get(Calendar.MINUTE);
int sec = cal.get(Calendar.SECOND);
int milli = cal.get(Calendar.MILLISECOND);
today.setTime(today.getTime() - (min * 60 * 1000) - (hrs * 60 * 60 * 1000) - (sec * 1000) - milli);
if (!list.isEmpty()) {
Iterator<UserData> itL = list.iterator();
while (itL.hasNext()) {
Parent p = parentService.loadParent(itL.next().getUsername());
String taskMsg = "";
boolean send = false;
Collection<Task> tasks = taskService.getAllTasksByReceiver(p.getUsername());
Iterator<Task> itT = tasks.iterator();
while (itT.hasNext()) {
Task t = itT.next();
cal.setTime(t.getBeginDate());
hrs = cal.get(Calendar.HOUR_OF_DAY);
min = cal.get(Calendar.MINUTE);
dateToCompare.setTime(t.getBeginDate().getTime() - (min * 60 * 1000) - (hrs * 60 * 60 * 1000));
if ((dateToCompare.getTime() - today.getTime()) == 345600000) { // 4
// days
// before
// the
// task
send = true;
taskMsg += t.getDescription() + "\t|\t" + t.getFormattedDate(t.getBeginDate()) + "\t|\t"
+ t.getFormattedDate(t.getEndingDate()) + "\n";
}
}
if (send) {
mailService.sendEmail(p.getEmail(), "Erinnerung - Anstehende Aufgaben",
"Guten Tag " + p.getFirstName() + " " + p.getLastName()
+ "!\n\nSie haben noch 4 Tage zeit, um folgende Aufgabe(n) zu erledigen:\n\n"
+ taskMsg + "\n\n" + footer);
}
}
}
}
@Scheduled(cron = "0 10 10 28-31 * ?")
public void monthlyLunchCalc() {
String footer = "Das Kinderkrippen-Team bedankt sich für Ihre Mitarbeit!";
Collection<Parent> list = parentService.getAllParents();
Iterator<Parent> iter = list.iterator();
while (iter.hasNext()) {
double costPerMonth = 0.0;
Parent p = iter.next();
for (Child c : p.getChildren()) {
Date start = new Date();
start.setDate(1);
start.setMonth((start.getMonth() + 0)%12);
Date end = new Date();
end.setDate(1);
end.setMonth((end.getMonth() + 0 + 1)%12);
if(end.getMonth() == 0){
end.setYear(end.getYear() + 1);
}
Collection<Lunch> lunch = lunchService.getLunchInTimeWindowIE(start, end);
for(Lunch l : lunch){
if(l.getChildrenIds().contains(c.getId()))
costPerMonth += l.getCost();
}
}
mailService.sendEmail(p.getEmail(), "Essensabrechnung",
"Guten Tag " + p.getFirstName() + " " + p.getLastName()
+ "!\n\nWir senden Ihnen die monatliche Abrechnung für die konsumierten Mahlzeiten.:\n\n"
+ "Offener Betrag: " + costPerMonth + " zahlbar binnen 14 Tagen."
+ "\n\n" + footer);
}
}
}
| UTF-8 | Java | 4,551 | java | NotificationConfig.java | Java | [
{
"context": "DateFormat;\nimport java.util.*;\n\n/**\n * Created by Stefan Mattersberger <stefan.mattersberger@student.uibk.ac.at> on\n * 0",
"end": 927,
"score": 0.9999036192893982,
"start": 907,
"tag": "NAME",
"value": "Stefan Mattersberger"
},
{
"context": ".util.*;\n\n/**\n * Created by Stefan Mattersberger <stefan.mattersberger@student.uibk.ac.at> on\n * 05.06.2017\n */\n@Configuration\n@EnableSched",
"end": 968,
"score": 0.9999277591705322,
"start": 929,
"tag": "EMAIL",
"value": "stefan.mattersberger@student.uibk.ac.at"
}
] | null | [] | package at.qe.sepm.asn_app.configs;
import at.qe.sepm.asn_app.models.UserData;
import at.qe.sepm.asn_app.models.child.Child;
import at.qe.sepm.asn_app.models.nursery.Lunch;
import at.qe.sepm.asn_app.models.nursery.Task;
import at.qe.sepm.asn_app.models.referencePerson.Parent;
import at.qe.sepm.asn_app.services.LunchService;
import at.qe.sepm.asn_app.services.MailService;
import at.qe.sepm.asn_app.services.ParentService;
import at.qe.sepm.asn_app.services.TaskService;
import at.qe.sepm.asn_app.services.UserService;
import at.qe.sepm.asn_app.ui.controllers.ReportController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by <NAME> <<EMAIL>> on
* 05.06.2017
*/
@Configuration
@EnableScheduling
public class NotificationConfig {
@Autowired
private MailService mailService;
@Autowired
private UserService userService;
@Autowired
private ParentService parentService;
@Autowired
private TaskService taskService;
@Autowired
private LunchService lunchService;
@Scheduled(cron = "0 0 10 * * *") // 60000 for one minute - "0 0 10 * * *"
// 10 AM everyday
public void taskReminder() {
Collection<UserData> list = userService.getParentsByNotification();
String footer = "Das Kinderkrippen-Team bedankt sich für Ihre Mitarbeit!";
Date today = new Date();
Date dateToCompare = new Date();
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Vienna"));
cal.setTime(today);
int hrs = cal.get(Calendar.HOUR_OF_DAY);
int min = cal.get(Calendar.MINUTE);
int sec = cal.get(Calendar.SECOND);
int milli = cal.get(Calendar.MILLISECOND);
today.setTime(today.getTime() - (min * 60 * 1000) - (hrs * 60 * 60 * 1000) - (sec * 1000) - milli);
if (!list.isEmpty()) {
Iterator<UserData> itL = list.iterator();
while (itL.hasNext()) {
Parent p = parentService.loadParent(itL.next().getUsername());
String taskMsg = "";
boolean send = false;
Collection<Task> tasks = taskService.getAllTasksByReceiver(p.getUsername());
Iterator<Task> itT = tasks.iterator();
while (itT.hasNext()) {
Task t = itT.next();
cal.setTime(t.getBeginDate());
hrs = cal.get(Calendar.HOUR_OF_DAY);
min = cal.get(Calendar.MINUTE);
dateToCompare.setTime(t.getBeginDate().getTime() - (min * 60 * 1000) - (hrs * 60 * 60 * 1000));
if ((dateToCompare.getTime() - today.getTime()) == 345600000) { // 4
// days
// before
// the
// task
send = true;
taskMsg += t.getDescription() + "\t|\t" + t.getFormattedDate(t.getBeginDate()) + "\t|\t"
+ t.getFormattedDate(t.getEndingDate()) + "\n";
}
}
if (send) {
mailService.sendEmail(p.getEmail(), "Erinnerung - Anstehende Aufgaben",
"Guten Tag " + p.getFirstName() + " " + p.getLastName()
+ "!\n\nSie haben noch 4 Tage zeit, um folgende Aufgabe(n) zu erledigen:\n\n"
+ taskMsg + "\n\n" + footer);
}
}
}
}
@Scheduled(cron = "0 10 10 28-31 * ?")
public void monthlyLunchCalc() {
String footer = "Das Kinderkrippen-Team bedankt sich für Ihre Mitarbeit!";
Collection<Parent> list = parentService.getAllParents();
Iterator<Parent> iter = list.iterator();
while (iter.hasNext()) {
double costPerMonth = 0.0;
Parent p = iter.next();
for (Child c : p.getChildren()) {
Date start = new Date();
start.setDate(1);
start.setMonth((start.getMonth() + 0)%12);
Date end = new Date();
end.setDate(1);
end.setMonth((end.getMonth() + 0 + 1)%12);
if(end.getMonth() == 0){
end.setYear(end.getYear() + 1);
}
Collection<Lunch> lunch = lunchService.getLunchInTimeWindowIE(start, end);
for(Lunch l : lunch){
if(l.getChildrenIds().contains(c.getId()))
costPerMonth += l.getCost();
}
}
mailService.sendEmail(p.getEmail(), "Essensabrechnung",
"Guten Tag " + p.getFirstName() + " " + p.getLastName()
+ "!\n\nWir senden Ihnen die monatliche Abrechnung für die konsumierten Mahlzeiten.:\n\n"
+ "Offener Betrag: " + costPerMonth + " zahlbar binnen 14 Tagen."
+ "\n\n" + footer);
}
}
}
| 4,505 | 0.652375 | 0.632586 | 129 | 34.255814 | 25.762566 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.248062 | false | false | 15 |
b15b3ae1241e59e9d83360826e7dda823732d8f3 | 2,070,174,278,968 | 3bfdd3781df5048a73a56e46a8ab5717ed12c676 | /src/main/java/com/tc/yuxiu/service/impl/TyStoreServiceImpl.java | fab251f50ad59de8ae39e7b056c8737aa0571914 | [] | no_license | Gemmmm/yuxiu | https://github.com/Gemmmm/yuxiu | e9ae2e26c045f401d5cdb746fccfa02f1e0e147a | 35e690366ea919563a15ea9f8696d94832a96cd7 | refs/heads/master | 2023-02-12T16:11:36.300000 | 2021-01-12T05:56:09 | 2021-01-12T05:56:09 | 327,478,215 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tc.yuxiu.service.impl;
import com.tc.yuxiu.dao.TyStoreMapper;
import com.tc.yuxiu.model.TyStore;
import com.tc.yuxiu.service.TyStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author DELL
* @date 2020/9/16 15:18
*/
@Service
public class TyStoreServiceImpl implements TyStoreService {
@Autowired(required = false)
private TyStoreMapper mapper;
@Override
public TyStore getById(Integer id) {
return mapper.selectByPrimaryKey(id);
}
@Override
public Integer modify(TyStore store) {
return mapper.updateByPrimaryKeySelective(store);
}
}
| UTF-8 | Java | 681 | java | TyStoreServiceImpl.java | Java | [
{
"context": "pringframework.stereotype.Service;\n\n/**\n * @author DELL\n * @date 2020/9/16 15:18\n */\n@Service\npublic clas",
"end": 284,
"score": 0.999328076839447,
"start": 280,
"tag": "USERNAME",
"value": "DELL"
}
] | null | [] | package com.tc.yuxiu.service.impl;
import com.tc.yuxiu.dao.TyStoreMapper;
import com.tc.yuxiu.model.TyStore;
import com.tc.yuxiu.service.TyStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author DELL
* @date 2020/9/16 15:18
*/
@Service
public class TyStoreServiceImpl implements TyStoreService {
@Autowired(required = false)
private TyStoreMapper mapper;
@Override
public TyStore getById(Integer id) {
return mapper.selectByPrimaryKey(id);
}
@Override
public Integer modify(TyStore store) {
return mapper.updateByPrimaryKeySelective(store);
}
}
| 681 | 0.743025 | 0.726872 | 26 | 25.192308 | 20.160929 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.346154 | false | false | 15 |
ffa55384e4e174791038a38e40b7cbbc575a4be2 | 23,708,219,530,575 | 7a63d774681b27f05f3c46c15c73bf6b9564932d | /backend/src/main/java/tr/com/bilkent/fods/dto/search/SearchDTO.java | 46750738d43ce6de53f7ad66f98e19ac39d5b111 | [] | no_license | bilkent-2021-spring-cs353-g21/food-ordering-and-delivery | https://github.com/bilkent-2021-spring-cs353-g21/food-ordering-and-delivery | f65038b36e90e4d704c92afe268f9c7e95caf813 | 0f9a34eb123e0eafe6f88cc8d4f118ae5cf9f470 | refs/heads/master | 2023-05-02T21:39:51.186000 | 2021-05-17T20:50:57 | 2021-05-17T20:50:57 | 341,817,491 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tr.com.bilkent.fods.dto.search;
import lombok.Data;
import lombok.NoArgsConstructor;
import tr.com.bilkent.fods.dto.district.DistrictDTO;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor
public class SearchDTO {
@NotNull
@NotEmpty
private String keyword;
@Valid
@NotNull
private DistrictDTO district;
// Filters
private Boolean onlyServingDistrict;
private Double scoreAtLeast;
private Double minPrice;
private Double maxPrice;
private Double maxMinDeliveryCost;
}
| UTF-8 | Java | 624 | java | SearchDTO.java | Java | [] | null | [] | package tr.com.bilkent.fods.dto.search;
import lombok.Data;
import lombok.NoArgsConstructor;
import tr.com.bilkent.fods.dto.district.DistrictDTO;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor
public class SearchDTO {
@NotNull
@NotEmpty
private String keyword;
@Valid
@NotNull
private DistrictDTO district;
// Filters
private Boolean onlyServingDistrict;
private Double scoreAtLeast;
private Double minPrice;
private Double maxPrice;
private Double maxMinDeliveryCost;
}
| 624 | 0.766026 | 0.766026 | 28 | 21.285715 | 15.718182 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 15 |
3ee016a98c2c6312fd646f773701a78f7f9eaa97 | 22,754,736,753,934 | 8e51346f5cb1740a43ddcd79f4e6f135b9c3e688 | /src/test/java/Project/ScreenSorter/Files/ScreenContentTest.java | 4caee7c76f0337a49fd3edb5c74b3b921caf400e | [] | no_license | TomaszZa/Own1-ScreenCleaner | https://github.com/TomaszZa/Own1-ScreenCleaner | 50348e7dd355ecbda5c65ec004b19303eeffba1a | 8d13d0b607b8517cc359302f222ee5b132b6b76b | refs/heads/master | 2021-01-10T15:16:41.790000 | 2015-10-20T15:56:57 | 2015-10-20T15:56:57 | 43,900,737 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Project.ScreenSorter.Files;
import java.io.File;
import java.util.List;
import org.junit.Test;
import junit.framework.TestCase;
public class ScreenContentTest extends TestCase {
//dodac tworzenie pliku
@Test
public void testShouldReturnAllFilesNamesOnCreen(){
ScreenContent screen = new ScreenContent();
List<String> filesNameList;
File tempFile = new File("C:\\Users\\Tomasz\\Desktop\\cos.jpg");
try {
tempFile.createNewFile();
} catch(Exception e) {
System.out.println(e);
}
filesNameList = screen.makeScreenFoldersNames();
assertFalse(filesNameList.isEmpty());
assertTrue(filesNameList.contains("cos.jpg"));
tempFile.delete();
}
@Test
public void testShouldReturnAllFilesOnScreen(){
ScreenContent screen = new ScreenContent();
List<File> filesList;
File tempFile = new File("C:\\Users\\Tomasz\\Desktop\\cos.jpg");
try {
tempFile.createNewFile();
} catch(Exception e) {
System.out.println(e);
}
filesList = screen.makeScreenFolders();
assertTrue(filesList.contains(tempFile));
tempFile.delete();
}
}
| UTF-8 | Java | 1,143 | java | ScreenContentTest.java | Java | [
{
"context": "sNameList;\n\t\tFile tempFile = new File(\"C:\\\\Users\\\\Tomasz\\\\Desktop\\\\cos.jpg\");\n\t\t\n\t\ttry {\n\t\ttempFile.create",
"end": 401,
"score": 0.9115539193153381,
"start": 395,
"tag": "NAME",
"value": "Tomasz"
}
] | null | [] | package Project.ScreenSorter.Files;
import java.io.File;
import java.util.List;
import org.junit.Test;
import junit.framework.TestCase;
public class ScreenContentTest extends TestCase {
//dodac tworzenie pliku
@Test
public void testShouldReturnAllFilesNamesOnCreen(){
ScreenContent screen = new ScreenContent();
List<String> filesNameList;
File tempFile = new File("C:\\Users\\Tomasz\\Desktop\\cos.jpg");
try {
tempFile.createNewFile();
} catch(Exception e) {
System.out.println(e);
}
filesNameList = screen.makeScreenFoldersNames();
assertFalse(filesNameList.isEmpty());
assertTrue(filesNameList.contains("cos.jpg"));
tempFile.delete();
}
@Test
public void testShouldReturnAllFilesOnScreen(){
ScreenContent screen = new ScreenContent();
List<File> filesList;
File tempFile = new File("C:\\Users\\Tomasz\\Desktop\\cos.jpg");
try {
tempFile.createNewFile();
} catch(Exception e) {
System.out.println(e);
}
filesList = screen.makeScreenFolders();
assertTrue(filesList.contains(tempFile));
tempFile.delete();
}
}
| 1,143 | 0.685039 | 0.685039 | 49 | 22.32653 | 19.518059 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.428571 | false | false | 15 |
07cc8364ab21bdc4f92bb1605013853b1d255fa2 | 20,701,742,400,844 | d33f9670be4cd47565d1962de5d0e72fe007a52f | /src/main/java/com/jovana/nsibackend/service/PollService.java | 81d0cd1241900f428bd93fa457ff4e4195038922 | [] | no_license | jovanapetrovic/movies-app-backend | https://github.com/jovanapetrovic/movies-app-backend | 4a13eab74c95dd9c127c072e0623d0e8fb299d38 | 922b94df1f34529ae37b9dc2f31948bf49e615f0 | refs/heads/master | 2020-07-31T17:46:38.398000 | 2019-09-24T21:31:08 | 2019-09-24T21:31:08 | 210,699,496 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jovana.nsibackend.service;
import com.jovana.nsibackend.exception.BadRequestException;
import com.jovana.nsibackend.exception.ResourceNotFoundException;
import com.jovana.nsibackend.model.*;
import com.jovana.nsibackend.repository.PollRepository;
import com.jovana.nsibackend.repository.UserRepository;
import com.jovana.nsibackend.repository.VoteRepository;
import com.jovana.nsibackend.resource.PagedResponse;
import com.jovana.nsibackend.resource.PollRequest;
import com.jovana.nsibackend.resource.PollResponse;
import com.jovana.nsibackend.resource.VoteRequest;
import com.jovana.nsibackend.security.UserPrincipal;
import com.jovana.nsibackend.util.Constants;
import com.jovana.nsibackend.util.ModelMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* Created by jovana on 05.11.2018
*/
@Service
public class PollService {
public static final String DATE_CREATED = "dateCreated";
@Autowired
private PollRepository pollRepository;
@Autowired
private VoteRepository voteRepository;
@Autowired
private UserRepository userRepository;
private static final Logger log = LoggerFactory.getLogger(PollService.class);
public PagedResponse<PollResponse> getAllPolls(UserPrincipal currentUser, int page, int size) {
validatePageNumberAndSize(page, size);
Pageable pageable = PageRequest.of(page, size, Sort.Direction.DESC, DATE_CREATED);
Page<Poll> polls = pollRepository.findAll(pageable);
if (polls.getNumberOfElements() == 0) {
return new PagedResponse<>(Collections.emptyList(), polls.getNumber(),
polls.getSize(), polls.getTotalElements(), polls.getTotalPages(), polls.isLast());
}
List<Long> pollIds = polls.map(Poll::getId).getContent();
Map<Long, Long> optionVotesMap = getOptionVotes(pollIds);
Map<Long, Long> pollUserVoteMap = getPollUserVoteMap(currentUser, pollIds);
Map<Long, User> creatorMap = getPollCreatorMap(polls.getContent());
List<PollResponse> pollResponses = polls.map(poll -> ModelMapper.mapPollToPollResponse(
poll,
optionVotesMap,
creatorMap.get(poll.getCreatedBy()),
pollUserVoteMap == null ? null : pollUserVoteMap.getOrDefault(poll.getId(), null)
)).getContent();
return new PagedResponse<>(pollResponses, polls.getNumber(), polls.getSize(), polls.getTotalElements(), polls.getTotalPages(), polls.isLast());
}
public PagedResponse<PollResponse> getPollsCreatedBy(String username, UserPrincipal currentUser, int page, int size) {
validatePageNumberAndSize(page, size);
User user = userRepository.findByUsername(username)
.orElseThrow(() -> new ResourceNotFoundException("User", "username", username));
Pageable pageable = PageRequest.of(page, size, Sort.Direction.DESC, DATE_CREATED);
Page<Poll> polls = pollRepository.findByCreatedBy(user.getId(), pageable);
if (polls.getNumberOfElements() == 0) {
return new PagedResponse<>(Collections.emptyList(), polls.getNumber(),
polls.getSize(), polls.getTotalElements(), polls.getTotalPages(), polls.isLast());
}
List<Long> pollIds = polls.map(Poll::getId).getContent();
Map<Long, Long> optionVotesMap = getOptionVotes(pollIds);
Map<Long, Long> pollUserVoteMap = getPollUserVoteMap(currentUser, pollIds);
List<PollResponse> pollResponses = polls.map(poll -> ModelMapper.mapPollToPollResponse(
poll,
optionVotesMap,
user,
pollUserVoteMap == null ? null : pollUserVoteMap.getOrDefault(poll.getId(), null)
)).getContent();
return new PagedResponse<>(pollResponses, polls.getNumber(), polls.getSize(), polls.getTotalElements(), polls.getTotalPages(), polls.isLast());
}
public PagedResponse<PollResponse> getPollsVotedBy(String username, UserPrincipal currentUser, int page, int size) {
validatePageNumberAndSize(page, size);
User user = userRepository.findByUsername(username)
.orElseThrow(() -> new ResourceNotFoundException("User", "username", username));
Pageable pageable = PageRequest.of(page, size, Sort.Direction.DESC, DATE_CREATED);
Page<Long> userVotedPollIds = voteRepository.findVotedPollIdsByUserId(user.getId(), pageable);
if (userVotedPollIds.getNumberOfElements() == 0) {
return new PagedResponse<>(Collections.emptyList(), userVotedPollIds.getNumber(),
userVotedPollIds.getSize(), userVotedPollIds.getTotalElements(),
userVotedPollIds.getTotalPages(), userVotedPollIds.isLast());
}
List<Long> pollIds = userVotedPollIds.getContent();
Sort sort = new Sort(Sort.Direction.DESC, DATE_CREATED);
List<Poll> polls = pollRepository.findByIdIn(pollIds, sort);
Map<Long, Long> optionVotesMap = getOptionVotes(pollIds);
Map<Long, Long> pollUserVoteMap = getPollUserVoteMap(currentUser, pollIds);
Map<Long, User> creatorMap = getPollCreatorMap(polls);
List<PollResponse> pollResponses = polls.stream().map(poll -> ModelMapper.mapPollToPollResponse(
poll,
optionVotesMap,
creatorMap.get(poll.getCreatedBy()),
pollUserVoteMap == null ? null : pollUserVoteMap.getOrDefault(poll.getId(), null)
)).collect(Collectors.toList());
return new PagedResponse<>(pollResponses, userVotedPollIds.getNumber(), userVotedPollIds.getSize(), userVotedPollIds.getTotalElements(), userVotedPollIds.getTotalPages(), userVotedPollIds.isLast());
}
public Poll createPoll(PollRequest pollRequest) {
Poll poll = new Poll();
poll.setQuestion(pollRequest.getQuestion());
pollRequest.getOptions().forEach(req -> poll.addOption(new Option(req.getText())));
Instant now = Instant.now();
Instant expirationDateTime = now.plus(Duration.ofDays(pollRequest.getPollDuration().getDays()))
.plus(Duration.ofHours(pollRequest.getPollDuration().getHours()));
poll.setExpirationDateTime(expirationDateTime);
return pollRepository.save(poll);
}
public PollResponse getPollById(Long pollId, UserPrincipal currentUser) {
Poll poll = pollRepository.findById(pollId).orElseThrow(() -> new ResourceNotFoundException("Poll", "id", pollId));
List<OptionVotes> votes = voteRepository.countByPollIdGroupByOptionId(pollId);
Map<Long, Long> optionVotes = votes.stream()
.collect(Collectors.toMap(OptionVotes::getOptionId, OptionVotes::getVoteCount));
User creator = userRepository.findById(poll.getCreatedBy())
.orElseThrow(() -> new ResourceNotFoundException("User", "id", poll.getCreatedBy()));
Vote userVote = null;
if (currentUser != null) {
userVote = voteRepository.findByUserIdAndPollId(currentUser.getId(), pollId);
}
return ModelMapper.mapPollToPollResponse(poll, optionVotes,
creator, userVote != null ? userVote.getOption().getId() : null);
}
public PollResponse submitVoteAndGetUpdatedPoll(Long pollId, VoteRequest voteRequest, UserPrincipal currentUser) {
Poll poll = pollRepository.findById(pollId).orElseThrow(() -> new ResourceNotFoundException("Poll", "id", pollId));
if (poll.getExpirationDateTime().isBefore(Instant.now())) {
throw new BadRequestException("This poll has already expired!");
}
User user = userRepository.getOne(currentUser.getId());
Option selectedOption = poll.getOptions().stream()
.filter(option -> option.getId().equals(voteRequest.getOptionId()))
.findFirst()
.orElseThrow(() -> new ResourceNotFoundException("Option", "id", voteRequest.getOptionId()));
Vote vote = new Vote();
vote.setPoll(poll);
vote.setUser(user);
vote.setOption(selectedOption);
try {
vote = voteRepository.save(vote);
} catch (DataIntegrityViolationException ex) {
log.info("User {} has already voted in poll {}", currentUser.getId(), pollId);
throw new BadRequestException("You already voted in this poll!");
}
List<OptionVotes> votes = voteRepository.countByPollIdGroupByOptionId(pollId);
Map<Long, Long> optionVotes = votes.stream()
.collect(Collectors.toMap(OptionVotes::getOptionId, OptionVotes::getVoteCount));
User creator = userRepository.findById(poll.getCreatedBy())
.orElseThrow(() -> new ResourceNotFoundException("User", "id", poll.getCreatedBy()));
return ModelMapper.mapPollToPollResponse(poll, optionVotes, creator, vote.getOption().getId());
}
private void validatePageNumberAndSize(int page, int size) {
if (page < 0) {
throw new BadRequestException("Page number cannot be less than zero.");
}
if (size > Constants.MAX_PAGE_SIZE) {
throw new BadRequestException("Page size cannot be greater than " + Constants.MAX_PAGE_SIZE);
}
}
private Map<Long, Long> getOptionVotes(List<Long> pollIds) {
List<OptionVotes> votes = voteRepository.countByPollIdInGroupByOptionId(pollIds);
return votes.stream().collect(Collectors.toMap(OptionVotes::getOptionId, OptionVotes::getVoteCount));
}
private Map<Long, Long> getPollUserVoteMap(UserPrincipal currentUser, List<Long> pollIds) {
Map<Long, Long> pollUserVoteMap = null;
if (currentUser != null) {
List<Vote> userVotes = voteRepository.findByUserIdAndPollIdIn(currentUser.getId(), pollIds);
pollUserVoteMap = userVotes.stream()
.collect(Collectors.toMap(vote -> vote.getPoll().getId(), vote -> vote.getOption().getId()));
}
return pollUserVoteMap;
}
private Map<Long, User> getPollCreatorMap(List<Poll> polls) {
List<Long> creatorIds = polls.stream().map(Poll::getCreatedBy).distinct().collect(Collectors.toList());
List<User> creators = userRepository.findByIdIn(creatorIds);
return creators.stream().collect(Collectors.toMap(User::getId, Function.identity()));
}
}
| UTF-8 | Java | 10,988 | java | PollService.java | Java | [
{
"context": "rt java.util.stream.Collectors;\n\n/**\n * Created by jovana on 05.11.2018\n */\n@Service\npublic class PollServi",
"end": 1372,
"score": 0.99931401014328,
"start": 1366,
"tag": "USERNAME",
"value": "jovana"
}
] | null | [] | package com.jovana.nsibackend.service;
import com.jovana.nsibackend.exception.BadRequestException;
import com.jovana.nsibackend.exception.ResourceNotFoundException;
import com.jovana.nsibackend.model.*;
import com.jovana.nsibackend.repository.PollRepository;
import com.jovana.nsibackend.repository.UserRepository;
import com.jovana.nsibackend.repository.VoteRepository;
import com.jovana.nsibackend.resource.PagedResponse;
import com.jovana.nsibackend.resource.PollRequest;
import com.jovana.nsibackend.resource.PollResponse;
import com.jovana.nsibackend.resource.VoteRequest;
import com.jovana.nsibackend.security.UserPrincipal;
import com.jovana.nsibackend.util.Constants;
import com.jovana.nsibackend.util.ModelMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* Created by jovana on 05.11.2018
*/
@Service
public class PollService {
public static final String DATE_CREATED = "dateCreated";
@Autowired
private PollRepository pollRepository;
@Autowired
private VoteRepository voteRepository;
@Autowired
private UserRepository userRepository;
private static final Logger log = LoggerFactory.getLogger(PollService.class);
public PagedResponse<PollResponse> getAllPolls(UserPrincipal currentUser, int page, int size) {
validatePageNumberAndSize(page, size);
Pageable pageable = PageRequest.of(page, size, Sort.Direction.DESC, DATE_CREATED);
Page<Poll> polls = pollRepository.findAll(pageable);
if (polls.getNumberOfElements() == 0) {
return new PagedResponse<>(Collections.emptyList(), polls.getNumber(),
polls.getSize(), polls.getTotalElements(), polls.getTotalPages(), polls.isLast());
}
List<Long> pollIds = polls.map(Poll::getId).getContent();
Map<Long, Long> optionVotesMap = getOptionVotes(pollIds);
Map<Long, Long> pollUserVoteMap = getPollUserVoteMap(currentUser, pollIds);
Map<Long, User> creatorMap = getPollCreatorMap(polls.getContent());
List<PollResponse> pollResponses = polls.map(poll -> ModelMapper.mapPollToPollResponse(
poll,
optionVotesMap,
creatorMap.get(poll.getCreatedBy()),
pollUserVoteMap == null ? null : pollUserVoteMap.getOrDefault(poll.getId(), null)
)).getContent();
return new PagedResponse<>(pollResponses, polls.getNumber(), polls.getSize(), polls.getTotalElements(), polls.getTotalPages(), polls.isLast());
}
public PagedResponse<PollResponse> getPollsCreatedBy(String username, UserPrincipal currentUser, int page, int size) {
validatePageNumberAndSize(page, size);
User user = userRepository.findByUsername(username)
.orElseThrow(() -> new ResourceNotFoundException("User", "username", username));
Pageable pageable = PageRequest.of(page, size, Sort.Direction.DESC, DATE_CREATED);
Page<Poll> polls = pollRepository.findByCreatedBy(user.getId(), pageable);
if (polls.getNumberOfElements() == 0) {
return new PagedResponse<>(Collections.emptyList(), polls.getNumber(),
polls.getSize(), polls.getTotalElements(), polls.getTotalPages(), polls.isLast());
}
List<Long> pollIds = polls.map(Poll::getId).getContent();
Map<Long, Long> optionVotesMap = getOptionVotes(pollIds);
Map<Long, Long> pollUserVoteMap = getPollUserVoteMap(currentUser, pollIds);
List<PollResponse> pollResponses = polls.map(poll -> ModelMapper.mapPollToPollResponse(
poll,
optionVotesMap,
user,
pollUserVoteMap == null ? null : pollUserVoteMap.getOrDefault(poll.getId(), null)
)).getContent();
return new PagedResponse<>(pollResponses, polls.getNumber(), polls.getSize(), polls.getTotalElements(), polls.getTotalPages(), polls.isLast());
}
public PagedResponse<PollResponse> getPollsVotedBy(String username, UserPrincipal currentUser, int page, int size) {
validatePageNumberAndSize(page, size);
User user = userRepository.findByUsername(username)
.orElseThrow(() -> new ResourceNotFoundException("User", "username", username));
Pageable pageable = PageRequest.of(page, size, Sort.Direction.DESC, DATE_CREATED);
Page<Long> userVotedPollIds = voteRepository.findVotedPollIdsByUserId(user.getId(), pageable);
if (userVotedPollIds.getNumberOfElements() == 0) {
return new PagedResponse<>(Collections.emptyList(), userVotedPollIds.getNumber(),
userVotedPollIds.getSize(), userVotedPollIds.getTotalElements(),
userVotedPollIds.getTotalPages(), userVotedPollIds.isLast());
}
List<Long> pollIds = userVotedPollIds.getContent();
Sort sort = new Sort(Sort.Direction.DESC, DATE_CREATED);
List<Poll> polls = pollRepository.findByIdIn(pollIds, sort);
Map<Long, Long> optionVotesMap = getOptionVotes(pollIds);
Map<Long, Long> pollUserVoteMap = getPollUserVoteMap(currentUser, pollIds);
Map<Long, User> creatorMap = getPollCreatorMap(polls);
List<PollResponse> pollResponses = polls.stream().map(poll -> ModelMapper.mapPollToPollResponse(
poll,
optionVotesMap,
creatorMap.get(poll.getCreatedBy()),
pollUserVoteMap == null ? null : pollUserVoteMap.getOrDefault(poll.getId(), null)
)).collect(Collectors.toList());
return new PagedResponse<>(pollResponses, userVotedPollIds.getNumber(), userVotedPollIds.getSize(), userVotedPollIds.getTotalElements(), userVotedPollIds.getTotalPages(), userVotedPollIds.isLast());
}
public Poll createPoll(PollRequest pollRequest) {
Poll poll = new Poll();
poll.setQuestion(pollRequest.getQuestion());
pollRequest.getOptions().forEach(req -> poll.addOption(new Option(req.getText())));
Instant now = Instant.now();
Instant expirationDateTime = now.plus(Duration.ofDays(pollRequest.getPollDuration().getDays()))
.plus(Duration.ofHours(pollRequest.getPollDuration().getHours()));
poll.setExpirationDateTime(expirationDateTime);
return pollRepository.save(poll);
}
public PollResponse getPollById(Long pollId, UserPrincipal currentUser) {
Poll poll = pollRepository.findById(pollId).orElseThrow(() -> new ResourceNotFoundException("Poll", "id", pollId));
List<OptionVotes> votes = voteRepository.countByPollIdGroupByOptionId(pollId);
Map<Long, Long> optionVotes = votes.stream()
.collect(Collectors.toMap(OptionVotes::getOptionId, OptionVotes::getVoteCount));
User creator = userRepository.findById(poll.getCreatedBy())
.orElseThrow(() -> new ResourceNotFoundException("User", "id", poll.getCreatedBy()));
Vote userVote = null;
if (currentUser != null) {
userVote = voteRepository.findByUserIdAndPollId(currentUser.getId(), pollId);
}
return ModelMapper.mapPollToPollResponse(poll, optionVotes,
creator, userVote != null ? userVote.getOption().getId() : null);
}
public PollResponse submitVoteAndGetUpdatedPoll(Long pollId, VoteRequest voteRequest, UserPrincipal currentUser) {
Poll poll = pollRepository.findById(pollId).orElseThrow(() -> new ResourceNotFoundException("Poll", "id", pollId));
if (poll.getExpirationDateTime().isBefore(Instant.now())) {
throw new BadRequestException("This poll has already expired!");
}
User user = userRepository.getOne(currentUser.getId());
Option selectedOption = poll.getOptions().stream()
.filter(option -> option.getId().equals(voteRequest.getOptionId()))
.findFirst()
.orElseThrow(() -> new ResourceNotFoundException("Option", "id", voteRequest.getOptionId()));
Vote vote = new Vote();
vote.setPoll(poll);
vote.setUser(user);
vote.setOption(selectedOption);
try {
vote = voteRepository.save(vote);
} catch (DataIntegrityViolationException ex) {
log.info("User {} has already voted in poll {}", currentUser.getId(), pollId);
throw new BadRequestException("You already voted in this poll!");
}
List<OptionVotes> votes = voteRepository.countByPollIdGroupByOptionId(pollId);
Map<Long, Long> optionVotes = votes.stream()
.collect(Collectors.toMap(OptionVotes::getOptionId, OptionVotes::getVoteCount));
User creator = userRepository.findById(poll.getCreatedBy())
.orElseThrow(() -> new ResourceNotFoundException("User", "id", poll.getCreatedBy()));
return ModelMapper.mapPollToPollResponse(poll, optionVotes, creator, vote.getOption().getId());
}
private void validatePageNumberAndSize(int page, int size) {
if (page < 0) {
throw new BadRequestException("Page number cannot be less than zero.");
}
if (size > Constants.MAX_PAGE_SIZE) {
throw new BadRequestException("Page size cannot be greater than " + Constants.MAX_PAGE_SIZE);
}
}
private Map<Long, Long> getOptionVotes(List<Long> pollIds) {
List<OptionVotes> votes = voteRepository.countByPollIdInGroupByOptionId(pollIds);
return votes.stream().collect(Collectors.toMap(OptionVotes::getOptionId, OptionVotes::getVoteCount));
}
private Map<Long, Long> getPollUserVoteMap(UserPrincipal currentUser, List<Long> pollIds) {
Map<Long, Long> pollUserVoteMap = null;
if (currentUser != null) {
List<Vote> userVotes = voteRepository.findByUserIdAndPollIdIn(currentUser.getId(), pollIds);
pollUserVoteMap = userVotes.stream()
.collect(Collectors.toMap(vote -> vote.getPoll().getId(), vote -> vote.getOption().getId()));
}
return pollUserVoteMap;
}
private Map<Long, User> getPollCreatorMap(List<Poll> polls) {
List<Long> creatorIds = polls.stream().map(Poll::getCreatedBy).distinct().collect(Collectors.toList());
List<User> creators = userRepository.findByIdIn(creatorIds);
return creators.stream().collect(Collectors.toMap(User::getId, Function.identity()));
}
}
| 10,988 | 0.689934 | 0.68866 | 243 | 44.218105 | 39.196007 | 206 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.925926 | false | false | 15 |
f3edaf1dd36b98e6ce8abf45acf02f9ad400ae0c | 25,941,602,525,001 | 2e37f59d52e23d247c2940401ca00706030ee8bb | /Instruccion brake y continue/src/paquete/Main.java | bdf5731586bc737f5f1a56093337e6c1082357ac | [] | no_license | erick4556/Java-Basico | https://github.com/erick4556/Java-Basico | 90bd2cc6be11ce8360b0c0d47feb9ecff85bbe1c | a05604df8441effca1d9af290c415f62ca4a9adf | refs/heads/master | 2021-01-10T12:37:23.569000 | 2015-12-14T02:26:00 | 2015-12-14T02:26:00 | 47,946,617 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package paquete;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
/**for(int i=0; i<=10;i++){
System.out.println("Estas todavia en el ciclo");
//break; Es salirse de un ciclo. Se va cortar todas las funciones que se estan realizando dentro de ese ciclo y se va salir de ciclo. Se corta completamente el ciclo.
if (i==4){
break;
}
System.out.println("El valor de i es = "+i);
}
System.out.println("Hola ya saliste del ciclo");*/
for(int i=0; i<=10; i++){
System.out.println("Estas todavia en el ciclo");
//continue;Va cortar el ciclo pero no se va salir completamente de el. Se termina el ciclo.
if(i==4){
continue;
}
System.out.println("El valor de i es= "+i);
}
System.out.println("Has dejado el ciclo for");
}
}
| UTF-8 | Java | 829 | java | Main.java | Java | [] | null | [] | package paquete;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
/**for(int i=0; i<=10;i++){
System.out.println("Estas todavia en el ciclo");
//break; Es salirse de un ciclo. Se va cortar todas las funciones que se estan realizando dentro de ese ciclo y se va salir de ciclo. Se corta completamente el ciclo.
if (i==4){
break;
}
System.out.println("El valor de i es = "+i);
}
System.out.println("Hola ya saliste del ciclo");*/
for(int i=0; i<=10; i++){
System.out.println("Estas todavia en el ciclo");
//continue;Va cortar el ciclo pero no se va salir completamente de el. Se termina el ciclo.
if(i==4){
continue;
}
System.out.println("El valor de i es= "+i);
}
System.out.println("Has dejado el ciclo for");
}
}
| 829 | 0.646562 | 0.636912 | 31 | 25.741936 | 34.644711 | 169 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.451613 | false | false | 15 |
9cf3c034c3478fde8db5b2aede3db1c75fc3c59a | 7,885,559,956,293 | af0f7f7afbf2898983d9612d051633510234020f | /GetUserInput.java | 3f5eabe3d3743d1d9c50c95f8c7ec4a81e017bff | [] | no_license | VasudhaAdvani/Vasudha_Advani_AirportBaggage | https://github.com/VasudhaAdvani/Vasudha_Advani_AirportBaggage | 668c358e1a7c019df8f0b0887df9425d864eb443 | 427642ef65044667e626062af33e0e75df399091 | refs/heads/master | 2021-01-01T16:56:26.316000 | 2015-06-17T12:37:04 | 2015-06-17T12:37:04 | 37,593,109 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Author : Vasudha Advani
* Class to initate the process
*/
package airportBaggageProblem;
import java.util.Scanner;
public class GetUserInput {
public static void main(String[] args) {
String input;
Scanner in = new Scanner(System.in);
System.out.println("Enter details of baggage system :");
input = in.nextLine();
new ReadingInput().readInput(input);
}
}
| UTF-8 | Java | 407 | java | GetUserInput.java | Java | [
{
"context": "/*\n * Author : Vasudha Advani\n * Class to initate the process\n */\n\npackage airp",
"end": 29,
"score": 0.9998748898506165,
"start": 15,
"tag": "NAME",
"value": "Vasudha Advani"
}
] | null | [] | /*
* Author : <NAME>
* Class to initate the process
*/
package airportBaggageProblem;
import java.util.Scanner;
public class GetUserInput {
public static void main(String[] args) {
String input;
Scanner in = new Scanner(System.in);
System.out.println("Enter details of baggage system :");
input = in.nextLine();
new ReadingInput().readInput(input);
}
}
| 399 | 0.663391 | 0.663391 | 20 | 19.35 | 18.72238 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.9 | false | false | 15 |
e669aad99d88572ac2306b64e391f40b215c92e7 | 1,468,878,819,469 | 7ad654c6c386552eea0b6342d7c7fa1228328589 | /src/test/java/com/study/codec/rsa/TestRSACoder.java | 2c2ba089542972791e4513249f392b8f3c83b7c4 | [] | no_license | MagiRui/java-encryption | https://github.com/MagiRui/java-encryption | 9e86be3b7adafe09a7e271f8c66abbe3a1be2226 | 1fdbfbafa4e39e9bfb1ed824cb7efafaceb924d3 | refs/heads/main | 2023-05-31T12:45:31.966000 | 2021-06-16T03:38:06 | 2021-06-16T03:38:06 | 377,354,421 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.study.codec.rsa;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author MagiRui
* @description
* @date 2020-09-07
*/
public class TestRSACoder {
private byte[] publicKey;
private byte[] privateKey;
@Before
public void initKey() throws Exception {
Map<String, Object>
keyMap = RSACoder.initKey();
publicKey = RSACoder.getPublicKey(keyMap);
privateKey = RSACoder.getPrivateKey(keyMap);
System.out.println("公钥:\n" +
Base64.encodeBase64String(publicKey));
System.out.println("私钥:\n" +
Base64.encodeBase64String(privateKey));
}
@Test
public void test1() throws Exception {
System.out.println("\n---私钥加密-公钥解密---");
String inputStr1 = "RSA加密算法";
byte[] data1 = inputStr1.getBytes();
System.out.println("原文:\n" + inputStr1);
//加密
byte[] encodeData1 = RSACoder.encryptByPrivateKey(data1, privateKey);
System.out.println("加密后:\n" + Base64.encodeBase64String(encodeData1));
//解密
byte[] decodeData1 = RSACoder.decryptByPublicKey(encodeData1, publicKey);
String outputStr1 = new String(decodeData1);
System.out.println("解密后:\n" + outputStr1);
Assert.assertEquals(inputStr1, outputStr1);
}
@Test
public void test2() throws Exception {
System.out.println("\n---公钥加密-私钥解密---");
String inputStr1 = "RSA加密算法";
byte[] data1 = inputStr1.getBytes();
System.out.println("原文:\n" + inputStr1);
//加密
byte[] encodeData1 = RSACoder.encryptByPubicKey(data1, publicKey);
System.out.println("加密后:\n" + Base64.encodeBase64String(encodeData1));
//解密
byte[] decodeData1 = RSACoder.decryptByPrivateKey(encodeData1, privateKey);
String outputStr1 = new String(decodeData1);
System.out.println("解密后:\n" + outputStr1);
Assert.assertEquals(inputStr1, outputStr1);
}
@Test
public void testSign() throws Exception{
String inputStr = "RSA数字签名";
byte[] data = inputStr.getBytes();
//产生签名
byte[] sign = RSACoder.sign(data, privateKey);
System.out.println("签名:\n" + Hex.encodeHexString(sign));
boolean status = RSACoder.verify(data, publicKey, sign);
Assert.assertTrue(status);
}
}
| UTF-8 | Java | 2,444 | java | TestRSACoder.java | Java | [
{
"context": "nit.Before;\nimport org.junit.Test;\n\n/**\n * @author MagiRui\n * @description\n * @date 2020-09-07\n */\npublic cl",
"end": 239,
"score": 0.7943559885025024,
"start": 232,
"tag": "NAME",
"value": "MagiRui"
}
] | null | [] | package com.study.codec.rsa;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author MagiRui
* @description
* @date 2020-09-07
*/
public class TestRSACoder {
private byte[] publicKey;
private byte[] privateKey;
@Before
public void initKey() throws Exception {
Map<String, Object>
keyMap = RSACoder.initKey();
publicKey = RSACoder.getPublicKey(keyMap);
privateKey = RSACoder.getPrivateKey(keyMap);
System.out.println("公钥:\n" +
Base64.encodeBase64String(publicKey));
System.out.println("私钥:\n" +
Base64.encodeBase64String(privateKey));
}
@Test
public void test1() throws Exception {
System.out.println("\n---私钥加密-公钥解密---");
String inputStr1 = "RSA加密算法";
byte[] data1 = inputStr1.getBytes();
System.out.println("原文:\n" + inputStr1);
//加密
byte[] encodeData1 = RSACoder.encryptByPrivateKey(data1, privateKey);
System.out.println("加密后:\n" + Base64.encodeBase64String(encodeData1));
//解密
byte[] decodeData1 = RSACoder.decryptByPublicKey(encodeData1, publicKey);
String outputStr1 = new String(decodeData1);
System.out.println("解密后:\n" + outputStr1);
Assert.assertEquals(inputStr1, outputStr1);
}
@Test
public void test2() throws Exception {
System.out.println("\n---公钥加密-私钥解密---");
String inputStr1 = "RSA加密算法";
byte[] data1 = inputStr1.getBytes();
System.out.println("原文:\n" + inputStr1);
//加密
byte[] encodeData1 = RSACoder.encryptByPubicKey(data1, publicKey);
System.out.println("加密后:\n" + Base64.encodeBase64String(encodeData1));
//解密
byte[] decodeData1 = RSACoder.decryptByPrivateKey(encodeData1, privateKey);
String outputStr1 = new String(decodeData1);
System.out.println("解密后:\n" + outputStr1);
Assert.assertEquals(inputStr1, outputStr1);
}
@Test
public void testSign() throws Exception{
String inputStr = "RSA数字签名";
byte[] data = inputStr.getBytes();
//产生签名
byte[] sign = RSACoder.sign(data, privateKey);
System.out.println("签名:\n" + Hex.encodeHexString(sign));
boolean status = RSACoder.verify(data, publicKey, sign);
Assert.assertTrue(status);
}
}
| 2,444 | 0.681035 | 0.656897 | 92 | 24.217392 | 23.032503 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.543478 | false | false | 15 |
1916211054334abc172a459e2383ccd48c9c8441 | 6,554,120,109,743 | e18800e73206c384983482eb2be1685aee792f08 | /sample-jpa-spring-4.x-jsf-2.x-primefaces-5.x/src/main/java/com/sample/model/dao/IAlbumDAO.java | f399ec7f845d8a251ae20d552b55f459e8a542f6 | [] | no_license | cjrequena/samples | https://github.com/cjrequena/samples | 4d6d1070d0121eb7b0a87bb1dd389c6df8b774a3 | b3b76be014242d46c8ea6c20a817010a1c2c4b99 | refs/heads/master | 2021-01-21T12:49:27.860000 | 2016-03-21T15:29:35 | 2016-03-21T15:29:35 | 14,345,290 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sample.model.dao;
import com.sample.architecture.dao.IDAO;
import com.sample.model.jpa.Album;
public interface IAlbumDAO extends IDAO<Album, Integer>{
}
| UTF-8 | Java | 168 | java | IAlbumDAO.java | Java | [] | null | [] | package com.sample.model.dao;
import com.sample.architecture.dao.IDAO;
import com.sample.model.jpa.Album;
public interface IAlbumDAO extends IDAO<Album, Integer>{
}
| 168 | 0.791667 | 0.791667 | 8 | 20 | 21.017849 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 15 |
71b965d80522f5238fa36ea7dbbf76b5836f705b | 23,356,032,177,299 | df43e703481a22f0a45cf3e30f060ff1ed9ecfd6 | /src/org/nutz/walnut/ext/data/app/hdl/app_i18n.java | 79146b2c6930dea1b686444d71969133be800503 | [
"Apache-2.0"
] | permissive | zozoh/walnut | https://github.com/zozoh/walnut | 3e9c5a8d05693dcb45b26317a280b9a6808e76d7 | ff96c8ed2e684786d3e5a928a298d0f7c6c04263 | refs/heads/master | 2023-09-03T14:02:37.140000 | 2023-08-25T12:52:40 | 2023-08-25T12:52:40 | 25,297,698 | 11 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.nutz.walnut.ext.data.app.hdl;
import java.util.List;
import org.nutz.json.Json;
import org.nutz.lang.util.NutMap;
import org.nutz.walnut.api.io.WnObj;
import org.nutz.walnut.ext.data.app.WnApps;
import org.nutz.walnut.impl.box.JvmHdl;
import org.nutz.walnut.impl.box.JvmHdlContext;
import org.nutz.walnut.impl.box.JvmHdlParamArgs;
import org.nutz.walnut.impl.box.WnSystem;
@JvmHdlParamArgs(regex = "^(merge)$", value = "cqn")
public class app_i18n implements JvmHdl {
@Override
public void invoke(WnSystem sys, JvmHdlContext hc) {
// 得到语言
String lang = "zh-cn";
if (hc.params.vals.length > 0)
lang = hc.params.val(0);
// 是否合并
boolean isMerge = hc.params.is("merge");
// 得到所有的 UI 主目录
List<WnObj> oUIHomes = WnApps.getUIHomes(sys);
// 准备消息字符串集合
NutMap msg = new NutMap();
// 循环
String rph = "i18n/" + lang + ".js";
for (WnObj oUIHome : oUIHomes) {
WnObj o = sys.io.fetch(oUIHome, rph);
// 存在这个文件
if (null != o) {
NutMap map = sys.io.readJson(o, NutMap.class);
msg.mergeWith(map, true);
// 不合并的话就退出了
if (!isMerge)
break;
}
}
// 输出
sys.out.println(Json.toJson(msg, hc.jfmt));
}
}
| UTF-8 | Java | 1,462 | java | app_i18n.java | Java | [] | null | [] | package org.nutz.walnut.ext.data.app.hdl;
import java.util.List;
import org.nutz.json.Json;
import org.nutz.lang.util.NutMap;
import org.nutz.walnut.api.io.WnObj;
import org.nutz.walnut.ext.data.app.WnApps;
import org.nutz.walnut.impl.box.JvmHdl;
import org.nutz.walnut.impl.box.JvmHdlContext;
import org.nutz.walnut.impl.box.JvmHdlParamArgs;
import org.nutz.walnut.impl.box.WnSystem;
@JvmHdlParamArgs(regex = "^(merge)$", value = "cqn")
public class app_i18n implements JvmHdl {
@Override
public void invoke(WnSystem sys, JvmHdlContext hc) {
// 得到语言
String lang = "zh-cn";
if (hc.params.vals.length > 0)
lang = hc.params.val(0);
// 是否合并
boolean isMerge = hc.params.is("merge");
// 得到所有的 UI 主目录
List<WnObj> oUIHomes = WnApps.getUIHomes(sys);
// 准备消息字符串集合
NutMap msg = new NutMap();
// 循环
String rph = "i18n/" + lang + ".js";
for (WnObj oUIHome : oUIHomes) {
WnObj o = sys.io.fetch(oUIHome, rph);
// 存在这个文件
if (null != o) {
NutMap map = sys.io.readJson(o, NutMap.class);
msg.mergeWith(map, true);
// 不合并的话就退出了
if (!isMerge)
break;
}
}
// 输出
sys.out.println(Json.toJson(msg, hc.jfmt));
}
}
| 1,462 | 0.567686 | 0.563319 | 51 | 25.941177 | 18.610994 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.529412 | false | false | 15 |
ec97c883fd514d0f712c73db8a7cf9fb5c0fd31d | 33,071,248,239,796 | fc4e9ad6d2acabfd80559efda9dd67183bfd9da5 | /JAVA/JAVA INDIV/Smart Start Yasser/src/GUI3/AuthentificationFXMLController.java | 408cc8356ab4800ecab9841f73946ba7bdef5e66 | [] | no_license | NidhalATTIA/Epsilon | https://github.com/NidhalATTIA/Epsilon | 711da40537beee4d5d5ad2abf31e8499845c1c1e | 27c7bb7b5df48b46c2b43849e43a20c4dc4e9fc9 | refs/heads/master | 2022-12-12T05:44:38.037000 | 2020-01-16T07:49:20 | 2020-01-16T07:49:20 | 211,060,325 | 0 | 0 | null | false | 2022-12-06T03:28:00 | 2019-09-26T10:14:10 | 2020-01-16T07:49:23 | 2022-12-06T03:27:58 | 82,929 | 0 | 0 | 14 | JavaScript | 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 GUI3;
import Entite.Admin;
import Entite.Client;
import Entite.Freelancer;
import GUI.AjouterFeedbackFXMLController;
import Service.ServiceAuthentification;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
/**
* FXML Controller class
*
* @author Yasser Bel Haj Ali
*/
public class AuthentificationFXMLController implements Initializable {
@FXML
private TextField username;
@FXML
private TextField userpassword;
@FXML
private Label reponce;
@FXML
private Button entre;
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
@FXML
private void login(ActionEvent event) throws SQLException, MalformedURLException, IOException {
try {
ServiceAuthentification tache = new ServiceAuthentification();
Freelancer f1= new Freelancer() ;
Client c1= new Client() ;
Admin a1= new Admin() ;
a1 = tache.rechercheAdminByName_Mdp(username.getText(),userpassword.getText());
c1 = tache.rechercheClientByName_Mdp(username.getText(),userpassword.getText());
f1 = tache.rechercheFreelancerByName_Mdp(username.getText(),userpassword.getText());
if (username.getText().isEmpty() ) {
reponce.setText("entrez vos donner");}
else if(f1.getMotDePass()== null && c1.getMotDePass()== null && a1.getMotDePass()== null ) {
reponce.setText("error");
}
else if(f1.getMotDePass()!= null && c1.getMotDePass()== null && a1.getMotDePass()== null ) {
//.reponce.setText("Freelancer");
URL url = new File("C:/Users/Yasser Bel Haj Ali/Documents/NetBeansProjects/ProjetPi/src/GUI5/AccueilFreelancerFXML.fxml").toURI().toURL();
Parent root = FXMLLoader.load(url);
entre.getScene().setRoot(root);
}
else if(f1.getMotDePass() == null && c1.getMotDePass() != null && a1.getMotDePass()== null ) {
URL url = new File("C:/Users/Yasser Bel Haj Ali/Documents/NetBeansProjects/ProjetPi/src/GUI4/AccueilClientFXML.fxml").toURI().toURL();
Parent root = FXMLLoader.load(url);
entre.getScene().setRoot(root);
}
else if(f1.getMotDePass() == null && c1.getMotDePass() == null && a1.getMotDePass()!= null ) {
URL url = new File("C:/Users/Yasser Bel Haj Ali/Documents/NetBeansProjects/ProjetPi/src/GUI6/AccueilAdminFXML.fxml").toURI().toURL();
Parent root = FXMLLoader.load(url);
entre.getScene().setRoot(root);
}
} catch (SQLException ex) {
Logger.getLogger(AuthentificationFXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
| UTF-8 | Java | 3,371 | java | AuthentificationFXMLController.java | Java | [
{
"context": "Field;\n\n/**\n * FXML Controller class\n *\n * @author Yasser Bel Haj Ali\n */\n\npublic class AuthentificationFXMLController ",
"end": 911,
"score": 0.9997851848602295,
"start": 893,
"tag": "NAME",
"value": "Yasser Bel Haj Ali"
},
{
"context": " \n URL url = new File(\"C:/Users/Yasser Bel Haj Ali/Documents/NetBeansProjects/ProjetPi/src/GUI5/Accu",
"end": 2304,
"score": 0.9997034072875977,
"start": 2286,
"tag": "NAME",
"value": "Yasser Bel Haj Ali"
},
{
"context": "ull ) {\n URL url = new File(\"C:/Users/Yasser Bel Haj Ali/Documents/NetBeansProjects/ProjetPi/src/GUI4/Accu",
"end": 2661,
"score": 0.9997653961181641,
"start": 2643,
"tag": "NAME",
"value": "Yasser Bel Haj Ali"
},
{
"context": "ll ) {\n URL url = new File(\"C:/Users/Yasser Bel Haj Ali/Documents/NetBeansProjects/ProjetPi/src/GUI6/Accu",
"end": 3006,
"score": 0.9998478889465332,
"start": 2988,
"tag": "NAME",
"value": "Yasser Bel Haj Ali"
}
] | 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 GUI3;
import Entite.Admin;
import Entite.Client;
import Entite.Freelancer;
import GUI.AjouterFeedbackFXMLController;
import Service.ServiceAuthentification;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
/**
* FXML Controller class
*
* @author <NAME>
*/
public class AuthentificationFXMLController implements Initializable {
@FXML
private TextField username;
@FXML
private TextField userpassword;
@FXML
private Label reponce;
@FXML
private Button entre;
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
@FXML
private void login(ActionEvent event) throws SQLException, MalformedURLException, IOException {
try {
ServiceAuthentification tache = new ServiceAuthentification();
Freelancer f1= new Freelancer() ;
Client c1= new Client() ;
Admin a1= new Admin() ;
a1 = tache.rechercheAdminByName_Mdp(username.getText(),userpassword.getText());
c1 = tache.rechercheClientByName_Mdp(username.getText(),userpassword.getText());
f1 = tache.rechercheFreelancerByName_Mdp(username.getText(),userpassword.getText());
if (username.getText().isEmpty() ) {
reponce.setText("entrez vos donner");}
else if(f1.getMotDePass()== null && c1.getMotDePass()== null && a1.getMotDePass()== null ) {
reponce.setText("error");
}
else if(f1.getMotDePass()!= null && c1.getMotDePass()== null && a1.getMotDePass()== null ) {
//.reponce.setText("Freelancer");
URL url = new File("C:/Users/<NAME>/Documents/NetBeansProjects/ProjetPi/src/GUI5/AccueilFreelancerFXML.fxml").toURI().toURL();
Parent root = FXMLLoader.load(url);
entre.getScene().setRoot(root);
}
else if(f1.getMotDePass() == null && c1.getMotDePass() != null && a1.getMotDePass()== null ) {
URL url = new File("C:/Users/<NAME>/Documents/NetBeansProjects/ProjetPi/src/GUI4/AccueilClientFXML.fxml").toURI().toURL();
Parent root = FXMLLoader.load(url);
entre.getScene().setRoot(root);
}
else if(f1.getMotDePass() == null && c1.getMotDePass() == null && a1.getMotDePass()!= null ) {
URL url = new File("C:/Users/<NAME>/Documents/NetBeansProjects/ProjetPi/src/GUI6/AccueilAdminFXML.fxml").toURI().toURL();
Parent root = FXMLLoader.load(url);
entre.getScene().setRoot(root);
}
} catch (SQLException ex) {
Logger.getLogger(AuthentificationFXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
| 3,323 | 0.669238 | 0.662711 | 98 | 33.336735 | 34.016186 | 147 | false | false | 0 | 0 | 0 | 0 | 70 | 0.059626 | 0.581633 | false | false | 15 |
859b6aff12488715e9f70f4f200d62000c1ae32a | 5,068,061,409,355 | eb2c22492d4740a3eb455f2a898f6b3bc8235809 | /jnnsBank/annual-api/src/main/java/com/ideatech/ams/annual/dto/poi/AnnualWaitingProcessPoi.java | 2e11bd67703eed22764277bce0be93b9277093fb | [] | no_license | deepexpert-gaohz/sa-d | https://github.com/deepexpert-gaohz/sa-d | 72a2d0cbfe95252d2a62f6247e7732c883049459 | 2d14275071b3d562447d24bd44d3a53f5a96fb71 | refs/heads/master | 2023-03-10T08:39:15.544000 | 2021-02-24T02:17:58 | 2021-02-24T02:17:58 | 341,395,351 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ideatech.ams.annual.dto.poi;
import lombok.Data;
/**
* 年检待处理导出类
* @author jzh
* @date 2019/4/25.
*/
@Data
public class AnnualWaitingProcessPoi {
/**
* 账号
*/
private String acctNo;
/**
* 企业名称
*/
private String depositorName;
/**
* 人行机构号
*/
private String organPbcCode;
/**
* 网点机构号
*/
private String organCode;
/**
* 单边状态
*/
private String unilateral;
/**
* 异常状态
* 多值用逗号分隔
*/
private String abnormal;
/**
* 工商状态
*/
private String saicStatus;
/**
* 数据一致性
*/
private String match;
/**
* 处理状态
*/
private String dataProcessStatus;
/**
* 账户性质
*/
private String acctType;
}
| UTF-8 | Java | 891 | java | AnnualWaitingProcessPoi.java | Java | [
{
"context": ";\n\nimport lombok.Data;\n\n/**\n * 年检待处理导出类\n * @author jzh\n * @date 2019/4/25.\n */\n@Data\npublic class Annual",
"end": 93,
"score": 0.9996581673622131,
"start": 90,
"tag": "USERNAME",
"value": "jzh"
}
] | null | [] | package com.ideatech.ams.annual.dto.poi;
import lombok.Data;
/**
* 年检待处理导出类
* @author jzh
* @date 2019/4/25.
*/
@Data
public class AnnualWaitingProcessPoi {
/**
* 账号
*/
private String acctNo;
/**
* 企业名称
*/
private String depositorName;
/**
* 人行机构号
*/
private String organPbcCode;
/**
* 网点机构号
*/
private String organCode;
/**
* 单边状态
*/
private String unilateral;
/**
* 异常状态
* 多值用逗号分隔
*/
private String abnormal;
/**
* 工商状态
*/
private String saicStatus;
/**
* 数据一致性
*/
private String match;
/**
* 处理状态
*/
private String dataProcessStatus;
/**
* 账户性质
*/
private String acctType;
}
| 891 | 0.501926 | 0.49294 | 63 | 11.365079 | 10.835423 | 40 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.190476 | false | false | 15 |
a0d4be63f104a78ea7c9c9bbdb0a5bb75675f134 | 1,434,519,079,816 | bca4b68ca6d8c1a8e0e5e7b35542d7acace6bb16 | /temp/src/pdr.src/io/dcloud/common/adapter/io/UnicodeInputStream.java | 27232d5594ea651304f9f30e7b65034c0edfcc42 | [] | no_license | ConAlgorithm/fastapp | https://github.com/ConAlgorithm/fastapp | a891ea9496b7cc0451823a4e2d9405b95dc77219 | 6f0b64cf055c71a7055e5d025df5d801e8706b9b | refs/heads/master | 2021-06-17T08:50:14.684000 | 2017-05-09T10:47:42 | 2017-05-09T10:47:42 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* */ package io.dcloud.common.adapter.io;
/* */
/* */ import java.io.IOException;
/* */ import java.io.InputStream;
/* */ import java.io.PushbackInputStream;
/* */
/* */ public class UnicodeInputStream extends InputStream
/* */ {
/* */ PushbackInputStream internalIn;
/* 19 */ boolean isInited = false;
/* */ String defaultEnc;
/* */ String encoding;
/* */ private static final int BOM_SIZE = 4;
/* */
/* */ public UnicodeInputStream(InputStream paramInputStream, String paramString)
/* */ {
/* 26 */ this.internalIn = new PushbackInputStream(paramInputStream, 4);
/* 27 */ this.defaultEnc = paramString;
/* */ }
/* */
/* */ public String getDefaultEncoding() {
/* 31 */ return this.defaultEnc;
/* */ }
/* */
/* */ public String getEncoding() {
/* 35 */ if (!this.isInited) {
/* */ try {
/* 37 */ init();
/* */ } catch (IOException localIOException) {
/* 39 */ IllegalStateException localIllegalStateException = new IllegalStateException("Init method failed.");
/* */
/* 41 */ localIllegalStateException.initCause(localIllegalStateException);
/* 42 */ throw localIllegalStateException;
/* */ }
/* */ }
/* 45 */ return this.encoding;
/* */ }
/* */
/* */ protected void init()
/* */ throws IOException
/* */ {
/* 53 */ if (this.isInited) {
/* 54 */ return;
/* */ }
/* 56 */ byte[] arrayOfByte = new byte[4];
/* */
/* 58 */ int i = this.internalIn.read(arrayOfByte, 0, arrayOfByte.length);
/* */ int j;
/* 60 */ if ((arrayOfByte[0] == 0) && (arrayOfByte[1] == 0) && (arrayOfByte[2] == -2) && (arrayOfByte[3] == -1))
/* */ {
/* 62 */ this.encoding = "UTF-32BE";
/* 63 */ j = i - 4;
/* 64 */ } else if ((arrayOfByte[0] == -1) && (arrayOfByte[1] == -2) && (arrayOfByte[2] == 0) && (arrayOfByte[3] == 0))
/* */ {
/* 66 */ this.encoding = "UTF-32LE";
/* 67 */ j = i - 4;
/* 68 */ } else if ((arrayOfByte[0] == -17) && (arrayOfByte[1] == -69) && (arrayOfByte[2] == -65))
/* */ {
/* 70 */ this.encoding = "UTF-8";
/* 71 */ j = i - 3;
/* 72 */ } else if ((arrayOfByte[0] == -2) && (arrayOfByte[1] == -1)) {
/* 73 */ this.encoding = "UTF-16BE";
/* 74 */ j = i - 2;
/* 75 */ } else if ((arrayOfByte[0] == -1) && (arrayOfByte[1] == -2)) {
/* 76 */ this.encoding = "UTF-16LE";
/* 77 */ j = i - 2;
/* */ }
/* */ else {
/* 80 */ this.encoding = this.defaultEnc;
/* 81 */ j = i;
/* */ }
/* */
/* 85 */ if (j > 0) {
/* 86 */ this.internalIn.unread(arrayOfByte, i - j, j);
/* */ }
/* 88 */ this.isInited = true;
/* */ }
/* */
/* */ public void close() throws IOException
/* */ {
/* 93 */ this.isInited = true;
/* 94 */ this.internalIn.close();
/* */ }
/* */
/* */ public int read() throws IOException {
/* 98 */ init();
/* 99 */ this.isInited = true;
/* 100 */ return this.internalIn.read();
/* */ }
/* */ }
/* Location: F:\xunlei\sdk\Android-SDK@1.9.9.29448_20170217\Android-SDK\SDK\libs\pdr.jar
* Qualified Name: io.dcloud.common.adapter.io.UnicodeInputStream
* JD-Core Version: 0.6.2
*/ | UTF-8 | Java | 3,442 | java | UnicodeInputStream.java | Java | [] | null | [] | /* */ package io.dcloud.common.adapter.io;
/* */
/* */ import java.io.IOException;
/* */ import java.io.InputStream;
/* */ import java.io.PushbackInputStream;
/* */
/* */ public class UnicodeInputStream extends InputStream
/* */ {
/* */ PushbackInputStream internalIn;
/* 19 */ boolean isInited = false;
/* */ String defaultEnc;
/* */ String encoding;
/* */ private static final int BOM_SIZE = 4;
/* */
/* */ public UnicodeInputStream(InputStream paramInputStream, String paramString)
/* */ {
/* 26 */ this.internalIn = new PushbackInputStream(paramInputStream, 4);
/* 27 */ this.defaultEnc = paramString;
/* */ }
/* */
/* */ public String getDefaultEncoding() {
/* 31 */ return this.defaultEnc;
/* */ }
/* */
/* */ public String getEncoding() {
/* 35 */ if (!this.isInited) {
/* */ try {
/* 37 */ init();
/* */ } catch (IOException localIOException) {
/* 39 */ IllegalStateException localIllegalStateException = new IllegalStateException("Init method failed.");
/* */
/* 41 */ localIllegalStateException.initCause(localIllegalStateException);
/* 42 */ throw localIllegalStateException;
/* */ }
/* */ }
/* 45 */ return this.encoding;
/* */ }
/* */
/* */ protected void init()
/* */ throws IOException
/* */ {
/* 53 */ if (this.isInited) {
/* 54 */ return;
/* */ }
/* 56 */ byte[] arrayOfByte = new byte[4];
/* */
/* 58 */ int i = this.internalIn.read(arrayOfByte, 0, arrayOfByte.length);
/* */ int j;
/* 60 */ if ((arrayOfByte[0] == 0) && (arrayOfByte[1] == 0) && (arrayOfByte[2] == -2) && (arrayOfByte[3] == -1))
/* */ {
/* 62 */ this.encoding = "UTF-32BE";
/* 63 */ j = i - 4;
/* 64 */ } else if ((arrayOfByte[0] == -1) && (arrayOfByte[1] == -2) && (arrayOfByte[2] == 0) && (arrayOfByte[3] == 0))
/* */ {
/* 66 */ this.encoding = "UTF-32LE";
/* 67 */ j = i - 4;
/* 68 */ } else if ((arrayOfByte[0] == -17) && (arrayOfByte[1] == -69) && (arrayOfByte[2] == -65))
/* */ {
/* 70 */ this.encoding = "UTF-8";
/* 71 */ j = i - 3;
/* 72 */ } else if ((arrayOfByte[0] == -2) && (arrayOfByte[1] == -1)) {
/* 73 */ this.encoding = "UTF-16BE";
/* 74 */ j = i - 2;
/* 75 */ } else if ((arrayOfByte[0] == -1) && (arrayOfByte[1] == -2)) {
/* 76 */ this.encoding = "UTF-16LE";
/* 77 */ j = i - 2;
/* */ }
/* */ else {
/* 80 */ this.encoding = this.defaultEnc;
/* 81 */ j = i;
/* */ }
/* */
/* 85 */ if (j > 0) {
/* 86 */ this.internalIn.unread(arrayOfByte, i - j, j);
/* */ }
/* 88 */ this.isInited = true;
/* */ }
/* */
/* */ public void close() throws IOException
/* */ {
/* 93 */ this.isInited = true;
/* 94 */ this.internalIn.close();
/* */ }
/* */
/* */ public int read() throws IOException {
/* 98 */ init();
/* 99 */ this.isInited = true;
/* 100 */ return this.internalIn.read();
/* */ }
/* */ }
/* Location: F:\xunlei\sdk\Android-SDK@1.9.9.29448_20170217\Android-SDK\SDK\libs\pdr.jar
* Qualified Name: io.dcloud.common.adapter.io.UnicodeInputStream
* JD-Core Version: 0.6.2
*/ | 3,442 | 0.475596 | 0.432016 | 95 | 35.242104 | 26.641762 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.484211 | false | false | 15 |
6193e4e36fec8b052d9390f02ff71f4b97d8a2ff | 15,315,853,385,827 | fe14d1b3a3bf2142c6930948458098f884d21fc2 | /app/src/main/java/com/example/jetpack/ui/addGoods/AddGoodsViewModel.java | c22927fdfd03f5c1f285f89ad300a54765e5665e | [] | no_license | FTDShanCai/jetpackdemo | https://github.com/FTDShanCai/jetpackdemo | 9eedf3d802f74d8556c95db14ec8bddca4b6cce5 | c8bde7867d7a8d8526903b8ed21169bac736492d | refs/heads/master | 2021-06-23T07:18:10.166000 | 2021-01-23T10:21:41 | 2021-01-23T10:21:41 | 186,396,474 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.jetpack.ui.addGoods;
import android.app.Application;
import android.content.Intent;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import com.example.jetpack.db.repository.GoodsDataSource;
import com.example.jetpack.db.repository.GoodsRepositroy;
import com.example.jetpack.entity.GoodsEntity;
import com.example.jetpack.ui.BaseAndroidViewModel;
/**
* @author ddc
* 邮箱: 931952032@qq.com
* <p>description:
*/
public class AddGoodsViewModel extends BaseAndroidViewModel<AddGoodsNavigator> {
private GoodsRepositroy repositroy;
private MutableLiveData<Boolean> isVisible = new MutableLiveData<>();
private MutableLiveData<String> name = new MutableLiveData<>();
private MutableLiveData<String> count = new MutableLiveData<>();
private MutableLiveData<String> desc = new MutableLiveData<>();
public MutableLiveData<String> imgPath = new MutableLiveData<>();
public MutableLiveData<Boolean> isEdit = new MutableLiveData<>();
public String SUBMIT = "提交";
public String UPDATE = "修改";
long goodsId = -1;
public AddGoodsViewModel(@NonNull Application application, GoodsRepositroy repositroy) {
super(application);
this.repositroy = repositroy;
isVisible.postValue(false);
}
@Override
public void onViewCrate(AddGoodsNavigator navigator) {
super.onViewCrate(navigator);
Intent intent = navigator.getIntentData();
if (intent != null) {
goodsId = intent.getLongExtra("goodsId", -1);
if (goodsId != -1) {
repositroy.queryGoods(goodsId, goods -> {
if (goods == null) return;
isEdit.postValue(true);
name.postValue(goods.getGoodsName());
count.postValue(goods.getGoodsCount());
desc.postValue(goods.getGoodsDesc());
imgPath.postValue(goods.getGoodsImg());
});
}
}
}
public MutableLiveData<String> getName() {
return name;
}
public MutableLiveData<String> getCount() {
return count;
}
public MutableLiveData<String> getDesc() {
return desc;
}
public MutableLiveData<Boolean> getIsVisible() {
return isVisible;
}
// public MutableLiveData<String> getImgPath() {
// return imgPath;
// }
//
// public void setImgPath(String imgPath) {
// this.imgPath.setValue(imgPath);
// }
public void showPicChoiceDialog() {
if (navigator != null) navigator.showPicChoiceDialog();
}
public void onSubmit() {
if (TextUtils.isEmpty(name.getValue())) {
toastMessage("请输入商品名称");
return;
}
if (TextUtils.isEmpty(count.getValue())) {
toastMessage("请输入商品库存");
return;
}
if (TextUtils.isEmpty(desc.getValue())) {
toastMessage("请输入商品介绍");
return;
}
if (TextUtils.isEmpty(imgPath.getValue())) {
toastMessage("请选择商品图片");
return;
}
GoodsEntity entity = new GoodsEntity(name.getValue(), count.getValue(), desc.getValue(), imgPath.getValue());
if (goodsId != -1) {
entity.setId(goodsId);
}
repositroy.insertOrUpdateGoods(() -> {
toastMessage("保存成功");
navigator.onSubmit();
}, entity);
// repositroy.insertGoods(entity, () -> {
// toastMessage("保存成功");
// navigator.onSubmit();
// });
}
}
| UTF-8 | Java | 3,729 | java | AddGoodsViewModel.java | Java | [
{
"context": "e.jetpack.ui.BaseAndroidViewModel;\n\n/**\n * @author ddc\n * 邮箱: 931952032@qq.com\n * <p>description:\n */\npu",
"end": 451,
"score": 0.9996375441551208,
"start": 448,
"tag": "USERNAME",
"value": "ddc"
},
{
"context": ".BaseAndroidViewModel;\n\n/**\n * @author ddc\n * 邮箱: 931952032@qq.com\n * <p>description:\n */\npublic class AddGoodsViewM",
"end": 475,
"score": 0.9995243549346924,
"start": 459,
"tag": "EMAIL",
"value": "931952032@qq.com"
}
] | null | [] | package com.example.jetpack.ui.addGoods;
import android.app.Application;
import android.content.Intent;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import com.example.jetpack.db.repository.GoodsDataSource;
import com.example.jetpack.db.repository.GoodsRepositroy;
import com.example.jetpack.entity.GoodsEntity;
import com.example.jetpack.ui.BaseAndroidViewModel;
/**
* @author ddc
* 邮箱: <EMAIL>
* <p>description:
*/
public class AddGoodsViewModel extends BaseAndroidViewModel<AddGoodsNavigator> {
private GoodsRepositroy repositroy;
private MutableLiveData<Boolean> isVisible = new MutableLiveData<>();
private MutableLiveData<String> name = new MutableLiveData<>();
private MutableLiveData<String> count = new MutableLiveData<>();
private MutableLiveData<String> desc = new MutableLiveData<>();
public MutableLiveData<String> imgPath = new MutableLiveData<>();
public MutableLiveData<Boolean> isEdit = new MutableLiveData<>();
public String SUBMIT = "提交";
public String UPDATE = "修改";
long goodsId = -1;
public AddGoodsViewModel(@NonNull Application application, GoodsRepositroy repositroy) {
super(application);
this.repositroy = repositroy;
isVisible.postValue(false);
}
@Override
public void onViewCrate(AddGoodsNavigator navigator) {
super.onViewCrate(navigator);
Intent intent = navigator.getIntentData();
if (intent != null) {
goodsId = intent.getLongExtra("goodsId", -1);
if (goodsId != -1) {
repositroy.queryGoods(goodsId, goods -> {
if (goods == null) return;
isEdit.postValue(true);
name.postValue(goods.getGoodsName());
count.postValue(goods.getGoodsCount());
desc.postValue(goods.getGoodsDesc());
imgPath.postValue(goods.getGoodsImg());
});
}
}
}
public MutableLiveData<String> getName() {
return name;
}
public MutableLiveData<String> getCount() {
return count;
}
public MutableLiveData<String> getDesc() {
return desc;
}
public MutableLiveData<Boolean> getIsVisible() {
return isVisible;
}
// public MutableLiveData<String> getImgPath() {
// return imgPath;
// }
//
// public void setImgPath(String imgPath) {
// this.imgPath.setValue(imgPath);
// }
public void showPicChoiceDialog() {
if (navigator != null) navigator.showPicChoiceDialog();
}
public void onSubmit() {
if (TextUtils.isEmpty(name.getValue())) {
toastMessage("请输入商品名称");
return;
}
if (TextUtils.isEmpty(count.getValue())) {
toastMessage("请输入商品库存");
return;
}
if (TextUtils.isEmpty(desc.getValue())) {
toastMessage("请输入商品介绍");
return;
}
if (TextUtils.isEmpty(imgPath.getValue())) {
toastMessage("请选择商品图片");
return;
}
GoodsEntity entity = new GoodsEntity(name.getValue(), count.getValue(), desc.getValue(), imgPath.getValue());
if (goodsId != -1) {
entity.setId(goodsId);
}
repositroy.insertOrUpdateGoods(() -> {
toastMessage("保存成功");
navigator.onSubmit();
}, entity);
// repositroy.insertGoods(entity, () -> {
// toastMessage("保存成功");
// navigator.onSubmit();
// });
}
}
| 3,720 | 0.609877 | 0.60631 | 124 | 28.395161 | 24.00061 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.516129 | false | false | 15 |
3ac195131908822c369b81ae7bbbaa58486847d0 | 19,112,604,529,968 | b7693e7a6ba1c217c17b257f56367a6c826193f2 | /plugins/org.ifc4emf.metamodel.express/src/org/ifc4emf/metamodel/express/core/GeneralAggregationType.java | 8b38b0292be89042b6487a6b1dacb004610fd07f | [] | no_license | patins1/ifc4emf | https://github.com/patins1/ifc4emf | 6941967114f87965ea124c36b95aaedc5ef01349 | ad65df3fce500e5691625d4e0906041c8c0db284 | refs/heads/master | 2021-01-19T10:40:16.758000 | 2017-09-11T02:25:57 | 2017-09-11T02:25:57 | 87,891,492 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.ifc4emf.metamodel.express.core;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>General Aggregation Type</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link org.ifc4emf.metamodel.express.core.GeneralAggregationType#getMemberType <em>Member Type</em>}</li>
* </ul>
* </p>
*
* @see org.ifc4emf.metamodel.express.core.CorePackage#getGeneralAggregationType()
* @model abstract="true"
* @generated
*/
public interface GeneralAggregationType extends GeneralizedType, AggregationType {
/**
* Returns the value of the '<em><b>Member Type</b></em>' reference.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Member Type</em>' reference isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Member Type</em>' reference.
* @see #setMemberType(GeneralizedType)
* @see org.ifc4emf.metamodel.express.core.CorePackage#getGeneralAggregationType_MemberType()
* @model required="true" ordered="false"
* @generated
*/
GeneralizedType getMemberType();
/**
* Sets the value of the '{@link org.ifc4emf.metamodel.express.core.GeneralAggregationType#getMemberType <em>Member Type</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Member Type</em>' reference.
* @see #getMemberType()
* @generated
*/
void setMemberType(GeneralizedType value);
} // GeneralAggregationType
| UTF-8 | Java | 1,655 | java | GeneralAggregationType.java | Java | [] | null | [] | /**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.ifc4emf.metamodel.express.core;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>General Aggregation Type</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link org.ifc4emf.metamodel.express.core.GeneralAggregationType#getMemberType <em>Member Type</em>}</li>
* </ul>
* </p>
*
* @see org.ifc4emf.metamodel.express.core.CorePackage#getGeneralAggregationType()
* @model abstract="true"
* @generated
*/
public interface GeneralAggregationType extends GeneralizedType, AggregationType {
/**
* Returns the value of the '<em><b>Member Type</b></em>' reference.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Member Type</em>' reference isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Member Type</em>' reference.
* @see #setMemberType(GeneralizedType)
* @see org.ifc4emf.metamodel.express.core.CorePackage#getGeneralAggregationType_MemberType()
* @model required="true" ordered="false"
* @generated
*/
GeneralizedType getMemberType();
/**
* Sets the value of the '{@link org.ifc4emf.metamodel.express.core.GeneralAggregationType#getMemberType <em>Member Type</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Member Type</em>' reference.
* @see #getMemberType()
* @generated
*/
void setMemberType(GeneralizedType value);
} // GeneralAggregationType
| 1,655 | 0.648338 | 0.645317 | 53 | 29.226416 | 32.268124 | 139 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.54717 | false | false | 15 |
0297883733f18c04bdcc7f74a0756b7935ef3857 | 29,515,015,281,714 | f255e58e9988f79e1e56935a94dbeaf732a45146 | /app/src/main/java/com/svs/svs/ActivityText.java | 1605953266a749d92ecc77f2b532a2e577b1de8a | [] | no_license | MuhammadShuja/SVS | https://github.com/MuhammadShuja/SVS | 4e28a01c1acfb6a2ac8f147eebb35505a18972d6 | 530b48de14016ff914ad39356812fa1cf853c60b | refs/heads/master | 2020-07-28T08:22:49.824000 | 2019-09-18T17:05:32 | 2019-09-18T17:05:32 | 209,363,218 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.svs.svs;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.io.IOException;
public class ActivityText extends AppCompatActivity {
private static final int CONTACT_SELECTION_PERMISSION = 1;
private String contactNumber="", contactName="", textMessage=null;
private Button btnBrowse, btnSend;
private EditText inputContact, inputMessage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.activity_text);
inputContact = (EditText) findViewById(R.id.inputContact);
inputMessage = (EditText) findViewById(R.id.inputMessage);
btnBrowse = (Button) findViewById(R.id.btnBrowse);
btnBrowse.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i=new Intent(Intent.ACTION_PICK);
i.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(i, CONTACT_SELECTION_PERMISSION);
}
});
btnSend = (Button) findViewById(R.id.btnSend);
btnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
textMessage = inputMessage.getText().toString();
if(contactName == "" || contactNumber == ""){
Toast.makeText(getBaseContext(), "Please select contact before sending a message.", Toast.LENGTH_LONG).show();
return;
}
if(textMessage.isEmpty()){
Toast.makeText(getBaseContext(), "There's nothing to send, please write something.", Toast.LENGTH_LONG).show();
return;
}
SMSHandler.INSTANCE.newMessage(ActivityText.this, SMSHandler.SMS_TYPE_STRING, textMessage, contactNumber);
SMSHandler.INSTANCE.send();
}
});
}
@Override
protected void onActivityResult(int reqCode, int resultCode, Intent data) {
if(reqCode == CONTACT_SELECTION_PERMISSION){
if(resultCode == RESULT_OK){
Cursor cursor = null;
try {
Uri uri = data.getData();
cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
int phoneIndex =cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
int nameIndex =cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
contactNumber = cursor.getString(phoneIndex);
contactName = cursor.getString(nameIndex);
inputContact.setText(contactName);
Toast.makeText(this, "Name: "+contactName+"..Number: "+contactNumber, Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
}finally{
cursor.close();
}
}
}
}
}
| UTF-8 | Java | 3,542 | java | ActivityText.java | Java | [] | null | [] | package com.svs.svs;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.io.IOException;
public class ActivityText extends AppCompatActivity {
private static final int CONTACT_SELECTION_PERMISSION = 1;
private String contactNumber="", contactName="", textMessage=null;
private Button btnBrowse, btnSend;
private EditText inputContact, inputMessage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.activity_text);
inputContact = (EditText) findViewById(R.id.inputContact);
inputMessage = (EditText) findViewById(R.id.inputMessage);
btnBrowse = (Button) findViewById(R.id.btnBrowse);
btnBrowse.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i=new Intent(Intent.ACTION_PICK);
i.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(i, CONTACT_SELECTION_PERMISSION);
}
});
btnSend = (Button) findViewById(R.id.btnSend);
btnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
textMessage = inputMessage.getText().toString();
if(contactName == "" || contactNumber == ""){
Toast.makeText(getBaseContext(), "Please select contact before sending a message.", Toast.LENGTH_LONG).show();
return;
}
if(textMessage.isEmpty()){
Toast.makeText(getBaseContext(), "There's nothing to send, please write something.", Toast.LENGTH_LONG).show();
return;
}
SMSHandler.INSTANCE.newMessage(ActivityText.this, SMSHandler.SMS_TYPE_STRING, textMessage, contactNumber);
SMSHandler.INSTANCE.send();
}
});
}
@Override
protected void onActivityResult(int reqCode, int resultCode, Intent data) {
if(reqCode == CONTACT_SELECTION_PERMISSION){
if(resultCode == RESULT_OK){
Cursor cursor = null;
try {
Uri uri = data.getData();
cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
int phoneIndex =cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
int nameIndex =cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
contactNumber = cursor.getString(phoneIndex);
contactName = cursor.getString(nameIndex);
inputContact.setText(contactName);
Toast.makeText(this, "Name: "+contactName+"..Number: "+contactNumber, Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
}finally{
cursor.close();
}
}
}
}
}
| 3,542 | 0.616036 | 0.615471 | 86 | 40.186047 | 31.396383 | 131 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.825581 | false | false | 15 |
1f406d7d68c0a67dcffcd93ccacd81d4eb517d7c | 2,645,699,878,513 | f092d9e88b49de6b76d6c96580dbc6a2f6009f30 | /easy/problem001_twoSum/Solution.java | da83f61f6b0f471df094cb9752861bf3a9367fc9 | [] | no_license | ukmjkim/leetcode | https://github.com/ukmjkim/leetcode | 93802c716bd487ccf0ffd8be790a9d6eb8ac6d41 | 03395a7ae8c0026c0ee66b04028c21be558bb1b6 | refs/heads/master | 2023-03-16T03:43:59.433000 | 2023-03-03T23:40:38 | 2023-03-03T23:40:38 | 100,893,750 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // indices of the two numbers
// no sort
// no Brute Force
import java.util.*;
public class Solution {
public int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> map = new HashMap<>();
for (int i=0, max=nums.length; i < max; i++) {
int diff = target - nums[i];
if (map.containsKey(diff)) {
return new int[] {map.get(diff), i};
} else {
map.put(nums[i], i);
}
}
return new int[]{};
}
public static void main(String[] args) {
int[] nums;
int target;
int[] expected;
Solution solution = new Solution();
// Sorted
nums = new int[] {2, 7, 11, 15};
target = 9;
expected = new int[] {0, 1};
if (Arrays.equals(solution.twoSum(nums, target), expected)) {
System.out.printf("result: matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
} else {
System.out.printf("result: not matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
}
nums = new int[] {2, 7, 11, 15};
target = 13;
expected = new int[] {0, 2};
if (Arrays.equals(solution.twoSum(nums, target), expected)) {
System.out.printf("result: matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
} else {
System.out.printf("result: not matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
}
// Not Sorted
nums = new int[] {11, 7, 2, 15};
target = 18;
expected = new int[] {0, 1};
if (Arrays.equals(solution.twoSum(nums, target), expected)) {
System.out.printf("result: matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
} else {
System.out.printf("result: not matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
}
}
}
| UTF-8 | Java | 2,104 | java | Solution.java | Java | [] | null | [] | // indices of the two numbers
// no sort
// no Brute Force
import java.util.*;
public class Solution {
public int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> map = new HashMap<>();
for (int i=0, max=nums.length; i < max; i++) {
int diff = target - nums[i];
if (map.containsKey(diff)) {
return new int[] {map.get(diff), i};
} else {
map.put(nums[i], i);
}
}
return new int[]{};
}
public static void main(String[] args) {
int[] nums;
int target;
int[] expected;
Solution solution = new Solution();
// Sorted
nums = new int[] {2, 7, 11, 15};
target = 9;
expected = new int[] {0, 1};
if (Arrays.equals(solution.twoSum(nums, target), expected)) {
System.out.printf("result: matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
} else {
System.out.printf("result: not matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
}
nums = new int[] {2, 7, 11, 15};
target = 13;
expected = new int[] {0, 2};
if (Arrays.equals(solution.twoSum(nums, target), expected)) {
System.out.printf("result: matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
} else {
System.out.printf("result: not matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
}
// Not Sorted
nums = new int[] {11, 7, 2, 15};
target = 18;
expected = new int[] {0, 1};
if (Arrays.equals(solution.twoSum(nums, target), expected)) {
System.out.printf("result: matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
} else {
System.out.printf("result: not matched nums: %s, target: %d, result: %s\n", Arrays.toString(nums), target, Arrays.toString(solution.twoSum(nums, target)));
}
}
}
| 2,104 | 0.611217 | 0.596958 | 59 | 34.64407 | 45.306026 | 161 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.457627 | false | false | 15 |
511fde79e17471f3464cfca5fde8fcd3175c96a9 | 1,176,821,078,399 | d0f8d7a89843d16bb68dd7f1c5d4190f409ef00a | /src/main/java/com/red/star/wechat/work/site/admin/service/impl/ResourceServiceImpl.java | dacba37e945b831d1bb082576a9abaa49b524f6e | [] | no_license | lipiapia/redstar | https://github.com/lipiapia/redstar | 8978692d5181bd0bcbaac0b75bf377b3734ca298 | 06fad135e96d1c241da05ea12b295e4e0f61dcc2 | refs/heads/master | 2020-04-08T15:37:04.581000 | 2018-12-10T10:05:12 | 2018-12-10T10:05:12 | 159,485,719 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.red.star.wechat.work.site.admin.service.impl;
import com.red.star.wechat.work.entity.Resource;
import com.red.star.wechat.work.entity.Role;
import com.red.star.wechat.work.site.admin.mapper.ResourceMapper;
import com.red.star.wechat.work.site.admin.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.access.SecurityConfig;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* @author nofish.yan@gmail.com
* @date 2018/1/29.
*/
@Service("resService")
public class ResourceServiceImpl implements ResourceService {
@Autowired
private ResourceMapper resourceMapper;
@Override
public Map<String, Collection<ConfigAttribute>> getResourceMap() {
Map<String, Collection<ConfigAttribute>> result = new HashMap<>();
List<Resource> resources = resourceMapper.findAll();
for (Resource resource : resources) {
Set<ConfigAttribute> itemAttributes = new HashSet<>();
for (Role role : resource.getRoles()) {
ConfigAttribute ca = new SecurityConfig(role.getAuthority());
itemAttributes.add(ca);
}
result.put(resource.getAddress(), itemAttributes);
}
return result;
}
@Override
public List<Resource> findAll() {
return resourceMapper.findAll();
}
}
| UTF-8 | Java | 1,466 | java | ResourceServiceImpl.java | Java | [
{
"context": "type.Service;\n\nimport java.util.*;\n\n/**\n * @author nofish.yan@gmail.com\n * @date 2018/1/29.\n */\n@Service(\"resService\")\npu",
"end": 573,
"score": 0.9999088644981384,
"start": 553,
"tag": "EMAIL",
"value": "nofish.yan@gmail.com"
}
] | null | [] | package com.red.star.wechat.work.site.admin.service.impl;
import com.red.star.wechat.work.entity.Resource;
import com.red.star.wechat.work.entity.Role;
import com.red.star.wechat.work.site.admin.mapper.ResourceMapper;
import com.red.star.wechat.work.site.admin.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.access.SecurityConfig;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* @author <EMAIL>
* @date 2018/1/29.
*/
@Service("resService")
public class ResourceServiceImpl implements ResourceService {
@Autowired
private ResourceMapper resourceMapper;
@Override
public Map<String, Collection<ConfigAttribute>> getResourceMap() {
Map<String, Collection<ConfigAttribute>> result = new HashMap<>();
List<Resource> resources = resourceMapper.findAll();
for (Resource resource : resources) {
Set<ConfigAttribute> itemAttributes = new HashSet<>();
for (Role role : resource.getRoles()) {
ConfigAttribute ca = new SecurityConfig(role.getAuthority());
itemAttributes.add(ca);
}
result.put(resource.getAddress(), itemAttributes);
}
return result;
}
@Override
public List<Resource> findAll() {
return resourceMapper.findAll();
}
}
| 1,453 | 0.704638 | 0.699864 | 44 | 32.31818 | 25.788275 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 15 |
6e6a6e7870b9abfc30f4e8d5b6af0014617c7d5c | 33,165,737,490,419 | ff41c841e64dcf873ac8b987c8869f1b9292c3a8 | /clone.java | 57b9b63b63533847df526e3f3d1d7bac685dfa52 | [] | no_license | simrandeol1/java_codes_foobar | https://github.com/simrandeol1/java_codes_foobar | 6615dd410f3cd40d2600b2a0a142e8b2e078e7a6 | a23246179a9e015a4a323698f51ebab603165f05 | refs/heads/master | 2021-09-24T07:20:15.018000 | 2017-10-25T10:59:57 | 2017-10-25T10:59:57 | 108,257,831 | 0 | 1 | null | true | 2018-10-05T06:54:35 | 2017-10-25T10:56:47 | 2017-10-25T10:56:49 | 2017-10-25T10:59:57 | 18 | 0 | 1 | 1 | Java | false | null | import java.util.Scanner;
public class clone {
public static void clones(){
Scanner t = new Scanner(System.in);
int n = t.nextInt();
int num = t.nextInt();
while (num >0){
int number = t.nextInt();
if (number == n){
System.out.println("-1");}
else{
int display = n - number;
int i = display;
while(i > 0){
System.out.println(number);
i=i-1;}}
num = num -1;}
}
public static void main(String[] args){
clones();}
}
| UTF-8 | Java | 552 | java | clone.java | Java | [] | null | [] | import java.util.Scanner;
public class clone {
public static void clones(){
Scanner t = new Scanner(System.in);
int n = t.nextInt();
int num = t.nextInt();
while (num >0){
int number = t.nextInt();
if (number == n){
System.out.println("-1");}
else{
int display = n - number;
int i = display;
while(i > 0){
System.out.println(number);
i=i-1;}}
num = num -1;}
}
public static void main(String[] args){
clones();}
}
| 552 | 0.48913 | 0.480072 | 30 | 16.4 | 12.273549 | 43 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 15 |
de9455a860d9a1ca5f95ae3d10221d9496a0b181 | 32,006,096,332,058 | 183b475f118d5bb4c028464b8fdbc48349159ad0 | /app/src/main/java/com/yeeyun/todo/presenter/contract/LoginContract.java | 6883386fbd9dffe16370b4602b5b3a539245e31b | [] | no_license | JuiceShui/Yeeyun | https://github.com/JuiceShui/Yeeyun | b22d92af79bb7cee5b8f1a5bf9dff101106e50bb | 174c7924a469c2c0a030aa7349c713492033bb26 | refs/heads/master | 2018-03-28T13:30:19.213000 | 2017-04-08T06:04:40 | 2017-04-08T06:04:40 | 87,533,204 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.yeeyun.todo.presenter.contract;
import com.yeeyun.todo.base.BasePresenter;
import com.yeeyun.todo.base.BaseView;
/**
* 作者: JuiceShui on 2017/4/7.
* We improve ourselves by victories over ourselves.
* There must be contests, and we must win.
*/
/**
* 登录界面的contract
*/
public interface LoginContract {
interface View extends BaseView
{
/**
* 登录成功 跳转到主页面
*/
void jumpToMain();
/**
* 显示登录错误
* @param error
*/
void showMistake(String error);
}
interface Presenter extends BasePresenter<View>
{ /**
*执行登录
*/
void doLogin(String account,String passWord);
/**
* 保存密码
* @param account 账号
* @param passWord 密码
*/
void saveInfo(String account,String passWord);
}
}
| UTF-8 | Java | 968 | java | LoginContract.java | Java | [
{
"context": "port com.yeeyun.todo.base.BaseView;\r\n\r\n/**\r\n * 作者: JuiceShui on 2017/4/7.\r\n * We improve ourselves by victorie",
"end": 153,
"score": 0.9980769157409668,
"start": 144,
"tag": "USERNAME",
"value": "JuiceShui"
},
{
"context": " * @param account 账号\r\n * @param passWord 密码\r\n */\r\n void saveInfo(String accoun",
"end": 815,
"score": 0.9912892580032349,
"start": 813,
"tag": "PASSWORD",
"value": "密码"
}
] | null | [] | package com.yeeyun.todo.presenter.contract;
import com.yeeyun.todo.base.BasePresenter;
import com.yeeyun.todo.base.BaseView;
/**
* 作者: JuiceShui on 2017/4/7.
* We improve ourselves by victories over ourselves.
* There must be contests, and we must win.
*/
/**
* 登录界面的contract
*/
public interface LoginContract {
interface View extends BaseView
{
/**
* 登录成功 跳转到主页面
*/
void jumpToMain();
/**
* 显示登录错误
* @param error
*/
void showMistake(String error);
}
interface Presenter extends BasePresenter<View>
{ /**
*执行登录
*/
void doLogin(String account,String passWord);
/**
* 保存密码
* @param account 账号
* @param passWord 密码
*/
void saveInfo(String account,String passWord);
}
}
| 968 | 0.543527 | 0.53683 | 42 | 19.333334 | 16.967289 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.238095 | false | false | 15 |
540fbaa5e780c23d9866392028071ca264f7bbd2 | 17,875,653,934,097 | a7246e9b0d69b29f656ccc12103fce4365a3f0db | /sources/com/camerasideas/collagemaker/activity/fragment/imagefragment/j.java | 8e3db638de3d82eeb1d8658627bdff4374b222e0 | [] | no_license | dungnguyenBKA/app1-decompile | https://github.com/dungnguyenBKA/app1-decompile | e1343b0505bfc8532409f5a51ddc9ac7ad439e04 | 5b9aadc0fb75d6f276e7f8ed912b430896989b15 | refs/heads/master | 2023-07-26T01:41:47.981000 | 2021-09-10T13:24:12 | 2021-09-10T13:24:12 | 405,087,480 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.camerasideas.collagemaker.activity.fragment.imagefragment;
import android.net.Uri;
import com.camerasideas.collagemaker.filter.ISCropFilter;
public final /* synthetic */ class j implements vd0 {
public final /* synthetic */ ImageCutoutBgFragment a;
public final /* synthetic */ Uri b;
public final /* synthetic */ ISCropFilter c;
public /* synthetic */ j(ImageCutoutBgFragment imageCutoutBgFragment, Uri uri, ISCropFilter iSCropFilter) {
this.a = imageCutoutBgFragment;
this.b = uri;
this.c = iSCropFilter;
}
@Override // defpackage.vd0
public final void a(ud0 ud0) {
this.a.f2(this.b, this.c, ud0);
}
}
| UTF-8 | Java | 684 | java | j.java | Java | [] | null | [] | package com.camerasideas.collagemaker.activity.fragment.imagefragment;
import android.net.Uri;
import com.camerasideas.collagemaker.filter.ISCropFilter;
public final /* synthetic */ class j implements vd0 {
public final /* synthetic */ ImageCutoutBgFragment a;
public final /* synthetic */ Uri b;
public final /* synthetic */ ISCropFilter c;
public /* synthetic */ j(ImageCutoutBgFragment imageCutoutBgFragment, Uri uri, ISCropFilter iSCropFilter) {
this.a = imageCutoutBgFragment;
this.b = uri;
this.c = iSCropFilter;
}
@Override // defpackage.vd0
public final void a(ud0 ud0) {
this.a.f2(this.b, this.c, ud0);
}
}
| 684 | 0.69152 | 0.682749 | 21 | 31.571428 | 28.031567 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 15 |
592d3ab0c39f467aec8a79ffc2072ae3a0269fa5 | 2,688,649,597,311 | 678a3d58c110afd1e9ce195d2f20b2531d45a2e0 | /sources/com/airbnb/android/booking/fragments/alipayv2/AlipayV2RetryFragment$$Lambda$2.java | 8e3b52d9bc62d8296a4666626ff5e9b42eb5fb72 | [] | no_license | jasonnth/AirCode | https://github.com/jasonnth/AirCode | d1c37fb9ba3d8087efcdd9fa2103fb85d13735d5 | d37db1baa493fca56f390c4205faf5c9bbe36604 | refs/heads/master | 2020-07-03T08:35:24.902000 | 2019-08-12T03:34:56 | 2019-08-12T03:34:56 | 201,842,970 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.airbnb.android.booking.fragments.alipayv2;
import android.view.View;
import android.view.View.OnClickListener;
final /* synthetic */ class AlipayV2RetryFragment$$Lambda$2 implements OnClickListener {
private final AlipayV2RetryFragment arg$1;
private AlipayV2RetryFragment$$Lambda$2(AlipayV2RetryFragment alipayV2RetryFragment) {
this.arg$1 = alipayV2RetryFragment;
}
public static OnClickListener lambdaFactory$(AlipayV2RetryFragment alipayV2RetryFragment) {
return new AlipayV2RetryFragment$$Lambda$2(alipayV2RetryFragment);
}
public void onClick(View view) {
AlipayV2RetryFragment.lambda$onCreateView$1(this.arg$1, view);
}
}
| UTF-8 | Java | 698 | java | AlipayV2RetryFragment$$Lambda$2.java | Java | [] | null | [] | package com.airbnb.android.booking.fragments.alipayv2;
import android.view.View;
import android.view.View.OnClickListener;
final /* synthetic */ class AlipayV2RetryFragment$$Lambda$2 implements OnClickListener {
private final AlipayV2RetryFragment arg$1;
private AlipayV2RetryFragment$$Lambda$2(AlipayV2RetryFragment alipayV2RetryFragment) {
this.arg$1 = alipayV2RetryFragment;
}
public static OnClickListener lambdaFactory$(AlipayV2RetryFragment alipayV2RetryFragment) {
return new AlipayV2RetryFragment$$Lambda$2(alipayV2RetryFragment);
}
public void onClick(View view) {
AlipayV2RetryFragment.lambda$onCreateView$1(this.arg$1, view);
}
}
| 698 | 0.767908 | 0.740688 | 20 | 33.900002 | 33.778545 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 15 |
10e6d21b8a29444a02fd958155683e08451314a7 | 3,539,053,108,804 | d84fb71a651132a6afba4c5671c32d666d454148 | /src/main/java/ReachingPoint.java | 06bb6b6ca400a3a2f63a7e9cd8d4b166bdc3b0a7 | [] | no_license | QWERTYP5391/more-practice | https://github.com/QWERTYP5391/more-practice | afd09b905f158926977af89ecf6a8dff5092a206 | 2b144ad8ab199fa75d1428e70972da184e257bde | refs/heads/master | 2021-06-28T08:08:26.996000 | 2020-08-07T14:35:15 | 2020-08-07T14:35:15 | 173,505,141 | 0 | 0 | null | false | 2020-10-13T12:12:06 | 2019-03-02T22:20:17 | 2020-08-07T14:35:23 | 2020-10-13T12:12:04 | 53 | 0 | 0 | 1 | Java | false | false | class ReachingPoint {
private static boolean result = false;
public static boolean reachingPoints(int sx, int sy, int tx, int ty) {
dfs(sx, sy, tx, ty, new boolean[tx + 1][ty + 1]);
return result;
}
private static void dfs(int sx, int sy, int tx, int ty, boolean[][] visited) {
if (sx > tx || sy > ty) {
return;
}
if (visited[sx][sy]) {
return;
}
if (sx == tx && sy == ty) {
result = true;
return;
}
dfs(sx, sx + sy, tx, ty, visited);
dfs(sx + sy, sy, tx, ty, visited);
visited[sx][sy] = true;
}
} | UTF-8 | Java | 663 | java | ReachingPoint.java | Java | [] | null | [] | class ReachingPoint {
private static boolean result = false;
public static boolean reachingPoints(int sx, int sy, int tx, int ty) {
dfs(sx, sy, tx, ty, new boolean[tx + 1][ty + 1]);
return result;
}
private static void dfs(int sx, int sy, int tx, int ty, boolean[][] visited) {
if (sx > tx || sy > ty) {
return;
}
if (visited[sx][sy]) {
return;
}
if (sx == tx && sy == ty) {
result = true;
return;
}
dfs(sx, sx + sy, tx, ty, visited);
dfs(sx + sy, sy, tx, ty, visited);
visited[sx][sy] = true;
}
} | 663 | 0.46908 | 0.466063 | 32 | 19.75 | 21.945957 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.96875 | false | false | 15 |
5c9dc569e22d85eb48c52aceb3a46ce7830e4ec8 | 31,817,117,777,304 | 25181b803a6da5fa748bc8ec353cd2f3a3a836ed | /clientAndServer/circle/data/java/g/data/admin/agent/currency/AgentCurrencyExchangeMapper.java | c753987663e8fdd2a04bf9dc80edcdae03ce39f5 | [] | no_license | primary10/bullCard | https://github.com/primary10/bullCard | 991ed8619cac7a75fa56ce8cb6879f6c0bba2d62 | 39f4e36624a692b8fb6d991b791e0e2e9e8d7722 | refs/heads/master | 2022-11-08T02:20:57.135000 | 2019-10-12T01:15:52 | 2019-10-12T01:15:52 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package g.data.admin.agent.currency;
import g.model.admin.agent.currency.po.AgentCurrencyExchange;
import org.soul.data.rdb.mybatis.IBaseMapper;
/**
* 货币汇率数据访问对象
*
* @author black
* @time 2016-11-28 11:26:51
*/
//region your codes 1
public interface AgentCurrencyExchangeMapper extends IBaseMapper<AgentCurrencyExchange, Integer> {
//endregion your codes 1
//region your codes 2
//endregion your codes 2
} | UTF-8 | Java | 444 | java | AgentCurrencyExchangeMapper.java | Java | [
{
"context": "tis.IBaseMapper;\n\n\n/**\n * 货币汇率数据访问对象\n *\n * @author black\n * @time 2016-11-28 11:26:51\n */\n//region your co",
"end": 185,
"score": 0.9760494232177734,
"start": 180,
"tag": "USERNAME",
"value": "black"
}
] | null | [] | package g.data.admin.agent.currency;
import g.model.admin.agent.currency.po.AgentCurrencyExchange;
import org.soul.data.rdb.mybatis.IBaseMapper;
/**
* 货币汇率数据访问对象
*
* @author black
* @time 2016-11-28 11:26:51
*/
//region your codes 1
public interface AgentCurrencyExchangeMapper extends IBaseMapper<AgentCurrencyExchange, Integer> {
//endregion your codes 1
//region your codes 2
//endregion your codes 2
} | 444 | 0.75 | 0.707547 | 21 | 19.238094 | 24.428526 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.190476 | false | false | 15 |
5cbd05b5481ff59530c954a0c53453d0f85f8843 | 37,778,532,340,247 | 833423de9043268a14b6e63428efc6a9b6f16bb4 | /app/src/main/java/online/icording/smartbulter2_01/entity/TopNewsData.java | 9daa4c6e047c73bf69f74411d4d23fa7b11bc44f | [] | no_license | yangtaoyao/Android | https://github.com/yangtaoyao/Android | f6f21564b4503a15c37757f379fa7bca89b153c5 | 4c7509190e8207a64d8d904f2d224ce7e02fe391 | refs/heads/master | 2020-03-17T10:52:47.831000 | 2018-05-15T15:25:57 | 2018-05-15T15:25:57 | 133,528,998 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package online.icording.smartbulter2_01.entity;
/**
* 项目名 SmartBulter
* 包名 online.icording.smartbulter.entity
* 创建时间 2018/4/22 0022 0:27
* 创建者 yangtaoyao
* 描述 TODO
**/
public class TopNewsData {
public static final int TYPE_ONE=1;
public static final int TYPE_TWO=2;
public static final int TYPE_THREE=3;
private int type;
private String title;
private String source;
private String wechat_date;
private String imgUrl="";
private String imgUrl02="";
private String imgUrl03="";
private String newUrl;
public String getImgUrl02() {
return imgUrl02;
}
public void setImgUrl02(String imgUrl02) {
this.imgUrl02 = imgUrl02;
}
public String getImgUrl03() {
return imgUrl03;
}
public void setImgUrl03(String imgUrl03) {
this.imgUrl03 = imgUrl03;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public String getNewUrl() {
return newUrl;
}
public void setNewUrl(String newUrl) {
this.newUrl = newUrl;
}
public String getWechat_date() {
return wechat_date;
}
public void setWechat_date(String wechat_date) {
this.wechat_date = wechat_date;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}
| UTF-8 | Java | 1,771 | java | TopNewsData.java | Java | [
{
"context": "ter.entity\n * 创建时间 2018/4/22 0022 0:27\n * 创建者 yangtaoyao\n * 描述 TODO\n **/\npublic class TopNewsData {\n ",
"end": 172,
"score": 0.9996997117996216,
"start": 162,
"tag": "USERNAME",
"value": "yangtaoyao"
}
] | null | [] | package online.icording.smartbulter2_01.entity;
/**
* 项目名 SmartBulter
* 包名 online.icording.smartbulter.entity
* 创建时间 2018/4/22 0022 0:27
* 创建者 yangtaoyao
* 描述 TODO
**/
public class TopNewsData {
public static final int TYPE_ONE=1;
public static final int TYPE_TWO=2;
public static final int TYPE_THREE=3;
private int type;
private String title;
private String source;
private String wechat_date;
private String imgUrl="";
private String imgUrl02="";
private String imgUrl03="";
private String newUrl;
public String getImgUrl02() {
return imgUrl02;
}
public void setImgUrl02(String imgUrl02) {
this.imgUrl02 = imgUrl02;
}
public String getImgUrl03() {
return imgUrl03;
}
public void setImgUrl03(String imgUrl03) {
this.imgUrl03 = imgUrl03;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public String getNewUrl() {
return newUrl;
}
public void setNewUrl(String newUrl) {
this.newUrl = newUrl;
}
public String getWechat_date() {
return wechat_date;
}
public void setWechat_date(String wechat_date) {
this.wechat_date = wechat_date;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}
| 1,771 | 0.602983 | 0.575445 | 90 | 18.366667 | 15.820837 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.311111 | false | false | 15 |
055136c770ffbe9e73eed5c2c80c035aaf8cbf9c | 18,734,647,395,818 | a143664ca5b2849dd857c98560f224fd684b8c18 | /src/Question119.java | d2bb1a8aa78db0173b42f477fd9c642a5d1a9dd8 | [] | no_license | Dench991228/MyLeetcode | https://github.com/Dench991228/MyLeetcode | b2d1172d5d67b9a6a347743e66b587189c636fb4 | bb8712b620dc6601d70e64a1e215e8c2de325559 | refs/heads/main | 2023-03-13T06:31:33.744000 | 2021-03-05T02:56:01 | 2021-03-05T02:56:01 | 336,449,338 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.LinkedList;
import java.util.List;
public class Question119 {
/**
* 占用常数空间的杨辉三角形问题
* */
public List<Integer> getRow(int rowIndex) {
int[] triangle = new int[rowIndex+1];
for(int i=0;i<=rowIndex;i++){
triangle[0] = 1;
triangle[rowIndex] = 1;
for(int j=rowIndex-1;j-1>=0;j--){
System.out.println(j);
triangle[j] = triangle[j] + triangle[j-1];
}
}
LinkedList<Integer> result = new LinkedList<>();
for(int i:triangle){
result.addLast(i);
}
return result;
}
}
| UTF-8 | Java | 671 | java | Question119.java | Java | [] | null | [] | import java.util.LinkedList;
import java.util.List;
public class Question119 {
/**
* 占用常数空间的杨辉三角形问题
* */
public List<Integer> getRow(int rowIndex) {
int[] triangle = new int[rowIndex+1];
for(int i=0;i<=rowIndex;i++){
triangle[0] = 1;
triangle[rowIndex] = 1;
for(int j=rowIndex-1;j-1>=0;j--){
System.out.println(j);
triangle[j] = triangle[j] + triangle[j-1];
}
}
LinkedList<Integer> result = new LinkedList<>();
for(int i:triangle){
result.addLast(i);
}
return result;
}
}
| 671 | 0.505443 | 0.486781 | 24 | 25.791666 | 16.653276 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.583333 | false | false | 15 |
400db4924efcb7b90729863481128b72af84d48f | 37,709,812,861,760 | b7429cb7d9f3197d33121d366050183dd7447111 | /app/src/main/java/com/hex/express/iwant/fragments/BaseItemFragment.java | 99295cbaf39333a2d6c96dbafd7b8d6f051c0c78 | [] | no_license | hexiaoleione/biaowang_studio | https://github.com/hexiaoleione/biaowang_studio | 28c719909667f131637205de79bb8cc72fc52545 | 1735f31cd4e25ba5e08dd117ba7492186dcee8b0 | refs/heads/master | 2021-07-10T00:03:42.022000 | 2019-02-12T03:35:51 | 2019-02-12T03:35:51 | 144,809,142 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hex.express.iwant.fragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.framework.base.BaseFragment;
import com.hex.express.iwant.R;
public abstract class BaseItemFragment extends BaseFragment {
public View rootView;
@Bind(R.id.view_load_fail)
LinearLayout view_load_fail;
@Bind(R.id.listview)
com.handmark.pulltorefresh.library.PullToRefreshListView listview;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_list, container, false);
ButterKnife.bind(this, rootView);
return null;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initData();
}
/**
* 实现点击事件
* @param v
*/
public abstract void onWeightClick(View v);
/**
* 初始化数据
*/
public abstract void initData();
/**
* 设置点击事件
*/
public abstract void setOnClick();
/**
* 获取存储或者传递过来的数据
*/
public abstract void getData();
public void onClick(View v){
onWeightClick(v);
}
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
return false;
}
}
| UTF-8 | Java | 1,489 | java | BaseItemFragment.java | Java | [] | null | [] | package com.hex.express.iwant.fragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.framework.base.BaseFragment;
import com.hex.express.iwant.R;
public abstract class BaseItemFragment extends BaseFragment {
public View rootView;
@Bind(R.id.view_load_fail)
LinearLayout view_load_fail;
@Bind(R.id.listview)
com.handmark.pulltorefresh.library.PullToRefreshListView listview;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_list, container, false);
ButterKnife.bind(this, rootView);
return null;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initData();
}
/**
* 实现点击事件
* @param v
*/
public abstract void onWeightClick(View v);
/**
* 初始化数据
*/
public abstract void initData();
/**
* 设置点击事件
*/
public abstract void setOnClick();
/**
* 获取存储或者传递过来的数据
*/
public abstract void getData();
public void onClick(View v){
onWeightClick(v);
}
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
return false;
}
}
| 1,489 | 0.757873 | 0.757173 | 63 | 21.682539 | 19.388121 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.31746 | false | false | 15 |
ba01048131ecd09a0cbd9c15e0ff226df75dcab2 | 24,687,472,072,075 | 9b0a6c2f4a6a14668b185cf501f1275d5140a561 | /app/src/main/java/harmony/app/RecyclerViewAdapter/VideoListAdapter.java | 4ed1bdb825850a49acb9a4653d9385f75553dc14 | [] | no_license | MultiplexerLab/MySymphony | https://github.com/MultiplexerLab/MySymphony | 29f58cd3b6200d67d37d89ba8067a98e249e6dc0 | 8f220f9d7307d10618d99c4b11c103da6827bea6 | refs/heads/master | 2020-03-13T00:44:42.224000 | 2018-07-23T13:08:07 | 2018-07-23T13:08:07 | 130,892,363 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package harmony.app.RecyclerViewAdapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import harmony.app.ModelClass.MusicVideo;
import harmony.app.R;
import harmony.app.Helper.DataHelper;
import harmony.app.Helper.ProgressDialog;
public class VideoListAdapter extends BaseAdapter {
ProgressDialog progressDialog;
Context context;
ArrayList<MusicVideo> videoList;
boolean isSubscribed;
public VideoListAdapter(Context context, ArrayList<MusicVideo> videoList, boolean isSubscribed) {
this.context = context;
this.videoList = videoList;
this.isSubscribed = isSubscribed;
progressDialog = new harmony.app.Helper.ProgressDialog(context);
}
@Override
public int getCount() {
return videoList.size();
}
@Override
public Object getItem(int i) {
return i;
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(final int position, View view, ViewGroup viewGroup) {
DataHelper dataHelper = new DataHelper(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View customView = inflater.inflate(R.layout.video_list_item, viewGroup, false);
ImageView videoThumbnail = customView.findViewById(R.id.videoThumbnail);
TextView apptitle = customView.findViewById(R.id.videoTitle);
TextView type = customView.findViewById(R.id.contentType);
TextView priceTag = customView.findViewById(R.id.priceTag);
if (videoList.get(position).getThumbnailImgUrl() == null || videoList.get(position).getThumbnailImgUrl() == "") {
if (videoList.get(position).getContentType().equals("video")) {
videoThumbnail.setImageDrawable(context.getResources().getDrawable(R.drawable.video_thumbnail));
}
} else {
Glide.with(context).load(videoList.get(position).getThumbnailImgUrl()).into(videoThumbnail);
}
/* int price = videoList.get(position).getContentPrice();
if(price>0) {
if (dataHelper.checkDownLoadedOrNot(videoList.get(position).getContentCat(), videoList.get(position).getContentId()) || isSubscribed)
{
priceTag.setVisibility(View.INVISIBLE);
}else{
priceTag.setText("৳" + price);
}
}*/
apptitle.setText(videoList.get(position).getContentTitle());
type.setText(videoList.get(position).getContentType());
return customView;
}
}
| UTF-8 | Java | 2,826 | java | VideoListAdapter.java | Java | [] | null | [] | package harmony.app.RecyclerViewAdapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import harmony.app.ModelClass.MusicVideo;
import harmony.app.R;
import harmony.app.Helper.DataHelper;
import harmony.app.Helper.ProgressDialog;
public class VideoListAdapter extends BaseAdapter {
ProgressDialog progressDialog;
Context context;
ArrayList<MusicVideo> videoList;
boolean isSubscribed;
public VideoListAdapter(Context context, ArrayList<MusicVideo> videoList, boolean isSubscribed) {
this.context = context;
this.videoList = videoList;
this.isSubscribed = isSubscribed;
progressDialog = new harmony.app.Helper.ProgressDialog(context);
}
@Override
public int getCount() {
return videoList.size();
}
@Override
public Object getItem(int i) {
return i;
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(final int position, View view, ViewGroup viewGroup) {
DataHelper dataHelper = new DataHelper(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View customView = inflater.inflate(R.layout.video_list_item, viewGroup, false);
ImageView videoThumbnail = customView.findViewById(R.id.videoThumbnail);
TextView apptitle = customView.findViewById(R.id.videoTitle);
TextView type = customView.findViewById(R.id.contentType);
TextView priceTag = customView.findViewById(R.id.priceTag);
if (videoList.get(position).getThumbnailImgUrl() == null || videoList.get(position).getThumbnailImgUrl() == "") {
if (videoList.get(position).getContentType().equals("video")) {
videoThumbnail.setImageDrawable(context.getResources().getDrawable(R.drawable.video_thumbnail));
}
} else {
Glide.with(context).load(videoList.get(position).getThumbnailImgUrl()).into(videoThumbnail);
}
/* int price = videoList.get(position).getContentPrice();
if(price>0) {
if (dataHelper.checkDownLoadedOrNot(videoList.get(position).getContentCat(), videoList.get(position).getContentId()) || isSubscribed)
{
priceTag.setVisibility(View.INVISIBLE);
}else{
priceTag.setText("৳" + price);
}
}*/
apptitle.setText(videoList.get(position).getContentTitle());
type.setText(videoList.get(position).getContentType());
return customView;
}
}
| 2,826 | 0.688385 | 0.688031 | 78 | 35.205128 | 32.598316 | 145 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.653846 | false | false | 15 |
7efcaed9992dfccf2361b5f7095608abde5a1e8e | 26,018,911,916,273 | 21f6c1eca917961d8b45d546220100f9114bfdf5 | /src/main/java/com/marcin/converters/Converter.java | 5ad2979a5dc33c774513d7970f78327e56c2fdd2 | [] | no_license | mklasicki/ClientDB | https://github.com/mklasicki/ClientDB | a5030c367f065f78743f0949e7c7f01c947f6cd3 | e47ec3b8a08513defca6d12f251af1bcf6b642b0 | refs/heads/master | 2020-09-14T14:23:42.902000 | 2020-06-16T17:50:50 | 2020-06-16T17:50:50 | 223,154,948 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.marcin.converters;
public interface Converter<DTO, DOMAIN> {
DOMAIN to(DTO dto);
DTO from(DOMAIN domain);
}
| UTF-8 | Java | 130 | java | Converter.java | Java | [] | null | [] | package com.marcin.converters;
public interface Converter<DTO, DOMAIN> {
DOMAIN to(DTO dto);
DTO from(DOMAIN domain);
}
| 130 | 0.707692 | 0.707692 | 7 | 17.571428 | 15.737645 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.571429 | false | false | 15 |
5cd2911f7d26b21d158e435973f52d720d226373 | 6,322,191,898,552 | 308ad5d673d7320074c6165059f334a57289af41 | /Spielraum2-Tests/src/spielraum/tests/menu/RibbonGroupTest.java | 2c3aa66a66afb50ef763ebbf033a83880ba8d615 | [] | no_license | Madsim/Spielraum | https://github.com/Madsim/Spielraum | 18903114fd0ee689487ccbafa765ba8e17a4ef28 | cf868e7dc4f8e5a4e1874ee8a156162ec4cd5b2c | refs/heads/master | 2016-09-07T10:46:15.203000 | 2013-07-23T18:07:10 | 2013-07-23T18:07:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package spielraum.tests.menu;
import com.madsim.engine.Engine;
import codeanticode.glgraphics.GLGraphics;
import codeanticode.glgraphics.GLModel;
import codeanticode.glgraphics.GLSLShader;
import processing.core.PApplet;
import processing.core.PVector;
import spielraum.gfx.ribbon.Ribbon3D;
import toxi.geom.AABB;
import toxi.geom.Sphere;
import toxi.geom.Vec3D;
import toxi.physics.VerletParticle;
import toxi.physics.VerletPhysics;
import toxi.physics.VerletSpring;
import toxi.physics.behaviors.GravityBehavior;
import toxi.physics.constraints.ParticleConstraint;
import toxi.physics.constraints.SphereConstraint;
public class RibbonGroupTest {
Engine e;
private static final long serialVersionUID = 1L;
private float seed;
private int numPhysicParticles;
private int numQuadsPerRibbon;
private float sphereSize;
private Ribbon3D[] particles;
private VerletPhysics physics;
private VerletParticle head, tail;
private int REST_LENGTH;
private VerletParticle pivot;
private VerletSpring[] pivotSprings;
private ParticleConstraint sphereA, sphereB;
private boolean isPivoting = false;
private int vertexCount = 0;
private GLModel imageQuadModel;
private GLSLShader imageShader; // should pe provided by mother class?
private int cosDetail = 25;
private float[] cosLUT = new float[cosDetail];
private float seedSpeed = .01f;
public RibbonGroupTest(Engine e, float sphereSize, int numRibbons, int numJointsPerRibbon, int REST_LENGTH) {
this.e = e;
this.seed = e.p.random(1000);
this.numPhysicParticles = numRibbons;
this.numQuadsPerRibbon = numJointsPerRibbon;
this.sphereSize = sphereSize;
this.REST_LENGTH = REST_LENGTH;
// create drole particles
particles = new Ribbon3D[numRibbons];
// create particles
for (int i = 0; i < numRibbons; i++) {
// PVector startPosition = new PVector(parent.random(-3.1414f, 3.1414f), parent.random(-3.1414f, 3.1414f), parent.random(-3.1414f, 3.1414f));
PVector startPosition = new PVector(0, 0, 0);
particles[i] = new Ribbon3D(e, startPosition, numJointsPerRibbon, false);
vertexCount += particles[i].getVertexCount();
}
// create collision sphere at origin, replace OUTSIDE with INSIDE to
// keep particles inside the sphere
ParticleConstraint sphereA = new SphereConstraint(new Sphere(new Vec3D(), sphereSize * .8f), SphereConstraint.OUTSIDE);
ParticleConstraint sphereB = new SphereConstraint(new Sphere(new Vec3D(), sphereSize), SphereConstraint.INSIDE);
physics = new VerletPhysics();
// weak gravity along Y axis
physics.addBehavior(new GravityBehavior(new Vec3D(0, 0.01f, 0)));
// set bounding box to 110% of sphere radius
physics.setWorldBounds(new AABB(new Vec3D(), new Vec3D(sphereSize, sphereSize, sphereSize).scaleSelf(1.1f)));
VerletParticle prev = null;
for (int i = 0; i < numRibbons; i++) {
// create particles at random positions outside sphere
VerletParticle p = new VerletParticle(Vec3D.randomVector().scaleSelf(sphereSize * 2));
// set sphere as particle constraint
p.addConstraint(sphereA);
p.addConstraint(sphereB);
physics.addParticle(p);
if(prev != null) {
physics.addSpring(new VerletSpring(prev, p, REST_LENGTH * 1, 0.005f));
physics.addSpring(new VerletSpring(physics.particles.get((int) e.p.random(i)), p, REST_LENGTH * 2, 0.00001f + i * .0005f));
}
prev = p;
}
head = physics.particles.get(0);
head.lock();
tail = physics.particles.get(physics.particles.size() - 1);
tail.lock();
// create a model that uses quads
imageQuadModel = new GLModel(e.p, vertexCount*4, PApplet.QUADS, GLModel.DYNAMIC);
imageQuadModel.initColors();
imageQuadModel.initNormals();
// load shader
imageShader = new GLSLShader(e.p, "data/shader/imageVert.glsl", "data/shader/imageFrag.glsl");
// create cos lookup table
for(int i=0;i<cosDetail;i++) {
cosLUT[i] = e.p.sin(((float)i/cosDetail)*e.p.PI);
}
}
public void update() {
if(!isPivoting) {
seed += seedSpeed;
// update particle movement
head.set(
e.p.noise(seed * (.0015f + PApplet.cos(seed * .001f) * .0015f)) * e.p.width -e.p. width / 2,
e.p.noise(seed * .0015f + PApplet.cos(seed * .001f) * .0015f) * e.p.height - e.p.height / 2,
e.p.noise(seed * .001f + 100) * e.p.width - e.p.width / 2);
float tailSeed = seed + 10.0f;
tail.set(
e.p.noise(tailSeed * (.0015f + PApplet.cos(tailSeed * .001f) * .0015f)) * e.p.width - e.p.width / 2,
e.p.noise(tailSeed * .0015f + PApplet.cos(tailSeed * .001f) * .0015f) * e.p.height - e.p.height / 2,
e.p.noise(tailSeed * .01f + 100) * e.p.width - e.p.width / 2);
// also apply sphere constraint to head
// this needs to be done manually because if this particle is locked
// it won't be updated automatically
head.applyConstraints();
tail.applyConstraints();
}
// update sim
physics.update();
// then all particles as dots
int index = 0;
for(int i = 0; i < particles.length; i++) {
VerletParticle p = physics.particles.get(i);
particles[index++].update(p.x, p.y, p.z);
}
}
public void createPivotAt(float x, float y, float z) {
pivot = new VerletParticle(x, y, z);
pivot.lock();
physics.addParticle(pivot);
/* First tighten all springs*/
for(VerletSpring s : physics.springs) {
s.setRestLength(0.1f);
s.setStrength(0.001f);
}
// Add springs between all joints and the pivot
pivotSprings = new VerletSpring[numPhysicParticles];
for(int i = 0; i < numPhysicParticles; i++) {
pivotSprings[i] = new VerletSpring(head, pivot, 5, 0.000001f);
pivotSprings[i].lockB(true);
physics.addSpring(pivotSprings[i]);
}
head.unlock();
isPivoting = true;
}
public void deletePivot() {
// First remove all pivot prings
for(int i = 0; i < numPhysicParticles; i++) {
physics.removeSpring(pivotSprings[i]);
}
// Remove pivot
physics.removeParticle(pivot);
// Relax all other springs
for(VerletSpring s : physics.springs) s.setRestLength(REST_LENGTH * 20);
// Randomize all particle positions
for(VerletParticle p : physics.particles) {
p.lock();
p.set(Vec3D.randomVector().scaleSelf(sphereSize * 2));
p.update();
p.unlock();
}
head.lock();
isPivoting = false;
}
public boolean isPivoting() {
return isPivoting;
}
public void draw() {
// arrays for storing ribbon vertices
float[] floatQuadVertices = new float[vertexCount*16];
float[] floatQuadNormals = new float[vertexCount*16];
float[] floatQuadColors = new float[vertexCount*16];
int quadVertexIndex = 0;
int quadNormalIndex = 0;
int quadColorIndex = 0;
float ribbonR = .1f;
float ribbonG = .1f;
float ribbonB = .1f;
float quadHeight = .75f;
for (int i = 0; i < numPhysicParticles; i++) {
Ribbon3D agent = particles[i];
// create quads from ribbons
PVector[] agentsVertices = agent.getVertices();
int agentVertexNum = agentsVertices.length;
for(int j=0;j<agentVertexNum-1;j++) {
// cosinus from lookup table
float ratio = cosLUT[(int)(((float)j/agentVertexNum) * cosDetail)];
PVector thisP = agentsVertices[j];
PVector nextP = agentsVertices[j+1];
//PVector thirdP = agentsVertices[j+1];
// create quad from above vertices and save in glmodel, then add colors
floatQuadVertices[quadVertexIndex++] = thisP.x;
floatQuadVertices[quadVertexIndex++] = thisP.y;
floatQuadVertices[quadVertexIndex++] = thisP.z;
floatQuadVertices[quadVertexIndex++] = 1.0f;
floatQuadVertices[quadVertexIndex++] = thisP.x;
floatQuadVertices[quadVertexIndex++] = thisP.y + quadHeight*ratio*2.0f;
floatQuadVertices[quadVertexIndex++] = thisP.z;
floatQuadVertices[quadVertexIndex++] = 1.0f;
floatQuadVertices[quadVertexIndex++] = nextP.x;
floatQuadVertices[quadVertexIndex++] = nextP.y + quadHeight*ratio*2.0f;
floatQuadVertices[quadVertexIndex++] = nextP.z;
floatQuadVertices[quadVertexIndex++] = 1.0f;
floatQuadVertices[quadVertexIndex++] = nextP.x;
floatQuadVertices[quadVertexIndex++] = nextP.y;
floatQuadVertices[quadVertexIndex++] = nextP.z;
floatQuadVertices[quadVertexIndex++] = 1.0f;
// compute face normal
// PVector v1 = new PVector(thisP.x - nextP.x, thisP.y - nextP.y, thisP.z - nextP.z);
// PVector v2 = new PVector(nextP.x - thisP.x, (nextP.y+quadHeight) - thisP.y, nextP.z - thisP.z);
PVector v3 = new PVector(thisP.x, thisP.y, thisP.z);//v1.cross(v2);
v3.normalize();
float nX = v3.x;
float nY = v3.y;
float nZ = v3.z;
floatQuadNormals[quadNormalIndex++] = nX;
floatQuadNormals[quadNormalIndex++] = nY;
floatQuadNormals[quadNormalIndex++] = nZ;
floatQuadNormals[quadNormalIndex++] = 1.0f;
floatQuadNormals[quadNormalIndex++] = nX;
floatQuadNormals[quadNormalIndex++] = nY;
floatQuadNormals[quadNormalIndex++] = nZ;
floatQuadNormals[quadNormalIndex++] = 1.0f;
floatQuadNormals[quadNormalIndex++] = nX;
floatQuadNormals[quadNormalIndex++] = nY;
floatQuadNormals[quadNormalIndex++] = nZ;
floatQuadNormals[quadNormalIndex++] = 1.0f;
floatQuadNormals[quadNormalIndex++] = nX;
floatQuadNormals[quadNormalIndex++] = nY;
floatQuadNormals[quadNormalIndex++] = nZ;
floatQuadNormals[quadNormalIndex++] = 1.0f;
// add colors
float theAlpha = 1.0f;//agent.a;// * ((!gaps[gapIndex++]) ? 1.0f : 0.0f);
floatQuadColors[quadColorIndex++] = ribbonR;
floatQuadColors[quadColorIndex++] = ribbonG;
floatQuadColors[quadColorIndex++] = ribbonB;
floatQuadColors[quadColorIndex++] = theAlpha;
floatQuadColors[quadColorIndex++] = ribbonR;
floatQuadColors[quadColorIndex++] = ribbonG;
floatQuadColors[quadColorIndex++] = ribbonB;
floatQuadColors[quadColorIndex++] = theAlpha;
floatQuadColors[quadColorIndex++] = ribbonR;
floatQuadColors[quadColorIndex++] = ribbonG;
floatQuadColors[quadColorIndex++] = ribbonB;
floatQuadColors[quadColorIndex++] = theAlpha;
floatQuadColors[quadColorIndex++] = ribbonR;
floatQuadColors[quadColorIndex++] = ribbonG;
floatQuadColors[quadColorIndex++] = ribbonB;
floatQuadColors[quadColorIndex++] = theAlpha;
}
}
imageQuadModel.updateVertices(floatQuadVertices);
imageQuadModel.updateColors(floatQuadColors);
imageQuadModel.updateNormals(floatQuadVertices);
imageShader.start();
imageShader.setFloatUniform("zmin", 0.65f);
imageShader.setFloatUniform("zmax", 0.85f);
imageShader.setFloatUniform("shininess", 100.0f);
imageShader.setVecUniform("lightPos", 100.0f, -10.0f, 30.0f);
// A model can be drawn through the GLGraphics renderer:
GLGraphics renderer = (GLGraphics)e.g;
renderer.model(imageQuadModel);
imageShader.stop();
e.p.fill(255);
e.p.pushMatrix();
e.p.translate(head.x, head.y, head.z);
e.p.ellipse(0,0, 30, 30);
e.p.popMatrix();
}
public void drawAsLines() {
for (int i = 0; i < numPhysicParticles; i++) {
if(i != numPhysicParticles-1) particles[i].drawStrokeRibbon(e.p.color(200, 200, 0), 5);
else particles[i].drawStrokeRibbon(e.p.color(200, 0, 0), 5);
}
}
public PVector getHead() {
return new PVector(head.x, head.y, head.z);
}
}
| UTF-8 | Java | 11,256 | java | RibbonGroupTest.java | Java | [] | null | [] | package spielraum.tests.menu;
import com.madsim.engine.Engine;
import codeanticode.glgraphics.GLGraphics;
import codeanticode.glgraphics.GLModel;
import codeanticode.glgraphics.GLSLShader;
import processing.core.PApplet;
import processing.core.PVector;
import spielraum.gfx.ribbon.Ribbon3D;
import toxi.geom.AABB;
import toxi.geom.Sphere;
import toxi.geom.Vec3D;
import toxi.physics.VerletParticle;
import toxi.physics.VerletPhysics;
import toxi.physics.VerletSpring;
import toxi.physics.behaviors.GravityBehavior;
import toxi.physics.constraints.ParticleConstraint;
import toxi.physics.constraints.SphereConstraint;
public class RibbonGroupTest {
Engine e;
private static final long serialVersionUID = 1L;
private float seed;
private int numPhysicParticles;
private int numQuadsPerRibbon;
private float sphereSize;
private Ribbon3D[] particles;
private VerletPhysics physics;
private VerletParticle head, tail;
private int REST_LENGTH;
private VerletParticle pivot;
private VerletSpring[] pivotSprings;
private ParticleConstraint sphereA, sphereB;
private boolean isPivoting = false;
private int vertexCount = 0;
private GLModel imageQuadModel;
private GLSLShader imageShader; // should pe provided by mother class?
private int cosDetail = 25;
private float[] cosLUT = new float[cosDetail];
private float seedSpeed = .01f;
public RibbonGroupTest(Engine e, float sphereSize, int numRibbons, int numJointsPerRibbon, int REST_LENGTH) {
this.e = e;
this.seed = e.p.random(1000);
this.numPhysicParticles = numRibbons;
this.numQuadsPerRibbon = numJointsPerRibbon;
this.sphereSize = sphereSize;
this.REST_LENGTH = REST_LENGTH;
// create drole particles
particles = new Ribbon3D[numRibbons];
// create particles
for (int i = 0; i < numRibbons; i++) {
// PVector startPosition = new PVector(parent.random(-3.1414f, 3.1414f), parent.random(-3.1414f, 3.1414f), parent.random(-3.1414f, 3.1414f));
PVector startPosition = new PVector(0, 0, 0);
particles[i] = new Ribbon3D(e, startPosition, numJointsPerRibbon, false);
vertexCount += particles[i].getVertexCount();
}
// create collision sphere at origin, replace OUTSIDE with INSIDE to
// keep particles inside the sphere
ParticleConstraint sphereA = new SphereConstraint(new Sphere(new Vec3D(), sphereSize * .8f), SphereConstraint.OUTSIDE);
ParticleConstraint sphereB = new SphereConstraint(new Sphere(new Vec3D(), sphereSize), SphereConstraint.INSIDE);
physics = new VerletPhysics();
// weak gravity along Y axis
physics.addBehavior(new GravityBehavior(new Vec3D(0, 0.01f, 0)));
// set bounding box to 110% of sphere radius
physics.setWorldBounds(new AABB(new Vec3D(), new Vec3D(sphereSize, sphereSize, sphereSize).scaleSelf(1.1f)));
VerletParticle prev = null;
for (int i = 0; i < numRibbons; i++) {
// create particles at random positions outside sphere
VerletParticle p = new VerletParticle(Vec3D.randomVector().scaleSelf(sphereSize * 2));
// set sphere as particle constraint
p.addConstraint(sphereA);
p.addConstraint(sphereB);
physics.addParticle(p);
if(prev != null) {
physics.addSpring(new VerletSpring(prev, p, REST_LENGTH * 1, 0.005f));
physics.addSpring(new VerletSpring(physics.particles.get((int) e.p.random(i)), p, REST_LENGTH * 2, 0.00001f + i * .0005f));
}
prev = p;
}
head = physics.particles.get(0);
head.lock();
tail = physics.particles.get(physics.particles.size() - 1);
tail.lock();
// create a model that uses quads
imageQuadModel = new GLModel(e.p, vertexCount*4, PApplet.QUADS, GLModel.DYNAMIC);
imageQuadModel.initColors();
imageQuadModel.initNormals();
// load shader
imageShader = new GLSLShader(e.p, "data/shader/imageVert.glsl", "data/shader/imageFrag.glsl");
// create cos lookup table
for(int i=0;i<cosDetail;i++) {
cosLUT[i] = e.p.sin(((float)i/cosDetail)*e.p.PI);
}
}
public void update() {
if(!isPivoting) {
seed += seedSpeed;
// update particle movement
head.set(
e.p.noise(seed * (.0015f + PApplet.cos(seed * .001f) * .0015f)) * e.p.width -e.p. width / 2,
e.p.noise(seed * .0015f + PApplet.cos(seed * .001f) * .0015f) * e.p.height - e.p.height / 2,
e.p.noise(seed * .001f + 100) * e.p.width - e.p.width / 2);
float tailSeed = seed + 10.0f;
tail.set(
e.p.noise(tailSeed * (.0015f + PApplet.cos(tailSeed * .001f) * .0015f)) * e.p.width - e.p.width / 2,
e.p.noise(tailSeed * .0015f + PApplet.cos(tailSeed * .001f) * .0015f) * e.p.height - e.p.height / 2,
e.p.noise(tailSeed * .01f + 100) * e.p.width - e.p.width / 2);
// also apply sphere constraint to head
// this needs to be done manually because if this particle is locked
// it won't be updated automatically
head.applyConstraints();
tail.applyConstraints();
}
// update sim
physics.update();
// then all particles as dots
int index = 0;
for(int i = 0; i < particles.length; i++) {
VerletParticle p = physics.particles.get(i);
particles[index++].update(p.x, p.y, p.z);
}
}
public void createPivotAt(float x, float y, float z) {
pivot = new VerletParticle(x, y, z);
pivot.lock();
physics.addParticle(pivot);
/* First tighten all springs*/
for(VerletSpring s : physics.springs) {
s.setRestLength(0.1f);
s.setStrength(0.001f);
}
// Add springs between all joints and the pivot
pivotSprings = new VerletSpring[numPhysicParticles];
for(int i = 0; i < numPhysicParticles; i++) {
pivotSprings[i] = new VerletSpring(head, pivot, 5, 0.000001f);
pivotSprings[i].lockB(true);
physics.addSpring(pivotSprings[i]);
}
head.unlock();
isPivoting = true;
}
public void deletePivot() {
// First remove all pivot prings
for(int i = 0; i < numPhysicParticles; i++) {
physics.removeSpring(pivotSprings[i]);
}
// Remove pivot
physics.removeParticle(pivot);
// Relax all other springs
for(VerletSpring s : physics.springs) s.setRestLength(REST_LENGTH * 20);
// Randomize all particle positions
for(VerletParticle p : physics.particles) {
p.lock();
p.set(Vec3D.randomVector().scaleSelf(sphereSize * 2));
p.update();
p.unlock();
}
head.lock();
isPivoting = false;
}
public boolean isPivoting() {
return isPivoting;
}
public void draw() {
// arrays for storing ribbon vertices
float[] floatQuadVertices = new float[vertexCount*16];
float[] floatQuadNormals = new float[vertexCount*16];
float[] floatQuadColors = new float[vertexCount*16];
int quadVertexIndex = 0;
int quadNormalIndex = 0;
int quadColorIndex = 0;
float ribbonR = .1f;
float ribbonG = .1f;
float ribbonB = .1f;
float quadHeight = .75f;
for (int i = 0; i < numPhysicParticles; i++) {
Ribbon3D agent = particles[i];
// create quads from ribbons
PVector[] agentsVertices = agent.getVertices();
int agentVertexNum = agentsVertices.length;
for(int j=0;j<agentVertexNum-1;j++) {
// cosinus from lookup table
float ratio = cosLUT[(int)(((float)j/agentVertexNum) * cosDetail)];
PVector thisP = agentsVertices[j];
PVector nextP = agentsVertices[j+1];
//PVector thirdP = agentsVertices[j+1];
// create quad from above vertices and save in glmodel, then add colors
floatQuadVertices[quadVertexIndex++] = thisP.x;
floatQuadVertices[quadVertexIndex++] = thisP.y;
floatQuadVertices[quadVertexIndex++] = thisP.z;
floatQuadVertices[quadVertexIndex++] = 1.0f;
floatQuadVertices[quadVertexIndex++] = thisP.x;
floatQuadVertices[quadVertexIndex++] = thisP.y + quadHeight*ratio*2.0f;
floatQuadVertices[quadVertexIndex++] = thisP.z;
floatQuadVertices[quadVertexIndex++] = 1.0f;
floatQuadVertices[quadVertexIndex++] = nextP.x;
floatQuadVertices[quadVertexIndex++] = nextP.y + quadHeight*ratio*2.0f;
floatQuadVertices[quadVertexIndex++] = nextP.z;
floatQuadVertices[quadVertexIndex++] = 1.0f;
floatQuadVertices[quadVertexIndex++] = nextP.x;
floatQuadVertices[quadVertexIndex++] = nextP.y;
floatQuadVertices[quadVertexIndex++] = nextP.z;
floatQuadVertices[quadVertexIndex++] = 1.0f;
// compute face normal
// PVector v1 = new PVector(thisP.x - nextP.x, thisP.y - nextP.y, thisP.z - nextP.z);
// PVector v2 = new PVector(nextP.x - thisP.x, (nextP.y+quadHeight) - thisP.y, nextP.z - thisP.z);
PVector v3 = new PVector(thisP.x, thisP.y, thisP.z);//v1.cross(v2);
v3.normalize();
float nX = v3.x;
float nY = v3.y;
float nZ = v3.z;
floatQuadNormals[quadNormalIndex++] = nX;
floatQuadNormals[quadNormalIndex++] = nY;
floatQuadNormals[quadNormalIndex++] = nZ;
floatQuadNormals[quadNormalIndex++] = 1.0f;
floatQuadNormals[quadNormalIndex++] = nX;
floatQuadNormals[quadNormalIndex++] = nY;
floatQuadNormals[quadNormalIndex++] = nZ;
floatQuadNormals[quadNormalIndex++] = 1.0f;
floatQuadNormals[quadNormalIndex++] = nX;
floatQuadNormals[quadNormalIndex++] = nY;
floatQuadNormals[quadNormalIndex++] = nZ;
floatQuadNormals[quadNormalIndex++] = 1.0f;
floatQuadNormals[quadNormalIndex++] = nX;
floatQuadNormals[quadNormalIndex++] = nY;
floatQuadNormals[quadNormalIndex++] = nZ;
floatQuadNormals[quadNormalIndex++] = 1.0f;
// add colors
float theAlpha = 1.0f;//agent.a;// * ((!gaps[gapIndex++]) ? 1.0f : 0.0f);
floatQuadColors[quadColorIndex++] = ribbonR;
floatQuadColors[quadColorIndex++] = ribbonG;
floatQuadColors[quadColorIndex++] = ribbonB;
floatQuadColors[quadColorIndex++] = theAlpha;
floatQuadColors[quadColorIndex++] = ribbonR;
floatQuadColors[quadColorIndex++] = ribbonG;
floatQuadColors[quadColorIndex++] = ribbonB;
floatQuadColors[quadColorIndex++] = theAlpha;
floatQuadColors[quadColorIndex++] = ribbonR;
floatQuadColors[quadColorIndex++] = ribbonG;
floatQuadColors[quadColorIndex++] = ribbonB;
floatQuadColors[quadColorIndex++] = theAlpha;
floatQuadColors[quadColorIndex++] = ribbonR;
floatQuadColors[quadColorIndex++] = ribbonG;
floatQuadColors[quadColorIndex++] = ribbonB;
floatQuadColors[quadColorIndex++] = theAlpha;
}
}
imageQuadModel.updateVertices(floatQuadVertices);
imageQuadModel.updateColors(floatQuadColors);
imageQuadModel.updateNormals(floatQuadVertices);
imageShader.start();
imageShader.setFloatUniform("zmin", 0.65f);
imageShader.setFloatUniform("zmax", 0.85f);
imageShader.setFloatUniform("shininess", 100.0f);
imageShader.setVecUniform("lightPos", 100.0f, -10.0f, 30.0f);
// A model can be drawn through the GLGraphics renderer:
GLGraphics renderer = (GLGraphics)e.g;
renderer.model(imageQuadModel);
imageShader.stop();
e.p.fill(255);
e.p.pushMatrix();
e.p.translate(head.x, head.y, head.z);
e.p.ellipse(0,0, 30, 30);
e.p.popMatrix();
}
public void drawAsLines() {
for (int i = 0; i < numPhysicParticles; i++) {
if(i != numPhysicParticles-1) particles[i].drawStrokeRibbon(e.p.color(200, 200, 0), 5);
else particles[i].drawStrokeRibbon(e.p.color(200, 0, 0), 5);
}
}
public PVector getHead() {
return new PVector(head.x, head.y, head.z);
}
}
| 11,256 | 0.693408 | 0.669065 | 357 | 30.529411 | 26.571342 | 143 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.92437 | false | false | 15 |
e2b246bbbc8e658ca6fd8adad26b932b410644c7 | 12,429,635,400,063 | 5a554a9296d0e11e03c47f031b89848507ecfcd5 | /app/src/main/java/com/example/dreams/widget/PathMeasureHookView.java | 01098b0ef636d6237db13e1af2e2889ae895f86a | [] | no_license | DreamerKy/PracticeMakesPerfect | https://github.com/DreamerKy/PracticeMakesPerfect | 53bee5d3b6864ebd79b6e11aa3863f40edbcbbc9 | 2d8b5b0aced8e8ede222bbb6e91c8599cd6ada76 | refs/heads/master | 2022-12-17T09:23:50.631000 | 2020-09-22T03:01:04 | 2020-09-22T03:01:04 | 286,656,291 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.dreams.widget;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.util.AttributeSet;
import android.view.View;
import com.example.dreams.R;
import androidx.annotation.Nullable;
public class PathMeasureHookView extends View {
private Paint mPaint = new Paint();
private Paint mLinePaint = new Paint(); //坐标系
private Bitmap mBitmap;
private float mLength;
private float mLength2;
private ValueAnimator valueAnimator;
private float mAnimatedValue;
private PathMeasure pathMeasure;
private PathMeasure pathMeasure2;
private ViewState viewState;
public PathMeasureHookView(Context context) {
this(context,null);
}
public PathMeasureHookView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs,0);
}
public PathMeasureHookView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(Color.WHITE);
mPaint.setAntiAlias(true);
mPaint.setStrokeWidth(4);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mLinePaint.setStyle(Paint.Style.STROKE);
mLinePaint.setColor(Color.RED);
mLinePaint.setStrokeWidth(6);
//缩小图片
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
mBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.arrow,options);
mPath.reset();
mPath.addCircle(0,0,100, Path.Direction.CW);
mPath2.moveTo(-50, 0);
mPath2.lineTo(-10, 40);
mPath2.lineTo(50, -30);
pathMeasure = new PathMeasure(mPath, false);
mLength = pathMeasure.getLength();
pathMeasure2 = new PathMeasure(mPath2, false);
mLength2 = pathMeasure2.getLength();
setBackgroundColor(Color.BLACK);
}
private abstract class ViewState{
abstract void drawState(Canvas canvas);
}
private class CircleState extends ViewState{
public CircleState(){
valueAnimator = ValueAnimator.ofFloat(0,1);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mAnimatedValue = (float) animation.getAnimatedValue();
invalidate();
}
});
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
viewState = new HookState();
}
});
valueAnimator.setDuration(1000);
// valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.setRepeatCount(0);
valueAnimator.start();
}
@Override
void drawState(Canvas canvas) {
mDsc.reset();
mDsc.lineTo(0,0);
float distance = mLength * mAnimatedValue;
// float start = (float) (distance-((0.5-Math.abs(mAnimatedValue-0.5))*mLength));
float start = 0;
pathMeasure.getSegment(start,distance,mDsc,true);
canvas.drawPath(mDsc,mPaint);
}
}
private class HookState extends ViewState{
public HookState(){
valueAnimator = ValueAnimator.ofFloat(0,1);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mAnimatedValue = (float) animation.getAnimatedValue();
invalidate();
}
});
valueAnimator.setDuration(1000);
// valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.setRepeatCount(0);
valueAnimator.start();
}
@Override
void drawState(Canvas canvas) {
mDsc2.reset();
float distance = mLength2 * mAnimatedValue;
// float start = (float) (distance-((0.5-Math.abs(mAnimatedValue-0.5))*mLength));
float start = 0;
pathMeasure2.getSegment(start,distance,mDsc2,true);
canvas.drawPath(mDsc,mPaint);
canvas.drawPath(mDsc2,mPaint);
}
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// canvas.drawLine(0, getHeight() / 2, getWidth(), getHeight() / 2, mLinePaint);
// canvas.drawLine(getWidth() / 2, 0, getWidth() / 2, getHeight(), mLinePaint);
// canvas.drawPath(mPath, mPaint);
canvas.translate(getWidth() / 2, getHeight() / 2);
// Path path = new Path();
// path.lineTo(0,200);
// path.lineTo(200,200);
// path.lineTo(200,0);
//
// /**
// * pathMeasure需要关联一个创建好的path, forceClosed会影响Path的测量结果
// */
// PathMeasure pathMeasure = new PathMeasure();
// pathMeasure.setPath(path, true);
// Log.e("TAG", "onDraw:forceClosed=true "+ pathMeasure.getLength());
//
// PathMeasure pathMeasure2 = new PathMeasure();
// pathMeasure2.setPath(path, false);
// Log.e("TAG", "onDraw:forceClosed=false "+ pathMeasure2.getLength());
//
// PathMeasure pathMeasure1 = new PathMeasure(path, false);
// Log.e("TAG", "onDraw:PathMeasure(path, false) "+ pathMeasure1.getLength());
//
// path.lineTo(200, -200);
//
// Log.e("TAG", "onDraw:PathMeasure(path, false) "+ pathMeasure1.getLength());
// //如果Path进行了调整,需要重新调用setPath方法进行关联
// pathMeasure1.setPath(path, false);
//
// Log.e("TAG", "onDraw:PathMeasure(path, false) "+ pathMeasure1.getLength());
// Path path = new Path();
// path.addRect(-200,-200, 200,200, Path.Direction.CW);
//
// Path dst = new Path();
// dst.lineTo(-300,-300);//添加一条直线
//
// PathMeasure pathMeasure = new PathMeasure(path, false);
// //截取一部分存入dst中,并且使用moveTo保持截取得到的Path第一个点位置不变。
// pathMeasure.getSegment(200, 1000, dst, true);
//
//
//
// canvas.drawPath(path, mPaint);
// canvas.drawPath(dst, mLinePaint);
// Path path = new Path();
// path.addRect(-100,-100,100,100, Path.Direction.CW);//添加一个矩形
// path.addOval(-200,-200,200,200, Path.Direction.CW);//添加一个椭圆
// canvas.drawPath(path, mPaint);
// PathMeasure pathMeasure = new PathMeasure(path, false);
// Log.e("TAG", "onDraw:forceClosed=false "+ pathMeasure.getLength());
// //跳转到下一条曲线
// pathMeasure.nextContour();
// Log.e("TAG", "onDraw:forceClosed=false "+ pathMeasure.getLength());
// mPath.reset();
// mPath.addCircle(0,0,200, Path.Direction.CW);
// canvas.drawPath(mPath, mPaint);
// mFloat += 0.01;
// if (mFloat >= 1){
// mFloat = 0;
// }
// PathMeasure pathMeasure = new PathMeasure(mPath, false);
// pathMeasure.getPosTan(pathMeasure.getLength() * mFloat,pos,tan);
// Log.e("TAG", "onDraw: pos[0]="+pos[0]+";pos[1]="+pos[1]);
// Log.e("TAG", "onDraw: tan[0]="+tan[0]+";tan[1]="+tan[1]);
//
// //计算出当前的切线与x轴夹角的度数
// double degrees = Math.atan2(tan[1], tan[0]) * 180.0 / Math.PI;
// Log.e("TAG", "onDraw: degrees="+degrees);
//
// mMatrix.reset();
// //进行角度旋转
// mMatrix.postRotate((float) degrees, mBitmap.getWidth() / 2, mBitmap.getHeight() / 2);
// //将图片的绘制点中心与当前点重合
// mMatrix.postTranslate(pos[0] - mBitmap.getWidth() / 2, pos[1]-mBitmap.getHeight() / 2);
// canvas.drawBitmap(mBitmap,mMatrix, mPaint);
// PathMeasure pathMeasure = new PathMeasure(mPath, false);
//将pos信息和tan信息保存在mMatrix中
// pathMeasure.getMatrix(pathMeasure.getLength() * mFloat, mMatrix, PathMeasure.POSITION_MATRIX_FLAG | PathMeasure.TANGENT_MATRIX_FLAG);
//将图片的旋转坐标调整到图片中心位置
// mMatrix.preTranslate(-mBitmap.getWidth() / 2, -mBitmap.getHeight() / 2);
// canvas.drawBitmap(mBitmap,mMatrix, mPaint);
// invalidate();
// mLength = pathMeasure.getLength();
if(viewState == null){
viewState = new CircleState();
}
viewState.drawState(canvas);
}
public void stopAnimator() {
if (valueAnimator != null && valueAnimator.isRunning()) {
valueAnimator.cancel();
}
valueAnimator = null;
}
private Matrix mMatrix = new Matrix();
private float[] pos = new float[2];
private float[] tan = new float[2];
private Path mPath = new Path();
private Path mPath2 = new Path();
private Path mDsc = new Path();
private Path mDsc2 = new Path();
private float mFloat;
}
| UTF-8 | Java | 9,601 | java | PathMeasureHookView.java | Java | [] | null | [] | package com.example.dreams.widget;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.util.AttributeSet;
import android.view.View;
import com.example.dreams.R;
import androidx.annotation.Nullable;
public class PathMeasureHookView extends View {
private Paint mPaint = new Paint();
private Paint mLinePaint = new Paint(); //坐标系
private Bitmap mBitmap;
private float mLength;
private float mLength2;
private ValueAnimator valueAnimator;
private float mAnimatedValue;
private PathMeasure pathMeasure;
private PathMeasure pathMeasure2;
private ViewState viewState;
public PathMeasureHookView(Context context) {
this(context,null);
}
public PathMeasureHookView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs,0);
}
public PathMeasureHookView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(Color.WHITE);
mPaint.setAntiAlias(true);
mPaint.setStrokeWidth(4);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mLinePaint.setStyle(Paint.Style.STROKE);
mLinePaint.setColor(Color.RED);
mLinePaint.setStrokeWidth(6);
//缩小图片
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
mBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.arrow,options);
mPath.reset();
mPath.addCircle(0,0,100, Path.Direction.CW);
mPath2.moveTo(-50, 0);
mPath2.lineTo(-10, 40);
mPath2.lineTo(50, -30);
pathMeasure = new PathMeasure(mPath, false);
mLength = pathMeasure.getLength();
pathMeasure2 = new PathMeasure(mPath2, false);
mLength2 = pathMeasure2.getLength();
setBackgroundColor(Color.BLACK);
}
private abstract class ViewState{
abstract void drawState(Canvas canvas);
}
private class CircleState extends ViewState{
public CircleState(){
valueAnimator = ValueAnimator.ofFloat(0,1);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mAnimatedValue = (float) animation.getAnimatedValue();
invalidate();
}
});
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
viewState = new HookState();
}
});
valueAnimator.setDuration(1000);
// valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.setRepeatCount(0);
valueAnimator.start();
}
@Override
void drawState(Canvas canvas) {
mDsc.reset();
mDsc.lineTo(0,0);
float distance = mLength * mAnimatedValue;
// float start = (float) (distance-((0.5-Math.abs(mAnimatedValue-0.5))*mLength));
float start = 0;
pathMeasure.getSegment(start,distance,mDsc,true);
canvas.drawPath(mDsc,mPaint);
}
}
private class HookState extends ViewState{
public HookState(){
valueAnimator = ValueAnimator.ofFloat(0,1);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mAnimatedValue = (float) animation.getAnimatedValue();
invalidate();
}
});
valueAnimator.setDuration(1000);
// valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.setRepeatCount(0);
valueAnimator.start();
}
@Override
void drawState(Canvas canvas) {
mDsc2.reset();
float distance = mLength2 * mAnimatedValue;
// float start = (float) (distance-((0.5-Math.abs(mAnimatedValue-0.5))*mLength));
float start = 0;
pathMeasure2.getSegment(start,distance,mDsc2,true);
canvas.drawPath(mDsc,mPaint);
canvas.drawPath(mDsc2,mPaint);
}
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// canvas.drawLine(0, getHeight() / 2, getWidth(), getHeight() / 2, mLinePaint);
// canvas.drawLine(getWidth() / 2, 0, getWidth() / 2, getHeight(), mLinePaint);
// canvas.drawPath(mPath, mPaint);
canvas.translate(getWidth() / 2, getHeight() / 2);
// Path path = new Path();
// path.lineTo(0,200);
// path.lineTo(200,200);
// path.lineTo(200,0);
//
// /**
// * pathMeasure需要关联一个创建好的path, forceClosed会影响Path的测量结果
// */
// PathMeasure pathMeasure = new PathMeasure();
// pathMeasure.setPath(path, true);
// Log.e("TAG", "onDraw:forceClosed=true "+ pathMeasure.getLength());
//
// PathMeasure pathMeasure2 = new PathMeasure();
// pathMeasure2.setPath(path, false);
// Log.e("TAG", "onDraw:forceClosed=false "+ pathMeasure2.getLength());
//
// PathMeasure pathMeasure1 = new PathMeasure(path, false);
// Log.e("TAG", "onDraw:PathMeasure(path, false) "+ pathMeasure1.getLength());
//
// path.lineTo(200, -200);
//
// Log.e("TAG", "onDraw:PathMeasure(path, false) "+ pathMeasure1.getLength());
// //如果Path进行了调整,需要重新调用setPath方法进行关联
// pathMeasure1.setPath(path, false);
//
// Log.e("TAG", "onDraw:PathMeasure(path, false) "+ pathMeasure1.getLength());
// Path path = new Path();
// path.addRect(-200,-200, 200,200, Path.Direction.CW);
//
// Path dst = new Path();
// dst.lineTo(-300,-300);//添加一条直线
//
// PathMeasure pathMeasure = new PathMeasure(path, false);
// //截取一部分存入dst中,并且使用moveTo保持截取得到的Path第一个点位置不变。
// pathMeasure.getSegment(200, 1000, dst, true);
//
//
//
// canvas.drawPath(path, mPaint);
// canvas.drawPath(dst, mLinePaint);
// Path path = new Path();
// path.addRect(-100,-100,100,100, Path.Direction.CW);//添加一个矩形
// path.addOval(-200,-200,200,200, Path.Direction.CW);//添加一个椭圆
// canvas.drawPath(path, mPaint);
// PathMeasure pathMeasure = new PathMeasure(path, false);
// Log.e("TAG", "onDraw:forceClosed=false "+ pathMeasure.getLength());
// //跳转到下一条曲线
// pathMeasure.nextContour();
// Log.e("TAG", "onDraw:forceClosed=false "+ pathMeasure.getLength());
// mPath.reset();
// mPath.addCircle(0,0,200, Path.Direction.CW);
// canvas.drawPath(mPath, mPaint);
// mFloat += 0.01;
// if (mFloat >= 1){
// mFloat = 0;
// }
// PathMeasure pathMeasure = new PathMeasure(mPath, false);
// pathMeasure.getPosTan(pathMeasure.getLength() * mFloat,pos,tan);
// Log.e("TAG", "onDraw: pos[0]="+pos[0]+";pos[1]="+pos[1]);
// Log.e("TAG", "onDraw: tan[0]="+tan[0]+";tan[1]="+tan[1]);
//
// //计算出当前的切线与x轴夹角的度数
// double degrees = Math.atan2(tan[1], tan[0]) * 180.0 / Math.PI;
// Log.e("TAG", "onDraw: degrees="+degrees);
//
// mMatrix.reset();
// //进行角度旋转
// mMatrix.postRotate((float) degrees, mBitmap.getWidth() / 2, mBitmap.getHeight() / 2);
// //将图片的绘制点中心与当前点重合
// mMatrix.postTranslate(pos[0] - mBitmap.getWidth() / 2, pos[1]-mBitmap.getHeight() / 2);
// canvas.drawBitmap(mBitmap,mMatrix, mPaint);
// PathMeasure pathMeasure = new PathMeasure(mPath, false);
//将pos信息和tan信息保存在mMatrix中
// pathMeasure.getMatrix(pathMeasure.getLength() * mFloat, mMatrix, PathMeasure.POSITION_MATRIX_FLAG | PathMeasure.TANGENT_MATRIX_FLAG);
//将图片的旋转坐标调整到图片中心位置
// mMatrix.preTranslate(-mBitmap.getWidth() / 2, -mBitmap.getHeight() / 2);
// canvas.drawBitmap(mBitmap,mMatrix, mPaint);
// invalidate();
// mLength = pathMeasure.getLength();
if(viewState == null){
viewState = new CircleState();
}
viewState.drawState(canvas);
}
public void stopAnimator() {
if (valueAnimator != null && valueAnimator.isRunning()) {
valueAnimator.cancel();
}
valueAnimator = null;
}
private Matrix mMatrix = new Matrix();
private float[] pos = new float[2];
private float[] tan = new float[2];
private Path mPath = new Path();
private Path mPath2 = new Path();
private Path mDsc = new Path();
private Path mDsc2 = new Path();
private float mFloat;
}
| 9,601 | 0.61186 | 0.592237 | 273 | 32.974358 | 26.159613 | 143 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.952381 | false | false | 15 |
e5576c4f412bce5604e69ef67beeb88206938992 | 28,372,553,977,182 | e58d896b358def1a7335f1671a0aacef7c99adde | /src/com/dss/TwoClass.java | d22ff42d0cdde3f60d1cf6c218cffebd90198385 | [] | no_license | rambej0201/SeleniumOne1 | https://github.com/rambej0201/SeleniumOne1 | c881ab8c9f27b613250f7a5073aae19a7c8ebf7d | 05e1851d233d6c52e48e4c81cc3e65f7aeaaaef8 | refs/heads/master | 2020-03-22T02:45:26.829000 | 2018-07-02T04:43:23 | 2018-07-02T04:43:23 | 139,391,368 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dss;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class TwoClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "D:\\Softwares\\JAVA\\chromedriver_win32\\chromedriver.exe");
WebDriver e = new ChromeDriver();
e.get("https://www.udemy.com/");
//e.findElement(By.xpath("//*[@id=\'udemy\']/div[1]/div[2]/div[1]/div[4]/div[4]/require-auth/div/a")).click();
e.findElement(By.xpath("//div[@class='dropdown dropdown--login']/require-auth/div/a")).click();
}
}
| UTF-8 | Java | 641 | java | TwoClass.java | Java | [] | null | [] | package com.dss;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class TwoClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "D:\\Softwares\\JAVA\\chromedriver_win32\\chromedriver.exe");
WebDriver e = new ChromeDriver();
e.get("https://www.udemy.com/");
//e.findElement(By.xpath("//*[@id=\'udemy\']/div[1]/div[2]/div[1]/div[4]/div[4]/require-auth/div/a")).click();
e.findElement(By.xpath("//div[@class='dropdown dropdown--login']/require-auth/div/a")).click();
}
}
| 641 | 0.702028 | 0.691108 | 19 | 32.736843 | 35.616142 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.368421 | false | false | 15 |
9efd5821fece8e2c0c606569ef247b3f75e8873a | 4,784,593,608,568 | 7522e4a6adc8ff227c09527cb88cb3790ec0df4f | /src/Quadrado.java | 8ef50eaeae55e99f018b1cb4fbbf614103359c6e | [] | no_license | imlucasconte/Lucas-Conte_CI_-81727834----PratProg-Aula_01 | https://github.com/imlucasconte/Lucas-Conte_CI_-81727834----PratProg-Aula_01 | 7a21d2e1b6e189ab69a829cd9b09654a4a4e19a6 | a87d46f5eef011df7463a50f5fd217c5e3df8feb | refs/heads/master | 2021-04-27T00:25:08.054000 | 2018-03-04T16:54:27 | 2018-03-04T16:54:27 | 123,809,220 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Quadrado extends Poligono implements Diagonal{
public Quadrado(double base, double altura) {
super(base, altura);
}
//Variaveis
double base = super.getBase();
double altura = super.getAltura();
//*********************************************************\
//Calculo da area
@Override
public double area() {
double area = base*altura;
return area;
}
//Calculo da diagonal
@Override
public double CalcDiagonal() {
double diagonal = Math.sqrt((base*base)+(altura*altura));
return diagonal;
}
//Calculo do perimetro
@Override
public double perimetro() {
double calcPeri = Math.pow(base,2);
return calcPeri;
}
//Método toSting
@Override
public String toString() {
return "Area: "+area()+"\nPerimetro: "+perimetro()+"\nDiagonal: "+CalcDiagonal();
}
}
| ISO-8859-2 | Java | 811 | java | Quadrado.java | Java | [] | null | [] |
public class Quadrado extends Poligono implements Diagonal{
public Quadrado(double base, double altura) {
super(base, altura);
}
//Variaveis
double base = super.getBase();
double altura = super.getAltura();
//*********************************************************\
//Calculo da area
@Override
public double area() {
double area = base*altura;
return area;
}
//Calculo da diagonal
@Override
public double CalcDiagonal() {
double diagonal = Math.sqrt((base*base)+(altura*altura));
return diagonal;
}
//Calculo do perimetro
@Override
public double perimetro() {
double calcPeri = Math.pow(base,2);
return calcPeri;
}
//Método toSting
@Override
public String toString() {
return "Area: "+area()+"\nPerimetro: "+perimetro()+"\nDiagonal: "+CalcDiagonal();
}
}
| 811 | 0.634568 | 0.633333 | 33 | 23.515152 | 19.890795 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.818182 | false | false | 15 |
d7a9bec33f3dae670eb72f9bafeb03f05d4c2544 | 21,354,577,451,269 | b39e303635b38fc6c33de77c1857524bdc323562 | /Advance/Servlet/FilterApp/src/com/dheerendra/filter/CheckInputFilter.java | 649bea50526d490c47d453ef0420595c9f3103cc | [] | no_license | Dheerendrasingh12/Java | https://github.com/Dheerendrasingh12/Java | 227473792941c63c821d5e13b61676f91d72f681 | 2e8bfdcdb7abab456afedae59f1d3e7a3205a94c | refs/heads/master | 2020-03-26T00:51:06.402000 | 2020-01-01T04:59:20 | 2020-01-01T04:59:20 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dheerendra.filter;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
@WebFilter("/sumurl")
public class CheckInputFilter implements Filter {
public CheckInputFilter() {
System.out.println("CheckInputsFilter: 0-paramconstructor");
}
@Override
public void init(FilterConfig config) throws ServletException {
System.out.println("CheckInputFilter:inint(-)");
}
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
System.out.println("CheckInputFilter:doFilter");
ServletContext sc=null;
PrintWriter pw=null;
int val1=0;
int val2=0;
pw=res.getWriter();
res.setContentType("text/html");
val1=Integer.parseInt(req.getParameter("first"));
val2=Integer.parseInt(req.getParameter("second"));
if(val1<0 || val2<0) {
pw.println("<h3 style=color:blue;text-align:center>Input Must be Positive</h4>");
pw.println("<a href=page.html>HOME PAGE</a>");
}
else {
System.out.println("checkInputFilter:before chain.doFilter(-,-)");
chain.doFilter(req, res);
System.out.println("checkInputFilter:after chain.doFilter(-,-)");
}
}
@Override
public void destroy() {
System.out.println("checkInputFilter:destroy()");
}
}
| UTF-8 | Java | 1,574 | java | CheckInputFilter.java | Java | [] | null | [] | package com.dheerendra.filter;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
@WebFilter("/sumurl")
public class CheckInputFilter implements Filter {
public CheckInputFilter() {
System.out.println("CheckInputsFilter: 0-paramconstructor");
}
@Override
public void init(FilterConfig config) throws ServletException {
System.out.println("CheckInputFilter:inint(-)");
}
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
System.out.println("CheckInputFilter:doFilter");
ServletContext sc=null;
PrintWriter pw=null;
int val1=0;
int val2=0;
pw=res.getWriter();
res.setContentType("text/html");
val1=Integer.parseInt(req.getParameter("first"));
val2=Integer.parseInt(req.getParameter("second"));
if(val1<0 || val2<0) {
pw.println("<h3 style=color:blue;text-align:center>Input Must be Positive</h4>");
pw.println("<a href=page.html>HOME PAGE</a>");
}
else {
System.out.println("checkInputFilter:before chain.doFilter(-,-)");
chain.doFilter(req, res);
System.out.println("checkInputFilter:after chain.doFilter(-,-)");
}
}
@Override
public void destroy() {
System.out.println("checkInputFilter:destroy()");
}
}
| 1,574 | 0.740152 | 0.731893 | 63 | 23.984127 | 22.986877 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.809524 | false | false | 15 |
f21a193c56b2878e06397bff9e1fe6c97450d419 | 26,938,034,936,527 | 1fda65b298311eb157f95bcb8c5b5f9d19f7f3c4 | /Test.java | 6b4b5f2cae9e99fc94f70d9bc94c6ee2a8dfaa1f | [] | no_license | Mihai238/Aufgabe8 | https://github.com/Mihai238/Aufgabe8 | 61f727e6b9e751b0445f5ae55034b074576b0f6a | 922c4e5204518845288d0a6f357964c2256e9d25 | refs/heads/master | 2015-08-04T19:49:38.757000 | 2012-12-11T19:49:06 | 2012-12-11T19:49:06 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.lang.reflect.Method;
/**
* Test.java Dec 9, 2012
* @author Mihai Lepadat
*/
@Author(who="Mihai Lepadat")
public class Test {
private static final String separator = "--------------------------------------------------------" +
"\n--------------------------------------------------------";
private static FarmsManagement farms; //set used to store multiple farms
@Author(who="Mihai Lepadat")
public static void main(String[] args) {
/* Create a collection of farms */
farms = new FarmsManagement();
testAddDelete();
testActiveHours();
testConsumption();
testSaeenAndDuengen();
testAnnotationen();
}
/**
* Test the functionality of add/remove tractors
*/
@Author(who="Mihai Lepadat")
public static void testAddDelete() {
System.out.println("Test add/delete of the farms/tractors: ");
System.out.println();
/* Create a new farm */
Bauernhof b0 = new Bauernhof("b0");
DieselTraktor t0 = new DieselTraktor(0, new Duengen(10.5));
DieselTraktor t1 = new DieselTraktor(1, new Saeen(10));
BiogasTraktor t2 = new BiogasTraktor(2, new Duengen(22.2));
BiogasTraktor t3 = new BiogasTraktor(3, new Saeen(20));
b0.insert(t0); b0.insert(t1); b0.insert(t2); b0.insert(t3);
/* Create another farm*/
Bauernhof b1 = new Bauernhof("b1");
DieselTraktor t4 = new DieselTraktor(4, new Duengen(10.5));
DieselTraktor t5 = new DieselTraktor(5, new Saeen(10));
BiogasTraktor t6 = new BiogasTraktor(6, new Duengen(22.2));
BiogasTraktor t7 = new BiogasTraktor(7, new Saeen(20));
b1.insert(t4); b1.insert(t5); b1.insert(t6); b1.insert(t7);
/* Create a collection of farms and add the farms*/
farms.addFarm(b0);
farms.addFarm(b1);
/* Print the Farm with the name "b1" */
System.out.println("Print details about the farm called b1:");
System.out.println(farms.getFarm("b1"));
/* Print the tractor with the number 0 */
System.out.println("Print details about the tractor with the number 0:");
b0.increaseTractorActiveHours(0, 10); b0.increaseTractorDieselConsume(0, 5);
System.out.println(farms.getTractor(0));
/* Print the tractor with the number 7 */
System.out.println("Print details about the tractor with the number 7:");
b1.increaseTractorActiveHours(7, 25); b1.increaseTractorBiogasConsume(7, 20.235);
System.out.println(farms.getTractor(7));
/* Remove the tractors with the numbers 0, 1 and 3*/
if (farms.getFarmByTractor(0).remove(0)) System.out.println("The tractor with the number 0 was successfully removed!");
if (farms.getFarmByTractor(1).remove(1)) System.out.println("The tractor with the number 1 was successfully removed!");
if (farms.getFarmByTractor(3).remove(3)) System.out.println("The tractor with the number 3 was successfully removed!");
/* Add a new tractor with the number 99 in the farm b0*/
Traktor t99 = new DieselTraktor(99, new Duengen(100));
if (farms.addTractor("b0", t99)) System.out.println("The tractor with the number 99 was successfully added to farm b0!");
System.out.println("The farm called b0 has now the following tractors:");
System.out.println(farms.getFarm("b0"));
System.out.println();
}
/**
* Test the functionality of the computation of active hours
*/
@Author(who="Mihai Lepadat")
public static void testActiveHours() {
System.out.println(separator);
System.out.println("Test the active hours: ");
System.out.println();
/* Increase the number of active hours */
System.out.println("Increase the number of active hours for all tractors from farm called b0 by 12");
farms.getFarm("b0").increaseAllActiveHours(12);
System.out.println("Increase the number of active hours for the tractor with the number 99 by 1");
farms.getTractor(99).increaseActiveHours(1);
System.out.println("The farm b0 has the following average active hour:");
System.out.println(farms.getFarm("b0").getAverageActiveHour());
System.out.println("The farm b0 has the following average active hour for diesel tactors:");
System.out.println(farms.getFarm("b0").getAverageActiveHourForDiesel());
System.out.println("The farm b0 has the following average active hour for biogas tractors:");
System.out.println(farms.getFarm("b0").getAverageActiveHourForBiogas());
System.out.println("The farm b0 has the following average active hour for duengen tactors:");
System.out.println(farms.getFarm("b0").getAverageActiveHourForDuengen());
System.out.println("The farm b0 has the following average active hour for saeen tractors:");
System.out.println(farms.getFarm("b0").getAverageActiveHourForSaeen());
}
/**
* Test the functionality of the computation of consume
*/
@Author(who="Mihai Lepadat")
public static void testConsumption() {
System.out.println(separator);
System.out.println("Test the consume hours: ");
System.out.println();
System.out.println("Increase the diesel consume of tractor 4 by 12 and for 5 by 100");
farms.getTractor(4).increaseDieselConsume(12);
farms.getTractor(5).increaseDieselConsume(100);
System.out.println("Increase the biogas consume of tractor 6 by 8");
farms.getTractor(6).increaseBiogasConsume(8);
System.out.println("The farm b1 has the following average diesel consume: ");
System.out.println(farms.getFarm("b1").getAverageDieselConsume());
System.out.println("The farm b1 has the following average diesel consume for Duengen: ");
System.out.println(farms.getFarm("b1").getAverageDieselConsumeForDuengen());
System.out.println("The farm b1 has the following average diesel consume for Saeen: ");
System.out.println(farms.getFarm("b1").getAverageDieselConsumeForSaeen());
System.out.println();
System.out.println("The farm b1 has the following average biogas consume: ");
System.out.println(farms.getFarm("b1").getAverageBiogasConsume());
System.out.println("The farm b1 has the following average biogas consume for Duengen: ");
System.out.println(farms.getFarm("b1").getAverageBiogasConsumeForDuengen());
System.out.println("The farm b1 has the following average biogas consume for Saeen: ");
System.out.println(farms.getFarm("b1").getAverageBiogasConsumeForSaeen());
}
@Author(who="Mihai Lepadat")
public static void testSaeenAndDuengen() {
System.out.println(separator);
System.out.println("Test the number of Saescharen: ");
System.out.println();
System.out.println("The farm b1 has the following minimum number of Saescharen: ");
System.out.println(farms.getFarm("b1").getMinNumberSaeschare());
System.out.println("The farm b1 has the following minimum number of Saescharen for diesel: ");
System.out.println(farms.getFarm("b1").getMinNumberSaeschareForDiesel());
System.out.println("The farm b1 has the following minimum number of Saescharen for biogas: ");
System.out.println(farms.getFarm("b1").getMinNumberSaeschareForBiogas());
System.out.println("The farm b1 has the following maximum number of Saescharen: ");
System.out.println(farms.getFarm("b1").getMaxNumberSaeschare());
System.out.println("The farm b1 has the following maximum number of Saescharen for diesel: ");
System.out.println(farms.getFarm("b1").getMaxNumberSaeschareForDiesel());
System.out.println("The farm b1 has the following maximum number of Saescharen for biogas: ");
System.out.println(farms.getFarm("b1").getMaxNumberSaeschareForBiogas());
System.out.println(separator);
System.out.println("Test the average capacity of Duengen: ");
System.out.println();
System.out.println("The farm b1 has the following average capacity: ");
System.out.println(farms.getFarm("b1").getAverageDuengenCapacity());
System.out.println("The farm b1 has the following average capacity for diesel: ");
System.out.println(farms.getFarm("b1").getAverageDuengenCapacityForDiesel());
System.out.println("The farm b1 has the following average capacity for biogas: ");
System.out.println(farms.getFarm("b1").getAverageDuengenCapacityForBiogas());
}
/**
* Test the annotations
*/
@Author(who="Mihai Lepadat")
public static void testAnnotationen() {
System.out.println(separator);
System.out.println("Test the annotationen: ");
System.out.println();
getAnn(Node.class);
getAnn(MyIterator.class);
getAnn(Set.class);
getAnn(Bauernhof.class);
getAnn(BiogasTraktor.class);
getAnn(DieselTraktor.class);
getAnn(Duengen.class);
getAnn(Role.class);
getAnn(Saeen.class);
getAnn(Traktor.class);
getAnn(FarmsManagement.class);
getAnn(Test.class);
}
/**
* This method displays informations about a given class
* @param cl An object of type class
*/
@Author(who="Mihai Lepadat")
public static void getAnn(Class<?> cl) {
Author author = cl.getAnnotation(Author.class);
if (cl.isInterface()) System.out.print("The author of the interface " + cl.getName() + " is: ");
else System.out.print("The author of the class " + cl.getName() + " is: ");
System.out.println(author.who());
if (cl.isInterface()) System.out.println("The following methods are implemented in the interface " + cl.getName() + ":");
else System.out.println("The following methods are implemented in the class " + cl.getName() + ":");
Method[] ms = cl.getDeclaredMethods();
for (Method m : ms) {
System.out.println(m.getName() + " implemented by " + m.getAnnotation(Author.class).who());
}
System.out.println();
}
}
| UTF-8 | Java | 9,361 | java | Test.java | Java | [
{
"context": ".Method;\n\n/**\n * Test.java Dec 9, 2012 \n * @author Mihai Lepadat\n */\n@Author(who=\"Mihai Lepadat\")\npublic class Tes",
"end": 88,
"score": 0.9999034404754639,
"start": 75,
"tag": "NAME",
"value": "Mihai Lepadat"
},
{
"context": ", 2012 \n * @author Mihai Lepadat\n */\n@Author(who=\"Mihai Lepadat\")\npublic class Test {\n\t\n\tprivate static final Str",
"end": 119,
"score": 0.9999094009399414,
"start": 106,
"tag": "NAME",
"value": "Mihai Lepadat"
},
{
"context": "/set used to store multiple farms\n\t\n\t@Author(who=\"Mihai Lepadat\")\n\tpublic static void main(String[] args) {\n\t\t/* ",
"end": 416,
"score": 0.999908983707428,
"start": 403,
"tag": "NAME",
"value": "Mihai Lepadat"
},
{
"context": "onality of add/remove tractors\n\t */\n\t@Author(who=\"Mihai Lepadat\")\n\tpublic static void testAddDelete() {\n\t\tSystem.",
"end": 734,
"score": 0.9999087452888489,
"start": 721,
"tag": "NAME",
"value": "Mihai Lepadat"
},
{
"context": "he computation of active hours\n\t */\n\t@Author(who=\"Mihai Lepadat\")\n\tpublic static void testActiveHours() {\n\t\tSyste",
"end": 3267,
"score": 0.9998734593391418,
"start": 3254,
"tag": "NAME",
"value": "Mihai Lepadat"
},
{
"context": " of the computation of consume\n\t */\n\t@Author(who=\"Mihai Lepadat\")\n\tpublic static void testConsumption() {\n\t\tSyste",
"end": 4694,
"score": 0.9998887181282043,
"start": 4681,
"tag": "NAME",
"value": "Mihai Lepadat"
},
{
"context": "erageBiogasConsumeForSaeen());\n\t}\n\t\n\t@Author(who=\"Mihai Lepadat\")\n\tpublic static void testSaeenAndDuengen() {\n\t\tS",
"end": 6190,
"score": 0.9998952746391296,
"start": 6177,
"tag": "NAME",
"value": "Mihai Lepadat"
},
{
"context": "\n\t/**\n\t * Test the annotations\n\t */\n\t@Author(who=\"Mihai Lepadat\")\n\tpublic static void testAnnotationen() {\n\t\tSyst",
"end": 8021,
"score": 0.9999009966850281,
"start": 8008,
"tag": "NAME",
"value": "Mihai Lepadat"
},
{
"context": "ram cl An object of type class\n\t */\n\t@Author(who=\"Mihai Lepadat\")\n\tpublic static void getAnn(Class<?> cl) {\n\t\tAut",
"end": 8619,
"score": 0.9999051094055176,
"start": 8606,
"tag": "NAME",
"value": "Mihai Lepadat"
}
] | null | [] | import java.lang.reflect.Method;
/**
* Test.java Dec 9, 2012
* @author <NAME>
*/
@Author(who="<NAME>")
public class Test {
private static final String separator = "--------------------------------------------------------" +
"\n--------------------------------------------------------";
private static FarmsManagement farms; //set used to store multiple farms
@Author(who="<NAME>")
public static void main(String[] args) {
/* Create a collection of farms */
farms = new FarmsManagement();
testAddDelete();
testActiveHours();
testConsumption();
testSaeenAndDuengen();
testAnnotationen();
}
/**
* Test the functionality of add/remove tractors
*/
@Author(who="<NAME>")
public static void testAddDelete() {
System.out.println("Test add/delete of the farms/tractors: ");
System.out.println();
/* Create a new farm */
Bauernhof b0 = new Bauernhof("b0");
DieselTraktor t0 = new DieselTraktor(0, new Duengen(10.5));
DieselTraktor t1 = new DieselTraktor(1, new Saeen(10));
BiogasTraktor t2 = new BiogasTraktor(2, new Duengen(22.2));
BiogasTraktor t3 = new BiogasTraktor(3, new Saeen(20));
b0.insert(t0); b0.insert(t1); b0.insert(t2); b0.insert(t3);
/* Create another farm*/
Bauernhof b1 = new Bauernhof("b1");
DieselTraktor t4 = new DieselTraktor(4, new Duengen(10.5));
DieselTraktor t5 = new DieselTraktor(5, new Saeen(10));
BiogasTraktor t6 = new BiogasTraktor(6, new Duengen(22.2));
BiogasTraktor t7 = new BiogasTraktor(7, new Saeen(20));
b1.insert(t4); b1.insert(t5); b1.insert(t6); b1.insert(t7);
/* Create a collection of farms and add the farms*/
farms.addFarm(b0);
farms.addFarm(b1);
/* Print the Farm with the name "b1" */
System.out.println("Print details about the farm called b1:");
System.out.println(farms.getFarm("b1"));
/* Print the tractor with the number 0 */
System.out.println("Print details about the tractor with the number 0:");
b0.increaseTractorActiveHours(0, 10); b0.increaseTractorDieselConsume(0, 5);
System.out.println(farms.getTractor(0));
/* Print the tractor with the number 7 */
System.out.println("Print details about the tractor with the number 7:");
b1.increaseTractorActiveHours(7, 25); b1.increaseTractorBiogasConsume(7, 20.235);
System.out.println(farms.getTractor(7));
/* Remove the tractors with the numbers 0, 1 and 3*/
if (farms.getFarmByTractor(0).remove(0)) System.out.println("The tractor with the number 0 was successfully removed!");
if (farms.getFarmByTractor(1).remove(1)) System.out.println("The tractor with the number 1 was successfully removed!");
if (farms.getFarmByTractor(3).remove(3)) System.out.println("The tractor with the number 3 was successfully removed!");
/* Add a new tractor with the number 99 in the farm b0*/
Traktor t99 = new DieselTraktor(99, new Duengen(100));
if (farms.addTractor("b0", t99)) System.out.println("The tractor with the number 99 was successfully added to farm b0!");
System.out.println("The farm called b0 has now the following tractors:");
System.out.println(farms.getFarm("b0"));
System.out.println();
}
/**
* Test the functionality of the computation of active hours
*/
@Author(who="<NAME>")
public static void testActiveHours() {
System.out.println(separator);
System.out.println("Test the active hours: ");
System.out.println();
/* Increase the number of active hours */
System.out.println("Increase the number of active hours for all tractors from farm called b0 by 12");
farms.getFarm("b0").increaseAllActiveHours(12);
System.out.println("Increase the number of active hours for the tractor with the number 99 by 1");
farms.getTractor(99).increaseActiveHours(1);
System.out.println("The farm b0 has the following average active hour:");
System.out.println(farms.getFarm("b0").getAverageActiveHour());
System.out.println("The farm b0 has the following average active hour for diesel tactors:");
System.out.println(farms.getFarm("b0").getAverageActiveHourForDiesel());
System.out.println("The farm b0 has the following average active hour for biogas tractors:");
System.out.println(farms.getFarm("b0").getAverageActiveHourForBiogas());
System.out.println("The farm b0 has the following average active hour for duengen tactors:");
System.out.println(farms.getFarm("b0").getAverageActiveHourForDuengen());
System.out.println("The farm b0 has the following average active hour for saeen tractors:");
System.out.println(farms.getFarm("b0").getAverageActiveHourForSaeen());
}
/**
* Test the functionality of the computation of consume
*/
@Author(who="<NAME>")
public static void testConsumption() {
System.out.println(separator);
System.out.println("Test the consume hours: ");
System.out.println();
System.out.println("Increase the diesel consume of tractor 4 by 12 and for 5 by 100");
farms.getTractor(4).increaseDieselConsume(12);
farms.getTractor(5).increaseDieselConsume(100);
System.out.println("Increase the biogas consume of tractor 6 by 8");
farms.getTractor(6).increaseBiogasConsume(8);
System.out.println("The farm b1 has the following average diesel consume: ");
System.out.println(farms.getFarm("b1").getAverageDieselConsume());
System.out.println("The farm b1 has the following average diesel consume for Duengen: ");
System.out.println(farms.getFarm("b1").getAverageDieselConsumeForDuengen());
System.out.println("The farm b1 has the following average diesel consume for Saeen: ");
System.out.println(farms.getFarm("b1").getAverageDieselConsumeForSaeen());
System.out.println();
System.out.println("The farm b1 has the following average biogas consume: ");
System.out.println(farms.getFarm("b1").getAverageBiogasConsume());
System.out.println("The farm b1 has the following average biogas consume for Duengen: ");
System.out.println(farms.getFarm("b1").getAverageBiogasConsumeForDuengen());
System.out.println("The farm b1 has the following average biogas consume for Saeen: ");
System.out.println(farms.getFarm("b1").getAverageBiogasConsumeForSaeen());
}
@Author(who="<NAME>")
public static void testSaeenAndDuengen() {
System.out.println(separator);
System.out.println("Test the number of Saescharen: ");
System.out.println();
System.out.println("The farm b1 has the following minimum number of Saescharen: ");
System.out.println(farms.getFarm("b1").getMinNumberSaeschare());
System.out.println("The farm b1 has the following minimum number of Saescharen for diesel: ");
System.out.println(farms.getFarm("b1").getMinNumberSaeschareForDiesel());
System.out.println("The farm b1 has the following minimum number of Saescharen for biogas: ");
System.out.println(farms.getFarm("b1").getMinNumberSaeschareForBiogas());
System.out.println("The farm b1 has the following maximum number of Saescharen: ");
System.out.println(farms.getFarm("b1").getMaxNumberSaeschare());
System.out.println("The farm b1 has the following maximum number of Saescharen for diesel: ");
System.out.println(farms.getFarm("b1").getMaxNumberSaeschareForDiesel());
System.out.println("The farm b1 has the following maximum number of Saescharen for biogas: ");
System.out.println(farms.getFarm("b1").getMaxNumberSaeschareForBiogas());
System.out.println(separator);
System.out.println("Test the average capacity of Duengen: ");
System.out.println();
System.out.println("The farm b1 has the following average capacity: ");
System.out.println(farms.getFarm("b1").getAverageDuengenCapacity());
System.out.println("The farm b1 has the following average capacity for diesel: ");
System.out.println(farms.getFarm("b1").getAverageDuengenCapacityForDiesel());
System.out.println("The farm b1 has the following average capacity for biogas: ");
System.out.println(farms.getFarm("b1").getAverageDuengenCapacityForBiogas());
}
/**
* Test the annotations
*/
@Author(who="<NAME>")
public static void testAnnotationen() {
System.out.println(separator);
System.out.println("Test the annotationen: ");
System.out.println();
getAnn(Node.class);
getAnn(MyIterator.class);
getAnn(Set.class);
getAnn(Bauernhof.class);
getAnn(BiogasTraktor.class);
getAnn(DieselTraktor.class);
getAnn(Duengen.class);
getAnn(Role.class);
getAnn(Saeen.class);
getAnn(Traktor.class);
getAnn(FarmsManagement.class);
getAnn(Test.class);
}
/**
* This method displays informations about a given class
* @param cl An object of type class
*/
@Author(who="<NAME>")
public static void getAnn(Class<?> cl) {
Author author = cl.getAnnotation(Author.class);
if (cl.isInterface()) System.out.print("The author of the interface " + cl.getName() + " is: ");
else System.out.print("The author of the class " + cl.getName() + " is: ");
System.out.println(author.who());
if (cl.isInterface()) System.out.println("The following methods are implemented in the interface " + cl.getName() + ":");
else System.out.println("The following methods are implemented in the class " + cl.getName() + ":");
Method[] ms = cl.getDeclaredMethods();
for (Method m : ms) {
System.out.println(m.getName() + " implemented by " + m.getAnnotation(Author.class).who());
}
System.out.println();
}
}
| 9,298 | 0.717124 | 0.696827 | 217 | 42.138248 | 32.893196 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.40553 | false | false | 15 |
8f878811079c6513e03e7b26620d4ad1ec0f6a78 | 1,030,792,169,125 | 6597856f966ef05a1912040cb7b399aa501a1c62 | /app/src/main/java/com/funnyapps/moviespal/ReviewsBottomSheet.java | f8d64bde9b99ff37caf15faf926ac8fb1a115a22 | [] | no_license | wisammechano/MoviesPal | https://github.com/wisammechano/MoviesPal | 4272571084a1f9b8016fc9f1978b9b289e5ec766 | e64b6478709409740b2fd14c918d9668da0f4380 | refs/heads/master | 2020-03-23T21:25:03.354000 | 2018-08-18T14:58:04 | 2018-08-18T14:58:04 | 142,104,961 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.funnyapps.moviespal;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetDialogFragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.funnyapps.moviespal.Models.Review;
import java.util.List;
public class ReviewsBottomSheet extends BottomSheetDialogFragment {
private List<Review> reviews;
public ReviewsBottomSheet() {
// Required empty public constructor
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View root = inflater.inflate(R.layout.fragment_reviews_bottom_sheet, container, false);
RecyclerView mainRv = root.findViewById(R.id.reviews_rv);
Toolbar tb = root.findViewById(R.id.frag_toolbar);
tb.setTitle(R.string.reviews);
tb.setNavigationIcon(getResources().getDrawable(R.drawable.ic_back));
tb.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ReviewsBottomSheet.this.dismiss();
}
});
mainRv.setLayoutManager(new LinearLayoutManager(getContext()));
ReviewsAdapter adapter = new ReviewsAdapter(getContext());
adapter.setReviews(reviews);
mainRv.setAdapter(adapter);
return root;
}
public void setReviews(List<Review> reviews){
this.reviews = reviews;
}
}
| UTF-8 | Java | 1,747 | java | ReviewsBottomSheet.java | Java | [] | null | [] | package com.funnyapps.moviespal;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetDialogFragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.funnyapps.moviespal.Models.Review;
import java.util.List;
public class ReviewsBottomSheet extends BottomSheetDialogFragment {
private List<Review> reviews;
public ReviewsBottomSheet() {
// Required empty public constructor
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View root = inflater.inflate(R.layout.fragment_reviews_bottom_sheet, container, false);
RecyclerView mainRv = root.findViewById(R.id.reviews_rv);
Toolbar tb = root.findViewById(R.id.frag_toolbar);
tb.setTitle(R.string.reviews);
tb.setNavigationIcon(getResources().getDrawable(R.drawable.ic_back));
tb.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ReviewsBottomSheet.this.dismiss();
}
});
mainRv.setLayoutManager(new LinearLayoutManager(getContext()));
ReviewsAdapter adapter = new ReviewsAdapter(getContext());
adapter.setReviews(reviews);
mainRv.setAdapter(adapter);
return root;
}
public void setReviews(List<Review> reviews){
this.reviews = reviews;
}
}
| 1,747 | 0.705209 | 0.703492 | 50 | 33.939999 | 25.317513 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 15 |
c371fdc95ac1707bc7134e4ef69feff7c41d3c12 | 8,718,783,633,518 | 7b429523017f3816d88c43f6b9bee8610185a0e3 | /worksapce/day32/src/cn/itcast/demo1/UDPSend.java | 04a3a4e9949ee570ac2c1454553d61afe8510be2 | [] | no_license | nixiangyu1/Java-Foundation | https://github.com/nixiangyu1/Java-Foundation | c736130d655aed05d8f7bea274fe1d83cf402949 | 87f68f355521315d662021b087a3cf2dc178279a | refs/heads/master | 2020-05-21T14:39:35.240000 | 2019-07-17T02:46:36 | 2019-07-17T02:46:36 | 186,086,069 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.itcast.demo1;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;
public class UDPSend {
public static void main(String[] args) throws IOException {
//
Scanner sc = new Scanner(System.in);
DatagramSocket ds = new DatagramSocket();
InetAddress inet = InetAddress.getByName("192.168.56.1");
while(true) {
String message = sc.nextLine();
byte[] data = message.getBytes();
//创建InetAddress对象,封装自己的IP地址
DatagramPacket dp = new DatagramPacket(data, data.length,inet,6000);
//创建
ds.send(dp);
System.out.println(new String(data));
}
// ds.close();
}
}
| GB18030 | Java | 710 | java | UDPSend.java | Java | [
{
"context": "(); \n\t\tInetAddress inet = InetAddress.getByName(\"192.168.56.1\");\n\t\twhile(true) {\n\t\tString message = sc.nextLine",
"end": 404,
"score": 0.9997546672821045,
"start": 392,
"tag": "IP_ADDRESS",
"value": "192.168.56.1"
}
] | null | [] | package cn.itcast.demo1;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;
public class UDPSend {
public static void main(String[] args) throws IOException {
//
Scanner sc = new Scanner(System.in);
DatagramSocket ds = new DatagramSocket();
InetAddress inet = InetAddress.getByName("192.168.56.1");
while(true) {
String message = sc.nextLine();
byte[] data = message.getBytes();
//创建InetAddress对象,封装自己的IP地址
DatagramPacket dp = new DatagramPacket(data, data.length,inet,6000);
//创建
ds.send(dp);
System.out.println(new String(data));
}
// ds.close();
}
}
| 710 | 0.719941 | 0.699413 | 26 | 25.23077 | 19.020855 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.846154 | false | false | 15 |
d23c4e4faabb48dbaa1d7cfbe68e1845c47dec71 | 9,972,914,088,406 | 1de8a36d13aa9b792c1980aed9677ae9935bead7 | /powerfin/src/com/powerfin/model/MovableType.java | eb63a2ca63298b83dcec8ced7761bdb40a45b1f9 | [] | no_license | ochiengisaac/sss | https://github.com/ochiengisaac/sss | f5b55e53252305b97797edfb68cbcea84d4aa65a | 471c8d5f5373a2b49dde805d7f518dbcbc42014c | refs/heads/master | 2022-02-26T00:57:25.794000 | 2019-05-31T22:22:02 | 2019-05-31T22:22:02 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.powerfin.model;
import java.io.*;
import java.util.*;
import javax.persistence.*;
import org.openxava.annotations.*;
/**
* The persistent class for the movable_type database table.
*
*/
@Entity
@Table(name="movable_type")
@View(members = "movableTypeId;"
+ "name;")
public class MovableType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="movable_type_id", unique=true, nullable=false, length=3)
private String movableTypeId;
@Column(nullable=false, length=100)
private String name;
//bi-directional many-to-one association to PersonMovable
@OneToMany(mappedBy="movableType")
private List<PersonMovable> personMovables;
public MovableType() {
}
public String getMovableTypeId() {
return this.movableTypeId;
}
public void setMovableTypeId(String movableTypeId) {
this.movableTypeId = movableTypeId;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public List<PersonMovable> getPersonMovables() {
return this.personMovables;
}
public void setPersonMovables(List<PersonMovable> personMovables) {
this.personMovables = personMovables;
}
public PersonMovable addPersonMovable(PersonMovable personMovable) {
getPersonMovables().add(personMovable);
personMovable.setMovableType(this);
return personMovable;
}
public PersonMovable removePersonMovable(PersonMovable personMovable) {
getPersonMovables().remove(personMovable);
personMovable.setMovableType(null);
return personMovable;
}
} | UTF-8 | Java | 1,567 | java | MovableType.java | Java | [] | null | [] | package com.powerfin.model;
import java.io.*;
import java.util.*;
import javax.persistence.*;
import org.openxava.annotations.*;
/**
* The persistent class for the movable_type database table.
*
*/
@Entity
@Table(name="movable_type")
@View(members = "movableTypeId;"
+ "name;")
public class MovableType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="movable_type_id", unique=true, nullable=false, length=3)
private String movableTypeId;
@Column(nullable=false, length=100)
private String name;
//bi-directional many-to-one association to PersonMovable
@OneToMany(mappedBy="movableType")
private List<PersonMovable> personMovables;
public MovableType() {
}
public String getMovableTypeId() {
return this.movableTypeId;
}
public void setMovableTypeId(String movableTypeId) {
this.movableTypeId = movableTypeId;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public List<PersonMovable> getPersonMovables() {
return this.personMovables;
}
public void setPersonMovables(List<PersonMovable> personMovables) {
this.personMovables = personMovables;
}
public PersonMovable addPersonMovable(PersonMovable personMovable) {
getPersonMovables().add(personMovable);
personMovable.setMovableType(this);
return personMovable;
}
public PersonMovable removePersonMovable(PersonMovable personMovable) {
getPersonMovables().remove(personMovable);
personMovable.setMovableType(null);
return personMovable;
}
} | 1,567 | 0.758137 | 0.754946 | 74 | 20.18919 | 21.408306 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.081081 | false | false | 15 |
99dc321be8b6cafbc40f4c71bbfcf576d8d802b2 | 9,053,791,077,024 | 7c996f3b0685d56f06d6f17a01784e0dea640dd2 | /examples/documentation/src/test/java/de/quantummaid/httpmaid/documentation/exceptions/ExceptionExampleTests.java | 627506aee6e5e785a2ca1453ad1e51a618807319 | [
"Apache-2.0"
] | permissive | quantummaid/httpmaid | https://github.com/quantummaid/httpmaid | 1f110eb685b62dd7342d9575026051c942a186a7 | cd570b6e810181af727fbbdbe90dc627ee85349d | refs/heads/master | 2022-12-24T14:25:28.480000 | 2021-08-10T10:49:46 | 2021-08-10T10:49:46 | 227,642,614 | 10 | 1 | Apache-2.0 | false | 2022-12-12T21:43:25 | 2019-12-12T15:52:33 | 2021-08-10T10:49:49 | 2022-12-12T21:43:21 | 3,074 | 10 | 0 | 37 | Java | false | false | /*
* Copyright (c) 2020 Richard Hauswald - https://quantummaid.de/.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package de.quantummaid.httpmaid.documentation.exceptions;
import de.quantummaid.httpmaid.HttpMaid;
import de.quantummaid.httpmaid.documentation.support.Deployer;
import org.junit.jupiter.api.Test;
import static de.quantummaid.httpmaid.HttpMaid.anHttpMaid;
import static de.quantummaid.httpmaid.exceptions.ExceptionConfigurators.toMapExceptionsByDefaultUsing;
import static de.quantummaid.httpmaid.exceptions.ExceptionConfigurators.toMapExceptionsOfType;
public final class ExceptionExampleTests {
@Test
public void exceptionInHandlerExample() {
//Showcase start exceptionInHandler
final HttpMaid httpMaid = anHttpMaid()
.get("/exception", (request, response) -> {
throw new RuntimeException("this is an example");
})
.build();
//Showcase end exceptionInHandler
Deployer.test(httpMaid, client ->
Deployer.assertGet("/exception", "", 500, client));
}
@Test
public void mappedDefaultExceptionExample() {
//Showcase start defaultMappedException
final HttpMaid httpMaid = anHttpMaid()
.get("/exception", (request, response) -> {
throw new RuntimeException("this is an example");
})
.configured(toMapExceptionsByDefaultUsing((exception, request, response) -> response.setBody("Something went wrong")))
.build();
//Showcase end defaultMappedException
Deployer.test(httpMaid, client ->
Deployer.assertGet("/exception", "Something went wrong", 500, client));
}
@Test
public void mappedSpecificExceptionExample() {
//Showcase start specificMappedException
final HttpMaid httpMaid = anHttpMaid()
.get("/exception", (request, response) -> {
throw new UnsupportedOperationException("this is an example");
})
.configured(toMapExceptionsByDefaultUsing((exception, request, response) -> response.setBody("Something went wrong")))
.configured(toMapExceptionsOfType(UnsupportedOperationException.class, (exception, request, response) -> response.setBody("Operation not supported")))
.build();
//Showcase end specificMappedException
Deployer.test(httpMaid, client ->
Deployer.assertGet("/exception", "Operation not supported", 500, client));
}
}
| UTF-8 | Java | 3,346 | java | ExceptionExampleTests.java | Java | [
{
"context": "/*\n * Copyright (c) 2020 Richard Hauswald - https://quantummaid.de/.\n *\n * Licensed to the ",
"end": 41,
"score": 0.9997810125350952,
"start": 25,
"tag": "NAME",
"value": "Richard Hauswald"
}
] | null | [] | /*
* Copyright (c) 2020 <NAME> - https://quantummaid.de/.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package de.quantummaid.httpmaid.documentation.exceptions;
import de.quantummaid.httpmaid.HttpMaid;
import de.quantummaid.httpmaid.documentation.support.Deployer;
import org.junit.jupiter.api.Test;
import static de.quantummaid.httpmaid.HttpMaid.anHttpMaid;
import static de.quantummaid.httpmaid.exceptions.ExceptionConfigurators.toMapExceptionsByDefaultUsing;
import static de.quantummaid.httpmaid.exceptions.ExceptionConfigurators.toMapExceptionsOfType;
public final class ExceptionExampleTests {
@Test
public void exceptionInHandlerExample() {
//Showcase start exceptionInHandler
final HttpMaid httpMaid = anHttpMaid()
.get("/exception", (request, response) -> {
throw new RuntimeException("this is an example");
})
.build();
//Showcase end exceptionInHandler
Deployer.test(httpMaid, client ->
Deployer.assertGet("/exception", "", 500, client));
}
@Test
public void mappedDefaultExceptionExample() {
//Showcase start defaultMappedException
final HttpMaid httpMaid = anHttpMaid()
.get("/exception", (request, response) -> {
throw new RuntimeException("this is an example");
})
.configured(toMapExceptionsByDefaultUsing((exception, request, response) -> response.setBody("Something went wrong")))
.build();
//Showcase end defaultMappedException
Deployer.test(httpMaid, client ->
Deployer.assertGet("/exception", "Something went wrong", 500, client));
}
@Test
public void mappedSpecificExceptionExample() {
//Showcase start specificMappedException
final HttpMaid httpMaid = anHttpMaid()
.get("/exception", (request, response) -> {
throw new UnsupportedOperationException("this is an example");
})
.configured(toMapExceptionsByDefaultUsing((exception, request, response) -> response.setBody("Something went wrong")))
.configured(toMapExceptionsOfType(UnsupportedOperationException.class, (exception, request, response) -> response.setBody("Operation not supported")))
.build();
//Showcase end specificMappedException
Deployer.test(httpMaid, client ->
Deployer.assertGet("/exception", "Operation not supported", 500, client));
}
}
| 3,336 | 0.679319 | 0.674238 | 78 | 41.897434 | 34.090599 | 166 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.589744 | false | false | 15 |
3e6386dde64196007cdc9215de31c96070cc8f1a | 16,707,422,831,840 | 10dc699710d7b1e16ad615b9cfd96ecf2cc5d5dc | /src/main/java/cn/youguang/controller/DbController.java | b53f231cd13a8100dc11075aa42bd602139a8a38 | [] | no_license | andy20160606/yxgj | https://github.com/andy20160606/yxgj | 6f6aa50171eb2d0560e38e5947858d672907308f | 645be8ba8fa45c2c7cb1daa9959bb84c2e177063 | refs/heads/master | 2021-09-27T03:38:29.756000 | 2019-07-17T01:51:33 | 2019-07-17T01:51:33 | 186,326,500 | 0 | 0 | null | false | 2021-09-20T20:48:20 | 2019-05-13T01:41:57 | 2019-07-17T01:51:50 | 2021-09-20T20:48:17 | 140 | 0 | 0 | 6 | Java | false | false | package cn.youguang.controller;
import cn.youguang.entity.Organization;
import cn.youguang.entity.Resource;
import cn.youguang.entity.Role;
import cn.youguang.entity.User;
import cn.youguang.service.OrganizationService;
import cn.youguang.service.ResourceService;
import cn.youguang.service.RoleService;
import cn.youguang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.Date;
@Controller
@RequestMapping("db")
public class DbController {
@Autowired
private ResourceService resService;
@Autowired
private OrganizationService orgService;
@Autowired
private RoleService roleService;
@Autowired
private UserService userService;
@ResponseBody
@RequestMapping("/ressave")
public Resource resSave() {
Resource res = new Resource();
res.setCreatedate(new Date());
res.setDescription("系统管理");
res.setUrl("system");
res.setName("res-name-1");
res.setResourcetype(0);
resService.saveRes(res);
Resource res1=new Resource();
res1.setCreatedate(new Date());
res1.setDescription("系统管理/用户管理");
res1.setUrl("system/user");
res1.setName("用户管理");
res1.setResourcetype(0);
res1.setParent(res);
resService.saveRes(res1);
Resource res2=new Resource();
res2.setCreatedate(new Date());
res2.setDescription("系统管理/用户管理/添加");
res2.setUrl("system/user/add");
res2.setName("添加");
res2.setResourcetype(1);
res2.setParent(res1);
resService.saveRes(res2);
Resource res3=new Resource();
res3.setCreatedate(new Date());
res3.setDescription("系统管理/用户管理/修改");
res3.setUrl("system/user/edit");
res3.setName("修改");
res3.setResourcetype(1);
res3.setParent(res1);
resService.saveRes(res3);
Resource res4=new Resource();
res4.setCreatedate(new Date());
res4.setDescription("系统管理/用户管理/删除");
res4.setUrl("system/user/del");
res4.setName("删除");
res4.setResourcetype(1);
res4.setParent(res1);
resService.saveRes(res4);
return res;
}
@ResponseBody
@RequestMapping("/orgsave")
public Organization orgSave() {
Organization org = new Organization();
org.setAddress("行政楼");
org.setCode("111000");
org.setCreatedate(new Date());
org.setDescription("desc");
org.setName("办公室");
orgService.saveOrg(org);
Organization org1 = new Organization();
org1.setAddress("行政楼111");
org1.setCode("111000");
org1.setCreatedate(new Date());
org1.setDescription("desc");
org1.setName("办公室1");
org1.setParent(org);
orgService.saveOrg(org1);
Organization org2 = new Organization();
org2.setAddress("行政楼222");
org2.setCode("111000");
org2.setCreatedate(new Date());
org2.setDescription("desc");
org2.setName("办公室1");
org2.setParent(org1);
orgService.saveOrg(org2);
return org;
}
@ResponseBody
@RequestMapping("/rolesave")
public Role roleSave() {
Role role = new Role();
role.setDescription("desc");
role.setName("超级用户");
role.setSeq(1);
role.setStatus(1);
ArrayList<Resource> ress = new ArrayList<Resource>();
ress.add(resService.findResById(1l));
role.setRess(ress);
roleService.saveRole(role);
return role;
}
@ResponseBody
@RequestMapping("/usersave")
public User userSave() {
User user = new User();
user.setAge(20);
user.setCreatedate(new Date());
user.setLoginname("root");
user.setLoginpass("root");
user.setPhone("139000000000");
user.setSex(1);
user.setStatus(1);
user.setUsername("张三");
ArrayList<Organization> orgs = new ArrayList<Organization>();
orgs.add(orgService.findOrgById(1L));
ArrayList<Role> roles = new ArrayList<Role>();
roles.add(roleService.findRoleById(1L));
user.setOrgs(orgs);
user.setRoles(roles);
userService.saveUser(user);
return user;
}
@ResponseBody
@RequestMapping("/deluserbyid/{id}")
public void delUser(@PathVariable long id) {
userService.delUserById(id);
}
@ResponseBody
@RequestMapping("/delrolebyid/{id}")
public void delRole(@PathVariable long id) {
roleService.delRoleById(id);
}
@ResponseBody
@RequestMapping("/delorgbyid/{id}")
public void delOrg(@PathVariable long id) {
orgService.delOrgById(id);
}
@ResponseBody
@RequestMapping("/delresbyid/{id}")
public void delRes(@PathVariable long id) {
resService.delResById(id);
}
@ResponseBody
@RequestMapping("/editresbyid/{id}")
public Resource editRes(@PathVariable long id) {
Resource res=resService.findResById(id);
res.setName("教学资料");
res.setId(100l);
resService.saveRes(res);
return res;
}
@ResponseBody
@RequestMapping("/getorgbyid/{id}")
public Organization getOrg(@PathVariable long id) {
Organization org=orgService.findOrgById(id);
return org;
}
@ResponseBody
@RequestMapping("/getrolebyid/{id}")
public Role getRole(@PathVariable long id) {
Role role=roleService.findRoleById(id);
return role;
}
@ResponseBody
@RequestMapping("/getresbyid/{id}")
public Resource getRes(@PathVariable long id) {
Resource res=resService.findResById(id);
return res;
}
}
| UTF-8 | Java | 5,364 | java | DbController.java | Java | [
{
"context": "\t\tuser.setLoginname(\"root\");\n\t\tuser.setLoginpass(\"root\");\n\t\tuser.setPhone(\"139000000000\");\n\t\tuser.setSex",
"end": 3547,
"score": 0.9985714554786682,
"start": 3543,
"tag": "PASSWORD",
"value": "root"
},
{
"context": "tSex(1);\n\t\tuser.setStatus(1);\n\t\tuser.setUsername(\"张三\");\n\t\tArrayList<Organization> orgs = new ArrayList",
"end": 3645,
"score": 0.9996762871742249,
"start": 3643,
"tag": "USERNAME",
"value": "张三"
}
] | null | [] | package cn.youguang.controller;
import cn.youguang.entity.Organization;
import cn.youguang.entity.Resource;
import cn.youguang.entity.Role;
import cn.youguang.entity.User;
import cn.youguang.service.OrganizationService;
import cn.youguang.service.ResourceService;
import cn.youguang.service.RoleService;
import cn.youguang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.Date;
@Controller
@RequestMapping("db")
public class DbController {
@Autowired
private ResourceService resService;
@Autowired
private OrganizationService orgService;
@Autowired
private RoleService roleService;
@Autowired
private UserService userService;
@ResponseBody
@RequestMapping("/ressave")
public Resource resSave() {
Resource res = new Resource();
res.setCreatedate(new Date());
res.setDescription("系统管理");
res.setUrl("system");
res.setName("res-name-1");
res.setResourcetype(0);
resService.saveRes(res);
Resource res1=new Resource();
res1.setCreatedate(new Date());
res1.setDescription("系统管理/用户管理");
res1.setUrl("system/user");
res1.setName("用户管理");
res1.setResourcetype(0);
res1.setParent(res);
resService.saveRes(res1);
Resource res2=new Resource();
res2.setCreatedate(new Date());
res2.setDescription("系统管理/用户管理/添加");
res2.setUrl("system/user/add");
res2.setName("添加");
res2.setResourcetype(1);
res2.setParent(res1);
resService.saveRes(res2);
Resource res3=new Resource();
res3.setCreatedate(new Date());
res3.setDescription("系统管理/用户管理/修改");
res3.setUrl("system/user/edit");
res3.setName("修改");
res3.setResourcetype(1);
res3.setParent(res1);
resService.saveRes(res3);
Resource res4=new Resource();
res4.setCreatedate(new Date());
res4.setDescription("系统管理/用户管理/删除");
res4.setUrl("system/user/del");
res4.setName("删除");
res4.setResourcetype(1);
res4.setParent(res1);
resService.saveRes(res4);
return res;
}
@ResponseBody
@RequestMapping("/orgsave")
public Organization orgSave() {
Organization org = new Organization();
org.setAddress("行政楼");
org.setCode("111000");
org.setCreatedate(new Date());
org.setDescription("desc");
org.setName("办公室");
orgService.saveOrg(org);
Organization org1 = new Organization();
org1.setAddress("行政楼111");
org1.setCode("111000");
org1.setCreatedate(new Date());
org1.setDescription("desc");
org1.setName("办公室1");
org1.setParent(org);
orgService.saveOrg(org1);
Organization org2 = new Organization();
org2.setAddress("行政楼222");
org2.setCode("111000");
org2.setCreatedate(new Date());
org2.setDescription("desc");
org2.setName("办公室1");
org2.setParent(org1);
orgService.saveOrg(org2);
return org;
}
@ResponseBody
@RequestMapping("/rolesave")
public Role roleSave() {
Role role = new Role();
role.setDescription("desc");
role.setName("超级用户");
role.setSeq(1);
role.setStatus(1);
ArrayList<Resource> ress = new ArrayList<Resource>();
ress.add(resService.findResById(1l));
role.setRess(ress);
roleService.saveRole(role);
return role;
}
@ResponseBody
@RequestMapping("/usersave")
public User userSave() {
User user = new User();
user.setAge(20);
user.setCreatedate(new Date());
user.setLoginname("root");
user.setLoginpass("<PASSWORD>");
user.setPhone("139000000000");
user.setSex(1);
user.setStatus(1);
user.setUsername("张三");
ArrayList<Organization> orgs = new ArrayList<Organization>();
orgs.add(orgService.findOrgById(1L));
ArrayList<Role> roles = new ArrayList<Role>();
roles.add(roleService.findRoleById(1L));
user.setOrgs(orgs);
user.setRoles(roles);
userService.saveUser(user);
return user;
}
@ResponseBody
@RequestMapping("/deluserbyid/{id}")
public void delUser(@PathVariable long id) {
userService.delUserById(id);
}
@ResponseBody
@RequestMapping("/delrolebyid/{id}")
public void delRole(@PathVariable long id) {
roleService.delRoleById(id);
}
@ResponseBody
@RequestMapping("/delorgbyid/{id}")
public void delOrg(@PathVariable long id) {
orgService.delOrgById(id);
}
@ResponseBody
@RequestMapping("/delresbyid/{id}")
public void delRes(@PathVariable long id) {
resService.delResById(id);
}
@ResponseBody
@RequestMapping("/editresbyid/{id}")
public Resource editRes(@PathVariable long id) {
Resource res=resService.findResById(id);
res.setName("教学资料");
res.setId(100l);
resService.saveRes(res);
return res;
}
@ResponseBody
@RequestMapping("/getorgbyid/{id}")
public Organization getOrg(@PathVariable long id) {
Organization org=orgService.findOrgById(id);
return org;
}
@ResponseBody
@RequestMapping("/getrolebyid/{id}")
public Role getRole(@PathVariable long id) {
Role role=roleService.findRoleById(id);
return role;
}
@ResponseBody
@RequestMapping("/getresbyid/{id}")
public Resource getRes(@PathVariable long id) {
Resource res=resService.findResById(id);
return res;
}
}
| 5,370 | 0.729823 | 0.70907 | 208 | 24.01923 | 14.985878 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.942308 | false | false | 15 |
958a84481fc3d66bd0a2db233df9d606f2f2984f | 9,826,885,218,501 | d160f852ed4828c4c96f785dbd800f90af797066 | /Serious Client/src/client/ContactPanel.java | 7554d12f429a59284c3994c2aa12cddefbf4eb1c | [] | no_license | nitro404/Serious_Messenger | https://github.com/nitro404/Serious_Messenger | 728b5469c04d2baf12cbbad79d7427cef9ddc91a | 9e74fa8dd62bb4e6faebd94df520f00ea9488cb8 | refs/heads/master | 2020-03-19T00:57:14.049000 | 2018-06-20T22:34:10 | 2018-06-20T22:34:10 | 135,512,167 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package client;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import shared.*;
public class ContactPanel extends JPanel {
private UserNetworkData m_contact;
private JTextField personalMessageTextField;
private JTextField nickNameTextField;
private JLabel displayPicIconLabel;
private JTextField statusTextField;
private boolean m_editable = false;
private static final long serialVersionUID = 1L;
public ContactPanel(UserNetworkData contact) {
m_contact = contact;
initComponents();
initLayout();
setEditable(m_editable);
update();
}
public void setEditable(boolean editable) {
nickNameTextField.setFocusable(m_editable);
personalMessageTextField.setFocusable(m_editable);
statusTextField.setFocusable(m_editable);
}
private void initComponents() {
displayPicIconLabel = new JLabel();
nickNameTextField = new JTextField();
personalMessageTextField = new JTextField();
personalMessageTextField.setFont(new Font("Tahoma", 2, 11));
displayPicIconLabel.setIcon(new ImageIcon("img/serious_logo.png"));
statusTextField = new JTextField();
}
private void initLayout() {
GroupLayout contactPanelLayout = new GroupLayout(this);
setLayout(contactPanelLayout);
contactPanelLayout.setHorizontalGroup(
contactPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(contactPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(displayPicIconLabel)
.addGap(18, 18, 18)
.addGroup(contactPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(contactPanelLayout.createSequentialGroup()
.addComponent(nickNameTextField, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(statusTextField, GroupLayout.DEFAULT_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addComponent(personalMessageTextField, GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE))
.addContainerGap())
);
contactPanelLayout.setVerticalGroup(
contactPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(contactPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(contactPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(displayPicIconLabel)
.addGroup(contactPanelLayout.createSequentialGroup()
.addGroup(contactPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(nickNameTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(statusTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(personalMessageTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
}
public static ImageIcon getDisplayPicture(String userName) {
if(userName == null) { return new ImageIcon(Globals.DEFAULT_DISPLAY_PICTURE); }
String filePath = "img/" + userName + ".png";
File file = new File(filePath);
if(!file.exists() || !file.isFile()) { return new ImageIcon(Globals.DEFAULT_DISPLAY_PICTURE); }
return new ImageIcon(filePath);
}
public void update() {
if(m_contact == null) { return; }
nickNameTextField.setText(m_contact.getNickName());
personalMessageTextField.setText(m_contact.getPersonalMessage());
statusTextField.setText(StatusType.getStatus(m_contact.getStatus()));
displayPicIconLabel.setIcon(getDisplayPicture(m_contact.getUserName()));
}
}
| UTF-8 | Java | 4,059 | java | ContactPanel.java | Java | [] | null | [] | package client;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import shared.*;
public class ContactPanel extends JPanel {
private UserNetworkData m_contact;
private JTextField personalMessageTextField;
private JTextField nickNameTextField;
private JLabel displayPicIconLabel;
private JTextField statusTextField;
private boolean m_editable = false;
private static final long serialVersionUID = 1L;
public ContactPanel(UserNetworkData contact) {
m_contact = contact;
initComponents();
initLayout();
setEditable(m_editable);
update();
}
public void setEditable(boolean editable) {
nickNameTextField.setFocusable(m_editable);
personalMessageTextField.setFocusable(m_editable);
statusTextField.setFocusable(m_editable);
}
private void initComponents() {
displayPicIconLabel = new JLabel();
nickNameTextField = new JTextField();
personalMessageTextField = new JTextField();
personalMessageTextField.setFont(new Font("Tahoma", 2, 11));
displayPicIconLabel.setIcon(new ImageIcon("img/serious_logo.png"));
statusTextField = new JTextField();
}
private void initLayout() {
GroupLayout contactPanelLayout = new GroupLayout(this);
setLayout(contactPanelLayout);
contactPanelLayout.setHorizontalGroup(
contactPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(contactPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(displayPicIconLabel)
.addGap(18, 18, 18)
.addGroup(contactPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(contactPanelLayout.createSequentialGroup()
.addComponent(nickNameTextField, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(statusTextField, GroupLayout.DEFAULT_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addComponent(personalMessageTextField, GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE))
.addContainerGap())
);
contactPanelLayout.setVerticalGroup(
contactPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(contactPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(contactPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(displayPicIconLabel)
.addGroup(contactPanelLayout.createSequentialGroup()
.addGroup(contactPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(nickNameTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(statusTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(personalMessageTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
}
public static ImageIcon getDisplayPicture(String userName) {
if(userName == null) { return new ImageIcon(Globals.DEFAULT_DISPLAY_PICTURE); }
String filePath = "img/" + userName + ".png";
File file = new File(filePath);
if(!file.exists() || !file.isFile()) { return new ImageIcon(Globals.DEFAULT_DISPLAY_PICTURE); }
return new ImageIcon(filePath);
}
public void update() {
if(m_contact == null) { return; }
nickNameTextField.setText(m_contact.getNickName());
personalMessageTextField.setText(m_contact.getPersonalMessage());
statusTextField.setText(StatusType.getStatus(m_contact.getStatus()));
displayPicIconLabel.setIcon(getDisplayPicture(m_contact.getUserName()));
}
}
| 4,059 | 0.687608 | 0.681695 | 99 | 39 | 34.754841 | 144 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.717172 | false | false | 15 |
76000cb7d890f5a57ff013140cc9d37cfef5d4df | 18,004,502,926,274 | 5413fb59ccbf0455bd038ac1fe22c12cefb8673a | /src/main/java/com/lc/cartest/ex/OutOfParkException.java | 0205ff89502bb36d37681a2eabd1e83bd972bdc1 | [] | no_license | BuildMyselfL/driverless-car | https://github.com/BuildMyselfL/driverless-car | b242a7ec1ca808dda97fc30f3177a279dd7afde8 | 17a9d8d3f2d5fb061127b25a50bd9a5e5e5a1e72 | refs/heads/master | 2023-04-17T21:56:57.581000 | 2020-07-02T04:38:22 | 2020-07-02T04:38:22 | 276,549,198 | 0 | 0 | null | false | 2021-04-26T20:26:31 | 2020-07-02T04:34:56 | 2020-07-02T04:38:26 | 2021-04-26T20:26:31 | 7 | 0 | 0 | 1 | Java | false | false | package com.lc.cartest.ex;
public class OutOfParkException extends Exception {
public OutOfParkException(String message) {
super(message);
}
}
| UTF-8 | Java | 161 | java | OutOfParkException.java | Java | [] | null | [] | package com.lc.cartest.ex;
public class OutOfParkException extends Exception {
public OutOfParkException(String message) {
super(message);
}
}
| 161 | 0.714286 | 0.714286 | 8 | 19.125 | 19.732191 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 15 |
b715e918f3267ee997545957ecc2e72d96666e8d | 17,059,610,141,164 | 2fe9246670e87384298aa8ec23ecfe10396c9ad9 | /AppDevLab/NITTApp/app/src/main/java/com/android/nittapp/MainActivity.java | 7243a0a19b759c94a1daab43f81b1258ada4ec58 | [] | no_license | HarshitCodex/AppDev_Lab | https://github.com/HarshitCodex/AppDev_Lab | 2ae7b6d1baf45b3f54754e617692dbde41a83c94 | f88e2f26f248a50e25c0e889573bcb1a96137216 | refs/heads/master | 2023-05-07T06:16:22.724000 | 2021-05-28T17:10:21 | 2021-05-28T17:10:21 | 371,765,439 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.android.nittapp;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Button submitBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(MainActivity.this, "Welcome to NITT", Toast.LENGTH_LONG).show();
submitBtn=(Button) findViewById(R.id.btnSubmit);
submitBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openActivityOption();
}
});
}
private void openActivityOption() {
Intent i = new Intent(this, OptionActivity.class);
startActivity(i);
}
} | UTF-8 | Java | 941 | java | MainActivity.java | Java | [] | null | [] | package com.android.nittapp;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Button submitBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(MainActivity.this, "Welcome to NITT", Toast.LENGTH_LONG).show();
submitBtn=(Button) findViewById(R.id.btnSubmit);
submitBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openActivityOption();
}
});
}
private void openActivityOption() {
Intent i = new Intent(this, OptionActivity.class);
startActivity(i);
}
} | 941 | 0.682253 | 0.682253 | 32 | 28.4375 | 22.269567 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.59375 | false | false | 15 |
4ab021572787127683bd9d9fe4ddaf4556c4a6e5 | 14,611,478,762,752 | 1d03ff3823f1a9a902f7bd5d633c46474acbc7ed | /InterviewPrepCode/src/Arrays/SecondLargestElement_Array.java | f7a6c02d22122c5e2393101dc8fa600d22c822d4 | [] | no_license | suryasomasundar/JAVA-Programs | https://github.com/suryasomasundar/JAVA-Programs | 39e7140d9f6f8f7129e325eaa53f06d9f0d4f663 | 5b9977731f6c0d11d7831b26e8c83921ea9e1271 | refs/heads/Master | 2021-01-10T03:05:58.142000 | 2018-03-03T21:38:25 | 2018-03-03T21:38:25 | 52,829,939 | 0 | 2 | null | false | 2018-03-03T21:38:26 | 2016-02-29T22:34:47 | 2016-02-29T22:46:45 | 2018-03-03T21:38:25 | 126 | 0 | 2 | 0 | Java | false | null | package Arrays;
public class SecondLargestElement_Array {
public int secondlargest(int[] A) {
int first = A[0];
int second = -1;
for (int i = 1; i < A.length; i++) {
if (first < A[i]) {
second = first;
first = A[i];
} else if (second < A[i]) {
second = A[i];
}
}
return second;
}
public static void main(String[] args) {
int[] array = { 1, 7, 8, 5, 6, 7, 4 };
SecondLargestElement_Array obj = new SecondLargestElement_Array();
System.out.println(obj.secondlargest(array));
}
}
| UTF-8 | Java | 522 | java | SecondLargestElement_Array.java | Java | [] | null | [] | package Arrays;
public class SecondLargestElement_Array {
public int secondlargest(int[] A) {
int first = A[0];
int second = -1;
for (int i = 1; i < A.length; i++) {
if (first < A[i]) {
second = first;
first = A[i];
} else if (second < A[i]) {
second = A[i];
}
}
return second;
}
public static void main(String[] args) {
int[] array = { 1, 7, 8, 5, 6, 7, 4 };
SecondLargestElement_Array obj = new SecondLargestElement_Array();
System.out.println(obj.secondlargest(array));
}
}
| 522 | 0.595785 | 0.576628 | 25 | 19.879999 | 18.124723 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.36 | false | false | 15 |
e5bee216ab7e79d168d97759bf2038189c5d443e | 19,378,892,456,706 | 63b8d70aff3a228bf791552bed12b74598cf5e20 | /factory/factory-service-voip-conferences/src/main/java/org/qualipso/factory/voipservice/entity/SipConf.java | 693c46e939a7c418f94ddc4b779d17d46f2506e5 | [] | no_license | gritchou/Ulysse | https://github.com/gritchou/Ulysse | 8dd9442ce951a9d830784fb0e27e268ed1896e0b | 65da3e524d468bd56661602ad1d1fcc7471b3999 | refs/heads/master | 2016-09-06T02:03:28.757000 | 2010-01-06T10:03:16 | 2010-01-06T10:03:16 | 394,387 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.qualipso.factory.voipservice.entity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
* @author <a href="mailto:janny@man.poznan.pl">Dariusz Janny</a>
* @author <a href="mailto:debe@man.poznan.pl">Marcin Wrzos</a>
* @company Poznan Supercomputing and Networking Center
* @license LGPL
* @project QualiPSo
* @date 24/07/2009
*/
@Entity
@Table(name = "sip_conf")
public class SipConf implements Serializable {
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = -2234139177249045142L;
@Id
@Column(length = 80)
private String name="";
@Column(length = 512)
private String userid ="";
@Column(nullable = false,length = 100)
private String fullcontact="";
@Column(length = 20)
private String accountcode;
@Column(length = 7)
private String amaflags;
@Column(length = 10)
private String callgroup;
@Column(length = 80)
private String callerid;
@Column(length = 3)
private String canreinvite ="no";
@Column(length = 80)
private String context;
@Column(length = 15)
private String defaultip;
@Column(length = 7)
private String dtmfmode;
@Column(length = 80)
private String fromuser;
@Column(length = 80)
private String fromdomain;
@Column(nullable = false, length = 31)
private String host="";
@Column(length = 4)
private String insecure;
@Column(length = 2)
private String language;
@Column(length = 50)
private String mailbox;
@Column(length = 80)
private String md5secret;
@Column(nullable = false, length = 5)
private String nat="yes";
@Column(length = 95)
private String permit;
@Column(length = 95)
private String deny;
@Column(length = 95)
private String mask;
@Column(length = 10)
private String pickupgroup;
@Column(nullable = false, length = 5)
private String port="";
@Column(length = 3)
private String qualify;
@Column(length = 1)
private String restrictcid;
@Column(length = 3)
private String rtptimeout;
@Column(length = 3)
private String rtpholdtimeout;
@Column(length = 80)
private String secret;
@Column(nullable = false)
private String type="friend";
@Column(nullable = false, length = 80, unique = true)
private String username="";
@Column(length = 100)
private String disallow="";
@Column(length = 100)
private String allow="g729;ilbc;gsm;ulaw;alaw;h261;h263;h263p";
@Column(length = 100)
private String musiconhold;
@Column(nullable = false, length = 200)
private String regseconds= "0";
@Column(nullable = false, length = 15)
private String ipaddr="";
@Column(nullable = false, length = 80)
private String regexten="";
@Column(length = 3)
private String cancallforward="yes";
@Column(length = 255, nullable=false)
private String email = "";
@Column(length = 80, nullable=false)
private String defaultuser = "";
@Column(length = 255, nullable=false)
private String lastms = "0";
@Column(length = 100, nullable=true)
private String regserver = "";
@Column(length = 100, nullable=true)
private String useragent = "";
@OneToMany(cascade=CascadeType.ALL, mappedBy="sipConf")
private Set<ConferenceUser> conferences=new HashSet<ConferenceUser>();
@SuppressWarnings("unused")
@OneToMany(cascade=CascadeType.ALL, mappedBy="sipConf")
private Set<ConferenceUser> pastConferences = new HashSet<ConferenceUser>();
public SipConf() {}
public String getAccountcode() {
return accountcode;
}
public void setAccountcode(String accountcode) {
this.accountcode = accountcode;
}
public String getAllow() {
return allow;
}
public void setAllow(String allow) {
this.allow = allow;
}
public String getAmaflags() {
return amaflags;
}
public void setAmaflags(String amaflags) {
this.amaflags = amaflags;
}
public String getCallerid() {
return callerid;
}
public void setCallerid(String callerid) {
this.callerid = callerid;
}
public String getCallgroup() {
return callgroup;
}
public void setCallgroup(String callgroup) {
this.callgroup = callgroup;
}
public String getCancallforward() {
return cancallforward;
}
public void setCancallforward(String cancallforward) {
this.cancallforward = cancallforward;
}
public String getCanreinvite() {
return canreinvite;
}
public void setCanreinvite(String canreinvite) {
this.canreinvite = canreinvite;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public String getDefaultip() {
return defaultip;
}
public void setDefaultip(String defaultip) {
this.defaultip = defaultip;
}
public String getDeny() {
return deny;
}
public void setDeny(String deny) {
this.deny = deny;
}
public String getDisallow() {
return disallow;
}
public void setDisallow(String disallow) {
this.disallow = disallow;
}
public String getDtmfmode() {
return dtmfmode;
}
public void setDtmfmode(String dtmfmode) {
this.dtmfmode = dtmfmode;
}
public String getFromdomain() {
return fromdomain;
}
public void setFromdomain(String fromdomain) {
this.fromdomain = fromdomain;
}
public String getFromuser() {
return fromuser;
}
public void setFromuser(String fromuser) {
this.fromuser = fromuser;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
/*
public Long getId() {
return id;
}
private void setId(Long id) {
this.id = id;
}
*/
public List<Integer> getConferences() {
List<Integer> conferenceList=new ArrayList<Integer>();
Iterator<ConferenceUser> iterator=conferences.iterator();
while (iterator.hasNext()) {
conferenceList.add(((ConferenceUser)iterator.next()).getMeetMe().getConfno());
}
return conferenceList;
}
public String getInsecure() {
return insecure;
}
public void setInsecure(String insecure) {
this.insecure = insecure;
}
public String getIpaddr() {
return ipaddr;
}
public void setIpaddr(String ipaddr) {
this.ipaddr = ipaddr;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getMailbox() {
return mailbox;
}
public void setMailbox(String mailbox) {
this.mailbox = mailbox;
}
public String getMask() {
return mask;
}
public void setMask(String mask) {
this.mask = mask;
}
public String getMd5secret() {
return md5secret;
}
public void setMd5secret(String md5secret) {
this.md5secret = md5secret;
}
public String getMusiconhold() {
return musiconhold;
}
public void setMusiconhold(String musiconhold) {
this.musiconhold = musiconhold;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getQualispoUser() {
return userid;
}
public void setQualipsoUser(String userid) {
this.userid = userid;
}
public String getNat() {
return nat;
}
public void setNat(String nat) {
this.nat = nat;
}
public String getPermit() {
return permit;
}
public void setPermit(String permit) {
this.permit = permit;
}
public String getPickupgroup() {
return pickupgroup;
}
public void setPickupgroup(String pickupgroup) {
this.pickupgroup = pickupgroup;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public String getQualify() {
return qualify;
}
public void setQualify(String qualify) {
this.qualify = qualify;
}
public String getRegexten() {
return regexten;
}
public void setRegexten(String regexten) {
this.regexten = regexten;
}
public String getRegseconds() {
return regseconds;
}
public void setRegseconds(String regseconds) {
this.regseconds = regseconds;
}
public String getRestrictcid() {
return restrictcid;
}
public void setRestrictcid(String restrictcid) {
this.restrictcid = restrictcid;
}
public String getRtpholdtimeout() {
return rtpholdtimeout;
}
public void setRtpholdtimeout(String rtpholdtimeout) {
this.rtpholdtimeout = rtpholdtimeout;
}
public String getRtptimeout() {
return rtptimeout;
}
public void setRtptimeout(String rtptimeout) {
this.rtptimeout = rtptimeout;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFullcontact() {
return fullcontact;
}
public void setFullcontact(String fullcontact) {
this.fullcontact = fullcontact;
}
public void setEmail(String email) {
this.email = email;
}
public String getEmail() {
return email;
}
public void setDefaultuser(String defaultuser) {
this.defaultuser = defaultuser;
}
public String getDefaultuser() {
return defaultuser;
}
public void setLastms(String lastms) {
this.lastms = lastms;
}
public String getLastms() {
return lastms;
}
public void setRegserver(String regserver) {
this.regserver = regserver;
}
public String getRegserver() {
return regserver;
}
public void setUseragent(String useragent) {
this.useragent = useragent;
}
public String getUseragent() {
return useragent;
}
} | UTF-8 | Java | 10,211 | java | SipConf.java | Java | [
{
"context": "istence.Table;\r\n\r\n/**\r\n * @author <a href=\"mailto:janny@man.poznan.pl\">Dariusz Janny</a>\r\n * @author <a href=\"mailto:de",
"end": 475,
"score": 0.999932587146759,
"start": 456,
"tag": "EMAIL",
"value": "janny@man.poznan.pl"
},
{
"context": "\r\n * @author <a href=\"mailto:janny@man.poznan.pl\">Dariusz Janny</a>\r\n * @author <a href=\"mailto:debe@man.poznan.p",
"end": 490,
"score": 0.9998564720153809,
"start": 477,
"tag": "NAME",
"value": "Dariusz Janny"
},
{
"context": "pl\">Dariusz Janny</a>\r\n * @author <a href=\"mailto:debe@man.poznan.pl\">Marcin Wrzos</a>\r\n * @company Poznan Supercomput",
"end": 541,
"score": 0.9999336004257202,
"start": 523,
"tag": "EMAIL",
"value": "debe@man.poznan.pl"
},
{
"context": ">\r\n * @author <a href=\"mailto:debe@man.poznan.pl\">Marcin Wrzos</a>\r\n * @company Poznan Supercomputing and Networ",
"end": 555,
"score": 0.9998405575752258,
"start": 543,
"tag": "NAME",
"value": "Marcin Wrzos"
}
] | null | [] | package org.qualipso.factory.voipservice.entity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
* @author <a href="mailto:<EMAIL>"><NAME></a>
* @author <a href="mailto:<EMAIL>"><NAME></a>
* @company Poznan Supercomputing and Networking Center
* @license LGPL
* @project QualiPSo
* @date 24/07/2009
*/
@Entity
@Table(name = "sip_conf")
public class SipConf implements Serializable {
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = -2234139177249045142L;
@Id
@Column(length = 80)
private String name="";
@Column(length = 512)
private String userid ="";
@Column(nullable = false,length = 100)
private String fullcontact="";
@Column(length = 20)
private String accountcode;
@Column(length = 7)
private String amaflags;
@Column(length = 10)
private String callgroup;
@Column(length = 80)
private String callerid;
@Column(length = 3)
private String canreinvite ="no";
@Column(length = 80)
private String context;
@Column(length = 15)
private String defaultip;
@Column(length = 7)
private String dtmfmode;
@Column(length = 80)
private String fromuser;
@Column(length = 80)
private String fromdomain;
@Column(nullable = false, length = 31)
private String host="";
@Column(length = 4)
private String insecure;
@Column(length = 2)
private String language;
@Column(length = 50)
private String mailbox;
@Column(length = 80)
private String md5secret;
@Column(nullable = false, length = 5)
private String nat="yes";
@Column(length = 95)
private String permit;
@Column(length = 95)
private String deny;
@Column(length = 95)
private String mask;
@Column(length = 10)
private String pickupgroup;
@Column(nullable = false, length = 5)
private String port="";
@Column(length = 3)
private String qualify;
@Column(length = 1)
private String restrictcid;
@Column(length = 3)
private String rtptimeout;
@Column(length = 3)
private String rtpholdtimeout;
@Column(length = 80)
private String secret;
@Column(nullable = false)
private String type="friend";
@Column(nullable = false, length = 80, unique = true)
private String username="";
@Column(length = 100)
private String disallow="";
@Column(length = 100)
private String allow="g729;ilbc;gsm;ulaw;alaw;h261;h263;h263p";
@Column(length = 100)
private String musiconhold;
@Column(nullable = false, length = 200)
private String regseconds= "0";
@Column(nullable = false, length = 15)
private String ipaddr="";
@Column(nullable = false, length = 80)
private String regexten="";
@Column(length = 3)
private String cancallforward="yes";
@Column(length = 255, nullable=false)
private String email = "";
@Column(length = 80, nullable=false)
private String defaultuser = "";
@Column(length = 255, nullable=false)
private String lastms = "0";
@Column(length = 100, nullable=true)
private String regserver = "";
@Column(length = 100, nullable=true)
private String useragent = "";
@OneToMany(cascade=CascadeType.ALL, mappedBy="sipConf")
private Set<ConferenceUser> conferences=new HashSet<ConferenceUser>();
@SuppressWarnings("unused")
@OneToMany(cascade=CascadeType.ALL, mappedBy="sipConf")
private Set<ConferenceUser> pastConferences = new HashSet<ConferenceUser>();
public SipConf() {}
public String getAccountcode() {
return accountcode;
}
public void setAccountcode(String accountcode) {
this.accountcode = accountcode;
}
public String getAllow() {
return allow;
}
public void setAllow(String allow) {
this.allow = allow;
}
public String getAmaflags() {
return amaflags;
}
public void setAmaflags(String amaflags) {
this.amaflags = amaflags;
}
public String getCallerid() {
return callerid;
}
public void setCallerid(String callerid) {
this.callerid = callerid;
}
public String getCallgroup() {
return callgroup;
}
public void setCallgroup(String callgroup) {
this.callgroup = callgroup;
}
public String getCancallforward() {
return cancallforward;
}
public void setCancallforward(String cancallforward) {
this.cancallforward = cancallforward;
}
public String getCanreinvite() {
return canreinvite;
}
public void setCanreinvite(String canreinvite) {
this.canreinvite = canreinvite;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public String getDefaultip() {
return defaultip;
}
public void setDefaultip(String defaultip) {
this.defaultip = defaultip;
}
public String getDeny() {
return deny;
}
public void setDeny(String deny) {
this.deny = deny;
}
public String getDisallow() {
return disallow;
}
public void setDisallow(String disallow) {
this.disallow = disallow;
}
public String getDtmfmode() {
return dtmfmode;
}
public void setDtmfmode(String dtmfmode) {
this.dtmfmode = dtmfmode;
}
public String getFromdomain() {
return fromdomain;
}
public void setFromdomain(String fromdomain) {
this.fromdomain = fromdomain;
}
public String getFromuser() {
return fromuser;
}
public void setFromuser(String fromuser) {
this.fromuser = fromuser;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
/*
public Long getId() {
return id;
}
private void setId(Long id) {
this.id = id;
}
*/
public List<Integer> getConferences() {
List<Integer> conferenceList=new ArrayList<Integer>();
Iterator<ConferenceUser> iterator=conferences.iterator();
while (iterator.hasNext()) {
conferenceList.add(((ConferenceUser)iterator.next()).getMeetMe().getConfno());
}
return conferenceList;
}
public String getInsecure() {
return insecure;
}
public void setInsecure(String insecure) {
this.insecure = insecure;
}
public String getIpaddr() {
return ipaddr;
}
public void setIpaddr(String ipaddr) {
this.ipaddr = ipaddr;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getMailbox() {
return mailbox;
}
public void setMailbox(String mailbox) {
this.mailbox = mailbox;
}
public String getMask() {
return mask;
}
public void setMask(String mask) {
this.mask = mask;
}
public String getMd5secret() {
return md5secret;
}
public void setMd5secret(String md5secret) {
this.md5secret = md5secret;
}
public String getMusiconhold() {
return musiconhold;
}
public void setMusiconhold(String musiconhold) {
this.musiconhold = musiconhold;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getQualispoUser() {
return userid;
}
public void setQualipsoUser(String userid) {
this.userid = userid;
}
public String getNat() {
return nat;
}
public void setNat(String nat) {
this.nat = nat;
}
public String getPermit() {
return permit;
}
public void setPermit(String permit) {
this.permit = permit;
}
public String getPickupgroup() {
return pickupgroup;
}
public void setPickupgroup(String pickupgroup) {
this.pickupgroup = pickupgroup;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public String getQualify() {
return qualify;
}
public void setQualify(String qualify) {
this.qualify = qualify;
}
public String getRegexten() {
return regexten;
}
public void setRegexten(String regexten) {
this.regexten = regexten;
}
public String getRegseconds() {
return regseconds;
}
public void setRegseconds(String regseconds) {
this.regseconds = regseconds;
}
public String getRestrictcid() {
return restrictcid;
}
public void setRestrictcid(String restrictcid) {
this.restrictcid = restrictcid;
}
public String getRtpholdtimeout() {
return rtpholdtimeout;
}
public void setRtpholdtimeout(String rtpholdtimeout) {
this.rtpholdtimeout = rtpholdtimeout;
}
public String getRtptimeout() {
return rtptimeout;
}
public void setRtptimeout(String rtptimeout) {
this.rtptimeout = rtptimeout;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFullcontact() {
return fullcontact;
}
public void setFullcontact(String fullcontact) {
this.fullcontact = fullcontact;
}
public void setEmail(String email) {
this.email = email;
}
public String getEmail() {
return email;
}
public void setDefaultuser(String defaultuser) {
this.defaultuser = defaultuser;
}
public String getDefaultuser() {
return defaultuser;
}
public void setLastms(String lastms) {
this.lastms = lastms;
}
public String getLastms() {
return lastms;
}
public void setRegserver(String regserver) {
this.regserver = regserver;
}
public String getRegserver() {
return regserver;
}
public void setUseragent(String useragent) {
this.useragent = useragent;
}
public String getUseragent() {
return useragent;
}
} | 10,175 | 0.672412 | 0.659681 | 538 | 16.983271 | 16.809719 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.184015 | false | false | 15 |
acdf51ce62000dbe83879bb202d2cbd35cfbc7bb | 29,214,367,595,056 | 05be927ffbd73e2703b1e00c8200596bbbe7384f | /src/main/java/com/github/chainmailstudios/astromine/client/registry/SkyboxRegistry.java | 24df61c8a0a6a7d94cebac35e256233874892e99 | [
"MIT"
] | permissive | AlexIIL/Astromine | https://github.com/AlexIIL/Astromine | 0f2d2d7a3eb28c28cb97a2be9507e83a652b82fa | 71bbc5f896c1a5f3b622c6d3c98d885548498de2 | refs/heads/master | 2022-11-04T21:47:52.187000 | 2020-06-28T14:45:04 | 2020-06-28T14:45:04 | 275,673,278 | 0 | 0 | MIT | true | 2020-06-28T21:44:31 | 2020-06-28T21:44:31 | 2020-06-28T14:45:09 | 2020-06-28T19:30:24 | 4,547 | 0 | 0 | 0 | null | false | false | package com.github.chainmailstudios.astromine.client.registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.dimension.DimensionType;
import com.github.chainmailstudios.astromine.client.render.sky.skybox.AbstractSkybox;
import com.github.chainmailstudios.astromine.common.registry.base.BiDirectionalRegistry;
public class SkyboxRegistry extends BiDirectionalRegistry<RegistryKey<DimensionType>, AbstractSkybox> {
public static final SkyboxRegistry INSTANCE = new SkyboxRegistry();
private SkyboxRegistry() {
// Locked.
}
}
| UTF-8 | Java | 561 | java | SkyboxRegistry.java | Java | [
{
"context": "package com.github.chainmailstudios.astromine.client.registry;\n\nimport net.minecraft.",
"end": 35,
"score": 0.9886664152145386,
"start": 19,
"tag": "USERNAME",
"value": "chainmailstudios"
},
{
"context": "world.dimension.DimensionType;\n\nimport com.github.chainmailstudios.astromine.client.render.sky.skybox.AbstractSkybox",
"end": 199,
"score": 0.9913878440856934,
"start": 183,
"tag": "USERNAME",
"value": "chainmailstudios"
},
{
"context": "nder.sky.skybox.AbstractSkybox;\nimport com.github.chainmailstudios.astromine.common.registry.base.BiDirectionalRegis",
"end": 285,
"score": 0.9904271364212036,
"start": 269,
"tag": "USERNAME",
"value": "chainmailstudios"
}
] | null | [] | package com.github.chainmailstudios.astromine.client.registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.dimension.DimensionType;
import com.github.chainmailstudios.astromine.client.render.sky.skybox.AbstractSkybox;
import com.github.chainmailstudios.astromine.common.registry.base.BiDirectionalRegistry;
public class SkyboxRegistry extends BiDirectionalRegistry<RegistryKey<DimensionType>, AbstractSkybox> {
public static final SkyboxRegistry INSTANCE = new SkyboxRegistry();
private SkyboxRegistry() {
// Locked.
}
}
| 561 | 0.836007 | 0.836007 | 15 | 36.400002 | 36.386444 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.8 | false | false | 15 |
3cfa61a6ad18542bce596f5b0a759ee981968966 | 5,540,507,871,117 | b9e896d7628377b0ccc81621ff9cac747b918275 | /oneLine.java | 2833851cbe98d6eec835711a6690ef13c7b5e49e | [] | no_license | DTCC-CIS211-4H1/LoadAnArtistBag | https://github.com/DTCC-CIS211-4H1/LoadAnArtistBag | d2274f2af9dd7eefa30645eee5aa6064fb20554e | 4ad74d280f8ac3c64087a726898a86d54efffd70 | refs/heads/master | 2021-06-28T04:53:39.134000 | 2017-09-17T21:59:46 | 2017-09-17T21:59:46 | 103,864,928 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
// This example displays the use of hasNext and nextLine methods
// Also displayed is the use of reading the text file into an ArrayBag
// Running oneLine.java displays the number of items in the file and the number of times 4\tBarton is found
public class oneLine {
public static void main(String[] args) throws FileNotFoundException {
int counter=0;
ArrayBag<String> exampleArray = new ArrayBag(100);
File file = new File("foo.txt");
Scanner input = new Scanner(file).useDelimiter("\t");
while (input.hasNext()) {
//print each line as it's read
exampleArray.add(input.nextLine());
// System.out.println(input.nextLine());
counter++;
}
System.out.println(exampleArray.getFrequencyOf("4\tBaron"));
System.out.println(exampleArray.getCurrentSize());
System.out.println("Value of counter: "+ counter);
input.close();
}
}
| UTF-8 | Java | 1,111 | java | oneLine.java | Java | [] | null | [] | import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
// This example displays the use of hasNext and nextLine methods
// Also displayed is the use of reading the text file into an ArrayBag
// Running oneLine.java displays the number of items in the file and the number of times 4\tBarton is found
public class oneLine {
public static void main(String[] args) throws FileNotFoundException {
int counter=0;
ArrayBag<String> exampleArray = new ArrayBag(100);
File file = new File("foo.txt");
Scanner input = new Scanner(file).useDelimiter("\t");
while (input.hasNext()) {
//print each line as it's read
exampleArray.add(input.nextLine());
// System.out.println(input.nextLine());
counter++;
}
System.out.println(exampleArray.getFrequencyOf("4\tBaron"));
System.out.println(exampleArray.getCurrentSize());
System.out.println("Value of counter: "+ counter);
input.close();
}
}
| 1,111 | 0.620162 | 0.614761 | 27 | 40.111111 | 27.28632 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.518519 | false | false | 15 |
cb039b798ffd4f8ffb7c11ce8ed58eba0d5a0792 | 29,042,568,877,528 | e63964ef68078145e9794c101a24c7203751ed30 | /src/engine/core/EngineMain.java | 14cea77084cba0f749d6441714dfc8b6a434bc6e | [] | no_license | winNixz/JavaFX-Game-Engine | https://github.com/winNixz/JavaFX-Game-Engine | 1fcbebb8e18fbb796ac03bf43f3d02b846c10330 | 1ac03e13eb6694f9ee6aa608647006256160cc1f | refs/heads/master | 2017-10-06T10:21:54.450000 | 2017-06-21T11:00:29 | 2017-06-21T11:00:29 | 94,992,542 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package engine.core;
import engine.state.StateManager;
import game.core.GameMain;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
import javafx.stage.Stage;
public class EngineMain extends Application {
public static void main(String[] args){
launch(args);
}
@Override
public void start(Stage stage) {
stage.getIcons().add(new Image("fire.png"));
stage.setTitle("TestGame");
Canvas canvas = new Canvas(800, 600);
GraphicsContext gc = canvas.getGraphicsContext2D();
Scene scene = new Scene(new Group(canvas));
StateManager stateManager = createStateManager();
GameLoop gameLoop = new GameLoop(stateManager, gc, new InputHandler(scene));
gameLoop.start();
stage.setScene(scene);
stage.show();
}
private StateManager createStateManager(){
StateManager stateManager = new StateManager();
stateManager.addState("GameMain", new GameMain(stateManager));
return stateManager;
}
}
| UTF-8 | Java | 1,104 | java | EngineMain.java | Java | [] | null | [] | package engine.core;
import engine.state.StateManager;
import game.core.GameMain;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
import javafx.stage.Stage;
public class EngineMain extends Application {
public static void main(String[] args){
launch(args);
}
@Override
public void start(Stage stage) {
stage.getIcons().add(new Image("fire.png"));
stage.setTitle("TestGame");
Canvas canvas = new Canvas(800, 600);
GraphicsContext gc = canvas.getGraphicsContext2D();
Scene scene = new Scene(new Group(canvas));
StateManager stateManager = createStateManager();
GameLoop gameLoop = new GameLoop(stateManager, gc, new InputHandler(scene));
gameLoop.start();
stage.setScene(scene);
stage.show();
}
private StateManager createStateManager(){
StateManager stateManager = new StateManager();
stateManager.addState("GameMain", new GameMain(stateManager));
return stateManager;
}
}
| 1,104 | 0.73913 | 0.73279 | 40 | 26.6 | 20.145472 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.6 | false | false | 15 |
2b27d2b5343db0bc1a9ab71b948a7e2ff1cf325b | 27,161,373,195,439 | 0ffc1f2b936d688595319425bee62a5470984c51 | /src/main/java/co/kurapka/caching/CachingUtility.java | 1431c8b12222c83b51b31d407af6722670d55ffa | [] | no_license | achmudas/rss-reader | https://github.com/achmudas/rss-reader | de3a69c0d0ac99f5e731674e86f22f2afbc520e1 | 4d2a2ad007c9da585960aa8648120142ff6f08ad | refs/heads/master | 2021-01-23T04:02:56.200000 | 2017-08-17T04:44:35 | 2017-08-17T04:44:35 | 86,149,250 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package co.kurapka.caching;
import co.kurapka.model.User;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
/**
* Created by achmudas on 15/04/16.
*/
public class CachingUtility {
private static final Logger logger = LoggerFactory.getLogger(CachingUtility.class);
private LoadingCache<String, User> cache;
public CachingUtility() {
cache = CacheBuilder.newBuilder()
.maximumSize(5000)
.expireAfterAccess(10, TimeUnit.MINUTES)
.build(
new CacheLoader<String, User>() {
public User load(String accessToken) throws Exception {
return null;
}
});
}
public User getUserByToken(String token) {
try {
return cache.get(token);
} catch (ExecutionException e) {
logger.error("Error loading user by token", e);
return null;
}
}
public void cacheUserByToken(String token, User user) {
cache.put(token, user);
}
}
| UTF-8 | Java | 1,333 | java | CachingUtility.java | Java | [
{
"context": " java.util.concurrent.TimeUnit;\n\n/**\n * Created by achmudas on 15/04/16.\n */\npublic class CachingUtility {\n\n ",
"end": 366,
"score": 0.9996044039726257,
"start": 358,
"tag": "USERNAME",
"value": "achmudas"
}
] | null | [] | package co.kurapka.caching;
import co.kurapka.model.User;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
/**
* Created by achmudas on 15/04/16.
*/
public class CachingUtility {
private static final Logger logger = LoggerFactory.getLogger(CachingUtility.class);
private LoadingCache<String, User> cache;
public CachingUtility() {
cache = CacheBuilder.newBuilder()
.maximumSize(5000)
.expireAfterAccess(10, TimeUnit.MINUTES)
.build(
new CacheLoader<String, User>() {
public User load(String accessToken) throws Exception {
return null;
}
});
}
public User getUserByToken(String token) {
try {
return cache.get(token);
} catch (ExecutionException e) {
logger.error("Error loading user by token", e);
return null;
}
}
public void cacheUserByToken(String token, User user) {
cache.put(token, user);
}
}
| 1,333 | 0.603901 | 0.593398 | 49 | 26.204082 | 22.70573 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.469388 | false | false | 15 |
960712badc9032e643a0004b70f6d60c71fbe37d | 11,742,440,632,780 | f3f33f31769f48d7f40122678d64420aa91629f6 | /app/src/main/java/com/example/ndiaz/parquesbsas/contract/ListaReclamosUsuarioContract.java | 150b3542fcab17d38b2a1a10647c0c69f441f5fa | [] | no_license | aledoss/ParquesBsAs | https://github.com/aledoss/ParquesBsAs | 0c7c6df79f3acf9a8c1c08a6d41c585afd09fd97 | 0dd7d971a77a69c34cc36f078f318e069ff81f3b | refs/heads/master | 2021-01-17T17:58:45.532000 | 2019-02-20T00:56:26 | 2019-02-20T00:56:26 | 70,707,836 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.ndiaz.parquesbsas.contract;
import com.example.ndiaz.parquesbsas.callbacks.BaseCallback;
import com.example.ndiaz.parquesbsas.contract.basecontract.BaseInteractor;
import com.example.ndiaz.parquesbsas.contract.basecontract.BasePresenter;
import com.example.ndiaz.parquesbsas.contract.basecontract.BaseView;
import com.example.ndiaz.parquesbsas.model.ReclamoFecha;
import java.util.List;
public interface ListaReclamosUsuarioContract {
interface View extends BaseView {
void showReclamosConFechas(List<ReclamoFecha> reclamosFechas);
void showMessage(String message);
void showEmptyContainer();
void refreshReclamos(List<ReclamoFecha> reclamosFechas);
void hideSwipeRefresh();
void callGetReclamosConFechas(boolean refreshData);
}
interface Presenter extends BasePresenter {
void doGetReclamosConFechas(int idUsuario, boolean refreshData);
void doDeleteReclamo(int idReclamo);
}
interface Interactor extends BaseInteractor {
void getReclamosFecha(int idUsuario, BaseCallback<List<ReclamoFecha>> callback);
void deleteReclamo(int idReclamo, BaseCallback<String> callback);
}
}
| UTF-8 | Java | 1,212 | java | ListaReclamosUsuarioContract.java | Java | [] | null | [] | package com.example.ndiaz.parquesbsas.contract;
import com.example.ndiaz.parquesbsas.callbacks.BaseCallback;
import com.example.ndiaz.parquesbsas.contract.basecontract.BaseInteractor;
import com.example.ndiaz.parquesbsas.contract.basecontract.BasePresenter;
import com.example.ndiaz.parquesbsas.contract.basecontract.BaseView;
import com.example.ndiaz.parquesbsas.model.ReclamoFecha;
import java.util.List;
public interface ListaReclamosUsuarioContract {
interface View extends BaseView {
void showReclamosConFechas(List<ReclamoFecha> reclamosFechas);
void showMessage(String message);
void showEmptyContainer();
void refreshReclamos(List<ReclamoFecha> reclamosFechas);
void hideSwipeRefresh();
void callGetReclamosConFechas(boolean refreshData);
}
interface Presenter extends BasePresenter {
void doGetReclamosConFechas(int idUsuario, boolean refreshData);
void doDeleteReclamo(int idReclamo);
}
interface Interactor extends BaseInteractor {
void getReclamosFecha(int idUsuario, BaseCallback<List<ReclamoFecha>> callback);
void deleteReclamo(int idReclamo, BaseCallback<String> callback);
}
}
| 1,212 | 0.768152 | 0.768152 | 39 | 30.076923 | 29.687592 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.512821 | false | false | 15 |
92dbc39b1a7d2ecd7580494db5a6b141dad7cf35 | 12,618,613,937,476 | 633659fb24c8ad1de347ce97c5e5f5479593536a | /app/models/User.java | fe80d22ddc3c5e04dd3829b738cea9a3d5b7b46f | [] | no_license | ucesur/NewsLoader | https://github.com/ucesur/NewsLoader | 2eb5c1cd0437526bf5fa46468d74ba83f51954b6 | 95c9dd304fb3d277a655a020f98470c898660d0c | refs/heads/master | 2020-04-20T23:29:16.218000 | 2013-11-30T12:47:24 | 2013-11-30T12:47:24 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package models;
import javax.persistence.*;
import play.db.jpa.GenericModel;
import play.db.jpa.Model;
@Entity
public class User extends Model{
//@Id
//public long id;
public String name;
public String surname;
}
| UTF-8 | Java | 227 | java | User.java | Java | [] | null | [] | package models;
import javax.persistence.*;
import play.db.jpa.GenericModel;
import play.db.jpa.Model;
@Entity
public class User extends Model{
//@Id
//public long id;
public String name;
public String surname;
}
| 227 | 0.722467 | 0.722467 | 18 | 11.611111 | 12.033005 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.722222 | false | false | 15 |
26add88b291f30cef0edcb970d5ef2ed71fb5117 | 17,274,358,506,813 | a6182efcc348da74623d19dccd92a7331ed30ca4 | /src/main/java/com/iisi/opd/cfg/service/impl/DataApplyServiceImpl.java | cdcec489c7fbab06aae4c6ca4aa09ec342e979c2 | [] | no_license | kevins7301/opd | https://github.com/kevins7301/opd | bb983265c6112d9d76e219978c353a3e37eba086 | 54c87997d5e351d3f8413e437c5b89f646dfdf6c | refs/heads/master | 2020-04-06T09:06:20.429000 | 2018-12-21T15:50:39 | 2018-12-21T15:50:39 | 157,326,957 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.iisi.opd.cfg.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.iisi.opd.cfg.dao.DataCfgApplyDao;
import com.iisi.opd.cfg.po.DataCfgApplyPo;
import com.iisi.opd.cfg.po.DataCfgPo;
import com.iisi.opd.cfg.po.DataSetApplyPo;
import com.iisi.opd.cfg.po.DataSetPo;
import com.iisi.opd.cfg.service.DataApplyService;
import com.iisi.opd.cfg.service.DataCfgService;
import com.iisi.opd.cfg.service.DataSetService;
import com.iisi.opd.data.in.vo.DataInOptionsVo;
@Service
@Transactional
public class DataApplyServiceImpl implements DataApplyService {
@Autowired
private Boolean isVerify;
@Autowired
private DataCfgApplyDao dataCfgApplyDao;
@Autowired
private DataCfgService dataCfgService;
@Autowired
private DataSetService dataSetService;
@Override
public DataSetApplyPo enableApply(DataSetApplyPo dataSetApplyPo, List<DataCfgApplyPo> dataCfgApplyPos) {
if (this.isVerify.booleanValue()) {
dataSetApplyPo = this.dataSetService.enableApply(dataSetApplyPo);
List<DataCfgApplyPo> newdataCfgApplyPos = new ArrayList();
for (DataCfgApplyPo dataCfgApplyPo : dataCfgApplyPos) {
dataCfgApplyPo.setDataSetApplyPo(dataSetApplyPo);
dataCfgApplyPo = this.dataCfgService.enableApply(dataCfgApplyPo);
newdataCfgApplyPos.add(dataCfgApplyPo);
}
dataSetApplyPo.setDataCfgApplyPoList(newdataCfgApplyPos);
this.dataSetService.update(dataSetApplyPo);
} else {
dataSetApplyPo = this.dataSetService.enableApply(dataSetApplyPo);
DataSetPo dataSetPo = dataSetApplyPo.getDataSetPo();
List<DataCfgPo> newDataCfgPos = new ArrayList();
List<DataCfgApplyPo> newdataCfgApplyPos = new ArrayList();
for (DataCfgApplyPo dataCfgApplyPo : dataCfgApplyPos) {
dataCfgApplyPo.setDataSetPo(dataSetApplyPo.getDataSetPo());
dataCfgApplyPo = this.dataCfgService.enableApply(dataCfgApplyPo);
newdataCfgApplyPos.add(dataCfgApplyPo);
DataCfgPo dataCfgPo = dataCfgApplyPo.getDataCfgPo();
newDataCfgPos.add(dataCfgPo);
}
dataSetPo.setDataCfgPoList(newDataCfgPos);
dataSetApplyPo.setDataCfgApplyPoList(newdataCfgApplyPos);
}
return dataSetApplyPo;
}
@Override
public DataSetPo agreeDataSetApply(String oid, boolean doDataCfgAlso) throws Exception {
return agreeDataSetApply(oid, doDataCfgAlso, null);
}
@Override
public DataSetPo agreeDataSetApply(String oid, boolean doDataCfgAlso, DataInOptionsVo optionsVo) throws Exception {
DataSetApplyPo dataSetApplyPo = this.dataSetService.findDataSetApplyPoById(oid);
List<DataCfgApplyPo> DataCfgApplyPoList = dataSetApplyPo.getDataCfgApplyPoList();
// ! dataSet -> save dataSetVer -> save dataSetApply -> delete
DataSetPo dataSetPo = this.dataSetService.setAgree(oid);
List<DataCfgPo> dataCfgPoList = dataSetPo.getDataCfgPoList();
if ((doDataCfgAlso) && (DataCfgApplyPoList != null)) {
dataCfgPoList.clear();
for (DataCfgApplyPo dataCfgApplyPo : DataCfgApplyPoList) {
dataSetPo = this.dataSetService.findByOid(dataSetPo.getOid());
dataCfgApplyPo = this.dataCfgApplyDao.findById(dataCfgApplyPo.getOid());
dataCfgApplyPo.setDataSetPo(dataSetPo);
this.dataCfgApplyDao.update(dataCfgApplyPo);
// ! dataCfg -> save dataCfgVer -> save dataCfgFile -> save dataCfgApply -> delete
DataCfgPo dataCfgPo = this.dataCfgService.setAgree(dataCfgApplyPo.getOid(), optionsVo);
dataCfgPo = this.dataCfgService.findByOid(dataCfgPo.getOid());
dataSetPo = this.dataSetService.findByOid(dataSetPo.getOid());
dataCfgPo.setDataSetPo(dataSetPo);
dataCfgPo = this.dataCfgService.add(dataCfgPo);
dataCfgPoList = dataSetPo.getDataCfgPoList();
dataCfgPoList.add(dataCfgPo);
}
}
return dataSetPo;
}
@Override
public void refuseDataSetApply(String oid, boolean doDataCfgAlso) {
if (doDataCfgAlso) {
DataSetApplyPo dataSetApplyPo = this.dataSetService.findDataSetApplyPoById(oid);
if (dataSetApplyPo.getDataCfgApplyPoList() != null) {
List<DataCfgApplyPo> DataCfgApplyPos = dataSetApplyPo.getDataCfgApplyPoList();
for (DataCfgApplyPo dataCfgApplyPo : DataCfgApplyPos) {
this.dataCfgService.setRefuse(dataCfgApplyPo.getOid());
}
}
}
this.dataSetService.setRefuse(oid);
}
@Override
public Boolean isVerify() {
return this.isVerify;
}
@Override
public void setVerify(Boolean isVerify) {
this.isVerify = isVerify;
}
} | UTF-8 | Java | 5,301 | java | DataApplyServiceImpl.java | Java | [] | null | [] | package com.iisi.opd.cfg.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.iisi.opd.cfg.dao.DataCfgApplyDao;
import com.iisi.opd.cfg.po.DataCfgApplyPo;
import com.iisi.opd.cfg.po.DataCfgPo;
import com.iisi.opd.cfg.po.DataSetApplyPo;
import com.iisi.opd.cfg.po.DataSetPo;
import com.iisi.opd.cfg.service.DataApplyService;
import com.iisi.opd.cfg.service.DataCfgService;
import com.iisi.opd.cfg.service.DataSetService;
import com.iisi.opd.data.in.vo.DataInOptionsVo;
@Service
@Transactional
public class DataApplyServiceImpl implements DataApplyService {
@Autowired
private Boolean isVerify;
@Autowired
private DataCfgApplyDao dataCfgApplyDao;
@Autowired
private DataCfgService dataCfgService;
@Autowired
private DataSetService dataSetService;
@Override
public DataSetApplyPo enableApply(DataSetApplyPo dataSetApplyPo, List<DataCfgApplyPo> dataCfgApplyPos) {
if (this.isVerify.booleanValue()) {
dataSetApplyPo = this.dataSetService.enableApply(dataSetApplyPo);
List<DataCfgApplyPo> newdataCfgApplyPos = new ArrayList();
for (DataCfgApplyPo dataCfgApplyPo : dataCfgApplyPos) {
dataCfgApplyPo.setDataSetApplyPo(dataSetApplyPo);
dataCfgApplyPo = this.dataCfgService.enableApply(dataCfgApplyPo);
newdataCfgApplyPos.add(dataCfgApplyPo);
}
dataSetApplyPo.setDataCfgApplyPoList(newdataCfgApplyPos);
this.dataSetService.update(dataSetApplyPo);
} else {
dataSetApplyPo = this.dataSetService.enableApply(dataSetApplyPo);
DataSetPo dataSetPo = dataSetApplyPo.getDataSetPo();
List<DataCfgPo> newDataCfgPos = new ArrayList();
List<DataCfgApplyPo> newdataCfgApplyPos = new ArrayList();
for (DataCfgApplyPo dataCfgApplyPo : dataCfgApplyPos) {
dataCfgApplyPo.setDataSetPo(dataSetApplyPo.getDataSetPo());
dataCfgApplyPo = this.dataCfgService.enableApply(dataCfgApplyPo);
newdataCfgApplyPos.add(dataCfgApplyPo);
DataCfgPo dataCfgPo = dataCfgApplyPo.getDataCfgPo();
newDataCfgPos.add(dataCfgPo);
}
dataSetPo.setDataCfgPoList(newDataCfgPos);
dataSetApplyPo.setDataCfgApplyPoList(newdataCfgApplyPos);
}
return dataSetApplyPo;
}
@Override
public DataSetPo agreeDataSetApply(String oid, boolean doDataCfgAlso) throws Exception {
return agreeDataSetApply(oid, doDataCfgAlso, null);
}
@Override
public DataSetPo agreeDataSetApply(String oid, boolean doDataCfgAlso, DataInOptionsVo optionsVo) throws Exception {
DataSetApplyPo dataSetApplyPo = this.dataSetService.findDataSetApplyPoById(oid);
List<DataCfgApplyPo> DataCfgApplyPoList = dataSetApplyPo.getDataCfgApplyPoList();
// ! dataSet -> save dataSetVer -> save dataSetApply -> delete
DataSetPo dataSetPo = this.dataSetService.setAgree(oid);
List<DataCfgPo> dataCfgPoList = dataSetPo.getDataCfgPoList();
if ((doDataCfgAlso) && (DataCfgApplyPoList != null)) {
dataCfgPoList.clear();
for (DataCfgApplyPo dataCfgApplyPo : DataCfgApplyPoList) {
dataSetPo = this.dataSetService.findByOid(dataSetPo.getOid());
dataCfgApplyPo = this.dataCfgApplyDao.findById(dataCfgApplyPo.getOid());
dataCfgApplyPo.setDataSetPo(dataSetPo);
this.dataCfgApplyDao.update(dataCfgApplyPo);
// ! dataCfg -> save dataCfgVer -> save dataCfgFile -> save dataCfgApply -> delete
DataCfgPo dataCfgPo = this.dataCfgService.setAgree(dataCfgApplyPo.getOid(), optionsVo);
dataCfgPo = this.dataCfgService.findByOid(dataCfgPo.getOid());
dataSetPo = this.dataSetService.findByOid(dataSetPo.getOid());
dataCfgPo.setDataSetPo(dataSetPo);
dataCfgPo = this.dataCfgService.add(dataCfgPo);
dataCfgPoList = dataSetPo.getDataCfgPoList();
dataCfgPoList.add(dataCfgPo);
}
}
return dataSetPo;
}
@Override
public void refuseDataSetApply(String oid, boolean doDataCfgAlso) {
if (doDataCfgAlso) {
DataSetApplyPo dataSetApplyPo = this.dataSetService.findDataSetApplyPoById(oid);
if (dataSetApplyPo.getDataCfgApplyPoList() != null) {
List<DataCfgApplyPo> DataCfgApplyPos = dataSetApplyPo.getDataCfgApplyPoList();
for (DataCfgApplyPo dataCfgApplyPo : DataCfgApplyPos) {
this.dataCfgService.setRefuse(dataCfgApplyPo.getOid());
}
}
}
this.dataSetService.setRefuse(oid);
}
@Override
public Boolean isVerify() {
return this.isVerify;
}
@Override
public void setVerify(Boolean isVerify) {
this.isVerify = isVerify;
}
} | 5,301 | 0.668176 | 0.668176 | 126 | 40.087303 | 31.036083 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 15 |
3b73e036905c7a248e7619fd8b2ba344c4ac200d | 33,500,744,948,077 | 2b97edbc752ead0f5921a54c3916974b8b9506f8 | /com.tjoeun.java.1028/src/Star.java | 1e1e13cf8d1898921625dc2b7da9fa9ff7e8d17a | [] | no_license | yerrinn/java1028 | https://github.com/yerrinn/java1028 | 68abc7c02a31f06429657c3ca24da4275d722d8f | becfd719d8f01b16f18798c4164aa709b92a54e5 | refs/heads/main | 2023-08-20T17:42:00.345000 | 2021-10-28T09:11:31 | 2021-10-28T09:11:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Star {
public static void main(String[] args) {
int i;
//#1) *****출력
System.out.println("#1 -------------");
for(i=0; i<5; i=i+1) {
System.out.print("*");
}System.out.println();
//#2)
System.out.println("#2 -------------");
for(i=0; i<5; i=i+1) {
for(int j=0; j<5; j=j+1) {
System.out.print("*");
}System.out.println();
}
//#3)
System.out.println("#3 -------------");
for(i=0;i<5;i=i+1) {
for(int j=0; j<i+1; j=j+1) {
System.out.print("*");
}System.out.println();
}
//#4)
System.out.println("#4 -------------");
for(i=0;i<5;i=i+1) {
for(int j=0; j<5-i; j=j+1) {
System.out.print("*");
}System.out.println();
}
//#5)
System.out.println("#5 -------------");
for(i=0;i<5;i=i+1) {
for(int j=0; j<2*i+1; j=j+1) {
System.out.print("*");
}System.out.println();
}
//#6)
System.out.println("#6 -------------");
for(i=0;i<5;i=i+1) {
for(int j=0; j<9-2*i; j=j+1) {
System.out.print("*");
}System.out.println();
}
//#7)증가->감소문제
System.out.println("#7 -------------");
for(i=0; i<5; i=i+1) {
if(i<3) {//증가부분
for(int j=0; j<i+1; j=j+1) {
System.out.print("*");
}
}else {//감소부분
for(int j=2; j>0; j=j-1) {
System.out.print("*");
}
}System.out.println();
}System.out.println();
//#8.공백있는 증가->감소 문제
System.out.println("#8 -------------");
}//main
}//class
| UTF-8 | Java | 1,581 | java | Star.java | Java | [] | null | [] |
public class Star {
public static void main(String[] args) {
int i;
//#1) *****출력
System.out.println("#1 -------------");
for(i=0; i<5; i=i+1) {
System.out.print("*");
}System.out.println();
//#2)
System.out.println("#2 -------------");
for(i=0; i<5; i=i+1) {
for(int j=0; j<5; j=j+1) {
System.out.print("*");
}System.out.println();
}
//#3)
System.out.println("#3 -------------");
for(i=0;i<5;i=i+1) {
for(int j=0; j<i+1; j=j+1) {
System.out.print("*");
}System.out.println();
}
//#4)
System.out.println("#4 -------------");
for(i=0;i<5;i=i+1) {
for(int j=0; j<5-i; j=j+1) {
System.out.print("*");
}System.out.println();
}
//#5)
System.out.println("#5 -------------");
for(i=0;i<5;i=i+1) {
for(int j=0; j<2*i+1; j=j+1) {
System.out.print("*");
}System.out.println();
}
//#6)
System.out.println("#6 -------------");
for(i=0;i<5;i=i+1) {
for(int j=0; j<9-2*i; j=j+1) {
System.out.print("*");
}System.out.println();
}
//#7)증가->감소문제
System.out.println("#7 -------------");
for(i=0; i<5; i=i+1) {
if(i<3) {//증가부분
for(int j=0; j<i+1; j=j+1) {
System.out.print("*");
}
}else {//감소부분
for(int j=2; j>0; j=j-1) {
System.out.print("*");
}
}System.out.println();
}System.out.println();
//#8.공백있는 증가->감소 문제
System.out.println("#8 -------------");
}//main
}//class
| 1,581 | 0.42119 | 0.381295 | 87 | 15.551724 | 14.128116 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.471264 | false | false | 15 |
52ec4755610dd6c95d66eb61b18cab041ee26fbd | 16,338,055,610,037 | e9527ed358fe42a3fd19ece530ac40072938d341 | /DataExploration/src/org/legacyprojectx/datastructures/Person.java | 9038d88332e93fbedeefe39c00d0a3940ee62b64 | [] | no_license | hmisra/Legacy | https://github.com/hmisra/Legacy | 0d6e1ad437e3661d15af778686fd373eb820bcfc | 1ac34da206d64b081612b99abb51990e8b4f8a2b | refs/heads/master | 2021-05-03T10:02:22.269000 | 2015-07-02T03:49:50 | 2015-07-02T03:49:50 | 38,330,098 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.legacyprojectx.datastructures;
public class Person {
String name;
String age;
String gender;
String dateOfDeath;
String dateOfBirth;
String location;
String serviceDate;
String serviceLocation;
String educationInformation;
String militaryInformation;
boolean nameSet=false;
boolean ageSet=false;
boolean genderSet=false;
boolean dateOfBirthSet=false;
boolean dateOfDeathSet=false;
boolean locationSet=false;
boolean serviceSet=false;
boolean educationSet=false;
boolean militarySet=false;
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public boolean isGenderSet() {
return genderSet;
}
public void setGenderSet(boolean genderSet) {
this.genderSet = genderSet;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getDateOfDeath() {
return dateOfDeath;
}
public void setDateOfDeath(String dateOfDeath) {
this.dateOfDeath = dateOfDeath;
}
public String getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(String dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getServiceDate() {
return serviceDate;
}
public void setServiceDate(String serviceDate) {
this.serviceDate = serviceDate;
}
public String getServiceLocation() {
return serviceLocation;
}
public void setServiceLocation(String serviceLocation) {
this.serviceLocation = serviceLocation;
}
public String getEducationInformation() {
return educationInformation;
}
public void setEducationInformation(String educationInformation) {
this.educationInformation = educationInformation;
}
public String getMilitaryInformation() {
return militaryInformation;
}
public void setMilitaryInformation(String militaryInformation) {
this.militaryInformation = militaryInformation;
}
public boolean isNameSet() {
return nameSet;
}
public void setNameSet(boolean nameSet) {
this.nameSet = nameSet;
}
public boolean isAgeSet() {
return ageSet;
}
public void setAgeSet(boolean ageSet) {
this.ageSet = ageSet;
}
public boolean isDateOfBirthSet() {
return dateOfBirthSet;
}
public void setDateOfBirthSet(boolean dateOfBirthSet) {
this.dateOfBirthSet = dateOfBirthSet;
}
public boolean isDateOfDeathSet() {
return dateOfDeathSet;
}
public void setDateOfDeathSet(boolean dateOfDeathSet) {
this.dateOfDeathSet = dateOfDeathSet;
}
public boolean isLocationSet() {
return locationSet;
}
public void setLocationSet(boolean locationSet) {
this.locationSet = locationSet;
}
public boolean isServiceSet() {
return serviceSet;
}
public void setServiceSet(boolean serviceSet) {
this.serviceSet = serviceSet;
}
public boolean isEducationSet() {
return educationSet;
}
public void setEducationSet(boolean educationSet) {
this.educationSet = educationSet;
}
public boolean isMilitarySet() {
return militarySet;
}
public void setMilitarySet(boolean militarySet) {
this.militarySet = militarySet;
}
}
| UTF-8 | Java | 3,139 | java | Person.java | Java | [] | null | [] | package org.legacyprojectx.datastructures;
public class Person {
String name;
String age;
String gender;
String dateOfDeath;
String dateOfBirth;
String location;
String serviceDate;
String serviceLocation;
String educationInformation;
String militaryInformation;
boolean nameSet=false;
boolean ageSet=false;
boolean genderSet=false;
boolean dateOfBirthSet=false;
boolean dateOfDeathSet=false;
boolean locationSet=false;
boolean serviceSet=false;
boolean educationSet=false;
boolean militarySet=false;
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public boolean isGenderSet() {
return genderSet;
}
public void setGenderSet(boolean genderSet) {
this.genderSet = genderSet;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getDateOfDeath() {
return dateOfDeath;
}
public void setDateOfDeath(String dateOfDeath) {
this.dateOfDeath = dateOfDeath;
}
public String getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(String dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getServiceDate() {
return serviceDate;
}
public void setServiceDate(String serviceDate) {
this.serviceDate = serviceDate;
}
public String getServiceLocation() {
return serviceLocation;
}
public void setServiceLocation(String serviceLocation) {
this.serviceLocation = serviceLocation;
}
public String getEducationInformation() {
return educationInformation;
}
public void setEducationInformation(String educationInformation) {
this.educationInformation = educationInformation;
}
public String getMilitaryInformation() {
return militaryInformation;
}
public void setMilitaryInformation(String militaryInformation) {
this.militaryInformation = militaryInformation;
}
public boolean isNameSet() {
return nameSet;
}
public void setNameSet(boolean nameSet) {
this.nameSet = nameSet;
}
public boolean isAgeSet() {
return ageSet;
}
public void setAgeSet(boolean ageSet) {
this.ageSet = ageSet;
}
public boolean isDateOfBirthSet() {
return dateOfBirthSet;
}
public void setDateOfBirthSet(boolean dateOfBirthSet) {
this.dateOfBirthSet = dateOfBirthSet;
}
public boolean isDateOfDeathSet() {
return dateOfDeathSet;
}
public void setDateOfDeathSet(boolean dateOfDeathSet) {
this.dateOfDeathSet = dateOfDeathSet;
}
public boolean isLocationSet() {
return locationSet;
}
public void setLocationSet(boolean locationSet) {
this.locationSet = locationSet;
}
public boolean isServiceSet() {
return serviceSet;
}
public void setServiceSet(boolean serviceSet) {
this.serviceSet = serviceSet;
}
public boolean isEducationSet() {
return educationSet;
}
public void setEducationSet(boolean educationSet) {
this.educationSet = educationSet;
}
public boolean isMilitarySet() {
return militarySet;
}
public void setMilitarySet(boolean militarySet) {
this.militarySet = militarySet;
}
}
| 3,139 | 0.790698 | 0.790698 | 145 | 20.648275 | 17.030817 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.662069 | false | false | 15 |
d3bd2ab2ff996cdb4d1ca0fdaae2fbe76d59a0a8 | 884,763,314,584 | baf41061931225ec53bce905db0adb3efa5bb4e9 | /ArgusCore/src/test/java/com/salesforce/dva/argus/service/metric/transform/GroupByTagTransformTest.java | cbbee4d1d79da25f2d9fbf9d9642269ddd5f84f3 | [] | permissive | noirHck/Argus | https://github.com/noirHck/Argus | 0157a6a50d4175df10ee0ffaeac7ef38addeeb11 | 5539ccc2fed5f714b76e07eac8271cfaa45df9cf | refs/heads/master | 2021-05-21T19:38:39.868000 | 2020-06-17T01:42:34 | 2020-06-17T01:42:34 | 252,773,088 | 1 | 0 | BSD-3-Clause | true | 2020-04-03T15:37:49 | 2020-04-03T15:37:48 | 2020-03-15T01:00:48 | 2020-04-01T06:13:25 | 9,265 | 0 | 0 | 0 | null | false | false | package com.salesforce.dva.argus.service.metric.transform;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.salesforce.dva.argus.entity.Metric;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
public class GroupByTagTransformTest {
@Test
public void testGroupBySingleCommonTag() {
GroupByTagTransform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("system.DCA.xy1", "metric1");
metric1.setDatapoints(datapoints);
metric1.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("tag1", "value1");
put("tag2", "value1");
}});
Metric metric2 = new Metric("system.DCA.xy2", "metric1");
metric2.setDatapoints(datapoints);
metric2.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("tag1", "value2");
put("tag2", "value2");
}});
Metric metric3 = new Metric("system.DCB.xy1", "metric1");
metric3.setDatapoints(datapoints);
metric3.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value3");
put("tag2", "value3");
}});
Metric metric4 = new Metric("system.DCB.xy2", "metric1");
metric4.setDatapoints(datapoints);
metric4.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value4");
put("tag2", "value4");
}});
metrics.add(metric1);
metrics.add(metric2);
metrics.add(metric3);
metrics.add(metric4);
List<String> constants = new ArrayList<>();
constants.add("dc");
constants.add("SUM");
List<Metric> result = transform.transform(metrics, constants);
assertTrue(result.size() == 2);
for(Metric r : result) {
assertEquals(new Double(2.0), r.getDatapoints().get(1000L));
assertTrue(r.getScope().equals("DCA") || r.getScope().equals("DCB"));
assertTrue(r.getMetric().equals("metric1"));
assertTrue(r.getTag("dc") != null);
}
}
@Test
public void testGroupByTagTwoCommonTags() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("system.DCA.xy1", "metric1");
metric1.setDatapoints(datapoints);
metric1.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP1");
put("tag1", "value1");
put("tag2", "value1");
}});
Metric metric2 = new Metric("system.DCA.xy2", "metric1");
metric2.setDatapoints(datapoints);
metric2.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP2");
put("tag1", "value2");
put("tag2", "value2");
}});
Metric metric3 = new Metric("system.DCB.xy1", "metric1");
metric3.setDatapoints(datapoints);
metric3.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("sp", "SP1");
put("tag1", "value3");
put("tag2", "value3");
}});
Metric metric4 = new Metric("system.DCB.xy2", "metric1");
metric4.setDatapoints(datapoints);
metric4.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("sp", "SP1");
put("tag1", "value4");
put("tag2", "value4");
}});
metrics.add(metric1);
metrics.add(metric2);
metrics.add(metric3);
metrics.add(metric4);
List<String> constants = new ArrayList<>();
constants.add("dc");
constants.add("sp");
constants.add("SUM");
List<Metric> result = transform.transform(metrics, constants);
assertEquals(3, result.size());
for(Metric r : result) {
assertTrue(
r.getScope().equals("DCA,SP1") ||
r.getScope().equals("DCA,SP2") ||
r.getScope().equals("DCB,SP1"));
assertEquals("metric1", r.getMetric());
assertNotNull(r.getTag("dc"));
assertNotNull(r.getTag("sp"));
}
}
@Test
public void testGroupByTagTwoTagsOnePartial() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("system.DCA.xy1", "metric1");
metric1.setDatapoints(datapoints);
metric1.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP1");
put("tag1", "value1");
put("tag2", "value1");
}});
Metric metric2 = new Metric("system.DCA.xy2", "metric1");
metric2.setDatapoints(datapoints);
metric2.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP2");
put("tag1", "value2");
put("tag2", "value2");
}});
Metric metric3 = new Metric("system.DCB.xy1", "metric1");
metric3.setDatapoints(datapoints);
metric3.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value3");
put("tag2", "value3");
}});
Metric metric4 = new Metric("system.DCB.xy2", "metric1");
metric4.setDatapoints(datapoints);
metric4.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value4");
put("tag2", "value4");
}});
metrics.add(metric1);
metrics.add(metric2);
metrics.add(metric3);
metrics.add(metric4);
List<String> constants = new ArrayList<>();
constants.add("dc");
constants.add("sp");
constants.add("SUM");
List<Metric> result = transform.transform(metrics, constants);
assertEquals(3, result.size());
for(Metric r : result) {
assertTrue(
r.getScope().equals("DCA,SP1") ||
r.getScope().equals("DCA,SP2") ||
r.getScope().equals("DCB"));
assertEquals("metric1", r.getMetric());
assertNotNull(r.getTag("dc"));
if (r.getTag("dc").equals("DCA")) {
assertNotNull(r.getTag("sp"));
}
else {
assertNull(r.getTag("sp"));
}
}
}
@Test
public void testGroupByTagOnePartial() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("system.DCA.xy1", "metric1");
metric1.setDatapoints(datapoints);
metric1.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP1");
put("tag1", "value1");
put("tag2", "value1");
}});
Metric metric2 = new Metric("system.DCA.xy2", "metric1");
metric2.setDatapoints(datapoints);
metric2.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP2");
put("tag1", "value2");
put("tag2", "value2");
}});
Metric metric3 = new Metric("system.DCB.xy1", "metric1");
metric3.setDatapoints(datapoints);
metric3.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value3");
put("tag2", "value3");
}});
Metric metric4 = new Metric("system.DCB.xy2", "metric1");
metric4.setDatapoints(datapoints);
metric4.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value4");
put("tag2", "value4");
}});
metrics.add(metric1);
metrics.add(metric2);
metrics.add(metric3);
metrics.add(metric4);
List<String> constants = new ArrayList<>();
constants.add("sp");
constants.add("SUM");
List<Metric> result = transform.transform(metrics, constants);
assertEquals(3, result.size());
for(Metric r : result) {
assertTrue(
r.getScope().equals("SP1") ||
r.getScope().equals("SP2") ||
r.getScope().equals("uncaptured-group"));
assertEquals("metric1", r.getMetric());
if (!r.getScope().equals("uncaptured-group")) {
assertNotNull(r.getTag("sp"));
}
else {
assertNull(r.getTag("sp"));
}
}
}
@Test
public void testGroupByTagWithTransformConstant() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("system.DCA.xy1", "metric1");
metric1.setDatapoints(datapoints);
metric1.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP1");
put("tag1", "value1");
put("tag2", "value1");
}});
Metric metric2 = new Metric("system.DCA.xy2", "metric1");
metric2.setDatapoints(datapoints);
metric2.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP2");
put("tag1", "value2");
put("tag2", "value2");
}});
Metric metric3 = new Metric("system.DCB.xy1", "metric1");
metric3.setDatapoints(datapoints);
metric3.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("sp", "SP2");
put("tag1", "value3");
put("tag2", "value3");
}});
Metric metric4 = new Metric("system.DCB.xy2", "metric1");
metric4.setDatapoints(datapoints);
metric4.addDatapoints(new HashMap<Long, Double>() {{
put(2000L, 1.0);
}});
metric4.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("sp", "SP2");
put("tag1", "value4");
put("tag2", "value4");
}});
List<String> constants = new ArrayList<>();
constants.add("sp");
constants.add("dc");
constants.add("SUM");
constants.add("union");
metrics.add(metric1);
metrics.add(metric2);
metrics.add(metric3);
metrics.add(metric4);
List<Metric> result = transform.transform(metrics, constants);
assertEquals(3, result.size());
for(Metric r : result) {
assertTrue(
r.getScope().equals("SP1,DCA") ||
r.getScope().equals("SP2,DCA") ||
r.getScope().equals("SP2,DCB"));
assertEquals("metric1", r.getMetric());
assertNotNull(r.getTag("dc"));
assertNotNull(r.getTag("sp"));
if (r.getTag("dc").equals("DCA")) {
assertEquals(new Double(1.0), r.getDatapoints().get(1000L));
}
else {
assertEquals(new Double(2.0), r.getDatapoints().get(1000L));
assertEquals(new Double(1.0), r.getDatapoints().get(2000L));
}
}
}
@Test
public void testGroupByTagNoTags() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("scope", "latency");
metric1.setTag("device", "device1");
metric1.setDatapoints(datapoints);
Metric metric2 = new Metric("scope", "latency");
metric2.setTag("device", "device2");
metric2.setDatapoints(datapoints);
metrics.add(metric1);
metrics.add(metric2);
List<String> constants = new ArrayList<>();
constants.add("SUM");
constants.add("union");
try {
List<Metric> result = transform.transform(metrics, constants);
fail("Should fail because no tags is provided");
}
catch (UnsupportedOperationException ex) {
assertTrue(ex.getMessage().contains("one tag to be provided"));
}
}
@Test
public void testGroupByTagNoFunction() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("scope", "latency");
metric1.setTag("device", "device1");
metric1.setDatapoints(datapoints);
Metric metric2 = new Metric("scope", "latency");
metric2.setTag("device", "device2");
metric2.setDatapoints(datapoints);
metrics.add(metric1);
metrics.add(metric2);
List<String> constants = new ArrayList<>();
constants.add("device");
constants.add("union");
try {
List<Metric> result = transform.transform(metrics, constants);
fail("Should fail because no function is provided");
}
catch (UnsupportedOperationException ex) {
assertTrue(ex.getMessage().contains("function name to be provided"));
}
}
}
| UTF-8 | Java | 12,104 | java | GroupByTagTransformTest.java | Java | [] | null | [] | package com.salesforce.dva.argus.service.metric.transform;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.salesforce.dva.argus.entity.Metric;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
public class GroupByTagTransformTest {
@Test
public void testGroupBySingleCommonTag() {
GroupByTagTransform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("system.DCA.xy1", "metric1");
metric1.setDatapoints(datapoints);
metric1.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("tag1", "value1");
put("tag2", "value1");
}});
Metric metric2 = new Metric("system.DCA.xy2", "metric1");
metric2.setDatapoints(datapoints);
metric2.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("tag1", "value2");
put("tag2", "value2");
}});
Metric metric3 = new Metric("system.DCB.xy1", "metric1");
metric3.setDatapoints(datapoints);
metric3.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value3");
put("tag2", "value3");
}});
Metric metric4 = new Metric("system.DCB.xy2", "metric1");
metric4.setDatapoints(datapoints);
metric4.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value4");
put("tag2", "value4");
}});
metrics.add(metric1);
metrics.add(metric2);
metrics.add(metric3);
metrics.add(metric4);
List<String> constants = new ArrayList<>();
constants.add("dc");
constants.add("SUM");
List<Metric> result = transform.transform(metrics, constants);
assertTrue(result.size() == 2);
for(Metric r : result) {
assertEquals(new Double(2.0), r.getDatapoints().get(1000L));
assertTrue(r.getScope().equals("DCA") || r.getScope().equals("DCB"));
assertTrue(r.getMetric().equals("metric1"));
assertTrue(r.getTag("dc") != null);
}
}
@Test
public void testGroupByTagTwoCommonTags() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("system.DCA.xy1", "metric1");
metric1.setDatapoints(datapoints);
metric1.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP1");
put("tag1", "value1");
put("tag2", "value1");
}});
Metric metric2 = new Metric("system.DCA.xy2", "metric1");
metric2.setDatapoints(datapoints);
metric2.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP2");
put("tag1", "value2");
put("tag2", "value2");
}});
Metric metric3 = new Metric("system.DCB.xy1", "metric1");
metric3.setDatapoints(datapoints);
metric3.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("sp", "SP1");
put("tag1", "value3");
put("tag2", "value3");
}});
Metric metric4 = new Metric("system.DCB.xy2", "metric1");
metric4.setDatapoints(datapoints);
metric4.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("sp", "SP1");
put("tag1", "value4");
put("tag2", "value4");
}});
metrics.add(metric1);
metrics.add(metric2);
metrics.add(metric3);
metrics.add(metric4);
List<String> constants = new ArrayList<>();
constants.add("dc");
constants.add("sp");
constants.add("SUM");
List<Metric> result = transform.transform(metrics, constants);
assertEquals(3, result.size());
for(Metric r : result) {
assertTrue(
r.getScope().equals("DCA,SP1") ||
r.getScope().equals("DCA,SP2") ||
r.getScope().equals("DCB,SP1"));
assertEquals("metric1", r.getMetric());
assertNotNull(r.getTag("dc"));
assertNotNull(r.getTag("sp"));
}
}
@Test
public void testGroupByTagTwoTagsOnePartial() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("system.DCA.xy1", "metric1");
metric1.setDatapoints(datapoints);
metric1.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP1");
put("tag1", "value1");
put("tag2", "value1");
}});
Metric metric2 = new Metric("system.DCA.xy2", "metric1");
metric2.setDatapoints(datapoints);
metric2.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP2");
put("tag1", "value2");
put("tag2", "value2");
}});
Metric metric3 = new Metric("system.DCB.xy1", "metric1");
metric3.setDatapoints(datapoints);
metric3.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value3");
put("tag2", "value3");
}});
Metric metric4 = new Metric("system.DCB.xy2", "metric1");
metric4.setDatapoints(datapoints);
metric4.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value4");
put("tag2", "value4");
}});
metrics.add(metric1);
metrics.add(metric2);
metrics.add(metric3);
metrics.add(metric4);
List<String> constants = new ArrayList<>();
constants.add("dc");
constants.add("sp");
constants.add("SUM");
List<Metric> result = transform.transform(metrics, constants);
assertEquals(3, result.size());
for(Metric r : result) {
assertTrue(
r.getScope().equals("DCA,SP1") ||
r.getScope().equals("DCA,SP2") ||
r.getScope().equals("DCB"));
assertEquals("metric1", r.getMetric());
assertNotNull(r.getTag("dc"));
if (r.getTag("dc").equals("DCA")) {
assertNotNull(r.getTag("sp"));
}
else {
assertNull(r.getTag("sp"));
}
}
}
@Test
public void testGroupByTagOnePartial() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("system.DCA.xy1", "metric1");
metric1.setDatapoints(datapoints);
metric1.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP1");
put("tag1", "value1");
put("tag2", "value1");
}});
Metric metric2 = new Metric("system.DCA.xy2", "metric1");
metric2.setDatapoints(datapoints);
metric2.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP2");
put("tag1", "value2");
put("tag2", "value2");
}});
Metric metric3 = new Metric("system.DCB.xy1", "metric1");
metric3.setDatapoints(datapoints);
metric3.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value3");
put("tag2", "value3");
}});
Metric metric4 = new Metric("system.DCB.xy2", "metric1");
metric4.setDatapoints(datapoints);
metric4.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("tag1", "value4");
put("tag2", "value4");
}});
metrics.add(metric1);
metrics.add(metric2);
metrics.add(metric3);
metrics.add(metric4);
List<String> constants = new ArrayList<>();
constants.add("sp");
constants.add("SUM");
List<Metric> result = transform.transform(metrics, constants);
assertEquals(3, result.size());
for(Metric r : result) {
assertTrue(
r.getScope().equals("SP1") ||
r.getScope().equals("SP2") ||
r.getScope().equals("uncaptured-group"));
assertEquals("metric1", r.getMetric());
if (!r.getScope().equals("uncaptured-group")) {
assertNotNull(r.getTag("sp"));
}
else {
assertNull(r.getTag("sp"));
}
}
}
@Test
public void testGroupByTagWithTransformConstant() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("system.DCA.xy1", "metric1");
metric1.setDatapoints(datapoints);
metric1.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP1");
put("tag1", "value1");
put("tag2", "value1");
}});
Metric metric2 = new Metric("system.DCA.xy2", "metric1");
metric2.setDatapoints(datapoints);
metric2.setTags(new HashMap<String, String>(){{
put("dc", "DCA");
put("sp", "SP2");
put("tag1", "value2");
put("tag2", "value2");
}});
Metric metric3 = new Metric("system.DCB.xy1", "metric1");
metric3.setDatapoints(datapoints);
metric3.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("sp", "SP2");
put("tag1", "value3");
put("tag2", "value3");
}});
Metric metric4 = new Metric("system.DCB.xy2", "metric1");
metric4.setDatapoints(datapoints);
metric4.addDatapoints(new HashMap<Long, Double>() {{
put(2000L, 1.0);
}});
metric4.setTags(new HashMap<String, String>(){{
put("dc", "DCB");
put("sp", "SP2");
put("tag1", "value4");
put("tag2", "value4");
}});
List<String> constants = new ArrayList<>();
constants.add("sp");
constants.add("dc");
constants.add("SUM");
constants.add("union");
metrics.add(metric1);
metrics.add(metric2);
metrics.add(metric3);
metrics.add(metric4);
List<Metric> result = transform.transform(metrics, constants);
assertEquals(3, result.size());
for(Metric r : result) {
assertTrue(
r.getScope().equals("SP1,DCA") ||
r.getScope().equals("SP2,DCA") ||
r.getScope().equals("SP2,DCB"));
assertEquals("metric1", r.getMetric());
assertNotNull(r.getTag("dc"));
assertNotNull(r.getTag("sp"));
if (r.getTag("dc").equals("DCA")) {
assertEquals(new Double(1.0), r.getDatapoints().get(1000L));
}
else {
assertEquals(new Double(2.0), r.getDatapoints().get(1000L));
assertEquals(new Double(1.0), r.getDatapoints().get(2000L));
}
}
}
@Test
public void testGroupByTagNoTags() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("scope", "latency");
metric1.setTag("device", "device1");
metric1.setDatapoints(datapoints);
Metric metric2 = new Metric("scope", "latency");
metric2.setTag("device", "device2");
metric2.setDatapoints(datapoints);
metrics.add(metric1);
metrics.add(metric2);
List<String> constants = new ArrayList<>();
constants.add("SUM");
constants.add("union");
try {
List<Metric> result = transform.transform(metrics, constants);
fail("Should fail because no tags is provided");
}
catch (UnsupportedOperationException ex) {
assertTrue(ex.getMessage().contains("one tag to be provided"));
}
}
@Test
public void testGroupByTagNoFunction() {
Transform transform = new GroupByTagTransform(new TransformFactory(null));
Map<Long, Double> datapoints = new HashMap<Long, Double>();
datapoints.put(1000L, 1.0);
List<Metric> metrics = new ArrayList<>();
Metric metric1 = new Metric("scope", "latency");
metric1.setTag("device", "device1");
metric1.setDatapoints(datapoints);
Metric metric2 = new Metric("scope", "latency");
metric2.setTag("device", "device2");
metric2.setDatapoints(datapoints);
metrics.add(metric1);
metrics.add(metric2);
List<String> constants = new ArrayList<>();
constants.add("device");
constants.add("union");
try {
List<Metric> result = transform.transform(metrics, constants);
fail("Should fail because no function is provided");
}
catch (UnsupportedOperationException ex) {
assertTrue(ex.getMessage().contains("function name to be provided"));
}
}
}
| 12,104 | 0.640945 | 0.614094 | 441 | 26.446712 | 20.43989 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.947846 | false | false | 15 |
6fa9eb25bc843820e7cd8a05373ace3b9e26433f | 12,884,901,936,816 | 9b7026ae99281ddf3f39e19c9a502a2fd4bfae65 | /Zoom/src/midterm/Array4.java | 3fc5a59518a24e4e902f3573c46e87295bf571bc | [] | no_license | Yangdongjue/java_practice | https://github.com/Yangdongjue/java_practice | 68bdae67bea68ed5223cebb1e16ffa89ec188c90 | aee811548e81bfaf3f83b9d2c0984ec31f9e74ed | refs/heads/main | 2023-04-19T19:09:43.557000 | 2021-05-28T13:30:37 | 2021-05-28T13:30:37 | 329,290,557 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package midterm;
public class Array4 {
public static void main(String[] args) {
double score[][] = {{1.5, 3.5},
{3.2,4.2},{2.5,4.4},{1,2}};
double sum=0;
for(int i=0; i<score.length;i++) {
for(int j=0;j<score[i].length;j++) {
sum+=score[i][j];
}
}
System.out.println(sum/(score.length*score[0].length));
}
}
| UTF-8 | Java | 354 | java | Array4.java | Java | [] | null | [] | package midterm;
public class Array4 {
public static void main(String[] args) {
double score[][] = {{1.5, 3.5},
{3.2,4.2},{2.5,4.4},{1,2}};
double sum=0;
for(int i=0; i<score.length;i++) {
for(int j=0;j<score[i].length;j++) {
sum+=score[i][j];
}
}
System.out.println(sum/(score.length*score[0].length));
}
}
| 354 | 0.539548 | 0.485876 | 16 | 20.125 | 17.164188 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.75 | false | false | 15 |
160605068db44a72d30f4bb91ca38814a0de3172 | 12,171,937,350,434 | 90fd5e32f25f2617880a6532f125797c8ddc5f2b | /reverse strings/src/Main.java | 27c9facf0d57a94124a8fef4b722d34d47410483 | [] | no_license | zackdean808/codeeval | https://github.com/zackdean808/codeeval | ea98f96258dd803920afece16beecd5986cc0758 | 7733c7a9b8182354738e134594c58b8156f5916f | refs/heads/master | 2021-06-01T19:57:25.992000 | 2021-03-01T02:32:52 | 2021-03-01T02:32:52 | 23,452,285 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.*;
public class Main {
public static void main(String[] args) {
String s = "Hello World";
String s1 = "Hello CodeEval";
String s2 = "This is a test";
// System.out.println(flip(s));
//System.out.println(flip(s1));
flip(s);
System.out.println();
flip(s1);
System.out.println();
flip(s2);
}
static void flip(String s){
String[] myStrArr;
String delms = "[ ]";
myStrArr= s.split(delms);
for(int i = myStrArr.length -1 ; i >= 0; i-- ){
System.out.print(myStrArr[i] + " ");
}
}
}
| UTF-8 | Java | 546 | java | Main.java | Java | [] | null | [] | import java.util.*;
public class Main {
public static void main(String[] args) {
String s = "Hello World";
String s1 = "Hello CodeEval";
String s2 = "This is a test";
// System.out.println(flip(s));
//System.out.println(flip(s1));
flip(s);
System.out.println();
flip(s1);
System.out.println();
flip(s2);
}
static void flip(String s){
String[] myStrArr;
String delms = "[ ]";
myStrArr= s.split(delms);
for(int i = myStrArr.length -1 ; i >= 0; i-- ){
System.out.print(myStrArr[i] + " ");
}
}
}
| 546 | 0.587912 | 0.575092 | 31 | 16.612904 | 14.452765 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.032258 | false | false | 15 |
f74797b915b211995a4ce501229e0c95ff60af5b | 9,577,777,130,906 | b8503319c20120eb25d6f74c286afb5719db4f9d | /app/src/main/java/com/example/administrator/test/netutil/HttpClientAsyncTask.java | c9ba6f69e99f437d79df8705bd3ff2f32130af03 | [] | no_license | Gponder/Test | https://github.com/Gponder/Test | 58b9f06a71a1efb00e339b9d50708689ee1b522c | a72c3ee19a0cbb73c45d81f020ca2e756eae3a95 | refs/heads/master | 2021-01-10T16:42:19.081000 | 2015-12-29T10:20:05 | 2015-12-29T10:20:05 | 47,814,139 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.administrator.test.netutil;
import android.content.Context;
import android.net.http.AndroidHttpClient;
import android.os.AsyncTask;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.DefaultedHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Created by Administrator on 2015/12/16.
*/
public class HttpClientAsyncTask extends AsyncTask {
// 请求方法 空格 url 空格 协议版本 回车换行 请求行
@Override
protected Object doInBackground(Object[] objects) {
this.defaultHttpClient();
return null;
}
public void defaultHttpClient(){
HttpClient httpClient = new DefaultHttpClient();
HttpUriRequest httpUriRequest = new HttpGet("http://www.baidu.com");
HttpPost post = new HttpPost("http://www.baidu.com");
try {
InputStream is = new FileInputStream("baidu");
HttpEntity httpEntity = new InputStreamEntity(is,is.available());
// MultipartEntity
post.setEntity(httpEntity);
HttpResponse reponse = httpClient.execute(httpUriRequest);
HttpEntity entity = reponse.getEntity();
InputStream content = entity.getContent();
OutputStream os=new FileOutputStream("/baidu");
entity.writeTo(os);
} catch (IOException e) {
e.printStackTrace();
}
}
public void androidHttpClient(Context context){
HttpClient httpClient = AndroidHttpClient.newInstance("");
BasicHttpContext basicHttpContext = new BasicHttpContext();
basicHttpContext.setAttribute(ClientContext.COOKIE_STORE,new BasicCookieStore());
try {
HttpResponse res = httpClient.execute(null, basicHttpContext);
} catch (IOException e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 2,492 | java | HttpClientAsyncTask.java | Java | [
{
"context": "m;\nimport java.io.OutputStream;\n\n/**\n * Created by Administrator on 2015/12/16.\n */\npublic class HttpClientAsyncTa",
"end": 953,
"score": 0.5900149941444397,
"start": 940,
"tag": "NAME",
"value": "Administrator"
}
] | null | [] | package com.example.administrator.test.netutil;
import android.content.Context;
import android.net.http.AndroidHttpClient;
import android.os.AsyncTask;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.DefaultedHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Created by Administrator on 2015/12/16.
*/
public class HttpClientAsyncTask extends AsyncTask {
// 请求方法 空格 url 空格 协议版本 回车换行 请求行
@Override
protected Object doInBackground(Object[] objects) {
this.defaultHttpClient();
return null;
}
public void defaultHttpClient(){
HttpClient httpClient = new DefaultHttpClient();
HttpUriRequest httpUriRequest = new HttpGet("http://www.baidu.com");
HttpPost post = new HttpPost("http://www.baidu.com");
try {
InputStream is = new FileInputStream("baidu");
HttpEntity httpEntity = new InputStreamEntity(is,is.available());
// MultipartEntity
post.setEntity(httpEntity);
HttpResponse reponse = httpClient.execute(httpUriRequest);
HttpEntity entity = reponse.getEntity();
InputStream content = entity.getContent();
OutputStream os=new FileOutputStream("/baidu");
entity.writeTo(os);
} catch (IOException e) {
e.printStackTrace();
}
}
public void androidHttpClient(Context context){
HttpClient httpClient = AndroidHttpClient.newInstance("");
BasicHttpContext basicHttpContext = new BasicHttpContext();
basicHttpContext.setAttribute(ClientContext.COOKIE_STORE,new BasicCookieStore());
try {
HttpResponse res = httpClient.execute(null, basicHttpContext);
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 2,492 | 0.711084 | 0.707824 | 68 | 35.088234 | 22.756857 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.647059 | false | false | 15 |
cc53f52327e39ffc50b8c7a7086dd5a99b2682c6 | 29,832,842,839,420 | 46073502369f8e3fc5a1800c42912027332ca380 | /common/common_utils/src/main/java/com/wxy/utils/StandardResult.java | 24a027ef16f2fb8a425ab5ace34ed6099db80427 | [] | no_license | wu5625520/online_edu | https://github.com/wu5625520/online_edu | fbfa1a843c1af6e5718620bc60527c24e9a2d596 | 3c85e831cfb907f2051f063c0aff50ff6a4f16c2 | refs/heads/master | 2023-08-18T09:23:15.838000 | 2021-10-09T03:15:00 | 2021-10-09T03:15:00 | 409,939,000 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wxy.utils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.Map;
/**
* @author wxy
* @title: com.wxy.utils.StandardResult
* @description: TODO
* @date 2021/9/2218:36
*/
@ApiModel
@Data
public class StandardResult {
@ApiModelProperty(value = "success or not")
private Boolean success;
@ApiModelProperty(value = "the status code of this result")
private Integer code;
@ApiModelProperty(value = "additional information of this result")
private String message;
@ApiModelProperty(value = "the actual data of this return")
private Map<String, Object> data= new HashMap<>();
private StandardResult(){}
public static StandardResult ok(){
StandardResult standardResult = new StandardResult();
standardResult.setSuccess(true);
standardResult.setCode(ResultCode.SUCCESS.getCode());
standardResult.setMessage("ok");
return standardResult;//链式编程
}
public static StandardResult error(){
StandardResult standardResult = new StandardResult();
standardResult.setSuccess(false);
standardResult.setCode(ResultCode.ERROR.getCode());
standardResult.setMessage("failed");
return standardResult;
}
public StandardResult success(Boolean success){
setSuccess(success);
return this;
}
public StandardResult message(String message){
setMessage(message);
return this;
}
public StandardResult code(Integer code){
setCode(code);
return this;
}
public StandardResult data(Map<String, Object> data){
setData(data);
return this;
}
public StandardResult data(String key, Object value){
data.put(key, value);
return this;
}
}
| UTF-8 | Java | 1,925 | java | StandardResult.java | Java | [
{
"context": "til.HashMap;\nimport java.util.Map;\n\n/**\n * @author wxy\n * @title: com.wxy.utils.StandardResult\n * @descr",
"end": 250,
"score": 0.9996752738952637,
"start": 247,
"tag": "USERNAME",
"value": "wxy"
}
] | null | [] | package com.wxy.utils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.Map;
/**
* @author wxy
* @title: com.wxy.utils.StandardResult
* @description: TODO
* @date 2021/9/2218:36
*/
@ApiModel
@Data
public class StandardResult {
@ApiModelProperty(value = "success or not")
private Boolean success;
@ApiModelProperty(value = "the status code of this result")
private Integer code;
@ApiModelProperty(value = "additional information of this result")
private String message;
@ApiModelProperty(value = "the actual data of this return")
private Map<String, Object> data= new HashMap<>();
private StandardResult(){}
public static StandardResult ok(){
StandardResult standardResult = new StandardResult();
standardResult.setSuccess(true);
standardResult.setCode(ResultCode.SUCCESS.getCode());
standardResult.setMessage("ok");
return standardResult;//链式编程
}
public static StandardResult error(){
StandardResult standardResult = new StandardResult();
standardResult.setSuccess(false);
standardResult.setCode(ResultCode.ERROR.getCode());
standardResult.setMessage("failed");
return standardResult;
}
public StandardResult success(Boolean success){
setSuccess(success);
return this;
}
public StandardResult message(String message){
setMessage(message);
return this;
}
public StandardResult code(Integer code){
setCode(code);
return this;
}
public StandardResult data(Map<String, Object> data){
setData(data);
return this;
}
public StandardResult data(String key, Object value){
data.put(key, value);
return this;
}
}
| 1,925 | 0.683881 | 0.678143 | 65 | 28.492308 | 19.9562 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.538462 | false | false | 15 |
b035808bfd3734e367ef55e788ed625a0fd1cbce | 23,356,032,168,894 | b39128c918892235606c0934b7537a5e66b9b5bb | /src/test/java/org/alterq/scheduler/DailyWarningUserBalanceTest.java | eec0fc3ba30b6fbf7ffe655e6c54265f175e5ab2 | [] | no_license | racsor/prueba | https://github.com/racsor/prueba | 3adc8c165b0c805cf9fec9ed74d5767a1faceedf | 336cc7ffb813d2b69cae157c4f7c79b39aa79994 | refs/heads/master | 2021-07-06T06:00:43.492000 | 2017-04-01T21:36:36 | 2017-04-01T21:36:36 | 105,471,479 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.alterq.scheduler;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:/spring/applicationContext.xml" })
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class DailyWarningUserBalanceTest {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
DailyWarningUserBalance dailyWarningUserBalance;
@Test
public void test00() throws Exception {
dailyWarningUserBalance.executeDailyWarning();
log.debug("dailyWarning");
return;
}
}
| UTF-8 | Java | 934 | java | DailyWarningUserBalanceTest.java | Java | [] | null | [] | package org.alterq.scheduler;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:/spring/applicationContext.xml" })
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class DailyWarningUserBalanceTest {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
DailyWarningUserBalance dailyWarningUserBalance;
@Test
public void test00() throws Exception {
dailyWarningUserBalance.executeDailyWarning();
log.debug("dailyWarning");
return;
}
}
| 934 | 0.796574 | 0.789079 | 30 | 29.133333 | 24.179514 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.933333 | false | false | 15 |
0a6c9b81c6adb516db29d806a17dbeb2396d9210 | 13,812,614,863,373 | c80f25f9c8faa1ea9db5bb1b8e36c3903a80a58b | /laosiji-sources/feng/android/sources/com/talkingdata/sdk/cl.java | 8fa6263acc00f17040c4a134ca1f56c78829cf81 | [] | no_license | wenzhaot/luobo_tool | https://github.com/wenzhaot/luobo_tool | 05c2e009039178c50fd878af91f0347632b0c26d | e9798e5251d3d6ba859bb15a00d13f085bc690a8 | refs/heads/master | 2020-03-25T23:23:48.171000 | 2019-09-21T07:09:48 | 2019-09-21T07:09:48 | 144,272,972 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.talkingdata.sdk;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import java.util.HashMap;
/* compiled from: td */
class cl extends Handler {
final /* synthetic */ ck this$0;
cl(ck ckVar, Looper looper) {
this.this$0 = ckVar;
super(looper);
}
public void handleMessage(Message message) {
try {
ck.t = false;
HashMap hashMap = (HashMap) message.obj;
this.this$0.b(String.valueOf(hashMap.get("appId")), String.valueOf(hashMap.get("channelId")), (a) hashMap.get("Features"));
} catch (Throwable th) {
cs.postSDKError(th);
}
}
}
| UTF-8 | Java | 681 | java | cl.java | Java | [] | null | [] | package com.talkingdata.sdk;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import java.util.HashMap;
/* compiled from: td */
class cl extends Handler {
final /* synthetic */ ck this$0;
cl(ck ckVar, Looper looper) {
this.this$0 = ckVar;
super(looper);
}
public void handleMessage(Message message) {
try {
ck.t = false;
HashMap hashMap = (HashMap) message.obj;
this.this$0.b(String.valueOf(hashMap.get("appId")), String.valueOf(hashMap.get("channelId")), (a) hashMap.get("Features"));
} catch (Throwable th) {
cs.postSDKError(th);
}
}
}
| 681 | 0.604993 | 0.600587 | 26 | 25.192308 | 26.2752 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.576923 | false | false | 15 |
b6d3f72974b44a372b653f8f95f5c6f7c853f6a8 | 24,446,953,902,923 | 8de467ce05f8688265f2ca77f8056abb95b31f58 | /src/main/java/sms/TextMessage.java | 0cf892a7012f24d585d3e650934cb526609e9bd0 | [] | no_license | calebbaker194/PittsburgAPI | https://github.com/calebbaker194/PittsburgAPI | 109e74710f76e554b25708867f2fb07a0ec418e1 | 58b067a1ec4c623cbb354b17e43c163e37dd87e4 | refs/heads/master | 2021-08-16T05:23:57.574000 | 2020-08-11T20:02:56 | 2020-08-11T20:02:56 | 212,131,048 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package sms;
import java.util.ArrayList;
public class TextMessage extends helpers.Message{
private String text;
private String recipient;
private ArrayList<String> attachmentList = new ArrayList<String>();
public TextMessage(String text,String recipient, ArrayList<String> tlist)
{
setText(text);
setRecipient(recipient);
setAttachmentList(tlist);
}
public TextMessage(String text,String recipient)
{
setText(text);
setRecipient(recipient);
}
public TextMessage()
{
}
public String getRecipient()
{
return recipient;
}
public void setRecipient(String recipient)
{
this.recipient = recipient;
}
public String getText()
{
return text;
}
public void setText(String text)
{
this.text = text;
}
public ArrayList<String> getAttachmentList()
{
return attachmentList;
}
public void setAttachmentList(ArrayList<String> attachmentName)
{
this.attachmentList = attachmentName;
}
}
| UTF-8 | Java | 936 | java | TextMessage.java | Java | [] | null | [] | package sms;
import java.util.ArrayList;
public class TextMessage extends helpers.Message{
private String text;
private String recipient;
private ArrayList<String> attachmentList = new ArrayList<String>();
public TextMessage(String text,String recipient, ArrayList<String> tlist)
{
setText(text);
setRecipient(recipient);
setAttachmentList(tlist);
}
public TextMessage(String text,String recipient)
{
setText(text);
setRecipient(recipient);
}
public TextMessage()
{
}
public String getRecipient()
{
return recipient;
}
public void setRecipient(String recipient)
{
this.recipient = recipient;
}
public String getText()
{
return text;
}
public void setText(String text)
{
this.text = text;
}
public ArrayList<String> getAttachmentList()
{
return attachmentList;
}
public void setAttachmentList(ArrayList<String> attachmentName)
{
this.attachmentList = attachmentName;
}
}
| 936 | 0.735043 | 0.735043 | 53 | 16.64151 | 19.259983 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.433962 | false | false | 15 |
5984f31e487243ed519ba156b4e8ff079a066432 | 32,487,132,632,081 | e05cf54cd7f2a6a3f95797f0ad4b6891156b82f3 | /out/smali/com/kingcore/uilib/CheckingProgressBar.java | 5b28be0144dabd627185bbad09a992d1f2ca1137 | [] | no_license | chenxiaoyoyo/KROutCode | https://github.com/chenxiaoyoyo/KROutCode | fda014c0bdd9c38b5b79203de91634a71b10540b | f879c2815c4e1d570b6362db7430cb835a605cf0 | refs/heads/master | 2021-01-10T13:37:05.853000 | 2016-02-04T08:03:57 | 2016-02-04T08:03:57 | 49,871,343 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kingcore.uilib; class CheckingProgressBar { void a() { int a;
a=0;// .class public final Lcom/kingcore/uilib/CheckingProgressBar;
a=0;// .super Landroid/view/View;
a=0;// .source "SourceFile"
a=0;//
a=0;//
a=0;// # instance fields
a=0;// .field private ai:F
a=0;//
a=0;// .field private aj:I
a=0;//
a=0;// .field private ak:I
a=0;//
a=0;// .field private al:I
a=0;//
a=0;// .field private am:I
a=0;//
a=0;// .field private an:F
a=0;//
a=0;// .field private ao:F
a=0;//
a=0;// .field private ap:Landroid/graphics/RectF;
a=0;//
a=0;// .field private aq:F
a=0;//
a=0;// .field private ar:Landroid/graphics/Paint;
a=0;//
a=0;// .field private mHandler:Landroid/os/Handler;
a=0;//
a=0;//
a=0;// # direct methods
a=0;// .method public constructor <init>(Landroid/content/Context;)V
a=0;// .locals 0
a=0;//
a=0;// .prologue
a=0;// .line 38
a=0;// invoke-direct {p0, p1}, Landroid/view/View;-><init>(Landroid/content/Context;)V
a=0;//
a=0;// .line 39
a=0;// #p0=(Reference,Lcom/kingcore/uilib/CheckingProgressBar;);
a=0;// invoke-direct {p0}, Lcom/kingcore/uilib/CheckingProgressBar;->init()V
a=0;//
a=0;// .line 40
a=0;// return-void
a=0;// .end method
a=0;//
a=0;// .method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
a=0;// .locals 0
a=0;//
a=0;// .prologue
a=0;// .line 43
a=0;// invoke-direct {p0, p1, p2}, Landroid/view/View;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
a=0;//
a=0;// .line 44
a=0;// #p0=(Reference,Lcom/kingcore/uilib/CheckingProgressBar;);
a=0;// invoke-direct {p0}, Lcom/kingcore/uilib/CheckingProgressBar;->init()V
a=0;//
a=0;// .line 45
a=0;// return-void
a=0;// .end method
a=0;//
a=0;// .method public static synthetic a(Lcom/kingcore/uilib/CheckingProgressBar;F)F
a=0;// .locals 1
a=0;//
a=0;// .prologue
a=0;// .line 19
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// #v0=(Integer);
a=0;// add-float/2addr v0, p1
a=0;//
a=0;// #v0=(Float);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// return v0
a=0;// .end method
a=0;//
a=0;// .method public static synthetic a(Lcom/kingcore/uilib/CheckingProgressBar;)I
a=0;// .locals 1
a=0;//
a=0;// .prologue
a=0;// .line 19
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aj:I
a=0;//
a=0;// #v0=(Integer);
a=0;// return v0
a=0;// .end method
a=0;//
a=0;// .method public static synthetic b(Lcom/kingcore/uilib/CheckingProgressBar;)F
a=0;// .locals 1
a=0;//
a=0;// .prologue
a=0;// .line 19
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// #v0=(Integer);
a=0;// return v0
a=0;// .end method
a=0;//
a=0;// .method public static synthetic b(Lcom/kingcore/uilib/CheckingProgressBar;F)F
a=0;// .locals 1
a=0;//
a=0;// .prologue
a=0;// .line 19
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// #v0=(Integer);
a=0;// sub-float/2addr v0, p1
a=0;//
a=0;// #v0=(Float);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// return v0
a=0;// .end method
a=0;//
a=0;// .method private init()V
a=0;// .locals 8
a=0;//
a=0;// .prologue
a=0;// const/4 v7, 0x3
a=0;//
a=0;// #v7=(PosByte);
a=0;// const/4 v5, 0x1
a=0;//
a=0;// #v5=(One);
a=0;// const/4 v4, 0x0
a=0;//
a=0;// .line 48
a=0;// #v4=(Null);
a=0;// const/high16 v0, 0x43b40000 # 360.0f
a=0;//
a=0;// #v0=(Integer);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ai:F
a=0;//
a=0;// .line 49
a=0;// const/16 v0, 0xa
a=0;//
a=0;// #v0=(PosByte);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aj:I
a=0;//
a=0;// .line 50
a=0;// invoke-virtual {p0}, Lcom/kingcore/uilib/CheckingProgressBar;->getResources()Landroid/content/res/Resources;
a=0;//
a=0;// move-result-object v0
a=0;//
a=0;// #v0=(Reference,Landroid/content/res/Resources;);
a=0;// const v1, 0x7f080061
a=0;//
a=0;// #v1=(Integer);
a=0;// invoke-virtual {v0, v1}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I
a=0;//
a=0;// move-result v0
a=0;//
a=0;// #v0=(Integer);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ak:I
a=0;//
a=0;// .line 52
a=0;// const/high16 v0, 0x42700000 # 60.0f
a=0;//
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// .line 54
a=0;// new-instance v0, Landroid/graphics/Paint;
a=0;//
a=0;// #v0=(UninitRef,Landroid/graphics/Paint;);
a=0;// invoke-direct {v0, v5}, Landroid/graphics/Paint;-><init>(I)V
a=0;//
a=0;// #v0=(Reference,Landroid/graphics/Paint;);
a=0;// iput-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// .line 55
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// sget-object v1, Landroid/graphics/Paint$Style;->STROKE:Landroid/graphics/Paint$Style;
a=0;//
a=0;// #v1=(Reference,Landroid/graphics/Paint$Style;);
a=0;// invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V
a=0;//
a=0;// .line 56
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// sget-object v1, Landroid/graphics/Paint$Cap;->ROUND:Landroid/graphics/Paint$Cap;
a=0;//
a=0;// invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStrokeCap(Landroid/graphics/Paint$Cap;)V
a=0;//
a=0;// .line 58
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// iget v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ak:I
a=0;//
a=0;// #v1=(Integer);
a=0;// int-to-float v1, v1
a=0;//
a=0;// #v1=(Float);
a=0;// invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStrokeWidth(F)V
a=0;//
a=0;// .line 59
a=0;// invoke-virtual {p0}, Lcom/kingcore/uilib/CheckingProgressBar;->getResources()Landroid/content/res/Resources;
a=0;//
a=0;// move-result-object v0
a=0;//
a=0;// const v1, 0x7f08005f
a=0;//
a=0;// #v1=(Integer);
a=0;// invoke-virtual {v0, v1}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I
a=0;//
a=0;// move-result v0
a=0;//
a=0;// #v0=(Integer);
a=0;// div-int/lit8 v0, v0, 0x2
a=0;//
a=0;// int-to-float v0, v0
a=0;//
a=0;// #v0=(Float);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ao:F
a=0;//
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->an:F
a=0;//
a=0;// .line 61
a=0;// new-instance v0, Landroid/graphics/SweepGradient;
a=0;//
a=0;// #v0=(UninitRef,Landroid/graphics/SweepGradient;);
a=0;// iget v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->an:F
a=0;//
a=0;// iget v2, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ao:F
a=0;//
a=0;// #v2=(Integer);
a=0;// new-array v3, v7, [I
a=0;//
a=0;// #v3=(Reference,[I);
a=0;// aput v4, v3, v4
a=0;//
a=0;// const v4, 0xe5f2fd
a=0;//
a=0;// #v4=(Integer);
a=0;// aput v4, v3, v5
a=0;//
a=0;// const/4 v4, 0x2
a=0;//
a=0;// #v4=(PosByte);
a=0;// invoke-virtual {p0}, Lcom/kingcore/uilib/CheckingProgressBar;->getResources()Landroid/content/res/Resources;
a=0;//
a=0;// move-result-object v5
a=0;//
a=0;// #v5=(Reference,Landroid/content/res/Resources;);
a=0;// const v6, 0x7f070009
a=0;//
a=0;// #v6=(Integer);
a=0;// invoke-virtual {v5, v6}, Landroid/content/res/Resources;->getColor(I)I
a=0;//
a=0;// move-result v5
a=0;//
a=0;// #v5=(Integer);
a=0;// aput v5, v3, v4
a=0;//
a=0;// new-array v4, v7, [F
a=0;//
a=0;// #v4=(Reference,[F);
a=0;// fill-array-data v4, :array_0
a=0;//
a=0;// invoke-direct {v0, v1, v2, v3, v4}, Landroid/graphics/SweepGradient;-><init>(FF[I[F)V
a=0;//
a=0;// .line 66
a=0;// #v0=(Reference,Landroid/graphics/SweepGradient;);
a=0;// iget-object v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// #v1=(Reference,Landroid/graphics/Paint;);
a=0;// invoke-virtual {v1, v0}, Landroid/graphics/Paint;->setShader(Landroid/graphics/Shader;)Landroid/graphics/Shader;
a=0;//
a=0;// .line 67
a=0;// return-void
a=0;//
a=0;// .line 61
a=0;// :array_0
a=0;// .array-data 4
a=0;// 0x0
a=0;// 0x3e99999a # 0.3f
a=0;// 0x3f800000 # 1.0f
a=0;// .end array-data
a=0;// .end method
a=0;//
a=0;//
a=0;// # virtual methods
a=0;// .method protected onAttachedToWindow()V
a=0;// .locals 2
a=0;//
a=0;// .prologue
a=0;// .line 91
a=0;// invoke-super {p0}, Landroid/view/View;->onAttachedToWindow()V
a=0;//
a=0;// .line 92
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// #v0=(Reference,Landroid/os/Handler;);
a=0;// if-nez v0, :cond_0
a=0;//
a=0;// .line 93
a=0;// new-instance v0, Lcom/kingroot/kinguser/ad;
a=0;//
a=0;// #v0=(UninitRef,Lcom/kingroot/kinguser/ad;);
a=0;// invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;
a=0;//
a=0;// move-result-object v1
a=0;//
a=0;// #v1=(Reference,Landroid/os/Looper;);
a=0;// invoke-direct {v0, p0, v1}, Lcom/kingroot/kinguser/ad;-><init>(Lcom/kingcore/uilib/CheckingProgressBar;Landroid/os/Looper;)V
a=0;//
a=0;// #v0=(Reference,Lcom/kingroot/kinguser/ad;);
a=0;// iput-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// .line 106
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// const/4 v1, 0x0
a=0;//
a=0;// #v1=(Null);
a=0;// invoke-virtual {v0, v1}, Landroid/os/Handler;->obtainMessage(I)Landroid/os/Message;
a=0;//
a=0;// move-result-object v0
a=0;//
a=0;// invoke-virtual {v0}, Landroid/os/Message;->sendToTarget()V
a=0;//
a=0;// .line 108
a=0;// :cond_0
a=0;// #v1=(Conflicted);
a=0;// return-void
a=0;// .end method
a=0;//
a=0;// .method protected onDetachedFromWindow()V
a=0;// .locals 2
a=0;//
a=0;// .prologue
a=0;// .line 112
a=0;// invoke-super {p0}, Landroid/view/View;->onDetachedFromWindow()V
a=0;//
a=0;// .line 113
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// #v0=(Reference,Landroid/os/Handler;);
a=0;// if-eqz v0, :cond_0
a=0;//
a=0;// .line 114
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// const/4 v1, 0x0
a=0;//
a=0;// #v1=(Null);
a=0;// invoke-virtual {v0, v1}, Landroid/os/Handler;->removeMessages(I)V
a=0;//
a=0;// .line 115
a=0;// const/4 v0, 0x0
a=0;//
a=0;// #v0=(Null);
a=0;// iput-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// .line 117
a=0;// :cond_0
a=0;// #v0=(Reference,Landroid/os/Handler;);v1=(Conflicted);
a=0;// return-void
a=0;// .end method
a=0;//
a=0;// .method protected onDraw(Landroid/graphics/Canvas;)V
a=0;// .locals 6
a=0;//
a=0;// .prologue
a=0;// .line 71
a=0;// invoke-virtual {p1}, Landroid/graphics/Canvas;->save()I
a=0;//
a=0;// .line 72
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// #v0=(Integer);
a=0;// iget v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->an:F
a=0;//
a=0;// #v1=(Integer);
a=0;// iget v2, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ao:F
a=0;//
a=0;// #v2=(Integer);
a=0;// invoke-virtual {p1, v0, v1, v2}, Landroid/graphics/Canvas;->rotate(FFF)V
a=0;//
a=0;// .line 73
a=0;// iget-object v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ap:Landroid/graphics/RectF;
a=0;//
a=0;// #v1=(Reference,Landroid/graphics/RectF;);
a=0;// const/high16 v2, 0x43340000 # 180.0f
a=0;//
a=0;// iget v3, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ai:F
a=0;//
a=0;// #v3=(Integer);
a=0;// const/4 v4, 0x0
a=0;//
a=0;// #v4=(Null);
a=0;// iget-object v5, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// #v5=(Reference,Landroid/graphics/Paint;);
a=0;// move-object v0, p1
a=0;//
a=0;// #v0=(Reference,Landroid/graphics/Canvas;);
a=0;// invoke-virtual/range {v0 .. v5}, Landroid/graphics/Canvas;->drawArc(Landroid/graphics/RectF;FFZLandroid/graphics/Paint;)V
a=0;//
a=0;// .line 74
a=0;// invoke-virtual {p1}, Landroid/graphics/Canvas;->restore()V
a=0;//
a=0;// .line 75
a=0;// return-void
a=0;// .end method
a=0;//
a=0;// .method protected onSizeChanged(IIII)V
a=0;// .locals 6
a=0;//
a=0;// .prologue
a=0;// const/4 v4, 0x0
a=0;//
a=0;// .line 79
a=0;// #v4=(Null);
a=0;// invoke-super {p0, p1, p2, p3, p4}, Landroid/view/View;->onSizeChanged(IIII)V
a=0;//
a=0;// .line 80
a=0;// iput p1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->al:I
a=0;//
a=0;// .line 81
a=0;// iput p2, p0, Lcom/kingcore/uilib/CheckingProgressBar;->am:I
a=0;//
a=0;// .line 82
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->al:I
a=0;//
a=0;// #v0=(Integer);
a=0;// div-int/lit8 v0, v0, 0x2
a=0;//
a=0;// int-to-float v0, v0
a=0;//
a=0;// #v0=(Float);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->an:F
a=0;//
a=0;// .line 83
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->am:I
a=0;//
a=0;// #v0=(Integer);
a=0;// div-int/lit8 v0, v0, 0x2
a=0;//
a=0;// int-to-float v0, v0
a=0;//
a=0;// #v0=(Float);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ao:F
a=0;//
a=0;// .line 84
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ak:I
a=0;//
a=0;// #v0=(Integer);
a=0;// int-to-double v0, v0
a=0;//
a=0;// #v0=(DoubleLo);v1=(DoubleHi);
a=0;// const-wide/high16 v2, 0x4000000000000000L # 2.0
a=0;//
a=0;// #v2=(LongLo);v3=(LongHi);
a=0;// div-double/2addr v0, v2
a=0;//
a=0;// invoke-static {v0, v1}, Ljava/lang/Math;->ceil(D)D
a=0;//
a=0;// move-result-wide v0
a=0;//
a=0;// double-to-float v0, v0
a=0;//
a=0;// #v0=(Float);
a=0;// const/high16 v1, 0x3f800000 # 1.0f
a=0;//
a=0;// #v1=(Integer);
a=0;// add-float/2addr v0, v1
a=0;//
a=0;// .line 85
a=0;// new-instance v1, Landroid/graphics/RectF;
a=0;//
a=0;// #v1=(UninitRef,Landroid/graphics/RectF;);
a=0;// add-float v2, v4, v0
a=0;//
a=0;// #v2=(Float);
a=0;// add-float v3, v4, v0
a=0;//
a=0;// #v3=(Float);
a=0;// iget v4, p0, Lcom/kingcore/uilib/CheckingProgressBar;->al:I
a=0;//
a=0;// #v4=(Integer);
a=0;// int-to-float v4, v4
a=0;//
a=0;// #v4=(Float);
a=0;// sub-float/2addr v4, v0
a=0;//
a=0;// iget v5, p0, Lcom/kingcore/uilib/CheckingProgressBar;->am:I
a=0;//
a=0;// #v5=(Integer);
a=0;// int-to-float v5, v5
a=0;//
a=0;// #v5=(Float);
a=0;// sub-float v0, v5, v0
a=0;//
a=0;// invoke-direct {v1, v2, v3, v4, v0}, Landroid/graphics/RectF;-><init>(FFFF)V
a=0;//
a=0;// #v1=(Reference,Landroid/graphics/RectF;);
a=0;// iput-object v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ap:Landroid/graphics/RectF;
a=0;//
a=0;// .line 87
a=0;// return-void
a=0;// .end method
}}
| UTF-8 | Java | 15,731 | java | CheckingProgressBar.java | Java | [] | null | [] | package com.kingcore.uilib; class CheckingProgressBar { void a() { int a;
a=0;// .class public final Lcom/kingcore/uilib/CheckingProgressBar;
a=0;// .super Landroid/view/View;
a=0;// .source "SourceFile"
a=0;//
a=0;//
a=0;// # instance fields
a=0;// .field private ai:F
a=0;//
a=0;// .field private aj:I
a=0;//
a=0;// .field private ak:I
a=0;//
a=0;// .field private al:I
a=0;//
a=0;// .field private am:I
a=0;//
a=0;// .field private an:F
a=0;//
a=0;// .field private ao:F
a=0;//
a=0;// .field private ap:Landroid/graphics/RectF;
a=0;//
a=0;// .field private aq:F
a=0;//
a=0;// .field private ar:Landroid/graphics/Paint;
a=0;//
a=0;// .field private mHandler:Landroid/os/Handler;
a=0;//
a=0;//
a=0;// # direct methods
a=0;// .method public constructor <init>(Landroid/content/Context;)V
a=0;// .locals 0
a=0;//
a=0;// .prologue
a=0;// .line 38
a=0;// invoke-direct {p0, p1}, Landroid/view/View;-><init>(Landroid/content/Context;)V
a=0;//
a=0;// .line 39
a=0;// #p0=(Reference,Lcom/kingcore/uilib/CheckingProgressBar;);
a=0;// invoke-direct {p0}, Lcom/kingcore/uilib/CheckingProgressBar;->init()V
a=0;//
a=0;// .line 40
a=0;// return-void
a=0;// .end method
a=0;//
a=0;// .method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
a=0;// .locals 0
a=0;//
a=0;// .prologue
a=0;// .line 43
a=0;// invoke-direct {p0, p1, p2}, Landroid/view/View;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
a=0;//
a=0;// .line 44
a=0;// #p0=(Reference,Lcom/kingcore/uilib/CheckingProgressBar;);
a=0;// invoke-direct {p0}, Lcom/kingcore/uilib/CheckingProgressBar;->init()V
a=0;//
a=0;// .line 45
a=0;// return-void
a=0;// .end method
a=0;//
a=0;// .method public static synthetic a(Lcom/kingcore/uilib/CheckingProgressBar;F)F
a=0;// .locals 1
a=0;//
a=0;// .prologue
a=0;// .line 19
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// #v0=(Integer);
a=0;// add-float/2addr v0, p1
a=0;//
a=0;// #v0=(Float);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// return v0
a=0;// .end method
a=0;//
a=0;// .method public static synthetic a(Lcom/kingcore/uilib/CheckingProgressBar;)I
a=0;// .locals 1
a=0;//
a=0;// .prologue
a=0;// .line 19
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aj:I
a=0;//
a=0;// #v0=(Integer);
a=0;// return v0
a=0;// .end method
a=0;//
a=0;// .method public static synthetic b(Lcom/kingcore/uilib/CheckingProgressBar;)F
a=0;// .locals 1
a=0;//
a=0;// .prologue
a=0;// .line 19
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// #v0=(Integer);
a=0;// return v0
a=0;// .end method
a=0;//
a=0;// .method public static synthetic b(Lcom/kingcore/uilib/CheckingProgressBar;F)F
a=0;// .locals 1
a=0;//
a=0;// .prologue
a=0;// .line 19
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// #v0=(Integer);
a=0;// sub-float/2addr v0, p1
a=0;//
a=0;// #v0=(Float);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// return v0
a=0;// .end method
a=0;//
a=0;// .method private init()V
a=0;// .locals 8
a=0;//
a=0;// .prologue
a=0;// const/4 v7, 0x3
a=0;//
a=0;// #v7=(PosByte);
a=0;// const/4 v5, 0x1
a=0;//
a=0;// #v5=(One);
a=0;// const/4 v4, 0x0
a=0;//
a=0;// .line 48
a=0;// #v4=(Null);
a=0;// const/high16 v0, 0x43b40000 # 360.0f
a=0;//
a=0;// #v0=(Integer);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ai:F
a=0;//
a=0;// .line 49
a=0;// const/16 v0, 0xa
a=0;//
a=0;// #v0=(PosByte);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aj:I
a=0;//
a=0;// .line 50
a=0;// invoke-virtual {p0}, Lcom/kingcore/uilib/CheckingProgressBar;->getResources()Landroid/content/res/Resources;
a=0;//
a=0;// move-result-object v0
a=0;//
a=0;// #v0=(Reference,Landroid/content/res/Resources;);
a=0;// const v1, 0x7f080061
a=0;//
a=0;// #v1=(Integer);
a=0;// invoke-virtual {v0, v1}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I
a=0;//
a=0;// move-result v0
a=0;//
a=0;// #v0=(Integer);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ak:I
a=0;//
a=0;// .line 52
a=0;// const/high16 v0, 0x42700000 # 60.0f
a=0;//
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// .line 54
a=0;// new-instance v0, Landroid/graphics/Paint;
a=0;//
a=0;// #v0=(UninitRef,Landroid/graphics/Paint;);
a=0;// invoke-direct {v0, v5}, Landroid/graphics/Paint;-><init>(I)V
a=0;//
a=0;// #v0=(Reference,Landroid/graphics/Paint;);
a=0;// iput-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// .line 55
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// sget-object v1, Landroid/graphics/Paint$Style;->STROKE:Landroid/graphics/Paint$Style;
a=0;//
a=0;// #v1=(Reference,Landroid/graphics/Paint$Style;);
a=0;// invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V
a=0;//
a=0;// .line 56
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// sget-object v1, Landroid/graphics/Paint$Cap;->ROUND:Landroid/graphics/Paint$Cap;
a=0;//
a=0;// invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStrokeCap(Landroid/graphics/Paint$Cap;)V
a=0;//
a=0;// .line 58
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// iget v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ak:I
a=0;//
a=0;// #v1=(Integer);
a=0;// int-to-float v1, v1
a=0;//
a=0;// #v1=(Float);
a=0;// invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStrokeWidth(F)V
a=0;//
a=0;// .line 59
a=0;// invoke-virtual {p0}, Lcom/kingcore/uilib/CheckingProgressBar;->getResources()Landroid/content/res/Resources;
a=0;//
a=0;// move-result-object v0
a=0;//
a=0;// const v1, 0x7f08005f
a=0;//
a=0;// #v1=(Integer);
a=0;// invoke-virtual {v0, v1}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I
a=0;//
a=0;// move-result v0
a=0;//
a=0;// #v0=(Integer);
a=0;// div-int/lit8 v0, v0, 0x2
a=0;//
a=0;// int-to-float v0, v0
a=0;//
a=0;// #v0=(Float);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ao:F
a=0;//
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->an:F
a=0;//
a=0;// .line 61
a=0;// new-instance v0, Landroid/graphics/SweepGradient;
a=0;//
a=0;// #v0=(UninitRef,Landroid/graphics/SweepGradient;);
a=0;// iget v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->an:F
a=0;//
a=0;// iget v2, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ao:F
a=0;//
a=0;// #v2=(Integer);
a=0;// new-array v3, v7, [I
a=0;//
a=0;// #v3=(Reference,[I);
a=0;// aput v4, v3, v4
a=0;//
a=0;// const v4, 0xe5f2fd
a=0;//
a=0;// #v4=(Integer);
a=0;// aput v4, v3, v5
a=0;//
a=0;// const/4 v4, 0x2
a=0;//
a=0;// #v4=(PosByte);
a=0;// invoke-virtual {p0}, Lcom/kingcore/uilib/CheckingProgressBar;->getResources()Landroid/content/res/Resources;
a=0;//
a=0;// move-result-object v5
a=0;//
a=0;// #v5=(Reference,Landroid/content/res/Resources;);
a=0;// const v6, 0x7f070009
a=0;//
a=0;// #v6=(Integer);
a=0;// invoke-virtual {v5, v6}, Landroid/content/res/Resources;->getColor(I)I
a=0;//
a=0;// move-result v5
a=0;//
a=0;// #v5=(Integer);
a=0;// aput v5, v3, v4
a=0;//
a=0;// new-array v4, v7, [F
a=0;//
a=0;// #v4=(Reference,[F);
a=0;// fill-array-data v4, :array_0
a=0;//
a=0;// invoke-direct {v0, v1, v2, v3, v4}, Landroid/graphics/SweepGradient;-><init>(FF[I[F)V
a=0;//
a=0;// .line 66
a=0;// #v0=(Reference,Landroid/graphics/SweepGradient;);
a=0;// iget-object v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// #v1=(Reference,Landroid/graphics/Paint;);
a=0;// invoke-virtual {v1, v0}, Landroid/graphics/Paint;->setShader(Landroid/graphics/Shader;)Landroid/graphics/Shader;
a=0;//
a=0;// .line 67
a=0;// return-void
a=0;//
a=0;// .line 61
a=0;// :array_0
a=0;// .array-data 4
a=0;// 0x0
a=0;// 0x3e99999a # 0.3f
a=0;// 0x3f800000 # 1.0f
a=0;// .end array-data
a=0;// .end method
a=0;//
a=0;//
a=0;// # virtual methods
a=0;// .method protected onAttachedToWindow()V
a=0;// .locals 2
a=0;//
a=0;// .prologue
a=0;// .line 91
a=0;// invoke-super {p0}, Landroid/view/View;->onAttachedToWindow()V
a=0;//
a=0;// .line 92
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// #v0=(Reference,Landroid/os/Handler;);
a=0;// if-nez v0, :cond_0
a=0;//
a=0;// .line 93
a=0;// new-instance v0, Lcom/kingroot/kinguser/ad;
a=0;//
a=0;// #v0=(UninitRef,Lcom/kingroot/kinguser/ad;);
a=0;// invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;
a=0;//
a=0;// move-result-object v1
a=0;//
a=0;// #v1=(Reference,Landroid/os/Looper;);
a=0;// invoke-direct {v0, p0, v1}, Lcom/kingroot/kinguser/ad;-><init>(Lcom/kingcore/uilib/CheckingProgressBar;Landroid/os/Looper;)V
a=0;//
a=0;// #v0=(Reference,Lcom/kingroot/kinguser/ad;);
a=0;// iput-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// .line 106
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// const/4 v1, 0x0
a=0;//
a=0;// #v1=(Null);
a=0;// invoke-virtual {v0, v1}, Landroid/os/Handler;->obtainMessage(I)Landroid/os/Message;
a=0;//
a=0;// move-result-object v0
a=0;//
a=0;// invoke-virtual {v0}, Landroid/os/Message;->sendToTarget()V
a=0;//
a=0;// .line 108
a=0;// :cond_0
a=0;// #v1=(Conflicted);
a=0;// return-void
a=0;// .end method
a=0;//
a=0;// .method protected onDetachedFromWindow()V
a=0;// .locals 2
a=0;//
a=0;// .prologue
a=0;// .line 112
a=0;// invoke-super {p0}, Landroid/view/View;->onDetachedFromWindow()V
a=0;//
a=0;// .line 113
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// #v0=(Reference,Landroid/os/Handler;);
a=0;// if-eqz v0, :cond_0
a=0;//
a=0;// .line 114
a=0;// iget-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// const/4 v1, 0x0
a=0;//
a=0;// #v1=(Null);
a=0;// invoke-virtual {v0, v1}, Landroid/os/Handler;->removeMessages(I)V
a=0;//
a=0;// .line 115
a=0;// const/4 v0, 0x0
a=0;//
a=0;// #v0=(Null);
a=0;// iput-object v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->mHandler:Landroid/os/Handler;
a=0;//
a=0;// .line 117
a=0;// :cond_0
a=0;// #v0=(Reference,Landroid/os/Handler;);v1=(Conflicted);
a=0;// return-void
a=0;// .end method
a=0;//
a=0;// .method protected onDraw(Landroid/graphics/Canvas;)V
a=0;// .locals 6
a=0;//
a=0;// .prologue
a=0;// .line 71
a=0;// invoke-virtual {p1}, Landroid/graphics/Canvas;->save()I
a=0;//
a=0;// .line 72
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->aq:F
a=0;//
a=0;// #v0=(Integer);
a=0;// iget v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->an:F
a=0;//
a=0;// #v1=(Integer);
a=0;// iget v2, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ao:F
a=0;//
a=0;// #v2=(Integer);
a=0;// invoke-virtual {p1, v0, v1, v2}, Landroid/graphics/Canvas;->rotate(FFF)V
a=0;//
a=0;// .line 73
a=0;// iget-object v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ap:Landroid/graphics/RectF;
a=0;//
a=0;// #v1=(Reference,Landroid/graphics/RectF;);
a=0;// const/high16 v2, 0x43340000 # 180.0f
a=0;//
a=0;// iget v3, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ai:F
a=0;//
a=0;// #v3=(Integer);
a=0;// const/4 v4, 0x0
a=0;//
a=0;// #v4=(Null);
a=0;// iget-object v5, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ar:Landroid/graphics/Paint;
a=0;//
a=0;// #v5=(Reference,Landroid/graphics/Paint;);
a=0;// move-object v0, p1
a=0;//
a=0;// #v0=(Reference,Landroid/graphics/Canvas;);
a=0;// invoke-virtual/range {v0 .. v5}, Landroid/graphics/Canvas;->drawArc(Landroid/graphics/RectF;FFZLandroid/graphics/Paint;)V
a=0;//
a=0;// .line 74
a=0;// invoke-virtual {p1}, Landroid/graphics/Canvas;->restore()V
a=0;//
a=0;// .line 75
a=0;// return-void
a=0;// .end method
a=0;//
a=0;// .method protected onSizeChanged(IIII)V
a=0;// .locals 6
a=0;//
a=0;// .prologue
a=0;// const/4 v4, 0x0
a=0;//
a=0;// .line 79
a=0;// #v4=(Null);
a=0;// invoke-super {p0, p1, p2, p3, p4}, Landroid/view/View;->onSizeChanged(IIII)V
a=0;//
a=0;// .line 80
a=0;// iput p1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->al:I
a=0;//
a=0;// .line 81
a=0;// iput p2, p0, Lcom/kingcore/uilib/CheckingProgressBar;->am:I
a=0;//
a=0;// .line 82
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->al:I
a=0;//
a=0;// #v0=(Integer);
a=0;// div-int/lit8 v0, v0, 0x2
a=0;//
a=0;// int-to-float v0, v0
a=0;//
a=0;// #v0=(Float);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->an:F
a=0;//
a=0;// .line 83
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->am:I
a=0;//
a=0;// #v0=(Integer);
a=0;// div-int/lit8 v0, v0, 0x2
a=0;//
a=0;// int-to-float v0, v0
a=0;//
a=0;// #v0=(Float);
a=0;// iput v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ao:F
a=0;//
a=0;// .line 84
a=0;// iget v0, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ak:I
a=0;//
a=0;// #v0=(Integer);
a=0;// int-to-double v0, v0
a=0;//
a=0;// #v0=(DoubleLo);v1=(DoubleHi);
a=0;// const-wide/high16 v2, 0x4000000000000000L # 2.0
a=0;//
a=0;// #v2=(LongLo);v3=(LongHi);
a=0;// div-double/2addr v0, v2
a=0;//
a=0;// invoke-static {v0, v1}, Ljava/lang/Math;->ceil(D)D
a=0;//
a=0;// move-result-wide v0
a=0;//
a=0;// double-to-float v0, v0
a=0;//
a=0;// #v0=(Float);
a=0;// const/high16 v1, 0x3f800000 # 1.0f
a=0;//
a=0;// #v1=(Integer);
a=0;// add-float/2addr v0, v1
a=0;//
a=0;// .line 85
a=0;// new-instance v1, Landroid/graphics/RectF;
a=0;//
a=0;// #v1=(UninitRef,Landroid/graphics/RectF;);
a=0;// add-float v2, v4, v0
a=0;//
a=0;// #v2=(Float);
a=0;// add-float v3, v4, v0
a=0;//
a=0;// #v3=(Float);
a=0;// iget v4, p0, Lcom/kingcore/uilib/CheckingProgressBar;->al:I
a=0;//
a=0;// #v4=(Integer);
a=0;// int-to-float v4, v4
a=0;//
a=0;// #v4=(Float);
a=0;// sub-float/2addr v4, v0
a=0;//
a=0;// iget v5, p0, Lcom/kingcore/uilib/CheckingProgressBar;->am:I
a=0;//
a=0;// #v5=(Integer);
a=0;// int-to-float v5, v5
a=0;//
a=0;// #v5=(Float);
a=0;// sub-float v0, v5, v0
a=0;//
a=0;// invoke-direct {v1, v2, v3, v4, v0}, Landroid/graphics/RectF;-><init>(FFFF)V
a=0;//
a=0;// #v1=(Reference,Landroid/graphics/RectF;);
a=0;// iput-object v1, p0, Lcom/kingcore/uilib/CheckingProgressBar;->ap:Landroid/graphics/RectF;
a=0;//
a=0;// .line 87
a=0;// return-void
a=0;// .end method
}}
| 15,731 | 0.588329 | 0.518276 | 504 | 30.212301 | 28.115347 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.892857 | false | false | 15 |
7c86b2ee87ab80c6ccbfe27de52a877670f34d86 | 9,792,525,442,185 | df33222c9d2abfd50f1ff454d28ae429135d04e1 | /modules/collapse/src/collapse/CollapseSimulatorGUI.java | 4afb0a8e3c93880f90175599b62b00965e8517a8 | [
"BSD-3-Clause"
] | permissive | roborescue/rcrs-server | https://github.com/roborescue/rcrs-server | 40039fae44b171d4beec12c320bba55f51122c3d | 0cfa042db2c36e14a918395139cd73124413c299 | refs/heads/master | 2023-06-09T16:57:25.813000 | 2023-06-02T06:44:13 | 2023-06-02T06:44:13 | 99,498,612 | 39 | 43 | BSD-3-Clause | false | 2023-02-06T13:46:34 | 2017-08-06T16:18:45 | 2023-02-03T07:37:05 | 2023-02-06T13:46:31 | 75,659 | 25 | 34 | 3 | Java | false | false | package collapse;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import java.awt.GridLayout;
/**
GUI for the collapse simulator.
*/
public class CollapseSimulatorGUI extends JPanel {
private JLabel timeLabel;
private JLabel statusLabel;
private JProgressBar collapseProgress;
private JProgressBar fireProgress;
private JProgressBar blockadeProgress;
private int collapse;
private int fire;
private int block;
/**
Construct a collapse simulator GUI.
*/
public CollapseSimulatorGUI() {
super(new GridLayout(0, 2));
timeLabel = new JLabel("Not started");
statusLabel = new JLabel("Not started");
collapseProgress = new JProgressBar(0, 1);
fireProgress = new JProgressBar(0, 1);
blockadeProgress = new JProgressBar(0, 1);
collapseProgress.setStringPainted(true);
fireProgress.setStringPainted(true);
blockadeProgress.setStringPainted(true);
add(new JLabel("Timestep"));
add(timeLabel);
add(new JLabel("Status"));
add(statusLabel);
add(new JLabel("Collapsing buildings"));
add(collapseProgress);
add(new JLabel("Fire damage"));
add(fireProgress);
add(new JLabel("Creating blockades"));
add(blockadeProgress);
}
/**
Notify the gui that a new timestep has started.
@param time The timestep.
*/
void timestep(final int time) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
timeLabel.setText(String.valueOf(time));
collapseProgress.setValue(0);
fireProgress.setValue(0);
blockadeProgress.setValue(0);
collapse = 0;
fire = 0;
block = 0;
}
});
}
/**
Notify the gui that collapse computation has begun.
@param buildingCount The number of buildings to process.
*/
void startCollapse(final int buildingCount) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusLabel.setText("Collapsing buildings");
collapseProgress.setMaximum(buildingCount);
collapseProgress.setValue(0);
collapse = 0;
}
});
}
/**
Notify the gui that a building collapse has been processed.
*/
void bumpCollapse() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
collapseProgress.setValue(++collapse);
}
});
}
/**
Notify the gui that building collapse computation is complete.
*/
void endCollapse() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
collapseProgress.setValue(collapseProgress.getMaximum());
}
});
}
/**
Notify the gui that fire collapse computation has begun.
@param buildingCount The number of buildings to process.
*/
void startFire(final int buildingCount) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusLabel.setText("Fire damage");
fireProgress.setMaximum(buildingCount);
fireProgress.setValue(0);
fire = 0;
}
});
}
/**
Notify the gui that a fire collapse has been processed.
*/
void bumpFire() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
fireProgress.setValue(++fire);
}
});
}
/**
Notify the gui that fire collapse computation is complete.
*/
void endFire() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
fireProgress.setValue(fireProgress.getMaximum());
}
});
}
/**
Notify the gui that blockade generation has begun.
@param buildingCount The number of buildings to process.
*/
void startBlock(final int buildingCount) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusLabel.setText("Computing blockades");
if (buildingCount == 0) {
blockadeProgress.setMaximum(1);
blockadeProgress.setValue(1);
}
else {
blockadeProgress.setMaximum(buildingCount);
blockadeProgress.setValue(0);
block = 0;
}
}
});
}
/**
Notify the gui that blockade generation for a building has been processed.
*/
void bumpBlock() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
blockadeProgress.setValue(++block);
}
});
}
/**
Notify the gui that blockade generation is complete.
*/
void endBlock() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
blockadeProgress.setValue(blockadeProgress.getMaximum());
statusLabel.setText("Done");
}
});
}
} | UTF-8 | Java | 5,887 | java | CollapseSimulatorGUI.java | Java | [] | null | [] | package collapse;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import java.awt.GridLayout;
/**
GUI for the collapse simulator.
*/
public class CollapseSimulatorGUI extends JPanel {
private JLabel timeLabel;
private JLabel statusLabel;
private JProgressBar collapseProgress;
private JProgressBar fireProgress;
private JProgressBar blockadeProgress;
private int collapse;
private int fire;
private int block;
/**
Construct a collapse simulator GUI.
*/
public CollapseSimulatorGUI() {
super(new GridLayout(0, 2));
timeLabel = new JLabel("Not started");
statusLabel = new JLabel("Not started");
collapseProgress = new JProgressBar(0, 1);
fireProgress = new JProgressBar(0, 1);
blockadeProgress = new JProgressBar(0, 1);
collapseProgress.setStringPainted(true);
fireProgress.setStringPainted(true);
blockadeProgress.setStringPainted(true);
add(new JLabel("Timestep"));
add(timeLabel);
add(new JLabel("Status"));
add(statusLabel);
add(new JLabel("Collapsing buildings"));
add(collapseProgress);
add(new JLabel("Fire damage"));
add(fireProgress);
add(new JLabel("Creating blockades"));
add(blockadeProgress);
}
/**
Notify the gui that a new timestep has started.
@param time The timestep.
*/
void timestep(final int time) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
timeLabel.setText(String.valueOf(time));
collapseProgress.setValue(0);
fireProgress.setValue(0);
blockadeProgress.setValue(0);
collapse = 0;
fire = 0;
block = 0;
}
});
}
/**
Notify the gui that collapse computation has begun.
@param buildingCount The number of buildings to process.
*/
void startCollapse(final int buildingCount) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusLabel.setText("Collapsing buildings");
collapseProgress.setMaximum(buildingCount);
collapseProgress.setValue(0);
collapse = 0;
}
});
}
/**
Notify the gui that a building collapse has been processed.
*/
void bumpCollapse() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
collapseProgress.setValue(++collapse);
}
});
}
/**
Notify the gui that building collapse computation is complete.
*/
void endCollapse() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
collapseProgress.setValue(collapseProgress.getMaximum());
}
});
}
/**
Notify the gui that fire collapse computation has begun.
@param buildingCount The number of buildings to process.
*/
void startFire(final int buildingCount) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusLabel.setText("Fire damage");
fireProgress.setMaximum(buildingCount);
fireProgress.setValue(0);
fire = 0;
}
});
}
/**
Notify the gui that a fire collapse has been processed.
*/
void bumpFire() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
fireProgress.setValue(++fire);
}
});
}
/**
Notify the gui that fire collapse computation is complete.
*/
void endFire() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
fireProgress.setValue(fireProgress.getMaximum());
}
});
}
/**
Notify the gui that blockade generation has begun.
@param buildingCount The number of buildings to process.
*/
void startBlock(final int buildingCount) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusLabel.setText("Computing blockades");
if (buildingCount == 0) {
blockadeProgress.setMaximum(1);
blockadeProgress.setValue(1);
}
else {
blockadeProgress.setMaximum(buildingCount);
blockadeProgress.setValue(0);
block = 0;
}
}
});
}
/**
Notify the gui that blockade generation for a building has been processed.
*/
void bumpBlock() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
blockadeProgress.setValue(++block);
}
});
}
/**
Notify the gui that blockade generation is complete.
*/
void endBlock() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
blockadeProgress.setValue(blockadeProgress.getMaximum());
statusLabel.setText("Done");
}
});
}
} | 5,887 | 0.526414 | 0.522507 | 197 | 28.888325 | 20.84893 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.380711 | false | false | 15 |
d5145d918ebec408d1fea9f5be7a6479a86fdd9f | 30,039,001,301,310 | 5807a792c695fa4d15757b637abd70d3b5f39434 | /src/Init.java | 27a0b4b3da30bc1b6f3d19ffba95fdb9311107d1 | [] | no_license | sirdir/Temp | https://github.com/sirdir/Temp | 4c3760a4b6631f6121815afd94b435bbf6e9bafb | f4936e981541f1e22110587f89709eac9b82b2fd | refs/heads/master | 2021-01-19T09:08:45.412000 | 2017-04-14T08:17:00 | 2017-04-14T08:17:00 | 87,730,633 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import myPackage.ClassWithProtected;
/**
* Created by sirdir on 09.04.17.
*/
public class Init {
public static void main(String[] args){
System.out.println("before");
SomeClass init = new SomeClass();
System.out.println("after");
System.out.println(init.s1);
System.out.println(init.s2);
for (String sr:System.getenv().keySet()) {
System.out.println(sr + " = " + System.getenv().get(sr));
}
ClassWithProtected cp = new ClassWithProtected();
// cp.methodPriv();
// cp.methodPackage();
// cp.methodProt();
cp.methodPub();
ChildOfProtected ccp = new ChildOfProtected();
// cp.methodPriv();
// cp.methodPackage();
// cp.methodProt();
cp.methodPub();
}
}
| UTF-8 | Java | 804 | java | Init.java | Java | [
{
"context": "t myPackage.ClassWithProtected;\n\n/**\n * Created by sirdir on 09.04.17.\n */\npublic class Init {\n public s",
"end": 62,
"score": 0.9992894530296326,
"start": 56,
"tag": "USERNAME",
"value": "sirdir"
}
] | null | [] | import myPackage.ClassWithProtected;
/**
* Created by sirdir on 09.04.17.
*/
public class Init {
public static void main(String[] args){
System.out.println("before");
SomeClass init = new SomeClass();
System.out.println("after");
System.out.println(init.s1);
System.out.println(init.s2);
for (String sr:System.getenv().keySet()) {
System.out.println(sr + " = " + System.getenv().get(sr));
}
ClassWithProtected cp = new ClassWithProtected();
// cp.methodPriv();
// cp.methodPackage();
// cp.methodProt();
cp.methodPub();
ChildOfProtected ccp = new ChildOfProtected();
// cp.methodPriv();
// cp.methodPackage();
// cp.methodProt();
cp.methodPub();
}
}
| 804 | 0.567164 | 0.557214 | 28 | 27.714285 | 17.950045 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.607143 | false | false | 15 |
4696043e675b2e35a73e7d79652a87b202fbd541 | 5,102,421,162,226 | f85515549aa17a4ae5adc4af0d6708d32a83b8ba | /demo-leetcode/src/main/java/com/yunqing/demoleetcode/topics2020/array/No2MaxWater.java | ee1836b25b9b32eda2dcc0e5c76edde118b25f19 | [] | no_license | kangqing/boot-demos | https://github.com/kangqing/boot-demos | 8a052c3a77f6fac5c59fbcb4a27fa6cd3636a43d | 9395756dbf4940ac668e155784ef5f426b801521 | refs/heads/master | 2023-08-10T09:02:24.855000 | 2023-08-06T13:15:28 | 2023-08-06T13:15:28 | 232,770,815 | 3 | 1 | null | false | 2023-01-07T09:49:36 | 2020-01-09T09:23:49 | 2021-12-21T11:07:28 | 2023-01-07T09:49:36 | 5,304 | 1 | 0 | 4 | Java | false | false | package com.yunqing.demoleetcode.topics2020.array;
/**
* 双指针
* 盛水最多的容器
* @author kangqing
* @since 2021/2/4 21:14
*/
public class No2MaxWater {
public static void main(String[] args) {
}
}
class SolutionNo2 {
public int maxArea(int[] height) {
int res = -1;
int le = 0;
int ri = height.length - 1;
int lValue = height[0];
int rValue = height[ri];
while (le < ri) {
// 算两个墙之前盛水最多
res = Math.max(res, Math.min(height[le], height[ri]) * (ri - le));
if (height[le] < height[ri]) {
le++;
while (le < ri && height[le] <= lValue) {
le++;
}
lValue = height[le];
} else {
ri--;
while (le < ri && height[ri] <= rValue) {
ri--;
}
rValue = height[ri];
}
}
return res;
}
}
| UTF-8 | Java | 1,016 | java | No2MaxWater.java | Java | [
{
"context": "opics2020.array;\n\n/**\n * 双指针\n * 盛水最多的容器\n * @author kangqing\n * @since 2021/2/4 21:14\n */\npublic class No2MaxW",
"end": 93,
"score": 0.981432318687439,
"start": 85,
"tag": "USERNAME",
"value": "kangqing"
}
] | null | [] | package com.yunqing.demoleetcode.topics2020.array;
/**
* 双指针
* 盛水最多的容器
* @author kangqing
* @since 2021/2/4 21:14
*/
public class No2MaxWater {
public static void main(String[] args) {
}
}
class SolutionNo2 {
public int maxArea(int[] height) {
int res = -1;
int le = 0;
int ri = height.length - 1;
int lValue = height[0];
int rValue = height[ri];
while (le < ri) {
// 算两个墙之前盛水最多
res = Math.max(res, Math.min(height[le], height[ri]) * (ri - le));
if (height[le] < height[ri]) {
le++;
while (le < ri && height[le] <= lValue) {
le++;
}
lValue = height[le];
} else {
ri--;
while (le < ri && height[ri] <= rValue) {
ri--;
}
rValue = height[ri];
}
}
return res;
}
}
| 1,016 | 0.422131 | 0.401639 | 41 | 22.804878 | 17.571068 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.390244 | false | false | 15 |
e9cb6b927a8cd646a924a249fcd4c8e877b190ca | 30,459,908,134,237 | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.minihd.qq/assets/exlibs.2.jar/classes.jar/cri.java | d085d6389cb1cbe12acdfc2c57ab74e4eacdde4e | [] | no_license | tsuzcx/qq_apk | https://github.com/tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651000 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | false | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | 2022-01-31T06:56:43 | 2022-01-31T09:46:26 | 167,304 | 0 | 1 | 1 | Java | false | false | import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import com.tencent.biz.widgets.XChooserActivity;
public class cri
implements Runnable
{
public cri(XChooserActivity paramXChooserActivity, ActivityInfo paramActivityInfo) {}
public void run()
{
try
{
SharedPreferences.Editor localEditor = this.jdField_a_of_type_ComTencentBizWidgetsXChooserActivity.getPreferences(0).edit();
localEditor.putString(this.jdField_a_of_type_ComTencentBizWidgetsXChooserActivity.m, this.jdField_a_of_type_AndroidContentPmActivityInfo.applicationInfo.packageName + '/' + this.jdField_a_of_type_AndroidContentPmActivityInfo.name);
localEditor.commit();
return;
}
catch (Throwable localThrowable)
{
localThrowable.printStackTrace();
}
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.minihd.qq\assets\exlibs.2.jar\classes.jar
* Qualified Name: cri
* JD-Core Version: 0.7.0.1
*/ | UTF-8 | Java | 1,111 | java | cri.java | Java | [] | null | [] | import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import com.tencent.biz.widgets.XChooserActivity;
public class cri
implements Runnable
{
public cri(XChooserActivity paramXChooserActivity, ActivityInfo paramActivityInfo) {}
public void run()
{
try
{
SharedPreferences.Editor localEditor = this.jdField_a_of_type_ComTencentBizWidgetsXChooserActivity.getPreferences(0).edit();
localEditor.putString(this.jdField_a_of_type_ComTencentBizWidgetsXChooserActivity.m, this.jdField_a_of_type_AndroidContentPmActivityInfo.applicationInfo.packageName + '/' + this.jdField_a_of_type_AndroidContentPmActivityInfo.name);
localEditor.commit();
return;
}
catch (Throwable localThrowable)
{
localThrowable.printStackTrace();
}
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.minihd.qq\assets\exlibs.2.jar\classes.jar
* Qualified Name: cri
* JD-Core Version: 0.7.0.1
*/ | 1,111 | 0.727273 | 0.721872 | 36 | 29.027779 | 46.441414 | 237 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 15 |
c60377e311d898f98c0bb783b5dbc4f07820c75c | 31,645,319,044,323 | fd7c60d2b9a7a148c185c22b226b49066c468e47 | /GamificationActionService/src/test/java/i5/las2peer/services/gamificationActionService/GamificationActionServiceTest.java | a6b4ac4f5a87729ca108de6013de4d30fad09484 | [
"CC0-1.0"
] | permissive | rwth-acis/Gamification-Framework | https://github.com/rwth-acis/Gamification-Framework | b49df92c1826d51710f7fb363415a9843114ec5b | 4314470e03c0d6b789a3e8f1e24a589e122a69e1 | refs/heads/master | 2023-05-24T23:10:13.320000 | 2022-09-21T12:32:06 | 2022-09-21T12:32:06 | 62,332,121 | 8 | 5 | null | false | 2023-05-15T12:18:23 | 2016-06-30T18:03:43 | 2023-04-04T17:00:11 | 2023-05-15T12:18:22 | 305,549 | 6 | 2 | 8 | Java | false | false | package i5.las2peer.services.gamificationActionService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.StringBody;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import i5.las2peer.p2p.LocalNode;
import i5.las2peer.p2p.LocalNodeManager;
import i5.las2peer.api.p2p.ServiceNameVersion;
import i5.las2peer.security.UserAgentImpl;
//import i5.las2peer.services.gamificationActionService.GamificationActionService;
import i5.las2peer.testing.MockAgentFactory;
import i5.las2peer.connectors.webConnector.WebConnector;
import i5.las2peer.connectors.webConnector.client.ClientResponse;
import i5.las2peer.connectors.webConnector.client.MiniClient;
/**
* Example Test Class demonstrating a basic JUnit test structure.
*
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GamificationActionServiceTest {
private static final int HTTP_PORT = 8081;
private static LocalNode node;
private static WebConnector connector;
private static ByteArrayOutputStream logStream;
private static MiniClient c1, c2, c3;
private static UserAgentImpl user1, user2, user3;
private static String gameId = "test";
private static String actionId = "action_test_2";
private static final String mainPath = "gamification/actions/";
// to fetch data per batch
int currentPage = 1;
int windowSize = 10;
String searchParam = "";
String unitName = "dollar";
/**
* Called before the tests start.
*
* Sets up the node and initializes connector and users that can be used throughout the tests.
*
* @throws Exception
*/
@Before
public void startServer() throws Exception {
// start node
//node = LocalNode.newNode();
node = new LocalNodeManager().newNode();
node.launch();
user1 = MockAgentFactory.getAdam();
user2 = MockAgentFactory.getAbel();
user3 = MockAgentFactory.getEve();
// agent must be unlocked in order to be stored
user1.unlock("adamspass");
user2.unlock("abelspass");
user3.unlock("evespass");
node.storeAgent(user1);
node.storeAgent(user2);
node.storeAgent(user3);
node.startService(new ServiceNameVersion(GamificationActionService.class.getName(), "0.1"), "a pass");
logStream = new ByteArrayOutputStream();
connector = new WebConnector(true, HTTP_PORT, false, 1000);
connector.setLogStream(new PrintStream(logStream));
connector.start(node);
// wait a second for the connector to become ready
Thread.sleep(1000);
c1 = new MiniClient();
c1.setConnectorEndpoint(connector.getHttpEndpoint());
c1.setLogin(user1.getIdentifier(), "adamspass");
c2 = new MiniClient();
c2.setConnectorEndpoint(connector.getHttpEndpoint());
c2.setLogin(user2.getIdentifier(), "abelspass");
c3 = new MiniClient();
c3.setConnectorEndpoint(connector.getHttpEndpoint());
c3.setLogin(user3.getIdentifier(), "evespass");
}
/**
* Called after the test has finished. Shuts down the server and prints out the connector log file for reference.
*
* @throws Exception
*/
@After
public void shutDownServer() throws Exception {
if (connector != null) {
connector.stop();
connector = null;
}
if (node != null) {
node.shutDown();
node = null;
}
if (logStream != null) {
System.out.println("Connector-Log:");
System.out.println("--------------");
System.out.println(logStream.toString());
logStream = null;
}
}
@Test
public void testE1_createNewAction(){
System.out.println("Test --- Create New Action");
try
{
String boundary = "--32532twtfaweafwsgfaegfawegf4";
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.setBoundary(boundary);
builder.addPart("actionid", new StringBody(actionId, ContentType.TEXT_PLAIN));
builder.addPart("actionname", new StringBody("action name", ContentType.TEXT_PLAIN));
builder.addPart("actiondesc", new StringBody("action description", ContentType.TEXT_PLAIN));
builder.addPart("actionpointvalue", new StringBody("50", ContentType.TEXT_PLAIN));
builder.addPart("actionnotificationcheck", new StringBody("true", ContentType.TEXT_PLAIN));
builder.addPart("actionnotificationmessage", new StringBody("This is notification message", ContentType.TEXT_PLAIN));
HttpEntity formData = builder.build();
ByteArrayOutputStream out = new ByteArrayOutputStream();
formData.writeTo(out);
Map<String, String> headers = new HashMap<>();
headers.put("Accept-Encoding","gzip, deflate");
headers.put("Accept-Language","en-GB,en-US;q=0.8,en;q=0.6");
ClientResponse result = c1.sendRequest("POST", mainPath + "" + gameId, out.toString(), "multipart/form-data; boundary="+boundary, "*/*", headers);
System.out.println(result.getResponse());
if(result.getHttpCode()==HttpURLConnection.HTTP_OK){
assertEquals(HttpURLConnection.HTTP_OK,result.getHttpCode());
}
else{
assertEquals(HttpURLConnection.HTTP_CREATED,result.getHttpCode());
}
} catch (Exception e)
{
e.printStackTrace();
System.out.println(e.getMessage());
fail("Exception: " + e);
System.exit(0);
}
}
@Test
public void testE2_getActionWithId(){
System.out.println("Test --- Get Action With Id");
try
{
ClientResponse result = c1.sendRequest("GET", mainPath + "" + gameId + "/" + actionId, "");
assertEquals(200, result.getHttpCode());
} catch (Exception e)
{
e.printStackTrace();
fail("Exception: " + e);
System.exit(0);
}
}
@Test
public void testE2_updateAction(){
System.out.println("Test --- Update Action");
try
{
String boundary = "--32532twtfaweafwsgfaegfawegf4";
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.setBoundary(boundary);
builder.addPart("actionid", new StringBody(actionId, ContentType.TEXT_PLAIN));
builder.addPart("actionname", new StringBody("action name", ContentType.TEXT_PLAIN));
builder.addPart("actiondesc", new StringBody("action description", ContentType.TEXT_PLAIN));
builder.addPart("actionpointvalue", new StringBody("50", ContentType.TEXT_PLAIN));
builder.addPart("actionnotificationcheck", new StringBody("true", ContentType.TEXT_PLAIN));
builder.addPart("actionnotificationmessage", new StringBody("This is notification message", ContentType.TEXT_PLAIN));
HttpEntity formData = builder.build();
ByteArrayOutputStream out = new ByteArrayOutputStream();
formData.writeTo(out);
Map<String, String> headers = new HashMap<>();
headers.put("Accept-Encoding","gzip, deflate");
headers.put("Accept-Language","en-GB,en-US;q=0.8,en;q=0.6");
ClientResponse result = c1.sendRequest("PUT", mainPath + "" + gameId +"/"+ actionId, out.toString(), "multipart/form-data; boundary="+boundary, "*/*", headers);
System.out.println(result.getResponse());
assertEquals(HttpURLConnection.HTTP_OK,result.getHttpCode());
} catch (Exception e)
{
e.printStackTrace();
System.out.println(e.getMessage());
fail("Exception: " + e);
System.exit(0);
}
}
@Test
public void testE21_getActionList()
{
System.out.println("Test --- Get ACtion List");
try
{
ClientResponse result = c1.sendRequest("GET", mainPath + "" + gameId + "?current=1&rowCount=10&searchPhrase=", "");
assertEquals(200, result.getHttpCode());
} catch (Exception e)
{
e.printStackTrace();
fail("Exception: " + e);
System.exit(0);
}
}
@Test
public void testZ4_deleteAction(){
try
{
ClientResponse result = c1.sendRequest("DELETE", mainPath + "" + gameId + "/" + actionId, "");
assertEquals(200, result.getHttpCode());
} catch (Exception e)
{
e.printStackTrace();
fail("Exception: " + e);
System.exit(0);
}
}
}
| UTF-8 | Java | 8,323 | java | GamificationActionServiceTest.java | Java | [
{
"context": "e unlocked in order to be stored \n\t\tuser1.unlock(\"adamspass\");\n\t\tuser2.unlock(\"abelspass\");\n\t\tuser3.unlock(\"e",
"end": 2411,
"score": 0.9996355175971985,
"start": 2402,
"tag": "USERNAME",
"value": "adamspass"
},
{
"context": "red \n\t\tuser1.unlock(\"adamspass\");\n\t\tuser2.unlock(\"abelspass\");\n\t\tuser3.unlock(\"evespass\");\n\n\t\tnode.storeAgent",
"end": 2440,
"score": 0.9995157718658447,
"start": 2431,
"tag": "USERNAME",
"value": "abelspass"
},
{
"context": "s\");\n\t\tuser2.unlock(\"abelspass\");\n\t\tuser3.unlock(\"evespass\");\n\n\t\tnode.storeAgent(user1);\n\t\tnode.storeAgent(u",
"end": 2468,
"score": 0.998813807964325,
"start": 2460,
"tag": "USERNAME",
"value": "evespass"
},
{
"context": "ndpoint());\n\t\tc1.setLogin(user1.getIdentifier(), \"adamspass\");\n\t\t\n\t\tc2 = new MiniClient();\n\t\tc2.setConnectorE",
"end": 3049,
"score": 0.999649703502655,
"start": 3040,
"tag": "USERNAME",
"value": "adamspass"
},
{
"context": "ndpoint());\n\t\tc2.setLogin(user2.getIdentifier(), \"abelspass\");\n\n\t\tc3 = new MiniClient();\n\t\tc3.setConnectorEnd",
"end": 3184,
"score": 0.9996039271354675,
"start": 3175,
"tag": "USERNAME",
"value": "abelspass"
},
{
"context": "ndpoint());\n\t\tc3.setLogin(user3.getIdentifier(), \"evespass\");\n\t}\n\n\t/**\n\t * Called after the test has finishe",
"end": 3316,
"score": 0.9993188977241516,
"start": 3308,
"tag": "USERNAME",
"value": "evespass"
}
] | null | [] | package i5.las2peer.services.gamificationActionService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.StringBody;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import i5.las2peer.p2p.LocalNode;
import i5.las2peer.p2p.LocalNodeManager;
import i5.las2peer.api.p2p.ServiceNameVersion;
import i5.las2peer.security.UserAgentImpl;
//import i5.las2peer.services.gamificationActionService.GamificationActionService;
import i5.las2peer.testing.MockAgentFactory;
import i5.las2peer.connectors.webConnector.WebConnector;
import i5.las2peer.connectors.webConnector.client.ClientResponse;
import i5.las2peer.connectors.webConnector.client.MiniClient;
/**
* Example Test Class demonstrating a basic JUnit test structure.
*
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GamificationActionServiceTest {
private static final int HTTP_PORT = 8081;
private static LocalNode node;
private static WebConnector connector;
private static ByteArrayOutputStream logStream;
private static MiniClient c1, c2, c3;
private static UserAgentImpl user1, user2, user3;
private static String gameId = "test";
private static String actionId = "action_test_2";
private static final String mainPath = "gamification/actions/";
// to fetch data per batch
int currentPage = 1;
int windowSize = 10;
String searchParam = "";
String unitName = "dollar";
/**
* Called before the tests start.
*
* Sets up the node and initializes connector and users that can be used throughout the tests.
*
* @throws Exception
*/
@Before
public void startServer() throws Exception {
// start node
//node = LocalNode.newNode();
node = new LocalNodeManager().newNode();
node.launch();
user1 = MockAgentFactory.getAdam();
user2 = MockAgentFactory.getAbel();
user3 = MockAgentFactory.getEve();
// agent must be unlocked in order to be stored
user1.unlock("adamspass");
user2.unlock("abelspass");
user3.unlock("evespass");
node.storeAgent(user1);
node.storeAgent(user2);
node.storeAgent(user3);
node.startService(new ServiceNameVersion(GamificationActionService.class.getName(), "0.1"), "a pass");
logStream = new ByteArrayOutputStream();
connector = new WebConnector(true, HTTP_PORT, false, 1000);
connector.setLogStream(new PrintStream(logStream));
connector.start(node);
// wait a second for the connector to become ready
Thread.sleep(1000);
c1 = new MiniClient();
c1.setConnectorEndpoint(connector.getHttpEndpoint());
c1.setLogin(user1.getIdentifier(), "adamspass");
c2 = new MiniClient();
c2.setConnectorEndpoint(connector.getHttpEndpoint());
c2.setLogin(user2.getIdentifier(), "abelspass");
c3 = new MiniClient();
c3.setConnectorEndpoint(connector.getHttpEndpoint());
c3.setLogin(user3.getIdentifier(), "evespass");
}
/**
* Called after the test has finished. Shuts down the server and prints out the connector log file for reference.
*
* @throws Exception
*/
@After
public void shutDownServer() throws Exception {
if (connector != null) {
connector.stop();
connector = null;
}
if (node != null) {
node.shutDown();
node = null;
}
if (logStream != null) {
System.out.println("Connector-Log:");
System.out.println("--------------");
System.out.println(logStream.toString());
logStream = null;
}
}
@Test
public void testE1_createNewAction(){
System.out.println("Test --- Create New Action");
try
{
String boundary = "--32532twtfaweafwsgfaegfawegf4";
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.setBoundary(boundary);
builder.addPart("actionid", new StringBody(actionId, ContentType.TEXT_PLAIN));
builder.addPart("actionname", new StringBody("action name", ContentType.TEXT_PLAIN));
builder.addPart("actiondesc", new StringBody("action description", ContentType.TEXT_PLAIN));
builder.addPart("actionpointvalue", new StringBody("50", ContentType.TEXT_PLAIN));
builder.addPart("actionnotificationcheck", new StringBody("true", ContentType.TEXT_PLAIN));
builder.addPart("actionnotificationmessage", new StringBody("This is notification message", ContentType.TEXT_PLAIN));
HttpEntity formData = builder.build();
ByteArrayOutputStream out = new ByteArrayOutputStream();
formData.writeTo(out);
Map<String, String> headers = new HashMap<>();
headers.put("Accept-Encoding","gzip, deflate");
headers.put("Accept-Language","en-GB,en-US;q=0.8,en;q=0.6");
ClientResponse result = c1.sendRequest("POST", mainPath + "" + gameId, out.toString(), "multipart/form-data; boundary="+boundary, "*/*", headers);
System.out.println(result.getResponse());
if(result.getHttpCode()==HttpURLConnection.HTTP_OK){
assertEquals(HttpURLConnection.HTTP_OK,result.getHttpCode());
}
else{
assertEquals(HttpURLConnection.HTTP_CREATED,result.getHttpCode());
}
} catch (Exception e)
{
e.printStackTrace();
System.out.println(e.getMessage());
fail("Exception: " + e);
System.exit(0);
}
}
@Test
public void testE2_getActionWithId(){
System.out.println("Test --- Get Action With Id");
try
{
ClientResponse result = c1.sendRequest("GET", mainPath + "" + gameId + "/" + actionId, "");
assertEquals(200, result.getHttpCode());
} catch (Exception e)
{
e.printStackTrace();
fail("Exception: " + e);
System.exit(0);
}
}
@Test
public void testE2_updateAction(){
System.out.println("Test --- Update Action");
try
{
String boundary = "--32532twtfaweafwsgfaegfawegf4";
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.setBoundary(boundary);
builder.addPart("actionid", new StringBody(actionId, ContentType.TEXT_PLAIN));
builder.addPart("actionname", new StringBody("action name", ContentType.TEXT_PLAIN));
builder.addPart("actiondesc", new StringBody("action description", ContentType.TEXT_PLAIN));
builder.addPart("actionpointvalue", new StringBody("50", ContentType.TEXT_PLAIN));
builder.addPart("actionnotificationcheck", new StringBody("true", ContentType.TEXT_PLAIN));
builder.addPart("actionnotificationmessage", new StringBody("This is notification message", ContentType.TEXT_PLAIN));
HttpEntity formData = builder.build();
ByteArrayOutputStream out = new ByteArrayOutputStream();
formData.writeTo(out);
Map<String, String> headers = new HashMap<>();
headers.put("Accept-Encoding","gzip, deflate");
headers.put("Accept-Language","en-GB,en-US;q=0.8,en;q=0.6");
ClientResponse result = c1.sendRequest("PUT", mainPath + "" + gameId +"/"+ actionId, out.toString(), "multipart/form-data; boundary="+boundary, "*/*", headers);
System.out.println(result.getResponse());
assertEquals(HttpURLConnection.HTTP_OK,result.getHttpCode());
} catch (Exception e)
{
e.printStackTrace();
System.out.println(e.getMessage());
fail("Exception: " + e);
System.exit(0);
}
}
@Test
public void testE21_getActionList()
{
System.out.println("Test --- Get ACtion List");
try
{
ClientResponse result = c1.sendRequest("GET", mainPath + "" + gameId + "?current=1&rowCount=10&searchPhrase=", "");
assertEquals(200, result.getHttpCode());
} catch (Exception e)
{
e.printStackTrace();
fail("Exception: " + e);
System.exit(0);
}
}
@Test
public void testZ4_deleteAction(){
try
{
ClientResponse result = c1.sendRequest("DELETE", mainPath + "" + gameId + "/" + actionId, "");
assertEquals(200, result.getHttpCode());
} catch (Exception e)
{
e.printStackTrace();
fail("Exception: " + e);
System.exit(0);
}
}
}
| 8,323 | 0.714166 | 0.699748 | 275 | 29.265455 | 29.520386 | 163 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.483636 | false | false | 15 |
37daef2fda1476ded1da131b4945ee05f27d155d | 5,076,651,398,079 | f35443d070d1557d93c02224068df40f6586d150 | /src/main/java/com/microservice/user/web/UserController.java | d97efc954fcb8242c134e14551fef5ae48d8f18d | [] | no_license | yanzxu/user-service | https://github.com/yanzxu/user-service | 566ef09749de25d019a662f69e699b7e72c0ae17 | cd3dc80349dd4d0affdc4f8c23766a549801ed3f | refs/heads/master | 2020-06-16T18:21:30.497000 | 2019-07-10T10:14:45 | 2019-07-10T10:14:45 | 195,662,820 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.microservice.user.web;
import com.microservice.user.client.ProjectClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class UserController {
@Autowired
private ProjectClient projectClient;
// @Autowired
// UserController(ProjectClient projectClient){
// this.projectClient = projectClient;
// }
@RequestMapping(path = "/users", method = RequestMethod.GET)
public ResponseEntity listUsers(){
return ResponseEntity.ok().body("===== this is user service =====");
}
@RequestMapping(path = "/projects", method = RequestMethod.GET)
public ResponseEntity listProject(){
return ResponseEntity.ok().body(projectClient.listProjects());
}
}
| UTF-8 | Java | 990 | java | UserController.java | Java | [] | null | [] | package com.microservice.user.web;
import com.microservice.user.client.ProjectClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class UserController {
@Autowired
private ProjectClient projectClient;
// @Autowired
// UserController(ProjectClient projectClient){
// this.projectClient = projectClient;
// }
@RequestMapping(path = "/users", method = RequestMethod.GET)
public ResponseEntity listUsers(){
return ResponseEntity.ok().body("===== this is user service =====");
}
@RequestMapping(path = "/projects", method = RequestMethod.GET)
public ResponseEntity listProject(){
return ResponseEntity.ok().body(projectClient.listProjects());
}
}
| 990 | 0.748485 | 0.748485 | 30 | 32 | 26.106194 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.433333 | false | false | 15 |
5cd7808f919d187d6505b7bdebfc81041e6c7ae8 | 37,958,920,982,995 | 1294406571aa40099332e907ab09933d43e800c3 | /app/src/main/java/com/example/graduatioproject/MainActivity.java | 263c7aa3304115c7f6260bb6be16c06a5648366c | [] | no_license | jls0526/Android-magnetic-measurement-app | https://github.com/jls0526/Android-magnetic-measurement-app | 99d4ec459a103527b8f992220176713d34acb5b7 | d6af20f5e0c5536cd928153ada818250c7166903 | refs/heads/master | 2023-04-15T21:41:45.454000 | 2021-04-27T11:01:21 | 2021-04-27T11:01:21 | 362,039,974 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.graduatioproject;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.PersistableBundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.example.graduatioproject.ch340_library.driver.InitCH340;
import com.example.graduatioproject.contour.ContourCtrl;
import com.example.graduatioproject.contour.ContourPoint;
import com.example.graduatioproject.contour.MagneticRawData;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
private static final String databaseName = "MageticDataDatabase.db";
private static Handler handler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
switch (msg.what) {
case 1:
break;
case 2:
if(RealTimeFragment.getStartTransfer()){
String recv_dat = msg.getData().getString("data");
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putString("recv_dat",recv_dat);
message.setData(bundle);
message.what = 0;
Handler handlerSend = RealTimeFragment.getHandler();
if(handlerSend != null){
handlerSend.handleMessage(message);
}
//FileLog.fileLog(getApplicationContext(),recv_dat,"串口测试");
parseDataAndSaveToDataBase(recv_dat);
//Toast.makeText(MainActivity.this,"" + msg.getData().getString("data"),Toast.LENGTH_SHORT).show();
}
}
}
};
public static Handler getHandler(){
return handler;
}
private DatabaseHelper databaseHelper;
static SQLiteDatabase writableDatabase;
private static boolean isValid = false;
private static String time = null;
private static int x,y,gmi_ch1_integer,gmi_ch2_integer,gmi_ch3_integer,other_length = 0;
private static String other_data = null;
private static ArrayList<MagneticRawData> magneticRawDataArrayList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomNavigationView bottomNavigationView = findViewById(R.id.nav_view);
databaseHelper = new DatabaseHelper(this,databaseName,null,Constant.DATABASE_VERSION);
//接收USB广播
IntentFilter filter = new IntentFilter();
filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
registerReceiver(mUsbStateChangeReceiver, filter);
//请求写入外部文本文件权限
if(Build.VERSION.SDK_INT >= 23){
int REQUEST_CODE_CONTACT = 101;
String permissions[] = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
for(String str : permissions){
if(MainActivity.this.checkSelfPermission(str) != PackageManager.PERMISSION_GRANTED){
MainActivity.this.requestPermissions(permissions, REQUEST_CODE_CONTACT);
break;
}
}
}
writableDatabase = databaseHelper.getWritableDatabase();
FragmentManager fragmentManager = getSupportFragmentManager();
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
final RealTimeFragment realTimeFragment = new RealTimeFragment();
final ReceiverFragment receiverFragment = new ReceiverFragment();
final SettingFragment settingFragment = new SettingFragment();
fragmentTransaction.add(R.id.main_activity_layout,realTimeFragment);
fragmentTransaction.add(R.id.main_activity_layout,receiverFragment);
fragmentTransaction.add(R.id.main_activity_layout,settingFragment);
fragmentTransaction.show(realTimeFragment);
fragmentTransaction.hide(receiverFragment);
fragmentTransaction.hide(settingFragment);
fragmentTransaction.commit();
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()){
case R.id.navigation_receiver:
getSupportFragmentManager().beginTransaction()
.hide(receiverFragment).hide(settingFragment).show(realTimeFragment)
.commit();
break;
case R.id.navigation_history:
getSupportFragmentManager().beginTransaction()
.hide(realTimeFragment).hide(settingFragment).show(receiverFragment)
.commit();
break;
case R.id.navigation_settings:
getSupportFragmentManager().beginTransaction()
.hide(realTimeFragment).hide(receiverFragment).show(settingFragment)
.commit();
break;
}
return true;
}
});
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
}
//在Activity被回收时调用
@Override
public void onSaveInstanceState(@NonNull Bundle outState, @NonNull PersistableBundle outPersistentState) {
super.onSaveInstanceState(outState, outPersistentState);
}
/**
* ch340插入、拔出的监听函数
*/
private final BroadcastReceiver mUsbStateChangeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putInt("device_state",1);//1代表连接上,0代表断开
message.what = 1;
message.setData(bundle);
if(RealTimeFragment.getHandler() != null){
RealTimeFragment.getHandler().sendMessage(message);
}
UsbDevice usbDevice = (UsbDevice)intent.getExtras().get("device");
if(usbDevice != null && usbDevice.getProductId() == 29987 && usbDevice.getVendorId() == 6790){
if(action == UsbManager.ACTION_USB_DEVICE_ATTACHED){
if(InitCH340.getDriver() == null){
InitCH340.initCH340(getApplicationContext(),handler);
}
if(InitCH340.isIsOpenDeviceCH340()){
Toast.makeText(getApplicationContext(),"ch340已打开",Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(getApplicationContext(),"ch340打开失败",Toast.LENGTH_SHORT).show();
}
UsbDevice mUsbDevice = InitCH340.getUsbDevice();
if(mUsbDevice != null){
}
}else if(action == UsbManager.ACTION_USB_DEVICE_DETACHED){
}
}
}
};
public static void insertMageticData(SQLiteDatabase writableDatabase,int x,int y,int x_surface,int y_surface,int z_surface,String time){
if(writableDatabase == null)return;
ContentValues values = new ContentValues();
values.put("x",x);
values.put("y",y);
values.put("x_surface",x_surface);
values.put("y_surface",y_surface);
values.put("z_surface",z_surface);
values.put("time",time);
writableDatabase.insert("MagneticData",null,values);
}
public static void insertNameList(String name){
if(writableDatabase == null){
return;
}
ContentValues values = new ContentValues();
values.put("name",name);
values.put("label",name);
writableDatabase.insert("NameList",null,values);
}
public static void parseDataAndSaveToDataBase(String data){
if(other_length > 0){
data = other_data + data;
}
if(data.length() >= 5 && data.startsWith("START")){
isValid = true;
@SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMMdd-HHmmss");
Date curDate = new Date(System.currentTimeMillis());
time = formatter.format(curDate);
insertNameList(time);
data = data.substring(5);
}
while(isValid && data.length() >= 38){
x = Integer.parseInt(data.substring(0,4));
y = Integer.parseInt(data.substring(4,8));
gmi_ch1_integer = Integer.parseInt(data.substring(8,14));
gmi_ch2_integer = Integer.parseInt(data.substring(18,24));
gmi_ch3_integer = Integer.parseInt(data.substring(28,34));
insertMageticData(writableDatabase,x,y,gmi_ch1_integer,gmi_ch2_integer,gmi_ch3_integer,time);
data = data.substring(38);
}
other_length = data.length();
other_data = data;
if(data.endsWith("STOP")){
isValid = false;
other_length = 0;
other_data = null;
}
}
}
| UTF-8 | Java | 10,615 | java | MainActivity.java | Java | [] | null | [] | package com.example.graduatioproject;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.PersistableBundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.example.graduatioproject.ch340_library.driver.InitCH340;
import com.example.graduatioproject.contour.ContourCtrl;
import com.example.graduatioproject.contour.ContourPoint;
import com.example.graduatioproject.contour.MagneticRawData;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
private static final String databaseName = "MageticDataDatabase.db";
private static Handler handler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
switch (msg.what) {
case 1:
break;
case 2:
if(RealTimeFragment.getStartTransfer()){
String recv_dat = msg.getData().getString("data");
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putString("recv_dat",recv_dat);
message.setData(bundle);
message.what = 0;
Handler handlerSend = RealTimeFragment.getHandler();
if(handlerSend != null){
handlerSend.handleMessage(message);
}
//FileLog.fileLog(getApplicationContext(),recv_dat,"串口测试");
parseDataAndSaveToDataBase(recv_dat);
//Toast.makeText(MainActivity.this,"" + msg.getData().getString("data"),Toast.LENGTH_SHORT).show();
}
}
}
};
public static Handler getHandler(){
return handler;
}
private DatabaseHelper databaseHelper;
static SQLiteDatabase writableDatabase;
private static boolean isValid = false;
private static String time = null;
private static int x,y,gmi_ch1_integer,gmi_ch2_integer,gmi_ch3_integer,other_length = 0;
private static String other_data = null;
private static ArrayList<MagneticRawData> magneticRawDataArrayList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomNavigationView bottomNavigationView = findViewById(R.id.nav_view);
databaseHelper = new DatabaseHelper(this,databaseName,null,Constant.DATABASE_VERSION);
//接收USB广播
IntentFilter filter = new IntentFilter();
filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
registerReceiver(mUsbStateChangeReceiver, filter);
//请求写入外部文本文件权限
if(Build.VERSION.SDK_INT >= 23){
int REQUEST_CODE_CONTACT = 101;
String permissions[] = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
for(String str : permissions){
if(MainActivity.this.checkSelfPermission(str) != PackageManager.PERMISSION_GRANTED){
MainActivity.this.requestPermissions(permissions, REQUEST_CODE_CONTACT);
break;
}
}
}
writableDatabase = databaseHelper.getWritableDatabase();
FragmentManager fragmentManager = getSupportFragmentManager();
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
final RealTimeFragment realTimeFragment = new RealTimeFragment();
final ReceiverFragment receiverFragment = new ReceiverFragment();
final SettingFragment settingFragment = new SettingFragment();
fragmentTransaction.add(R.id.main_activity_layout,realTimeFragment);
fragmentTransaction.add(R.id.main_activity_layout,receiverFragment);
fragmentTransaction.add(R.id.main_activity_layout,settingFragment);
fragmentTransaction.show(realTimeFragment);
fragmentTransaction.hide(receiverFragment);
fragmentTransaction.hide(settingFragment);
fragmentTransaction.commit();
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()){
case R.id.navigation_receiver:
getSupportFragmentManager().beginTransaction()
.hide(receiverFragment).hide(settingFragment).show(realTimeFragment)
.commit();
break;
case R.id.navigation_history:
getSupportFragmentManager().beginTransaction()
.hide(realTimeFragment).hide(settingFragment).show(receiverFragment)
.commit();
break;
case R.id.navigation_settings:
getSupportFragmentManager().beginTransaction()
.hide(realTimeFragment).hide(receiverFragment).show(settingFragment)
.commit();
break;
}
return true;
}
});
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
}
//在Activity被回收时调用
@Override
public void onSaveInstanceState(@NonNull Bundle outState, @NonNull PersistableBundle outPersistentState) {
super.onSaveInstanceState(outState, outPersistentState);
}
/**
* ch340插入、拔出的监听函数
*/
private final BroadcastReceiver mUsbStateChangeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putInt("device_state",1);//1代表连接上,0代表断开
message.what = 1;
message.setData(bundle);
if(RealTimeFragment.getHandler() != null){
RealTimeFragment.getHandler().sendMessage(message);
}
UsbDevice usbDevice = (UsbDevice)intent.getExtras().get("device");
if(usbDevice != null && usbDevice.getProductId() == 29987 && usbDevice.getVendorId() == 6790){
if(action == UsbManager.ACTION_USB_DEVICE_ATTACHED){
if(InitCH340.getDriver() == null){
InitCH340.initCH340(getApplicationContext(),handler);
}
if(InitCH340.isIsOpenDeviceCH340()){
Toast.makeText(getApplicationContext(),"ch340已打开",Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(getApplicationContext(),"ch340打开失败",Toast.LENGTH_SHORT).show();
}
UsbDevice mUsbDevice = InitCH340.getUsbDevice();
if(mUsbDevice != null){
}
}else if(action == UsbManager.ACTION_USB_DEVICE_DETACHED){
}
}
}
};
public static void insertMageticData(SQLiteDatabase writableDatabase,int x,int y,int x_surface,int y_surface,int z_surface,String time){
if(writableDatabase == null)return;
ContentValues values = new ContentValues();
values.put("x",x);
values.put("y",y);
values.put("x_surface",x_surface);
values.put("y_surface",y_surface);
values.put("z_surface",z_surface);
values.put("time",time);
writableDatabase.insert("MagneticData",null,values);
}
public static void insertNameList(String name){
if(writableDatabase == null){
return;
}
ContentValues values = new ContentValues();
values.put("name",name);
values.put("label",name);
writableDatabase.insert("NameList",null,values);
}
public static void parseDataAndSaveToDataBase(String data){
if(other_length > 0){
data = other_data + data;
}
if(data.length() >= 5 && data.startsWith("START")){
isValid = true;
@SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMMdd-HHmmss");
Date curDate = new Date(System.currentTimeMillis());
time = formatter.format(curDate);
insertNameList(time);
data = data.substring(5);
}
while(isValid && data.length() >= 38){
x = Integer.parseInt(data.substring(0,4));
y = Integer.parseInt(data.substring(4,8));
gmi_ch1_integer = Integer.parseInt(data.substring(8,14));
gmi_ch2_integer = Integer.parseInt(data.substring(18,24));
gmi_ch3_integer = Integer.parseInt(data.substring(28,34));
insertMageticData(writableDatabase,x,y,gmi_ch1_integer,gmi_ch2_integer,gmi_ch3_integer,time);
data = data.substring(38);
}
other_length = data.length();
other_data = data;
if(data.endsWith("STOP")){
isValid = false;
other_length = 0;
other_data = null;
}
}
}
| 10,615 | 0.622347 | 0.614067 | 268 | 38.205223 | 29.400459 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.738806 | false | false | 11 |
d0384bd8a8d5bf4c6079139b9f7b584e8f524482 | 36,971,078,516,547 | 7bcff4d958998ea45baa9dfcce9fee706e23f9b0 | /hobbydoge-backend/src/main/java/org/koroglu/hobbydoge/service/SurveyService.java | 2544ee433dc1cc48de7fa0731db840bed0662705 | [] | no_license | BBM384-2021/final-koroglu | https://github.com/BBM384-2021/final-koroglu | f6e53e7c7e8792e629870317f28fd695ec071702 | 8ff3d02766fea5b0e4d9d164f3f04db5e7909721 | refs/heads/main | 2023-05-04T01:32:49.643000 | 2021-05-27T10:57:11 | 2021-05-27T10:57:11 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.koroglu.hobbydoge.service;
import org.koroglu.hobbydoge.controller.request.AddSurveyRequest;
import org.koroglu.hobbydoge.controller.request.ClubRequest;
import org.koroglu.hobbydoge.controller.request.NewClubRequest;
import org.koroglu.hobbydoge.controller.request.NewSurveyAnswerRequest;
import org.koroglu.hobbydoge.dto.model.ClubDTO;
import org.koroglu.hobbydoge.dto.model.SurveyPointDTO;
import org.koroglu.hobbydoge.dto.model.SurveyQuestionDTO;
import org.koroglu.hobbydoge.model.SurveyQuestion;
import java.util.HashMap;
import java.util.List;
public interface SurveyService {
List<SurveyQuestionDTO> getSurvey(Long clubId);
List<SurveyQuestionDTO> createSurvey(AddSurveyRequest addSurveyRequest);
List<SurveyQuestionDTO> updateSurvey(AddSurveyRequest addSurveyRequest);
SurveyPointDTO answerSurvey(NewSurveyAnswerRequest newSurveyAnswerRequest);
SurveyPointDTO getSurveyPoint(Long clubId);
}
| UTF-8 | Java | 930 | java | SurveyService.java | Java | [] | null | [] | package org.koroglu.hobbydoge.service;
import org.koroglu.hobbydoge.controller.request.AddSurveyRequest;
import org.koroglu.hobbydoge.controller.request.ClubRequest;
import org.koroglu.hobbydoge.controller.request.NewClubRequest;
import org.koroglu.hobbydoge.controller.request.NewSurveyAnswerRequest;
import org.koroglu.hobbydoge.dto.model.ClubDTO;
import org.koroglu.hobbydoge.dto.model.SurveyPointDTO;
import org.koroglu.hobbydoge.dto.model.SurveyQuestionDTO;
import org.koroglu.hobbydoge.model.SurveyQuestion;
import java.util.HashMap;
import java.util.List;
public interface SurveyService {
List<SurveyQuestionDTO> getSurvey(Long clubId);
List<SurveyQuestionDTO> createSurvey(AddSurveyRequest addSurveyRequest);
List<SurveyQuestionDTO> updateSurvey(AddSurveyRequest addSurveyRequest);
SurveyPointDTO answerSurvey(NewSurveyAnswerRequest newSurveyAnswerRequest);
SurveyPointDTO getSurveyPoint(Long clubId);
}
| 930 | 0.849462 | 0.849462 | 26 | 34.76923 | 28.529753 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.615385 | false | false | 11 |
99729f5181cfa91ac6a1f97aa11058263570cc39 | 36,971,078,515,431 | f8db050ceb4570ce53bc73d75b5a3de57caf8041 | /PETYAANDSTRINGS.java | b20b67bf77357c7a47acd1fef7be4549c6d89f6b | [] | no_license | yashk2000/PR0BL3M_SoLV1nG | https://github.com/yashk2000/PR0BL3M_SoLV1nG | a62bcae104fe33723372267103778ecb06d31c0a | 5f5f01fcb2f675ab77e24795eb4e72a3ff0a65c7 | refs/heads/master | 2020-04-02T21:41:36.721000 | 2020-01-02T10:46:10 | 2020-01-02T10:46:10 | 154,808,604 | 0 | 1 | null | false | 2018-10-29T07:15:37 | 2018-10-26T09:15:19 | 2018-10-29T05:35:27 | 2018-10-29T07:14:15 | 26 | 0 | 2 | 2 | Java | false | null | import java.util.*;
public class solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
String ss=sc.nextLine();
String s1=s.toLowerCase();
String s2=ss.toLowerCase();
int flag=0;
for (int i=0;i<s1.length();i++)
if (s1.charAt(i)==s2.charAt(i))
continue;
else if (s1.charAt(i)<s2.charAt(i)) {
flag=-1;
break;
}
else {
flag=1;
break;
}
System.out.println(flag);
}
}
| UTF-8 | Java | 506 | java | PETYAANDSTRINGS.java | Java | [] | null | [] | import java.util.*;
public class solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
String ss=sc.nextLine();
String s1=s.toLowerCase();
String s2=ss.toLowerCase();
int flag=0;
for (int i=0;i<s1.length();i++)
if (s1.charAt(i)==s2.charAt(i))
continue;
else if (s1.charAt(i)<s2.charAt(i)) {
flag=-1;
break;
}
else {
flag=1;
break;
}
System.out.println(flag);
}
}
| 506 | 0.56917 | 0.547431 | 26 | 17.461538 | 13.039085 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.692308 | false | false | 11 |
72c020d1febf840b96674354dd6fbb1addf704cc | 38,826,504,371,301 | 4d65368b07ef8b20654871b9b4c2838485b6d2df | /common/src/main/java/com/thinkgem/jeesite/common/utils/UserUtils.java | da58b5f4e7005cd45b28b19c88c36fed5733de92 | [
"Apache-2.0"
] | permissive | guolf/jeesite | https://github.com/guolf/jeesite | 584cf869fbd85c3e47b69035bc97f2bfe5e55430 | ebecf261a3f72c791bc5dc9072c72dce971555d5 | refs/heads/master | 2021-01-01T20:01:34.962000 | 2017-09-23T07:10:40 | 2017-09-23T07:11:35 | 98,741,315 | 0 | 0 | null | true | 2017-07-29T15:28:19 | 2017-07-29T15:28:19 | 2017-07-29T13:30:06 | 2017-07-27T10:41:58 | 60,769 | 0 | 0 | 0 | null | null | null | package com.thinkgem.jeesite.common.utils;
import com.thinkgem.jeesite.common.entity.User;
import com.thinkgem.jeesite.common.security.shiro.Principal;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.UnavailableSecurityManagerException;
import org.apache.shiro.session.InvalidSessionException;
import org.apache.shiro.subject.Subject;
/**
* Created by guolf on 17/8/22.
*/
public class UserUtils {
public static Principal getPrincipal(){
try{
Subject subject = SecurityUtils.getSubject();
Principal principal = (Principal)subject.getPrincipal();
if (principal != null){
return principal;
}
}catch (UnavailableSecurityManagerException e) {
}catch (InvalidSessionException e){
}
return null;
}
public static User getUser(){
Principal principal = getPrincipal();
if (principal!=null){
User user = new User() ;//get(principal.getId());
if (user != null){
return user;
}
return new User();
}
return new User();
}
}
| UTF-8 | Java | 1,149 | java | UserUtils.java | Java | [
{
"context": "g.apache.shiro.subject.Subject;\n\n/**\n * Created by guolf on 17/8/22.\n */\npublic class UserUtils {\n\n pub",
"end": 375,
"score": 0.9995065331459045,
"start": 370,
"tag": "USERNAME",
"value": "guolf"
}
] | null | [] | package com.thinkgem.jeesite.common.utils;
import com.thinkgem.jeesite.common.entity.User;
import com.thinkgem.jeesite.common.security.shiro.Principal;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.UnavailableSecurityManagerException;
import org.apache.shiro.session.InvalidSessionException;
import org.apache.shiro.subject.Subject;
/**
* Created by guolf on 17/8/22.
*/
public class UserUtils {
public static Principal getPrincipal(){
try{
Subject subject = SecurityUtils.getSubject();
Principal principal = (Principal)subject.getPrincipal();
if (principal != null){
return principal;
}
}catch (UnavailableSecurityManagerException e) {
}catch (InvalidSessionException e){
}
return null;
}
public static User getUser(){
Principal principal = getPrincipal();
if (principal!=null){
User user = new User() ;//get(principal.getId());
if (user != null){
return user;
}
return new User();
}
return new User();
}
}
| 1,149 | 0.623151 | 0.618799 | 41 | 27.024391 | 20.962788 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.414634 | false | false | 11 |
99a5d86aff82dc127a0b96f1de22a403dd3442f1 | 33,887,292,023,508 | 87fdfaa47f5dcf531757784f86918798996fbc52 | /src/java/servlets/EditAccountantForm.java | 62c70cd38f8b40a49861fe9f68d726f35097dfae | [
"MIT"
] | permissive | PhilippauxAdrien/ProjetPOO | https://github.com/PhilippauxAdrien/ProjetPOO | 3f939f983284b14ae9090e67bec4691bb88ccaf8 | 0dc539cf3fc2e82d129f4689866cff3880580bbf | refs/heads/master | 2020-03-19T01:51:55.877000 | 2018-06-04T09:23:34 | 2018-06-04T09:23:34 | 135,578,309 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import beans.AccountantBean;
import beans.StudentBean;
import dao.AccountantDao;
import dao.StudentDao;
@WebServlet("/EditAccountantForm")
public class EditAccountantForm extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
String sid = request.getParameter("id") != null ? request.getParameter("id") : "0";
int id = Integer.parseInt(sid);
AccountantBean bean = AccountantDao.getRecordById(id);
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Edit Accountant</title>");
out.println("<link rel='stylesheet' href='resources/bootstrap.min.css'/>");
out.println("<link rel='stylesheet' href='style.css'/>");
out.println("</head>");
out.println("<body>");
request.getRequestDispatcher("navadmin.html").include(request, response);
out.println("<div class='container'>");
out.print("<h1>Edit Accountant Form</h1>");
out.println("<form action=\"EditAccountant\" method=\"post\">");
out.println(
"<div class=\"form-group\"><input type=\"hidden\" name=\"id\" value=\"" + bean.getId() + "\" required></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputFirstname\">Firstname</label><input type=\"text\" class=\"form-control\" id=\"inputFirstname\" name=\"firstname\" value=\""
+ bean.getFirstname() + "\" required></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputLastname\">Lastname</label><input type=\"text\" class=\"form-control\" id=\"inputLastname\" name=\"lastname\" value=\""
+ bean.getLastname() + "\" required></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputPassword\">Password</label><input type=\"password\" class=\"form-control\" id=\"inputPassword\" name=\"password\" value=\""
+ bean.getPassword() + "\" required></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputEmail\">Email</label><input type=\"email\" class=\"form-control\" id=\"inputEmail\" name=\"email\" value=\""
+ bean.getEmail() + "\" required></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputAddress\">Address</label><textarea class=\"form-control\" name=\"address\" id=\"inputAddress\" rows=\"3\">"
+ bean.getAddress() + "</textarea></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputRole\">Rôle</label><input type=\"number\" class=\"form-control\" id=\"inputRole\" name=\"role\" value=\""
+ bean.getRole() + "\" required></div>");
out.println("<button type=\"submit\" class=\"btn btn-default\">Update Accountant</button>");
out.println("</form>");
out.println("</div>");
request.getRequestDispatcher("footer.html").include(request, response);
out.println("</body>");
out.println("</html>");
out.close();
}
}
| UTF-8 | Java | 3,648 | java | EditAccountantForm.java | Java | [] | null | [] | package servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import beans.AccountantBean;
import beans.StudentBean;
import dao.AccountantDao;
import dao.StudentDao;
@WebServlet("/EditAccountantForm")
public class EditAccountantForm extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
String sid = request.getParameter("id") != null ? request.getParameter("id") : "0";
int id = Integer.parseInt(sid);
AccountantBean bean = AccountantDao.getRecordById(id);
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Edit Accountant</title>");
out.println("<link rel='stylesheet' href='resources/bootstrap.min.css'/>");
out.println("<link rel='stylesheet' href='style.css'/>");
out.println("</head>");
out.println("<body>");
request.getRequestDispatcher("navadmin.html").include(request, response);
out.println("<div class='container'>");
out.print("<h1>Edit Accountant Form</h1>");
out.println("<form action=\"EditAccountant\" method=\"post\">");
out.println(
"<div class=\"form-group\"><input type=\"hidden\" name=\"id\" value=\"" + bean.getId() + "\" required></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputFirstname\">Firstname</label><input type=\"text\" class=\"form-control\" id=\"inputFirstname\" name=\"firstname\" value=\""
+ bean.getFirstname() + "\" required></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputLastname\">Lastname</label><input type=\"text\" class=\"form-control\" id=\"inputLastname\" name=\"lastname\" value=\""
+ bean.getLastname() + "\" required></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputPassword\">Password</label><input type=\"password\" class=\"form-control\" id=\"inputPassword\" name=\"password\" value=\""
+ bean.getPassword() + "\" required></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputEmail\">Email</label><input type=\"email\" class=\"form-control\" id=\"inputEmail\" name=\"email\" value=\""
+ bean.getEmail() + "\" required></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputAddress\">Address</label><textarea class=\"form-control\" name=\"address\" id=\"inputAddress\" rows=\"3\">"
+ bean.getAddress() + "</textarea></div>");
out.println(
"<div class=\"form-group\"><label for=\"inputRole\">Rôle</label><input type=\"number\" class=\"form-control\" id=\"inputRole\" name=\"role\" value=\""
+ bean.getRole() + "\" required></div>");
out.println("<button type=\"submit\" class=\"btn btn-default\">Update Accountant</button>");
out.println("</form>");
out.println("</div>");
request.getRequestDispatcher("footer.html").include(request, response);
out.println("</body>");
out.println("</html>");
out.close();
}
}
| 3,648 | 0.601042 | 0.599671 | 75 | 46.626667 | 47.361523 | 184 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.626667 | false | false | 11 |
8ccd5603d07c5459132e14e056d5b7e9263e71c4 | 38,878,044,007,351 | 5bb2ddd2ff756d4ba1de9cc01653a5d906515780 | /common/src/test/java/eu/cloudnetservice/common/io/ZipUtilTest.java | 09c1ebbc72c7379442718641071ec70b82a270fa | [
"Apache-2.0"
] | permissive | CloudNetService/CloudNet-v3 | https://github.com/CloudNetService/CloudNet-v3 | 7aac3162219068333deb7854a009276ca846b71a | fe1e270eab29e540d7691f1c09293ebf42197ddd | refs/heads/nightly | 2023-08-31T18:18:21.220000 | 2023-08-22T14:15:56 | 2023-08-22T14:15:56 | 187,873,041 | 431 | 365 | Apache-2.0 | false | 2023-09-09T09:41:16 | 2019-05-21T16:12:57 | 2023-09-05T03:54:48 | 2023-09-09T09:41:15 | 105,041 | 321 | 114 | 71 | Java | false | false | /*
* Copyright 2019-2023 CloudNetService team & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package eu.cloudnetservice.common.io;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.zip.ZipFile;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public final class ZipUtilTest {
private static final Path TEST_DIR = Path.of("build", "testDirectory");
@BeforeAll
static void setupTestDirectories() {
FileUtil.createDirectory(TEST_DIR);
}
@AfterAll
static void removeTestDirectories() {
FileUtil.delete(TEST_DIR);
}
@Test
void testZipUtils() throws Exception {
var zipFilePath = TEST_DIR.resolve("test.zip").toAbsolutePath();
try (
var out = Files.newOutputStream(zipFilePath);
var is = ZipUtilTest.class.getClassLoader().getResourceAsStream("empty_zip_file.zip")
) {
FileUtil.copy(is, out);
}
FileUtil.openZipFile(zipFilePath, fileSystem -> {
var zipEntryInfoFile = fileSystem.getPath("info.txt");
try (
var out = Files.newOutputStream(zipEntryInfoFile);
var is = new ByteArrayInputStream("Info message :3".getBytes())
) {
FileUtil.copy(is, out);
}
});
try (var out = new ByteArrayOutputStream(); var zipFile = new ZipFile(zipFilePath.toFile())) {
var zipEntry = zipFile.getEntry("info.txt");
Assertions.assertNotNull(zipEntry);
try (var inputStream = zipFile.getInputStream(zipEntry)) {
FileUtil.copy(inputStream, out);
}
Assertions.assertEquals("Info message :3", out.toString(StandardCharsets.UTF_8));
}
FileUtil.delete(TEST_DIR);
Assertions.assertFalse(Files.exists(TEST_DIR));
}
@Test
void testExtractZip() throws Exception {
var zipFilePath = TEST_DIR.resolve("test.zip");
try (
var outputStream = Files.newOutputStream(zipFilePath);
var is = ZipUtilTest.class.getClassLoader().getResourceAsStream("file_utils_resources.zip")
) {
FileUtil.copy(is, outputStream);
}
ZipUtil.extract(zipFilePath, TEST_DIR);
Assertions.assertTrue(Files.exists(TEST_DIR));
Assertions.assertTrue(Files.exists(TEST_DIR.resolve("bungee/config.yml")));
Assertions.assertTrue(Files.exists(TEST_DIR.resolve("nms/bukkit.yml")));
Assertions.assertTrue(Files.exists(TEST_DIR.resolve("nms/server.properties")));
}
}
| UTF-8 | Java | 3,113 | java | ZipUtilTest.java | Java | [] | null | [] | /*
* Copyright 2019-2023 CloudNetService team & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package eu.cloudnetservice.common.io;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.zip.ZipFile;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public final class ZipUtilTest {
private static final Path TEST_DIR = Path.of("build", "testDirectory");
@BeforeAll
static void setupTestDirectories() {
FileUtil.createDirectory(TEST_DIR);
}
@AfterAll
static void removeTestDirectories() {
FileUtil.delete(TEST_DIR);
}
@Test
void testZipUtils() throws Exception {
var zipFilePath = TEST_DIR.resolve("test.zip").toAbsolutePath();
try (
var out = Files.newOutputStream(zipFilePath);
var is = ZipUtilTest.class.getClassLoader().getResourceAsStream("empty_zip_file.zip")
) {
FileUtil.copy(is, out);
}
FileUtil.openZipFile(zipFilePath, fileSystem -> {
var zipEntryInfoFile = fileSystem.getPath("info.txt");
try (
var out = Files.newOutputStream(zipEntryInfoFile);
var is = new ByteArrayInputStream("Info message :3".getBytes())
) {
FileUtil.copy(is, out);
}
});
try (var out = new ByteArrayOutputStream(); var zipFile = new ZipFile(zipFilePath.toFile())) {
var zipEntry = zipFile.getEntry("info.txt");
Assertions.assertNotNull(zipEntry);
try (var inputStream = zipFile.getInputStream(zipEntry)) {
FileUtil.copy(inputStream, out);
}
Assertions.assertEquals("Info message :3", out.toString(StandardCharsets.UTF_8));
}
FileUtil.delete(TEST_DIR);
Assertions.assertFalse(Files.exists(TEST_DIR));
}
@Test
void testExtractZip() throws Exception {
var zipFilePath = TEST_DIR.resolve("test.zip");
try (
var outputStream = Files.newOutputStream(zipFilePath);
var is = ZipUtilTest.class.getClassLoader().getResourceAsStream("file_utils_resources.zip")
) {
FileUtil.copy(is, outputStream);
}
ZipUtil.extract(zipFilePath, TEST_DIR);
Assertions.assertTrue(Files.exists(TEST_DIR));
Assertions.assertTrue(Files.exists(TEST_DIR.resolve("bungee/config.yml")));
Assertions.assertTrue(Files.exists(TEST_DIR.resolve("nms/bukkit.yml")));
Assertions.assertTrue(Files.exists(TEST_DIR.resolve("nms/server.properties")));
}
}
| 3,113 | 0.708962 | 0.704144 | 99 | 30.444445 | 28.182028 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.494949 | false | false | 11 |
fcd2979f804c2dc4cf1c89d02b2b69de6705d659 | 39,402,029,982,857 | a62d2406f5fb2b1fa187187215b5432b6dbaf2b8 | /src/main/java/org/tlw/MyPaperless/models/Observations.java | 5604e17864b14f483dde459d11e64b04ce4773b7 | [] | no_license | twilks18/MyPaperlessLabNotebook | https://github.com/twilks18/MyPaperlessLabNotebook | 0b15485b1d938483b2fcfb611a1e959904980924 | 88382ccec23675ceecccb1832afb60d56789e226 | refs/heads/master | 2021-01-12T03:45:46.395000 | 2018-06-29T04:47:45 | 2018-06-29T04:47:45 | 78,262,068 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.tlw.MyPaperless.models;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Entity
public class Observations {
@Id
private int observid;
@NotNull
@Lob
@Size(min=1000, message = "Either you did not add observations or its just too short")
private String observation;
@OneToOne
@JoinColumn(name="intro_id",nullable = false)
private Intro intro;
public Observations(String observation) {
this.observation = observation;
}
public Observations() {
}
public int getObservid() {
return observid;
}
public void setObservid(int observid) {
this.observid = observid;
}
public String getObservation() {
return observation;
}
public void setObservation(String observation) {
this.observation = observation;
}
public Intro getIntro() {
return intro;
}
public void setIntro(Intro intro) {
this.intro = intro;
}
}
| UTF-8 | Java | 1,044 | java | Observations.java | Java | [] | null | [] | package org.tlw.MyPaperless.models;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Entity
public class Observations {
@Id
private int observid;
@NotNull
@Lob
@Size(min=1000, message = "Either you did not add observations or its just too short")
private String observation;
@OneToOne
@JoinColumn(name="intro_id",nullable = false)
private Intro intro;
public Observations(String observation) {
this.observation = observation;
}
public Observations() {
}
public int getObservid() {
return observid;
}
public void setObservid(int observid) {
this.observid = observid;
}
public String getObservation() {
return observation;
}
public void setObservation(String observation) {
this.observation = observation;
}
public Intro getIntro() {
return intro;
}
public void setIntro(Intro intro) {
this.intro = intro;
}
}
| 1,044 | 0.652299 | 0.648467 | 52 | 19.076923 | 19.208218 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.307692 | false | false | 11 |
197e9b6c2ed9174ee812b64117c81588afac0f73 | 37,022,618,127,650 | d2fe337452fa1f0dcbe48a7c76e7453c32fd47f4 | /src/main/java/javase/algorithm/search/BubbleSort.java | 06553234657bd41935683c299d778d611ac820dd | [] | no_license | 623162052/java-samples | https://github.com/623162052/java-samples | c1b5183902c288950293ab4771135e2ffb90d1d7 | b508ab8f45367a9167530d92b8243077de7625e7 | refs/heads/master | 2021-01-21T11:49:16.603000 | 2017-09-12T08:38:36 | 2017-09-12T08:38:36 | 102,021,679 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package javase.algorithm.search;
/**
* @author 嗷嗷
* 冒泡排序
*
*/
public class BubbleSort {
private int[] arrayBubble;
private static int flag;
private BubbleSort(int length)
{
arrayBubble = new int[length];
flag = 0;
}
private void insert(int value){
arrayBubble[flag] = value;
flag++;
}
private void swap(int a,int b){
int temp = arrayBubble[a];
arrayBubble[a] = arrayBubble[b];
arrayBubble[b] = temp;
}
/*未优化的冒泡排序算法*/
private void sortArray(){
for(int i=0;i<arrayBubble.length;i++)
for(int j=0;j<arrayBubble.length-1 ;j++){
if(arrayBubble[j]>arrayBubble[j+1])
swap(j,j+1);
}
}
/*优化过的冒泡排序算法*/
// private void sortArray(){
// for(int i=0;i<arrayBubble.length;i++)
// for(int j=arrayBubble.length-1; j>0;j--)
// if(arrayBubble[j]<arrayBubble[j-1])
// swap(j,j-1);
// }
private void display(){
for(int i=0;i<arrayBubble.length;i++)
System.out.print(arrayBubble[i] + " ");
System.out.println();
}
public static void main(String[] args){
BubbleSort bs = new BubbleSort(10);
bs.insert(10);
bs.insert(9);
bs.insert(8);
bs.insert(7);
bs.insert(6);
bs.insert(5);
bs.insert(4);
bs.insert(3);
bs.insert(2);
bs.insert(1);
bs.display();
bs.sortArray();
bs.display();
}
}
| GB18030 | Java | 1,358 | java | BubbleSort.java | Java | [
{
"context": "\npackage javase.algorithm.search;\n\n/**\n * @author 嗷嗷\n * 冒泡排序\n *\n */\npublic class BubbleSort {\n\t\n\tpriva",
"end": 52,
"score": 0.9995835423469543,
"start": 50,
"tag": "NAME",
"value": "嗷嗷"
}
] | null | [] |
package javase.algorithm.search;
/**
* @author 嗷嗷
* 冒泡排序
*
*/
public class BubbleSort {
private int[] arrayBubble;
private static int flag;
private BubbleSort(int length)
{
arrayBubble = new int[length];
flag = 0;
}
private void insert(int value){
arrayBubble[flag] = value;
flag++;
}
private void swap(int a,int b){
int temp = arrayBubble[a];
arrayBubble[a] = arrayBubble[b];
arrayBubble[b] = temp;
}
/*未优化的冒泡排序算法*/
private void sortArray(){
for(int i=0;i<arrayBubble.length;i++)
for(int j=0;j<arrayBubble.length-1 ;j++){
if(arrayBubble[j]>arrayBubble[j+1])
swap(j,j+1);
}
}
/*优化过的冒泡排序算法*/
// private void sortArray(){
// for(int i=0;i<arrayBubble.length;i++)
// for(int j=arrayBubble.length-1; j>0;j--)
// if(arrayBubble[j]<arrayBubble[j-1])
// swap(j,j-1);
// }
private void display(){
for(int i=0;i<arrayBubble.length;i++)
System.out.print(arrayBubble[i] + " ");
System.out.println();
}
public static void main(String[] args){
BubbleSort bs = new BubbleSort(10);
bs.insert(10);
bs.insert(9);
bs.insert(8);
bs.insert(7);
bs.insert(6);
bs.insert(5);
bs.insert(4);
bs.insert(3);
bs.insert(2);
bs.insert(1);
bs.display();
bs.sortArray();
bs.display();
}
}
| 1,358 | 0.604135 | 0.584992 | 75 | 16.24 | 14.16177 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.173333 | false | false | 11 |
e1445dd571ce166acc4e57adaf1ab29cc979a908 | 35,527,969,518,971 | 3571e8cf1a9c21a2ad7960039efce7aa8911943d | /ManagementCompany.java | 54807288aa95c420c113eaa1e4afcfcb529c536c | [] | no_license | avenir1984/avenirtouwe | https://github.com/avenir1984/avenirtouwe | 1f0cdb51e37cabf8f382e9577b8266ef4f728b9a | faa524cd327399473f96d98d5d1660d4c6a4b3fd | refs/heads/master | 2023-01-01T07:41:24.899000 | 2020-10-26T00:28:10 | 2020-10-26T00:28:10 | 273,534,672 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class ManagementCompany {
private int MAX_PROPERTY;
private double mgmFeePer;
private String name;
private Property[] properties;
private String taxID;
private int MGMT_WIDTH = 10;
private int MGMT_DEPTH = 10;
private Plot plot;
/**No-Arg Constructor that creates a ManagementCompany
* object using empty strings and the plot set to a Plot with x, y set to 0 , width and depth set to 10.
properties array is initialized here as well.
*/
public ManagementCompany() {
this.name = "";
this.taxID = "";
this.mgmFeePer = 0;
this.plot = new Plot(0, 0,MGMT_WIDTH ,MGMT_DEPTH );
properties = new Property[MAX_PROPERTY];
}
/**Constructor Creates a ManagementCompany object using the passed information.
plot is set to a Plot with x, y set to 0 , width and depth set to 10
properties array is initialized here as well
*/
public ManagementCompany(String name, String taxID, double mgmFee) {
this.properties = new Property[MAX_PROPERTY];
this.name = name;
this.taxID = taxID;
this.mgmFeePer = mgmFee;
this.plot = new Plot(0, 0, MGMT_WIDTH, MGMT_DEPTH);
}
/**Constructor Creates a ManagementCompany object using the passed information.
*/
public ManagementCompany(String name, String taxID, double mgmFee, int x, int y, int width, int depth) {
this.properties = new Property[MAX_PROPERTY];
this.name = name;
this.taxID = taxID;
this.mgmFeePer = mgmFee;
this.plot = new Plot(x,y,width,depth);
}
/**Copy Constructor creates a ManagementCompany object using another ManagementCompany object.
* "properties" array is initialized here as well.
Parameters:
otherCompany - another management company
*/
public ManagementCompany(ManagementCompany otherCompany) {
this.properties = new Property[MAX_PROPERTY];
this.name = otherCompany.name;
this.taxID = otherCompany.taxID;
this.mgmFeePer = otherCompany.mgmFeePer;
this.plot = new Plot(otherCompany.plot);
}
/**Return the MAX_PROPERTY constant that represent the size of the "properties" array.
Returns:
the MAX_PROPERTY a constant attribute for this class that is set 5
*/
public int getMAX_PROPERTY()
{
return MAX_PROPERTY;
}
/**Adds the property object to the "properties" array.
*Parameters:
* property - a property object
* Returns:
Returns either -1 if the array is full, -2 if property is null,
-3 if the plot is not contained by the MgmtCo plot, -4 of the plot overlaps any other property,
or the index in the array where the property was added successfully.
*/
public int addProperty(Property property) {
if(property == null) {
return -2;
}
if(!plot.encompasses(property.getPlot())){
return -3;
}
for (int i = 0;i < properties.length; i++) {
if (properties[i] != null) {
if(properties[i].getPlot().overlaps(property.getPlot())) {
return -4;
}
}
else {
properties[i] = property;
return i;
}
}
return -1;
}
/**Creates a property object and adds it to the "properties" array, in a default plot.
Parameters:
name - property name
city - location of the property
rent - monthly rent
owner - owner of the property
*/
public int addProperty(String name,String city,double rent,String owner) {
return addProperty(new Property(name, city, rent, owner));
}
/** Method that creates object and adds it to properties array
* param name
* param city
* param rent
* param owner
* param x
* param y
* param width
* param depth
* return conditional values
*/
public int addProperty(String name, String city, double rent, String owner, int x, int y, int width, int depth)
{
return addProperty(new Property(name, city, rent, owner, x, y, width, depth));
}
/**
* Method that finds total rent of all properties
* @return total
*/
public double totalRent()
{
double total = 0.0;
for (Property property : properties)
{
if (property == null)
{
break;
}
total += property.getRentAmount();
}
return total;
}
/**
* Method that finds maximum rent amount out of all properties and returns it
* @return maxRentAmount
*/
public double maxRentProp()
{
double maxRentProp =0.0 ;
int count = 0;
for(int i = 0; i < count; i++) {
if(properties[i] != null) {
maxRentProp += properties[i].getRentAmount();
}
}
return maxRentProp ;
}
/**
* Method that finds index of property that has maximum rent amount
* @return index
*/
public int maxPropertyRentIndex() {
int indexOFMaxRent=0;
int index = 0;
for (int i =0; i < index; i++) {
if(properties[i] != null) {
if(properties[indexOFMaxRent].getRentAmount() < properties[i].getRentAmount()) {
indexOFMaxRent = i;
}
}
}
return indexOFMaxRent;
}
/**
* Method that takes index of a property and returns information
* @param i
* @return string
*/
public String displayPropertyAtIndex(int i)
{
String string = properties[i].toString();
return string;
}
/**
* To string
* @return string
*/
public String toString(){
String output = "";
for (int i=0; i<MAX_PROPERTY;i++) {
if(properties[i]==null){
break;
}
output += properties[i].toString()+"\n";
}
return "List of the properties for " + name + ", taxID: " + taxID + "\n___________________________________\n"+output+"\n"
+ "___________________________________\ntotal " + "management Fee: "+(totalRent()*mgmFeePer/100);
}
}
| UTF-8 | Java | 6,837 | java | ManagementCompany.java | Java | [] | null | [] |
public class ManagementCompany {
private int MAX_PROPERTY;
private double mgmFeePer;
private String name;
private Property[] properties;
private String taxID;
private int MGMT_WIDTH = 10;
private int MGMT_DEPTH = 10;
private Plot plot;
/**No-Arg Constructor that creates a ManagementCompany
* object using empty strings and the plot set to a Plot with x, y set to 0 , width and depth set to 10.
properties array is initialized here as well.
*/
public ManagementCompany() {
this.name = "";
this.taxID = "";
this.mgmFeePer = 0;
this.plot = new Plot(0, 0,MGMT_WIDTH ,MGMT_DEPTH );
properties = new Property[MAX_PROPERTY];
}
/**Constructor Creates a ManagementCompany object using the passed information.
plot is set to a Plot with x, y set to 0 , width and depth set to 10
properties array is initialized here as well
*/
public ManagementCompany(String name, String taxID, double mgmFee) {
this.properties = new Property[MAX_PROPERTY];
this.name = name;
this.taxID = taxID;
this.mgmFeePer = mgmFee;
this.plot = new Plot(0, 0, MGMT_WIDTH, MGMT_DEPTH);
}
/**Constructor Creates a ManagementCompany object using the passed information.
*/
public ManagementCompany(String name, String taxID, double mgmFee, int x, int y, int width, int depth) {
this.properties = new Property[MAX_PROPERTY];
this.name = name;
this.taxID = taxID;
this.mgmFeePer = mgmFee;
this.plot = new Plot(x,y,width,depth);
}
/**Copy Constructor creates a ManagementCompany object using another ManagementCompany object.
* "properties" array is initialized here as well.
Parameters:
otherCompany - another management company
*/
public ManagementCompany(ManagementCompany otherCompany) {
this.properties = new Property[MAX_PROPERTY];
this.name = otherCompany.name;
this.taxID = otherCompany.taxID;
this.mgmFeePer = otherCompany.mgmFeePer;
this.plot = new Plot(otherCompany.plot);
}
/**Return the MAX_PROPERTY constant that represent the size of the "properties" array.
Returns:
the MAX_PROPERTY a constant attribute for this class that is set 5
*/
public int getMAX_PROPERTY()
{
return MAX_PROPERTY;
}
/**Adds the property object to the "properties" array.
*Parameters:
* property - a property object
* Returns:
Returns either -1 if the array is full, -2 if property is null,
-3 if the plot is not contained by the MgmtCo plot, -4 of the plot overlaps any other property,
or the index in the array where the property was added successfully.
*/
public int addProperty(Property property) {
if(property == null) {
return -2;
}
if(!plot.encompasses(property.getPlot())){
return -3;
}
for (int i = 0;i < properties.length; i++) {
if (properties[i] != null) {
if(properties[i].getPlot().overlaps(property.getPlot())) {
return -4;
}
}
else {
properties[i] = property;
return i;
}
}
return -1;
}
/**Creates a property object and adds it to the "properties" array, in a default plot.
Parameters:
name - property name
city - location of the property
rent - monthly rent
owner - owner of the property
*/
public int addProperty(String name,String city,double rent,String owner) {
return addProperty(new Property(name, city, rent, owner));
}
/** Method that creates object and adds it to properties array
* param name
* param city
* param rent
* param owner
* param x
* param y
* param width
* param depth
* return conditional values
*/
public int addProperty(String name, String city, double rent, String owner, int x, int y, int width, int depth)
{
return addProperty(new Property(name, city, rent, owner, x, y, width, depth));
}
/**
* Method that finds total rent of all properties
* @return total
*/
public double totalRent()
{
double total = 0.0;
for (Property property : properties)
{
if (property == null)
{
break;
}
total += property.getRentAmount();
}
return total;
}
/**
* Method that finds maximum rent amount out of all properties and returns it
* @return maxRentAmount
*/
public double maxRentProp()
{
double maxRentProp =0.0 ;
int count = 0;
for(int i = 0; i < count; i++) {
if(properties[i] != null) {
maxRentProp += properties[i].getRentAmount();
}
}
return maxRentProp ;
}
/**
* Method that finds index of property that has maximum rent amount
* @return index
*/
public int maxPropertyRentIndex() {
int indexOFMaxRent=0;
int index = 0;
for (int i =0; i < index; i++) {
if(properties[i] != null) {
if(properties[indexOFMaxRent].getRentAmount() < properties[i].getRentAmount()) {
indexOFMaxRent = i;
}
}
}
return indexOFMaxRent;
}
/**
* Method that takes index of a property and returns information
* @param i
* @return string
*/
public String displayPropertyAtIndex(int i)
{
String string = properties[i].toString();
return string;
}
/**
* To string
* @return string
*/
public String toString(){
String output = "";
for (int i=0; i<MAX_PROPERTY;i++) {
if(properties[i]==null){
break;
}
output += properties[i].toString()+"\n";
}
return "List of the properties for " + name + ", taxID: " + taxID + "\n___________________________________\n"+output+"\n"
+ "___________________________________\ntotal " + "management Fee: "+(totalRent()*mgmFeePer/100);
}
}
| 6,837 | 0.527863 | 0.522305 | 216 | 29.560184 | 27.037458 | 130 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.87037 | false | false | 11 |
b27eb973946342cb09da4dfd6c4b79826be9e4e0 | 35,880,156,835,024 | c156ebde1b19baa9f0e72eca1b7cf72e70e5ea87 | /src/test/java/com/oregonstate/snooze/controller/EditProfileControllerTest.java | 307a6511babcefb0c3f463b3fc585c3c587e5791 | [
"Apache-2.0"
] | permissive | ellenchenzl/Snooze-Schedule-System | https://github.com/ellenchenzl/Snooze-Schedule-System | 72aaae715800fc3e989f046ace2c97e7df6fd0d8 | cb47a75dea42a01fdbe6ba0af358c5f0b6e8b7a7 | refs/heads/master | 2020-12-05T02:40:35.588000 | 2018-12-06T04:01:47 | 2018-12-06T04:01:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | //package com.oregonstate.snooze.controller;
//
//import com.oregonstate.snooze.model.User;
//import org.junit.After;
//import org.junit.Before;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.test.context.ContextConfiguration;
//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
//
//import javax.annotation.Resource;
//
//import static org.junit.Assert.*;
//
//@RunWith(SpringJUnit4ClassRunner.class)
//@ContextConfiguration({"classpath*:/*.xml"})
//public class EditProfileControllerTest {
//
// @Resource
// @Autowired
// private EditProfileController editProfileController;
// @Autowired
// private SignUpController signUpController;
//
// @Before
// public void setUp() throws Exception {
// signUpController.signUp("TestEdit", "123456", "TestEdit@gmail.com");
// }
//
// @After
// public void tearDown() throws Exception {
// User user = signUpController.userService.selectByEmail("TestEdit@gmail.com");
// assertEquals(1,signUpController.userService.deleteByPrimaryKey(user.getUserId()));
// }
//
// @Test
// public void editProfile() {
// assertTrue(
// editProfileController.editProfile("user","123456", "TestNew", "1234567"));
// }
//} | UTF-8 | Java | 1,359 | java | EditProfileControllerTest.java | Java | [
{
"context": "ws Exception {\n// signUpController.signUp(\"TestEdit\", \"123456\", \"TestEdit@gmail.com\");\n// }\n//\n// ",
"end": 887,
"score": 0.7652947306632996,
"start": 879,
"tag": "USERNAME",
"value": "TestEdit"
},
{
"context": " signUpController.signUp(\"TestEdit\", \"123456\", \"TestEdit@gmail.com\");\n// }\n//\n// @After\n// public void tear",
"end": 919,
"score": 0.9999241232872009,
"start": 901,
"tag": "EMAIL",
"value": "TestEdit@gmail.com"
},
{
"context": "ser = signUpController.userService.selectByEmail(\"TestEdit@gmail.com\");\n// assertEquals(1,signUpController.user",
"end": 1079,
"score": 0.9999213218688965,
"start": 1061,
"tag": "EMAIL",
"value": "TestEdit@gmail.com"
},
{
"context": "itProfileController.editProfile(\"user\",\"123456\", \"TestNew\", \"1234567\"));\n// }\n//}",
"end": 1332,
"score": 0.9355868101119995,
"start": 1325,
"tag": "USERNAME",
"value": "TestNew"
}
] | null | [] | //package com.oregonstate.snooze.controller;
//
//import com.oregonstate.snooze.model.User;
//import org.junit.After;
//import org.junit.Before;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.test.context.ContextConfiguration;
//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
//
//import javax.annotation.Resource;
//
//import static org.junit.Assert.*;
//
//@RunWith(SpringJUnit4ClassRunner.class)
//@ContextConfiguration({"classpath*:/*.xml"})
//public class EditProfileControllerTest {
//
// @Resource
// @Autowired
// private EditProfileController editProfileController;
// @Autowired
// private SignUpController signUpController;
//
// @Before
// public void setUp() throws Exception {
// signUpController.signUp("TestEdit", "123456", "<EMAIL>");
// }
//
// @After
// public void tearDown() throws Exception {
// User user = signUpController.userService.selectByEmail("<EMAIL>");
// assertEquals(1,signUpController.userService.deleteByPrimaryKey(user.getUserId()));
// }
//
// @Test
// public void editProfile() {
// assertTrue(
// editProfileController.editProfile("user","123456", "TestNew", "1234567"));
// }
//} | 1,337 | 0.701987 | 0.685063 | 42 | 31.380953 | 26.791037 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.547619 | false | false | 11 |
ba81578edc10105e6416de9b512b0ffe9951fd38 | 31,361,851,264,935 | 5d351db42c7fa766cfb4d67f070d2e67b00e8cc8 | /src/net/endhq/util/Meta.java | 982be84be0525cf7d4af087b8d9fee26798e8d0e | [
"Apache-2.0"
] | permissive | MeRPG/EndHQ-Libraries | https://github.com/MeRPG/EndHQ-Libraries | f88ab1aefa4b5eb5f64ff0f0ff1b7b862b8a2f95 | b1083f258931d1e14c4f7751b84eb986276d9e74 | refs/heads/master | 2021-01-20T05:32:31.885000 | 2014-11-13T23:32:43 | 2014-11-13T23:32:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.endhq.util;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.metadata.Metadatable;
import org.bukkit.plugin.Plugin;
import java.util.List;
/**
* Created by J on 10/18/2014.
*/
public class Meta {
public static void setMetadata(Metadatable object, String key, Object value, Plugin plugin) {
object.setMetadata(key, new FixedMetadataValue(plugin, value));
}
public static Object getMetadata(Metadatable object, String key, Plugin plugin) {
List<MetadataValue> values = object.getMetadata(key);
for (MetadataValue value : values) {
if (value.getOwningPlugin() == plugin) {
return value.value();
}
}
return null;
}
}
| UTF-8 | Java | 812 | java | Meta.java | Java | [
{
"context": "n;\r\n\r\nimport java.util.List;\r\n\r\n/**\r\n * Created by J on 10/18/2014.\r\n */\r\npublic class Meta {\r\n pub",
"end": 241,
"score": 0.899726390838623,
"start": 240,
"tag": "USERNAME",
"value": "J"
}
] | null | [] | package net.endhq.util;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.metadata.Metadatable;
import org.bukkit.plugin.Plugin;
import java.util.List;
/**
* Created by J on 10/18/2014.
*/
public class Meta {
public static void setMetadata(Metadatable object, String key, Object value, Plugin plugin) {
object.setMetadata(key, new FixedMetadataValue(plugin, value));
}
public static Object getMetadata(Metadatable object, String key, Plugin plugin) {
List<MetadataValue> values = object.getMetadata(key);
for (MetadataValue value : values) {
if (value.getOwningPlugin() == plugin) {
return value.value();
}
}
return null;
}
}
| 812 | 0.651478 | 0.641626 | 27 | 28.074074 | 26.846514 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.62963 | false | false | 11 |
2b6f7f4fa405c2c08969da671df471d79417dbd8 | 9,715,216,066,814 | 2ffda6f3908ac2ec7779103c651297f30ed5298d | /app/src/main/java/com/example/maptest/MapsActivity.java | f1a8c39020462934a5252c59691fd9ffefe8d7c9 | [] | no_license | hmendoza23/Homework-3 | https://github.com/hmendoza23/Homework-3 | ef8922e89582163be163f381ce3f18aa497a1aec | 2faa858bd2617bb48cf41d3fea68a7050e83bb58 | refs/heads/master | 2022-05-27T12:36:38.676000 | 2020-05-01T19:58:57 | 2020-05-01T19:58:57 | 256,076,802 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.maptest;
//import android.support.v4.app.FragmentActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.location.Address;
import android.location.Geocoder;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.gms.common.data.DataBufferSafeParcelable;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private EditText search;
private Button searchbtn;
private MyAdapter myAdapter;
private RecyclerView recyclerView;
private ArrayList<String> addresses = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
//Function to click on card view and plot a previously searched address
RecyclerViewClickListener listener = new RecyclerViewClickListener() {
@Override
public void onClick(View view, int position) {
LatLng latLng = getLocationFromAddress(addresses.get(position));
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.title(addresses.get(position));
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
markerOptions.position(latLng);
mMap.clear();
mMap.addMarker(markerOptions);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
}
};
final CardView cardView = findViewById(R.id.card_view);
recyclerView = findViewById(R.id.previousSearches);
LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager);
myAdapter = new MyAdapter(getApplicationContext(), addresses, listener);
recyclerView.setAdapter(myAdapter);
search = findViewById(R.id.searchbar);
searchbtn = findViewById(R.id.searchbtn);
//Function to search address based on searchbar
searchbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String searchText;
searchText = search.getText().toString();
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(Objects.requireNonNull(getCurrentFocus()).getWindowToken(), 0);
LatLng latLng = getLocationFromAddress(searchText);
if(latLng != null) {
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.title(searchText);
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
markerOptions.position(latLng);
mMap.clear();
mMap.addMarker(markerOptions);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
addresses.add(searchText);
myAdapter.notifyDataSetChanged();
cardView.setVisibility(View.VISIBLE);
}
else{
search.clearComposingText();
showAlertDialog(view);
}
}
});
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
}
/* call back interface */
public interface RecyclerViewClickListener{
void onClick(View view, int position);
}
//Function to convert address into longitude and latitude for plotting map and marker
public LatLng getLocationFromAddress(String strAddress){
Geocoder coder = new Geocoder(getBaseContext());
List<Address> addresses;
try {
addresses = coder.getFromLocationName(strAddress, 1);
if (addresses == null) {
return null;
}
Address location = addresses.get(0);
double lat = location.getLatitude();
double lng = location.getLongitude();
LatLng latLng = new LatLng(lat, lng);
return latLng;
} catch (Exception e) {
return null;
}
}
//Alert dialog for when address is invalid, or not entered
public void showAlertDialog(View v){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Error");
alert.setMessage("Invalid Address!");
alert.setNeutralButton("okay", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(MapsActivity.this,"Re-enter address", Toast.LENGTH_SHORT);
}
});
alert.create().show();
}
}
| UTF-8 | Java | 6,458 | java | MapsActivity.java | Java | [] | null | [] | package com.example.maptest;
//import android.support.v4.app.FragmentActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.location.Address;
import android.location.Geocoder;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.gms.common.data.DataBufferSafeParcelable;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private EditText search;
private Button searchbtn;
private MyAdapter myAdapter;
private RecyclerView recyclerView;
private ArrayList<String> addresses = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
//Function to click on card view and plot a previously searched address
RecyclerViewClickListener listener = new RecyclerViewClickListener() {
@Override
public void onClick(View view, int position) {
LatLng latLng = getLocationFromAddress(addresses.get(position));
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.title(addresses.get(position));
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
markerOptions.position(latLng);
mMap.clear();
mMap.addMarker(markerOptions);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
}
};
final CardView cardView = findViewById(R.id.card_view);
recyclerView = findViewById(R.id.previousSearches);
LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager);
myAdapter = new MyAdapter(getApplicationContext(), addresses, listener);
recyclerView.setAdapter(myAdapter);
search = findViewById(R.id.searchbar);
searchbtn = findViewById(R.id.searchbtn);
//Function to search address based on searchbar
searchbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String searchText;
searchText = search.getText().toString();
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(Objects.requireNonNull(getCurrentFocus()).getWindowToken(), 0);
LatLng latLng = getLocationFromAddress(searchText);
if(latLng != null) {
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.title(searchText);
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
markerOptions.position(latLng);
mMap.clear();
mMap.addMarker(markerOptions);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
addresses.add(searchText);
myAdapter.notifyDataSetChanged();
cardView.setVisibility(View.VISIBLE);
}
else{
search.clearComposingText();
showAlertDialog(view);
}
}
});
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
}
/* call back interface */
public interface RecyclerViewClickListener{
void onClick(View view, int position);
}
//Function to convert address into longitude and latitude for plotting map and marker
public LatLng getLocationFromAddress(String strAddress){
Geocoder coder = new Geocoder(getBaseContext());
List<Address> addresses;
try {
addresses = coder.getFromLocationName(strAddress, 1);
if (addresses == null) {
return null;
}
Address location = addresses.get(0);
double lat = location.getLatitude();
double lng = location.getLongitude();
LatLng latLng = new LatLng(lat, lng);
return latLng;
} catch (Exception e) {
return null;
}
}
//Alert dialog for when address is invalid, or not entered
public void showAlertDialog(View v){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Error");
alert.setMessage("Invalid Address!");
alert.setNeutralButton("okay", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(MapsActivity.this,"Re-enter address", Toast.LENGTH_SHORT);
}
});
alert.create().show();
}
}
| 6,458 | 0.669247 | 0.668009 | 177 | 35.485874 | 27.619511 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.627119 | false | false | 11 |
f4d9b614cfb8b849b8db5079640def969d2ab34c | 14,345,190,829,520 | ab53220f69895b71652b6de1f4badaacae45f6ea | /app/src/main/java/com/example/android/registration/LogInPage.java | 04a47bc194ab358b6e73a0107a0aacb24d21558b | [] | no_license | vipulpopli7534/registration_app | https://github.com/vipulpopli7534/registration_app | 83ba1fd6f9c9e60bea1ce84d210e68bf69c27fe2 | 678cfaa7d60a14b6c043a6213c5b3b0b37a56700 | refs/heads/master | 2020-03-21T20:25:53.212000 | 2018-06-28T10:59:31 | 2018-06-28T10:59:31 | 139,006,509 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.android.registration;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import static android.view.View.*;
public class LogInPage extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_in_page);
Button button2=findViewById(R.id.button2);
button2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "logged in succesfullly",
Toast.LENGTH_SHORT).show();
}
});
}
}
| UTF-8 | Java | 784 | java | LogInPage.java | Java | [] | null | [] | package com.example.android.registration;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import static android.view.View.*;
public class LogInPage extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_in_page);
Button button2=findViewById(R.id.button2);
button2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "logged in succesfullly",
Toast.LENGTH_SHORT).show();
}
});
}
}
| 784 | 0.683673 | 0.678571 | 27 | 28.037037 | 23.081949 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.518519 | false | false | 11 |
ebc692fcdbb8d52590ded3c0ad7566ac3371d507 | 20,529,943,726,202 | a2336505ccf6ed331efd8cd02e1f82d44ae31729 | /src/main/java/org/bookshare/api/model/LibraryGroup.java | c1f628ae8a4b6c3dba2fe00b82f09fe9bc1f2275 | [] | no_license | corpus-mens-spiritus/bookshare | https://github.com/corpus-mens-spiritus/bookshare | a2eac55f3fd7c8eb23db135178274f816e1118a9 | 1fb0441ab9617cbd0609792c29d707557f845f4e | refs/heads/master | 2022-07-10T02:16:32.186000 | 2020-04-21T06:13:17 | 2020-04-21T06:13:17 | 254,621,213 | 0 | 0 | null | false | 2022-06-25T07:30:19 | 2020-04-10T11:46:27 | 2020-04-21T06:13:27 | 2022-06-25T07:30:18 | 536 | 0 | 0 | 2 | Java | false | false | package org.bookshare.api.model;
import lombok.Data;
import java.util.Set;
@Data
public class LibraryGroup {
private Set<Library> libraries;
}
| UTF-8 | Java | 150 | java | LibraryGroup.java | Java | [] | null | [] | package org.bookshare.api.model;
import lombok.Data;
import java.util.Set;
@Data
public class LibraryGroup {
private Set<Library> libraries;
}
| 150 | 0.753333 | 0.753333 | 10 | 14 | 13.586759 | 35 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 11 |
fcec85e44e738027a8d8dd7893121308bd2f6e71 | 23,837,068,544,302 | c472b654b61eaa90765625b373dd6d625c915da9 | /src/main/java/br/com/techHouse/zmed/entity/Fornecedor.java | 540d73bfc99e7197316b9b50c775950ddfbe9f54 | [
"Apache-2.0"
] | permissive | jeremiasrocha/zmed | https://github.com/jeremiasrocha/zmed | f47a1cd59842842382abea17265c5022b2e7e2d1 | 9af55c37386fd0a9bbd348b03e8b87fc6510fa1a | refs/heads/master | 2020-03-22T11:33:39.838000 | 2018-09-21T20:51:47 | 2018-09-21T20:51:47 | 139,979,544 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.techHouse.zmed.entity;
import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
/**
* The persistent class for the zmed_fornecedor database table.
*
*/
@Entity
@Table(name="zmed_fornecedor")
public class Fornecedor implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name="SEQ_FORNECEDOR", sequenceName="zmed_seq_fornecedor", allocationSize = 1)
@GeneratedValue(generator="SEQ_FORNECEDOR",strategy=GenerationType.AUTO)
private Integer id;
@Column(name="alto_custo")
private String altoCusto;
private Integer cep;
private String codigo;
private String complemento;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="data_alteracao")
private Date dataAlteracao;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="data_cadastro")
private Date dataCadastro;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="data_exclusao")
private Date dataExclusao;
private String email;
@Column(name="endereco_completo")
private String enderecoCompleto;
@Column(name="inscricao_estadual")
private String inscricaoEstadual;
private String nome;
private String observacao;
@Column(name="razao_social")
private String razaoSocial;
private String status;
private String telefone;
@Column(name="tipo_operacao")
private String tipoOperacao;
@Column(name="tipo_pessoa")
private String tipoPessoa;
private String uf;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_usuario_alteracao")
private Usuario UsuarioAlteracao;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_usuario_cadastro")
private Usuario UsuarioCadastro;
public Fornecedor() {
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAltoCusto() {
return this.altoCusto;
}
public void setAltoCusto(String altoCusto) {
this.altoCusto = altoCusto;
}
public Integer getCep() {
return this.cep;
}
public void setCep(Integer cep) {
this.cep = cep;
}
public String getCodigo() {
return this.codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getComplemento() {
return this.complemento;
}
public void setComplemento(String complemento) {
this.complemento = complemento;
}
public Date getDataAlteracao() {
return this.dataAlteracao;
}
public void setDataAlteracao(Date dataAlteracao) {
this.dataAlteracao = dataAlteracao;
}
public Date getDataCadastro() {
return this.dataCadastro;
}
public void setDataCadastro(Date dataCadastro) {
this.dataCadastro = dataCadastro;
}
public Date getDataExclusao() {
return this.dataExclusao;
}
public void setDataExclusao(Date dataExclusao) {
this.dataExclusao = dataExclusao;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getEnderecoCompleto() {
return this.enderecoCompleto;
}
public void setEnderecoCompleto(String enderecoCompleto) {
this.enderecoCompleto = enderecoCompleto;
}
public String getInscricaoEstadual() {
return this.inscricaoEstadual;
}
public void setInscricaoEstadual(String inscricaoEstadual) {
this.inscricaoEstadual = inscricaoEstadual;
}
public String getNome() {
return this.nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getObservacao() {
return this.observacao;
}
public void setObservacao(String observacao) {
this.observacao = observacao;
}
public String getRazaoSocial() {
return this.razaoSocial;
}
public void setRazaoSocial(String razaoSocial) {
this.razaoSocial = razaoSocial;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public String getTelefone() {
return this.telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public String getTipoOperacao() {
return this.tipoOperacao;
}
public void setTipoOperacao(String tipoOperacao) {
this.tipoOperacao = tipoOperacao;
}
public String getTipoPessoa() {
return this.tipoPessoa;
}
public void setTipoPessoa(String tipoPessoa) {
this.tipoPessoa = tipoPessoa;
}
public String getUf() {
return this.uf;
}
public void setUf(String uf) {
this.uf = uf;
}
public Usuario getUsuarioAlteracao() {
return UsuarioAlteracao;
}
public void setUsuarioAlteracao(Usuario usuarioAlteracao) {
UsuarioAlteracao = usuarioAlteracao;
}
public Usuario getUsuarioCadastro() {
return UsuarioCadastro;
}
public void setUsuarioCadastro(Usuario usuarioCadastro) {
UsuarioCadastro = usuarioCadastro;
}
} | UTF-8 | Java | 4,692 | java | Fornecedor.java | Java | [
{
"context": "tro(Usuario usuarioCadastro) {\n\t\tUsuarioCadastro = usuarioCadastro;\n\t}\n\n}",
"end": 4685,
"score": 0.9505043625831604,
"start": 4670,
"tag": "USERNAME",
"value": "usuarioCadastro"
}
] | null | [] | package br.com.techHouse.zmed.entity;
import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
/**
* The persistent class for the zmed_fornecedor database table.
*
*/
@Entity
@Table(name="zmed_fornecedor")
public class Fornecedor implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name="SEQ_FORNECEDOR", sequenceName="zmed_seq_fornecedor", allocationSize = 1)
@GeneratedValue(generator="SEQ_FORNECEDOR",strategy=GenerationType.AUTO)
private Integer id;
@Column(name="alto_custo")
private String altoCusto;
private Integer cep;
private String codigo;
private String complemento;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="data_alteracao")
private Date dataAlteracao;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="data_cadastro")
private Date dataCadastro;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="data_exclusao")
private Date dataExclusao;
private String email;
@Column(name="endereco_completo")
private String enderecoCompleto;
@Column(name="inscricao_estadual")
private String inscricaoEstadual;
private String nome;
private String observacao;
@Column(name="razao_social")
private String razaoSocial;
private String status;
private String telefone;
@Column(name="tipo_operacao")
private String tipoOperacao;
@Column(name="tipo_pessoa")
private String tipoPessoa;
private String uf;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_usuario_alteracao")
private Usuario UsuarioAlteracao;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_usuario_cadastro")
private Usuario UsuarioCadastro;
public Fornecedor() {
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAltoCusto() {
return this.altoCusto;
}
public void setAltoCusto(String altoCusto) {
this.altoCusto = altoCusto;
}
public Integer getCep() {
return this.cep;
}
public void setCep(Integer cep) {
this.cep = cep;
}
public String getCodigo() {
return this.codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getComplemento() {
return this.complemento;
}
public void setComplemento(String complemento) {
this.complemento = complemento;
}
public Date getDataAlteracao() {
return this.dataAlteracao;
}
public void setDataAlteracao(Date dataAlteracao) {
this.dataAlteracao = dataAlteracao;
}
public Date getDataCadastro() {
return this.dataCadastro;
}
public void setDataCadastro(Date dataCadastro) {
this.dataCadastro = dataCadastro;
}
public Date getDataExclusao() {
return this.dataExclusao;
}
public void setDataExclusao(Date dataExclusao) {
this.dataExclusao = dataExclusao;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getEnderecoCompleto() {
return this.enderecoCompleto;
}
public void setEnderecoCompleto(String enderecoCompleto) {
this.enderecoCompleto = enderecoCompleto;
}
public String getInscricaoEstadual() {
return this.inscricaoEstadual;
}
public void setInscricaoEstadual(String inscricaoEstadual) {
this.inscricaoEstadual = inscricaoEstadual;
}
public String getNome() {
return this.nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getObservacao() {
return this.observacao;
}
public void setObservacao(String observacao) {
this.observacao = observacao;
}
public String getRazaoSocial() {
return this.razaoSocial;
}
public void setRazaoSocial(String razaoSocial) {
this.razaoSocial = razaoSocial;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public String getTelefone() {
return this.telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public String getTipoOperacao() {
return this.tipoOperacao;
}
public void setTipoOperacao(String tipoOperacao) {
this.tipoOperacao = tipoOperacao;
}
public String getTipoPessoa() {
return this.tipoPessoa;
}
public void setTipoPessoa(String tipoPessoa) {
this.tipoPessoa = tipoPessoa;
}
public String getUf() {
return this.uf;
}
public void setUf(String uf) {
this.uf = uf;
}
public Usuario getUsuarioAlteracao() {
return UsuarioAlteracao;
}
public void setUsuarioAlteracao(Usuario usuarioAlteracao) {
UsuarioAlteracao = usuarioAlteracao;
}
public Usuario getUsuarioCadastro() {
return UsuarioCadastro;
}
public void setUsuarioCadastro(Usuario usuarioCadastro) {
UsuarioCadastro = usuarioCadastro;
}
} | 4,692 | 0.741901 | 0.741475 | 249 | 17.847389 | 18.153318 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.140562 | false | false | 11 |
3ede581a90db14398b0839966aa778ac5262a491 | 26,276,609,965,444 | 5aea39ad4bbc86569e5dbbcbca2d7af3f9f84c50 | /jpl/src/ch22/ex14/DoubleSum.java | ea8a1a8ab13bc18e5558264a5c260fb6b5af2ac6 | [] | no_license | atsuhirooo/java-study | https://github.com/atsuhirooo/java-study | 8b659e7dfe56456e039ab11bcaf13561a3f3dee4 | 371e95d53d11385c4bb74615b15c00b0dedcaaa9 | refs/heads/master | 2021-06-30T20:49:09.551000 | 2020-12-18T00:20:45 | 2020-12-18T00:20:45 | 204,397,821 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ch22.ex14;
import java.io.IOException;
import java.util.Scanner;
public class DoubleSum {
public static double sumDouble(Readable source) throws IOException {
Scanner in = new Scanner(source);
double sum = 0;
while (in.hasNext()) {
sum += in.nextDouble();
}
return sum;
}
}
| UTF-8 | Java | 304 | java | DoubleSum.java | Java | [] | null | [] | package ch22.ex14;
import java.io.IOException;
import java.util.Scanner;
public class DoubleSum {
public static double sumDouble(Readable source) throws IOException {
Scanner in = new Scanner(source);
double sum = 0;
while (in.hasNext()) {
sum += in.nextDouble();
}
return sum;
}
}
| 304 | 0.690789 | 0.674342 | 20 | 14.2 | 17.220917 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.1 | false | false | 11 |
b4d9c8160f16bb6538e9308a330c6b3e39fb2010 | 8,546,984,974,211 | 8d2b5ba8c9a2e181bb0e74f65bde20d74e904960 | /app/src/main/java/com/ashwashing/pro/impl/bluetooth/BluetoothService.java | 682449e57bca2d9fb3ea1848fbfd3fcb31c0688e | [] | no_license | xjunz/AshWashing | https://github.com/xjunz/AshWashing | ba0f4ad6157fde068ea62e38851a32d559ae5775 | fa1657c4eed69f8b1b4d99a064fe226b74546a67 | refs/heads/master | 2023-03-21T01:04:04.333000 | 2020-06-26T15:42:30 | 2020-06-26T15:42:30 | 275,191,148 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ashwashing.pro.impl.bluetooth;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.annotation.NonNull;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
public class BluetoothService {
private @NonNull
BluetoothDevice mServerDevice;
private static final UUID SERVER_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
private BluetoothSocket mSocket;
private ConnectionHandler mHandler;
private static class ConnectionHandler extends Handler {
private BluetoothService.Callback callback;
static final int MSG_CONN_START = 0x1a;
static final int MSG_CONNECTED = 0x1b;
static final int MSG_WRITTEN = 0x1c;
static final int MSG_READ = 0x1e;
static final int MSG_CONN_FAIL = 0x1f;
static final int MSG_CONN_LOST = 0x20;
ConnectionHandler(BluetoothService.Callback callback) {
super(Looper.getMainLooper());
this.callback = callback;
}
private void removeCallback() {
callback = null;
}
@Override
public void handleMessage(Message msg) {
if (callback == null) {
return;
}
switch (msg.what) {
case MSG_CONN_START:
callback.onConnectStart();
break;
case MSG_CONNECTED:
callback.onConnected();
break;
case MSG_WRITTEN:
callback.onWritten((byte[]) msg.obj);
break;
case MSG_CONN_FAIL:
callback.onConnectFail((Exception) msg.obj);
break;
case MSG_CONN_LOST:
callback.onConnectionLost((Exception) msg.obj);
break;
case MSG_READ:
callback.onRead((byte[]) msg.obj);
}
}
}
private void notifyConnLost(Exception e) {
mHandler.removeMessages(ConnectionHandler.MSG_CONN_LOST);
mHandler.obtainMessage(ConnectionHandler.MSG_CONN_LOST, e).sendToTarget();
}
private void notifyConnFail(Exception e) {
mHandler.removeMessages(ConnectionHandler.MSG_CONN_FAIL);
mHandler.obtainMessage(ConnectionHandler.MSG_CONN_FAIL, e).sendToTarget();
}
public boolean hasConnection() {
return mTransferThread != null && mTransferThread.isAlive();
}
public BluetoothService(@NonNull BluetoothDevice server, @NonNull Callback callback) {
mServerDevice = server;
mHandler = new ConnectionHandler(callback);
}
private TransferThread mTransferThread;
private ConnectThread mConnectThread;
private class ConnectThread extends Thread {
@Override
public void run() {
mHandler.sendEmptyMessage(ConnectionHandler.MSG_CONN_START);
try {
mSocket = mServerDevice.createRfcommSocketToServiceRecord(SERVER_UUID);
} catch (IOException e) {
notifyConnFail(e);
}
try {
mSocket.connect();
mHandler.sendEmptyMessage(ConnectionHandler.MSG_CONNECTED);
mTransferThread = new TransferThread();
mTransferThread.start();
} catch (IOException connectException) {
notifyConnFail(connectException);
}
}
void cancel() {
try {
mSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
;
public void write(byte[] data) {
if (hasConnection()) {
mTransferThread.write(data);
}
}
//close connection and remove callback
public synchronized void purge() {
mHandler.removeCallback();
if (mSocket != null && mSocket.isConnected()) {
try {
mSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
//close connection safely (without connection check
public synchronized void safeClose() {
if (mSocket != null && mSocket.isConnected()) {
try {
mSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public interface Callback {
void onConnectStart();
void onConnectFail(Exception e);
void onConnectionLost(Exception e);
void onConnected();
void onWritten(byte[] data);
void onRead(byte[] data);
}
public synchronized void connect() {
if (mConnectThread != null) {
mConnectThread.cancel();
}
mConnectThread = new ConnectThread();
mConnectThread.start();
}
private class TransferThread extends Thread {
private InputStream in;
private OutputStream out;
TransferThread() {
try {
in = mSocket.getInputStream();
out = mSocket.getOutputStream();
} catch (IOException e) {
notifyConnLost(e);
}
}
@Override
public void run() {
byte[] var1 = new byte[1024];
label76:
while (true) {
byte[] var2 = null;
label73:
while (true) {
boolean var10001;
int var3;
try {
var3 = this.in.read(var1);
} catch (IOException var13) {
var10001 = false;
BluetoothService.this.notifyConnFail(var13);
break;
}
byte var4 = 0;
byte var5 = 0;
int var6 = 0;
byte[] var7;
if (var3 == 80) {
var7 = new byte[80];
while (true) {
var2 = var7;
if (var6 >= 80) {
continue label73;
}
var7[var6] = (byte) var1[var6];
++var6;
}
} else if (var2 == null) {
var2 = new byte[var3];
for (var6 = var4; var6 < var3; ++var6) {
var2[var6] = (byte) var1[var6];
}
BluetoothService.this.mHandler.obtainMessage(ConnectionHandler.MSG_READ, var2).sendToTarget();
} else {
var7 = new byte[var3];
for (var6 = var5; var6 < var3; ++var6) {
var7[var6] = (byte) var1[var6];
}
var2 = byteMerger(var2, var7);
BluetoothService.this.mHandler.obtainMessage(ConnectionHandler.MSG_READ, var2).sendToTarget();
}
continue label76;
}
return;
}
}
/* @Override
public void run() {
final byte[] arrayOfByte2 = new byte[1024];
while (true) {
byte[] bytes = null;
try {
int m = this.in.read(arrayOfByte2);
int j = 0;
int k = 0;
int i = 0;
byte[] arrayOfByte1;
if (m == 80) {
arrayOfByte1 = new byte[80];
while (true) {
bytes = arrayOfByte1;
if (i >= 80) {
break;
}
arrayOfByte1[i] = arrayOfByte2[i];
i++;
}
}
if (bytes == null) {
bytes = new byte[m];
for (i = j; i < m; i++) {
bytes[i] = arrayOfByte2[i];
}
mHandler.obtainMessage(ConnectionHandler.MSG_READ, bytes).sendToTarget();
} else {
arrayOfByte1 = new byte[m];
for (i = k; i < m; i++) {
arrayOfByte1[i] = arrayOfByte2[i];
}
bytes = byteMerger(bytes, arrayOfByte1);
mHandler.obtainMessage(ConnectionHandler.MSG_READ, bytes).sendToTarget();
}
} catch (IOException e) {
notifyConnFail(e);
break;
}
}
}
*/
void write(byte[] data) {
try {
out.write(data);
mHandler.obtainMessage(ConnectionHandler.MSG_WRITTEN, data);
} catch (IOException e) {
notifyConnLost(e);
}
}
}
private static byte[] byteMerger(byte[] bt1, byte[] bt2) {
byte[] bt3 = new byte[bt1.length + bt2.length];
System.arraycopy(bt1, 0, bt3, 0, bt1.length);
System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length);
return bt3;
}
}
| UTF-8 | Java | 9,808 | java | BluetoothService.java | Java | [] | null | [] | package com.ashwashing.pro.impl.bluetooth;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.annotation.NonNull;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
public class BluetoothService {
private @NonNull
BluetoothDevice mServerDevice;
private static final UUID SERVER_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
private BluetoothSocket mSocket;
private ConnectionHandler mHandler;
private static class ConnectionHandler extends Handler {
private BluetoothService.Callback callback;
static final int MSG_CONN_START = 0x1a;
static final int MSG_CONNECTED = 0x1b;
static final int MSG_WRITTEN = 0x1c;
static final int MSG_READ = 0x1e;
static final int MSG_CONN_FAIL = 0x1f;
static final int MSG_CONN_LOST = 0x20;
ConnectionHandler(BluetoothService.Callback callback) {
super(Looper.getMainLooper());
this.callback = callback;
}
private void removeCallback() {
callback = null;
}
@Override
public void handleMessage(Message msg) {
if (callback == null) {
return;
}
switch (msg.what) {
case MSG_CONN_START:
callback.onConnectStart();
break;
case MSG_CONNECTED:
callback.onConnected();
break;
case MSG_WRITTEN:
callback.onWritten((byte[]) msg.obj);
break;
case MSG_CONN_FAIL:
callback.onConnectFail((Exception) msg.obj);
break;
case MSG_CONN_LOST:
callback.onConnectionLost((Exception) msg.obj);
break;
case MSG_READ:
callback.onRead((byte[]) msg.obj);
}
}
}
private void notifyConnLost(Exception e) {
mHandler.removeMessages(ConnectionHandler.MSG_CONN_LOST);
mHandler.obtainMessage(ConnectionHandler.MSG_CONN_LOST, e).sendToTarget();
}
private void notifyConnFail(Exception e) {
mHandler.removeMessages(ConnectionHandler.MSG_CONN_FAIL);
mHandler.obtainMessage(ConnectionHandler.MSG_CONN_FAIL, e).sendToTarget();
}
public boolean hasConnection() {
return mTransferThread != null && mTransferThread.isAlive();
}
public BluetoothService(@NonNull BluetoothDevice server, @NonNull Callback callback) {
mServerDevice = server;
mHandler = new ConnectionHandler(callback);
}
private TransferThread mTransferThread;
private ConnectThread mConnectThread;
private class ConnectThread extends Thread {
@Override
public void run() {
mHandler.sendEmptyMessage(ConnectionHandler.MSG_CONN_START);
try {
mSocket = mServerDevice.createRfcommSocketToServiceRecord(SERVER_UUID);
} catch (IOException e) {
notifyConnFail(e);
}
try {
mSocket.connect();
mHandler.sendEmptyMessage(ConnectionHandler.MSG_CONNECTED);
mTransferThread = new TransferThread();
mTransferThread.start();
} catch (IOException connectException) {
notifyConnFail(connectException);
}
}
void cancel() {
try {
mSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
;
public void write(byte[] data) {
if (hasConnection()) {
mTransferThread.write(data);
}
}
//close connection and remove callback
public synchronized void purge() {
mHandler.removeCallback();
if (mSocket != null && mSocket.isConnected()) {
try {
mSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
//close connection safely (without connection check
public synchronized void safeClose() {
if (mSocket != null && mSocket.isConnected()) {
try {
mSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public interface Callback {
void onConnectStart();
void onConnectFail(Exception e);
void onConnectionLost(Exception e);
void onConnected();
void onWritten(byte[] data);
void onRead(byte[] data);
}
public synchronized void connect() {
if (mConnectThread != null) {
mConnectThread.cancel();
}
mConnectThread = new ConnectThread();
mConnectThread.start();
}
private class TransferThread extends Thread {
private InputStream in;
private OutputStream out;
TransferThread() {
try {
in = mSocket.getInputStream();
out = mSocket.getOutputStream();
} catch (IOException e) {
notifyConnLost(e);
}
}
@Override
public void run() {
byte[] var1 = new byte[1024];
label76:
while (true) {
byte[] var2 = null;
label73:
while (true) {
boolean var10001;
int var3;
try {
var3 = this.in.read(var1);
} catch (IOException var13) {
var10001 = false;
BluetoothService.this.notifyConnFail(var13);
break;
}
byte var4 = 0;
byte var5 = 0;
int var6 = 0;
byte[] var7;
if (var3 == 80) {
var7 = new byte[80];
while (true) {
var2 = var7;
if (var6 >= 80) {
continue label73;
}
var7[var6] = (byte) var1[var6];
++var6;
}
} else if (var2 == null) {
var2 = new byte[var3];
for (var6 = var4; var6 < var3; ++var6) {
var2[var6] = (byte) var1[var6];
}
BluetoothService.this.mHandler.obtainMessage(ConnectionHandler.MSG_READ, var2).sendToTarget();
} else {
var7 = new byte[var3];
for (var6 = var5; var6 < var3; ++var6) {
var7[var6] = (byte) var1[var6];
}
var2 = byteMerger(var2, var7);
BluetoothService.this.mHandler.obtainMessage(ConnectionHandler.MSG_READ, var2).sendToTarget();
}
continue label76;
}
return;
}
}
/* @Override
public void run() {
final byte[] arrayOfByte2 = new byte[1024];
while (true) {
byte[] bytes = null;
try {
int m = this.in.read(arrayOfByte2);
int j = 0;
int k = 0;
int i = 0;
byte[] arrayOfByte1;
if (m == 80) {
arrayOfByte1 = new byte[80];
while (true) {
bytes = arrayOfByte1;
if (i >= 80) {
break;
}
arrayOfByte1[i] = arrayOfByte2[i];
i++;
}
}
if (bytes == null) {
bytes = new byte[m];
for (i = j; i < m; i++) {
bytes[i] = arrayOfByte2[i];
}
mHandler.obtainMessage(ConnectionHandler.MSG_READ, bytes).sendToTarget();
} else {
arrayOfByte1 = new byte[m];
for (i = k; i < m; i++) {
arrayOfByte1[i] = arrayOfByte2[i];
}
bytes = byteMerger(bytes, arrayOfByte1);
mHandler.obtainMessage(ConnectionHandler.MSG_READ, bytes).sendToTarget();
}
} catch (IOException e) {
notifyConnFail(e);
break;
}
}
}
*/
void write(byte[] data) {
try {
out.write(data);
mHandler.obtainMessage(ConnectionHandler.MSG_WRITTEN, data);
} catch (IOException e) {
notifyConnLost(e);
}
}
}
private static byte[] byteMerger(byte[] bt1, byte[] bt2) {
byte[] bt3 = new byte[bt1.length + bt2.length];
System.arraycopy(bt1, 0, bt3, 0, bt1.length);
System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length);
return bt3;
}
}
| 9,808 | 0.463193 | 0.446472 | 310 | 30.63871 | 22.507744 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.509677 | false | false | 11 |
8f199ed29755ab11d57c0e7bc69387595e97458d | 7,395,933,742,946 | b51c2b0675b057ec87f7d1a00110ac713e098dc9 | /weixin-base/src/test/java/com/project/core/utils/builder/ImageBuilderTest.java | 28fc1bcf3c60d34021621e5202cffe9dab79a7c2 | [] | no_license | GrandKai/weixin-root | https://github.com/GrandKai/weixin-root | b3a092b5d0e2b083a1a88f8bacbf66eaee7bb155 | 7fecdbab2deda3018aa645703d7dc6073ec10fea | refs/heads/master | 2016-09-17T01:40:31.647000 | 2016-07-28T06:31:39 | 2016-07-28T06:34:28 | 64,300,864 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
* @Project : weixin-basement
* @Program Name : com.kai.core.utils.builder.ImageBuilderTest.java
* @Class Name : ImageBuilderTest
* @Description : 类描述
* @Author : zyn
* @Creation Date : 2015年7月6日 下午5:09:07
* @ModificationHistory
* Who When What
* -------- ---------- -----------------------------------
* username 2015年7月6日 TODO
*/
package com.project.core.utils.builder;
import org.junit.Test;
import com.project.core.beans.wx.OutMessage;
import com.project.core.beans.out.OutMessageImage;
import com.project.core.utils.xml.XmlUtils;
//import com.kai.core.beans.XmlOutMessage;
//import com.kai.core.beans.out.XmlOutMessageImage;
//import com.kai.core.beans.out.builder.ImageBuilder;
/**
* @Project : weixin-basement
* @Program Name : com.kai.core.utils.builder.ImageBuilderTest.java
* @Class Name : ImageBuilderTest
* @Description : 类描述
* @Author : zyn
* @Creation Date : 2015年7月6日 下午5:09:07
* @ModificationHistory
* Who When What
* -------- ---------- -----------------------------------
* username 2015年7月6日 TODO
*/
public class ImageBuilderTest {
@Test
public void testImageBuilder(){
// XmlOutMessage out = new ImageBuilder().MediaId("111").FromUserName("22").ToUserName("33").build();
OutMessage out = OutMessage.IMAGE().FromUserName("11").ToUserName("22").MediaId("33").build();
String str = out.toXml();
System.out.println(str);
// System.out.println(XmlTransformer.fromXml(out.toXml(), XmlOutMessageImage.class));
// XmlOutMessageImage i = XmlUtils.fromXml(str, XmlOutMessageImage.class);
// System.out.println(i.getToUserName());
}
}
| UTF-8 | Java | 1,779 | java | ImageBuilderTest.java | Java | [
{
"context": "Test\n * @Description : 类描述\n * @Author : zyn\n * @Creation Date : 2015年7月6日 下午5:09:07\n * @Mod",
"end": 200,
"score": 0.9997381567955017,
"start": 197,
"tag": "USERNAME",
"value": "zyn"
},
{
"context": "Test\n * @Description : 类描述\n * @Author : zyn\n * @Creation Date : 2015年7月6日 下午5:09:07\n * @Mod",
"end": 962,
"score": 0.9997090101242065,
"start": 959,
"tag": "USERNAME",
"value": "zyn"
}
] | null | [] |
/**
* @Project : weixin-basement
* @Program Name : com.kai.core.utils.builder.ImageBuilderTest.java
* @Class Name : ImageBuilderTest
* @Description : 类描述
* @Author : zyn
* @Creation Date : 2015年7月6日 下午5:09:07
* @ModificationHistory
* Who When What
* -------- ---------- -----------------------------------
* username 2015年7月6日 TODO
*/
package com.project.core.utils.builder;
import org.junit.Test;
import com.project.core.beans.wx.OutMessage;
import com.project.core.beans.out.OutMessageImage;
import com.project.core.utils.xml.XmlUtils;
//import com.kai.core.beans.XmlOutMessage;
//import com.kai.core.beans.out.XmlOutMessageImage;
//import com.kai.core.beans.out.builder.ImageBuilder;
/**
* @Project : weixin-basement
* @Program Name : com.kai.core.utils.builder.ImageBuilderTest.java
* @Class Name : ImageBuilderTest
* @Description : 类描述
* @Author : zyn
* @Creation Date : 2015年7月6日 下午5:09:07
* @ModificationHistory
* Who When What
* -------- ---------- -----------------------------------
* username 2015年7月6日 TODO
*/
public class ImageBuilderTest {
@Test
public void testImageBuilder(){
// XmlOutMessage out = new ImageBuilder().MediaId("111").FromUserName("22").ToUserName("33").build();
OutMessage out = OutMessage.IMAGE().FromUserName("11").ToUserName("22").MediaId("33").build();
String str = out.toXml();
System.out.println(str);
// System.out.println(XmlTransformer.fromXml(out.toXml(), XmlOutMessageImage.class));
// XmlOutMessageImage i = XmlUtils.fromXml(str, XmlOutMessageImage.class);
// System.out.println(i.getToUserName());
}
}
| 1,779 | 0.621902 | 0.594813 | 53 | 31.716982 | 26.246565 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.471698 | false | false | 11 |
47cf3d6830c656d4f6dc964acc85047c65e9cc7f | 14,697,378,153,993 | f6eda37913ff83c64a557507fa18b4fc081272c0 | /src/com/trairas/nig/busca_solucao.java | e1f5c3f162759ff20ca554c541e36627d09657bd | [] | no_license | Marcos001/x_by_x | https://github.com/Marcos001/x_by_x | 18030a61f0ca326e62ec0bf5cdb25002e7cb24aa | 13d987159b6baa8ff076ae5287ebf7ae6aca790a | refs/heads/master | 2021-01-21T12:30:52.982000 | 2018-09-03T00:13:51 | 2018-09-03T00:13:51 | 102,076,079 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.trairas.nig;
/**
* Created by nig on 04/09/17.
*/
public class busca_solucao {
//qual a melhor jogada ?
//qual jogada atinge menos casas ?
public busca_solucao(int i_j, int j_i){
}
}
| UTF-8 | Java | 220 | java | busca_solucao.java | Java | [
{
"context": "package com.trairas.nig;\n\n/**\n * Created by nig on 04/09/17.\n */\npublic class busca_solucao {\n\n ",
"end": 47,
"score": 0.9994627833366394,
"start": 44,
"tag": "USERNAME",
"value": "nig"
}
] | null | [] | package com.trairas.nig;
/**
* Created by nig on 04/09/17.
*/
public class busca_solucao {
//qual a melhor jogada ?
//qual jogada atinge menos casas ?
public busca_solucao(int i_j, int j_i){
}
}
| 220 | 0.609091 | 0.581818 | 17 | 11.941176 | 15.256515 | 43 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.117647 | false | false | 11 |
599232035353abe7b0272a74d576bd0e0e328e17 | 13,511,967,167,213 | eaaaaee85a51b1700db89d23eb589bcb107437f9 | /mdrive-business/src/main/java/mdrive/business/util/DBUnitDataExporter.java | 2a3c469f94ead89c6301f7a27130e17eee0c4580 | [] | no_license | andreyo/mdrive | https://github.com/andreyo/mdrive | 5ae632cc5b687a7482387672df13ecf4185402c3 | e6fe2dc6723d0f7b548d464738d79615401c169a | refs/heads/master | 2021-01-01T15:50:10.928000 | 2014-03-16T17:40:15 | 2014-03-16T17:40:15 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package mdrive.business.util;
import org.apache.log4j.Logger;
import org.dbunit.database.DatabaseConfig;
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.DatabaseSequenceFilter;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.database.QueryDataSet;
import org.dbunit.dataset.FilteredDataSet;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.csv.CsvDataSetWriter;
import org.dbunit.dataset.filter.ITableFilter;
import org.dbunit.dataset.xml.XmlDataSetWriter;
import org.dbunit.ext.hsqldb.HsqldbDataTypeFactory;
import org.springframework.jdbc.datasource.ConnectionHolder;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.sql.Connection;
import java.util.regex.Pattern;
/**
* User: andrey.osipov
*/
public class DBUnitDataExporter {
private static final Logger log = Logger.getLogger(DBUnitDataExporter.class);
private static final String NUMERIC_REGEX = "[-+]?\\d*\\.?\\d+";
//write csv, otherwise xml
private static final boolean WRITE_CSV = true;
String CSV_EXPORT_DB_DIR = "csv_db_export";
/**
* See exportTables() below, this one with default charset UTF-8
*/
public void exportTables(String destinationFile) throws Exception {
exportTables(null, destinationFile, Charset.forName("UTF-8"));
}
/**
* See exportTables() below, this one with default charset UTF-8
*/
public void exportTables(String[] tableNames, String destinationFile) throws Exception {
exportTables(tableNames, destinationFile, Charset.forName("UTF-8"));
}
/**
* exportTables() is used to produce human readable (initial DB) xml file
* all fields are saved in CDATA, except numerics
*
* @param tableNames
* @param destinationFile
* @param charset
* @throws Exception
*/
public void exportTables(String[] tableNames, String destinationFile, Charset charset) throws Exception {
IDatabaseConnection connection = new DatabaseConnection(getConnectionFromSpringTransaction());
connection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
IDataSet dataSet;
if (tableNames != null) {
// partial database export
QueryDataSet partialDataSet = new QueryDataSet(connection);
for (String tableName : tableNames) {
partialDataSet.addTable(tableName);
}
dataSet = partialDataSet;
} else {
//full dataSet by default
dataSet = connection.createDataSet();
}
//DatabaseSequenceFilter - order tables according to foreign keys
ITableFilter filter = new DatabaseSequenceFilter(connection);
if (WRITE_CSV) {
CsvDataSetWriter csvWriter = new CsvDataSetWriter(CSV_EXPORT_DB_DIR);
csvWriter.write(new FilteredDataSet(filter, dataSet));
} else {
XmlDataSetWriter xmlDataSetWriter = new XmlDataSetWriter(new FileOutputStream(destinationFile),
charset.name()) {
@Override
protected void writeValue(String stringValue) throws IOException {
//write everything in CDATA except numbers
if (Pattern.matches(NUMERIC_REGEX, stringValue)) {
super.writeValue(stringValue);
} else {
super.writeValueCData(stringValue);
}
}
};
xmlDataSetWriter.write(new FilteredDataSet(filter, dataSet));
}
}
protected Connection getConnectionFromSpringTransaction() {
for (Object value : TransactionSynchronizationManager.getResourceMap().values()) {
if (value instanceof ConnectionHolder) {
ConnectionHolder connectionHolder = (ConnectionHolder) value;
return connectionHolder.getConnection();
}
}
throw new RuntimeException("unable to get Connection from Spring transaction");
}
} | UTF-8 | Java | 4,212 | java | DBUnitDataExporter.java | Java | [
{
"context": "ion;\nimport java.util.regex.Pattern;\n\n/**\n * User: andrey.osipov\n */\npublic class DBUnitDataExporter {\n private",
"end": 892,
"score": 0.9290809631347656,
"start": 879,
"tag": "NAME",
"value": "andrey.osipov"
}
] | null | [] | package mdrive.business.util;
import org.apache.log4j.Logger;
import org.dbunit.database.DatabaseConfig;
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.DatabaseSequenceFilter;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.database.QueryDataSet;
import org.dbunit.dataset.FilteredDataSet;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.csv.CsvDataSetWriter;
import org.dbunit.dataset.filter.ITableFilter;
import org.dbunit.dataset.xml.XmlDataSetWriter;
import org.dbunit.ext.hsqldb.HsqldbDataTypeFactory;
import org.springframework.jdbc.datasource.ConnectionHolder;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.sql.Connection;
import java.util.regex.Pattern;
/**
* User: andrey.osipov
*/
public class DBUnitDataExporter {
private static final Logger log = Logger.getLogger(DBUnitDataExporter.class);
private static final String NUMERIC_REGEX = "[-+]?\\d*\\.?\\d+";
//write csv, otherwise xml
private static final boolean WRITE_CSV = true;
String CSV_EXPORT_DB_DIR = "csv_db_export";
/**
* See exportTables() below, this one with default charset UTF-8
*/
public void exportTables(String destinationFile) throws Exception {
exportTables(null, destinationFile, Charset.forName("UTF-8"));
}
/**
* See exportTables() below, this one with default charset UTF-8
*/
public void exportTables(String[] tableNames, String destinationFile) throws Exception {
exportTables(tableNames, destinationFile, Charset.forName("UTF-8"));
}
/**
* exportTables() is used to produce human readable (initial DB) xml file
* all fields are saved in CDATA, except numerics
*
* @param tableNames
* @param destinationFile
* @param charset
* @throws Exception
*/
public void exportTables(String[] tableNames, String destinationFile, Charset charset) throws Exception {
IDatabaseConnection connection = new DatabaseConnection(getConnectionFromSpringTransaction());
connection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
IDataSet dataSet;
if (tableNames != null) {
// partial database export
QueryDataSet partialDataSet = new QueryDataSet(connection);
for (String tableName : tableNames) {
partialDataSet.addTable(tableName);
}
dataSet = partialDataSet;
} else {
//full dataSet by default
dataSet = connection.createDataSet();
}
//DatabaseSequenceFilter - order tables according to foreign keys
ITableFilter filter = new DatabaseSequenceFilter(connection);
if (WRITE_CSV) {
CsvDataSetWriter csvWriter = new CsvDataSetWriter(CSV_EXPORT_DB_DIR);
csvWriter.write(new FilteredDataSet(filter, dataSet));
} else {
XmlDataSetWriter xmlDataSetWriter = new XmlDataSetWriter(new FileOutputStream(destinationFile),
charset.name()) {
@Override
protected void writeValue(String stringValue) throws IOException {
//write everything in CDATA except numbers
if (Pattern.matches(NUMERIC_REGEX, stringValue)) {
super.writeValue(stringValue);
} else {
super.writeValueCData(stringValue);
}
}
};
xmlDataSetWriter.write(new FilteredDataSet(filter, dataSet));
}
}
protected Connection getConnectionFromSpringTransaction() {
for (Object value : TransactionSynchronizationManager.getResourceMap().values()) {
if (value instanceof ConnectionHolder) {
ConnectionHolder connectionHolder = (ConnectionHolder) value;
return connectionHolder.getConnection();
}
}
throw new RuntimeException("unable to get Connection from Spring transaction");
}
} | 4,212 | 0.675926 | 0.674739 | 104 | 39.509617 | 29.395512 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.567308 | false | false | 11 |
2d4dc21c2c5186f856e6022455b84175be01fee8 | 21,114,059,233,271 | 069ab981a4df7d42fb9100f184348a545c175595 | /app/src/main/java/com/work/xinlai/component/lunbo/CommonBanner.java | c98f713576a81ca9a6b906bb9879afe970d17ec1 | [] | no_license | JETYIN/XinLaiAPP | https://github.com/JETYIN/XinLaiAPP | 2f3b8043072764da89bf04063e37a1681432b7ab | 984d1afaa82f14348c804b5d2561667ee6152195 | refs/heads/master | 2021-01-22T02:20:53.503000 | 2017-08-07T04:00:52 | 2017-08-07T04:00:52 | 81,043,653 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.work.xinlai.component.lunbo;
import android.content.Context;
import android.content.res.TypedArray;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.work.xinlai.R;
import com.work.xinlai.bean.CommanBannerClass;
import java.util.ArrayList;
import java.util.List;
public class CommonBanner extends ViewSwitcher implements OnClickListener {
public int BANNER_TYPE;
private MyViewAdapter myViewAdapter;
private LayoutInflater mLayoutInflater;
//此处定义数据
private List<CommanBannerClass> list;
public CommonBanner(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
TypedArray typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.CommonBanner);
BANNER_TYPE = typedArray.getInteger(R.styleable.CommonBanner_banner_plate, -1);
typedArray.recycle();
mLayoutInflater = LayoutInflater.from(context);
initData();
//实例化抽象的viewswitcheradapter
myViewAdapter = new MyViewAdapter();
this.setAdapter(myViewAdapter);
}
/**
* 点击跳转在此完成
**/
private void initData() {
list = new ArrayList<>();
list.add(new CommanBannerClass(R.drawable.splash_an));
list.add(new CommanBannerClass(R.drawable.pic_prof_scene));
list.add(new CommanBannerClass(R.drawable.splash_an));
list.add(new CommanBannerClass(R.drawable.pic_prof_scene));
}
private class MyViewAdapter extends ViewSwitcherAdapter {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mLayoutInflater.inflate(R.layout.item_switcher_image, parent, false);
}
ImageView image = (ImageView) convertView;
image.setImageResource(list.get(position).imageID);
return convertView;
}
@Override
public int getCount() {
return list.size();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.iv_image:
break;
}
}
}
| UTF-8 | Java | 2,409 | java | CommonBanner.java | Java | [] | null | [] | package com.work.xinlai.component.lunbo;
import android.content.Context;
import android.content.res.TypedArray;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.work.xinlai.R;
import com.work.xinlai.bean.CommanBannerClass;
import java.util.ArrayList;
import java.util.List;
public class CommonBanner extends ViewSwitcher implements OnClickListener {
public int BANNER_TYPE;
private MyViewAdapter myViewAdapter;
private LayoutInflater mLayoutInflater;
//此处定义数据
private List<CommanBannerClass> list;
public CommonBanner(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
TypedArray typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.CommonBanner);
BANNER_TYPE = typedArray.getInteger(R.styleable.CommonBanner_banner_plate, -1);
typedArray.recycle();
mLayoutInflater = LayoutInflater.from(context);
initData();
//实例化抽象的viewswitcheradapter
myViewAdapter = new MyViewAdapter();
this.setAdapter(myViewAdapter);
}
/**
* 点击跳转在此完成
**/
private void initData() {
list = new ArrayList<>();
list.add(new CommanBannerClass(R.drawable.splash_an));
list.add(new CommanBannerClass(R.drawable.pic_prof_scene));
list.add(new CommanBannerClass(R.drawable.splash_an));
list.add(new CommanBannerClass(R.drawable.pic_prof_scene));
}
private class MyViewAdapter extends ViewSwitcherAdapter {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mLayoutInflater.inflate(R.layout.item_switcher_image, parent, false);
}
ImageView image = (ImageView) convertView;
image.setImageResource(list.get(position).imageID);
return convertView;
}
@Override
public int getCount() {
return list.size();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.iv_image:
break;
}
}
}
| 2,409 | 0.669903 | 0.669481 | 78 | 29.371796 | 24.831799 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.576923 | false | false | 11 |
0ef7ddb18908fb9381469272721fd550e00c11da | 31,576,599,615,915 | a95c217d7802f42a7fec78e5cd2e5ab1631890a9 | /assignment3/NumberRow.java | c33293a6b67e37c72a69f3a58044b4b43dba9b6a | [] | no_license | frenz/PAD | https://github.com/frenz/PAD | 32389bcce6d3137458aed6b07084cf1a8f4f692a | 06b60fd8d9e4bbf2f7aac6ae746249ea816405c8 | refs/heads/master | 2020-04-01T16:47:31.569000 | 2015-06-26T19:47:27 | 2015-06-26T19:47:27 | 37,890,564 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package assignment3;
import java.util.Arrays;
public class NumberRow {
private double[] rowsArray;
private int numberOfRows = 0;
public NumberRow(int colomns) {
rowsArray = new double[colomns];
}
public double get(int i) {
return rowsArray[i];
}
public void set(int i, double d) {
if (i<=numberOfRows) {
rowsArray[i] = d;
}
else{
System.err.println("ERROR: ");
System.exit(-1);
}
}
public void add(double d) {
if (numberOfRows < rowsArray.length) {
rowsArray[numberOfRows++] = d;
}
else{
System.err.println("ERROR: ");
System.exit(-1);
}
}
public int size() {
return numberOfRows;
}
public void truncate(int length) {
rowsArray = Arrays.copyOf(rowsArray, length);
}
public double getMax() {
double result = Double.MIN_VALUE;
for(double item:rowsArray)
result=item>result?item:result;
return result;
}
} | UTF-8 | Java | 886 | java | NumberRow.java | Java | [] | null | [] | package assignment3;
import java.util.Arrays;
public class NumberRow {
private double[] rowsArray;
private int numberOfRows = 0;
public NumberRow(int colomns) {
rowsArray = new double[colomns];
}
public double get(int i) {
return rowsArray[i];
}
public void set(int i, double d) {
if (i<=numberOfRows) {
rowsArray[i] = d;
}
else{
System.err.println("ERROR: ");
System.exit(-1);
}
}
public void add(double d) {
if (numberOfRows < rowsArray.length) {
rowsArray[numberOfRows++] = d;
}
else{
System.err.println("ERROR: ");
System.exit(-1);
}
}
public int size() {
return numberOfRows;
}
public void truncate(int length) {
rowsArray = Arrays.copyOf(rowsArray, length);
}
public double getMax() {
double result = Double.MIN_VALUE;
for(double item:rowsArray)
result=item>result?item:result;
return result;
}
} | 886 | 0.653499 | 0.648984 | 56 | 14.839286 | 14.404584 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.553571 | false | false | 11 |
e0952dbad2ff0d74cba8dd7388a5a58e52fea05e | 5,978,594,490,350 | 10294e36832e897be5205024d429dcee7914d092 | /impala/impala-web/src/org/impalaframework/web/spring/servlet/InternalModuleServlet.java | 9c6af9d6764abad3fce16e84882dd6613fcd6d79 | [] | no_license | realtimedespatch/impala | https://github.com/realtimedespatch/impala | 8c9241b038e3c0b57eabc0dbaadfbc48647fed08 | 85c05dbffa47efec6d95ee8565245497d95ffb2e | refs/heads/master | 2022-05-16T08:29:22.430000 | 2022-03-21T16:35:56 | 2022-03-21T16:35:56 | 48,985,384 | 2 | 2 | null | true | 2016-01-04T08:54:47 | 2016-01-04T08:54:46 | 2015-08-01T21:23:59 | 2015-08-01T09:00:38 | 598,708 | 0 | 0 | 0 | null | null | null | /*
* Copyright 2007-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package org.impalaframework.web.spring.servlet;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.impalaframework.web.servlet.invoker.HttpServiceInvoker;
import org.impalaframework.web.servlet.invoker.ThreadContextClassLoaderHttpServiceInvoker;
import org.impalaframework.web.spring.ImpalaFrameworkServlet;
import org.impalaframework.web.spring.helper.ImpalaServletUtils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.util.NestedServletException;
/**
* Extension of {@link DispatcherServlet} for servlets which are defined
* not in web.xml but internally within the module using the
* <code>ServletFactoryBean</code>. At runtime, an instance can be retrieved
* using <code>ModuleProxyServlet</code>
*
* @author Phil Zoio
*/
public class InternalModuleServlet extends DispatcherServlet implements ApplicationContextAware, HttpServiceInvoker, ImpalaFrameworkServlet {
private static final long serialVersionUID = 1L;
private WebApplicationContext applicationContext;
private HttpServiceInvoker invoker;
/**
* Sets whether to set the thread context class loader to that of the class loader
* of the module. By default this is false.
*/
private boolean setThreadContextClassLoader = true;
public InternalModuleServlet() {
super();
}
@Override
protected WebApplicationContext initWebApplicationContext()
throws BeansException {
onRefresh(applicationContext);
//FIXME also, can this not simply override the findApplicationContext method
ImpalaServletUtils.publishWebApplicationContext(applicationContext, this);
setInvoker();
return applicationContext;
}
void setInvoker() {
this.invoker = new ThreadContextClassLoaderHttpServiceInvoker(this, setThreadContextClassLoader, applicationContext.getClassLoader());
}
@Override
protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception {
invoker.invoke(request, response, null);
}
public void invoke(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws IOException, ServletException {
try {
super.doService(request, response);
} catch (Exception e) {
throw new NestedServletException("Request processing failed", e);
}
}
@Override
public void destroy() {
ImpalaServletUtils.unpublishWebApplicationContext(this);
super.destroy();
}
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.applicationContext = ImpalaServletUtils.checkIsWebApplicationContext(getServletName(), applicationContext);
}
public void setSetThreadContextClassLoader(boolean setThreadContextClassLoader) {
this.setThreadContextClassLoader = setThreadContextClassLoader;
}
}
| UTF-8 | Java | 4,006 | java | InternalModuleServlet.java | Java | [
{
"context": "ing <code>ModuleProxyServlet</code>\n * \n * @author Phil Zoio\n */\npublic class InternalModuleServlet extends Di",
"end": 1769,
"score": 0.9998513460159302,
"start": 1760,
"tag": "NAME",
"value": "Phil Zoio"
}
] | null | [] | /*
* Copyright 2007-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package org.impalaframework.web.spring.servlet;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.impalaframework.web.servlet.invoker.HttpServiceInvoker;
import org.impalaframework.web.servlet.invoker.ThreadContextClassLoaderHttpServiceInvoker;
import org.impalaframework.web.spring.ImpalaFrameworkServlet;
import org.impalaframework.web.spring.helper.ImpalaServletUtils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.util.NestedServletException;
/**
* Extension of {@link DispatcherServlet} for servlets which are defined
* not in web.xml but internally within the module using the
* <code>ServletFactoryBean</code>. At runtime, an instance can be retrieved
* using <code>ModuleProxyServlet</code>
*
* @author <NAME>
*/
public class InternalModuleServlet extends DispatcherServlet implements ApplicationContextAware, HttpServiceInvoker, ImpalaFrameworkServlet {
private static final long serialVersionUID = 1L;
private WebApplicationContext applicationContext;
private HttpServiceInvoker invoker;
/**
* Sets whether to set the thread context class loader to that of the class loader
* of the module. By default this is false.
*/
private boolean setThreadContextClassLoader = true;
public InternalModuleServlet() {
super();
}
@Override
protected WebApplicationContext initWebApplicationContext()
throws BeansException {
onRefresh(applicationContext);
//FIXME also, can this not simply override the findApplicationContext method
ImpalaServletUtils.publishWebApplicationContext(applicationContext, this);
setInvoker();
return applicationContext;
}
void setInvoker() {
this.invoker = new ThreadContextClassLoaderHttpServiceInvoker(this, setThreadContextClassLoader, applicationContext.getClassLoader());
}
@Override
protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception {
invoker.invoke(request, response, null);
}
public void invoke(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws IOException, ServletException {
try {
super.doService(request, response);
} catch (Exception e) {
throw new NestedServletException("Request processing failed", e);
}
}
@Override
public void destroy() {
ImpalaServletUtils.unpublishWebApplicationContext(this);
super.destroy();
}
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.applicationContext = ImpalaServletUtils.checkIsWebApplicationContext(getServletName(), applicationContext);
}
public void setSetThreadContextClassLoader(boolean setThreadContextClassLoader) {
this.setThreadContextClassLoader = setThreadContextClassLoader;
}
}
| 4,003 | 0.755117 | 0.751872 | 106 | 36.792454 | 35.380337 | 142 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.509434 | false | false | 11 |
bf7b4b6c0cfd0565d298f60dd70848933e22d217 | 17,093,969,852,185 | b536174eaae6dab9e7bb749f495db9aa0859f7e8 | /src/main/java/ru/baikalpass/rest/DateGenerate.java | 293f9568a2fde7687ee6dabf14763a7b6942c10b | [] | no_license | trudoliubov/Java_restAssured_api_test_sample | https://github.com/trudoliubov/Java_restAssured_api_test_sample | 729931d377fb7165f5381ac5ef8dec062064b3f1 | ac6501c5a324f82c54fd2555904b735348d591ff | refs/heads/master | 2023-04-06T05:17:57.945000 | 2021-04-16T17:10:48 | 2021-04-16T17:10:48 | 358,667,642 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ru.baikalpass.rest;
import org.codehaus.groovy.transform.PackageScopeASTTransformation;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class DateGenerate {
public static String genDate(String date) throws ParseException {
DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
Calendar calendar = new GregorianCalendar();
calendar.add(Calendar.DAY_OF_YEAR, Integer.parseInt(date));
return date = dateFormat.format(calendar.getTime());
}
public static String genDateMillisecond(String date) throws ParseException {
DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
Calendar calendar = new GregorianCalendar();
calendar.add(Calendar.DAY_OF_YEAR, Integer.parseInt(date));
date = dateFormat.format(calendar.getTime());
Date dateMillisecond = dateFormat.parse(date);
calendar.setTime(dateMillisecond);
Long time = calendar.getTimeInMillis();
String timeMillisecond = Long.toString(time);
return timeMillisecond;
}
/* private static String genBeginDate(){
return genBeginDate();
}*/
}
/*Date parseBeginDateMillisecond =dateFormat.parse(beginDate);
calendar.add(Calendar.DAY_OF_YEAR, 6);
this.endDate = dateFormat.format(calendar.getTime());
Date parseEndDateMillisecond =dateFormat.parse(endDate);
calendar.setTime(parseBeginDateMillisecond);
this.beginDateMillisecond = calendar.getTimeInMillis();
calendar.setTime(parseEndDateMillisecond);
this.endDateMillisecond = calendar.getTimeInMillis();*/ | UTF-8 | Java | 1,764 | java | DateGenerate.java | Java | [] | null | [] | package ru.baikalpass.rest;
import org.codehaus.groovy.transform.PackageScopeASTTransformation;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class DateGenerate {
public static String genDate(String date) throws ParseException {
DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
Calendar calendar = new GregorianCalendar();
calendar.add(Calendar.DAY_OF_YEAR, Integer.parseInt(date));
return date = dateFormat.format(calendar.getTime());
}
public static String genDateMillisecond(String date) throws ParseException {
DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
Calendar calendar = new GregorianCalendar();
calendar.add(Calendar.DAY_OF_YEAR, Integer.parseInt(date));
date = dateFormat.format(calendar.getTime());
Date dateMillisecond = dateFormat.parse(date);
calendar.setTime(dateMillisecond);
Long time = calendar.getTimeInMillis();
String timeMillisecond = Long.toString(time);
return timeMillisecond;
}
/* private static String genBeginDate(){
return genBeginDate();
}*/
}
/*Date parseBeginDateMillisecond =dateFormat.parse(beginDate);
calendar.add(Calendar.DAY_OF_YEAR, 6);
this.endDate = dateFormat.format(calendar.getTime());
Date parseEndDateMillisecond =dateFormat.parse(endDate);
calendar.setTime(parseBeginDateMillisecond);
this.beginDateMillisecond = calendar.getTimeInMillis();
calendar.setTime(parseEndDateMillisecond);
this.endDateMillisecond = calendar.getTimeInMillis();*/ | 1,764 | 0.717687 | 0.71712 | 50 | 34.299999 | 26.018646 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.66 | false | false | 11 |
64000b13a7bf57c712f04abf813f336463aea57c | 29,472,065,647,761 | 820e415f8968bce1a9b2eab636cc7bb26502b437 | /service-ribbon/src/main/java/tech/elven/springcloud/ribbon/rest/HelloService.java | 069c224dab9a47b5f0965a2d42bcb6a46c48cc0b | [] | no_license | elveny/elven-spring-cloud | https://github.com/elveny/elven-spring-cloud | bf7860b5182238e41647546aea12d24a0475cdcb | 2ba05b38f2f8a7ee81d602ef80eeeb15ecf1aa80 | refs/heads/master | 2021-10-04T06:42:35.239000 | 2018-12-03T13:37:26 | 2018-12-03T13:37:26 | 103,965,888 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* elven.site Inc.
* Copyright (c) 2017-2026 All Rights Reserved.
*/
package tech.elven.springcloud.ribbon.rest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
/**
* @author qiusheng.wu
* @Filename HelloService.java
* @description
* @Version 1.0
* @History <li>Author: qiusheng.wu</li>
* <li>Date: 2017/9/19 17:45</li>
* <li>Version: 1.0</li>
* <li>Content: create</li>
*/
@Service
public class HelloService {
@Autowired
private RestTemplate restTemplate;
public String hello() {
return restTemplate.getForObject("http://elven-spring-cloud-serviceA/cloud.elven.tech/serviceA/rest/hello/hello",String.class);
}
} | UTF-8 | Java | 769 | java | HelloService.java | Java | [
{
"context": "framework.web.client.RestTemplate;\n\n/**\n * @author qiusheng.wu\n * @Filename HelloService.java\n * @description\n *",
"end": 309,
"score": 0.9988792538642883,
"start": 298,
"tag": "NAME",
"value": "qiusheng.wu"
},
{
"context": "escription\n * @Version 1.0\n * @History <li>Author: qiusheng.wu</li>\n * <li>Date: 2017/9/19 17:45</li>\n * <li>Ver",
"end": 408,
"score": 0.9899222254753113,
"start": 397,
"tag": "NAME",
"value": "qiusheng.wu"
}
] | null | [] | /**
* elven.site Inc.
* Copyright (c) 2017-2026 All Rights Reserved.
*/
package tech.elven.springcloud.ribbon.rest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
/**
* @author qiusheng.wu
* @Filename HelloService.java
* @description
* @Version 1.0
* @History <li>Author: qiusheng.wu</li>
* <li>Date: 2017/9/19 17:45</li>
* <li>Version: 1.0</li>
* <li>Content: create</li>
*/
@Service
public class HelloService {
@Autowired
private RestTemplate restTemplate;
public String hello() {
return restTemplate.getForObject("http://elven-spring-cloud-serviceA/cloud.elven.tech/serviceA/rest/hello/hello",String.class);
}
} | 769 | 0.719116 | 0.689207 | 30 | 24.666666 | 27.059605 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.233333 | false | false | 11 |
0a10a63bbe35f521ba4fb488832529043b6257e1 | 927,712,960,192 | 8b405fdb0c5cca7885de95089663b06d72157066 | /basket-service/src/test/java/com/ecommerce/BasketControllerTest.java | 9961fd7f20902b8bdddb8b1496ccf9ad20cd148f | [] | no_license | yahyatoraman/Cloud-Native-Ecommerce | https://github.com/yahyatoraman/Cloud-Native-Ecommerce | 20d2d179108ae7e9718c18f53b981709ba42e82a | d74c6057377fd136f299b7ca8cc579ef7762673b | refs/heads/master | 2022-12-22T12:55:05.820000 | 2020-09-29T08:14:18 | 2020-09-29T08:14:18 | 297,436,124 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ecommerce;
import com.ecommerce.model.BasketDto;
import com.ecommerce.model.BasketSummaryDto;
import com.ecommerce.resource.BasketController;
import com.ecommerce.service.BasketService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import java.util.Arrays;
import java.util.List;
import static org.hamcrest.Matchers.containsString;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(BasketController.class)
@AutoConfigureMockMvc(addFilters = false)
@RunWith(SpringRunner.class)
public class BasketControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private BasketService basketService;
@Test
public void test_getSummaryBasketByUsername() throws Exception {
Mockito.when(basketService.getBasketSummaryByUsername("foo")).thenReturn(prepareBasketSDtoList());
this.mockMvc.perform(get("/basket-summary/foo"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string(containsString("612")));
}
@Test
public void test_getDetailedBasketByUsername() throws Exception {
Mockito.when(basketService.getDetailedBasketByUsername("foo")).thenReturn(prepareBasketDtoList());
this.mockMvc.perform(get("/detailed-basket/foo"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string(containsString("306")));
}
private List<BasketDto> prepareBasketDtoList() {
BasketDto dto = new BasketDto();
dto.setProductId(4L);
dto.setQuantity(306);
dto.setSizeId(2L);
return Arrays.asList(dto);
}
private List<BasketSummaryDto> prepareBasketSDtoList() {
BasketSummaryDto dto = new BasketSummaryDto();
dto.setProductId(3L);
dto.setQuantity(612);
return Arrays.asList(dto);
}
}
| UTF-8 | Java | 2,614 | java | BasketControllerTest.java | Java | [] | null | [] | package com.ecommerce;
import com.ecommerce.model.BasketDto;
import com.ecommerce.model.BasketSummaryDto;
import com.ecommerce.resource.BasketController;
import com.ecommerce.service.BasketService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import java.util.Arrays;
import java.util.List;
import static org.hamcrest.Matchers.containsString;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(BasketController.class)
@AutoConfigureMockMvc(addFilters = false)
@RunWith(SpringRunner.class)
public class BasketControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private BasketService basketService;
@Test
public void test_getSummaryBasketByUsername() throws Exception {
Mockito.when(basketService.getBasketSummaryByUsername("foo")).thenReturn(prepareBasketSDtoList());
this.mockMvc.perform(get("/basket-summary/foo"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string(containsString("612")));
}
@Test
public void test_getDetailedBasketByUsername() throws Exception {
Mockito.when(basketService.getDetailedBasketByUsername("foo")).thenReturn(prepareBasketDtoList());
this.mockMvc.perform(get("/detailed-basket/foo"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string(containsString("306")));
}
private List<BasketDto> prepareBasketDtoList() {
BasketDto dto = new BasketDto();
dto.setProductId(4L);
dto.setQuantity(306);
dto.setSizeId(2L);
return Arrays.asList(dto);
}
private List<BasketSummaryDto> prepareBasketSDtoList() {
BasketSummaryDto dto = new BasketSummaryDto();
dto.setProductId(3L);
dto.setQuantity(612);
return Arrays.asList(dto);
}
}
| 2,614 | 0.740627 | 0.734506 | 70 | 36.342857 | 28.224552 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.514286 | false | false | 11 |
a37a5d2dc123af972a6c057b512a9c0cb9afe5a1 | 5,248,450,056,420 | bf36ab295984f4bdd36b7c8fa41422055fd66de4 | /yssl/src/com/strod/yssl/view/autoscrollviewpager/Banner.java | 8ab09996ba44b6070fd539f9ef2844a93d439f17 | [] | no_license | laiying/atangge | https://github.com/laiying/atangge | 7447f79338d54620750e536bd4e4274bb2a26c21 | 10878a830851568bb34b7f38c597096d9f471518 | refs/heads/master | 2018-01-13T06:27:05.471000 | 2017-01-13T07:30:21 | 2017-01-13T07:30:21 | 40,306,130 | 5 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.strod.yssl.view.autoscrollviewpager;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.strod.yssl.R;
import com.strod.yssl.bean.main.Article;
import java.util.List;
/**
* @author lying
*/
public class Banner extends RelativeLayout{
private Context context;
private List<Article> bannerEntityList;
private RelativeLayout mContainer;
private AutoScrollViewPager viewPager;
private CircleIndicator indicator;
public Banner(Context context) {
this(context, null);
initView(context);
}
public Banner(Context context, AttributeSet attrs) {
this(context, attrs, 0);
initView(context);
}
public Banner(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
initView(context);
}
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public Banner(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
// super(context, attrs, defStyleAttr, defStyleRes);
// this.context = context;
// initView(context);
// }
public void initView(Context act) {
View mView = LayoutInflater.from(act).inflate(R.layout.banner, this, true);
mContainer = (RelativeLayout) mView.findViewById(R.id.banner);
viewPager = (AutoScrollViewPager) mView.findViewById(R.id.viewpager);
indicator = (CircleIndicator) mView.findViewById(R.id.indicator);
}
public void setBannerVisibility(int visibility){
mContainer.setVisibility(visibility);
}
public void setBannerEntityList(List<Article> bannerEntityList){
if (bannerEntityList == null)
throw new NullPointerException("bannerEntity cannot be null");
this.bannerEntityList = bannerEntityList;
}
public void setBannerPagerAdapter(){
viewPager.setAdapter(new BannerPagerAdapter(context, bannerEntityList));
}
public void setIndicator(){
indicator.setViewPager(viewPager);
indicator.setSelectedPos(0);
}
@Override
protected void attachViewToParent(View child, int index, ViewGroup.LayoutParams params) {
super.attachViewToParent(child, index, params);
viewPager.startAutoScroll();
}
@Override
protected void detachViewFromParent(View child) {
super.detachViewFromParent(child);
viewPager.stopAutoScroll();
}
}
| UTF-8 | Java | 2,601 | java | Banner.java | Java | [
{
"context": "n.Article;\n\nimport java.util.List;\n\n/**\n * @author lying\n */\npublic class Banner extends RelativeLayout{\n\n",
"end": 359,
"score": 0.9993710517883301,
"start": 354,
"tag": "USERNAME",
"value": "lying"
}
] | null | [] | package com.strod.yssl.view.autoscrollviewpager;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.strod.yssl.R;
import com.strod.yssl.bean.main.Article;
import java.util.List;
/**
* @author lying
*/
public class Banner extends RelativeLayout{
private Context context;
private List<Article> bannerEntityList;
private RelativeLayout mContainer;
private AutoScrollViewPager viewPager;
private CircleIndicator indicator;
public Banner(Context context) {
this(context, null);
initView(context);
}
public Banner(Context context, AttributeSet attrs) {
this(context, attrs, 0);
initView(context);
}
public Banner(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
initView(context);
}
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public Banner(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
// super(context, attrs, defStyleAttr, defStyleRes);
// this.context = context;
// initView(context);
// }
public void initView(Context act) {
View mView = LayoutInflater.from(act).inflate(R.layout.banner, this, true);
mContainer = (RelativeLayout) mView.findViewById(R.id.banner);
viewPager = (AutoScrollViewPager) mView.findViewById(R.id.viewpager);
indicator = (CircleIndicator) mView.findViewById(R.id.indicator);
}
public void setBannerVisibility(int visibility){
mContainer.setVisibility(visibility);
}
public void setBannerEntityList(List<Article> bannerEntityList){
if (bannerEntityList == null)
throw new NullPointerException("bannerEntity cannot be null");
this.bannerEntityList = bannerEntityList;
}
public void setBannerPagerAdapter(){
viewPager.setAdapter(new BannerPagerAdapter(context, bannerEntityList));
}
public void setIndicator(){
indicator.setViewPager(viewPager);
indicator.setSelectedPos(0);
}
@Override
protected void attachViewToParent(View child, int index, ViewGroup.LayoutParams params) {
super.attachViewToParent(child, index, params);
viewPager.startAutoScroll();
}
@Override
protected void detachViewFromParent(View child) {
super.detachViewFromParent(child);
viewPager.stopAutoScroll();
}
}
| 2,601 | 0.698193 | 0.697424 | 90 | 27.9 | 25.350454 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 11 |
3d278c9af84e7869bd9069402430efc2a653c983 | 26,637,387,228,662 | 7140636fbd8016710b39dfda518bf2ce19b2c7c1 | /jbpm-form-modeler-core/jbpm-form-modeler-service/jbpm-form-modeler-request-dispatcher/src/main/java/org/jbpm/formModeler/service/bb/mvc/components/handling/BeanHandler.java | 0720ff782fdb3a978f6d5abe435813a08a12b870 | [
"Apache-2.0"
] | permissive | repo-autkat/jbpm-form-modeler | https://github.com/repo-autkat/jbpm-form-modeler | 2a6023a610aab1cbbf13b342eccef6f37d316959 | bd957f86b8b1a810a0210c19566c5e1bf030c6e4 | refs/heads/master | 2023-04-28T14:19:11.988000 | 2017-09-22T12:33:09 | 2017-09-22T12:33:09 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Copyright (C) 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jbpm.formModeler.service.bb.mvc.components.handling;
import org.slf4j.Logger;
import org.jbpm.formModeler.service.bb.mvc.components.CurrentComponentRenderer;
import org.jbpm.formModeler.service.bb.mvc.components.FactoryURL;
import org.jbpm.formModeler.service.bb.mvc.controller.CommandRequest;
import org.jbpm.formModeler.service.bb.mvc.controller.CommandResponse;
import org.jbpm.formModeler.service.bb.mvc.controller.responses.SendStreamResponse;
import org.apache.commons.lang3.StringUtils;
import org.jbpm.formModeler.service.bb.mvc.controller.responses.ShowScreenResponse;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.*;
public abstract class BeanHandler implements Serializable {
private Logger log = LoggerFactory.getLogger(BeanHandler.class);
private List propertyErrors = new ArrayList();
private Set wrongFields = new HashSet();
private Properties actionsShortcuts = new Properties();
private Properties reverseActionsShortcuts = new Properties();
private boolean useActionShortcuts = true;
private boolean enableDoubleClickControl = true;
private boolean enabledForActionHandling = false;
private Map<String, String> extraActionParams = new HashMap<String, String>();
public String getBeanName() {
return this.getClass().getName();
}
public boolean isUseActionShortcuts() {
return useActionShortcuts;
}
public void setUseActionShortcuts(boolean useActionShortcuts) {
this.useActionShortcuts = useActionShortcuts;
}
public boolean isEnableDoubleClickControl() {
return enableDoubleClickControl;
}
public void setEnableDoubleClickControl(boolean enableDoubleClickControl) {
this.enableDoubleClickControl = enableDoubleClickControl;
}
public boolean isEnabledForActionHandling() {
return enabledForActionHandling;
}
public void setEnabledForActionHandling(boolean enabledForActionHandling) {
this.enabledForActionHandling = enabledForActionHandling;
}
@PostConstruct
public void start() {
if (isUseActionShortcuts()) {
calculateActionShortcuts();
}
}
protected void calculateActionShortcuts() {
Method[] allMethods = this.getClass().getMethods();
TreeSet actionNames = new TreeSet();
for (int i = 0; i < allMethods.length; i++) {
Method method = allMethods[i];
if (method.getName().startsWith("action")) {
Class[] classes = method.getParameterTypes();
if (classes != null && classes.length == 1) {
Class paramClass = classes[0];
if (paramClass.equals(CommandRequest.class)) {
String actionName = method.getName().substring("action".length());
actionNames.add(actionName);
}
}
}
}
int index = 0;
for (Iterator iterator = actionNames.iterator(); iterator.hasNext(); index++) {
String action = (String) iterator.next();
actionsShortcuts.put(action, String.valueOf(index));
reverseActionsShortcuts.put(String.valueOf(index), action);
}
}
/**
* Get the action name for given action name. If there is a shortcut, it will be returned, otherwise, the same name applies.
*
* @param actionName action name
* @return the action name for given action name
*/
public String getActionName(String actionName) {
actionName = StringUtils.capitalize(actionName);
return actionsShortcuts.getProperty(actionName, actionName);
}
/**
* Get the action name for a given shortcut.
*
* @param shortcut the possible shortcut whose action name is to be obtained.
* @return the action name for the given shortcut if found, or the shortcut itself if not.
*/
public String getActionForShortcut(String shortcut) {
String actionName = reverseActionsShortcuts.getProperty(shortcut);
return actionName != null ? actionName : shortcut;
}
public synchronized CommandResponse handle(CommandRequest request, String action) throws Exception {
if (log.isDebugEnabled()) log.debug("Entering handle " + getBeanName() + " action: " + action);
// Calculate the action to invoke.
action = StringUtils.capitalize(action);
action = reverseActionsShortcuts.getProperty(action, action);
// Double click control.
if (isEnableDoubleClickControl() && !isEnabledForActionHandling()) {
// Duplicates can only be prevented in session components, and if they are enabled for that purpose
log.warn("Discarding duplicated execution in component " + getBeanName() + ", action: " + action + ". User should be advised not to double click!");
return null;
}
try {
String methodName = "action" + action;
beforeInvokeAction(request, action);
CommandResponse response = null;
Method handlerMethod = this.getClass().getMethod(methodName, new Class[]{CommandRequest.class});
if (log.isDebugEnabled()) log.debug("Invoking method " + methodName + " on " + getBeanName());
response = (CommandResponse) handlerMethod.invoke(this, new Object[]{request});
afterInvokeAction(request, action);
if (response == null) {
response = new ShowScreenResponse( getCurrentComponentRenderer().getCurrentComponent().getBaseComponentJSP() );
}
if (!(response instanceof SendStreamResponse)) {
setEnabledForActionHandling(false);
String ajaxParam = request.getRequestObject().getParameter("ajaxAction");
boolean isAjax = ajaxParam != null && Boolean.valueOf(ajaxParam).booleanValue();
if ( !isAjax ) {
response = null;
}
}
if (log.isDebugEnabled()) log.debug("Leaving handle " + getBeanName() + " - " + action);
return response;
} catch (Exception ex) {
log.warn("Error handling action '" + action + "': ", ex);
}
return null;
}
protected CurrentComponentRenderer getCurrentComponentRenderer() {
return CurrentComponentRenderer.lookup();
}
protected void beforeInvokeAction(CommandRequest request, String action) throws Exception {
}
protected void afterInvokeAction(CommandRequest request, String action) throws Exception {
}
public void addFieldError(FactoryURL property, Exception e, Object propertyValue) {
propertyErrors.add(new FieldException("Error setting property to component", property, propertyValue, e));
wrongFields.add(property.getPropertyName());
}
public void clearFieldErrors() {
propertyErrors.clear();
wrongFields.clear();
}
public List getFieldErrors() {
return Collections.unmodifiableList(propertyErrors);
}
public boolean hasError(String fieldName) {
return wrongFields.contains(fieldName);
}
public void actionVoid(CommandRequest request) {
}
public Map<String, String> getExtraActionParams() {
return extraActionParams;
}
}
| UTF-8 | Java | 8,114 | java | BeanHandler.java | Java | [] | null | [] | /**
* Copyright (C) 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jbpm.formModeler.service.bb.mvc.components.handling;
import org.slf4j.Logger;
import org.jbpm.formModeler.service.bb.mvc.components.CurrentComponentRenderer;
import org.jbpm.formModeler.service.bb.mvc.components.FactoryURL;
import org.jbpm.formModeler.service.bb.mvc.controller.CommandRequest;
import org.jbpm.formModeler.service.bb.mvc.controller.CommandResponse;
import org.jbpm.formModeler.service.bb.mvc.controller.responses.SendStreamResponse;
import org.apache.commons.lang3.StringUtils;
import org.jbpm.formModeler.service.bb.mvc.controller.responses.ShowScreenResponse;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.*;
public abstract class BeanHandler implements Serializable {
private Logger log = LoggerFactory.getLogger(BeanHandler.class);
private List propertyErrors = new ArrayList();
private Set wrongFields = new HashSet();
private Properties actionsShortcuts = new Properties();
private Properties reverseActionsShortcuts = new Properties();
private boolean useActionShortcuts = true;
private boolean enableDoubleClickControl = true;
private boolean enabledForActionHandling = false;
private Map<String, String> extraActionParams = new HashMap<String, String>();
public String getBeanName() {
return this.getClass().getName();
}
public boolean isUseActionShortcuts() {
return useActionShortcuts;
}
public void setUseActionShortcuts(boolean useActionShortcuts) {
this.useActionShortcuts = useActionShortcuts;
}
public boolean isEnableDoubleClickControl() {
return enableDoubleClickControl;
}
public void setEnableDoubleClickControl(boolean enableDoubleClickControl) {
this.enableDoubleClickControl = enableDoubleClickControl;
}
public boolean isEnabledForActionHandling() {
return enabledForActionHandling;
}
public void setEnabledForActionHandling(boolean enabledForActionHandling) {
this.enabledForActionHandling = enabledForActionHandling;
}
@PostConstruct
public void start() {
if (isUseActionShortcuts()) {
calculateActionShortcuts();
}
}
protected void calculateActionShortcuts() {
Method[] allMethods = this.getClass().getMethods();
TreeSet actionNames = new TreeSet();
for (int i = 0; i < allMethods.length; i++) {
Method method = allMethods[i];
if (method.getName().startsWith("action")) {
Class[] classes = method.getParameterTypes();
if (classes != null && classes.length == 1) {
Class paramClass = classes[0];
if (paramClass.equals(CommandRequest.class)) {
String actionName = method.getName().substring("action".length());
actionNames.add(actionName);
}
}
}
}
int index = 0;
for (Iterator iterator = actionNames.iterator(); iterator.hasNext(); index++) {
String action = (String) iterator.next();
actionsShortcuts.put(action, String.valueOf(index));
reverseActionsShortcuts.put(String.valueOf(index), action);
}
}
/**
* Get the action name for given action name. If there is a shortcut, it will be returned, otherwise, the same name applies.
*
* @param actionName action name
* @return the action name for given action name
*/
public String getActionName(String actionName) {
actionName = StringUtils.capitalize(actionName);
return actionsShortcuts.getProperty(actionName, actionName);
}
/**
* Get the action name for a given shortcut.
*
* @param shortcut the possible shortcut whose action name is to be obtained.
* @return the action name for the given shortcut if found, or the shortcut itself if not.
*/
public String getActionForShortcut(String shortcut) {
String actionName = reverseActionsShortcuts.getProperty(shortcut);
return actionName != null ? actionName : shortcut;
}
public synchronized CommandResponse handle(CommandRequest request, String action) throws Exception {
if (log.isDebugEnabled()) log.debug("Entering handle " + getBeanName() + " action: " + action);
// Calculate the action to invoke.
action = StringUtils.capitalize(action);
action = reverseActionsShortcuts.getProperty(action, action);
// Double click control.
if (isEnableDoubleClickControl() && !isEnabledForActionHandling()) {
// Duplicates can only be prevented in session components, and if they are enabled for that purpose
log.warn("Discarding duplicated execution in component " + getBeanName() + ", action: " + action + ". User should be advised not to double click!");
return null;
}
try {
String methodName = "action" + action;
beforeInvokeAction(request, action);
CommandResponse response = null;
Method handlerMethod = this.getClass().getMethod(methodName, new Class[]{CommandRequest.class});
if (log.isDebugEnabled()) log.debug("Invoking method " + methodName + " on " + getBeanName());
response = (CommandResponse) handlerMethod.invoke(this, new Object[]{request});
afterInvokeAction(request, action);
if (response == null) {
response = new ShowScreenResponse( getCurrentComponentRenderer().getCurrentComponent().getBaseComponentJSP() );
}
if (!(response instanceof SendStreamResponse)) {
setEnabledForActionHandling(false);
String ajaxParam = request.getRequestObject().getParameter("ajaxAction");
boolean isAjax = ajaxParam != null && Boolean.valueOf(ajaxParam).booleanValue();
if ( !isAjax ) {
response = null;
}
}
if (log.isDebugEnabled()) log.debug("Leaving handle " + getBeanName() + " - " + action);
return response;
} catch (Exception ex) {
log.warn("Error handling action '" + action + "': ", ex);
}
return null;
}
protected CurrentComponentRenderer getCurrentComponentRenderer() {
return CurrentComponentRenderer.lookup();
}
protected void beforeInvokeAction(CommandRequest request, String action) throws Exception {
}
protected void afterInvokeAction(CommandRequest request, String action) throws Exception {
}
public void addFieldError(FactoryURL property, Exception e, Object propertyValue) {
propertyErrors.add(new FieldException("Error setting property to component", property, propertyValue, e));
wrongFields.add(property.getPropertyName());
}
public void clearFieldErrors() {
propertyErrors.clear();
wrongFields.clear();
}
public List getFieldErrors() {
return Collections.unmodifiableList(propertyErrors);
}
public boolean hasError(String fieldName) {
return wrongFields.contains(fieldName);
}
public void actionVoid(CommandRequest request) {
}
public Map<String, String> getExtraActionParams() {
return extraActionParams;
}
}
| 8,114 | 0.670569 | 0.668721 | 208 | 38.009617 | 33.310165 | 160 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.538462 | false | false | 11 |
c18a6438daed91e0e6622719e7b89ae111a825e3 | 8,813,272,933,644 | 764ffb02e460c886796a453941ee47e51b75ad07 | /code/GDES/GDES-WEB/src/main/test/com/gdes/GDES/test/TestKonwledgepoint.java | b70e2b837d4b30711653831845686e9ebfeba4ca | [
"MIT"
] | permissive | o174110/GraduationDesign_EvaluationSystem | https://github.com/o174110/GraduationDesign_EvaluationSystem | 4059b84e834d9e442a9ca18956a992ebe396fb2e | 6ed0d423a3d2a5b08a44a6a15a66a56fb35998ee | refs/heads/master | 2021-01-01T03:06:26.195000 | 2018-06-13T06:18:20 | 2018-06-13T06:18:20 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gdes.GDES.test;
import com.gdes.GDES.model.Knowledgepoint;
import com.gdes.GDES.service.KnowledgepointService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gdes.GDES.model.KnowledgepointExample;
import com.gdes.GDES.dao.KnowledgepointMapper;
import javax.annotation.Resource;
import java.util.List;
/**
* Created by Allen on 2018/5/10.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:config/applicationContext.xml")
public class TestKonwledgepoint {
@Resource
private KnowledgepointMapper kpm;
@Resource
private KnowledgepointService knowledgepointService;
@Test
public void testFindKonwledgepoint(){
KnowledgepointExample kpe=new KnowledgepointExample();
kpe.setOrderByClause("id_kp asc");
kpe.setDistinct(false);
KnowledgepointExample.Criteria criteria=kpe.createCriteria();
criteria.andIdCIsNotNull();
List<Knowledgepoint> list=kpm.selectByExample(kpe);
// System.out.println(list);
for(Knowledgepoint kp:list){
System.out.println(kp.getNameKp());
}
}
//模糊查询
@Test
public void findKonwledgepoint()throws Exception{
KnowledgepointExample kpe=new KnowledgepointExample();
KnowledgepointExample.Criteria criteria=kpe.createCriteria();
criteria.andIdCEqualTo("2");
List<Knowledgepoint> list=kpm.selectByExample(kpe);
for(Knowledgepoint kp:list){
System.out.println(kp.getNameKp());
}
}
//添加测试
@Test
public void addKonwledgepoint(){
Knowledgepoint kp=new Knowledgepoint();
kp.setIdC("2");
kp.setIdAp(4);
kp.setNameKp("数组的抽象思维");
kp.setProportionKp("0.2");
//
kpm.insert(kp);
}
@Test
public void updateKonwledgepoint(){
Knowledgepoint kp=new Knowledgepoint();
kp.setIdKp(3);
kp.setProportionKp("0.01");
kpm.updateByPrimaryKeySelective(kp);
}
@Test
public void testGetCount() throws Exception {
System.out.println(knowledgepointService.getCount());
}
}
| UTF-8 | Java | 2,329 | java | TestKonwledgepoint.java | Java | [
{
"context": "esource;\nimport java.util.List;\n\n/**\n * Created by Allen on 2018/5/10.\n */\n\n@RunWith(SpringJUnit4ClassRunn",
"end": 494,
"score": 0.9822132587432861,
"start": 489,
"tag": "NAME",
"value": "Allen"
}
] | null | [] | package com.gdes.GDES.test;
import com.gdes.GDES.model.Knowledgepoint;
import com.gdes.GDES.service.KnowledgepointService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gdes.GDES.model.KnowledgepointExample;
import com.gdes.GDES.dao.KnowledgepointMapper;
import javax.annotation.Resource;
import java.util.List;
/**
* Created by Allen on 2018/5/10.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:config/applicationContext.xml")
public class TestKonwledgepoint {
@Resource
private KnowledgepointMapper kpm;
@Resource
private KnowledgepointService knowledgepointService;
@Test
public void testFindKonwledgepoint(){
KnowledgepointExample kpe=new KnowledgepointExample();
kpe.setOrderByClause("id_kp asc");
kpe.setDistinct(false);
KnowledgepointExample.Criteria criteria=kpe.createCriteria();
criteria.andIdCIsNotNull();
List<Knowledgepoint> list=kpm.selectByExample(kpe);
// System.out.println(list);
for(Knowledgepoint kp:list){
System.out.println(kp.getNameKp());
}
}
//模糊查询
@Test
public void findKonwledgepoint()throws Exception{
KnowledgepointExample kpe=new KnowledgepointExample();
KnowledgepointExample.Criteria criteria=kpe.createCriteria();
criteria.andIdCEqualTo("2");
List<Knowledgepoint> list=kpm.selectByExample(kpe);
for(Knowledgepoint kp:list){
System.out.println(kp.getNameKp());
}
}
//添加测试
@Test
public void addKonwledgepoint(){
Knowledgepoint kp=new Knowledgepoint();
kp.setIdC("2");
kp.setIdAp(4);
kp.setNameKp("数组的抽象思维");
kp.setProportionKp("0.2");
//
kpm.insert(kp);
}
@Test
public void updateKonwledgepoint(){
Knowledgepoint kp=new Knowledgepoint();
kp.setIdKp(3);
kp.setProportionKp("0.01");
kpm.updateByPrimaryKeySelective(kp);
}
@Test
public void testGetCount() throws Exception {
System.out.println(knowledgepointService.getCount());
}
}
| 2,329 | 0.68769 | 0.679426 | 84 | 26.369047 | 22.199196 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.440476 | false | false | 11 |
00f25f4ddca81fc2ee023f4ff56e51d43e409a45 | 31,284,541,826,580 | b47783c8770f7818f123b63cf7c86207c4f94f8f | /java_course_internship/8thTask_DesignPatterns [EightTask]/src/test/java/StepDefinition/RegisterSteps.java | c399be3acb4ac1b2648196eb6c208be89824f5dd | [] | no_license | peBetrator/java_course_internship | https://github.com/peBetrator/java_course_internship | 2e852759f9dd2b4fbb181a91bdb9d4f679a62e5b | 68c03b60614d018a960a2aac555f6b19c92ca227 | refs/heads/master | 2020-04-12T04:02:13.656000 | 2018-12-18T12:19:29 | 2018-12-18T12:19:29 | 162,283,014 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package StepDefinition;
import Pages.LoginPage;
import Pages.MainPage;
import Pages.RegisterPage;
import TestContext.TestContext;
import cucumber.api.PendingException;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.junit.Assert;
public class RegisterSteps {
TestContext testContext;
MainPage mainPage;
LoginPage loginPage;
RegisterPage registerPage;
public RegisterSteps(TestContext context) {
testContext = context;
mainPage = testContext.getPageObjectManager().getMainPage();
loginPage = testContext.getPageObjectManager().getLoginPage();
registerPage = testContext.getPageObjectManager().getRegisterPage();
}
@When("^User navigates to RegisterPage$")
public void user_navigates_to_RegisterPage() {
mainPage.clickLoginButton();
loginPage.clickRegisterButton();
String res = registerPage.getHeadingText();
Assert.assertEquals("Register", res);
}
@And("^User fills in \"([^\"]*)\", \"([^\"]*)\"and \"([^\"]*)\"$")
public void user_regs(String arg1, String arg2, String arg3) {
registerPage.createAccount(arg1, arg2, arg3);
loginPage.clickSubmitButton();
String res = registerPage.getConfirmation();
Assert.assertEquals("You are now registered.", res);
}
@And("^User fills in existing account$")
public void userFillsInExistingAccount() {
registerPage.createAccount("test_user", "prank@mail.com", "123");
loginPage.clickSubmitButton();
String res = registerPage.getErrorMessage();
Assert.assertEquals("A user with that username already exists.", res);
}
@Then("^User is warned$")
public void userIsWarnedAboutDuplicate() {
Assert.assertTrue(registerPage.checkErrorMsg());
}
@When("^User fills in different passwords$")
public void userFillsInDifferentPasswords() {
registerPage.usernameInput.clear();
registerPage.mailInput.clear();
registerPage.createAccount("new_user", "prank@mail.com", "123");
registerPage.typeConfirmPass("321");
loginPage.clickSubmitButton();
String res = registerPage.getErrorMessage();
Assert.assertEquals("The two password fields didn't match.", res);
}
}
| UTF-8 | Java | 2,331 | java | RegisterSteps.java | Java | [
{
"context": "ngAccount() {\n registerPage.createAccount(\"test_user\", \"prank@mail.com\", \"123\");\n loginPage.cli",
"end": 1507,
"score": 0.9995009303092957,
"start": 1498,
"tag": "USERNAME",
"value": "test_user"
},
{
"context": "\n registerPage.createAccount(\"test_user\", \"prank@mail.com\", \"123\");\n loginPage.clickSubmitButton();\n",
"end": 1525,
"score": 0.9999158978462219,
"start": 1511,
"tag": "EMAIL",
"value": "prank@mail.com"
},
{
"context": "nput.clear();\n registerPage.createAccount(\"new_user\", \"prank@mail.com\", \"123\");\n register",
"end": 2077,
"score": 0.8115096688270569,
"start": 2074,
"tag": "USERNAME",
"value": "new"
},
{
"context": ";\n registerPage.createAccount(\"new_user\", \"prank@mail.com\", \"123\");\n registerPage.typeConfirmPass(\"3",
"end": 2100,
"score": 0.9999200701713562,
"start": 2086,
"tag": "EMAIL",
"value": "prank@mail.com"
},
{
"context": "Page.createAccount(\"new_user\", \"prank@mail.com\", \"123\");\n registerPage.typeConfirmPass(\"321\");\n ",
"end": 2107,
"score": 0.9987645745277405,
"start": 2104,
"tag": "PASSWORD",
"value": "123"
},
{
"context": "m\", \"123\");\n registerPage.typeConfirmPass(\"321\");\n loginPage.clickSubmitButton();\n ",
"end": 2152,
"score": 0.999286949634552,
"start": 2149,
"tag": "PASSWORD",
"value": "321"
}
] | null | [] | package StepDefinition;
import Pages.LoginPage;
import Pages.MainPage;
import Pages.RegisterPage;
import TestContext.TestContext;
import cucumber.api.PendingException;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.junit.Assert;
public class RegisterSteps {
TestContext testContext;
MainPage mainPage;
LoginPage loginPage;
RegisterPage registerPage;
public RegisterSteps(TestContext context) {
testContext = context;
mainPage = testContext.getPageObjectManager().getMainPage();
loginPage = testContext.getPageObjectManager().getLoginPage();
registerPage = testContext.getPageObjectManager().getRegisterPage();
}
@When("^User navigates to RegisterPage$")
public void user_navigates_to_RegisterPage() {
mainPage.clickLoginButton();
loginPage.clickRegisterButton();
String res = registerPage.getHeadingText();
Assert.assertEquals("Register", res);
}
@And("^User fills in \"([^\"]*)\", \"([^\"]*)\"and \"([^\"]*)\"$")
public void user_regs(String arg1, String arg2, String arg3) {
registerPage.createAccount(arg1, arg2, arg3);
loginPage.clickSubmitButton();
String res = registerPage.getConfirmation();
Assert.assertEquals("You are now registered.", res);
}
@And("^User fills in existing account$")
public void userFillsInExistingAccount() {
registerPage.createAccount("test_user", "<EMAIL>", "123");
loginPage.clickSubmitButton();
String res = registerPage.getErrorMessage();
Assert.assertEquals("A user with that username already exists.", res);
}
@Then("^User is warned$")
public void userIsWarnedAboutDuplicate() {
Assert.assertTrue(registerPage.checkErrorMsg());
}
@When("^User fills in different passwords$")
public void userFillsInDifferentPasswords() {
registerPage.usernameInput.clear();
registerPage.mailInput.clear();
registerPage.createAccount("new_user", "<EMAIL>", "123");
registerPage.typeConfirmPass("321");
loginPage.clickSubmitButton();
String res = registerPage.getErrorMessage();
Assert.assertEquals("The two password fields didn't match.", res);
}
}
| 2,317 | 0.682969 | 0.676534 | 66 | 34.31818 | 23.050774 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.772727 | false | false | 11 |
6252ebd09ce3c9878ea39299fb6a4fccc0e9ebe9 | 21,105,469,346,427 | ebb5358188a449728ccac988c84b088f138432bb | /src/homework2/task2/Car.java | db302f3802979f3428058b01ec75aaae9ba9f89f | [] | no_license | MaxParastiuk/EssentialHomeWork | https://github.com/MaxParastiuk/EssentialHomeWork | d7123603a3147f9e4a73be38e0bc347f892a3bd1 | bac18386f56df3bfa855d087242e773b3b5727d2 | refs/heads/master | 2023-04-06T00:02:33.573000 | 2021-04-18T14:10:11 | 2021-04-18T14:10:11 | 350,726,737 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package homework2.task2;
public class Car {
private int age;
private String color;
public Car(int age, String color) {
this.age = age;
this.color = color;
}
public Car(int age) {
this.age = age;
this.color = "black";
}
@Override
public String toString() {
return "Car{" +
"age=" + age +
", color='" + color + '\'' +
'}';
}
}
| UTF-8 | Java | 453 | java | Car.java | Java | [] | null | [] | package homework2.task2;
public class Car {
private int age;
private String color;
public Car(int age, String color) {
this.age = age;
this.color = color;
}
public Car(int age) {
this.age = age;
this.color = "black";
}
@Override
public String toString() {
return "Car{" +
"age=" + age +
", color='" + color + '\'' +
'}';
}
}
| 453 | 0.459161 | 0.454746 | 24 | 17.875 | 12.81377 | 44 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.416667 | false | false | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.