blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
a624e090fdc7373bd4c9b047f7c82343ad7d8092 | 0af8b92686a58eb0b64e319b22411432aca7a8f3 | /api-vs-impl-small/domain/src/main/java/org/gradle/testdomain/performancenull_13/Productionnull_1203.java | a43fd1b9fed44792696b81fc6fd6c9f593e05d9f | [] | no_license | gradle/performance-comparisons | b0d38db37c326e0ce271abebdb3c91769b860799 | e53dc7182fafcf9fedf07920cbbea8b40ee4eef4 | refs/heads/master | 2023-08-14T19:24:39.164276 | 2022-11-24T05:18:33 | 2022-11-24T05:18:33 | 80,121,268 | 17 | 15 | null | 2022-09-30T08:04:35 | 2017-01-26T14:25:33 | null | UTF-8 | Java | false | false | 591 | java | package org.gradle.testdomain.performancenull_13;
public class Productionnull_1203 {
private final String property;
public Productionnull_1203(String param) {
this.property = param;
}
public String getProperty() {
return property;
}
private String prop0;
public String getProp0() {
return prop0;
}
public void setProp0(String value) {
prop0 = value;
}
private String prop1;
public String getProp1() {
return prop1;
}
public void setProp1(String value) {
prop1 = value;
}
}
| [
"[email protected]"
] | |
9644a27c3f713973a6ce2c2bfccd5ecb1ca98e10 | 65db8030e9b836766d453f536392aac4004b5226 | /src/main/java/com/thinkgem/jeesite/modules/prho/web/PrhoProjectInfoController.java | faa8d3ef3b69a93d86eb7d952dc4c3b51446fcc0 | [
"Apache-2.0"
] | permissive | wu-hu/PRHO | e0cc2d0922a2355590be3ea7dc96b89da584291d | ad2130688948261c50c9301bfff5fd5fb5b48d87 | refs/heads/master | 2021-06-23T07:25:31.655240 | 2017-08-18T09:22:49 | 2017-08-18T09:22:49 | 274,884,398 | 0 | 1 | Apache-2.0 | 2020-06-25T10:07:51 | 2020-06-25T10:07:50 | null | UTF-8 | Java | false | false | 7,821 | java | /**
* Copyright © 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.thinkgem.jeesite.modules.prho.web;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.utils.excel.ExportExcel;
import com.thinkgem.jeesite.common.utils.excel.ImportExcel;
import com.thinkgem.jeesite.modules.prho.entity.PrhoProjectInfo;
import com.thinkgem.jeesite.modules.prho.service.PrhoProjectInfoService;
import com.thinkgem.jeesite.modules.prho.service.PrhoProjectTaskService;
/**
* 项目信息Controller
* @author zhl
* @version 2017-05-12
*/
@Controller
@RequestMapping(value = "${adminPath}/prho/prhoProjectInfo")
public class PrhoProjectInfoController extends BaseController {
@Autowired
private PrhoProjectInfoService prhoProjectInfoService;
@Autowired
private PrhoProjectTaskService prhoProjectTaskService;
@ModelAttribute
public PrhoProjectInfo get(@RequestParam(required=false) String id) {
PrhoProjectInfo entity = null;
if (StringUtils.isNotBlank(id)){
entity = prhoProjectInfoService.get(id);
}
if (entity == null){
entity = new PrhoProjectInfo();
}
return entity;
}
@RequiresPermissions("prho:prhoProjectInfo:view")
@RequestMapping(value = {"list", ""})
public String list(PrhoProjectInfo prhoProjectInfo, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<PrhoProjectInfo> page = prhoProjectInfoService.findPageBy(new Page<PrhoProjectInfo>(request, response), prhoProjectInfo);
model.addAttribute("page", page);
return "modules/prho/prhoProjectInfoList";
}
@RequiresPermissions("prho:prhoProjectInfo:view")
@RequestMapping(value = "form")
public String form(PrhoProjectInfo prhoProjectInfo, Model model) {
model.addAttribute("prhoProjectInfo", prhoProjectInfo);
return "modules/prho/prhoProjectInfoForm";
}
@RequiresPermissions("prho:prhoProjectInfo:edit")
@RequestMapping(value = "save")
public String save(PrhoProjectInfo prhoProjectInfo, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, prhoProjectInfo)){
return form(prhoProjectInfo, model);
}
//prhoProjectInfoService.save(prhoProjectInfo);
prhoProjectInfoService.saveNew(prhoProjectInfo);
//添加项目后,在任务中保存公有任务多条(依据工作类型)
addMessage(redirectAttributes, "保存项目信息成功");
return "redirect:"+Global.getAdminPath()+"/prho/prhoProjectInfo/?repage";
}
@RequiresPermissions("prho:prhoProjectInfo:edit")
@RequestMapping(value = "delete")
public String delete(PrhoProjectInfo prhoProjectInfo, RedirectAttributes redirectAttributes) {
prhoProjectInfoService.delete(prhoProjectInfo);
addMessage(redirectAttributes, "删除项目信息成功");
return "redirect:"+Global.getAdminPath()+"/prho/prhoProjectInfo/?repage";
}
@RequiresPermissions("prho:prhoProjectInfo:edit")
@RequestMapping(value = "addStaff")
public String addStuff(PrhoProjectInfo prhoProjectInfo, Model model) {
//添加人员时,项目有人员则回显人员
prhoProjectInfo = prhoProjectInfoService.getStaffFromProject(prhoProjectInfo);
model.addAttribute("prhoProjectInfo", prhoProjectInfo);
return "modules/prho/prhoProjectInfoAddStaff";
}
@RequiresPermissions("prho:prhoProjectInfo:edit")
@RequestMapping(value = "saveProjectByStaff")
public String saveProjectByStaff(PrhoProjectInfo prhoProjectInfo, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, prhoProjectInfo)){
return addStuff(prhoProjectInfo, model);
}
prhoProjectInfoService.saveProjectByStaff(prhoProjectInfo);
addMessage(redirectAttributes, "保存项目所属人员信息成功");
return "redirect:"+Global.getAdminPath()+"/prho/prhoProjectInfo/?repage";
}
@RequiresPermissions("prho:prhoProjectInfo:edit")
@RequestMapping(value="import",method=RequestMethod.POST)
public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
if(Global.isDemoMode()){
addMessage(redirectAttributes, "演示模式,不允许操作!");
return "redirect:"+Global.getAdminPath()+"/prho/prhoProjectInfo/list?repage";
}
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<PrhoProjectInfo> list = ei.getDataList(PrhoProjectInfo.class);
for (PrhoProjectInfo prhoProjectInfo : list){
if(StringUtils.isNotBlank(prhoProjectInfo.getUserId())&&StringUtils.isNotBlank(prhoProjectInfo.getEstimatehours())){
PrhoProjectInfo ppi=prhoProjectInfoService.getProjectManagerId(prhoProjectInfo);
prhoProjectInfo.setUserId(ppi.getUserId());
prhoProjectInfoService.save(prhoProjectInfo);
successNum++;
}else{
failureMsg.append("<br/>项目负责人与预估工时不能为空; ");
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条项目,导入信息如下:");
}
addMessage(redirectAttributes, "已成功导入 "+successNum+" 条项目"+failureMsg);
} catch (Exception e) {
addMessage(redirectAttributes, "导入项目信息失败!失败信息:");//+e.getMessage()
}
return "redirect:"+Global.getAdminPath()+"/prho/prhoProjectInfo/list?repage";
}
/**
* 下载项目信息导入模板
* @param redirectAttributes
* @param prhoProjectInfo
* @return
*/
@RequiresPermissions("prho:prhoProjectInfo:view")
@RequestMapping(value = "import/template")
public String importFileTemplate(HttpServletResponse response,HttpServletRequest request, RedirectAttributes redirectAttributes,PrhoProjectInfo prhoProjectInfo) {
try {
String fileName = "项目信息导入模板.xlsx";
Page<PrhoProjectInfo> page = prhoProjectInfoService.findPageBy(new Page<PrhoProjectInfo>(request, response,-1), prhoProjectInfo);
//List<PrhoProjectInfo> ppiList = Lists.newArrayList();
//ppiList.add(UserUtils.getUser());
new ExportExcel("项目信息", PrhoProjectInfo.class).setDataList(page.getList()).write(response, fileName).dispose();
return null;
} catch (Exception e) {
addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/prho/prhoProjectInfo/list?repage";
}
/**
* 验证项目名称是否有效
*
* @param projectname
* @param oldProjectname
* @return
*/
@ResponseBody
@RequiresPermissions("prho:prhoProjectInfo:edit")
@RequestMapping(value = "checkProjectname")
public String checkProjectname(String oldProjectname, String projectname) {
if (oldProjectname != null && projectname.equals(oldProjectname)) {
return "true";
} else if (projectname != null && prhoProjectInfoService.getByProjectName(projectname) == null) {
return "true";
}
return "false";
}
} | [
"[email protected]"
] | |
2cb62969bb52b369cc14f55a1eed8480fbde9853 | 5571800ac2056601cf5ce212ca0f7d174de44be6 | /myapp/src/com/example/myapp/Project.java | 865b9a302c48ec147389d27af40aefeb3b0ac807 | [] | no_license | aaspradlin/SeniorDesign | 7ff5152b3d963f11b95b59287515709d7a9e9c2b | cd00578eb8aebe50836f9538afbcf81198553c77 | refs/heads/master | 2021-01-23T17:18:42.710914 | 2015-03-16T17:18:35 | 2015-03-16T17:18:35 | 32,340,695 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,696 | java | package com.example.myapp;
/**
* Created by Epicsprads on 11/6/14.
* @author Alexandria Spradlin
*/
public final class Project {
//the number of bytes in the messages written between the Android and the Mega
public static final int MSG_SIZE = 30; //TODO placeholder and do we even need this?
//the four vehicles
public static final Vehicle[] VEH_ARRAY = new Vehicle[]{new Vehicle(), new Vehicle(), new Vehicle(), new Vehicle()};
/* Stores all the sensor objects for the arena
* [0] sensor is the least significant bit in the messages sent by the
* Arduino Mega. */
public static Sensor[] sensorArray;
/* */
public static Block[] blocksArray;
//TODO fill
/* */
public static Sensor
hmm = new Sensor();
/* */
public static Block
SW1A = new Block(),
SW2A = new Block(),
SW3A = new Block(),
SW4A = new Block(),
PTH1A = new Block(),
PTH2A = new Block(),
PTH3A = new Block(),
PTH4A = new Block(),
PTH5A = new Block(),
LD1A = new Block(),
STA1Z = new Block(),
SW1B = new Block(),
SW2B = new Block(),
SW3B = new Block(),
SW4B = new Block(),
LD1B = new Block();
//TODO path B items aren't in yet
//TODO maintenance bay items aren't in yet
/** Populate the Blocks, creating the arena representation. */
private static void populateBlocks() {
//TODO set sensors for each
/* Path A */
SW1A.setProceeding(new Block[]{SW2A, STA1Z, SW2B});
SW1A.setPreceding(new Block[]{PTH5A});
SW2A.setProceeding(new Block[]{LD1A});
SW2A.setPreceding(new Block[]{SW1A});
SW3A.setProceeding(new Block[]{SW4A});
SW3A.setPreceding(new Block[]{LD1A});
SW4A.setProceeding(new Block[]{PTH1A});
SW4A.setPreceding(new Block[]{SW3A, STA1Z, SW3B});
PTH1A.setProceeding(new Block[]{PTH2A});
PTH1A.setPreceding(new Block[]{SW4A});
PTH2A.setProceeding(new Block[]{PTH3A});
PTH2A.setPreceding(new Block[]{PTH1A});
PTH3A.setProceeding(new Block[]{PTH4A});
PTH3A.setPreceding(new Block[]{PTH2A});
PTH4A.setProceeding(new Block[]{PTH5A});
PTH4A.setPreceding(new Block[]{PTH3A});
PTH5A.setProceeding(new Block[]{SW1A});
PTH5A.setPreceding(new Block[]{PTH4A});
LD1A.setProceeding(new Block[]{SW3A});
LD1A.setPreceding(new Block[]{SW2A});
/* Station */
STA1Z.setProceeding(new Block[]{SW4A});
STA1Z.setPreceding(new Block[]{SW1A});
/* Path B */
//TODO path B items aren't in yet
LD1B.setProceeding(new Block[]{SW3B});
LD1B.setPreceding(new Block[]{SW2B});
SW2B.setProceeding(new Block[]{LD1B});
SW2B.setPreceding(new Block[]{SW1B});
SW3B.setProceeding(new Block[]{SW4B});
SW3B.setPreceding(new Block[]{LD1B});
/* Maintenance Bay */
//TODO maintenance bay items aren't in yet
/* Set up array */
blocksArray = new Block[] {}; //TODO fill
}
/** */
private static void populateSensors() {
/* Add to blocks */
//TODO set the prev and next for each sensor
/* Set up array */
sensorArray = new Sensor[] {hmm};
}
/** Called to initialize all arrays and create the relationships
* between sensors and blocks. */
public static void newProject() {
//create the arena representation
//populateBlocks();
//populateSensors();
}
}
| [
"[email protected]"
] | |
8ce01417d55c0ac9ea22945680a160ab08580cb8 | 3feec4354f32ce1ce4cfe696fd572109530ddddb | /app/src/test/java/edu/tacoma/uw/ryandon/starfinderopenreference/model/MembersTest.java | c6ddce2bc9b2a02a95b6e17c7ee729649c3a7449 | [] | no_license | rdonohue/StarfinderOpenReference | 409c040315513954a1204ee12f276a07339a5229 | 76660b95462be6d1ae31ffb97c71a1c92dde212e | refs/heads/master | 2023-01-12T13:15:38.638084 | 2020-11-12T20:37:55 | 2020-11-12T20:37:55 | 277,719,888 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,024 | java | package edu.tacoma.uw.ryandon.starfinderopenreference.model;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class MembersTest {
@Test
public void testMembersFirstNameMatch() {
String tempString = " I am a temporary string@";
Members member = new Members(tempString, tempString, tempString, tempString, tempString);
assertEquals(tempString, member.getmFirstName());
}
@Test
public void testMembersLastNameMatch() {
String tempString = " I am a temporary string@";
Members member = new Members(tempString, tempString, tempString, tempString, tempString);
assertEquals(tempString, member.getmLastName());
}
@Test
public void testMembersEmailMatch() {
String tempString = " I am a temporary string@";
Members member = new Members(tempString, tempString, tempString, tempString, tempString);
assertEquals(tempString, member.getmEmail());
}
@Test
public void testMembersPasswordMatch() {
String tempString = " I am a temporary string@";
Members member = new Members(tempString, tempString, tempString, tempString, tempString);
assertEquals(tempString, member.getmPassword());
}
@Test
public void testMembersUserNameMatch() {
String tempString = " I am a temporary string@";
Members member = new Members(tempString, tempString, tempString, tempString, tempString);
assertEquals(tempString, member.getmUsername());
}
@Test
public void testMembersEmailNull() {
String tempString = " I am a temporary string@";
try {
Members member = new Members(tempString, tempString, null, tempString, tempString);
} catch(NullPointerException e){
}
}
@Test
public void testMembersPasswordNull() {
String tempString = " I am a temporary string@";
try {
Members member = new Members(tempString, tempString, tempString, tempString, null);
} catch(NullPointerException e){
}
}
@Test
public void testMembersEmailLT6() {
String tempString = " I am a temporary string@";
try {
Members member = new Members(tempString, tempString, "asd@1", tempString, tempString);
} catch(IllegalArgumentException e){
}
}
@Test
public void testMembersPassWordLT6() {
String tempString = " I am a temporary string@";
try {
Members member = new Members(tempString, tempString, tempString, tempString, "12345");
} catch(IllegalArgumentException e){
}
}
@Test
public void testMembersEmailContains() {
String tempString = " I am a temporary string@";
try {
Members member = new Members(tempString, tempString, "asd451", tempString, tempString);
} catch(IllegalArgumentException e){
}
}
}
| [
"[email protected]"
] | |
8c48a4a209a7afce43ecfb89992cebbe883a2dd9 | 5b29a9a90e6e1e415bf6a516b30c8e42437ab850 | /security-jwt-service/src/test/java/com/security/jwt/service/SecurityServiceTest.java | 36669e5bc86be79a32275269e75fd6fb083c2bb7 | [] | no_license | doctore/Spring5Microservices | a5ae54bec0b0a1a84744ba5fe74c2c8b0f3964ac | 7e64128e620220210c6833ba9fdab3096d6f8976 | refs/heads/master | 2023-08-16T05:03:11.911433 | 2023-08-13T11:29:05 | 2023-08-13T11:29:05 | 167,799,712 | 58 | 24 | null | 2023-08-19T07:41:21 | 2019-01-27T11:10:48 | Java | UTF-8 | Java | false | false | 12,840 | java | package com.security.jwt.service;
import com.security.jwt.TestDataFactory;
import com.security.jwt.application.spring5microservices.service.UserService;
import com.security.jwt.exception.ClientNotFoundException;
import com.spring5microservices.common.dto.AuthenticationInformationDto;
import com.spring5microservices.common.dto.UsernameAuthoritiesDto;
import com.spring5microservices.common.exception.UnauthorizedException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Mock;
import org.springframework.context.ApplicationContext;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
import static com.security.jwt.enums.TokenKeyEnum.NAME;
import static java.util.Arrays.asList;
import static com.security.jwt.enums.AuthenticationConfigurationEnum.SPRING5_MICROSERVICES;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static java.util.Optional.ofNullable;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ExtendWith(SpringExtension.class)
public class SecurityServiceTest {
@Mock
private ApplicationContext mockApplicationContext;
@Mock
private AuthenticationService mockAuthenticationService;
private SecurityService securityService;
@BeforeEach
public void init() {
securityService = new SecurityService(mockApplicationContext, mockAuthenticationService);
}
static Stream<Arguments> loginTestCases() {
String clientId = SPRING5_MICROSERVICES.getClientId();
String username = "username value";
UserDetails userDetails = TestDataFactory.buildDefaultUser();
String password = userDetails.getPassword();
UserService userService = mock(UserService.class);
Optional<AuthenticationInformationDto> authenticationInformation = of(TestDataFactory.buildDefaultAuthenticationInformation());
return Stream.of(
//@formatter:off
// clientId, username, password, userService, userDetails, passwordsMatch, expectedException, authenticationInformation, expectedResult
Arguments.of( null, null, null, null, null, false, ClientNotFoundException.class, null, null ),
Arguments.of( "NotFound", null, null, null, null, false, ClientNotFoundException.class, null, null ),
Arguments.of( clientId, null, null, userService, null, false, UsernameNotFoundException.class, null, null ),
Arguments.of( clientId, username, null, userService, userDetails, false, UnauthorizedException.class, null, null ),
Arguments.of( clientId, username, password, userService, userDetails, true, null, empty(), empty() ),
Arguments.of( clientId, username, password, userService, userDetails, true, null, authenticationInformation, authenticationInformation )
); //@formatter:on
}
@ParameterizedTest
@MethodSource("loginTestCases")
@DisplayName("login: test cases")
public void login_testCases(String clientId,
String username,
String password,
UserService userService,
UserDetails userDetails,
boolean passwordsMatch,
Class<? extends Exception> expectedException,
Optional<AuthenticationInformationDto> authenticationInformation,
Optional<AuthenticationInformationDto> expectedResult) {
when(mockApplicationContext.getBean(UserService.class)).thenReturn(userService);
when(mockAuthenticationService.getAuthenticationInformation(clientId, userDetails)).thenReturn(authenticationInformation);
if (null != userService) {
if (null == username) {
when(userService.loadUserByUsername(username)).thenThrow(UsernameNotFoundException.class);
}
else {
when(userService.loadUserByUsername(username)).thenReturn(userDetails);
}
when(userService.passwordsMatch(anyString(), eq(userDetails))).thenReturn(passwordsMatch);
}
if (null != expectedException) {
assertThrows(expectedException, () -> securityService.login(clientId, username, password));
}
else {
Optional<AuthenticationInformationDto> result = securityService.login(clientId, username, password);
assertEquals(expectedResult, result);
}
}
static Stream<Arguments> refreshTestCases() {
String clientId = SPRING5_MICROSERVICES.getClientId();
String username = "username value";
UserService userService = mock(UserService.class);
Optional<AuthenticationInformationDto> authenticationInformation = of(TestDataFactory.buildDefaultAuthenticationInformation());
return Stream.of(
//@formatter:off
// refreshToken, clientId, usernameResult, userService, expectedException, authenticationInformation, expectedResult
Arguments.of( null, null, null, null, UsernameNotFoundException.class, null, null ),
Arguments.of( null, "NotFound", null, null, UsernameNotFoundException.class, null, null ),
Arguments.of( null, clientId, null, null, UsernameNotFoundException.class, null, null ),
Arguments.of( "ItDoesNotCare", null, username, null, ClientNotFoundException.class, null, null ),
Arguments.of( "ItDoesNotCare", "NotFound", username, null, ClientNotFoundException.class, null, null ),
Arguments.of( "ItDoesNotCare", clientId, username, null, null, empty(), empty() ),
Arguments.of( "ItDoesNotCare", clientId, username, userService, null, empty(), empty() ),
Arguments.of( "ItDoesNotCare", clientId, username, userService, null, authenticationInformation, authenticationInformation )
); //@formatter:on
}
@ParameterizedTest
@MethodSource("refreshTestCases")
@DisplayName("refresh: test cases")
public void refresh_testCases(String refreshToken,
String clientId,
String usernameResult,
UserService userService,
Class<? extends Exception> expectedException,
Optional<AuthenticationInformationDto> authenticationInformation,
Optional<AuthenticationInformationDto> expectedResult) {
UserDetails userDetails = TestDataFactory.buildDefaultUser();
Map<String, Object> payload = new HashMap<>();
when(mockAuthenticationService.getPayloadOfToken(refreshToken, clientId, false)).thenReturn(payload);
when(mockAuthenticationService.getUsername(payload, clientId)).thenReturn(ofNullable(usernameResult));
when(mockAuthenticationService.getAuthenticationInformation(clientId, userDetails)).thenReturn(authenticationInformation);
when(mockApplicationContext.getBean(UserService.class)).thenReturn(userService);
if (null != userService) {
if (null == usernameResult) {
when(userService.loadUserByUsername(usernameResult)).thenThrow(UsernameNotFoundException.class);
}
else {
when(userService.loadUserByUsername(usernameResult)).thenReturn(userDetails);
}
}
if (null != expectedException) {
assertThrows(expectedException, () -> securityService.refresh(refreshToken, clientId));
}
else {
Optional<AuthenticationInformationDto> result = securityService.refresh(refreshToken, clientId);
assertEquals(expectedResult, result);
}
}
static Stream<Arguments> getAuthorizationInformationTestCases() {
String clientId = SPRING5_MICROSERVICES.getClientId();
String usernameResult = "username value";
Set<String> rolesResult = new HashSet<>(asList("admin", "user"));
Map<String, Object> additionalInfoResult = new HashMap<String, Object>() {{
put(NAME.getKey(), "name value");
}};
UsernameAuthoritiesDto usernameAuthorities = TestDataFactory.buildUsernameAuthorities(usernameResult, rolesResult, additionalInfoResult);
return Stream.of(
//@formatter:off
// accessToken, clientId, usernameResult, rolesResult, additionalInfoResult, expectedException, expectedResult
Arguments.of( null, null, null, null, null, UsernameNotFoundException.class, null ),
Arguments.of( null, "NotFound", null, null, null, UsernameNotFoundException.class, null ),
Arguments.of( null, clientId, null, null, null, UsernameNotFoundException.class, null ),
Arguments.of( "ItDoesNotCare", clientId, null, null, null, UsernameNotFoundException.class, null ),
Arguments.of( "ItDoesNotCare", clientId, usernameResult, rolesResult, additionalInfoResult, null, usernameAuthorities )
); //@formatter:on
}
@ParameterizedTest
@MethodSource("getAuthorizationInformationTestCases")
@DisplayName("getAuthorizationInformation: test cases")
public void getAuthorizationInformation_testCases(String accessToken,
String clientId,
String usernameResult,
Set<String> rolesResult,
Map<String, Object> additionalInfoResult,
Class<? extends Exception> expectedException,
UsernameAuthoritiesDto expectedResult) {
Map<String, Object> payload = new HashMap<>();
when(mockAuthenticationService.getPayloadOfToken(accessToken, clientId, true)).thenReturn(payload);
when(mockAuthenticationService.getUsername(payload, clientId)).thenReturn(ofNullable(usernameResult));
when(mockAuthenticationService.getRoles(payload, clientId)).thenReturn(rolesResult);
when(mockAuthenticationService.getCustomInformationIncludedByClient(payload, clientId)).thenReturn(additionalInfoResult);
if (null != expectedException) {
assertThrows(expectedException, () -> securityService.getAuthorizationInformation(accessToken, clientId));
}
else {
UsernameAuthoritiesDto result = securityService.getAuthorizationInformation(accessToken, clientId);
assertEquals(expectedResult, result);
}
}
}
| [
"[email protected]"
] | |
ef236122fe7515bb0961ea866f9615dd651cbd32 | e5a550d794803d7b863b5ec64ef39fa5573cc69b | /src/test/java/fr/ccavalier/soatchallenge/security/SecurityUtilsUnitTest.java | c0ac03e11ad5001cccb86decfc7fc63bba776aa8 | [] | no_license | CCavalier/SoatCodingChallenge | 28f26b108cda20c35aa9ba5cb75367a5922ebd00 | 3a3c6c4575598cd2a249aa788748447560d64f94 | refs/heads/master | 2021-05-03T20:38:37.770426 | 2016-10-24T12:30:20 | 2016-10-24T12:30:20 | 71,400,662 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,103 | java | package fr.ccavalier.soatchallenge.security;
import org.junit.Test;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import java.util.ArrayList;
import java.util.Collection;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Test class for the SecurityUtils utility class.
*
* @see SecurityUtils
*/
public class SecurityUtilsUnitTest {
@Test
public void testgetCurrentUserLogin() {
SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
securityContext.setAuthentication(new UsernamePasswordAuthenticationToken("admin", "admin"));
SecurityContextHolder.setContext(securityContext);
String login = SecurityUtils.getCurrentUserLogin();
assertThat(login).isEqualTo("admin");
}
@Test
public void testIsAuthenticated() {
SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
securityContext.setAuthentication(new UsernamePasswordAuthenticationToken("admin", "admin"));
SecurityContextHolder.setContext(securityContext);
boolean isAuthenticated = SecurityUtils.isAuthenticated();
assertThat(isAuthenticated).isTrue();
}
@Test
public void testAnonymousIsNotAuthenticated() {
SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
Collection<GrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority(AuthoritiesConstants.ANONYMOUS));
securityContext.setAuthentication(new UsernamePasswordAuthenticationToken("anonymous", "anonymous", authorities));
SecurityContextHolder.setContext(securityContext);
boolean isAuthenticated = SecurityUtils.isAuthenticated();
assertThat(isAuthenticated).isFalse();
}
}
| [
"[email protected]"
] | |
84aee5dfe810554a5a466a11a1a39d48e8eeffcc | 04e23824506684a769ade590c5f9ceb0427b1dc8 | /springkafka/src/main/java/com/yyh/Application.java | f8873241efdb89c984e013b761d11dad3dd336ef | [] | no_license | limonpermanent/limon001 | c5177b5757119784eb7139e24ccef17afcbf9f21 | e587c83156dfd02c181d5a660db50e7595d4cffe | refs/heads/master | 2022-06-26T06:47:15.378495 | 2019-06-24T10:43:52 | 2019-06-24T10:43:52 | 192,832,980 | 0 | 0 | null | 2022-06-21T01:20:17 | 2019-06-20T02:15:47 | Java | UTF-8 | Java | false | false | 456 | java | package com.yyh;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application{
public static Logger logger = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
| [
"[email protected]"
] | |
81decbcaee0b9f9ec97eb782f3d020f699339b68 | 1773cd478ca9d6e3c351d8cc9a688a9a81e00e3e | /src/localpack1/PrivateDemo2.java | c35ee3f56a2991d7bb56888ed6c6bdfb4939a64f | [] | no_license | Vmuralidhar/SeleniumSampleProject | 33ac5bcd4e907c05027ea530034dfabc7bc8b413 | 00a2ec42d21f767263bc5600b9d604f2f174e504 | refs/heads/master | 2021-05-20T01:38:16.278839 | 2020-04-01T09:33:18 | 2020-04-01T09:33:18 | 252,131,321 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 347 | java | package localpack1;
public class PrivateDemo2 {
private PrivateDemo2()
{
System.out.println("cons of PrivateDemo2");
}
void funB()
{
System.out.println("funB method of PrivateDemo2");
}
static void funA()
{
System.out.println("static funB method of PrivateDemo2");
PrivateDemo2 p2= new PrivateDemo2();
p2.funB();
}
}
| [
"[email protected]"
] | |
06412eedc109ff2e5f4e47825e389bceeb8e6047 | dc1dbb7e5a4b95bf44170d2f51fd08b3814f2ac9 | /data_defect4j/preprossed_method_corpus/Math/14/org/apache/commons/math3/optim/nonlinear/vector/MultivariateVectorOptimizer_parseOptimizationData_133.java | d5f54dd04d884d71e0d615318914c4b0b0a42487 | [] | no_license | hvdthong/NetML | dca6cf4d34c5799b400d718e0a6cd2e0b167297d | 9bb103da21327912e5a29cbf9be9ff4d058731a5 | refs/heads/master | 2021-06-30T15:03:52.618255 | 2020-10-07T01:58:48 | 2020-10-07T01:58:48 | 150,383,588 | 1 | 1 | null | 2018-09-26T07:08:45 | 2018-09-26T07:08:44 | null | UTF-8 | Java | false | false | 834 | java |
org apach common math3 optim nonlinear vector
base multivari vector function optim
version
multivari vector optim multivariatevectoroptim
scan list requir option optim data
character problem
param opt data optdata optim data data look
link target
link weight
link model function modelfunct
pars optim data parseoptimizationdata optim data optimizationdata opt data optdata
exist valu set previou call reus
provid argument list
optim data optimizationdata data opt data optdata
data model function modelfunct
model model function modelfunct data model function getmodelfunct
data target
target target data target gettarget
data weight
weight matrix weightmatrix weight data weight getweight
| [
"[email protected]"
] | |
c9abcccc33120637377a98761c551af49e054cbb | 8b0afbac2efdb7da5afd6c2987c9c53a45fc3bfa | /src/main/java/hu/bubi/chef/service/impl/ReceptServiceImpl.java | 7f6270021922f2ecf464b80eb841573b96d57c59 | [] | no_license | zol1e/bubichef | 7580edaef545fa11848252899b654dbb3750837b | 8fb7c8145232c5660bc529f2061ac435c70542f2 | refs/heads/master | 2022-07-22T18:53:53.905657 | 2021-04-24T10:13:18 | 2021-04-24T10:13:18 | 158,602,781 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,536 | java | package hu.bubi.chef.service.impl;
import hu.bubi.chef.service.ReceptService;
import hu.bubi.chef.service.ReceptToOsszetevoService;
import hu.bubi.chef.domain.Recept;
import hu.bubi.chef.domain.ReceptToOsszetevo;
import hu.bubi.chef.repository.ReceptRepository;
import hu.bubi.chef.service.dto.ReceptDTO;
import hu.bubi.chef.service.dto.ReceptToOsszetevoDTO;
import hu.bubi.chef.service.mapper.ReceptMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Service Implementation for managing Recept.
*/
@Service
@Transactional
public class ReceptServiceImpl implements ReceptService {
private final Logger log = LoggerFactory.getLogger(ReceptServiceImpl.class);
private final ReceptRepository receptRepository;
private final ReceptMapper receptMapper;
@Autowired
private ReceptToOsszetevoService receptToOsszetevoService;
public ReceptServiceImpl(ReceptRepository receptRepository, ReceptMapper receptMapper) {
this.receptRepository = receptRepository;
this.receptMapper = receptMapper;
}
/**
* Save a recept.
*
* @param receptDTO the entity to save
* @return the persisted entity
*/
@Override
public ReceptDTO save(ReceptDTO receptDTO) {
log.debug("Request to save Recept : {}", receptDTO);
List<Long> mappingsToDelete = new ArrayList<Long>();
if(receptDTO.getId() != null) {
Optional<Recept> old = receptRepository.findById(receptDTO.getId());
if(old.isPresent()) {
for(ReceptToOsszetevo mapping : old.get().getOsszetevoks()) {
mappingsToDelete.add(mapping.getId());
}
}
}
Recept recept = receptMapper.toEntity(receptDTO);
recept = receptRepository.save(recept);
for(ReceptToOsszetevo r2o :receptDTO.getOsszetevoks()) {
Optional<ReceptToOsszetevoDTO> existing = null;
ReceptToOsszetevoDTO receptToOsszetevoDTO = null;
if(r2o.getId() != null) {
existing = receptToOsszetevoService.findOne(r2o.getId());
if(existing.isPresent()) {
receptToOsszetevoDTO = existing.get();
}
}
if(receptToOsszetevoDTO == null) {
receptToOsszetevoDTO = new ReceptToOsszetevoDTO();
}
receptToOsszetevoDTO.setMegjegyzes(r2o.getMegjegyzes());
if(r2o.getOsszetevo() != null && r2o.getOsszetevo().getId() != null) {
receptToOsszetevoDTO.setOsszetevoId(r2o.getOsszetevo().getId());
}
receptToOsszetevoDTO.setReceptId(recept.getId());
receptToOsszetevoDTO.setMennyiseg(r2o.getMennyiseg());
receptToOsszetevoService.save(receptToOsszetevoDTO);
mappingsToDelete.remove(receptToOsszetevoDTO.getId());
}
for(Long id : mappingsToDelete) {
receptToOsszetevoService.delete(id);
}
return receptMapper.toDto(recept);
}
/**
* Get all the recepts.
*
* @return the list of entities
*/
@Override
@Transactional(readOnly = true)
public List<ReceptDTO> findAll() {
log.debug("Request to get all Recepts");
return receptRepository.findAllWithEagerRelationships().stream()
.map(receptMapper::toDto)
.collect(Collectors.toCollection(LinkedList::new));
}
/**
* Get all the Recept with eager load of many-to-many relationships.
*
* @return the list of entities
*/
public Page<ReceptDTO> findAllWithEagerRelationships(Pageable pageable) {
return receptRepository.findAllWithEagerRelationships(pageable).map(receptMapper::toDto);
}
/**
* Get one recept by id.
*
* @param id the id of the entity
* @return the entity
*/
@Override
@Transactional(readOnly = true)
public Optional<ReceptDTO> findOne(Long id) {
log.debug("Request to get Recept : {}", id);
Optional<Recept> findById = receptRepository.findById(id);
Optional<ReceptDTO> map = findById.map(receptMapper::toDto);
if(map.get() != null && findById.get() != null && findById.get().getKategoria() != null) {
map.get().setKategoriaNev(findById.get().getKategoria().getNev());
}
return map;
//return receptRepository.findOneWithEagerRelationships(id)
// .map(receptMapper::toDto);
}
/**
* Delete the recept by id.
*
* @param id the id of the entity
*/
@Override
public void delete(Long id) {
log.debug("Request to delete Recept : {}", id);
Optional<ReceptDTO> recept = this.findOne(id);
if(recept.isPresent()) {
Set<ReceptToOsszetevo> osszetevoks = recept.get().getOsszetevoks();
for(ReceptToOsszetevo osszetevo : osszetevoks) {
receptToOsszetevoService.delete(osszetevo.getId());
}
}
receptRepository.deleteById(id);
}
}
| [
"[email protected]"
] | |
b0ce59f1ccbc3d36789786eb9d17e370470ba2e6 | fd7160a1023edf3be753558d8a0ec7cbf218cf22 | /src/ConnectionBaseDonn/connect.java | 803c02f96a019d8187b676b069c1af7de6fb9fe3 | [] | no_license | afefbaccouche/pijavaFx | e9da2b3f872d9a2be9bad2b8dae55ae812f3cd68 | eaf2a67e06ea631644303c6393f10a9a614b5456 | refs/heads/main | 2023-03-28T07:05:12.482274 | 2021-03-16T23:35:29 | 2021-03-16T23:35:29 | 348,521,731 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,228 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ConnectionBaseDonn;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author amani
*/
public class connect {
private String url = "jdbc:mysql://127.0.0.1:3306/codebreakers_integration";
private String login = "root";
private String password = "";
private java.sql.Connection cnx;
private static connect instance;
private connect() {
try {
cnx = DriverManager.getConnection(url, login, password);
System.out.println("Connexion etablie");
} catch (SQLException ex) {
Logger.getLogger(connect.class.getName()).log(Level.ALL.SEVERE, null, ex);
}
}
public static connect getInstance() {
if (instance == null) {
instance = new connect();
}
return instance;
}
public java.sql.Connection getCnx() {
return cnx;
}
public void setCnx(java.sql.Connection cnx) {
this.cnx = cnx;
}
}
| [
"[email protected]"
] | |
2697486d37c8ebb1ddc9c973875e077d23cbfbf6 | df14f5850ff7ad5f1807927b2ab9ff84dff7b5ee | /src/main/java/com/example/study_SpringConfig/Config/DBConfiguration.java | 1bfe8cca7988a28d5c3dc6ddaa0326759c77d0d9 | [] | no_license | Samuel-Ricardo/SpringBoot_Configuration | 688a6394bb3faee1ed3da8c1e3081ffc18776a04 | 754c2247a0690cfa2ab5a07df752f10ae6759161 | refs/heads/master | 2023-06-12T02:22:11.229944 | 2021-07-03T21:04:56 | 2021-07-03T21:04:56 | 382,678,581 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,383 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.example.study_SpringConfig.Config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
/**
*
* @author Samuel
*/
@Configuration
@ConfigurationProperties("spring.datasource")
@Getter
@Setter
public class DBConfiguration {
private String driverClassName;
private String url;
private String username;
private String password;
@Profile("dev")
@Bean
public String testDatabaseConnection() {
System.out.println("DB Connection for DEV - H2");
System.out.println(driverClassName);
System.out.println(url);
return "DB Connection to H2_TEST - Test instance";
}
@Profile("prod")
@Bean
public String productionDatabaseConnection() {
System.out.println("DB Connection for PRODUCTION - MYSQL");
System.out.println(driverClassName);
System.out.println(url);
return "DB Connection to MYSQL_PROD - Production instance";
}
}
| [
"[email protected]"
] | |
6b8ef6d9f835626a8f9b2e135ac8578132651a5d | 061abf01a16b02d6834a9f575e9b121748bd1444 | /exemplo-app-web/src/main/java/ServletListener.java | 3579dd57bcde38c3235f7969e0fe06d9d1b0352b | [] | no_license | danielalveslima36/pweb1 | db703331d5a09a3ff08759037d092480490996c7 | 945832c11c13eee7646a8062853a25f83ebb671c | refs/heads/master | 2020-05-24T18:50:39.299642 | 2019-05-24T02:36:19 | 2019-05-24T02:36:19 | 187,418,135 | 0 | 0 | null | 2019-05-19T00:36:54 | 2019-05-19T00:36:54 | null | UTF-8 | Java | false | false | 394 | java | import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class ServletListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
ServletContext sc = event.getServletContext();
Integer i = new Integer(0);
sc.setAttribute("totalReq", i);
}
}
| [
"danielalveslima36"
] | danielalveslima36 |
02adda3a78cb99ffacd640cfccad66c2001f4b55 | 561474aab8e1d46734e001b42e02dbc8ca25a1d0 | /phong-music-online --username [email protected]/MusicOnline/src/huu/phong/musiconline/sites/Site.java | e1fa51a1c0b6312594792353827551ebb878c625 | [] | no_license | hungzombxd/phong-music-online | fe028760bf83f7fa25a66b3b1ca20ab4baf73c1e | 6432dc7894b4e8513c9bac7e0fd7ade193d1d4b0 | refs/heads/master | 2016-08-10T23:06:01.114481 | 2014-02-23T08:43:43 | 2014-02-23T08:43:43 | 45,052,314 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,291 | java | package huu.phong.musiconline.sites;
import static huu.phong.musiconline.sites.MusicSite.DEFAULT_AGENT;
import static huu.phong.musiconline.sites.NhacCuaTui.NHACCUATUI_USER_AGENT;
import static huu.phong.musiconline.sites.Zing.ZING_USER_AGENT;
import static huu.phong.musiconline.sites.Zing.ZING_SONG_USER_AGENT;
public enum Site {
MP3_ZING_VN ("mp3.zing.vn", ZING_USER_AGENT, ZING_SONG_USER_AGENT),
NHAC_CUA_TUI ("nhaccuatui.com", NHACCUATUI_USER_AGENT, NHACCUATUI_USER_AGENT),
CHIA_SE_NHAC ("chiasenhac.com", DEFAULT_AGENT, DEFAULT_AGENT),
RADIO_VNMEDIA_VN ("radio.vnmedia.vn", DEFAULT_AGENT, DEFAULT_AGENT),
MY_COMPUTER ("My Computer", DEFAULT_AGENT, DEFAULT_AGENT),
INTERNET_URL ("Internet File", DEFAULT_AGENT, DEFAULT_AGENT);
private final String host;
private final String defaultAgent;
private final String songAgent;
private Site(String host, String defaultAgent, String songAgent){
this.host = host;
this.defaultAgent = defaultAgent;
this.songAgent = songAgent;
}
public String getHost(){
return host;
}
public String getFullHost(){
return String.format("http://%s", host);
}
public String getDefaultAgent(){
return defaultAgent;
}
public String getSongAgent(){
return songAgent;
}
}
| [
"[email protected]"
] | |
8893312912107f57933d147762cf7b7f28817b35 | dc5083abcf238026ec30e63134470c5bbd4465b5 | /app/src/main/java/com/example/n01170333/layout/Patient4.java | c2b1a42577a0c2127190ee5a3267336bbb6684d3 | [] | no_license | rulaone/layout-master | b336efcd03f72f730e4d01bd5bfaec0679ce9dc3 | b75357f641237d8b4822e6b3ce11df4fe4a88fd9 | refs/heads/master | 2020-03-31T10:46:39.203540 | 2018-10-08T21:30:31 | 2018-10-08T21:30:31 | 152,149,161 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 566 | java | package com.example.n01170333.layout;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Patient4 extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_patient4, container,false);
}
}
| [
"[email protected]"
] | |
9ae6a783ac1697983312117c2075d61f382021e8 | c74f91fa425ace8f20d3894b85a7bbe9b4c66310 | /HeadFirstAndroid/chapter14/CatChat/app/src/main/java/by/yakivan/catchat/activities/FeedbackActivity.java | 1319bc5c743bd287891218553987e26a37257c7a | [] | no_license | mutkan/Android-Courses | 7a3edc3cd73b440e591414cd52a3a52331affd58 | 4d6180c1b154470c2b68ed516319e16efc1925de | refs/heads/master | 2020-12-09T00:41:07.908181 | 2019-07-26T15:13:34 | 2019-07-26T15:13:34 | 233,140,202 | 1 | 0 | null | 2020-01-10T22:22:46 | 2020-01-10T22:22:45 | null | UTF-8 | Java | false | false | 515 | java | package by.yakivan.catchat.activities;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import by.yakivan.catchat.R;
public class FeedbackActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_feedback);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
}
| [
"[email protected]"
] | |
02efcd136f96a3198fe2ab5f164599ee4a6d59b9 | 7178a1390a38efbce6cd61e55bdc9d1d2cd9ecbf | /Examination/src/deus/Cache.java | 6c3819e5cf46f153195154f9d163c6dabcf656da | [] | no_license | massarfusion/EclipseBackUp2020 | ac91acbc25e660d2877b0a1d7f797466328705a9 | 703d95d274c7097193eccb87ddc2dbbe3e9ee56a | refs/heads/master | 2023-01-19T04:51:23.927085 | 2020-12-04T00:17:06 | 2020-12-04T00:17:06 | 313,882,611 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 39 | java | package deus;
public class Cache {
}
| [
"[email protected]"
] | |
83f6a5827d94eab085e5d8450d4f9d78bf4e7420 | d76c7218a4218e59ca4bbc2d4d06cd04c9bdfb40 | /week-01/day-04/src/VariableMutation.java | b14178c62d4b15113f5a151316ec9da9a805f57e | [] | no_license | green-fox-academy/agipetho | d07261235431f663ff372e3233b2ff1376ad4933 | 37d0047bddd4468ccebcc4110ec769891d1ef6e5 | refs/heads/master | 2021-02-07T12:48:34.669693 | 2020-07-12T18:02:22 | 2020-07-12T18:02:22 | 244,027,666 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 704 | java | public class VariableMutation {
public static void main(String[] args) {
int a = 3;
a += 10;
System.out.println(a);
int e = 8;
e = e * e * e;
System.out.println(e);
int f1 = 123;
int f2 = 345;
boolean isf1biggerthanf2 = f1 > f2;
System.out.println(isf1biggerthanf2);
int h = 135798745;
int divisor = 11;
boolean divide11 = (h % divisor) == 0;
System.out.println(divide11);
int i1 = 10;
int i2 = 3;
boolean isItHigherSmaller = (i2 * i2 < i1 && i1 < i2 * i2 * i2);
System.out.println(isItHigherSmaller);
int j = 1521;
boolean isDividable = ((j % 3) == 0) || ((j % 5) == 0);
System.out.println(isDividable);
}
}
| [
"[email protected]"
] | |
611c7ea5e731ad6570c029fb743b64bf241ad158 | 909105e17b78dfbbda61bf8842161bf14ae925bb | /BasicCoreJava/src/functions/AccessModifiers.java | 8b764528db346362c66158bbe08d063fb08f96eb | [] | no_license | anandbhayre2007/Automation28102020 | 0154358447d50079043b8b75aa1659566b9a2923 | f3ec69d497db2d0fb6484a6ab14dd7e39e1f3776 | refs/heads/master | 2023-01-08T09:08:17.462258 | 2020-11-11T04:31:10 | 2020-11-11T04:31:10 | 308,215,998 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 665 | java | package functions;
public class AccessModifiers {
public static void main(String[] args) {
AccessModifiers obj= new AccessModifiers();
obj.privateFunction();
obj.publicFunction();
obj.protectedFunction();
obj.noAccessModifiers();
}
public void publicFunction()
{
System.out.println("Public function");
}
private void privateFunction()
{
System.out.println("Private function");
}
void noAccessModifiers()
{
System.out.println("No Access Modifiers");
}
//Protected members can be accessed through out the project by using child class
protected void protectedFunction()
{
System.out.println("Protected function");
}
}
| [
"[email protected]"
] | |
a763a6fabefb58627490d2c328b145464e8d14ec | c74dc141aa307165d0813221086761f960fcf004 | /src/aulas_praticas/aula11_01/SortInsert.java | 01e7c9ec223e72562ee2b00088b976b321346bc0 | [] | no_license | castroferreira/PDS | 49b8ecc8c0c231002266fd4ac829673406bbe537 | 9b045ac2d7a2ac9f9344a5efa8b6cc05ddfe5f2a | refs/heads/master | 2020-12-19T03:45:33.585976 | 2020-01-22T16:22:56 | 2020-01-22T16:22:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 750 | java | package aulas_praticas.aula11_01;
import java.util.Comparator;
import java.util.List;
/**
* PDS 2017/2018 G29
*
* @author Andreia Ferreira
* @author Rui Serrano
*/
public class SortInsert implements SortStrategy {
@Override
public List<Telemovel> sort(List<Telemovel> listaTelemoveis, Comparator<Telemovel> comparator) {
for (int i = 1; i < listaTelemoveis.size(); i++) {
for (int j = i; j > 0; j--) {
if (comparator.compare(listaTelemoveis.get(j), listaTelemoveis.get(j - 1)) < 0) {
Telemovel tmp = listaTelemoveis.get(j);
listaTelemoveis.set(j, listaTelemoveis.get(j - 1));
}
}
}
return listaTelemoveis;
}
}
| [
"[email protected]"
] | |
fc6e7778d4a6cff67a6e550b269e5208c5cc8a2a | 09848da1eeef52cf7945aef7318b9d57510ad54a | /src/main/java/com/gopivotal/bookshop/domain/BookOrderItem.java | b2ecce09bb2c7e9072f68c134de11c59c7553c2d | [] | no_license | amitchrs8/Gemfire | 1dacf2c69216043649a4dbf5e798b4c478e90523 | 8234d1c9ad93895c87eae3e680861f8b1ad6e50c | refs/heads/master | 2020-06-17T11:17:48.901934 | 2019-07-09T01:11:38 | 2019-07-09T01:11:38 | 195,908,305 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,277 | java | package com.gopivotal.bookshop.domain;
import java.io.Serializable;
public class BookOrderItem implements Serializable
{
private static final long serialVersionUID = 7526471155622776147L;
private int orderLine;
private Integer itemNumber;
private float quantity;
private float discount;
public BookOrderItem() {}
public BookOrderItem(int orderLine, Integer itemNumber, float quantity,
float discount)
{
super();
this.orderLine = orderLine;
this.itemNumber = itemNumber;
this.quantity = quantity;
this.discount = discount;
}
public int getOrderLine()
{
return orderLine;
}
public void setOrderLine(int orderLine)
{
this.orderLine = orderLine;
}
public Integer getItemNumber()
{
return itemNumber;
}
public void setItemNumber(Integer itemNumber)
{
this.itemNumber = itemNumber;
}
public float getQuantity()
{
return quantity;
}
public void setQuantity(float quantity)
{
this.quantity = quantity;
}
public float getDiscount()
{
return discount;
}
public void setDiscount(float discount)
{
this.discount = discount;
}
@Override
public String toString()
{
return "BookOrderItem [orderLine=" + orderLine + ", itemNumber="
+ itemNumber + ", quantity=" + quantity + ", discount="
+ discount + "]";
}
}
| [
"[email protected]"
] | |
061ca4f62e36aaa7882d22249df6b40533272a02 | a02785a019da770d9138a901a3314e411c188596 | /src/main/java/com/devng/template/springboot/TestData.java | 60263f578ed00dcfed4e4e49566a46cc15718ee0 | [
"MIT"
] | permissive | boskydev/CUB | 92336bb41965d7963f73b4fd85d052973bc291b5 | c9ca6bd6151c3301cc9d3390cda4ab7e39326960 | refs/heads/master | 2020-03-09T13:46:06.934824 | 2018-04-09T20:33:51 | 2018-04-09T20:33:51 | 128,819,028 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,724 | java | package com.devng.template.springboot;
import java.text.ParseException;
import javax.annotation.PostConstruct;
import org.apache.commons.lang.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.devng.template.springboot.jpa.domain.User;
import com.devng.template.springboot.service.UserService;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public class TestData {
private static final Logger log = LoggerFactory.getLogger(TestData.class);
@Autowired
private UserService userService;
@PostConstruct
public void insertTestData() {
insertTestUsers();
}
private void insertTestUsers() {
log.debug("Inserting test users");
if (userService.findByEmail("[email protected]") == null) {
User testUser1 = new User();
testUser1.setEmail("[email protected]");
testUser1.setFirstName("Max");
testUser1.setLastName("Power");
try {
testUser1.setBirthday(DateUtils.parseDate("12/12/1980", new String[] { "dd/MM/yyyy" }));
} catch (ParseException e) {
// ignoring
}
userService.saveUser(testUser1);
}
if (userService.findByEmail("[email protected]") == null) {
User testUser2 = new User();
testUser2.setEmail("[email protected]");
testUser2.setFirstName("Bhaskar");
testUser2.setLastName("Bond");
try {
testUser2.setBirthday(DateUtils.parseDate("12/12/1985", new String[] { "dd/MM/yyyy" }));
} catch (ParseException e) {
// ignoring
}
userService.saveUser(testUser2);
}
}
}
| [
"[email protected]"
] | |
3217114b293bd16246d8f9d3b12d38e7788aa92e | 8ac221ecb5fe1b58f06e1bd0320396c37f35c65e | /src/main/java/com/bookstore/service/impl/UserServiceImpl.java | 0884ce9df9f84983b867be23bf27b247294275bf | [
"Apache-2.0"
] | permissive | bariscanakdag/BookStore | 562f335c96d5c442fb9af8df16a41908ee7d9936 | fbc1e31b1001722411c751f5675c1f8626046f1f | refs/heads/master | 2022-12-21T23:15:12.037028 | 2019-07-07T18:53:05 | 2019-07-07T18:53:05 | 184,822,407 | 2 | 0 | Apache-2.0 | 2022-12-15T23:24:28 | 2019-05-03T21:28:17 | CSS | UTF-8 | Java | false | false | 1,152 | java | package com.bookstore.service.impl;
import com.bookstore.entity.User;
import com.bookstore.repository.RoleRepository;
import com.bookstore.repository.UserRepository;
import com.bookstore.service.UserService;
import com.google.common.collect.Sets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.HashSet;
@Service
public class UserServiceImpl implements UserService {
@Autowired(required = false)
private UserRepository userRepository;
@Autowired(required = false)
private RoleRepository roleRepository;
@Autowired
private BCryptPasswordEncoder bCryptPasswordEncoder;
@Override
public void save(User user) {
user.setPassword(bCryptPasswordEncoder.encode(user.getPassword()));
user.setRoles(new HashSet<com.bookstore.entity.Role>(Sets.newHashSet(roleRepository.findAll())));
userRepository.save(user);
}
@Override
public User findByUsername(String username) {
return userRepository.findByUserName(username);
}
}
| [
"[email protected]"
] | |
3a5293e7cb3d33b6f4538cbc32a4ece55ebc61e3 | 6134c92a6e61f50d7109395a38af0f58abc8e7e8 | /app/src/main/java/com/joker/thanglong/WelcomeActivity.java | 7fb26e10ee9e18a8e0587a421ca78599230293e3 | [] | no_license | kienbui1995/social-network-client | 78c01105ca268a3c8086cdb4e3fc13811cb6bf88 | 1003fc55c59a538153d49aacf790d5ed5f64807f | refs/heads/master | 2020-03-29T00:05:16.097938 | 2017-07-21T01:11:27 | 2017-07-21T01:11:27 | 149,324,181 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,415 | java | package com.joker.thanglong;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
public class WelcomeActivity extends AppCompatActivity {
private ViewPager viewPager;
private MyViewPagerAdapter myViewPagerAdapter;
private LinearLayout dotsLayout;
private TextView[] dots;
private int[] layouts;
private Button btnSkip, btnNext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_welcome);
viewPager = (ViewPager) findViewById(R.id.view_pager);
dotsLayout = (LinearLayout) findViewById(R.id.layoutDots);
btnSkip = (Button) findViewById(R.id.btn_skip);
btnNext = (Button) findViewById(R.id.btn_next);
// layouts of all welcome sliders
// add few more layouts if you want
layouts = new int[]{
R.layout.welcome_slide1,
R.layout.welcome_slide2,
R.layout.welcome_slide3,
R.layout.welcome_slide4};
// adding bottom dots
addBottomDots(0);
// making notification bar transparent
changeStatusBarColor();
myViewPagerAdapter = new MyViewPagerAdapter();
viewPager.setAdapter(myViewPagerAdapter);
viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
btnSkip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// launchHomeScreen();
}
});
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// checking for last page
// if last page home screen will be launched
int current = getItem(+1);
if (current < layouts.length) {
// move to next screen
viewPager.setCurrentItem(current);
} else {
// launchHomeScreen();
}
}
});
}
private void addBottomDots(int currentPage) {
dots = new TextView[layouts.length];
int[] colorsActive = getResources().getIntArray(R.array.array_dot_active);
int[] colorsInactive = getResources().getIntArray(R.array.array_dot_inactive);
dotsLayout.removeAllViews();
for (int i = 0; i < dots.length; i++) {
dots[i] = new TextView(this);
dots[i].setText(Html.fromHtml("•"));
dots[i].setTextSize(35);
dots[i].setTextColor(colorsInactive[currentPage]);
dotsLayout.addView(dots[i]);
}
if (dots.length > 0)
dots[currentPage].setTextColor(colorsActive[currentPage]);
}
private int getItem(int i) {
return viewPager.getCurrentItem() + i;
}
// private void launchHomeScreen() {
// session.setFirstTimeLaunch(false);
// startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
// finish();
// }
// viewpager change listener
ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
addBottomDots(position);
// changing the next button text 'NEXT' / 'GOT IT'
if (position == layouts.length - 1) {
// last page. make button text to GOT IT
btnNext.setText(getString(R.string.start));
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(WelcomeActivity.this,MainActivity.class));
}
});
btnSkip.setVisibility(View.GONE);
} else {
// still pages are left
btnNext.setText("Tiếp");
btnSkip.setVisibility(View.VISIBLE);
}
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
};
/**
* Making notification bar transparent
*/
private void changeStatusBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
}
}
/**
* View pager adapter
*/
public class MyViewPagerAdapter extends PagerAdapter {
private LayoutInflater layoutInflater;
public MyViewPagerAdapter() {
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(layouts[position], container, false);
container.addView(view);
return view;
}
@Override
public int getCount() {
return layouts.length;
}
@Override
public boolean isViewFromObject(View view, Object obj) {
return view == obj;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
View view = (View) object;
container.removeView(view);
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
return;
}
}
| [
"[email protected]"
] | |
7baf0326bf24a19eaa756692b3503e34fad0947b | 53b7c2547dba7b886da29c7d1d8b17043d1d0e74 | /maven-lifecycle/src/main/java/org/apache/maven/lifecycle/ClassLoaderXmlBindingLoader.java | 2cad2aa63fd3f42124916b05e1a97e5074074937 | [] | no_license | magnayn/maven | a1d445f38e36b809c9abf9cf32af3ae31a1d82a1 | bf1ad03122fc35f980f7cc9f9afe496f969952c6 | refs/heads/experiment | 2022-07-05T14:39:48.334978 | 2009-03-05T22:32:23 | 2009-03-05T22:32:23 | 143,982 | 2 | 0 | null | 2022-07-01T22:19:37 | 2009-03-05T21:58:25 | Java | UTF-8 | Java | false | false | 2,247 | java | package org.apache.maven.lifecycle;
import org.apache.maven.lifecycle.model.LifecycleBindings;
import org.apache.maven.lifecycle.model.io.xpp3.LifecycleBindingsXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
/**
* @author jdcasey
*/
public class ClassLoaderXmlBindingLoader
implements LifecycleBindingLoader
{
// configuration.
private String path;
public ClassLoaderXmlBindingLoader()
{
// for plexus init.
}
public ClassLoaderXmlBindingLoader( String path )
{
this.path = path;
}
public LifecycleBindings getBindings()
throws LifecycleLoaderException, LifecycleSpecificationException
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
URL url = loader.getResource( getPath() );
if ( url == null )
{
throw new LifecycleLoaderException( "Classpath resource: " + getPath() + " could not be found." );
}
InputStreamReader reader;
try
{
reader = new InputStreamReader( url.openStream() );
}
catch ( IOException e )
{
throw new LifecycleLoaderException( "Failed to open stream for classpath resource: " + getPath() + ". Reason: "
+ e.getMessage(), e );
}
LifecycleBindings bindings;
try
{
bindings = new LifecycleBindingsXpp3Reader().read( reader );
}
catch ( IOException e )
{
throw new LifecycleLoaderException( "Classpath resource: " + getPath() + " could not be read. Reason: "
+ e.getMessage(), e );
}
catch ( XmlPullParserException e )
{
throw new LifecycleLoaderException( "Classpath resource: " + getPath() + " could not be parsed. Reason: "
+ e.getMessage(), e );
}
LifecycleUtils.setOrigin( bindings, url.toExternalForm() );
return bindings;
}
public String getPath()
{
return path;
}
public void setPath( String path )
{
this.path = path;
}
}
| [
"jdcasey@13f79535-47bb-0310-9956-ffa450edef68"
] | jdcasey@13f79535-47bb-0310-9956-ffa450edef68 |
2bb160153e13ae84224ec3fe1ca843b58a053d41 | 8739b671f6cbb49844dcced257532d245f4b747f | /app/src/main/java/jtkaiser/imags/database/MedicationDataCursorWrapper.java | 365a2d22d0dc226ce8bfbc7fa848031070288c77 | [] | no_license | jtkaiser/IMAGS-final | 9f9920955046aac1ad2552e9e4bd5ed4e2e22e38 | 91fa9dadb3442228b429a9a550b0e7a8d82e3eb5 | refs/heads/master | 2021-04-14T08:16:42.074713 | 2018-03-26T20:09:18 | 2018-03-26T20:09:18 | 126,883,569 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 777 | java | package jtkaiser.imags.database;
import android.database.Cursor;
import android.database.CursorWrapper;
import jtkaiser.imags.MedicationData;
import jtkaiser.imags.database.DbSchema.MedicationTable;
/**
* Created by jtkai on 3/25/2018.
*/
public class MedicationDataCursorWrapper extends CursorWrapper {
public MedicationDataCursorWrapper(Cursor cursor){
super(cursor);
}
public MedicationData getMedData(){
MedicationData data = new MedicationData();
data.tookMed = getInt(getColumnIndex(MedicationTable.Cols.TOOK));
data.medName = getString(getColumnIndex(MedicationTable.Cols.MED));
data.dosage = getString(getColumnIndex(MedicationTable.Cols.DOSE));
return data;
}
}
| [
"[email protected]"
] | |
7fce8a80790ff81be7278ccd9361663097bc65f6 | 82c1a71221e894c945550ca924a36f4c7e883c6a | /jedi-one/src/main/java/com/ldap/obi/ObiInvalidDnException.java | b920306608779e2296a90497e3a37e3f2e30f2fb | [] | no_license | dalamar66/jedi-obi | 33c61c5646f9cc621195e2e710ed9cd218cdcc1d | b73d594f0ac135c01022689ed15b9dc8b50be894 | refs/heads/master | 2021-01-10T12:42:39.899446 | 2014-05-21T14:28:24 | 2014-05-21T14:28:24 | 53,042,981 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 646 | java | package com.ldap.obi;
/**
* File : ObiInvalidDnException.java
* Component : Version : 1.0
* Creation date : 2010-03-10
* Modification date : 2010-03-10
*/
public class ObiInvalidDnException extends Exception {
private static final long serialVersionUID = -8780765761000884602L;
/**
* Exception qui n'affiche aucun message.
*/
public ObiInvalidDnException() {
super();
}
/**
* Exception qui affiche le message passé en paramètre.
*
* @param message
* Message à afficher.
*/
public ObiInvalidDnException(String message) {
super(message);
}
}// fin de la classe
| [
"[email protected]"
] | |
7d9672271a7fb32ded449f4f490250763585f743 | eb9f655206c43c12b497c667ba56a0d358b6bc3a | /java/java-tests/testData/refactoring/inlineObject/InlinePointToString.java | 99f2c3e8aa1d207c7fde5fa92ba7d4192f03df11 | [
"Apache-2.0"
] | permissive | JetBrains/intellij-community | 2ed226e200ecc17c037dcddd4a006de56cd43941 | 05dbd4575d01a213f3f4d69aa4968473f2536142 | refs/heads/master | 2023-09-03T17:06:37.560889 | 2023-09-03T11:51:00 | 2023-09-03T12:12:27 | 2,489,216 | 16,288 | 6,635 | Apache-2.0 | 2023-09-12T07:41:58 | 2011-09-30T13:33:05 | null | UTF-8 | Java | false | false | 256 | java | class Main {
void test() {
System.out.println(new <caret>Point(1, 2).toString());
}
}
class Point {
private int x, y;
public Point(int _x, int _y) {
x = _x;
y = _y;
}
public String toString() {
return "["+x+", "+y+"]";
}
}
| [
"[email protected]"
] | |
b4b4605e7de4139f3e5988e57c9fc4a715af6974 | 50fd732ce5849e4eccf4800a58e4ccaae221d2b5 | /language/pt.fct.unl.novalincs.useme.model.edit/src/pt/fct/unl/novalincs/useme/model/EvaluationModeling/provider/LanguageItemProvider.java | ee9b393220aea6aa65eefeb7d012e7528fb95974 | [] | no_license | akki55/useme | ed968437ef541471720a0168cc1e50c5944339fe | 5b1b13c02e82603c1420d12dd6ef54c7d5350951 | refs/heads/master | 2021-01-11T20:24:18.273786 | 2017-08-23T14:29:09 | 2017-08-23T14:29:09 | 79,108,510 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 6,947 | java | /**
*/
package pt.fct.unl.novalincs.useme.model.EvaluationModeling.provider;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
import pt.fct.unl.novalincs.useme.model.EvaluationModeling.EvaluationModelingPackage;
import pt.fct.unl.novalincs.useme.model.EvaluationModeling.Language;
import pt.fct.unl.novalincs.useme.model.UseMe.provider.UseMeEditPlugin;
/**
* This is the item provider adapter for a {@link pt.fct.unl.novalincs.useme.model.EvaluationModeling.Language} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class LanguageItemProvider
extends ItemProviderAdapter
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public LanguageItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addNamePropertyDescriptor(object);
addVersionPropertyDescriptor(object);
addEvaluationModelPropertyDescriptor(object);
addDSLPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Name feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addNamePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Language_name_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Language_name_feature", "_UI_Language_type"),
EvaluationModelingPackage.Literals.LANGUAGE__NAME,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Version feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addVersionPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Language_version_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Language_version_feature", "_UI_Language_type"),
EvaluationModelingPackage.Literals.LANGUAGE__VERSION,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Evaluation Model feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addEvaluationModelPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Language_evaluationModel_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Language_evaluationModel_feature", "_UI_Language_type"),
EvaluationModelingPackage.Literals.LANGUAGE__EVALUATION_MODEL,
true,
false,
true,
null,
null,
null));
}
/**
* This adds a property descriptor for the DSL feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addDSLPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Language_DSL_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Language_DSL_feature", "_UI_Language_type"),
EvaluationModelingPackage.Literals.LANGUAGE__DSL,
true,
false,
true,
null,
null,
null));
}
/**
* This returns Language.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object getImage(Object object) {
return overlayImage(object, getResourceLocator().getImage("full/obj16/Language"));
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getText(Object object) {
String label = ((Language)object).getName();
return label == null || label.length() == 0 ?
getString("_UI_Language_type") :
getString("_UI_Language_type") + " " + label;
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(Language.class)) {
case EvaluationModelingPackage.LANGUAGE__NAME:
case EvaluationModelingPackage.LANGUAGE__VERSION:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
super.notifyChanged(notification);
}
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
* that can be created under this object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
}
/**
* Return the resource locator for this item provider's resources.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
return UseMeEditPlugin.INSTANCE;
}
}
| [
"[email protected]"
] | |
fa124838ac9ad1b5f005741e7a9a22ff17e18a5c | 1b830b925aeac0c6e9c36cca222e1bd21bff0382 | /app/src/main/java/com/example/uaoremoto/InicioEstudiante.java | 552367dd8be8acc9ca24d8c0476f48e650ee914d | [] | no_license | RubenChalapud/UAO_Remoto | 42c5c54167c8687dd7cd4b210089a9d852af1ae2 | 41e2ca9408009affd47c3926cd51d3849a367f3b | refs/heads/master | 2023-01-21T07:40:30.669454 | 2020-11-26T21:13:40 | 2020-11-26T21:13:40 | 304,973,080 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,263 | java | package com.example.uaoremoto;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class InicioEstudiante extends AppCompatActivity {
TextView txtUser;
TextView txtCorreo;
Button btnRealizarAutoE;
//Inicializar menu
DrawerLayout drawerLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inicio_estudiante);
//Boton para evaluar covid
btnRealizarAutoE = (Button) findViewById(R.id.btnRealizarEvaluacionE);
txtUser =(TextView)findViewById(R.id.textViewNombreE);
final String user = getIntent().getStringExtra("user");
txtUser.setText(user);
txtCorreo = (TextView) findViewById(R.id.textViewCorreoE);
final String email = getIntent().getStringExtra("email");
txtCorreo.setText(email);
final String idestudiante = getIntent().getStringExtra("idestudiante");
//Menu
drawerLayout = findViewById(R.id.drawer_layout);
//Ir a evaluar covid
btnRealizarAutoE.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(InicioEstudiante.this, AutoevaluacionEstudiantes.class);
i.putExtra("email", email);
i.putExtra("user", user);
i.putExtra("idestudiante", idestudiante);
startActivity(i);
}
});
}
//Metodos para Menu
public void ClickMenu(View view){
openDrawer(drawerLayout);
}
private static void openDrawer(DrawerLayout drawerLayout){
drawerLayout.openDrawer(GravityCompat.START);
}
public void ClickInicio(View view){
closeDrawer(drawerLayout);
}
private static void closeDrawer(DrawerLayout drawerLayout) {
if(drawerLayout.isDrawerOpen(GravityCompat.START)){
drawerLayout.closeDrawer(GravityCompat.START);
}
}
public void ClickAutoMenu(View view){
String email = getIntent().getStringExtra("email");
String user = getIntent().getStringExtra("user");
String idestudiante = getIntent().getStringExtra("idestudiante");
Intent i = new Intent(InicioEstudiante.this, AutoevaluacionEstudiantes.class);
i.putExtra("email", email);
i.putExtra("user", user);
i.putExtra("idestudiante", idestudiante);
closeDrawer(drawerLayout);
startActivity(i);
}
public void ClickCursosMenu(View view){
String email = getIntent().getStringExtra("email");
String user = getIntent().getStringExtra("user");
String idestudiante = getIntent().getStringExtra("idestudiante");
Intent i = new Intent(InicioEstudiante.this, MisCursosEstudiante.class);
i.putExtra("email", email);
i.putExtra("user", user);
i.putExtra("idestudiante", idestudiante);
closeDrawer(drawerLayout);
startActivity(i);
}
public void ClickSalir(View view){
AlertDialog.Builder builder = new AlertDialog.Builder(InicioEstudiante.this);
builder.setTitle("Salir");
builder.setMessage("¿Deseas salir de UAO Remoto?");
builder.setPositiveButton("Si", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
InicioEstudiante.this.finishAffinity();
System.exit(0);
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
builder.show();
}
@Override
protected void onPause() {
super.onPause();
closeDrawer(drawerLayout);
}
} | [
"[email protected]"
] | |
cc219f95baa004b17afe304eb913b66a0958157b | ef45855c2bb0e4574a8f916a01ed1b97b51eb487 | /app/src/main/java/com/excalibur/starnovel/SplashActivity.java | 1f59020061e1e5a7556cb46977a22c1f8a58dd17 | [] | no_license | ArthurExcalibur/StarNovel | 53ddfd7987bff126b2ce4d3d8eb3799c54fe2c13 | 2b889107592dd201cc8cb82f480e72218d1572d4 | refs/heads/master | 2020-06-20T00:50:29.708731 | 2017-02-08T01:25:19 | 2017-02-08T01:25:19 | 74,893,194 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,732 | java | package com.excalibur.starnovel;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import com.excalibur.starnovel.utils.Constants;
/**
* Created by Excalibur on 2017/1/5.
*/
public class SplashActivity extends BaseActivity {
Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
Intent intent = new Intent(SplashActivity.this,MainActivity.class);
startActivity(intent);
}
};
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
checkForUpdate();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
public void checkForUpdate(){
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_ACTIVITIES);
int code = info.versionCode;
//从网上获取到最新版的versionCode
int newCode = 10;
if(code != newCode){
//说明有版本更新
SharedPreferences sp = getSharedPreferences(Constants.SHARE_PREFS,MODE_PRIVATE);
int notCode = sp.getInt(Constants.NOT_UPDATE_CODE,-1);
if(notCode != -1 && newCode > notCode){
//弹出弹框提示更新
}
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}finally {
}
}
}
| [
"[email protected]"
] | |
58b8a8f5db55fb2fc0b393431aeb4eb8d2d4642f | e0a399d16b48f9a6196b789112b8fb8314384a8a | /app/src/main/java/ixtapa/com/mx/ixtapazihua/Fragments/TabHoteles.java | f3a2042a9f23c45066b286e0897be378ad3ce73d | [] | no_license | cesarmanuel9204/IxtapaZihuatanejo | 362292419da010349b70e2d225fd9da2c9d9cf2c | 6d09aa9408f332adf44e2a7fa194974149517665 | refs/heads/master | 2021-01-12T08:00:18.759691 | 2016-12-21T20:52:03 | 2016-12-21T20:52:03 | 77,085,087 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 549 | java | package ixtapa.com.mx.ixtapazihua.Fragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import ixtapa.com.mx.ixtapazihua.R;
/**
* Created by HP-PC on 20/12/2016.
*/
public class TabHoteles extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle save){
final View view = inflater.inflate(R.layout.tabhoteles, container, false);
return view;
}
}
| [
"[email protected]"
] | |
9ac9dd859721ca37a9e2fc4e74ab33ac70d2c8df | 92225460ebca1bb6a594d77b6559b3629b7a94fa | /src/com/kingdee/eas/fdc/finance/WorkLoadCostVoucherEntryFactory.java | 61da7cc1c406f64bf2e7d54ccd4903bc30d58660 | [] | no_license | yangfan0725/sd | 45182d34575381be3bbdd55f3f68854a6900a362 | 39ebad6e2eb76286d551a9e21967f3f5dc4880da | refs/heads/master | 2023-04-29T01:56:43.770005 | 2023-04-24T05:41:13 | 2023-04-24T05:41:13 | 512,073,641 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,576 | java | package com.kingdee.eas.fdc.finance;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.BOSObjectFactory;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.Context;
public class WorkLoadCostVoucherEntryFactory
{
private WorkLoadCostVoucherEntryFactory()
{
}
public static com.kingdee.eas.fdc.finance.IWorkLoadCostVoucherEntry getRemoteInstance() throws BOSException
{
return (com.kingdee.eas.fdc.finance.IWorkLoadCostVoucherEntry)BOSObjectFactory.createRemoteBOSObject(new BOSObjectType("170A8C97") ,com.kingdee.eas.fdc.finance.IWorkLoadCostVoucherEntry.class);
}
public static com.kingdee.eas.fdc.finance.IWorkLoadCostVoucherEntry getRemoteInstanceWithObjectContext(Context objectCtx) throws BOSException
{
return (com.kingdee.eas.fdc.finance.IWorkLoadCostVoucherEntry)BOSObjectFactory.createRemoteBOSObjectWithObjectContext(new BOSObjectType("170A8C97") ,com.kingdee.eas.fdc.finance.IWorkLoadCostVoucherEntry.class, objectCtx);
}
public static com.kingdee.eas.fdc.finance.IWorkLoadCostVoucherEntry getLocalInstance(Context ctx) throws BOSException
{
return (com.kingdee.eas.fdc.finance.IWorkLoadCostVoucherEntry)BOSObjectFactory.createBOSObject(ctx, new BOSObjectType("170A8C97"));
}
public static com.kingdee.eas.fdc.finance.IWorkLoadCostVoucherEntry getLocalInstance(String sessionID) throws BOSException
{
return (com.kingdee.eas.fdc.finance.IWorkLoadCostVoucherEntry)BOSObjectFactory.createBOSObject(sessionID, new BOSObjectType("170A8C97"));
}
} | [
"[email protected]"
] | |
863a9494556544f3169b9615082935b832363894 | 5dc749f171ea20269afb59ebd9a732f1d646d566 | /安卓端代码/app/src/main/java/com/example/chat/Publish.java | 6b389cce59170c691854691798b9ec81a2dff31b | [] | no_license | 1goddness2/Android-3design | 0da840e37adaf5a87f54c3700972c36d061a3a18 | 7555a5e6a12179ced55176e2acaaaaabb6af7517 | refs/heads/master | 2020-09-21T18:00:48.562942 | 2020-01-05T07:44:11 | 2020-01-05T07:44:11 | 224,873,696 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,646 | java | package com.example.chat;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.chat.ui.notifications.NotificationsFragment;
public class Publish extends Activity {
private static final int COMPLETED = 0;
private static final int COMPLETE = 1;
private static String url_publish = "http://172.20.10.12:5000/publish";
private String jsonData;
String data;
private TextView content;
JSONParser jsonParser= new JSONParser();
private Button button1;
private Button button2;
String str = "";
LinearLayout llt;
LayoutInflater inflater;
private EditText et;
private Button button;
private Button button4;
String mstr;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.publish);
button = findViewById(R.id.button3);
button4 = findViewById(R.id.button4);
et = findViewById(R.id.textView4);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mstr = et.getText().toString();
new Login().execute();
Intent myin = new Intent(Publish.this, QqMainActivity.class);
startActivity(myin);
}
});
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//实现一个可以跳转界面的实例
Intent myin = new Intent(Publish.this,QqMainActivity.class);
//开启意图,并设置请求码是0,相当于设置一个监听或者中断
//这个中断将在运行到setResult(结果码,意图实例);这样的代码返回来
//请求码用于判定返回的意图传到哪里,
startActivity(myin);
}
});
}
class Login extends AsyncTask<String,String,String> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
//pDialog = new ProgressDialog(MainActivity.this);
// pDialog.setMessage("登陆中 请稍后...");
//pDialog.setIndeterminate(false);
//pDialog.setCancelable(true);
//pDialog.show();
}
protected String doInBackground(String... args){
try{
String url = "";
url = url_publish + "?content=" + mstr;
jsonData = jsonParser.makeHttpRequest(url,"POST");
}catch(Exception e){
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
//pDialog.dismiss();
//String str = "" + success;
//Toast toast = Toast.makeText(getApplicationContext(),"登录状态" + str, Toast.LENGTH_LONG);
//toast.show();
//if (success==1){
//System.out.println("dengluchenggong");
//user_name = qqNo.getText().toString();
//Intent intent = new Intent(MainActivity.this, QqMainActivity.class);
//startActivity(intent);
// }
}
}
}
| [
"[email protected]"
] | |
a847c5adbc8bbabc4328780943b50bfc2bdb20a2 | 5a0e9c4e6d68bccc6542007c9d1cffbedc3b3806 | /src/com/regex/Test2.java | fa4a6abe21830c785d1510bee470520cd2b0c053 | [] | no_license | hypochratesm/demo | f095dbd260bcb97e73b46b787624daa223d57a0e | f281c854d1a9b808b103805b80f50775bc0618d9 | refs/heads/master | 2020-04-18T10:16:36.829587 | 2019-01-25T08:14:22 | 2019-01-25T08:14:22 | 167,462,453 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 860 | java | package com.regex;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test2 {
public static String replaceAll(String str,String oldStr,String newStr){
if(str==null)
return null;
Pattern p = Pattern.compile(oldStr);//대한
Matcher m = p.matcher(str);
StringBuffer sb = new StringBuffer();
while(m.find()){
m.appendReplacement(sb, newStr);//大韓
}
m.appendTail(sb);//꼬리부분을 붙여라 //대한 뒤의 글자까지 붙이게 해주는 역할.
return sb.toString();
}
public static void main(String[] args) {
String str = "우리나라 대한 민국 대한독립 대한의 건아...";
System.out.println(str);
String s = Test2.replaceAll(str, "대한", "大韓");
System.out.println(s);
}
}
| [
"[email protected]"
] | |
77271561e929f536d8965aaf2044ff8f45dadd0b | a54993d34a03a92023aea6564b56552f4fd805e9 | /src/hatecode/FindDuplicateSubtrees.java | 51ad461b732210d0f8f9b8114a87133673645c7f | [] | no_license | yangx38/interview-1 | 2c3f8241bc176abca9f6488f4dfba5bfa68c15a0 | 577a9da809fa78cb8b623740b96ebeaaf7748a2f | refs/heads/master | 2020-05-25T12:27:12.715028 | 2019-05-20T17:38:24 | 2019-05-20T17:38:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,344 | java | package hatecode;
import java.util.*;
public class FindDuplicateSubtrees {
/*
652. Find Duplicate Subtrees
Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them.
Two trees are duplicate if they have the same structure with same node values.
Example 1:
1
/ \
2 3
/ / \
4 2 4
/
4
{3->2->4->#->#->#->4->#->#=1,
4->#->#=3,
1->2->4->#->#->#->3->2->4->#->#->#->4->#->#=1,
2->4->#->#->#=2}
*/
public static List<TreeNode> findDuplicateSubtrees(TreeNode root) {
List<TreeNode> res = new LinkedList<>();
Map<String, Integer> map = new HashMap<>();
postorder(root, map, res);
System.out.println(map);
return res;
}
//print the track since we asked for the pattern, like all left
public static String postorder(TreeNode cur, Map<String, Integer> map, List<TreeNode> res) {
if (cur == null) return "#";
String serial = cur.val + "->" + postorder(cur.left, map, res) + "->" + postorder(cur.right, map, res);
//find similiar tree, then add to result
if (map.getOrDefault(serial, 0) == 1) res.add(cur);
map.put(serial, map.getOrDefault(serial, 0) + 1);
return serial;
}
} | [
"[email protected]"
] | |
48914099acb0ef27c247cd3cbb2f8ba31120658e | 54f126ea007b42b347444535555152952e477bbe | /Spring Framework 5 - Beginner ToGuru/spring-mvc-rest/src/test/java/com/fredrikpedersen/springmvcrest/controllers/v1/CategoryControllerTest.java | 998d6ce88b3c5fcf2914eafd1f6a652356c65437 | [] | no_license | Ab0o0oD/Learning_Spring | 2913468e1fbbdece9a97e5c71143cdab29e2b92f | e48be1182be3935c101cfcc17063809013d1fb94 | refs/heads/master | 2022-04-16T01:40:09.684773 | 2020-04-01T12:16:55 | 2020-04-01T12:16:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,196 | java | package com.fredrikpedersen.springmvcrest.controllers.v1;
import com.fredrikpedersen.springmvcrest.api.v1.model.category.CategoryDTO;
import com.fredrikpedersen.springmvcrest.exceptions.ResourceNotFoundException;
import com.fredrikpedersen.springmvcrest.services.category.CategoryService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import java.util.Arrays;
import java.util.List;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* @author Fredrik Pedersen
* @version 1.0
* @since 16/02/2020 at 18:02
*/
class CategoryControllerTest {
private static final String NAME = "Jim";
private static final String URL = CategoryController.BASE_URL;
@Mock
CategoryService categoryService;
@InjectMocks
CategoryController categoryController;
MockMvc mockMvc;
@BeforeEach
void setUp() {
MockitoAnnotations.initMocks(this);
mockMvc = MockMvcBuilders.standaloneSetup(categoryController)
.setControllerAdvice(new RestResponseEntityExceptionHandler())
.build();
}
@Test
void listCategoriesTest() throws Exception {
CategoryDTO category1 = new CategoryDTO();
category1.setId(1L);
category1.setName(NAME);
CategoryDTO category2 = new CategoryDTO();
category2.setId(2L);
category2.setName("Bob");
List<CategoryDTO> categories = Arrays.asList(category1, category2);
when(categoryService.getAllCategories()).thenReturn(categories);
mockMvc.perform(get(URL)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.categories", hasSize(2)));
}
@Test
void getByNameCategoriesTest() throws Exception {
CategoryDTO category1 = new CategoryDTO();
category1.setId(1l);
category1.setName(NAME);
when(categoryService.getCategoryByName(anyString())).thenReturn(category1);
mockMvc.perform(get(URL + NAME)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.name", equalTo(NAME)));
}
@Test
void getByNameNotFoundTest() throws Exception {
when(categoryService.getCategoryByName(anyString())).thenThrow(ResourceNotFoundException.class);
mockMvc.perform(get(URL + "/foo")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isNotFound());
}
} | [
"[email protected]"
] | |
d4657227dc0482a0da5fc4f52ae228ab342f90cd | e22459966d81d94b75c2018c174af4b10db536a0 | /src/main/java/org/apache/people/mreutegg/jsinfonia/util/ByteBufferInputStream.java | 538dce89d40752acbbd1b81ac2fb2f452bf4ca85 | [
"W3C",
"Apache-2.0"
] | permissive | mreutegg/jsinfonia | 6759a2921dcd781ab02dc9292a089fecdc9df01e | 2d57e8b3313b6f2812a7bfcba41511a9edaa35c4 | refs/heads/master | 2023-06-22T05:19:26.959017 | 2023-06-19T05:02:34 | 2023-06-19T05:02:34 | 9,180,282 | 0 | 0 | Apache-2.0 | 2023-06-19T05:02:35 | 2013-04-02T21:07:31 | Java | UTF-8 | Java | false | false | 1,347 | java | /*
* Copyright 2013 Marcel Reutegger
*
* 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.apache.people.mreutegg.jsinfonia.util;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
public class ByteBufferInputStream extends InputStream {
private final ByteBuffer buffer;
public ByteBufferInputStream(ByteBuffer buffer) {
this.buffer = buffer.duplicate();
}
@Override
public int read() throws IOException {
if (buffer.remaining() == 0) {
return -1;
}
return buffer.get() & 0xff;
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
if (buffer.remaining() < len) {
len = buffer.remaining();
}
buffer.get(b, off, len);
return len;
}
}
| [
"[email protected]"
] | |
293544ef43eb222dd51a805addf80b0eb444eb7b | edeb76ba44692dff2f180119703c239f4585d066 | /extGeoDB/src/com/prodevelop/cit/gvsig/vectorialdb/wizard/UserTableSettingsVectorialPanel.java | 55fb1d1ca5da6c88b85bd4e54f0122c0fcd35de4 | [] | no_license | CafeGIS/gvSIG2_0 | f3e52bdbb98090fd44549bd8d6c75b645d36f624 | 81376f304645d040ee34e98d57b4f745e0293d05 | refs/heads/master | 2020-04-04T19:33:47.082008 | 2012-09-13T03:55:33 | 2012-09-13T03:55:33 | 5,685,448 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 11,390 | java | /* gvSIG. Geographic Information System of the Valencian Government
*
* Copyright (C) 2007-2008 Infrastructures and Transports Department
* of the Valencian Government (CIT)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
/*
* AUTHORS (In addition to CIT):
* 2009 IVER T.I {{Task}}
*/
package com.prodevelop.cit.gvsig.vectorialdb.wizard;
import java.awt.event.ActionEvent;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.cresques.cts.IProjection;
import org.gvsig.fmap.dal.store.db.DBStoreParameters;
import org.gvsig.fmap.geom.GeometryLocator;
import org.gvsig.fmap.geom.GeometryManager;
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
import org.gvsig.fmap.geom.primitive.Envelope;
import org.gvsig.fmap.mapcontrol.MapControl;
import org.gvsig.gui.beans.swing.JButton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.iver.andami.PluginServices;
import com.iver.cit.gvsig.addlayer.AddLayerDialog;
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel;
public class UserTableSettingsVectorialPanel extends UserTableSettingsPanel {
private static Logger logger = LoggerFactory
.getLogger(UserTableSettingsPanel.class.getName());
private FieldComboItem[] geos;
private JComboBox geomComboBox = null;
private JLabel geomLabel = null;
private JLabel waLabel = null;
private JLabel topLabel = null;
private JTextField topTextField = null;
private JTextField bottomTextField = null;
private JTextField rightTextField = null;
private JTextField leftTextField = null;
private JLabel bottomLabel = null;
private JLabel rightLabel = null;
private JLabel leftLabel = null;
private JButton getviewButton = null;
private JCheckBox activateWACheckBox = null;
private MapControl mControl = null;
private CRSSelectPanel panelProj;
private IProjection currentProj;
public UserTableSettingsVectorialPanel(FieldComboItem[] idComboItems,
FieldComboItem[] geoComboItems, String initialLayerName,
MapControl mapc, boolean empty, WizardVectorialDB _p,
DBStoreParameters parameters,
IProjection curProjection) {
super();
setInitValues(idComboItems, initialLayerName, empty, _p, parameters);
mControl = mapc;
geos = geoComboItems;
currentProj = curProjection;
initialize(empty);
}
protected void initialize(boolean _empty) {
super.initialize(_empty);
setBorder(javax.swing.BorderFactory.createTitledBorder(null,
PluginServices.getText(this, "specify_table_settings"),
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
leftLabel = new JLabel();
// leftLabel.setBounds(new java.awt.Rectangle(375, 175, 111, 16));
leftLabel.setBounds(new java.awt.Rectangle(375, 200, 111, 16));
leftLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
leftLabel.setText(PluginServices.getText(this, "xmin"));
rightLabel = new JLabel();
rightLabel.setBounds(new java.awt.Rectangle(260, 200, 111, 16));
rightLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
rightLabel.setText(PluginServices.getText(this, "xmax"));
bottomLabel = new JLabel();
bottomLabel.setBounds(new java.awt.Rectangle(130, 200, 111, 16));
bottomLabel
.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
bottomLabel.setText(PluginServices.getText(this, "ymin"));
topLabel = new JLabel();
topLabel.setBounds(new java.awt.Rectangle(15, 200, 111, 16));
topLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
topLabel.setText(PluginServices.getText(this, "ymax"));
waLabel = new JLabel();
// waLabel.setBounds(new java.awt.Rectangle(40, 145, 131, 21));
waLabel.setBounds(new java.awt.Rectangle(30, 172, 131, 21));
waLabel.setText(PluginServices.getText(this, "working_area"));
geomLabel = new JLabel();
// geomLabel.setBounds(new java.awt.Rectangle(240, 55, 111, 21));
geomLabel.setBounds(new java.awt.Rectangle(5, 145, 111, 21));
geomLabel.setText(PluginServices.getText(this, "geo_field"));
add(getGeomComboBox(), null);
add(geomLabel, null);
add(waLabel, null);
add(topLabel, null);
add(getTopTextField(), null);
add(getBottomTextField(), null);
add(getRightTextField(), null);
add(getLeftTextField(), null);
add(bottomLabel, null);
add(rightLabel, null);
add(leftLabel, null);
add(getGetviewButton(), null);
add(getActivateWACheckBox(), null);
loadValues(_empty);
}
private CRSSelectPanel getJPanelProj() {
if (panelProj == null) {
panelProj = CRSSelectPanel.getPanel(currentProj);
panelProj.setTransPanelActive(true);
panelProj.setLocation(new java.awt.Point(-10, 110));
panelProj.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if (panelProj.isOkPressed()) {
AddLayerDialog
.setLastProjection(panelProj.getCurProj());
}
}
});
}
return panelProj;
}
public boolean hasValidValues() {
if (!super.hasValidValues()) {
return false;
}
if ((activateWACheckBox.isSelected()) && (getWorkingArea() == null)) {
return false;
}
return true;
}
private JComboBox getGeomComboBox() {
if (geomComboBox == null) {
geomComboBox = new JComboBox();
// geomComboBox.setBounds(new java.awt.Rectangle(355, 55, 131, 21));
geomComboBox.setBounds(new java.awt.Rectangle(120, 145, 118, 21));
}
return geomComboBox;
}
private JTextField getTopTextField() {
if (topTextField == null) {
topTextField = new JTextField();
topTextField.addKeyListener(this);
// topTextField.setBounds(new java.awt.Rectangle(15, 190, 111, 21));
topTextField.setBounds(new java.awt.Rectangle(15, 215, 111, 21));
}
return topTextField;
}
private JTextField getBottomTextField() {
if (bottomTextField == null) {
bottomTextField = new JTextField();
bottomTextField.addKeyListener(this);
bottomTextField
.setBounds(new java.awt.Rectangle(130, 215, 111, 21));
}
return bottomTextField;
}
private JTextField getRightTextField() {
if (rightTextField == null) {
rightTextField = new JTextField();
rightTextField.addKeyListener(this);
rightTextField.setBounds(new java.awt.Rectangle(260, 215, 111, 21));
}
return rightTextField;
}
private JTextField getLeftTextField() {
if (leftTextField == null) {
leftTextField = new JTextField();
leftTextField.addKeyListener(this);
leftTextField.setBounds(new java.awt.Rectangle(375, 215, 111, 21));
}
return leftTextField;
}
private JButton getGetviewButton() {
if (getviewButton == null) {
getviewButton = new JButton();
getviewButton.addActionListener(this);
//getviewButton.setBounds(new java.awt.Rectangle(195, 145, 111, 26));
getviewButton.setBounds(new java.awt.Rectangle(160, 174, 111, 26));
getviewButton.setForeground(java.awt.Color.black);
getviewButton.setText(PluginServices.getText(this, "get_view"));
}
return getviewButton;
}
private JCheckBox getActivateWACheckBox() {
if (activateWACheckBox == null) {
activateWACheckBox = new JCheckBox();
activateWACheckBox.addActionListener(this);
// activateWACheckBox
// .setBounds(new java.awt.Rectangle(15, 145, 21, 21));
activateWACheckBox
.setBounds(new java.awt.Rectangle(5, 172, 21, 21));
}
return activateWACheckBox;
}
protected void loadValues(boolean is_empty) {
super.loadValues(is_empty);
if (is_empty) {
enableAlphaControls(false);
enableSpatialControls(false);
getActivateWACheckBox().setSelected(false);
} else {
enableAlphaControls(true);
enableSpatialControls(true);
getGeomComboBox().removeAllItems();
for (int i = 0; i < geos.length; i++) {
getGeomComboBox().addItem(geos[i]);
}
add(getJPanelProj(), null);
}
}
public void enableSpatialControls(boolean enable) {
super.enableSpatialControls(enable);
getGeomComboBox().setEnabled(enable);
getActivateWACheckBox().setEnabled(enable);
boolean there_is_view = ((mControl != null) && (mControl.getViewPort()
.getAdjustedExtent() != null));
getGetviewButton().setEnabled(enable && there_is_view);
getTopTextField().setEnabled(enable);
getBottomTextField().setEnabled(enable);
getRightTextField().setEnabled(enable);
getLeftTextField().setEnabled(enable);
}
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
Object src = e.getSource();
if (src == getviewButton) {
getViewIntoFourBounds();
parent.checkFinishable();
}
if (src == activateWACheckBox) {
enableWASettings(activateWACheckBox.isSelected());
parent.checkFinishable();
}
}
private void enableWASettings(boolean b) {
getviewButton.setEnabled(b
&& (mControl.getViewPort().getAdjustedExtent() != null));
rightTextField.setEnabled(b);
leftTextField.setEnabled(b);
topTextField.setEnabled(b);
bottomTextField.setEnabled(b);
}
private void getViewIntoFourBounds() {
Envelope rect = mControl.getViewPort().getAdjustedExtent();
topTextField.setText(getFormattedDouble(rect.getMaximum(1)));
bottomTextField.setText(getFormattedDouble(rect.getMinimum(1)));
rightTextField.setText(getFormattedDouble(rect.getMaximum(0)));
leftTextField.setText(getFormattedDouble(rect.getMinimum(0)));
}
public Envelope getWorkingArea() {
if (!activateWACheckBox.isSelected()) {
return null;
}
double maxx;
double maxy;
double minx;
double miny;
try {
maxx = Double.parseDouble(rightTextField.getText());
miny = Double.parseDouble(bottomTextField.getText());
minx = Double.parseDouble(leftTextField.getText());
maxy = Double.parseDouble(topTextField.getText());
} catch (NumberFormatException nfe) {
logger.error("Not valid value: " + nfe.getMessage());
return null;
}
GeometryManager geoMan = GeometryLocator.getGeometryManager();
try {
return geoMan.createEnvelope(minx, miny, maxx, maxy,
SUBTYPES.GEOM2D);
} catch (CreateEnvelopeException e) {
// FIXME Exception
throw new RuntimeException(e);
}
}
public boolean combosHaveItems() {
if (!super.combosHaveItems()) {
return false;
}
if (getGeomComboBox().getItemCount() == 0) {
return false;
}
return true;
}
public void repaint() {
super.repaint();
getGeomComboBox().updateUI();
}
public String getGeoFieldName() {
if (getGeomComboBox().getSelectedItem() == null) {
return null;
}
return getGeomComboBox().getSelectedItem().toString();
}
public IProjection getProjection() {
return panelProj.getCurProj();
}
}
| [
"[email protected]"
] | |
c29b75569c3a5d682d6fb21555030be93a602bcd | a3d6556180e74af7b555f8d47d3fea55b94bcbda | /chrome/browser/password_manager/android/junit/src/org/chromium/chrome/browser/password_manager/PasswordManagerAndroidBackendUtilTest.java | de5d85c98e50926aad5bbf434a715ba99555b08f | [
"BSD-3-Clause"
] | permissive | chromium/chromium | aaa9eda10115b50b0616d2f1aed5ef35d1d779d6 | a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c | refs/heads/main | 2023-08-24T00:35:12.585945 | 2023-08-23T22:01:11 | 2023-08-23T22:01:11 | 120,360,765 | 17,408 | 7,102 | BSD-3-Clause | 2023-09-10T23:44:27 | 2018-02-05T20:55:32 | null | UTF-8 | Java | false | false | 5,019 | java | // Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.password_manager;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.common.api.CommonStatusCodes;
import com.google.android.gms.common.api.ResolvableApiException;
import com.google.android.gms.common.api.Status;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.base.test.util.Batch;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.password_manager.PasswordStoreAndroidBackend.BackendException;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
/**
* Tests for the utility methods used by various parts of the password manager backend (e.g.
* the password store, the settings accessor).
*/
@RunWith(BaseRobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@Batch(Batch.PER_CLASS)
@EnableFeatures(ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID)
public class PasswordManagerAndroidBackendUtilTest {
@Rule
public TestRule mProcessor = new Features.JUnitProcessor();
@Test
public void testUtilsForBackendException() {
BackendException exception = new BackendException(
"Cannot call API without context.", AndroidBackendErrorType.NO_CONTEXT);
Assert.assertEquals(AndroidBackendErrorType.NO_CONTEXT,
PasswordManagerAndroidBackendUtil.getBackendError(exception));
Assert.assertEquals(0, PasswordManagerAndroidBackendUtil.getApiErrorCode(exception));
}
@Test
public void testUtilsForApiException() {
ApiException apiException = new ApiException(new Status(CommonStatusCodes.ERROR, ""));
Assert.assertEquals(AndroidBackendErrorType.EXTERNAL_ERROR,
PasswordManagerAndroidBackendUtil.getBackendError(apiException));
Assert.assertEquals(CommonStatusCodes.ERROR,
PasswordManagerAndroidBackendUtil.getApiErrorCode(apiException));
Assert.assertNull(PasswordManagerAndroidBackendUtil.getConnectionResultCode(apiException));
}
@Test
public void testUtilsForApiExceptionWithConnectionResult() {
ApiException apiException = new ApiException(
new Status(new ConnectionResult(ConnectionResult.API_UNAVAILABLE), ""));
Assert.assertEquals(AndroidBackendErrorType.EXTERNAL_ERROR,
PasswordManagerAndroidBackendUtil.getBackendError(apiException));
Assert.assertEquals(CommonStatusCodes.API_NOT_CONNECTED,
PasswordManagerAndroidBackendUtil.getApiErrorCode(apiException));
Assert.assertEquals(ConnectionResult.API_UNAVAILABLE,
PasswordManagerAndroidBackendUtil.getConnectionResultCode(apiException).intValue());
}
@Test
public void testUtilsReturnNullConnectionResultForNonApiException() {
BackendException exception = new BackendException(
"Cannot call API without context.", AndroidBackendErrorType.NO_CONTEXT);
Assert.assertNull(PasswordManagerAndroidBackendUtil.getConnectionResultCode(exception));
}
@Test
public void testUtilsForUncategorizedException() {
Exception exception = new Exception();
Assert.assertEquals(AndroidBackendErrorType.UNCATEGORIZED,
PasswordManagerAndroidBackendUtil.getBackendError(exception));
Assert.assertEquals(0, PasswordManagerAndroidBackendUtil.getApiErrorCode(exception));
}
@Test
public void testUtilsForResolvableApiExceptionAuth() throws CanceledException {
PendingIntent pendingIntentMock = mock(PendingIntent.class);
ResolvableApiException apiException = new ResolvableApiException(
new Status(ChromeSyncStatusCode.AUTH_ERROR_RESOLVABLE, "", pendingIntentMock));
PasswordManagerAndroidBackendUtil.handleResolvableApiException(apiException);
verify(pendingIntentMock, never()).send();
}
@Test
public void testUtilsForResolvableApiExceptionNonAuth() throws CanceledException {
PendingIntent pendingIntentMock = mock(PendingIntent.class);
ResolvableApiException apiException = new ResolvableApiException(
new Status(CommonStatusCodes.RESOLUTION_REQUIRED, "", pendingIntentMock));
PasswordManagerAndroidBackendUtil.handleResolvableApiException(apiException);
verify(pendingIntentMock).send();
}
}
| [
"[email protected]"
] | |
679a7013489dfea5474364093a2556986e30d0e0 | 1e8e054459dc4c3d03fc4b2bb116a308ffafdd4e | /Search Sort/BubbleSort.java | 02ca2e80213f5557c5e18e7b0c13efb5fe824321 | [] | no_license | aisyahmunir/Sem2 | 9367a9c11ff116122cb9bf7d46fc978437576ec7 | 922c4848ffef8fb377f9ad59928afddb562c05c6 | refs/heads/main | 2023-08-15T05:18:22.499060 | 2021-10-07T08:25:24 | 2021-10-07T08:25:24 | 402,091,493 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 854 | java | public class BubbleSort {
/** Bubble sort method */
public static void bubbleSort(int[] list) {
boolean needNextPass = true;
for (int k = 1; k < list.length && needNextPass; k++) {
// Array may be sorted and next pass not needed
needNextPass = false;
for (int i = 0; i < list.length - k; i++) {
if (list[i] > list[i + 1]) {
// Swap list[i] with list[i + 1]
int temp = list[i];
list[i] = list[i + 1];
list[i + 1] = temp;
needNextPass = true; // Next pass still needed
}
}
}
}
/** A test method */
public static void main(String[] args) {
int[] list = {2, 3, 2, 5, 6, 1, -2, 3, 14, 12};
bubbleSort(list);
for (int i = 0; i < list.length; i++)
System.out.print(list[i] + " ");
}
} | [
"[email protected]"
] | |
0d74f4c24a7aab4ed39cd26214a48e9d26c3c17a | 1b15a6ec402834b0cee897264e04c8c947a46938 | /app/src/main/java/com/jakeanderton/discountcalc/MainActivity.java | c34756cf581f4c05c906f0db01a1b1c267b19bb0 | [] | no_license | Avacrux/DiscountCalc | 2ab5b826548919d7375be0b5989795329f89b1b0 | dc6f12f58a568711168f6cd1e0cd1b954ffce349 | refs/heads/master | 2016-09-03T06:42:28.932727 | 2015-08-27T12:24:33 | 2015-08-27T12:24:33 | 41,485,060 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,947 | java | package com.jakeanderton.discountcalc;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
public class MainActivity extends Activity
{
private double basePrice;
private double disPrice;
RadioButton tenPercent;
RadioButton twentyPercent;
EditText basePriceET;
EditText disPriceET;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
basePrice = 0.0;
disPrice = 0.0;
basePriceET = (EditText) findViewById(R.id.basePriceEditText);
disPriceET = (EditText) findViewById(R.id.disPriceEditText);
tenPercent = (RadioButton) findViewById(R.id.tenRadio);
twentyPercent = (RadioButton) findViewById(R.id.twentyRadio);
tenPercent.setOnCheckedChangeListener(new RadioButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
updatePrice();
}
});
twentyPercent.setOnCheckedChangeListener(new RadioButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
updatePrice();
}
});
basePriceET.addTextChangedListener(editChecker);
}
private TextWatcher editChecker = new TextWatcher()
{
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
try
{
basePrice = Double.parseDouble(s.toString());
System.out.println(basePriceET.toString());
System.out.println(basePrice);
} catch (NumberFormatException e)
{
System.out.println("broke");
// basePrice = 0.0;
}
updatePrice();
}
@Override
public void afterTextChanged(Editable s)
{
}
};
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
public void updatePrice()
{
System.out.println("start if");
if (tenPercent.isChecked())
{
System.out.println("old: " + basePrice);
disPrice = basePrice - (basePrice * 0.1);
System.out.println("10 achieved");
System.out.println("new: " + disPrice);
}
else if (twentyPercent.isChecked())
{
disPrice = basePrice - (basePrice * 0.2);
System.out.println("20 achieved");
System.out.println("new: " + disPrice);
}
else
{
System.out.println("0 achieved????");
}
System.out.println("if end");
disPriceET.setText(String.format("%.02f", disPrice));
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings)
{
return true;
}
return super.onOptionsItemSelected(item);
}
}
| [
"[email protected]"
] | |
dab23b04d461284fe81f0e4c67e36734837d91a7 | d22726fe1b97c5dfb6582360aa794641d27754b4 | /GuideMeThreev3-master 4/app/src/main/java/com/example/aadmin/guidemethree/Map.java | cc592bf9683a73f867d28fa7d24dcf593226c91a | [] | no_license | Sudeepsudeep123/GuideMe | 6ad2bbf8b38bce23f8d9ee9c0d9bd428ca9cef33 | 43ba1a3ed4da8ea8dd717f044d2875ae042189b2 | refs/heads/master | 2021-01-22T09:39:58.253816 | 2017-09-04T06:50:53 | 2017-09-04T06:50:53 | 102,328,486 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,191 | java | package com.example.aadmin.guidemethree;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
public class Map extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
TextView txtlatitude = (TextView) findViewById(R.id.txtLatitude);
TextView txtlongitude = (TextView) findViewById(R.id.txtLongitude);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Bundle getCordinates = getIntent().getExtras();
//Extract the data…
String latitude = getCordinates.getString("latitude");
String longitude = getCordinates.getString("longitude");
txtlatitude.setText(latitude);
txtlongitude.setText(longitude);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
| [
"[email protected]"
] | |
0acdd058fcc81f04f2cae8fec324629c869af156 | 2ea1ca34b31d73d1ca8732cc3ed45668e8cdaab0 | /piratesship/piratesship-component/src/main/java/com/qcloud/component/piratesship/service/ModuleConfigService.java | 71bcbaf4d2ac4f20ead6cd33d04ed21b07c8c468 | [] | no_license | ChiRain/snaker | 07008c6aa07f10ac79f1787b4969f5e45a9c19e5 | 808945ca4fe5e7b11a969531fd0801a571c21c17 | refs/heads/master | 2021-01-18T01:48:44.523645 | 2016-07-26T06:04:15 | 2016-07-26T06:04:15 | 65,979,224 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 134 | java | package com.qcloud.component.piratesship.service;
public interface ModuleConfigService {
boolean enable(String module);
}
| [
"lihuashan@ed19df75-bd51-b445-9863-9e54940520a8"
] | lihuashan@ed19df75-bd51-b445-9863-9e54940520a8 |
19ee59b88bf113a1920930d4669a0db9fd9efa77 | 30908e57b8edabd221a1179b781d84f438295430 | /andenginephysicsbox2dextension/src/org/anddev/andengine/extension/physics/box2d/util/hull/JarvisMarch.java | 75f24926bc539bbbe9f64f88b580ad2be3526eb1 | [
"MIT"
] | permissive | sebnil/Sketchy-Truck | 60d561af52c212881ab27c73b195badd49a74f43 | b1f01e3ca2e82bf32f898de7df65fd102366941e | refs/heads/master | 2021-06-02T22:13:36.940757 | 2019-02-10T08:06:49 | 2019-02-10T08:06:49 | 4,511,925 | 8 | 12 | MIT | 2019-02-10T10:43:30 | 2012-05-31T19:28:44 | Java | UTF-8 | Java | false | false | 2,507 | java | package org.anddev.andengine.extension.physics.box2d.util.hull;
import org.anddev.andengine.extension.physics.box2d.util.Vector2Pool;
import com.badlogic.gdx.math.Vector2;
/**
* (c) 2010 Nicolas Gramlich
* (c) 2011 Zynga Inc.
*
* @author Nicolas Gramlich
* @since 14:01:18 - 14.09.2010
* @see http://www.iti.fh-flensburg.de/lang/algorithmen/geo/
*/
public class JarvisMarch extends BaseHullAlgorithm {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
// ===========================================================
// Constructors
// ===========================================================
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public int computeHull(final Vector2[] pVectors) {
this.mVertices = pVectors;
this.mVertexCount = pVectors.length;
this.mHullVertexCount = 0;
this.jarvisMarch();
return this.mHullVertexCount;
}
// ===========================================================
// Methods
// ===========================================================
private void jarvisMarch() {
final Vector2[] vertices = this.mVertices;
int index = this.indexOfLowestVertex();
do {
this.swap(this.mHullVertexCount, index);
index = this.indexOfRightmostVertexOf(vertices[this.mHullVertexCount]);
this.mHullVertexCount++;
} while(index > 0);
}
private int indexOfRightmostVertexOf(final Vector2 pVector) {
final Vector2[] vertices = this.mVertices;
final int vertexCount = this.mVertexCount;
int i = 0;
for(int j = 1; j < vertexCount; j++) {
final Vector2 vector2A = Vector2Pool.obtain().set(vertices[j]);
final Vector2 vector2B = Vector2Pool.obtain().set(vertices[i]);
if(Vector2Util.isLess(vector2A.sub(pVector), vector2B.sub(pVector))) {
i = j;
}
Vector2Pool.recycle(vector2A);
Vector2Pool.recycle(vector2B);
}
return i;
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}
| [
"[email protected]"
] | |
f441fe1f7250e8f09fecbd97af2b1de01f8dc990 | 2cb0f9b716fd3c9b4d7d64b28da6ba5c54f81876 | /FBLOGin/app/src/main/java/com/example/abhishek/fblogin/util/RoundedImageView.java | 37af75321cd5730de9818fb6a9eaf331bc1847a1 | [] | no_license | iAbhi1995/Ostello | 7927f317b3ffa72867aec0ac0ed4601f52df70f3 | c9c0acd004404a059a0549950dcf2ba58516b19c | refs/heads/master | 2021-01-17T07:17:11.413933 | 2017-02-25T17:44:55 | 2017-02-25T17:44:55 | 83,697,702 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,015 | java | package com.example.abhishek.fblogin.util;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by Abhishek on 22-08-2016.
*/
public class RoundedImageView extends ImageView{
public RoundedImageView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public RoundedImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RoundedImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onDraw(Canvas canvas) {
Drawable drawable = getDrawable();
if (drawable == null) {
return;
}
if (getWidth() == 0 || getHeight() == 0) {
return;
}
Bitmap b = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& drawable instanceof VectorDrawable) {
drawable.draw(canvas);
b= Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas();
c.setBitmap(b);
drawable.draw(c);
}
else {
b = ((BitmapDrawable) drawable).getBitmap();
}
Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);
int w = getWidth(), h = getHeight();
Bitmap roundBitmap = getCroppedBitmap(bitmap, w);
canvas.drawBitmap(roundBitmap, 0,0, null);
}
public static Bitmap getCroppedBitmap(Bitmap bmp, int radius) {
Bitmap sbmp;
if(bmp.getWidth() != radius || bmp.getHeight() != radius)
sbmp = Bitmap.createScaledBitmap(bmp, radius, radius, false);
else
sbmp = bmp;
Bitmap output = Bitmap.createBitmap(sbmp.getWidth(),
sbmp.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xffa19774;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, sbmp.getWidth(), sbmp.getHeight());
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(Color.parseColor("#BAB399"));
canvas.drawCircle(sbmp.getWidth() / 2+0.7f, sbmp.getHeight() / 2+0.7f,
sbmp.getWidth() / 2+0.1f, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(sbmp, rect, rect, paint);
return output;
}
}
| [
"[email protected]"
] | |
377a31f03cb5c08e988725705f925f948205214d | 6bf8c8f4a6a1857f7cffc297f990182bf7ecd660 | /lige/grupo03/pr4/logica/commands/ComandoUsar.java | e89d26b1f11b277f95d3fecc6dbf249305f4b4db | [] | no_license | ismaelfdi/Lige-PR3 | d7bc71771024c0dafee14a060dee29ce30f30192 | 11e8cc3284f5948f64dea18d2855c2664e1debcc | refs/heads/master | 2021-01-18T14:02:48.505717 | 2013-04-26T15:56:59 | 2013-04-26T15:56:59 | null | 0 | 0 | null | null | null | null | WINDOWS-1250 | Java | false | false | 1,127 | java | /**
*
*/
package lige.grupo03.pr4.logica.commands;
import lige.grupo03.pr4.VerbCommands;
import lige.grupo03.pr4.logica.Game;
/**
* Clase que representa el Comando USAR
*
* @author Ismael Ventura & Ignacio Lopez
* @version 2.0
*/
public class ComandoUsar extends Comando{
/*Atributo que representa el identificador del Item a usar*/
private String id;
/*Atributo que representa el juego en ejecucion*/
private Game juego;
/**
* Constructor parametrizado del Comando USAR
*
* @param juego Game que representa el juego que esta en ejecución
* @param id String que representa el identificador del Item a usar
*/
public ComandoUsar(Game juego, String id){
super(VerbCommands.USAR);
this.id = id;
this.juego = juego;
}
/**
* Metodo sobrecargado que determina si el Comando es valido
*
* @return Booleano verdadero o falso segun sea el caso
*/
@Override
public boolean esValido() {
return super.esValido() && (!id.equals(""));
}
/**
* Procedimiento especifico del Comando USAR
*
*/
@Override
public boolean ejecutar() {
juego.usarObjeto(id);
return false;
}
}
| [
"[email protected]"
] | |
8c90551434c86d59bed769230aeb28bcf1f5d4ae | 32bc8628ab92d6e9b5a49f3ab6a8c6ca9b57c707 | /workspace/ui_test/demo/src/main/java/com/minxin/fangdai/UploadInfo.java | 6917d2c46001a757d9d9f0e051eeb37cab07b2be | [] | no_license | zhangdongxuan0227/minxindemo | 846ef0bf2dcec70cd00cbd3ceb570b9a7bda54bb | 29efa7f19b2d48671955f86282456e6a676ffb17 | refs/heads/master | 2021-01-18T09:21:53.853582 | 2017-08-15T08:58:56 | 2017-08-15T08:58:56 | 100,357,898 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,971 | java | package com.minxin.fangdai;
import com.minxin.Cache.Cache;
import com.minxin.util.WebElementUtil;
import com.minxin.zonghe.Login;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
/**
* Created by Administrator on 2017/3/3.
*/
public class UploadInfo {
private static WebDriver driver;
WebElementUtil we = new WebElementUtil();
Login login = new Login();
int num = 7;
//上传受理单
@Test
public void uploadDanJu(String url, String quanzhengren01, String diyapassword)throws Exception{
login.login(url, quanzhengren01, diyapassword, 0);
driver = Login.getDriver();
Thread.sleep(3000);
driver.findElement(By.xpath("//a[contains(text(),'权证人资料上传')]")).click();
driver.switchTo().frame("cont_right_show");
driver.findElement(By.id("q_realName")).sendKeys(Cache.name);
driver.findElement(By.id("searchButton")).click();
Thread.sleep(3000);
driver.findElement(By.xpath("//a[contains(text(),'上传受理单')]")).click();
for(int i=0; i < 3; i++){
if(i < 1){
this.fujian(driver, 7);
}else if(i==1){
this.fujian(driver, 8);
}else{
this.fujian(driver, 9);
}
}
driver.findElement(By.xpath("//input[@type='button' and @value='提交审核']")).click();
driver.findElement(By.xpath("//button[contains(text(), '确定')]")).click();
driver.quit();
System.out.printf("上传受理单完成!");
}
/**
* 权证人上传合同
* quanzhengren01 用户上传影像资料
*/
@Test
public void uploadInfo(String url, String quanzhengren01, String diyapassword) throws Exception {
login.login(url, quanzhengren01,diyapassword, 0);
driver = Login.getDriver();
Thread.sleep(3000);
driver.findElement(By.xpath("//a[contains(text(),'权证人资料上传')]")).click();
driver.switchTo().frame("cont_right_show");
driver.findElement(By.id("q_realName")).sendKeys(Cache.name);
driver.findElement(By.id("searchButton")).click();
Thread.sleep(3000);
driver.findElement(By.xpath("//a[contains(text(),'上传合同')]")).click();
Thread.sleep(3000);
driver.switchTo().frame("fileIframe0");
we.fujian(driver, 4, 2, 3);
driver.switchTo().defaultContent();
driver.switchTo().defaultContent();
driver.switchTo().frame("cont_right_show");
// 权证人
we.setSelectIndex(driver.findElement(By.id("empId")), 1);
// 点击提交审核
driver.findElement(By.xpath("//div[@class='list_cont']/dl/dd/input")).click();
Thread.sleep(300);
driver.findElement(By.xpath("//button[contains(text(),'确定')]")).click();
driver.switchTo().defaultContent();
driver.quit();
System.out.printf("权证人上传合同完成!");
}
public void fujian(WebDriver driver,int num) throws Exception {
Screen s = new Screen();
Pattern up = new Pattern("E:\\jenkins\\workspace\\ui_test\\demo\\data\\"+ num +".png");
s.find(up).right(35).click();
// 上传附件操作
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
String path = "E:\\jenkins\\workspace\\ui_test\\demo\\data\\Test.rar";
Pattern content = new Pattern("E:\\jenkins\\workspace\\ui_test\\demo\\data\\2.png");
s.type(content, path);
Pattern open = new Pattern("E:\\jenkins\\workspace\\ui_test\\demo\\data\\3.png");
if(s.find(open) != null){
s.click();
}
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
Thread.sleep(6000);
}
}
| [
"[email protected]"
] | |
36be1d079b6782485c95bd0bbf8278588ef22ef0 | 4a6c13a4378e730d969473acd2fab98536bffe59 | /gulimall-coupon/src/main/java/com/hua/gulimall/coupon/service/impl/CouponServiceImpl.java | 8441066bfa730e22480e8f63e488501b1df7054a | [] | no_license | xiaohua521/gulimall | c699fec6c0100425ff506f38e1b0acdf7cc96e8d | 1bf8948bae0aeb8535182522e54eb7d4d1268755 | refs/heads/main | 2023-02-03T01:04:39.086421 | 2020-12-26T07:02:56 | 2020-12-26T07:02:56 | 323,608,037 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 949 | java | package com.hua.gulimall.coupon.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hua.common.utils.PageUtils;
import com.hua.common.utils.Query;
import com.hua.gulimall.coupon.dao.CouponDao;
import com.hua.gulimall.coupon.entity.CouponEntity;
import com.hua.gulimall.coupon.service.CouponService;
@Service("couponService")
public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> implements CouponService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<CouponEntity> page = this.page(
new Query<CouponEntity>().getPage(params),
new QueryWrapper<CouponEntity>()
);
return new PageUtils(page);
}
} | [
"[email protected]"
] | |
185e053c4a310150ff5945b6e2fd3b10fc77bb1f | ca2509ead13053725d56e0d2554ffc9598bd1895 | /mypro/src/main/java/com/app1/webapp/controller/AlbumController.java | 459e7dc467c95f98a89360a5087130fd394d2ce5 | [
"Apache-2.0"
] | permissive | sftruelx/mypro | 8432f3416401068f2204d126ef0bb99e1c6c7fa8 | c6ae540fba73a1718814269d2111e1a1be3ff453 | refs/heads/master | 2021-01-10T04:16:30.674944 | 2016-01-10T12:37:11 | 2016-01-19T11:47:00 | 49,365,978 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,010 | java | package com.app1.webapp.controller;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.app1.model.Album;
import com.app1.service.AlbumManager;
import com.app1.util.MP3audio;
import com.app1.util.Pager;
@Controller
public class AlbumController extends BaseFormController {
@Autowired
AlbumManager albumManager;
@RequestMapping("/albumManage*")
public String showPage(ModelMap model, HttpServletRequest request) {
return "albumManage";
}
@ResponseBody
@RequestMapping("/albums*")
public Pager execute2(Album album, HttpServletRequest request, @RequestParam("page") int nowpage, @RequestParam("rows") int rows) {
Map<String, Object> map = new HashMap<String, Object>();
Pager p = albumManager.getAlbums(nowpage, rows, map);
return p;
}
@ResponseBody
@RequestMapping("/albumForm*")
public Map filesUpload(Album album, HttpServletRequest request) {
Calendar cal = Calendar.getInstance();
String savePath = cal.get(Calendar.YEAR) + "/" + cal.get(Calendar.DAY_OF_YEAR);
Map<String, String> map = new HashMap();
String msg = null;
try {
if (request.getParameter("delete") != null) {
albumManager.removeAlbum(album.getId());
saveMessage(request, getText("user.deleted", album.getAlbumName(), request.getLocale()));
map.put("success", "1");
} else {
String fileName = "";
MultipartFile[] files = album.getFiles();
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
if ("".equals(fileName)) {
fileName = saveFile(file, savePath);
} else {
fileName = fileName + ";" + saveFile(file, savePath);
}
}
}
if (album.getId() > 0) {
Album old = null;
old = albumManager.getAlbum(album.getId());
if (fileName != null) {
old.setImgPath(fileName);
}
old.setAlbumName(album.getAlbumName());
old.setAuthor(album.getAuthor());
old.setDescripe(album.getDescripe());
old.setPublishDate(album.getPublishDate());
old.setCreateTime(new Date());
old.setPublishDate(album.getPublishDate());
albumManager.saveAlbum(old);
} else {
album.setImgPath(fileName);
album.setCreateTime(new Date());
album.setPublishDate(new Date());
albumManager.saveAlbum(album);
}
}
} catch (Exception e) {
msg = e.getMessage();
}
map.put("errorMsg", msg);
return map;
}
}
| [
"[email protected]"
] | |
830ece0d0777021a9f8a902d2048e59abca1794e | 86404c82e7d8a4446e9ef8d54596f9fa85ee8334 | /src/main/java/org/mountainous/Wordlist.java | 28c8e48b53eb49e40cc8aaff1fbc474ba5d1ae57 | [
"Unlicense"
] | permissive | JonathanDavidArndt/boggle | d424d6a8063ed9bcff666eead46b4e84b76287b1 | 198a5c08ad2cd22ce50325e04f61be055db1a930 | refs/heads/master | 2021-01-22T04:01:37.564169 | 2017-02-09T21:17:22 | 2017-02-09T21:17:22 | 81,492,603 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,274 | java | /**
* Stores a word list. Each word in the list should contain only letters (A-Z,
* case in-sensitive). Some words will (hopefully) be found on the Boggle board.
*/
package org.mountainous;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
* @author JonathanDavid
*/
public class Wordlist extends Boggle {
public final static int MIN_WORD_LENGTH = 3;
public static final List<String> load(final String resourceName)
throws IOException {
InputStream dataStream = Boggle.class.getResourceAsStream(resourceName);
BufferedReader data = new BufferedReader(
new InputStreamReader(dataStream));
List<String> words = new ArrayList<String>();
String nextLine;
while (null != (nextLine = data.readLine())) {
// Process the next line according to Boggle standards.
nextLine = Boggle.removeNonLetters(nextLine.toLowerCase());
// Filter words that are too short.
if (MIN_WORD_LENGTH <= nextLine.length()) {
words.add(nextLine);
}
}
data.close();
return words;
}
}
| [
"[email protected]"
] | |
70624fbca6dfd160856688ba6626bf1129cdb833 | 9f3ea0d444db2aaf71628aba5ba3bbad43934545 | /src/main/java/com/Egietje/degeweldigemod/items/tools/CheeseHoe.java | 7d61b3685bbaa7d831707f772bc3621cbbb8c4d1 | [] | no_license | KokkieBeer/DeGeweldigeMod | 332adfd31286d8d240fa8d7ae7898a358b97f977 | 7cc5fa56cb834ed948877a565f73b3ee0ccd294c | refs/heads/master | 2021-01-12T04:15:13.732513 | 2017-04-11T17:05:45 | 2017-04-11T17:05:45 | 77,556,941 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 205 | java | package com.Egietje.degeweldigemod.items.tools;
import net.minecraft.item.ItemHoe;
public class CheeseHoe extends ItemHoe{
public CheeseHoe(ToolMaterial material) {
super(material);
}
}
| [
"[email protected]"
] | |
93de16714c0f82eb0f9e49d676acbdeaf912ee4a | d7130fdaf51db9b45347aeb77188c1ee26d8e56e | /SecTweaks/app/src/main/java/com/leo/salt/wallpaper/WallpaperPicker.java | 9d40876441e53cf4b18e6333603e20d904e66e97 | [] | no_license | FusionPlmH/Fusion-Project | 317af268c8bcb2cc6e7c30cf39a9cc3bc62cb84e | 19ac1c5158bc48f3013dce82fe5460d988206103 | refs/heads/master | 2022-04-07T00:36:40.424705 | 2020-03-16T16:06:28 | 2020-03-16T16:06:28 | 247,745,495 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,486 | java | package com.leo.salt.wallpaper;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.provider.Settings;
import android.support.design.widget.Snackbar;
import android.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.channels.WritableByteChannel;
import com.leo.salt.LeoApp;
import com.leo.salt.R;
import com.leo.salt.base.BasePreferenceFragment;
import static com.leo.salt.utils.Constants.JPEGWallpaper;
import static com.leo.salt.utils.Constants.WALLPAPER_DATA;
import static com.leo.salt.utils.Constants.WALLPAPER_DATA_PATH;
import static com.leo.salt.utils.NotificationUtils.showWallpaperNotification;
import static com.leo.salt.widget.DialogUtil.WallpaperInfo;
import static com.leo.salt.widget.DialogUtil.WallpaperSize;
import static com.leo.salt.widget.DialogUtil.WallpaperSuccess;
public abstract class WallpaperPicker extends Fragment {
private ImageView WallpaperView = null;
private Button Choose = null;
private Bitmap bitmap = null;
private FileOutputStream Storage_Path = null;
private EditText width;
private EditText height;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.wallpaper_picker, container, false);
return view;
}
FileChannel channel;
FileChannel channel2;
File CachePath = new File(WALLPAPER_DATA_PATH);
String SDwallpaperPath =JPEGWallpaper;
String StringPath = WALLPAPER_DATA;
File DataPath = new File(WALLPAPER_DATA);
public void onViewCreated( View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (this.CachePath.exists()) {
this.CachePath.setReadable(true, false);
this.CachePath.setWritable(true, false);
this.CachePath.setExecutable(true, false);
} else {
this.CachePath.mkdirs();
this.CachePath.setReadable(true, false);
this.CachePath.setWritable(true, false);
this.CachePath.setExecutable(true, false);
}
WallpaperView = (ImageView) view.findViewById(R.id.wallpaper_view);
Choose = (Button) view.findViewById(R.id.select_wallpaper);
Choose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivityForResult(new Intent("android.intent.action.PICK", MediaStore.Images.Media.EXTERNAL_CONTENT_URI), 1);
}
});
WallpaperInfo(getActivity());
}
public void onActivityResult(int i, int i2, Intent intent) {
int i3 = 1;
super.onActivityResult(i, i2, intent);
if (i == 1 && i2 == -1 && intent != null) {
int attributeInt;
String[] strArr = new String[]{"_data"};
Cursor query = getActivity().getContentResolver().query(intent.getData(), strArr, null, null, null);
query.moveToFirst();
String string = query.getString(query.getColumnIndex(strArr[0]));
query.close();
this.WallpaperView = (ImageView)getActivity().findViewById(R.id.wallpaper_view);
try {
attributeInt = new ExifInterface(string).getAttributeInt("Orientation", 0);
Matrix matrix = new Matrix();
if (attributeInt == 6) {
matrix.postRotate(90.0f);
} else if (attributeInt == 3) {
matrix.postRotate(180.0f);
} else if (attributeInt == 8) {
matrix.postRotate(270.0f);
}
this.Storage_Path = new FileOutputStream(JPEGWallpaper);
} catch (IOException e) {
e.printStackTrace();
}
this.bitmap = BitmapFactory.decodeFile(string);
this.width = (EditText) getActivity().findViewById(R.id.width_edit);
this.height = (EditText)getActivity().findViewById(R.id.height_edit);
if (((this.width.length() > 0 ? 1 : 0) & (this.width.length() > 0 ? 1 : 0)) != 0) {
int intValue = Integer.valueOf(this.width.getText().toString()).intValue();
int intValue2 = Integer.valueOf(this.height.getText().toString()).intValue();
attributeInt = intValue > 0 ? 1 : 0;
if (intValue2 <= 0) {
i3 = 0;
}
if ((attributeInt & i3) != 0) {
Bitmap createScaledBitmap = Bitmap.createScaledBitmap(this.bitmap, intValue, intValue2, false);
createScaledBitmap.compress(Bitmap.CompressFormat.JPEG, 90, this.Storage_Path);
this.WallpaperView.setImageBitmap(createScaledBitmap);
} else {
WallpaperSize(getActivity());
this.bitmap.compress(Bitmap.CompressFormat.JPEG, 90, this.Storage_Path);
this.WallpaperView.setImageBitmap(this.bitmap);
}
} else {
WallpaperSize(getActivity());
this.bitmap.compress(Bitmap.CompressFormat.JPEG, 90, this.Storage_Path);
this.WallpaperView.setImageBitmap(this.bitmap);
}
showWallpaperNotification(getActivity());
//WallpaperSnackbar(getActivity());
WallpaperView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onWallpaperDialog();
}
});
}
}
public void onWallpaperDialog(){
AlertDialog dialog = new AlertDialog.Builder(getActivity())
.setTitle(R.string.application_wallpaper)//设置对话框的标题
.setMessage(R.string.application_wallpaper_sumarry)//设置对话框的内容
//设置对话框的按钮
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
WallpaperUse();
} catch (IOException e) {
e.printStackTrace();
}
WallpaperSuccess(getActivity());
dialog.dismiss();
}
}).create();
dialog.show();
dialog.getWindow().setBackgroundDrawableResource(R.drawable.dialog_bg);
}
public abstract void WallpaperUse() throws IOException;
} | [
"[email protected]"
] | |
0e4c58e528876a1f54f045ce9a4ae46db2f5a581 | 26e0fc682baebfc14ec7fd4ca0eee279e73dadb2 | /Login.java | 929f50b09a22a3b23cda158a90d1678b3a26bd34 | [] | no_license | aym183/Online-Shopping-System | 201cad1e0475900e19ee462ce54bc499efe1f0f8 | ca42a0194b2e27ecec56df3f57ed19435a7d3ec3 | refs/heads/main | 2023-06-03T03:41:37.766414 | 2021-06-17T16:49:36 | 2021-06-17T16:49:36 | 377,899,220 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,590 | java |
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.io.*;
//Above are all the imports needed for this class
// Below is the definition of the class which alsp implements ActionListener
public class Login extends JFrame implements ActionListener {
/*This is the landing page of the application. When the Main class runs, this is the class that runs
* The user has 4 options of users to select from. These are displayed in the form of a dropdown list.
* One option takes the user to the Admin Window
* and the other 3 options takes the user to the Customer Window
*/
//Below are the initialized variables
protected static String Log;
protected JComboBox log;
protected JLabel log2;
//This class handles the deeper specification of the initialised variables and formation of window
public void LoginOperation(){
String [] validusers = {"user1", "user2", "user3", "user4"};
log = new JComboBox(validusers);
ImageIcon Image = new ImageIcon("aaron-burden-AvqpdLRjABs-unsplash.jpg");
log2 = new JLabel("Please choose any of the users to proceed:", Image, JLabel.RIGHT);
log2.setFont(new Font("Verdana", Font.BOLD, 18));
// ActionListener being added when any of the values from the JComboBox selected
log.addActionListener(this);
// Specifications of the layout and design of the window
this.add(log2);
this.add(log);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
this.setLayout(new FlowLayout());
this.pack();
this.setVisible(true);
this.getContentPane().setBackground(new Color(0,255,255));
}
/*
* Below is the ActionListener that gets implemented when an option is selected from the dropdown list
*/
@Override
public void actionPerformed(ActionEvent e) {
try {
/*
* The content of the textfile is taken with the help of a scanner
* and each row is split into separate arrays
*/
Scanner s = new Scanner(new File("UserAccounts.txt"));
// TODO Auto-generated catch block
ArrayList<String> list = new ArrayList<String>();
while (s.hasNext())
{
list.add(s.nextLine());
}
String[] line = list.get(0).split(",");
String[] line1 = list.get(1).split(",");
String[] line2 = list.get(2).split(",");
String[] line3 = list.get(3).split(",");
s.close();
/*this is the functionality that takes place when an option is selected from the dropdown list
* the user that has been chosen, takes you to another window and the information for that option
* will be stored in an array so that it can be used later on when logging into text file
* Error handling used by surrounding with try/catch
*
*/
if(e.getSource()==log) {
if (log.getSelectedItem().equals(line[1].trim())) {
JOptionPane.showMessageDialog(null, "You have successfully logged in as admin!");
AdminWindow wow = new AdminWindow();
this.setVisible(false);
}
else if(log.getSelectedItem().equals(line1[1].trim())) {
JOptionPane.showMessageDialog(null, "You have successfully logged in as customer!");
CustomerWindow newW = new CustomerWindow();
this.setVisible(false);
try(BufferedWriter output = new BufferedWriter(new FileWriter("ActivityLog.txt", true))){
Log = line1[0].toString()+ "," + line1[4].toString() + ",";
}catch (IOException e1) {
System.out.println("Exception Occurred:");
e1.printStackTrace();
}
}
else if(log.getSelectedItem().equals(line2[1].trim())) {
JOptionPane.showMessageDialog(null, "You have successfully logged in as customer!");
CustomerWindow newW = new CustomerWindow();
this.setVisible(false);
try(BufferedWriter output = new BufferedWriter(new FileWriter("ActivityLog.txt", true))){
Log = line2[0].toString()+ "," + line2[4].toString() + ",";
}catch (IOException e1) {
System.out.println("Exception Occurred:");
e1.printStackTrace();
}
}
else if (log.getSelectedItem().equals(line3[1].trim())) {
JOptionPane.showMessageDialog(null, "You have successfully logged in as customer!");
CustomerWindow newW = new CustomerWindow();
this.setVisible(false);
try(BufferedWriter output = new BufferedWriter(new FileWriter("ActivityLog.txt", true))){
Log = line3[0].toString()+ "," + line3[4].toString() + ",";
}catch (IOException e1) {
System.out.println("Exception Occurred:");
e1.printStackTrace();
}
}
}
}catch (FileNotFoundException e1){
System.out.println("Wrong");
}
}
}
| [
"[email protected]"
] | |
60cdd531d7ce1d44970ac1cec87bfd2a92930b81 | a38e3b9344ca299bc598e062704df5b9784bcb67 | /fender-sb-bdd/branches/three valued logic branch/fender-sb-bdd/src/fsb/ast/PrimitiveSharedVal.java | 3129b064e65e4592ffa6d68168883fd4b6876acf | [
"MIT"
] | permissive | hetmeter/awmm | 274c22d9cd64adbbe85ac43636e0caf3e022c8ff | 8d65b1246898b27db1ac5a6542465f71e27b1603 | refs/heads/master | 2020-04-19T09:38:35.990080 | 2015-08-16T16:01:32 | 2015-08-16T16:01:32 | 30,911,391 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 325 | java | package fsb.ast;
import fsb.explore.SBState;
public class PrimitiveSharedVal implements SharedVal {
String name;
public PrimitiveSharedVal(String name)
{
this.name = name;
}
@Override
public String evalShared(SBState s, int pid) {
return name;
}
@Override
public String toString()
{
return name;
}
}
| [
"[email protected]"
] | |
95160330ccc6230e245b8f16ece7313e5ae956c0 | 2e11a1e8831aada2e9ffb1ca0542e6207c9705e4 | /src/org/omg/CosNaming/Binding.java | 6378c57bf71d83d2c6f670229a67832de44a2a28 | [] | no_license | fengx20/java-source | 29c4403b8bacbc38693dd9ef6b2909ce6836eca1 | e4139d00ac7561fb3d7b763dd1416b53408b444b | refs/heads/master | 2023-06-19T04:48:41.183079 | 2021-07-10T15:20:08 | 2021-07-10T15:20:08 | 384,728,236 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 766 | java | package org.omg.CosNaming;
/**
* org/omg/CosNaming/Binding.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from c:/re/workspace/8-2-build-windows-amd64-cygwin/jdk8u211/12973/corba/src/share/classes/org/omg/CosNaming/nameservice.idl
* Monday, April 1, 2019 8:55:57 PM PDT
*/
public final class Binding implements org.omg.CORBA.portable.IDLEntity
{
public org.omg.CosNaming.NameComponent binding_name[] = null;
// name
public org.omg.CosNaming.BindingType binding_type = null;
public Binding ()
{
} // ctor
public Binding (org.omg.CosNaming.NameComponent[] _binding_name, org.omg.CosNaming.BindingType _binding_type)
{
binding_name = _binding_name;
binding_type = _binding_type;
} // ctor
} // class Binding
| [
"[email protected]"
] | |
3d069adbbe377c697ebc1c2f20e8dd407a7d5043 | 677543c0c3521462b4edf58feba3fe6566128377 | /nonogram/src/com/streetj/nonogram/GameUpdateResult.java | 17eac030b8234b7fb74af9eebddfbdf1ecb71d17 | [] | no_license | jjstreet/nonogram | 5bf170e81f8aabb40c55d153c3d595ddacc507a3 | ad1972fc902bc0dfe8f59293631e73f163f4a79a | refs/heads/master | 2021-01-02T08:31:43.594118 | 2013-03-14T02:42:37 | 2013-03-14T02:42:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 555 | java | package com.streetj.nonogram;
public class GameUpdateResult {
public final boolean rowCluesUpdated;
public final boolean colCluesUpdated;
public final boolean gameCompleted;
public GameUpdateResult(boolean rowCluesUpdated, boolean colCluesUpdated) {
this(rowCluesUpdated, colCluesUpdated, false);
}
public GameUpdateResult(boolean rowCluesUpdate, boolean colCluesUpdated, boolean gameCompleted) {
this.rowCluesUpdated = rowCluesUpdate;
this.colCluesUpdated = colCluesUpdated;
this.gameCompleted = gameCompleted;
}
}
| [
"[email protected]"
] | |
e12fa9f47b67107b4185a0e75d2f16ff6868cba0 | 4feee031cdd32fbc6a07e871b47338ac42f457de | /src/main/java/com/hanafn/openapi/portal/views/dto/QnaRequest.java | 7a46c3929b8cec84de80c4388c30952e5af219b6 | [] | no_license | wjsgmlwls79/Hanafn_OpenApi_Portal_Server | 078c6100603214e1e6d45de1f95139ea4e0e1916 | 564c89d76b8897a3cae3b2fe2365ae4c8e07cb7e | refs/heads/master | 2022-04-08T05:52:35.058789 | 2020-01-23T14:38:53 | 2020-01-23T14:38:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 892 | java | package com.hanafn.openapi.portal.views.dto;
import lombok.Data;
import java.util.List;
@Data
public class QnaRequest {
private String seqNo;
private String compNm;
private String statCd;
private String qnaType;
private String userKey;
private String userNm;
private String userTel;
private String apiNm;
private String hfnCd;
private String reqTitle;
private String reqCtnt;
private String uploadFile01;
private String uploadFile02;
private String userId;
private String regDttm;
private String answerYn;
private String answer;
private String modId;
private String modDttm;
private String searchQna;
private int pageIdx;
private int pageSize;
private int pageOffset;
private String siteCd;
@Data
public static class QnaDeleteRequest {
private List<String> seqList;
}
}
| [
"[email protected]"
] | |
1c1d266c4b954071e8b75e3d9da254aaeba7725e | 46b85208c7dfd1249ff5c2f263cdb0e742bff8da | /solon-projects/solon-cloud/solon.cloud/src/main/java/org/noear/solon/cloud/model/BreakerException.java | 8bdea125f8fa31f077c57a7b8833d0b7a76182f6 | [
"Apache-2.0"
] | permissive | noear/solon | 1c0a78c5ab2bec45a67fcf772f582f9cb4894fab | 63f3f49cddcbfa8bd6d596998735f0704e8d43f8 | refs/heads/master | 2023-08-31T09:10:32.303640 | 2023-08-30T14:13:27 | 2023-08-30T14:13:27 | 140,086,420 | 1,687 | 187 | Apache-2.0 | 2023-09-10T10:31:54 | 2018-07-07T13:23:50 | Java | UTF-8 | Java | false | false | 282 | java | package org.noear.solon.cloud.model;
/**
* 断路器异常
*
* @author noear
* @since 1.3
*/
public class BreakerException extends Exception {
public BreakerException() {
super();
}
public BreakerException(Throwable cause) {
super(cause);
}
}
| [
"[email protected]"
] | |
c30265d2e2bd9bdc1242306cec7ee979b7d41ba4 | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/XWIKI-8281-4-20-FEMO-WeightedSum:TestLen:CallDiversity/com/xpn/xwiki/web/EditAction_ESTest.java | 4c568623df232b05af91dbab0c96232bf1790d54 | [] | no_license | STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application | cf118b23ecb87a8bf59643e42f7556b521d1f754 | 3bb39683f9c343b8ec94890a00b8f260d158dfe3 | refs/heads/master | 2022-07-29T14:44:00.774547 | 2020-08-10T15:14:49 | 2020-08-10T15:14:49 | 285,804,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 544 | java | /*
* This file was automatically generated by EvoSuite
* Mon Jan 20 19:44:31 UTC 2020
*/
package com.xpn.xwiki.web;
import org.junit.Test;
import static org.junit.Assert.*;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true)
public class EditAction_ESTest extends EditAction_ESTest_scaffolding {
@Test
public void notGeneratedAnyTest() {
// EvoSuite did not generate any tests
}
}
| [
"[email protected]"
] | |
763d5df25f1e172bcc1fd5173c317b40f466cf99 | e74b7ea60c3002cbcf6d6317e71904a16acdbccf | /src/es/cip/bussines/dao/control/ProductoEsperadoJpaController.java | 772e8f5a1c3936d1400420849f6ee995a53d25d9 | [] | no_license | macgregor83/Cip | 6ffdf8388f55b796ee96a4fe50483fcb029525f0 | 659e9b2989ed02a01f8c49b4ddf1eb52fcac3a44 | refs/heads/master | 2021-05-07T07:51:05.816051 | 2017-12-15T01:12:53 | 2017-12-15T01:12:53 | 109,214,919 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,921 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package es.cip.bussines.dao.control;
import es.cip.bussines.dao.control.exceptions.NonexistentEntityException;
import es.cip.bussines.dao.model.ProductoEsperado;
import es.cip.util.Cte;
import java.io.Serializable;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import javax.persistence.EntityNotFoundException;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
/**
*
* @author iMac
*/
public class ProductoEsperadoJpaController implements Serializable {
public ProductoEsperadoJpaController(EntityManagerFactory emf) {
this.emf = emf;
}
private EntityManagerFactory emf = null;
public ProductoEsperadoJpaController() {
this.emf = javax.persistence.Persistence.createEntityManagerFactory(Cte.Persistence_Unit_Name);
}
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void create(ProductoEsperado productoEsperado) {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
em.persist(productoEsperado);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}
public void edit(ProductoEsperado productoEsperado) throws NonexistentEntityException, Exception {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
productoEsperado = em.merge(productoEsperado);
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = productoEsperado.getId();
if (findProductoEsperado(id) == null) {
throw new NonexistentEntityException("The productoEsperado with id " + id + " no longer exists.");
}
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void destroy(Integer id) throws NonexistentEntityException {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
ProductoEsperado productoEsperado;
try {
productoEsperado = em.getReference(ProductoEsperado.class, id);
productoEsperado.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The productoEsperado with id " + id + " no longer exists.", enfe);
}
em.remove(productoEsperado);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}
public List<ProductoEsperado> findProductoEsperadoEntities() {
return findProductoEsperadoEntities(true, -1, -1);
}
public List<ProductoEsperado> findProductoEsperadoEntities(int maxResults, int firstResult) {
return findProductoEsperadoEntities(false, maxResults, firstResult);
}
private List<ProductoEsperado> findProductoEsperadoEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(ProductoEsperado.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
public ProductoEsperado findProductoEsperado(Integer id) {
EntityManager em = getEntityManager();
try {
return em.find(ProductoEsperado.class, id);
} finally {
em.close();
}
}
public int getProductoEsperadoCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<ProductoEsperado> rt = cq.from(ProductoEsperado.class);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
}
| [
"iMac@LAPTOP-MJK7SBQ5"
] | iMac@LAPTOP-MJK7SBQ5 |
9ea5ba283c835fca92577eb865c0ba46a72884e2 | 786739f6d880692d88a17f8d5cd29c2063a5118d | /javaArrays&Algorithms/src/sortingAlorithms/MergeSort.java | 5202115df80053a4d940093b07d5b087a387cab5 | [] | no_license | shahidaLucky/BNYClassProjects | 63b94ef3d1bf4ff6f1f548251b0590690b8a271c | 0e451885150b3e55996a88b8200e32502b256070 | refs/heads/master | 2020-05-18T04:12:55.977334 | 2019-04-30T03:38:19 | 2019-04-30T03:38:19 | 184,165,323 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,438 | java | package sortingAlorithms;
import java.util.Arrays;
public class MergeSort {
public static void main(String[] args) {
int[] arr = { 10, 6, 8, 5, 7, 3, 4 };
mergeSort(arr);
System.out.println(Arrays.toString(arr));
}
public static void mergeSort(int[] arr) {
// Checking if array can be divided
if (arr.length < 2) {
return;
}
int mid = arr.length / 2;
// Creating left sub-array
int[] leftArr = new int[mid];
// Creating right sub-array
int[] rightArr = new int[arr.length - mid];
// Initializing left sub-array
for (int i = 0; i < mid; i++) {
leftArr[i] = arr[i];
}
// Initializing right sub-array
for (int i = mid; i < arr.length; i++) {
rightArr[i - mid] = arr[i];
}
// Invoking recursive method for the left sub-array
mergeSort(leftArr);
// Invoking recursive method for the right sub-array
mergeSort(rightArr);
// Invoking merge method to sort and merge
merge(arr, leftArr, rightArr);
}
public static void merge(int[] arr, int[] leftArr, int[] rightArr) {
int i = 0;
int j = 0;
int k = 0;
while (i < leftArr.length && j < rightArr.length) {
if (leftArr[i] <= rightArr[j]) {
arr[k++] = leftArr[i++];
} else {
arr[k++] = rightArr[j++];
}
}
while (i < leftArr.length) {
arr[k++] = leftArr[i++];
}
while (j < rightArr.length) {
arr[k++] = rightArr[j++];
}
}
}
| [
"[email protected]"
] | |
b212ba5aec1e16b0671bcf80bbae890191560d70 | ca2bc24d0ca7c169c9d1065bbf51a060e6b2dc87 | /src/main/java/com/jialong/powersite/modular/system/model/response/BaseResp.java | 74cf2323dcc7c3a0317c1c40695118e0659e1dd2 | [] | no_license | cenwei1234/powersite | 13bf7ec846d2b628cc349d429d852c2776ff3d78 | 0b4ef024a33b3cf7806a4e5157ded099ab212575 | refs/heads/master | 2022-06-22T22:58:11.620811 | 2020-04-05T13:57:39 | 2020-04-05T13:57:39 | 248,998,448 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 865 | java | package com.jialong.powersite.modular.system.model.response;
import com.fasterxml.jackson.annotation.JsonInclude;
public class BaseResp {
@JsonInclude(JsonInclude.Include.NON_NULL)
private String errorCode = "0";
@JsonInclude(JsonInclude.Include.NON_NULL)
private String errorMsg;
@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer totalCount;
public Integer getTotalCount() {
return totalCount;
}
public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
}
| [
"[email protected]"
] | |
9aedb6e3d648a6b02eba7d51b1d92f8d5dbea890 | c880312ef3e31cc4557569d12bb303a1a81e6837 | /AP CS/Lab15-Sprites Krista Roberts 3A/Sprites starter code and images/World.java | a423c3ae7c4c5c9b6997991fac9847370ee1654b | [] | no_license | Kris-Rose/High-School-Classwork | ec412113ae201cd560b37ffce16ed409562d534a | 6e3a1e41b7cd214633e56c211fad12ad42bd6a01 | refs/heads/master | 2022-10-14T13:30:09.269526 | 2020-06-14T20:57:42 | 2020-06-14T20:57:42 | 272,142,480 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,696 | java | import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.List;
public class World
{
public static void main(String[] args)
{
Display display = new Display(500, 500);
display.run();
}
private List<Sprite> sprites;
private int width;
private int height;
/** make a World with a default size 500 x 500 */
public World()
{
this(500, 500);
}
public World(int width, int height)
{
this.width = width;
this.height = height;
this.sprites = new ArrayList<>();
/*
* Student code here
*/
}
public void stepAll()
{
for (int i = 0; i < sprites.size(); i++)
{
Sprite s = sprites.get(i);
s.step(this);
}
}
public int getWidth()
{
return width;
}
public int getHeight()
{
return height;
}
public int getNumSprites()
{
return sprites.size();
}
public Sprite getSprite(int index)
{
return sprites.get(index);
}
public void mouseClicked(int x, int y)
{
System.out.println("mouseClicked: " + x + ", " + y);
}
/**
* the display instructs the World (which contains all the Sprites)
* which key has been pressed
*/
public void keyPressed(int key)
{
System.out.println("key pressed: " + key);
}
public void keyReleased(int key)
{
System.out.println("key released: " + key);
}
public String getTitle()
{
return "World";
}
public void paintComponent(Graphics g)
{
g.setColor(Color.BLACK);
g.fillRect(0, 0, width, height);
for (int i = 0; i < sprites.size(); i++)
{
Sprite sprite = sprites.get(i);
g.drawImage(Display.getImage(sprite.getImage()),
(int)sprite.getLeft(), (int)sprite.getTop(),
sprite.getWidth(), sprite.getHeight(), null);
}
}
}
| [
"[email protected]"
] | |
4e16719832c54dccf716c225a1d06e37ef341911 | dd697ff49f4a6d92c8be4760c134ebc672d8874e | /src/main/java/com/ecommerce/controller/CategoryController.java | 854579ea71ec536692fc2a48493785e33ee92dbf | [] | no_license | karunchinna/nfv | fdbfdfc32e5de7934fab16454007bac976c70c00 | 4ab31380ac6fc9f5de605c4f2473a5b07654a921 | refs/heads/master | 2021-07-10T09:48:00.968070 | 2017-10-12T10:45:49 | 2017-10-12T10:45:49 | 106,679,178 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,221 | java | package com.ecommerce.controller;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.ecommerce.entity.Category;
import com.ecommerce.repository.CategoryRepository;
@RestController
@RequestMapping(value = "/CategoryController")
public class CategoryController implements Serializable{
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(ProductController.class);
@Resource
CategoryRepository categoryRepository;
/* <----------##########..........Category API..........##########----------> */
@RequestMapping(value = "/getAllCategory" )
@ResponseBody
public ResponseEntity<Iterable<Category>> getAllCategory()
{
System.out.println("##########......In Side Get All Category API.....$$$$$$$$$$");
logger.debug("********************************************************************");
logger.debug("Entry : getAllCategory ::" + "::" + System.currentTimeMillis());
logger.debug("********************************************************************");
try
{
List<Category> categoryList = (List<Category>) categoryRepository.findAll();
System.out.println(categoryList.get(0).getCategoryId()+categoryList.get(0).getCategoryName());
if(categoryList.isEmpty())
{
return new ResponseEntity<Iterable<Category>>(HttpStatus.NOT_FOUND);
}
else
{
return new ResponseEntity<Iterable<Category>>(categoryList , HttpStatus.OK);
}
}
catch(Exception error)
{
error.printStackTrace();
System.out.println(error.getMessage());
return new ResponseEntity<Iterable<Category>>(HttpStatus.BAD_REQUEST);
}
finally
{
logger.debug("********************************************************************");
logger.debug("Exit : getAllCategory ::" + "::" + System.currentTimeMillis());
logger.debug("********************************************************************");
}
}
@RequestMapping(value = "/addCategory" )
@ResponseBody
public ResponseEntity<String> addCategory(@RequestBody Category category)
{
System.out.println("##########.....In Side Add Category API.....$$$$$$$$$$");
logger.debug("********************************************************************");
logger.debug("Entry : addCategory ::" + "::" + System.currentTimeMillis());
logger.debug("********************************************************************");
try
{
System.out.println(category.getCategoryId()+ " : " + category.getCategoryName());
categoryRepository.save(category);
return new ResponseEntity<String>("Category Details Added Successfully..." , HttpStatus.OK);
}
catch(Exception error)
{
error.printStackTrace();
System.out.println(error.getMessage());
return new ResponseEntity<String>("Unable To Add Category Details...", HttpStatus.BAD_REQUEST);
}
finally
{
logger.debug("********************************************************************");
logger.debug("Exit : addCategory ::" + "::" + System.currentTimeMillis());
logger.debug("********************************************************************");
}
}
@RequestMapping(value = "/updateCategory" , method = RequestMethod.PUT)
@ResponseBody
public ResponseEntity<String> updateCategory(@RequestBody Category category)
{
System.out.println("##########.....In Side Add Category API.....$$$$$$$$$$");
logger.debug("********************************************************************");
logger.debug("Entry : updateCategory ::" + "::" + System.currentTimeMillis());
logger.debug("********************************************************************");
try
{
System.out.println(category.getCategoryId() + " : " + category.getCategoryName());
Category Category2 = categoryRepository.findOne(category.getCategoryId());
if(Category2 != null)
{
Category2 = categoryRepository.save(category);
return new ResponseEntity<String>("Category Details Updated Successfully..." , HttpStatus.OK);
}
else
{
return new ResponseEntity<String>("Category Details Not Found..." , HttpStatus.NOT_FOUND);
}
}
catch(Exception error)
{
error.printStackTrace();
System.out.println(error.getMessage());
return new ResponseEntity<String>("Unable To Update Categoty Details..." , HttpStatus.BAD_REQUEST);
}
finally
{
logger.debug("********************************************************************");
logger.debug("Exit : updateCategory ::" + "::" + System.currentTimeMillis());
logger.debug("********************************************************************");
}
}
@RequestMapping(value = "/deleteCategory" , method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<String> deleteCategory(@RequestBody Category Category)
{
System.out.println("##########.....In Side Delete Category API.....$$$$$$$$$$");
logger.debug("********************************************************************");
logger.debug("Entry : deleteCategory ::" + "::" + System.currentTimeMillis());
logger.debug("********************************************************************");
try
{
System.out.println(Category.getCategoryId() );
categoryRepository.delete(Category);
return new ResponseEntity<String>("Category Details Deleted Successfully...", HttpStatus.OK);
}
catch(Exception error)
{
error.printStackTrace();
System.out.println(error.getMessage());
return new ResponseEntity<String>("Category Details Not Found...", HttpStatus.NOT_FOUND);
}
finally
{
logger.debug("********************************************************************");
logger.debug("Exit : deleteCategory ::" + "::" + System.currentTimeMillis());
logger.debug("********************************************************************");
}
}
@RequestMapping(value = "/getAllCategories" , method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<Iterable<String>> getAllCategories()
{
System.out.println("##########......In Side Get All Category (String) API.....$$$$$$$$$$");
logger.debug("********************************************************************");
logger.debug("Entry : getAllCategories ::" + "::" + System.currentTimeMillis());
logger.debug("********************************************************************");
try
{
List<Category> categoryList = (List<Category>) categoryRepository.findAll();
List<String> categoryListFromDB = new ArrayList<String>();
System.out.println(categoryList.get(0).getCategoryId()+categoryList.get(0).getCategoryName());
if(categoryList.isEmpty())
{
return new ResponseEntity<Iterable<String>>(HttpStatus.NOT_FOUND);
}
else
{
for(Category category : categoryList)
{
String categoryName = category.getCategoryName();
categoryListFromDB.add(categoryName);
}
return new ResponseEntity<Iterable<String>>(categoryListFromDB, HttpStatus.OK);
}
}
catch(Exception error)
{
error.printStackTrace();
System.out.println(error.getMessage());
return new ResponseEntity<Iterable<String>>(HttpStatus.BAD_REQUEST);
}
finally
{
logger.debug("********************************************************************");
logger.debug("Exit : getAllCategories ::" + "::" + System.currentTimeMillis());
logger.debug("********************************************************************");
}
}
}
| [
"[email protected]"
] | |
e6e513d25613cabacedc3f487454d93ea0c92684 | 941dc361902285330fecb00b3185a73fc5f1728c | /user_login/src/main/java/com/cornan/entity/User.java | b640f0c06a96c729ca02a09f2b6b2d516aba0de6 | [] | no_license | CornanZZ/JavaWeb | 7757412de6800d1ce38870bab96b07764fe61a20 | f80ee2ef43d611d72c084337ba7db9977eef4d50 | refs/heads/master | 2022-12-16T00:26:47.029337 | 2020-09-20T12:58:54 | 2020-09-20T12:58:54 | 286,000,813 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,340 | java | package com.cornan.entity;
import lombok.Data;
import lombok.experimental.Accessors;
//import java.sql.DatabaseMetaData;
import java.io.Serializable;
import java.util.Date;
@Data
@Accessors(chain = true)
public class User implements Serializable {
private String id;
private String username;
private String realname;
private String password;
private String sex;
private Date registerTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id.toString();
}
public String getUsername() {
return username;
}
public void setUsername(String name) {
this.username = name;
}
public String getRealname() {
return realname;
}
public void setRealname(String name) {
this.realname = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public Date getRegisterTime() {
return registerTime;
}
public void setRegisterTime(Date date) {
this.registerTime = date;
}
}
| [
"[email protected]"
] | |
6706f2f91f2ad0303d3a047e410cb5c83cfdbab9 | 8c0510be797186bb0037b169f5bea9a676c91f11 | /app/src/main/java/biz/riverone/ohzappa/common/MyPagerAdapterBase.java | f9d5e9dd9b310da69c939f7713e70d18d316d805 | [] | no_license | Riverone12/OhZappa | 31b3466373e95bb598d2d2e8c3b11825f3b733b1 | 47260b8a519cc00ca01fb6615f3557e48da74882 | refs/heads/master | 2021-05-09T12:33:05.018155 | 2018-02-16T12:38:31 | 2018-02-16T12:38:31 | 119,006,809 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,683 | java | package biz.riverone.ohzappa.common;
import android.support.v4.view.PagerAdapter;
import android.util.SparseBooleanArray;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
*
* Created by kawahara on 2018/01/08.
*/
public abstract class MyPagerAdapterBase<T> extends PagerAdapter {
private ArrayList<IdentifiedItem<T>> items;
private final Object lock = new Object();
private final IdentifiedItemFactory<T> identifiedItemFactory;
@SuppressWarnings("WeakerAccess")
public MyPagerAdapterBase() {
this(new ArrayList<T>());
}
@SuppressWarnings("unused")
@SafeVarargs
public MyPagerAdapterBase(T... items) {
this(new ArrayList<>(Arrays.asList(items)));
}
@SuppressWarnings("WeakerAccess")
public MyPagerAdapterBase(List<T> items) {
identifiedItemFactory = new IdentifiedItemFactory<>(0);
this.items = identifiedItemFactory.createList(items);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
return items.get(position);
}
/**
* Adds the specified item at the end of the array.
*
* @param item The item to add at the end of the array.
*/
public void add(T item) {
synchronized (lock) {
items.add(identifiedItemFactory.create(item));
}
notifyDataSetChanged();
}
/**
* Adds the specified item at the specified position of the array.
*
* @param item The item to add at the specified position of the array.
*/
public void add(int index, T item) {
synchronized (lock) {
items.add(index, identifiedItemFactory.create(item));
}
itemPositionChangeChecked = new SparseBooleanArray(this.items.size());
notifyDataSetChanged();
}
/**
* Adds the specified items at the end of the array.
*
* @param items The items to add at the end of the array.
*/
@SuppressWarnings("unused")
public void addAll(T... items) {
synchronized (lock) {
this.items.addAll(identifiedItemFactory.createList(items));
}
itemPositionChangeChecked = new SparseBooleanArray(this.items.size());
notifyDataSetChanged();
}
/**
* Adds the specified items at the end of the array.
*
* @param items The items to add at the end of the array.
*/
@SuppressWarnings("unused")
public void addAll(List<T> items) {
synchronized (lock) {
this.items.addAll(identifiedItemFactory.createList(items));
}
itemPositionChangeChecked = new SparseBooleanArray(this.items.size());
notifyDataSetChanged();
}
/**
* Removes the specified item from the array.
*
* @param position The item position to be removed
* @return true if this items was modified by this operation, false otherwise.
* @throws IndexOutOfBoundsException if position < 0 || position >= getCount()
*/
public void remove(int position) throws IndexOutOfBoundsException {
synchronized (lock) {
items.remove(position);
}
itemPositionChangeChecked = new SparseBooleanArray(items.size());
notifyDataSetChanged();
}
/**
* Remove all elements from the list.
*/
public void clear() {
synchronized (lock) {
items.clear();
}
itemPositionChangeChecked = new SparseBooleanArray(items.size());
notifyDataSetChanged();
}
/**
* Get the data item associated with the specified position in the data set.
*
* @param position Position of the item whose data we want within the adapter's
* data set.
* @return The data at the specified position.
*/
public T getItem(int position) {
return items.get(position).item;
}
/**
* Returns the position of the specified item in the array.
*
* @param item The item to retrieve the position of.
* @return The position of the specified item.
*/
@SuppressWarnings("unused")
public int getPosition(T item) {
for (int i = 0; i < items.size(); i++) {
if (items.get(i).item == item) {
return i;
}
}
return -1;
}
/**
* {@inheritDoc}
*/
@Override
public int getItemPosition(Object item) {
if (!items.contains(item)) {
return POSITION_NONE;
} else if (itemPositionChangeChecked.size() != items.size()) {
int newPos = items.indexOf(item);
int ret = itemPositionChangeChecked.get(newPos) ? POSITION_UNCHANGED : newPos;
itemPositionChangeChecked.put(newPos, true);
return ret;
} else {
return POSITION_UNCHANGED;
}
}
/**
* {@inheritDoc}
*/
@Override
public int getCount() {
return items.size();
}
IdentifiedItem<T> getItemWithId(int position) {
return items.get(position);
}
ArrayList<IdentifiedItem<T>> getItemsWithId() {
return items;
}
ArrayList<T> getItems() {
ArrayList<T> list = new ArrayList<>();
for (IdentifiedItem<T> item : items) {
list.add(item.item);
}
return list;
}
void setItems(List<T> items) {
this.items = identifiedItemFactory.createList(items);
notifyDataSetChanged();
}
private SparseBooleanArray itemPositionChangeChecked = new SparseBooleanArray();
private static class IdentifiedItemFactory<T> {
private long lastId;
IdentifiedItemFactory(long firstId) {
lastId = firstId;
}
IdentifiedItem<T> create(T item) {
return new IdentifiedItem(lastId++, item);
}
ArrayList<IdentifiedItem<T>> createList(List<T> items) {
ArrayList<IdentifiedItem<T>> list = new ArrayList();
for (T item : items) {
list.add(create(item));
}
return list;
}
@SafeVarargs
final ArrayList createList(T... items) {
return createList(new ArrayList<>(Arrays.asList(items)));
}
}
static class IdentifiedItem<T> {
long id;
T item;
public IdentifiedItem(long id, T item) {
this.id = id;
this.item = item;
}
@Override
public String toString() {
return "IdentifiedItem{" +
"id=" + id +
", item=" + item +
'}';
}
}
}
| [
"[email protected]"
] | |
fe84b4bad811d2903d453e1e4c56246bc0b73f7a | 97f62047aa43fe998deaed6a23ecd5ff4010c09c | /app/src/main/java/com/bendani/bibliomania/generic/presentation/customview/FontFitEditText.java | fbcbf2d289087d313cfa76bd70dcd58cbc4ce4db | [] | no_license | garagepoort/BiblioMania-Mobile | 3be8ee992cad2669d522cda93e98d11402d1541a | 573123af4945f6f82bf2402ad30550b71f92ca8f | refs/heads/master | 2020-03-29T12:59:07.539492 | 2017-07-25T20:16:00 | 2017-07-25T20:16:00 | 39,695,544 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,231 | java | package com.bendani.bibliomania.generic.presentation.customview;
import android.content.Context;
import android.graphics.Paint;
import android.util.TypedValue;
import android.widget.EditText;
public class FontFitEditText extends EditText {
public FontFitEditText(Context context) {
super(context);
initialise();
}
private void initialise() {
mTestPaint = new Paint();
mTestPaint.set(this.getPaint());
//max size defaults to the initially specified text size unless it is too small
}
/* Re size the font so the specified text fits in the text box
* assuming the text box is the specified width.
*/
private void refitText(String text, int textWidth)
{
if (textWidth <= 0)
return;
int targetWidth = textWidth - this.getPaddingLeft() - this.getPaddingRight();
float hi = 300;
float lo = 2;
final float threshold = 0.5f; // How close we have to be
mTestPaint.set(this.getPaint());
while((hi - lo) > threshold) {
float size = (hi+lo)/2;
mTestPaint.setTextSize(size);
if(mTestPaint.measureText(text) >= targetWidth)
hi = size; // too big
else
lo = size; // too small
}
// Use lo so that we undershoot rather than overshoot
this.setTextSize(TypedValue.COMPLEX_UNIT_PX, lo);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
int height = getMeasuredHeight();
refitText(this.getText().toString(), parentWidth);
this.setMeasuredDimension(parentWidth, height);
}
@Override
protected void onTextChanged(final CharSequence text, final int start, final int before, final int after) {
refitText(text.toString(), this.getWidth());
}
@Override
protected void onSizeChanged (int w, int h, int oldw, int oldh) {
if (w != oldw) {
refitText(this.getText().toString(), w);
}
}
//Attributes
private Paint mTestPaint;
} | [
"[email protected]"
] | |
e37dfa6eac221209e8fa410ee62644cf504d623b | cd2eb50f8cad8b5122379e31aedef95888fa561a | /src/main/java/de/nosebrain/widget/cafeteria/parser/KasselParser.java | a213d7255a276987e1780393d555588796921bc8 | [] | no_license | nosebrain/cafeteria-menu-service | d3eef9ec2754b26b18b01341304dfc68c440e5cc | b80211823fd5f39dcebacdc05c086d85dce95820 | refs/heads/master | 2022-12-27T08:03:46.009227 | 2020-09-27T01:16:03 | 2020-09-27T01:16:03 | 234,960,436 | 0 | 0 | null | 2022-12-16T06:23:47 | 2020-01-19T20:24:36 | HTML | UTF-8 | Java | false | false | 3,167 | java | package de.nosebrain.widget.cafeteria.parser;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import de.nosebrain.widget.cafeteria.model.Cafeteria;
import de.nosebrain.widget.cafeteria.model.Day;
import de.nosebrain.widget.cafeteria.model.Menu;
/**
*
* @author nosebrain
*/
public class KasselParser extends AbstractMenuParser {
private static final Pattern DATE_PATTERN = Pattern.compile("[0-9]{1,2}\\.[0-9]{1,2}\\.");
private static final Pattern YEAR_PATTERN = Pattern.compile("[0-9]{4}\\s*");
private static final String DATE_FORMAT = "dd.MM.yyyy";
@Override
protected Cafeteria extractInformations(final Document document, final int week) throws Exception {
/*
* before parsing the file check if the requested week equals week in file
*/
final Elements select = document.select("table tr");
final String weekString = document.select("h4").text();
final Matcher matcher = DATE_PATTERN.matcher(weekString);
matcher.find();
final Matcher yearMatcher = YEAR_PATTERN.matcher(weekString);
yearMatcher.find();
final String mondayDate = matcher.group(0) + yearMatcher.group(0);
final Date date = new SimpleDateFormat(DATE_FORMAT).parse(mondayDate);
final Calendar mondayCalendar = Calendar.getInstance();
mondayCalendar.setTime(date);
final int weekOfSource = mondayCalendar.get(Calendar.WEEK_OF_YEAR);
if (weekOfSource != week) {
return null;
}
final Cafeteria cafeteria = new Cafeteria();
for (int i = 0; i < 5; i++) {
cafeteria.addDay(new Day());
}
// loop through all trs till you only find two tds (e.g. Salatbar)
int pos = 2;
while (true) {
final Element tr = select.get(pos);
final Elements tds = tr.select("td");
if (tds.size() == 2) {
break;
}
final Element priceTr = select.get(pos + 1);
final Elements priceTds = priceTr.select("td");
for (int j = 1; j < tds.size(); j++) {
final Element td = tds.get(j);
// this is a very strange char but it is used by the website
final String description = td.text().replace(" ", "").trim();
if (!description.startsWith("-") && !description.isEmpty()) {
final Menu menu = new Menu();
final Element priceTd = priceTds.get(j);
final String[] pricesString = priceTd.text().split("/");
for (final String priceString : pricesString) {
menu.addPrice(cleanPrice(priceString));
}
menu.setDescription(description);
cafeteria.getDays().get(j - 1).addMenu(menu);
}
}
pos += 2;
}
final Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, 4);
final Date endDate = calendar.getTime();
cafeteria.setWeekStart(date);
cafeteria.setWeekEnd(endDate);
cafeteria.setFoodInfo(document.select(".gelbunten").text());
return cafeteria;
}
}
| [
"[email protected]"
] | |
aebd132b04b263457eaf0dfb1d4e6d9a26d0da94 | 8603e812b87f7591c412135f3b49f24fa942bf09 | /Star/public/gatk-utils/src/test/java/org/broadinstitute/gatk/utils/file/FSLockWithSharedUnitTest.java | 7dbf3472ca6539ac44f7597bcc316a8040430e7a | [] | no_license | zhmz90/DebugMutect2 | 21617957e02a9adc216eb1eace06873874333568 | 53f39efaebd13efd21debc72c44fa5299ec338f4 | refs/heads/master | 2020-12-25T17:17:17.693506 | 2016-03-24T02:33:16 | 2016-03-24T02:33:16 | 53,378,698 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,508 | java | /*
* Copyright 2012-2015 Broad Institute, Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package org.broadinstitute.gatk.utils.file;
import org.broadinstitute.gatk.utils.BaseTest;
import org.broadinstitute.gatk.utils.exceptions.UserException;
import org.testng.annotations.Test;
import java.io.File;
public class FSLockWithSharedUnitTest extends BaseTest {
private static final int MAX_EXPECTED_LOCK_ACQUISITION_TIME = FSLockWithShared.DEFAULT_LOCK_ACQUISITION_TIMEOUT_IN_MILLISECONDS +
FSLockWithShared.THREAD_TERMINATION_TIMEOUT_IN_MILLISECONDS;
/**
* Test to ensure that we're never spending more than the maximum configured amount of time in lock acquisition calls.
*/
@Test( timeOut = MAX_EXPECTED_LOCK_ACQUISITION_TIME + 10 * 1000 )
public void testLockAcquisitionTimeout() {
final File lockFile = createTempFile("FSLockWithSharedUnitTest", ".lock");
final FSLockWithShared lock = new FSLockWithShared(lockFile);
boolean lockAcquisitionSucceeded = false;
try {
lockAcquisitionSucceeded = lock.sharedLock();
}
catch ( UserException e ) {
logger.info("Caught UserException from lock acquisition call: lock acquisition must have timed out. Message: " + e.getMessage());
}
finally {
if ( lockAcquisitionSucceeded ) {
lock.unlock();
}
}
}
}
| [
"[email protected]"
] | |
bff5043be29b51c859fb0d57ddc9753159292d09 | 4f2b0ae367f7e228fda199c360aaca4a40070933 | /core/core-api/src/main/java/org/etudes/sitecontent/api/Archive.java | 5a9fce9981a029f2f28197638b5176cd05cf2f5a | [] | no_license | etudes-inc/serenity | 3f66998b25b0d07a6662f59fa0ea35048fa4e6c5 | 6473d801b9ce3bfb967985ac6a09286c072b26e2 | refs/heads/master | 2021-01-20T04:47:22.931740 | 2017-04-28T18:28:44 | 2017-04-28T18:28:44 | 89,731,846 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,848 | java | /**********************************************************************************
* $URL: https://source.etudes.org/svn/serenity/trunk/core/core-api/src/main/java/org/etudes/sitecontent/api/Archive.java $
* $Id: Archive.java 10081 2015-02-14 23:06:22Z ggolden $
***********************************************************************************
*
* Copyright (c) 2009, 2015 Etudes, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************************/
package org.etudes.sitecontent.api;
import org.etudes.tool.api.Tool;
/**
* Archive is the collection of archived data for a site.
*/
public interface Archive
{
/**
* Add this artifact to the archive.
*
* @param artifact
* The artifact to archive.
*/
void archive(Artifact artifact);
/**
* Create a new artifact that can be archived.
*
* @param tool
* The tool handling the artifact.
* @param type
* The artifact type (a string defined by each archiving tool).
* @returnA new empty artifact.
*/
Artifact newArtifact(Tool tool, String type);
/**
* Translate the content html by any needed translations.
*
* @param content
* The content html.
* @return The updated content.
*/
String translateContentBody(String content);
}
| [
"[email protected]"
] | |
26f2de73403dc5ee5ebbd80c596fd5168e7ec573 | 88cdbf962f24b97eab0c38d0dd4e7070eba78ad5 | /week2les9/voorbereiding/StudentUitbreiden/OpgaveB/src/Student/Student.java | 27c5e0b11ddaf7619dd379ebfc1d2acdc0386c1f | [] | no_license | Daventer/oopd | ba982dbef3e2ec331e7711249ec7aef98e72105d | 9d8866914ddd117f7e0f6c5393fa0a9bdbca393e | refs/heads/master | 2021-05-04T04:19:03.604754 | 2018-03-16T12:54:53 | 2018-03-16T12:54:53 | 120,331,356 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 843 | java | package Student;
public class Student {
private String naam;
private String geslacht;
private int studentenNummer;
public static final String MAN = "man";
public static final String VROUW = "vrouw";
private static int nStudenten = 0;
public Student(String naam, int studentenNummer) {
this.naam = naam;
this.studentenNummer = studentenNummer;
nStudenten++;
}
public String getGeslacht() {
return geslacht;
}
public void setGeslacht(String geslacht) {
this.geslacht = geslacht;
}
public static int getNStudenten() {
return nStudenten;
}
public String toString() {
return getNaam();
}
public String getNaam() {
return naam;
}
public void setNaam(String naam) {
this.naam = naam;
}
}
| [
"[email protected]"
] | |
6a2341ae2392aca38864d696eb85246a99e1b8ec | 04b84db1f1e4231fbc6681ff073384f3c2164bbf | /techment/d7/collection/ArrayListDemo3.java | 1027ca85559dcaed594ff832f99794c8cc11a95c | [] | no_license | Ram165055/TraingAssigment | cc56d886efdf323937d683373edf4e6d58941c17 | 571b2925f153903fd6c0413295b8a1fbc911d65d | refs/heads/master | 2023-07-09T11:58:14.758050 | 2021-08-11T14:50:27 | 2021-08-11T14:50:27 | 392,946,986 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 906 | java | package com.techment.d7.collection;
import java.util.ArrayList;
import java.util.Collections;
public class ArrayListDemo3 {
public static void main(String[] args) {
ArrayList<Integer> o1=new ArrayList<Integer>();
o1.add(1);
o1.add(2);
o1.add(3);
o1.add(4);
o1.add(5);
o1.add(6);
System.out.println("elements are"+o1);
ArrayList<Integer> o2=new ArrayList<Integer>();
o2.add(100);
o2.add(101);
o2.add(102);
o2.add(103);
o2.add(104);
o2.add(105);
o2.add(3);
o2.add(5);
System.out.println("elements in o2"+o2);
// o2.addAll(o1);//add all elements in o2 from o1
// o2.removeAll(o1);//remove o1 elements present in o2
System.out.println("before retaining"+o2);
o2.retainAll(o1);//retains o1 all elements which present in o2
System.out.println("after retaining"+o2);
Collections.sort(o2);
System.out.println("elements of o2 after sorting"+o2);
}
}
| [
"[email protected]"
] | |
2b078ea500765f0af2573d46af31ffca1b4c5a54 | 5b6e8d84243b0d05cb41ff58c47c57736750ab0a | /app/src/main/java/foundation/icon/iconex/intro/auth/AuthLockNumFragment.java | ed2fdfc2bdd341c26dd8a5aa45fc26040c0e558c | [
"Apache-2.0"
] | permissive | Spl3en/iconex_android | cd7222ace3f2c52db72bc78dd52e8e3f8991b312 | 392deb3f6dd720642a29d84713838da6ec3e694a | refs/heads/master | 2020-03-27T21:17:19.575510 | 2018-10-13T16:07:58 | 2018-10-13T16:07:58 | 147,132,054 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,558 | java | package foundation.icon.iconex.intro.auth;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import foundation.icon.iconex.R;
import foundation.icon.iconex.util.CryptoUtil;
import foundation.icon.iconex.util.PreferenceUtil;
public class AuthLockNumFragment extends Fragment implements View.OnClickListener {
private static final String TAG = AuthLockNumFragment.class.getSimpleName();
private TextView txtGuide;
private EditText editNum;
private ImageView num1, num2, num3, num4, num5, num6;
private boolean isFingerprintInvalidated = false;
public AuthLockNumFragment() {
// Required empty public constructor
}
// TODO: Rename and change types and number of parameters
public static AuthLockNumFragment newInstance() {
AuthLockNumFragment fragment = new AuthLockNumFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_auth_lock_num, container, false);
txtGuide = v.findViewById(R.id.txt_guide);
txtGuide.setText(getString(R.string.enterLockNum));
editNum = v.findViewById(R.id.editNum);
editNum.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
setNumber(s.length());
if (s.length() == 6) {
if (validateLockNum(editNum.getText().toString())) {
if (isFingerprintInvalidated)
mListener.onFingerprintInvalidated();
else
mListener.onLockNumUnlockSuccess();
} else {
editNum.setText("");
txtGuide.setText(getString(R.string.errRetryLockNum));
}
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
num1 = v.findViewById(R.id.num1);
num2 = v.findViewById(R.id.num2);
num3 = v.findViewById(R.id.num3);
num4 = v.findViewById(R.id.num4);
num5 = v.findViewById(R.id.num5);
num6 = v.findViewById(R.id.num6);
Button btnNum0 = v.findViewById(R.id.btnNum0);
btnNum0.setOnClickListener(this);
Button btnNum1 = v.findViewById(R.id.btnNum1);
btnNum1.setOnClickListener(this);
Button btnNum2 = v.findViewById(R.id.btnNum2);
btnNum2.setOnClickListener(this);
Button btnNum3 = v.findViewById(R.id.btnNum3);
btnNum3.setOnClickListener(this);
Button btnNum4 = v.findViewById(R.id.btnNum4);
btnNum4.setOnClickListener(this);
Button btnNum5 = v.findViewById(R.id.btnNum5);
btnNum5.setOnClickListener(this);
Button btnNum6 = v.findViewById(R.id.btnNum6);
btnNum6.setOnClickListener(this);
Button btnNum7 = v.findViewById(R.id.btnNum7);
btnNum7.setOnClickListener(this);
Button btnNum8 = v.findViewById(R.id.btnNum8);
btnNum8.setOnClickListener(this);
Button btnNum9 = v.findViewById(R.id.btnNum9);
btnNum9.setOnClickListener(this);
ImageView btnDel = v.findViewById(R.id.btn_delete);
btnDel.setOnClickListener(this);
ViewGroup lockNumLost = v.findViewById(R.id.layout_lost_lock_num);
lockNumLost.setOnClickListener(this);
return v;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnLockNumAuthListener) {
mListener = (OnLockNumAuthListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFingerprintLockListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
@Override
public void onClick(View v) {
String number;
switch (v.getId()) {
case R.id.btnNum0:
number = editNum.getText().toString();
editNum.setText(number + "0");
break;
case R.id.btnNum1:
number = editNum.getText().toString();
editNum.setText(number + "1");
break;
case R.id.btnNum2:
number = editNum.getText().toString();
editNum.setText(number + "2");
break;
case R.id.btnNum3:
number = editNum.getText().toString();
editNum.setText(number + "3");
break;
case R.id.btnNum4:
number = editNum.getText().toString();
editNum.setText(number + "4");
break;
case R.id.btnNum5:
number = editNum.getText().toString();
editNum.setText(number + "5");
break;
case R.id.btnNum6:
number = editNum.getText().toString();
editNum.setText(number + "6");
break;
case R.id.btnNum7:
number = editNum.getText().toString();
editNum.setText(number + "7");
break;
case R.id.btnNum8:
number = editNum.getText().toString();
editNum.setText(number + "8");
break;
case R.id.btnNum9:
number = editNum.getText().toString();
editNum.setText(number + "9");
break;
case R.id.btn_delete:
number = editNum.getText().toString();
if (number.length() != 0)
editNum.setText(number.substring(0, number.length() - 1));
break;
case R.id.layout_lost_lock_num:
mListener.onLostLockNum();
break;
}
}
private void setNumber(int length) {
switch (length) {
case 0:
num1.setSelected(false);
num2.setSelected(false);
num3.setSelected(false);
num4.setSelected(false);
num5.setSelected(false);
num6.setSelected(false);
break;
case 1:
num1.setSelected(true);
num2.setSelected(false);
num3.setSelected(false);
num4.setSelected(false);
num5.setSelected(false);
num6.setSelected(false);
break;
case 2:
num1.setSelected(true);
num2.setSelected(true);
num3.setSelected(false);
num4.setSelected(false);
num5.setSelected(false);
num6.setSelected(false);
break;
case 3:
num1.setSelected(true);
num2.setSelected(true);
num3.setSelected(true);
num4.setSelected(false);
num5.setSelected(false);
num6.setSelected(false);
break;
case 4:
num1.setSelected(true);
num2.setSelected(true);
num3.setSelected(true);
num4.setSelected(true);
num5.setSelected(false);
num6.setSelected(false);
break;
case 5:
num1.setSelected(true);
num2.setSelected(true);
num3.setSelected(true);
num4.setSelected(true);
num5.setSelected(true);
num6.setSelected(false);
break;
case 6:
num1.setSelected(true);
num2.setSelected(true);
num3.setSelected(true);
num4.setSelected(true);
num5.setSelected(true);
num6.setSelected(true);
break;
}
}
private boolean validateLockNum(final String number) {
PreferenceUtil preferenceUtil = new PreferenceUtil(getActivity());
String encTxt = preferenceUtil.getLockNum();
String uuid = preferenceUtil.getUUID();
String txt;
try {
txt = CryptoUtil.decryptText(encTxt, number);
} catch (Exception e) {
return false;
}
return txt.equals(uuid);
}
public void setInvalidated(boolean isInvalidated) {
isFingerprintInvalidated = isInvalidated;
}
private OnLockNumAuthListener mListener;
public interface OnLockNumAuthListener {
void onLockNumUnlockSuccess();
void onFingerprintInvalidated();
void onLockNumUnlockFailed();
void onLostLockNum();
}
}
| [
"[email protected]"
] | |
2a1f6ec57dcdfb915a4c08b212bae568a55bf02d | 488a1303a596384efb7be61a84503bd26a746320 | /src/net/gslab/controller/InfoController.java | 9b1c976253dcdff3b2a89d5bc2d6e435fc1424c7 | [] | no_license | ZXHY607/Model_1.0 | 2b3ea6b5b6b8dfd44c85b473f67397f446d23a7c | 6d1e2a31d60341a2c0aad6065888fe32ee895676 | refs/heads/Model_1.0 | 2016-08-12T08:57:21.612961 | 2016-02-29T11:35:42 | 2016-02-29T11:35:42 | 46,965,763 | 0 | 3 | null | 2016-02-29T11:35:42 | 2015-11-27T07:24:37 | Java | UTF-8 | Java | false | false | 6,030 | java | package net.gslab.controller;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.io.IOException;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.gslab.entity.Info;
import net.gslab.service.InfoService;
import net.gslab.setting.PageBean;
import org.springframework.ui.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/info")
public class InfoController extends BaseController{
@Resource(name="infoServiceImpl")
private InfoService infoService;
//从后台添加新闻
@RequestMapping(value="/add")
public @ResponseBody String add(Info info,HttpServletRequest request)
{
if(info==null) return "error";
//进行格式判断,先判断是否为空
if(getSessionType(request).equals("teacher"))
{
info.setWho(0);
info.setPublishName(getSessionTeacher(request).getTeacherName());
info.setPublishId(getSessionTeacher(request).getTeacherId());
}
if(getSessionType(request).equals("admin"))
{
info.setWho(1);
info.setPublishName(getSessionAdmin(request).getAdminName());
info.setPublishId(getSessionAdmin(request).getAdminId());
}
//获取当前时间
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
String time=df.format(new Date());
info.setPublishDate(time);
infoService.save(info);
return "success";
}
//分页例子,
@RequestMapping(value = "/getPage")
public ModelAndView getPage(Integer pg) {
/**
* @param pageIndex 请求的页码
* @param pageSize 每页的记录条数
* @param
*/
//return infoService.getPage(pageIndex); //使用默认的pageSize
int pageIndex;
if(pg==null) pageIndex=1;
else pageIndex=pg;
PageBean page=infoService.getPage("from Info n order by n.publishDate desc",pageIndex); //自定义pageSize为2
ModelAndView mav=new ModelAndView("/view_admin/m_infoList.jsp");
PageBean pageBean=infoService.getPage(pageIndex);
mav.addObject("pageBean",pageBean);
return mav;
}
//分页2,返回分页,附带新闻总数,已测试,可以使用;
//参数pageIndex指定是第几页
@RequestMapping(value = "/getPage_2", method = RequestMethod.GET)
public @ResponseBody PageBean<Info> list2(HttpServletRequest request,
HttpServletResponse response,@RequestParam(value="pageIndex")Integer pageIndex, int pageSize)
{
/**
* @param pageIndex 请求的页码
* @param pageSize 每页的记录条数
* @param
*/
PageBean page=infoService.getPage("from Info n order by n.publishDate desc",pageIndex,pageSize);
return page;
}
//返回totalsize,即数据库里面的新闻总数,已测试,可以使用
@RequestMapping(value = "/getTotalcount", method = RequestMethod.GET)
public @ResponseBody long getTotalcount()
{
return infoService.getPage(1).getTotalCount();
}
//分页,返回首页显示的9条最新新闻
@RequestMapping(value = "/get9Page", method = RequestMethod.GET)
public @ResponseBody List<Info> list2(HttpServletRequest request,
HttpServletResponse response) {
//,@RequestParam(value="pageIndex")Integer pageIndex
/**
*
* @param pageIndex 请求的页码
* @param pageSize 每页的记录条数
* @param
*/
PageBean page=infoService.getPage("from Info n order by n.publishDate desc",1,9); //按日期排序
List<Info> data=page.getData();
//把不用的属性设置为null(主要是content,其余占用的空间小,减少占用的带宽)
for(int i=0;i<data.size();i++)
{
Info temp=data.get(i);
temp.setContent(null);
}
return page.getData();
}
//分页,返回首页显示的3条最新新闻,测试过,可以用
@RequestMapping(value = "/get6Page", method = RequestMethod.GET)
public @ResponseBody List<Info> get3Page(HttpServletRequest request,
HttpServletResponse response) {
//,@RequestParam(value="pageIndex")Integer pageIndex
/**
*
* @param pageIndex 请求的页码
* @param pageSize 每页的记录条数
* @param
*/
PageBean page=infoService.getPage("from Info n order by n.publishDate desc",1,6); //按日期排序
return page.getData();
}
//删除新闻,前台传入ID,根据ID删除新闻,删除后,检验是否删除成功
@RequestMapping("/delete")
public void delete(int []id,HttpServletResponse response) throws IOException
{
if(id!=null)
{
for(int i=0;i<id.length;i++)
infoService.delete(id[i]);
}
response.getWriter().print("删除成功");
}
//返回全部新闻 ,返回json串,这就是一个测试
@RequestMapping(value="/infoList")
public @ResponseBody List<Info> show(Model model) //后台往前台传输数据时用model
{
List<Info> info=infoService.listInfo();
model.addAttribute("info",info); //等效于request和respond
return info;
}
//根据新闻id,获得数据库中的新闻
@RequestMapping(value ="/getByID")
public @ResponseBody Info getByID(int id)
{
return infoService.get(id);
}
@RequestMapping(value ="/detail")
public ModelAndView detail(int id)
{
ModelAndView mav =new ModelAndView("/view_all/info_detail.jsp");
Info n=infoService.get(id);
mav.addObject("ele", n);
return mav;
}
}
| [
"[email protected]"
] | |
4374bc270d0ea493065145f33439603ce3d60158 | 24091b3f7fd62836e24ddb326a5e867b32957f86 | /src/main/java/org/nextrtc/signalingserver/domain/conversation/MeshConversation.java | f120a2023f4d3f2edb178c4d3cc756a2717b6441 | [
"MIT"
] | permissive | oliverhausler/nextrtc-signaling-server | 305badd4946911c6cedb899b6e70efa7ecc13c58 | 594f0feb71da21f869aab1a16187b211a1e8586e | refs/heads/master | 2020-03-15T15:19:15.656202 | 2018-04-04T18:17:10 | 2018-04-04T18:17:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,270 | java | package org.nextrtc.signalingserver.domain.conversation;
import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.Set;
@Component
@Scope("prototype")
public class MeshConversation extends Conversation {
private ExchangeSignalsBetweenMembers exchange;
private Set<Member> members = Sets.newConcurrentHashSet();
public MeshConversation(String id) {
super(id);
}
public MeshConversation(String id,
LeftConversation left,
MessageSender sender,
ExchangeSignalsBetweenMembers exchange) {
super(id, left, sender);
this.exchange = exchange;
}
@Override
public synchronized void join(Member sender) {
assignSenderToConversation(sender);
informSenderThatHasBeenJoined(sender);
informRestAndBeginSignalExchange(sender);
members.add(sender);
}
private void informRestAndBeginSignalExchange(Member sender) {
for (Member to : members) {
parallel.execute(() -> {
sendJoinedFrom(sender, to);
sendJoinedFrom(to, sender);
exchange.begin(to, sender);
});
}
}
private void informSenderThatHasBeenJoined(Member sender) {
if (isWithoutMember()) {
sendJoinedToFirst(sender, id);
} else {
sendJoinedToConversation(sender, id);
}
}
public synchronized boolean isWithoutMember() {
return members.isEmpty();
}
public synchronized boolean has(Member member) {
return member != null && members.contains(member);
}
@Override
public void exchangeSignals(InternalMessage message) {
exchange.execute(message);
}
@Override
public void broadcast(Member from, InternalMessage message) {
members.stream()
.filter(member -> !member.equals(from))
.forEach(to -> messageSender.send(message.copy()
.from(from)
.to(to)
.build()
));
}
@Override
public synchronized boolean remove(Member leaving) {
boolean remove = members.remove(leaving);
if (remove) {
leaving.unassignConversation(this);
parallel.execute(() -> {
for (Member member : members) {
sendLeftMessage(leaving, member);
}
});
}
return remove;
}
private void sendJoinedToFirst(Member sender, String id) {
messageSender.send(InternalMessage.create()//
.to(sender)//
.signal(Signal.CREATED)//
.addCustom("type", "MESH")
.content(id)//
.build()//
);
}
@Inject
public void setExchange(ExchangeSignalsBetweenMembers exchange) {
this.exchange = exchange;
}
}
| [
"[email protected]"
] | |
5a24f76b4a2311b5cab405605c84e4659da6b22f | 46f41fe0c5b560af2a2536b91d538dafaa7ffc4e | /springMq/src/main/java/cn/case1/Spring1.java | f5569a1cc494995c67a7f32c65bd39419f0e3653 | [] | no_license | reed2425537764/rabbitmqTest | 18b9decb570e103979a02e9605c0d797a7dbb6fb | 7b12f29e4dfccd1248aad93f9b371847825a89b0 | refs/heads/master | 2023-06-18T14:17:01.015834 | 2021-07-20T09:54:58 | 2021-07-20T09:54:58 | 332,762,105 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 736 | java | package cn.case1;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.concurrent.TimeUnit;
/**
* @Author: shiyuqin
* @Date: 2020/10/25 13:38
*/
public class Spring1 {
public static void main(String[] args) {
ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("rabbitmq-producer.xml");
//生产者
Send1 send1 = applicationContext.getBean(Send1.class);
send1.send();
try {
TimeUnit.SECONDS.sleep(1L);
} catch (InterruptedException e) {
e.printStackTrace();
}
applicationContext.close();
}
}
| [
"[email protected]"
] | |
31186e83cdbf2f6c041b44f9b2e7e5fe29ae708e | 146e4c716c02822f6e3f6f86f971938a12a0f3e8 | /src/main/java/foo/bar/day01/lab05/ProxyTest.java | cbad7102bfd1a6f7da1696b0201927373be07409 | [] | no_license | ainurminibaev/java-baruch | dd20e98a5b290f61c7e30a2da79056dde3e4098f | c9f05f852eeb7b425279d04ca635f008d47485f1 | refs/heads/master | 2021-01-22T00:03:36.403735 | 2015-04-28T14:00:29 | 2015-04-28T14:00:29 | 33,476,345 | 0 | 3 | null | 2015-04-26T20:52:46 | 2015-04-06T10:09:22 | Java | UTF-8 | Java | false | false | 427 | java | package foo.bar.day01.lab05;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Created by ainurminibaev on 06.04.15.
*/
public class ProxyTest {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("day01/context.xml");
Subject subject = (Subject) context.getBean("subject");
subject.call();
}
}
| [
"[email protected]"
] | |
78ec1bbd41e3b941c5f952057547e596a1293d96 | b39766dac782853efa5beb4fabfcd8e5af254a11 | /src/main/java/com/example/service/auth/init/ClientInitialization.java | ff9456439ca1b9b387b0091b33e50efb8f76ee66 | [] | no_license | dgsaigit/spring-security-5-upgrade_sso-auth-server | 728f268e75365627550c5489620e48e53612f5c1 | 6fe15125248c09f3a7e549fd9121782d0066f957 | refs/heads/master | 2020-05-30T12:50:28.161710 | 2019-03-27T21:01:48 | 2019-03-27T21:01:48 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,967 | java | package com.example.service.auth.init;
import com.example.service.auth.domain.Consumer;
import com.example.service.auth.domain.User;
import com.example.service.auth.repository.ConsumerRepository;
import com.example.service.auth.repository.UserRepository;
import javax.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@Profile("!test")
@Configuration
@EnableConfigurationProperties(ClientInitializationProperties.class)
@Slf4j
public class ClientInitialization {
private final ClientInitializationProperties clientInitializationProperties;
private ConsumerRepository consumerRepository;
private UserRepository userRepository;
private BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
@Autowired
public ClientInitialization(UserRepository userRepository,
ClientInitializationProperties clientInitializationProperties,
ConsumerRepository consumerRepository) {
this.userRepository = userRepository;
this.clientInitializationProperties = clientInitializationProperties;
this.consumerRepository = consumerRepository;
}
private Consumer createClient(ClientInitializationProperties.AuthClient authClient) {
log.info("Creating client for " + authClient.getName());
Consumer consumer = new Consumer();
consumer.setClientId(authClient.getName());
if (authClient.getKey() != null) {
consumer.setClientSecret(passwordEncoder.encode(authClient.getKey()));
}
consumer.setAuthorizedGrantTypesCsv(scrubTypes(authClient.getAuthorizedGrantTypes()));
consumer.setScopeCsv(authClient.getScope());
consumer.setResourceIdsCsv(authClient.getResourceIds());
consumer.setAccessTokenValiditySeconds(authClient.getAccessTokenValiditySeconds());
consumer.setRefreshTokenValiditySeconds(authClient.getRefreshTokenValiditySeconds());
consumer.setAuthorityCsv(authClient.getAuthorities());
consumer.setRegisteredRedirectUrisCsv(authClient.getRedirectUri());
consumer.setAutoApproveCsv(authClient.getAutoApproveScopes());
return consumer;
}
private String scrubTypes(final String authorizedGrantTypes) {
String scrubbedTypes = null;
if (authorizedGrantTypes != null) {
String[] types = authorizedGrantTypes.split(",");
StringBuilder sb = new StringBuilder();
String trimmed;
for (String type : types) {
if (type != null) {
trimmed = type.trim();
if (trimmed.length() > 0) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(trimmed);
}
}
}
scrubbedTypes = sb.toString();
}
return scrubbedTypes;
}
@PostConstruct
public void clientConfig() {
SecurityUtils.runAs("system", "system", "ROLE_ADMIN");
for (ClientInitializationProperties.AuthClient authClient : clientInitializationProperties
.getClients()) {
if (!consumerRepository.findByClientId(authClient.getName()).isPresent()) {
consumerRepository.save(createClient(authClient));
}
}
for (ClientInitializationProperties.AuthUser authUser : clientInitializationProperties
.getAuthUsers()) {
if (!userRepository.findByUsername(authUser.getName()).isPresent()) {
log.info("Adding user: " + authUser.getName());
User user = new User();
user.setUsername(authUser.getName());
if (authUser.getKey() != null) {
user.setPassword(passwordEncoder.encode(authUser.getKey()));
}
user.setActive(Boolean.TRUE);
user.setRoles(authUser.getAuthorities());
userRepository.save(user);
}
}
}
} | [
"[email protected]"
] | |
c6d3aa5c7e8b85f3a759f6bb9803ae846217eb5e | 4d7ed10fa9897fb2cb2872ca5a814924e9d9e000 | /src/main/java/com/punj/app/ecommerce/controller/reports/InvAdjustReportController.java | 39f658eb26c82dab2815f30b0e0d264caa136619 | [] | no_license | missaouib/CommerceApp | b5a86341fb8d50f1e4c818a65ed5fd879103238e | 34f052c4b75ab92431f1f690e6e7d985a274fc5d | refs/heads/master | 2022-01-16T16:44:55.695066 | 2018-08-25T17:20:17 | 2018-08-25T17:20:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,024 | java | package com.punj.app.ecommerce.controller.reports;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import com.punj.app.ecommerce.controller.common.MVCConstants;
import com.punj.app.ecommerce.controller.common.ViewPathConstants;
import com.punj.app.ecommerce.controller.common.transformer.InventoryBeanTransformer;
import com.punj.app.ecommerce.domains.inventory.StockAdjustment;
import com.punj.app.ecommerce.models.inventory.InvAdjustBean;
import com.punj.app.ecommerce.services.InventoryService;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
/**
*
* @author admin
*
*/
@Controller
public class InvAdjustReportController {
private static final Logger logger = LogManager.getLogger();
private InventoryService inventoryService;
/**
* @param inventoryService
* the inventoryService to set
*/
@Autowired
public void setInventoryService(InventoryService inventoryService) {
this.inventoryService = inventoryService;
}
@GetMapping(value = ViewPathConstants.PRINT_INV_ADJUSTS_URL)
public void printInventoryAdjustmentList(Model model, HttpSession session, final HttpServletRequest req,
HttpServletResponse response, Locale locale) {
logger.info("The inventory adjustment list report generation has been called.");
try {
List<StockAdjustment> stockAdjustmentList = this.inventoryService.listStockAdjustments();
List<InvAdjustBean> invAdjustBeanList = InventoryBeanTransformer
.transformStockAdjustmentList(stockAdjustmentList);
JRBeanCollectionDataSource invAdjustDS = new JRBeanCollectionDataSource(invAdjustBeanList);
InputStream invAdjustReportStream = getClass().getResourceAsStream(MVCConstants.INV_ADJUSTMENT_REPORT);
JasperReport jasperReport = JasperCompileManager.compileReport(invAdjustReportStream);
InputStream invAdjustReportStreamChild = getClass()
.getResourceAsStream(MVCConstants.INV_ADJUSTMENT_ITEMS_REPORT);
JasperReport jasperReportChild = JasperCompileManager.compileReport(invAdjustReportStreamChild);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put(MVCConstants.INV_ADJUSTMENT_ITEMS_REPORT_PARAM, jasperReportChild);
PdfReportGenerator pdfGenerator = PdfReportGenerator.getInstance();
pdfGenerator.printPDFReport(response, jasperReport, paramMap, invAdjustDS);
logger.info("The listing report for inventory adjustment has been generated successfully");
} catch (Exception e) {
logger.error("An unknown error has occurred while generating inventory adjustment list.", e);
}
}
@GetMapping(value = ViewPathConstants.PRINT_INV_ADJUST_URL)
public void printInventoryAdjustment(Model model, HttpSession session, final HttpServletRequest req,
HttpServletResponse response, Locale locale) {
logger.info("The single inventory adjustment report generation has been called.");
try {
BigInteger invAdjustId = new BigInteger(req.getParameter(MVCConstants.INV_ADJUST_ID_PARAM));
if (invAdjustId.intValue()>0) {
StockAdjustment stockAdjustment= this.inventoryService.searchStockAdjustment(invAdjustId);
InvAdjustBean invAdjustBean = InventoryBeanTransformer.transformStockAdjustmentDomainWithItems(stockAdjustment);
List<InvAdjustBean> invAdjustBeanList=new ArrayList<>();
invAdjustBeanList.add(invAdjustBean);
JRBeanCollectionDataSource invAdjustDS = new JRBeanCollectionDataSource(invAdjustBeanList);
InputStream invAdjustReportStream = getClass().getResourceAsStream(MVCConstants.INV_ADJUST_REPORT);
JasperReport jasperReport = JasperCompileManager.compileReport(invAdjustReportStream);
InputStream invAdjustReportStreamChild = getClass()
.getResourceAsStream(MVCConstants.INV_ADJUST_ITEMS_REPORT);
JasperReport jasperReportChild = JasperCompileManager.compileReport(invAdjustReportStreamChild);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put(MVCConstants.INV_ADJUST_ITEMS_REPORT_PARAM, jasperReportChild);
PdfReportGenerator pdfGenerator = PdfReportGenerator.getInstance();
pdfGenerator.printPDFReport(response, jasperReport, paramMap, invAdjustDS);
logger.info("The report for provided inventory adjustment has been generated successfully");
}
} catch (Exception e) {
logger.error("An unknown error has occurred while generating inventory adjustment report for provided id.",
e);
}
}
}
| [
"[email protected]"
] | |
9491ac46e12ab03daaa790e704011e5c8f1cadd9 | ed3cb95dcc590e98d09117ea0b4768df18e8f99e | /project_1_3/src/b/f/c/b/Calc_1_3_15212.java | 876c7bc7679644bbc3bfc5729aa9ecd533e096b3 | [] | no_license | chalstrick/bigRepo1 | ac7fd5785d475b3c38f1328e370ba9a85a751cff | dad1852eef66fcec200df10083959c674fdcc55d | refs/heads/master | 2016-08-11T17:59:16.079541 | 2015-12-18T14:26:49 | 2015-12-18T14:26:49 | 48,244,030 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 134 | java | package b.f.c.b;
public class Calc_1_3_15212 {
/** @return the sum of a and b */
public int add(int a, int b) {
return a+b;
}
}
| [
"[email protected]"
] | |
e1cf81242c9700485f1802e448b31089b936959a | 5fe8c60d3a29220ed27620b24ba7fed337270e64 | /backend/src/main/java/com/musicme/musicme/security/CurrentUser.java | 707dea9a1403f13301ea6f0f5ba324c57b0a5496 | [] | no_license | kgobakis/MusicMe | 87a1c382dfd79dee2b25593db8111dd1556f6de7 | 699807c9e0f968003e92f798bdd872dd47fa8ad5 | refs/heads/master | 2022-12-11T03:31:24.910460 | 2020-01-28T14:28:54 | 2020-01-28T14:28:54 | 228,051,632 | 1 | 0 | null | 2022-11-10T05:25:45 | 2019-12-14T16:15:09 | Java | UTF-8 | Java | false | false | 306 | java | package com.musicme.musicme.security;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import java.lang.annotation.*;
@Target({ElementType.PARAMETER, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@AuthenticationPrincipal
public @interface CurrentUser {
} | [
"[email protected]"
] | |
35c6a0b755654c67bb0187bb99d57505e8d21b68 | 8958ae3dff11f3f5a0431158a347ad6dfa82ad3e | /Kaprekar number/Main.java | a971670ac9b1811e37ce5b60af61b1446c2bc338 | [] | no_license | Yogesh155/Playground | c661ce53295ffa729bffbbee2c9a85db7ec90ddf | 919c722a6902130f68a5d9fa740920b8bc7d34a5 | refs/heads/master | 2022-11-09T10:55:35.386183 | 2020-06-28T02:42:53 | 2020-06-28T02:42:53 | 266,650,850 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 331 | java |
#include<iostream>
using namespace std;
int main()
{
int k,l,m,n,i,j,f,s;
std::cin>>k;
m=k; i=j=s=0;
n=k*k;
if(k==45)
{
std::cout<<"Kaprekar Number";
}
else
{
while(m>1)
{
m=m/10;
i++;
}
while(j<i)
{
f=n%10;
s=s+f;
n=n/10;
j++;
}
l=s+n;
if(l==k)
{
std::cout<<"Kaprekar Number";
}
else
{
std::cout<<"Not a Kaprekar Number";
}
}
} | [
"[email protected]"
] | |
cc15664dc6c1f6f42bf8eb6f9620815b6e9a6a74 | 800533c668b1c3a201acb28921ec85499027aba3 | /app/src/main/java/com/realmbookexample/model/Book.java | de3853b68dec0aa1b5c763fad4c99a3ccd9d4ac8 | [] | no_license | rajeshct/Realm_Database_Implementation | 106c80f90da9a5a8f9b389bf3c3c998600de241a | aba48438ba5208fcf702b92ec779e0f2fae5b4c8 | refs/heads/master | 2021-05-08T04:25:18.635758 | 2017-10-26T13:02:06 | 2017-10-26T13:02:06 | 108,407,426 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,078 | java | package com.realmbookexample.model;
import io.realm.RealmObject;
import io.realm.annotations.Index;
import io.realm.annotations.PrimaryKey;
/**
*
*/
public class Book extends RealmObject {
@PrimaryKey
private long id;
@Index
private String author;
private String title;
private String description;
private String imageUrl;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
} | [
"[email protected]"
] | |
9e94889a17ad7c2e469478ddbcbd744aee830890 | 435f8e433cfc8e329c83ff5ed0a67c1b80aafcb7 | /src/main/java/managers/JokeService.java | 8f415c9ec0a005bf9c8da74fff28685f3a3060cb | [] | no_license | jlegiedz/ChuckNorris | 9513c45ed3f75bbd992785075e91ca61def18b8e | b6e972748c4cb1b96cf9d119e1681767999efb7a | refs/heads/master | 2021-05-04T18:37:19.345707 | 2018-02-23T21:13:43 | 2018-02-23T21:13:43 | 120,164,905 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 274 | java | package managers;
import javaModel.JokeResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
public interface JokeService {
@GET("random/{randomCount}")
Call<JokeResponse> randomJokes(@Path("randomCount") int randomCount);
}
| [
"[email protected]"
] | |
43984b30135931cb9f3eab32e53a3bd40f2fa5b4 | a9a82ea11d66ba557a58a74c8f9ce666bf123b62 | /skypiea-system/skypiea-system-model/src/main/java/com/skypiea/system/model/PermissionInfo.java | 2ac8fbed097006e18fc96f20beaf1f0979618524 | [] | no_license | ertrtesr/skypiea-parent | bb41f16ac50529ac2e168ee94aa33e80d8c618b8 | 89d92a45ae192b51fb25b04e0d2455de5e2f9e61 | refs/heads/master | 2021-01-23T01:30:06.226934 | 2017-04-21T08:49:18 | 2017-04-21T08:49:18 | 85,913,916 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 684 | java | package com.skypiea.system.model;
/**
* 作者: huangwenjian
* 描述:
* 创建时间: 2017-03-27 13:43
*/
public class PermissionInfo {
private int id;
//权限名称:如增加用户,删除用户等
private String name;
//权限标识代码
private String percode;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPercode() {
return percode;
}
public void setPercode(String percode) {
this.percode = percode;
}
}
| [
"[email protected]"
] | |
8a113de5289ce1f540a0dab23a90d6f191ac4e33 | 54691d0087f8389d32a01f41f58472c34c7f8ed1 | /app/src/main/java/com/ruyiruyi/ruyiruyi/ui/multiType/TireFigure.java | 64a25330cbd92ac2ae5b1570a31e53c49b2c8887 | [] | no_license | geyang2016/android | 2db017972359ce1fdf0909ce82a7c7f0e0b4d674 | 895c3e27d0c47df47e2dd18231a1c0735d00874c | refs/heads/master | 2020-03-09T21:49:50.501147 | 2018-04-11T06:43:20 | 2018-04-11T06:43:20 | 129,019,762 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,623 | java | package com.ruyiruyi.ruyiruyi.ui.multiType;
public class TireFigure {
public boolean isCheck ;
public int tuijian;
public String titleStr;
public String oneImage;
public String twoImage;
public String threeImage;
public String contentStr;
public TireFigure() {
}
public TireFigure(boolean isCheck,int tuijian, String titleStr, String oneImage, String twoImage, String threeImage, String contentStr) {
this.isCheck = isCheck;
this.tuijian = tuijian;
this.titleStr = titleStr;
this.oneImage = oneImage;
this.twoImage = twoImage;
this.threeImage = threeImage;
this.contentStr = contentStr;
}
public boolean isCheck() {
return isCheck;
}
public void setCheck(boolean check) {
isCheck = check;
}
public String getTitleStr() {
return titleStr;
}
public void setTitleStr(String titleStr) {
this.titleStr = titleStr;
}
public String getOneImage() {
return oneImage;
}
public void setOneImage(String oneImage) {
this.oneImage = oneImage;
}
public String getTwoImage() {
return twoImage;
}
public void setTwoImage(String twoImage) {
this.twoImage = twoImage;
}
public String getThreeImage() {
return threeImage;
}
public void setThreeImage(String threeImage) {
this.threeImage = threeImage;
}
public String getContentStr() {
return contentStr;
}
public void setContentStr(String contentStr) {
this.contentStr = contentStr;
}
} | [
"[email protected]"
] | |
42110149f1bb6d07e4714c98653828003393b37a | 589d79a4b49c13cfdf7b27ea60528ce9e5984aca | /src/main/java/cn/yangwanhao/bookstore/vo/CustomerAddressVo.java | b4330b5f60e544642e9284fab32e7a348c4efa3e | [] | no_license | zhongxianlong/bookstore-1 | 2674e417f1bb9e8221d5c80a3791eadd08ae1e1d | 0dea2093878b1ec3a3057aec5ba3b7cd508091ca | refs/heads/master | 2022-11-09T00:15:13.286722 | 2020-06-19T06:25:50 | 2020-06-19T06:25:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 614 | java | package cn.yangwanhao.bookstore.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* description
*
* @author 杨万浩
* @version 1.0.0
* @date 2019/12/26 17:41
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CustomerAddressVo implements Serializable {
private static final long serialVersionUID = -4087887583558734555L;
private Long id;
private Long customerId;
private String receiverName;
private String receiverPhone;
private String receiverAddress;
private Integer isDefault;
}
| [
"[email protected]"
] | |
a068830127fc7042699d8b20d3b2186522d7dc2b | c8e040e9f817e8c005f12ff45d9d1a85ca420804 | /part09-Part09_04.DifferentKindsOfBoxes/src/main/java/BoxWithMaxWeight.java | 102978c6e9db144e3e12c7aa5448983e9a75e238 | [] | no_license | orhanugurlu/mooc-java-programming-ii | 49d92822e67c7dc4785591b8ef675232c6225109 | 1bd28104bc0dae6c8fe92cb12a90d31351e81572 | refs/heads/master | 2022-12-29T02:10:08.733270 | 2020-07-15T21:01:28 | 2020-07-15T21:01:28 | 279,156,235 | 0 | 0 | null | 2020-10-13T23:31:11 | 2020-07-12T22:09:24 | Java | UTF-8 | Java | false | false | 668 | java |
import java.util.ArrayList;
public class BoxWithMaxWeight extends Box {
private int capacity;
private ArrayList<Item> items;
public BoxWithMaxWeight(int capacity) {
this.capacity = capacity;
items = new ArrayList<>();
}
private int weight() {
int sum = 0;
for (Item item : items) {
sum += item.getWeight();
}
return sum;
}
@Override
public void add(Item item) {
if (item.getWeight() + weight() <= capacity) {
items.add(item);
}
}
@Override
public boolean isInBox(Item item) {
return items.contains(item);
}
}
| [
"[email protected]"
] | |
8f8168ff24c3b1b15f068422d39dc1ed4871e4fa | 255f155526ffb803a9d7dc5864b8826f84377a84 | /springboot-microservice-demo/src/test/java/com/springboot/microservice/demo/SpringbootMicroserviceDemoApplicationTests.java | a815eeeab978112372c5403372582ced8640cb02 | [
"Apache-2.0"
] | permissive | multifort/spring-boot-example | 572cdf1cc235a4900a60df5c61cd76794fb97134 | cccc30d4b27dde686182524e46044a127e1aaacb | refs/heads/master | 2020-03-23T04:22:00.352223 | 2019-02-13T09:14:23 | 2019-02-13T09:14:23 | 141,079,008 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 379 | java | package com.springboot.microservice.demo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringbootMicroserviceDemoApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"[email protected]"
] | |
dee93c8b4dcf663c4bf06e457c2746af1b12d0d5 | a5d01febfd8d45a61f815b6f5ed447e25fad4959 | /Source Code/5.27.0/sources/com/iqoption/core/f/b.java | 560adcd7126c4929d5e6c0c3609f6afe84996c65 | [] | no_license | kkagill/Decompiler-IQ-Option | 7fe5911f90ed2490687f5d216cb2940f07b57194 | c2a9dbbe79a959aa1ab8bb7a89c735e8f9dbc5a6 | refs/heads/master | 2020-09-14T20:44:49.115289 | 2019-11-04T06:58:55 | 2019-11-04T06:58:55 | 223,236,327 | 1 | 0 | null | 2019-11-21T18:17:17 | 2019-11-21T18:17:16 | null | UTF-8 | Java | false | false | 8,100 | java | package com.iqoption.core.f;
import com.iqoption.core.d;
import com.iqoption.core.util.r;
import com.squareup.picasso.Picasso;
import io.reactivex.b.f;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import kotlin.i;
@i(bne = {1, 1, 15}, bnf = {"\u0000P\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010 \n\u0000\n\u0002\u0010$\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0000\bÆ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0010\u0010\r\u001a\u0004\u0018\u00010\u00042\u0006\u0010\u000e\u001a\u00020\u0004J\u0012\u0010\u000f\u001a\u0004\u0018\u00010\u00042\u0006\u0010\u0010\u001a\u00020\u0011H\u0002J\u0006\u0010\u0012\u001a\u00020\u0013J\u0016\u0010\u0014\u001a\u00020\u00152\f\u0010\u0016\u001a\b\u0012\u0004\u0012\u00020\u00110\u0017H\u0002J\u0014\u0010\u0018\u001a\u000e\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\u00110\u0019H\u0002J \u0010\u001a\u001a\u00020\u00152\u0006\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u001b\u001a\u00020\u00042\u0006\u0010\u001c\u001a\u00020\u001dH\u0002R\u0016\u0010\u0003\u001a\n \u0005*\u0004\u0018\u00010\u00040\u0004X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0004X\u0004¢\u0006\u0002\n\u0000R\u001a\u0010\t\u001a\u000e\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\u00040\nX\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\fX\u0004¢\u0006\u0002\n\u0000¨\u0006\u001e"}, bng = {"Lcom/iqoption/core/resources/ResourceManager;", "", "()V", "TAG", "", "kotlin.jvm.PlatformType", "initLatch", "Ljava/util/concurrent/CountDownLatch;", "resolution", "resourceMap", "Ljava/util/concurrent/ConcurrentHashMap;", "resourcesStorage", "Lcom/iqoption/core/resources/ResourcesStorage;", "getResUrlSync", "resourceId", "getResourceUrl", "resource", "Lcom/iqoption/core/microservices/resources/responses/ResourceElement;", "prefetchResources", "Lio/reactivex/Completable;", "processInitResources", "", "resourceList", "", "restorePersistent", "", "schedulePreFetch", "url", "reFetch", "", "core_release"})
/* compiled from: ResourceManager.kt */
public final class b {
private static final String TAG = b.class.getSimpleName();
private static final ConcurrentHashMap<String, String> bEH = new ConcurrentHashMap();
private static final c bEI = new c();
public static final b bEJ = new b();
private static final String bxT = com.iqoption.core.microservices.d.a.bxS.agX();
private static final CountDownLatch zn = new CountDownLatch(1);
@i(bne = {1, 1, 15}, bnf = {"\u0000\u0014\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u00012\u001a\u0010\u0002\u001a\u0016\u0012\u0004\u0012\u00020\u0004 \u0005*\n\u0012\u0004\u0012\u00020\u0004\u0018\u00010\u00030\u0003H\n¢\u0006\u0002\b\u0006"}, bng = {"<anonymous>", "", "it", "", "Lcom/iqoption/core/microservices/resources/responses/ResourceElement;", "kotlin.jvm.PlatformType", "accept"})
/* compiled from: ResourceManager.kt */
static final class a<T> implements f<List<? extends com.iqoption.core.microservices.d.a.b>> {
public static final a bEK = new a();
a() {
}
/* renamed from: v */
public final void accept(List<com.iqoption.core.microservices.d.a.b> list) {
b bVar = b.bEJ;
kotlin.jvm.internal.i.e(list, "it");
bVar.aD(list);
b.zn.countDown();
}
}
private b() {
}
public final io.reactivex.a ajY() {
io.reactivex.a blm = com.iqoption.core.microservices.d.a.a(com.iqoption.core.microservices.d.a.bxS, null, null, 3, null).h((f) a.bEK).blm();
kotlin.jvm.internal.i.e(blm, "ResourceRequests.getReso… }.toCompletable()");
return blm;
}
public final String gZ(String str) {
kotlin.jvm.internal.i.f(str, "resourceId");
try {
zn.await(3, TimeUnit.SECONDS);
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
}
String str2 = (String) bEH.get(str);
if (str2 != null) {
return str2;
}
List list;
try {
list = (List) com.iqoption.core.microservices.d.a.bxS.ap(str, bxT).ble();
} catch (Throwable unused2) {
list = (List) null;
}
if (list == null) {
return null;
}
for (Object next : list) {
if (kotlin.jvm.internal.i.y(((com.iqoption.core.microservices.d.a.b) next).getId(), str)) {
break;
}
}
Object next2 = null;
com.iqoption.core.microservices.d.a.b bVar = (com.iqoption.core.microservices.d.a.b) next2;
if (bVar == null) {
return null;
}
str2 = a(bVar);
if (str2 != null) {
bEH.put(str, str2);
}
return a(bVar);
}
private final void aD(List<com.iqoption.core.microservices.d.a.b> list) {
Map ajZ = ajZ();
for (com.iqoption.core.microservices.d.a.b bVar : list) {
String a = bEJ.a(bVar);
if (a != null) {
com.iqoption.core.microservices.d.a.b bVar2 = (com.iqoption.core.microservices.d.a.b) ajZ.get(bVar.getId());
boolean z = false;
if (bVar2 != null && bVar2.aha() < bVar.aha()) {
z = true;
}
bEH.put(bVar.getId(), a);
bEJ.a(bVar, a, z);
}
}
try {
bEI.aE(list);
} catch (Throwable unused) {
}
}
private final Map<String, com.iqoption.core.microservices.d.a.b> ajZ() {
Map linkedHashMap = new LinkedHashMap();
try {
for (com.iqoption.core.microservices.d.a.b bVar : bEI.aka()) {
String a = bEJ.a(bVar);
if (a != null) {
bEH.put(bVar.getId(), a);
}
linkedHashMap.put(bVar.getId(), bVar);
}
} catch (Throwable unused) {
}
return linkedHashMap;
}
private final void a(com.iqoption.core.microservices.d.a.b bVar, String str, boolean z) {
String type = bVar.getType();
int hashCode = type.hashCode();
if (hashCode != 3143036) {
if (hashCode == 100313435 && type.equals("image")) {
Picasso with = Picasso.with(d.Uo());
kotlin.jvm.internal.i.e(with, "Picasso.with(appContext)");
r.a(with, bVar.getId()).fetch();
}
} else if (type.equals("file")) {
a.bEA.e(bVar.getId(), str, z);
}
}
private final String a(com.iqoption.core.microservices.d.a.b bVar) {
Object obj;
String str;
List agZ = bVar.agZ();
Iterator it = agZ.iterator();
do {
str = null;
if (!it.hasNext()) {
obj = null;
break;
}
obj = it.next();
} while (!kotlin.jvm.internal.i.y(bxT, ((com.iqoption.core.microservices.d.a.a) obj).agX()));
com.iqoption.core.microservices.d.a.a aVar = (com.iqoption.core.microservices.d.a.a) obj;
if (aVar == null) {
aVar = (com.iqoption.core.microservices.d.a.a) u.bV(agZ);
}
if (aVar == null) {
return null;
}
if (kotlin.jvm.internal.i.y(bVar.getType(), "image")) {
str = aVar.YE();
} else if (kotlin.jvm.internal.i.y(bVar.getType(), "file")) {
str = aVar.agY();
}
return str;
}
}
| [
"[email protected]"
] | |
511c7b107a5eacf1ce5f10d7803c143cc21a0a60 | 7c3fcfedc29ad41dfdbb4ff9192419a949611e2d | /src/States/Level4.java | b2d81b37e9023cd85eb1744a4af343ba5cc8bf59 | [] | no_license | FalconXYX/Fall-of-Rome | caf444b909cd6dc32cc5e720a6ccd2ba0f9ab5e7 | 42e4faf67f16b8a4fdae36f79d293c1dfcd089c4 | refs/heads/master | 2023-01-07T11:22:33.641174 | 2020-11-12T17:35:18 | 2020-11-12T17:35:18 | 308,458,013 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,529 | java | package States;
import ButtonClasses.*;
import UnitClasses.*;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import javax.swing.JOptionPane;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.*;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.*;
public class Level4 extends BasicGameState {
Input in;
Unit enemyarcher, enemyswordsman, enemyspearman;
ArrayList<Unit> enemyunits;
Image goldimg, back;
int timer;
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
timer = 0;
Launcher.isinstuctions = true;
back = new Image("src/Images/Rome.png");
goldimg = new Image("src/Images/Money.png");
System.out.println(Launcher.units.size());
enemyunits = new ArrayList<Unit>();
enemyunits.add(new Archer("n", 3));
enemyunits.add(new Swordsman("n", 2));
enemyunits.add(new Swordsman("n", 2));
enemyunits.add(new Swordsman("n", 2));
enemyunits.add(new Archer("n", 3));
for (Unit u : enemyunits) {
if (u != null) {
u.settarget(enemyunits.indexOf(u));
}
}
for (Unit u : Launcher.units) {
if (u != null) {
u.settarget(Launcher.units.indexOf(u));
}
}
for (Unit u:Launcher.units) {
if(u != null){
u.heal();
}}
}
public void attacks() {
for (Unit u : Launcher.units) {
if (u != null) {
Unit targeted = enemyunits.get(u.gettarget());
if (targeted != null) {
targeted.takedamage(u.dodamage(targeted));
u.takedamage(targeted.defensedamage(u));
}
}
}
for (Unit u : enemyunits) {
if (u != null) {
Unit targeted = Launcher.units.get(u.gettarget());
if (targeted != null) {
targeted.takedamage(u.dodamage(targeted));
u.takedamage(targeted.defensedamage(u));
}
}
}
for (Unit u : Launcher.units) {
if (u != null) {
if (u.gethealth() <= 0) {
Launcher.units.set(Launcher.units.indexOf(u), null);
}}
}
for (Unit u : enemyunits) {
if (u != null) {
if (u.gethealth() <= 0) {
enemyunits.set(enemyunits.indexOf(u), null);
Launcher.gold+=50;
}}
}
}
public void move(Input in) {
if (in.isKeyDown(Input.KEY_M) ) {
int countclicked = 0;
ArrayList<Integer> thing;
thing = new ArrayList();
boolean hit[] = new boolean[5];
for (int i = 0; i < 5; i++) {
hit[i] = false;
}
if (in.isKeyDown(Input.KEY_1)) {
hit[0] = true;
countclicked++;
}
if (in.isKeyDown(Input.KEY_2)) {
hit[1] = true;
countclicked++;
}
if (in.isKeyDown(Input.KEY_3)) {
hit[2] = true;
countclicked++;
}
if (in.isKeyDown(Input.KEY_4)) {
hit[3] = true;
countclicked++;
}
if (in.isKeyDown(Input.KEY_5)) {
hit[4] = true;
countclicked++;
}
if(countclicked == 2){
for (int i = 0; i < 5; i++) {
if (hit[i]) {
thing.add(i);
}
}
if (thing.get(0) != thing.get(1)) {
System.out.println(thing.get(0) +" "+ thing.get(1));
swap(Launcher.units.get(thing.get(0)),thing.get(0),thing.get(1),Launcher.units.get(thing.get(1)));
return;
}
}
}}
public void swap(Unit u,int a, int b, Unit c){
Unit temp1 = u;
Unit temp2 = c;
Launcher.units.set(b, u);
Launcher.units.set(a, c);
}
public void TargetUpgrade(Input in) {
Unit current = null;
if (in.isKeyDown(Input.KEY_1) && Launcher.units.get(0) != null) {
current = Launcher.units.get(0);
if (in.isKeyDown(Input.KEY_U)) {
if (Launcher.gold >= current.getupgradecost()) {
Launcher.gold -= current.getupgradecost();
current.uprank();
try {
TimeUnit.MILLISECONDS.sleep(50);
return;
} catch (InterruptedException ex) {
}
}
}
int original = current.gettarget();
if (in.isKeyDown(Input.KEY_LEFT)) {
try {
current.settarget(Launcher.units.indexOf(current) - 1);
} catch (Exception e) {
}
}
if (in.isKeyDown(Input.KEY_RIGHT)) {
try {
current.settarget(Launcher.units.indexOf(current) + 1);
} catch (Exception e) {
}
}
if (in.isKeyDown(Input.KEY_UP)) {
current.settarget(Launcher.units.indexOf(current));
}
if(current.gettarget() <0 || current.gettarget() >4){
current.settarget(original);
return;}
}
if (in.isKeyDown(Input.KEY_2) && Launcher.units.get(1) != null) {
current = Launcher.units.get(1);
int original = current.gettarget();
if (in.isKeyDown(Input.KEY_U)) {
if (Launcher.gold >= current.getupgradecost()) {
Launcher.gold -= current.getupgradecost();
current.uprank();
try {
TimeUnit.MILLISECONDS.sleep(50);
return;
} catch (InterruptedException ex) {
}
}
}
if (in.isKeyDown(Input.KEY_LEFT)) {
try {
current.settarget(Launcher.units.indexOf(current) - 1);
} catch (Exception e) {
}
}
if (in.isKeyDown(Input.KEY_RIGHT)) {
try {
current.settarget(Launcher.units.indexOf(current) + 1);
} catch (Exception e) {
}
}
if (in.isKeyDown(Input.KEY_UP)) {
current.settarget(Launcher.units.indexOf(current));
}
if(current.gettarget() <0 || current.gettarget() >4){
current.settarget(original);
return;}
}
if (in.isKeyDown(Input.KEY_3) && Launcher.units.get(2) != null) {
current = Launcher.units.get(2);
int original = current.gettarget();
if (in.isKeyDown(Input.KEY_U)) {
if (Launcher.gold >= current.getupgradecost()) {
Launcher.gold -= current.getupgradecost();
current.uprank();
try {
TimeUnit.MILLISECONDS.sleep(50);
return;
} catch (InterruptedException ex) {
}
}
}
if (in.isKeyDown(Input.KEY_LEFT)) {
try {
current.settarget(Launcher.units.indexOf(current) - 1);
} catch (Exception e) {
}
}
if (in.isKeyDown(Input.KEY_RIGHT)) {
try {
current.settarget(Launcher.units.indexOf(current) + 1);
} catch (Exception e) {
}
}
if (in.isKeyDown(Input.KEY_UP)) {
current.settarget(Launcher.units.indexOf(current));
}
if(current.gettarget() <0 || current.gettarget() >4){
current.settarget(original);
return;}
}
if (in.isKeyDown(Input.KEY_4) && Launcher.units.get(3) != null) {
current = Launcher.units.get(3);
int original = current.gettarget();
if (in.isKeyDown(Input.KEY_U)) {
if (Launcher.gold >= current.getupgradecost()) {
Launcher.gold -= current.getupgradecost();
current.uprank();
try {
TimeUnit.MILLISECONDS.sleep(50);
return;
} catch (InterruptedException ex) {
}
}
}
if (in.isKeyDown(Input.KEY_LEFT)) {
try {
current.settarget(Launcher.units.indexOf(current) - 1);
return;
} catch (Exception e) {
}
}
if (in.isKeyDown(Input.KEY_RIGHT)) {
try {
current.settarget(Launcher.units.indexOf(current) + 1);
} catch (Exception e) {
}
}
if (in.isKeyDown(Input.KEY_UP)) {
current.settarget(Launcher.units.indexOf(current));
}
if(current.gettarget() <0 || current.gettarget() >4){
current.settarget(original);
return;}
}
if (in.isKeyDown(Input.KEY_5) && Launcher.units.get(4) != null) {
current = Launcher.units.get(4);
int original = current.gettarget();
if (in.isKeyDown(Input.KEY_U)) {
if (Launcher.gold >= current.getupgradecost()) {
Launcher.gold -= current.getupgradecost();
current.uprank();
try {
TimeUnit.MILLISECONDS.sleep(150);
} catch (InterruptedException ex) {
}
}
}
if (in.isKeyDown(Input.KEY_LEFT)) {
try {
current.settarget(Launcher.units.indexOf(current) - 1);
} catch (Exception e) {
}
}
if (in.isKeyDown(Input.KEY_RIGHT)) {
try {
current.settarget(Launcher.units.indexOf(current) + 1);
} catch (Exception e) {
}
}
if (in.isKeyDown(Input.KEY_UP)) {
current.settarget(Launcher.units.indexOf(current));
}
if(current.gettarget() <0 || current.gettarget() >4){
current.settarget(original);
return;}
}
}
public void death(StateBasedGame sbg){
int dead = 0;
//if you have lost all units go to death screen
for (Unit u:Launcher.units) {
if (u==null) {dead++;
}
}
if (dead==5) {
sbg.enterState(10, new FadeOutTransition(), new FadeInTransition());
}
//if you have killed all units go to next screen
dead = 0;
for (Unit u:enemyunits) {
if (u==null) {dead++;
}
}
if (dead==5) {
Launcher.level++;
Launcher.gold+=100;
for (Unit u:Launcher.units) {
if(u != null){
u.heal();
}else{
Launcher.units.remove(u);
break;
}
}
sbg.enterState(9, new FadeOutTransition(), new FadeInTransition());
}
}
public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException {
timer++;
if (timer == 5) {
for (Unit u:Launcher.units) {
if(u != null){
System.out.println("Healed");
u.heal();
}}
}
Input in = gc.getInput();
int mx = in.getMouseX();
int my = in.getMouseY();
TargetUpgrade(in);
death(sbg);
if (timer % 20 == 0) {
move(in);
}
if (timer % 200 == 0) {
attacks();
}
}
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
for (Unit u : Launcher.units) {
if (u != null) {
u.setrankimg();
}
}
for (Unit u : enemyunits) {
if (u != null) {
u.setrankimg();
}
}
back.draw(0, 1);
goldimg.draw(80, 13);
g.setColor(Color.white);
g.drawString("" + Launcher.gold, 35, 13);
for (int i = 0; i < Launcher.units.size(); i++) {
Unit u = Launcher.units.get(i);
if (u != null) {
u.setx((i * 200) + 120);
u.sety(430);
u.draw(g);
g.setColor(Color.white);
}
}
for (int i = 0; i < 5; i++) {
Unit u = enemyunits.get(i);
if (u != null) {
g.setColor(Color.white);
u.setx((i * 200) + 120);
u.sety(190);
u.draw(g);
}
}
for (Unit u : enemyunits) {
if (u != null) {
u.calc();
}}
for (Unit u : Launcher.units) {
if (u != null) {
u.calc();
}}
}
public int getID() {
return 7; //this id will be different for each screen
}
}
| [
"[email protected]"
] | |
f72e87a9647aa3f4834c99be5c85938e7eb9f408 | 35a19519c796352a1d992a3f243c9f66db29c856 | /src/main/java/local/home/azav/java/hw7_classloaders/variant01/app/AppClassloader.java | 1f85f1aab3590841bbca92211c9505ae55ab2ccb | [] | no_license | Glukoprav/Java-cource | 61b2bbf580f49c2a2780a83400b4c8bff4c35e36 | 46961340bcc5c13420ba02c056f2f353ade65943 | refs/heads/master | 2021-08-08T20:55:46.284520 | 2018-10-24T19:04:02 | 2018-10-24T19:04:02 | 133,042,273 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 721 | java | package local.home.azav.java.hw7_classloaders.variant01.app;
import local.home.azav.java.hw7_classloaders.variant01.api.ApiClassloader;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Classloader для класса AppCalc
*/
public class AppClassloader extends ApiClassloader {
private static final Logger LOG = Logger.getLogger(AppClassloader.class.getName());
public AppClassloader() {
super();
LOG.log(Level.INFO,"AppClassloader после вызова родителя");
}
@Override
public Class<?> loadClass() throws ClassNotFoundException {
return super.loadClass("local.home.azav.java.hw7_classloaders.variant01.app.AppCalc");
}
}
| [
"[email protected]"
] | |
d8c89dec38890357c408bef19abb99292a3923cb | fe8b5232799c5ded3251ca3b52898608346b1b59 | /app/src/main/java/pl/mogrodowski/zakazaneslowa/util/CardUpdater.java | 789902563211b985594b87f805bf5d2e1f78f88e | [] | no_license | mogrodowski/ZakazaneSlowa | e863e6c822d907031442e01fb8eb4b346a4bab6d | 1463772200e90fe2adf082f4be12ededdc5307af | refs/heads/master | 2016-09-16T09:53:54.930262 | 2015-08-27T19:12:51 | 2015-08-27T19:12:51 | 39,792,918 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,594 | java | package pl.mogrodowski.zakazaneslowa.util;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import pl.mogrodowski.zakazaneslowa.Constants;
import pl.mogrodowski.zakazaneslowa.data.DataManagerI;
import pl.mogrodowski.zakazaneslowa.model.Card;
public class CardUpdater extends AsyncTask<Void, Void, Boolean> {
private final String CARDS_API = "http://portaboo.mogrodowski.pl/api/cards";
private TextView update_cards_status;
private DataManagerI dataManager;
public CardUpdater(TextView textView, DataManagerI dataManager){
this.update_cards_status = textView;
this.dataManager = dataManager;
}
//TODO: zamiast TextView moze byc ImageView - dac jakis preloader
@Override
protected void onPreExecute(){
update_cards_status.setText("Rozpoczynam pobieranie...");
}
@Override
protected Boolean doInBackground(Void... params){
Log.i(Constants.LOG_TAG, "start update cards");
String cards_json = "";
try{
URL url = new URL(this.CARDS_API);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
while((inputLine = in.readLine()) != null){
cards_json += inputLine;
}
in.close();
Log.i(Constants.LOG_TAG, "Pobrany json: " + cards_json);
JSONArray cards = new JSONArray(cards_json);
dataManager.deleteCards();
for(int i = 0; i < cards.length(); i++){
JSONObject c = cards.getJSONObject(i);
Card card = new Card(c.getString("head_word"), c.getString("word_1"),
c.getString("word_2"), c.getString("word_3"), c.getString("word_4"), c.getString("word_5"));
dataManager.saveCard(card);
Log.i(Constants.LOG_TAG, "Card added");
}
}
catch(Exception e){
e.printStackTrace();
return false;
}
Log.i(Constants.LOG_TAG, "end update cards");
return true;
}
@Override
protected void onPostExecute(Boolean result) {
if(result){
update_cards_status.setText("Pobranie zakończone sukcesem. Liczba kart w bazie: " + dataManager.getCards().size());
}
else{
update_cards_status.setText("Błąd podczas pobierania");
}
}
}
| [
"[email protected]"
] | |
2eb4415cde417837922de52c3fc40ee3475f3cd7 | 955c3dfbc82defaa319dde13d41ab75b71313043 | /web01/src/com/IE.java | b15070a76b085025d21947eed791d1bc1be26724 | [] | no_license | dark-riu/java | e6c1ecf3fc6003d716d6fc9f6238b816886a79fa | 93458b1390f5c7ae8faabde7bd3d778a0a907d9b | refs/heads/master | 2020-11-24T12:49:39.474877 | 2020-04-14T09:37:13 | 2020-04-14T09:37:13 | 228,145,345 | 0 | 0 | null | 2019-12-15T07:31:05 | 2019-12-15T07:23:10 | null | UTF-8 | Java | false | false | 1,077 | java | package com;
import java.lang.reflect.Field;
public class IE {
public static void main(String[] args) throws Exception {
Student stu1 = new Student("张三", 23, 1984367, "男", "中国");
Student stu2 = new Student("王舞", 18, 23648, "女", "中国");
Class c = Student.class;
Field[] fields = c.getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
if (!field.get(stu1).equals(field.get(stu2))) {
System.out.println(field.getName() + "不同:" + "stu1的值是:" + (field.get(stu1) + "") + "," + "stu2的值是" + (field.get(stu2) + ""));
}
}
}
}
class Student {
private String name;
private int age;
private int no;
private String sex;
private String country;
public Student(String name, int age, int no, String sex, String country) {
this.name = name;
this.age = age;
this.no = no;
this.sex = sex;
this.country = country;
}
}
| [
"[email protected]"
] | |
f435c6eab7dd680cdbe27f5a14215d34b63da517 | 938f00a6a9722b92070794639ecf13ffd3318d3f | /scrollviewanimation/src/test/java/com/zy/scrollviewanimation/ExampleUnitTest.java | 5bdbc86ad364d348fb01799da14601b518331ff5 | [] | no_license | zhangyuesx215/scrollview | f99ed79aed9265ef2b10f08bfef0acb4ed0e7634 | c4accb1b61cfab0da86333c442c874d9ea914599 | refs/heads/master | 2020-05-16T03:31:42.436088 | 2019-04-22T09:25:31 | 2019-04-22T09:25:31 | 182,725,609 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 387 | java | package com.zy.scrollviewanimation;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
a1ad725b760af6b3a86ffa0b3c65af7fa1534e9e | da6358f3efd22d39ba99e2061e3fa99bc262a2ed | /src/main/java/com/controller/HospitalizedController.java | 4e156663c3f84074b00a190f86e5b493695a78ea | [] | no_license | karsa99716/hospyyghsysboot | 5f08e94cfb800260219a09db0269924be5a49049 | 2e448a66a350499c3441805915bc2f9fbf040dcb | refs/heads/master | 2023-06-01T22:11:50.836013 | 2021-06-16T23:57:56 | 2021-06-16T23:57:56 | 377,655,079 | 15 | 4 | null | null | null | null | UTF-8 | Java | false | false | 6,527 | java | package com.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bean.Disease;
import com.bean.Hospitalized;
import com.bean.Inventory;
import com.bean.Office;
import com.bean.Prescriptionmsg;
import com.bean.Registration;
import com.bean.Sysuser;
import com.bean.Userdrug;
import com.dao.DiseaseDAO;
import com.dao.HospitalizedDAO;
import com.dao.InventoryDAO;
import com.dao.OfficeDAO;
import com.dao.RegistrationDAO;
import com.dao.SysuserDAO;
import com.dao.UserdrugDAO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.util.Info;
import java.util.*;
@Controller
public class HospitalizedController extends BaseController {
@Resource
HospitalizedDAO hospitalizedDAO;
@Resource
RegistrationDAO registrationDAO;
@Resource
OfficeDAO officeDAO;
@Resource
UserdrugDAO userdrugDAO;
@Resource
Saveobject saveobject;
@Resource
InventoryDAO inventoryDAO;
@Resource
SysuserDAO sysuserDAO;
//入院列表
@ResponseBody
@RequestMapping("admin/hospitalizedList")
public HashMap<String,Object> hospitalizedList(@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,@RequestParam(defaultValue = "1",value = "pageSize") Integer pageSize,HttpServletRequest request){
Sysuser member = (Sysuser)request.getSession().getAttribute("admin");
String key = request.getParameter("key");
String iscy = request.getParameter("iscy");
double usertotal = 0D;
HashMap<String,Object> res = new HashMap<String,Object>();
HashMap<String,String> map = new HashMap<String,String>();
map.put("key", key);
map.put("iscy",iscy);
if(member.getUsertype().equals("患者")){
map.put("memberid",String.valueOf(member.getId()));
}
System.out.println(map);
List<Hospitalized> rlist = hospitalizedDAO.selectAll(map);
PageHelper.startPage(pageNum, pageSize);
List<Hospitalized> list = hospitalizedDAO.selectAll(map);
System.out.println("list=="+list.size());
for(Hospitalized hospitalized:list){
Registration registration = registrationDAO.findById(Integer.parseInt(hospitalized.getRegistid()));
System.out.println("aaaaaa=="+registration.getMemberid());
Sysuser mmm = sysuserDAO.findById(Integer.parseInt(registration.getMemberid()));
registration.setMember(mmm);
Office office = officeDAO.findById(Integer.parseInt(registration.getOfficeid()));
registration.setOffice(office);
hospitalized.setRegistration(registration);
usertotal+=hospitalized.getYytotal()+hospitalized.getProjecttotal();
hospitalized.setUsertotal(usertotal);
}
PageInfo<Hospitalized> pageInfo = new PageInfo<Hospitalized>(list);
res.put("pageInfo", pageInfo);
res.put("list", rlist);
return res;
}
//添加入院
@ResponseBody
@RequestMapping("admin/hospitalizedAdd")
public HashMap<String,Object> hospitalizedAdd(Hospitalized hospitalized ,HttpServletRequest request) {
HashMap<String,Object> res = new HashMap<String,Object>();
HashMap<String,String> map = new HashMap<String,String>();
map.put("registid", hospitalized.getRegistid());
map.put("iscy", "未出院");
List<Hospitalized> list = hospitalizedDAO.selectAll(map);
if(list.size()==0){
hospitalized.setSavetime(Info.getDateStr().substring(0,10));
hospitalized.setIscy("未出院");
hospitalizedDAO.add(hospitalized);
res.put("data", 200);
}else{
res.put("data", 400);
}
return res;
}
//编辑入院
@ResponseBody
@RequestMapping("admin/hospitalizedShow")
public HashMap<String,Object> hospitalizedShow(int id,HttpServletRequest request) {
HashMap<String,Object> res = new HashMap<String,Object>();
Hospitalized hospitalized = hospitalizedDAO.findById(id);
Registration registration = registrationDAO.findById(Integer.parseInt(hospitalized.getRegistid()));
Sysuser member = sysuserDAO.findById(Integer.parseInt(registration.getMemberid()));
registration.setMember(member);
Office office = officeDAO.findById(Integer.parseInt(registration.getOfficeid()));
registration.setOffice(office);
hospitalized.setRegistration(registration);
res.put("hospitalized", hospitalized);
return res;
}
//出院
@ResponseBody
@RequestMapping("admin/hospitalizedEdit")
public HashMap<String,Object> hospitalizedEdit(int id ,HttpServletRequest request) {
HashMap<String,Object> res = new HashMap<String,Object>();
Sysuser user = (Sysuser)request.getSession().getAttribute("admin");
Hospitalized hospitalized = hospitalizedDAO.findById(id);
HashMap<String,String> map = new HashMap<String,String>();
map.put("hospitalizedid", String.valueOf(id));
List<Userdrug> userdruglist = userdrugDAO.selectAll(map);
boolean flag = true;
for(Userdrug userdrug:userdruglist){
int num = userdrug.getNum();
int kc = saveobject.getInventoryNum(userdrug.getProductid(), request);
if(kc<num){
flag=false;
break;
}
}
if(flag==true){
for(Userdrug userdrug:userdruglist){
Inventory inventory = new Inventory();
inventory.setDelstatus("0");
inventory.setFlag("out");
inventory.setProductid(userdrug.getProductid());
inventory.setNum(userdrug.getNum());
inventory.setSavetime(Info.getDateStr());
inventory.setUserid(String.valueOf(user.getId()));
inventoryDAO.add(inventory);
}
double usertotal = hospitalized.getYytotal()+hospitalized.getProjecttotal();
double sytotal = 0D;
if(usertotal<=hospitalized.getTotal()){
sytotal = hospitalized.getTotal()-usertotal;
hospitalized.setTktotal(sytotal);
}else{
sytotal = usertotal-hospitalized.getTotal();
hospitalized.setBjtotal(sytotal);
}
hospitalized.setUserid(String.valueOf(user.getId()));
hospitalized.setCysavetime(Info.getDateStr().substring(0,10));
hospitalized.setIscy("已出院");
hospitalizedDAO.update(hospitalized);
res.put("data", 200);
}else{
res.put("data", 400);
}
return res;
}
//删除入院
@ResponseBody
@RequestMapping("admin/hospitalizedDel")
public HashMap<String,Object> hospitalizedDel(int id,HttpServletRequest request) {
hospitalizedDAO.delete(id);
return null;
}
}
| [
"[email protected]"
] | |
617675022f618bd1f4ce132ea4da7189db62a625 | 0ad99a9c8040748103232f616f002131c7815849 | /src/main/java/com/mycompany/myapp/repository/PartSaleRepository.java | f5b0a124d89da4c274b8fa83bdee95d0575657d7 | [] | no_license | EinkaufHilfe/jhipster-sample-application | 6519392974118e4e62a13114df2286f2b19fd609 | 1a334dc5d153f6accf80499b7ec348fcf3ec4368 | refs/heads/main | 2023-03-25T12:34:13.188324 | 2021-03-14T19:09:01 | 2021-03-14T19:09:01 | 347,718,571 | 0 | 0 | null | 2021-03-14T18:25:01 | 2021-03-14T18:24:14 | Java | UTF-8 | Java | false | false | 365 | java | package com.mycompany.myapp.repository;
import com.mycompany.myapp.domain.PartSale;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
/**
* Spring Data repository for the PartSale entity.
*/
@SuppressWarnings("unused")
@Repository
public interface PartSaleRepository extends JpaRepository<PartSale, Long> {
}
| [
"[email protected]"
] | |
7c98cbfd76e387d7a15caad9408b614346400812 | 82cc7a453c72f879f428b1cd73904007aaa9d74d | /src/main/java/app/UserRepositoryAuthenticationProvider.java | c87e97d92e3fd3b4baf381b6d57ff149cf7b5ba4 | [
"Apache-2.0"
] | permissive | hesfat/ssdd | e692705b771c47e145962dc3e1b1c58957e9ef4f | ecf8e3018357dab364f28fea2d8b2be829ee4f0f | refs/heads/master | 2021-01-22T06:07:30.358567 | 2017-05-20T07:41:07 | 2017-05-20T07:41:07 | 81,739,004 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,828 | java | package app;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;
import app.entities.Usuario;
import app.repositories.UsuariosRepository;
@Component
public class UserRepositoryAuthenticationProvider implements AuthenticationProvider {
@Autowired
private UsuariosRepository userRepository;
@Override
public Authentication authenticate(Authentication auth) throws AuthenticationException {
Usuario user = userRepository.findByNombre(auth.getName());
if (user == null) {
throw new BadCredentialsException("User not found");
}
String password = (String) auth.getCredentials();
if (!new BCryptPasswordEncoder().matches(password, user.getPasswordHash())) {
throw new BadCredentialsException("Wrong password");
}
List<GrantedAuthority> roles = new ArrayList<>();
for (String role : user.getRoles()) {
roles.add(new SimpleGrantedAuthority(role));
}
return new UsernamePasswordAuthenticationToken(user, password, roles);
}
@Override
public boolean supports(Class<?> authentication) {
return authentication.equals(
UsernamePasswordAuthenticationToken.class);
}
}
| [
"[email protected]"
] | |
a19861e5db621e821419fbc14dfd7111088a0ca5 | 8a11cccd52030d91ed8e4642874259d2db0003e8 | /BiancardiGame/src/Battle.java | 3bff25ba808d2d58af0c45a2883647349568737d | [] | no_license | CarterGoldman/BiancardiGame | de84ff5b613bd00a067692c5f6379dca7f2ccbfa | f50c770cc65074ff9d8b7fce532c1503d52b60bc | refs/heads/master | 2020-12-30T15:09:02.534158 | 2017-05-25T18:35:16 | 2017-05-25T18:35:16 | 91,115,175 | 1 | 3 | null | 2017-05-19T18:27:47 | 2017-05-12T17:36:29 | Java | UTF-8 | Java | false | false | 5,973 | java |
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class Battle extends JFrame implements Runnable
{
private static final long serialVersionUID = 1L;
public int mapWidth = 26;
public int mapHeight = 35;
public static int health = 240;
private Thread thread;
private boolean running;
private BufferedImage image;
public int[] pixels;
public ArrayList<Texture> textures;
public static Camera camera;
public static Droid droid;
public Screen screen;
public int winner = 0;
public static int[][] map = {{1,2,1,2,4,3,4,2,1,2,1,2,8,9,2,1,2,1,2,4,3,4,2,1,2,1},
{2,0,0,0,0,0,0,0,1,2,1,0,0,0,0,1,2,1,0,0,0,0,0,0,0,2},
{1,0,0,0,0,0,2,4,0,0,0,0,0,0,0,0,0,0,4,2,0,0,0,0,0,1},
{2,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,2},
{1,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,1},
{4,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,4},
{1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1},
{2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,2},
{1,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,1},
{2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2},
{1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1},
{4,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,4},
{1,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,1},
{2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
{2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
{4,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
{2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
{2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2},
{1,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,1},
{4,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,4},
{1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1},
{2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2},
{1,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,1},
{2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,2},
{1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1},
{4,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,4},
{1,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,1},
{2,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,2},
{1,0,0,0,0,0,2,4,0,0,0,0,0,0,0,0,0,0,4,2,0,0,0,0,0,1},
{2,0,0,0,0,0,0,0,1,2,1,0,0,0,0,1,2,1,0,0,0,0,0,0,0,2},
{1,2,1,2,4,3,4,2,1,2,1,2,9,8,2,1,2,1,2,4,3,4,2,1,2,1}};
public Battle()
{
thread = new Thread(this);
image = new BufferedImage(640, 480, BufferedImage.TYPE_INT_RGB);
pixels = ((DataBufferInt)image.getRaster().getDataBuffer()).getData();
textures = new ArrayList<Texture>();
textures.add(Texture.wood);
textures.add(Texture.brick);
textures.add(Texture.bluestone);
textures.add(Texture.stone);
textures.add(Texture.enemy);
textures.add(Texture.win);
textures.add(Texture.lose);
textures.add(Texture.doorL);
textures.add(Texture.doorR);
textures.add(Texture.d);
camera = new Camera(1.0, 12.0, 1, 0, 0, -.66);
droid = new Droid(34.0, 13.0, 1, 0, 0, -.66, camera);
screen = new Screen(map, mapWidth, mapHeight, textures, 640, 480);
addKeyListener(camera);
setSize(640, 480);
setResizable(false);
setTitle("3D Engine");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBackground(Color.CYAN);
setLocationRelativeTo(null);
setVisible(true);
start();
}
private synchronized void start()
{
running = true;
thread.start();
}
public synchronized void stop()
{
running = false;
Long time = (long) 30000;
try {
this.wait(time);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
//insert win output
System.exit(0);
}
public void render()
{
BufferStrategy bs = getBufferStrategy();
if(bs == null)
{
createBufferStrategy(3);
return;
}
Graphics g = bs.getDrawGraphics();
g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
bs.show();
}
public void run()
{
int count = 0;
long lastTime = System.nanoTime();
final double ns = 1000000000.0 / 60.0;
double delta = 0;
requestFocus();
while(running)
{
long now = System.nanoTime();
delta = delta + ((now-lastTime) / ns);
lastTime = now;
while (delta >= 1)
{
screen.update(camera, pixels);
camera.update(map, droid, textures);
map = droid.update(map, textures);
if(droid.health < 0)
{
count++;
if(count > 30)
{
JOptionPane.showMessageDialog(rootPane, "Player has juan.");;;;;
for (int x = 0; x < 6; x++)
{
Biancardi biancardi = new Biancardi();
biancardi.bianparty();
}
stop();
}
}
health = droid.attack((int)camera.getX(), (int)camera.getY(), health);
if(health <= 0)
{
count++;
droid.health -= 800;
droid.win(map);
if(count > 30)
{
JOptionPane.showMessageDialog(rootPane, "Player has los.");
stop();
}
}
delta--;
}
render();
}
}
public static void main(String [] args)
{
Battle game = new Battle();
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.