blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
list | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
list | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6c023b054a6475c756accc831a2fae2a170174d9 | 27,848,567,977,694 | 340a321fbac9f342b272a5367701b369d267446b | /src/main/java/AccountDataProvider.java | c4a3ec2d00c8a55bf3320ed05a36942db53c4217 | [
"MIT"
]
| permissive | ulubeyn/transaction-web-api | https://github.com/ulubeyn/transaction-web-api | 53d76c6263587c7beeb5c195c0a97aed35b38364 | 3716277ff14124890a6977679bef5d6da1b9191d | refs/heads/master | 2020-07-09T05:31:43.758000 | 2019-08-23T00:37:33 | 2019-08-23T00:37:33 | 203,894,551 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import org.sample.protocols.web.WebProtocol;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class AccountDataProvider {
public static List<WebProtocol.Account> getAccounts() {
return Stream.of(
new WebProtocol.Account("Account1", new BigDecimal(100), new BigDecimal(100), new BigDecimal(100)),
new WebProtocol.Account("Account2", new BigDecimal(200), new BigDecimal(200), new BigDecimal(100)),
new WebProtocol.Account("Account3", new BigDecimal(500), new BigDecimal(500), new BigDecimal(50)),
new WebProtocol.Account("Account4", new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(500)),
new WebProtocol.Account("Account5", new BigDecimal(800), new BigDecimal(800), new BigDecimal(400)),
new WebProtocol.Account("Account6", new BigDecimal(600), new BigDecimal(600), new BigDecimal(600))
).collect(Collectors.toList());
}
}
| UTF-8 | Java | 1,034 | java | AccountDataProvider.java | Java | []
| null | []
| import org.sample.protocols.web.WebProtocol;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class AccountDataProvider {
public static List<WebProtocol.Account> getAccounts() {
return Stream.of(
new WebProtocol.Account("Account1", new BigDecimal(100), new BigDecimal(100), new BigDecimal(100)),
new WebProtocol.Account("Account2", new BigDecimal(200), new BigDecimal(200), new BigDecimal(100)),
new WebProtocol.Account("Account3", new BigDecimal(500), new BigDecimal(500), new BigDecimal(50)),
new WebProtocol.Account("Account4", new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(500)),
new WebProtocol.Account("Account5", new BigDecimal(800), new BigDecimal(800), new BigDecimal(400)),
new WebProtocol.Account("Account6", new BigDecimal(600), new BigDecimal(600), new BigDecimal(600))
).collect(Collectors.toList());
}
}
| 1,034 | 0.687621 | 0.628627 | 21 | 48.238094 | 45.087116 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.380952 | false | false | 1 |
b388282b5d1f0cb617321b6e88a0cc564e8bb63e | 12,412,455,526,609 | 08fe8149703399c97b364a8e35db5835770861e2 | /src/main/java/com/fanap/hibernate/controller/StudentApi.java | 58727962ccc762dc259da6b5af228fa31e62f937 | []
| no_license | parvanehabi/HibernateDemo | https://github.com/parvanehabi/HibernateDemo | 3acf9179136969198bb847f1f1f0f4dd2b9efd67 | 4cd19546a06702eb32df125643df2aecc401d688 | refs/heads/master | 2020-04-13T01:07:46.944000 | 2018-12-23T05:37:58 | 2018-12-23T05:37:58 | 162,865,132 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.fanap.hibernate.controller;
import com.fanap.hibernate.controller.Filter.JWTTokenNeeded;
import com.fanap.hibernate.data.modelVO.StudentVO;
import com.fanap.hibernate.data.repository.StudentCRUD;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.*;
import java.util.NoSuchElementException;
@Path("/student")
public class StudentApi {
final static String Image_Folder = "images";
@POST
@JWTTokenNeeded("admin")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response addStudent(StudentVO studentVO) {
if (studentVO == null) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
StudentVO student= StudentCRUD.saveStudent(studentVO);
return Response.status(201).entity(student).build();
}
@GET
@JWTTokenNeeded("admin")
@Produces(MediaType.APPLICATION_JSON)
public Response getStudents() {
return Response.status(200).entity(StudentCRUD.getAll()).build();
}
@GET
@Path("/{studentId}")
@JWTTokenNeeded({"admin","student"})
@Produces(MediaType.APPLICATION_JSON)
public Response getStudentInformation(@PathParam("studentId") long studentId) {
try {
return Response.status(200).entity(StudentCRUD.getStudent(studentId)).build();
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
@DELETE
@Path("/{studentId}")
@JWTTokenNeeded("admin")
public Response deleteStudent(@PathParam("studentId") long studentId) {
try {
StudentCRUD.deleteStudent(studentId);
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
return Response.status(204).build();
}
@PUT
@Path("/{studentId}")
@JWTTokenNeeded("admin")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateStudent(@PathParam("studentId") long studentId ,StudentVO studentVO) {
if(studentVO == null)
Response.status(Response.Status.BAD_REQUEST).build();
try {
return Response.status(200).entity(StudentCRUD.updateStudent(studentId ,studentVO)).build();
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
@POST
@Path("/{studentId}/addImage")
@JWTTokenNeeded("admin")
@Consumes({MediaType.MULTIPART_FORM_DATA})
@Produces(MediaType.APPLICATION_JSON)
public Response addImage(@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData, @PathParam("studentId") long studentId) {
String uploadedFileLocation = Image_Folder + "/" + fileMetaData.getFileName();
File dir = new File(Image_Folder);
if(!dir.exists())
if(!dir.mkdir())
return Response.status(500).entity("server can't make a directory to save image").build();
try {
StudentCRUD.writeToFile(fileInputStream, uploadedFileLocation);
}catch (IOException e){
return Response.status(500).entity("can't save image").build();
}
StudentVO studentVO = new StudentVO();
studentVO.setImage(fileMetaData.getFileName());
StudentVO studentVO1 = StudentCRUD.updateStudent(studentId,studentVO);
return Response.status(204).build();
}
@GET
@Path("/{studentId}/image")
@JWTTokenNeeded({"admin","student"})
@Produces("image/png")
public Response getFullImage(@PathParam("studentId") long studentId) {
StudentVO studentVO = StudentCRUD.getStudent(studentId);
try {
File file = new File(Image_Folder + "/" + studentVO.getImage());
return Response.ok((Object) file).header("Content-Disposition", "attachment; filename=image_from_server.png").build();
}catch (NullPointerException e){
return Response.status(404).entity("can't find file on server").build();
}
}
@GET
@Path("/{studentId}/courses")
@JWTTokenNeeded({"admin","student"})
@Produces(MediaType.APPLICATION_JSON)
public Response getStudentCourses(@PathParam("studentId") long studentId){
try{
return Response.status(200).entity(StudentCRUD.getStudentCourses(studentId)).build();
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
@POST
@Path("/{studentId}/addCourse/{courseId}")
@JWTTokenNeeded("admin")
@Produces(MediaType.APPLICATION_JSON)
public Response addStudentCourse(@PathParam("studentId") long studentId, @PathParam("courseId") long courseId){
try{
return Response.status(200).entity(StudentCRUD.addStudentCourse(studentId, courseId)).build();
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
@GET
@Path("/{studentId}/masters")
@JWTTokenNeeded({"admin","student"})
@Produces(MediaType.APPLICATION_JSON)
public Response getStudentMasters(@PathParam("studentId") long studentId){
try{
return Response.status(200).entity(StudentCRUD.getStudentMasters(studentId)).build();
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
}
| UTF-8 | Java | 5,764 | java | StudentApi.java | Java | [
{
"context": "UT\n @Path(\"/{studentId}\")\n @JWTTokenNeeded(\"admin\")\n @Consumes(MediaType.APPLICATION_JSON)\n @",
"end": 2099,
"score": 0.7907856702804565,
"start": 2094,
"tag": "USERNAME",
"value": "admin"
},
{
"context": "ath(\"/{studentId}/addImage\")\n @JWTTokenNeeded(\"admin\")\n @Consumes({MediaType.MULTIPART_FORM_DATA})\n",
"end": 2704,
"score": 0.7764703035354614,
"start": 2699,
"tag": "USERNAME",
"value": "admin"
},
{
"context": "@Path(\"/{studentId}/image\")\n @JWTTokenNeeded({\"admin\",\"student\"})\n @Produces(\"image/png\")\n publi",
"end": 3821,
"score": 0.7876374125480652,
"start": 3816,
"tag": "USERNAME",
"value": "admin"
},
{
"context": "{studentId}/image\")\n @JWTTokenNeeded({\"admin\",\"student\"})\n @Produces(\"image/png\")\n public Response",
"end": 3831,
"score": 0.48864513635635376,
"start": 3824,
"tag": "USERNAME",
"value": "student"
},
{
"context": "ath(\"/{studentId}/courses\")\n @JWTTokenNeeded({\"admin\",\"student\"})\n @Produces(MediaType.APPLICATION_",
"end": 4438,
"score": 0.5891405344009399,
"start": 4433,
"tag": "USERNAME",
"value": "admin"
}
]
| null | []
| package com.fanap.hibernate.controller;
import com.fanap.hibernate.controller.Filter.JWTTokenNeeded;
import com.fanap.hibernate.data.modelVO.StudentVO;
import com.fanap.hibernate.data.repository.StudentCRUD;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.*;
import java.util.NoSuchElementException;
@Path("/student")
public class StudentApi {
final static String Image_Folder = "images";
@POST
@JWTTokenNeeded("admin")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response addStudent(StudentVO studentVO) {
if (studentVO == null) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
StudentVO student= StudentCRUD.saveStudent(studentVO);
return Response.status(201).entity(student).build();
}
@GET
@JWTTokenNeeded("admin")
@Produces(MediaType.APPLICATION_JSON)
public Response getStudents() {
return Response.status(200).entity(StudentCRUD.getAll()).build();
}
@GET
@Path("/{studentId}")
@JWTTokenNeeded({"admin","student"})
@Produces(MediaType.APPLICATION_JSON)
public Response getStudentInformation(@PathParam("studentId") long studentId) {
try {
return Response.status(200).entity(StudentCRUD.getStudent(studentId)).build();
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
@DELETE
@Path("/{studentId}")
@JWTTokenNeeded("admin")
public Response deleteStudent(@PathParam("studentId") long studentId) {
try {
StudentCRUD.deleteStudent(studentId);
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
return Response.status(204).build();
}
@PUT
@Path("/{studentId}")
@JWTTokenNeeded("admin")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateStudent(@PathParam("studentId") long studentId ,StudentVO studentVO) {
if(studentVO == null)
Response.status(Response.Status.BAD_REQUEST).build();
try {
return Response.status(200).entity(StudentCRUD.updateStudent(studentId ,studentVO)).build();
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
@POST
@Path("/{studentId}/addImage")
@JWTTokenNeeded("admin")
@Consumes({MediaType.MULTIPART_FORM_DATA})
@Produces(MediaType.APPLICATION_JSON)
public Response addImage(@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData, @PathParam("studentId") long studentId) {
String uploadedFileLocation = Image_Folder + "/" + fileMetaData.getFileName();
File dir = new File(Image_Folder);
if(!dir.exists())
if(!dir.mkdir())
return Response.status(500).entity("server can't make a directory to save image").build();
try {
StudentCRUD.writeToFile(fileInputStream, uploadedFileLocation);
}catch (IOException e){
return Response.status(500).entity("can't save image").build();
}
StudentVO studentVO = new StudentVO();
studentVO.setImage(fileMetaData.getFileName());
StudentVO studentVO1 = StudentCRUD.updateStudent(studentId,studentVO);
return Response.status(204).build();
}
@GET
@Path("/{studentId}/image")
@JWTTokenNeeded({"admin","student"})
@Produces("image/png")
public Response getFullImage(@PathParam("studentId") long studentId) {
StudentVO studentVO = StudentCRUD.getStudent(studentId);
try {
File file = new File(Image_Folder + "/" + studentVO.getImage());
return Response.ok((Object) file).header("Content-Disposition", "attachment; filename=image_from_server.png").build();
}catch (NullPointerException e){
return Response.status(404).entity("can't find file on server").build();
}
}
@GET
@Path("/{studentId}/courses")
@JWTTokenNeeded({"admin","student"})
@Produces(MediaType.APPLICATION_JSON)
public Response getStudentCourses(@PathParam("studentId") long studentId){
try{
return Response.status(200).entity(StudentCRUD.getStudentCourses(studentId)).build();
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
@POST
@Path("/{studentId}/addCourse/{courseId}")
@JWTTokenNeeded("admin")
@Produces(MediaType.APPLICATION_JSON)
public Response addStudentCourse(@PathParam("studentId") long studentId, @PathParam("courseId") long courseId){
try{
return Response.status(200).entity(StudentCRUD.addStudentCourse(studentId, courseId)).build();
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
@GET
@Path("/{studentId}/masters")
@JWTTokenNeeded({"admin","student"})
@Produces(MediaType.APPLICATION_JSON)
public Response getStudentMasters(@PathParam("studentId") long studentId){
try{
return Response.status(200).entity(StudentCRUD.getStudentMasters(studentId)).build();
}catch (NoSuchElementException e){
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
}
| 5,764 | 0.663255 | 0.656836 | 165 | 33.933334 | 31.284061 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.345455 | false | false | 1 |
d3293a006bb226efd77a405435abe7c22f782117 | 21,406,117,044,737 | 29d81459bf1142df32c911dfa8d5d5ddff2225c3 | /mall-common/src/main/java/com/xg/mall/business/service/impl/AreaServiceImpl.java | 9cd86b1f16b6e183a7d4241b90ff1c580496eeab | []
| no_license | xiaoyu1423/xg | https://github.com/xiaoyu1423/xg | 7e778864f45162eb837b336ee538dc83b16475b9 | 14895325d18e2999bc03f8bc7a5f67747bc41dad | refs/heads/master | 2020-03-18T19:40:25.033000 | 2018-05-28T14:25:03 | 2018-05-28T14:25:03 | 135,169,234 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xg.mall.business.service.impl;
import com.xg.mall.business.service.IAreaService;
import com.xg.mall.dao.XgwhAreaMapper;
import com.xg.mall.po.XgwhArea;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
@Service
public class AreaServiceImpl implements IAreaService {
@Autowired
private XgwhAreaMapper xgwhAreaMapper;
@Override
public List<XgwhArea> selectAreas(Integer areaParentId) {
if (areaParentId > 0) {
List<XgwhArea> list = xgwhAreaMapper.selectAreas(areaParentId);
if (list.isEmpty()) {
return Collections.emptyList();
}
return list;
} else {
return Collections.emptyList();
}
}
}
| UTF-8 | Java | 838 | java | AreaServiceImpl.java | Java | []
| null | []
| package com.xg.mall.business.service.impl;
import com.xg.mall.business.service.IAreaService;
import com.xg.mall.dao.XgwhAreaMapper;
import com.xg.mall.po.XgwhArea;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
@Service
public class AreaServiceImpl implements IAreaService {
@Autowired
private XgwhAreaMapper xgwhAreaMapper;
@Override
public List<XgwhArea> selectAreas(Integer areaParentId) {
if (areaParentId > 0) {
List<XgwhArea> list = xgwhAreaMapper.selectAreas(areaParentId);
if (list.isEmpty()) {
return Collections.emptyList();
}
return list;
} else {
return Collections.emptyList();
}
}
}
| 838 | 0.686158 | 0.684964 | 30 | 26.933332 | 21.419514 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.433333 | false | false | 1 |
a392c029f47c398c31fdb9a1cd9f4ab12538d9f7 | 21,406,117,043,800 | cb8ccced1c84721994c9008d60f6b2a120365321 | /src/main/java/net/zomis/cards/iface/CardEffectTargets.java | aeab2ca5e1b11e9bdacd5c6a53eb88c80d5832cd | []
| no_license | Zomis/ZonesAndCards | https://github.com/Zomis/ZonesAndCards | ecda38ccbf2ef0cb71ec8079fba4b78b080ada1f | 8025a30ed51e1d9fcf49cf4bb7b0d9462a913011 | refs/heads/master | 2020-06-01T03:24:36.772000 | 2020-02-08T18:17:34 | 2020-02-08T18:17:34 | 20,162,557 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.zomis.cards.iface;
import net.zomis.cards.cbased.CardWithComponents;
@FunctionalInterface
public interface CardEffectTargets {
void performEffect(CardWithComponents source, TargetData targets);
}
| UTF-8 | Java | 214 | java | CardEffectTargets.java | Java | []
| null | []
| package net.zomis.cards.iface;
import net.zomis.cards.cbased.CardWithComponents;
@FunctionalInterface
public interface CardEffectTargets {
void performEffect(CardWithComponents source, TargetData targets);
}
| 214 | 0.827103 | 0.827103 | 10 | 20.4 | 23.078995 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 1 |
fe780c5d3849fe0cd10d6ced0c3f87c38caa8099 | 32,126,355,416,535 | 158aca590f07cf001a2af717ee33db9828e7f47a | /app/src/main/java/Yaduvanshi/androidbasics/Fragmentusing.java | 77a3d17586ec44ce12271b2988d90e125dd5f9ee | []
| no_license | VikramBaraiya/Basics | https://github.com/VikramBaraiya/Basics | bd5250bf02c460d072df82c4eadcc58a04250804 | a275e7a0472cc08836e60612ce7dcb8751aa0a5e | refs/heads/master | 2020-06-25T02:32:53.286000 | 2019-07-27T14:00:44 | 2019-07-27T14:00:44 | 199,171,848 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Yaduvanshi.androidbasics;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class Fragmentusing extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragmentusing);
}
}
| UTF-8 | Java | 348 | java | Fragmentusing.java | Java | []
| null | []
| package Yaduvanshi.androidbasics;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class Fragmentusing extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragmentusing);
}
}
| 348 | 0.767241 | 0.764368 | 14 | 23.857143 | 22.806192 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.357143 | false | false | 1 |
c906eb71176905f898c691e675d99e7ffb11b20c | 1,640,677,553,049 | 302093c29c09f64f221a5231aa7658fa1372d42e | /TextBookApplication/src/main/java/TextookApplication/Controller/AuthorController.java | 7deea5a318d9a125c03bd35e9c504db6c8e3b104 | []
| no_license | AnaStudent/TextBookApplication | https://github.com/AnaStudent/TextBookApplication | 33dc2fcbf4f9038f057d855338fd223cd74b9de4 | 62f59757de51ecacf97c4f527e0098fcf063da77 | refs/heads/main | 2023-01-23T16:58:08.519000 | 2020-11-30T22:41:48 | 2020-11-30T22:41:48 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package TextookApplication.Controller;
import TextookApplication.entity.Author;
import TextookApplication.service.AuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
public class AuthorController {
@Autowired
private AuthorService service;
@PostMapping("/create")
public List<Author> create(@RequestBody List<Author> authors) {
return service.saveAuthors(authors);
}
@GetMapping("/read/{authNumber}")
public List<Author> findAllAuthors(){
return service.getAuthors();
}
@PostMapping("/update")
public Author update(@RequestBody Author author){
return service.updateAuthor(author);
}
@DeleteMapping
public String deleteAuthor(@PathVariable int id){
return service.deleteAuthor(id);
}
}
| UTF-8 | Java | 918 | java | AuthorController.java | Java | []
| null | []
| package TextookApplication.Controller;
import TextookApplication.entity.Author;
import TextookApplication.service.AuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
public class AuthorController {
@Autowired
private AuthorService service;
@PostMapping("/create")
public List<Author> create(@RequestBody List<Author> authors) {
return service.saveAuthors(authors);
}
@GetMapping("/read/{authNumber}")
public List<Author> findAllAuthors(){
return service.getAuthors();
}
@PostMapping("/update")
public Author update(@RequestBody Author author){
return service.updateAuthor(author);
}
@DeleteMapping
public String deleteAuthor(@PathVariable int id){
return service.deleteAuthor(id);
}
}
| 918 | 0.6939 | 0.6939 | 36 | 23.5 | 21.289669 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.305556 | false | false | 1 |
e94c1a5d739143309f21375adf53a88111d0e17d | 10,411,000,781,799 | 3b91eef7b45b619c88ab2e586673271e1d7d843a | /SpringAssignment1/src/question3/MainApp.java | 4e1787bb5b3cdeee33b94439f07887c3cb551783 | []
| no_license | RushaliSetia/spring-codes | https://github.com/RushaliSetia/spring-codes | b8ea214c5086bc0d8f1c0979c1ef885192960db5 | 798b44cd241b1e08bd879f81c8293c59d033cec7 | refs/heads/master | 2020-03-30T16:25:36.054000 | 2018-10-03T12:33:38 | 2018-10-03T12:33:38 | 151,407,895 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package question3;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainApp {
public static void main(String[] args) {
ApplicationContext ac=new ClassPathXmlApplicationContext("question3/spring.xml");
Employee emp=(Employee) ac.getBean("employee");
System.out.println(emp);
}
}
| UTF-8 | Java | 398 | java | MainApp.java | Java | []
| null | []
| package question3;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainApp {
public static void main(String[] args) {
ApplicationContext ac=new ClassPathXmlApplicationContext("question3/spring.xml");
Employee emp=(Employee) ac.getBean("employee");
System.out.println(emp);
}
}
| 398 | 0.771357 | 0.766332 | 14 | 26.428572 | 28.123997 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 1 |
ea388d69f428b097a5cb1567050770ddaa681bbc | 2,491,081,035,924 | a623314091c525fc4e4ca0e6ecf026b28a87c7fc | /src/main/java/cn/tinbat/andu/example/proxy/HttpProxyServerConfig.java | ca21e2da3670a434ecc40bc7e4727f997376aff0 | [
"MIT"
]
| permissive | DQMT/andu | https://github.com/DQMT/andu | ae7415b1de6cf31697f27f9200034b3af59b392c | fe7c286e0566a4a0ef4629578db05c21d32e8d24 | refs/heads/master | 2021-05-01T21:58:30.834000 | 2018-11-22T05:53:04 | 2018-11-22T05:53:04 | 120,983,166 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.tinbat.andu.example.proxy;
import io.netty.channel.EventLoopGroup;
/**
* Created by songhangbo on 2018/10/27.
*/
public class HttpProxyServerConfig {
private EventLoopGroup loopGroup;
public EventLoopGroup getLoopGroup() {
return loopGroup;
}
public void setLoopGroup(EventLoopGroup loopGroup) {
this.loopGroup = loopGroup;
}
}
| UTF-8 | Java | 382 | java | HttpProxyServerConfig.java | Java | [
{
"context": "o.netty.channel.EventLoopGroup;\n\n/**\n * Created by songhangbo on 2018/10/27.\n */\npublic class HttpProxyServerCo",
"end": 108,
"score": 0.9994804263114929,
"start": 98,
"tag": "USERNAME",
"value": "songhangbo"
}
]
| null | []
| package cn.tinbat.andu.example.proxy;
import io.netty.channel.EventLoopGroup;
/**
* Created by songhangbo on 2018/10/27.
*/
public class HttpProxyServerConfig {
private EventLoopGroup loopGroup;
public EventLoopGroup getLoopGroup() {
return loopGroup;
}
public void setLoopGroup(EventLoopGroup loopGroup) {
this.loopGroup = loopGroup;
}
}
| 382 | 0.706806 | 0.685864 | 19 | 19.105263 | 19.139088 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.263158 | false | false | 1 |
d1e3e57fb01b088747d44c84cf5966d283e41591 | 31,954,556,733,538 | 31246a425fc22192db7e390a3f4b0aecfbd38c9d | /COMP2011/Assign1/src/Assign2/GenderSort.java | 1ecad03691e298d81dfba38ab1595a2768b8c023 | []
| no_license | zhuyidiwow/PolyU-Projects | https://github.com/zhuyidiwow/PolyU-Projects | 21490e037970132870e9cd11761c4359106f630b | e74232f7e4182996a82cb12bcaf4acb134b72b1b | refs/heads/master | 2019-07-06T02:02:23.534000 | 2016-07-26T01:54:20 | 2016-07-26T01:54:20 | 64,180,000 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* Name: ZHU Yidi
* Student ID: 13104363d
*
* This program just do what we do in assignment 1 twice (line 21 to 35).
* So the time complexity was not changed, which is still O(n)
*/
package Assign2;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.stream.Collectors;
public class GenderSort {
// sort arr such that all female students come before male students.
public static void binarySort (Student[] arr) {
int i = 0;
int j = arr.length - 1;
// sort arr such that all female students come before male and not classified students
while(j > i) {
while (i < j && arr[i].gender == 0) i++;
while (i < j && arr[j].gender != 0) j--;
swap(arr, i, j);
}
// re-initial j
j = arr.length - 1;
// sort arr such that all male students come before not classified students
while(j > i) {
while (i < j && arr[i].gender == 1) i++;
while (i < j && arr[j].gender != 1) j--;
swap(arr, i, j);
}
}
// swap two element in an array
public static void swap(Student[] arr, int i, int j) {
Student temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
public static void main(String[] args) {
SecureRandom random = new SecureRandom();
int size = 50;
Student[] arr = new Student[size];
// build 50 students with random id and gender.
for (int i= 0; i < size; i++ ) {
int id = Math.abs(random.nextInt());
arr[i] = new Student(id, id % 3);
}
binarySort(arr);
System.out.println(Arrays.stream(arr).
map(Student::toString).
collect(Collectors.joining("\n ")));
}
}
class Student {
int id;
String name;
int gender; // 0 for girls, 1 for boys, 2 for not classified
public Student (int id, int gender) {
this.id = id;
this.gender = gender;
}
public String toString () {
if (gender == 0) return "female" + " student " + id;
else if (gender == 1) return "male" + " student " + id;
else if (gender == 2) return "not classified" + " student " + id;
else return "error student";
}
} | UTF-8 | Java | 2,240 | java | GenderSort.java | Java | [
{
"context": "/* Name: ZHU Yidi\n * Student ID: 13104363d\n * \n * This program just",
"end": 17,
"score": 0.9997860789299011,
"start": 9,
"tag": "NAME",
"value": "ZHU Yidi"
}
]
| null | []
| /* Name: <NAME>
* Student ID: 13104363d
*
* This program just do what we do in assignment 1 twice (line 21 to 35).
* So the time complexity was not changed, which is still O(n)
*/
package Assign2;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.stream.Collectors;
public class GenderSort {
// sort arr such that all female students come before male students.
public static void binarySort (Student[] arr) {
int i = 0;
int j = arr.length - 1;
// sort arr such that all female students come before male and not classified students
while(j > i) {
while (i < j && arr[i].gender == 0) i++;
while (i < j && arr[j].gender != 0) j--;
swap(arr, i, j);
}
// re-initial j
j = arr.length - 1;
// sort arr such that all male students come before not classified students
while(j > i) {
while (i < j && arr[i].gender == 1) i++;
while (i < j && arr[j].gender != 1) j--;
swap(arr, i, j);
}
}
// swap two element in an array
public static void swap(Student[] arr, int i, int j) {
Student temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
public static void main(String[] args) {
SecureRandom random = new SecureRandom();
int size = 50;
Student[] arr = new Student[size];
// build 50 students with random id and gender.
for (int i= 0; i < size; i++ ) {
int id = Math.abs(random.nextInt());
arr[i] = new Student(id, id % 3);
}
binarySort(arr);
System.out.println(Arrays.stream(arr).
map(Student::toString).
collect(Collectors.joining("\n ")));
}
}
class Student {
int id;
String name;
int gender; // 0 for girls, 1 for boys, 2 for not classified
public Student (int id, int gender) {
this.id = id;
this.gender = gender;
}
public String toString () {
if (gender == 0) return "female" + " student " + id;
else if (gender == 1) return "male" + " student " + id;
else if (gender == 2) return "not classified" + " student " + id;
else return "error student";
}
} | 2,238 | 0.556696 | 0.541964 | 78 | 27.73077 | 22.415466 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 1 |
18b38f05cb3f7b5fc73bab171d6422d06221b3f8 | 30,391,188,620,033 | 4d274173ce10931ce2c819acf2ab382336816c3a | /jax-flink-job/src/main/java/com/eoi/jax/flink/job/process/StringDecoderFunction.java | 1c3d40ed1866323fbcd40527e1bc25393e8bd631 | [
"Apache-2.0"
]
| permissive | joely110/jax | https://github.com/joely110/jax | 346aa1d66f1c6c1f0f5eb1809a3a3c20cf544d36 | 9f54fd84f149896112bf1e39a0b60533196ac5fb | refs/heads/master | 2023-06-27T03:55:05.631000 | 2021-08-03T06:53:15 | 2021-08-03T06:53:15 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eoi.jax.flink.job.process;
import cn.hutool.core.util.StrUtil;
import com.eoi.jax.flink.job.common.DecoderFunction;
import org.apache.flink.util.OutputTag;
import java.util.Map;
public class StringDecoderFunction extends DecoderFunction {
private StringDecoderJobConfig config;
final OutputTag<Map<String, Object>> errorTag;
public StringDecoderFunction(StringDecoderJobConfig config, OutputTag<Map<String, Object>> errorTag) {
super(config, errorTag);
this.config = config;
this.errorTag = errorTag;
if (StrUtil.isEmpty(config.getOutputFieldName())) {
config.setOutputFieldName("@message");
}
}
@Override
protected Object decodedValue(byte[] bytes) throws Exception {
return new String(bytes, config.getCharset());
}
}
| UTF-8 | Java | 1,390 | java | StringDecoderFunction.java | Java | []
| null | []
| /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eoi.jax.flink.job.process;
import cn.hutool.core.util.StrUtil;
import com.eoi.jax.flink.job.common.DecoderFunction;
import org.apache.flink.util.OutputTag;
import java.util.Map;
public class StringDecoderFunction extends DecoderFunction {
private StringDecoderJobConfig config;
final OutputTag<Map<String, Object>> errorTag;
public StringDecoderFunction(StringDecoderJobConfig config, OutputTag<Map<String, Object>> errorTag) {
super(config, errorTag);
this.config = config;
this.errorTag = errorTag;
if (StrUtil.isEmpty(config.getOutputFieldName())) {
config.setOutputFieldName("@message");
}
}
@Override
protected Object decodedValue(byte[] bytes) throws Exception {
return new String(bytes, config.getCharset());
}
}
| 1,390 | 0.722302 | 0.719424 | 42 | 32.095238 | 28.388302 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.52381 | false | false | 1 |
22a77f2760ef5ed6f9cfacc58ce6406fed9d42c3 | 12,721,693,174,151 | cb95159baab884f97a4cc405fe7f99bb4385aae6 | /Virus/src/Viral/Painter.java | 0bcd0e87365e11467dd364dedc35f56edb3f8f92 | []
| no_license | irmiev/ViralTest | https://github.com/irmiev/ViralTest | 46c0dd3dcf8a6725390a63b6950568d76929a7c6 | 81da0416606b5dbf194ad9b3723b0ac0697b397e | refs/heads/master | 2021-01-10T10:25:43.915000 | 2015-01-23T15:23:53 | 2015-01-23T15:23:53 | 8,432,206 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Viral;
public class Painter extends Thread {
ViralArea vA;
public Painter(ViralArea vA) {
this.vA = vA;
}
public void run() {
while (true) {
//System.out.println("I am painting!!");
vA.repaint();
try {
this.sleep(20);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
| UTF-8 | Java | 370 | java | Painter.java | Java | []
| null | []
| package Viral;
public class Painter extends Thread {
ViralArea vA;
public Painter(ViralArea vA) {
this.vA = vA;
}
public void run() {
while (true) {
//System.out.println("I am painting!!");
vA.repaint();
try {
this.sleep(20);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
| 370 | 0.613514 | 0.608108 | 23 | 15.086957 | 13.720543 | 43 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.086957 | false | false | 1 |
e4d06b3135bf77f4640e3da0add46e1ec83b19ef | 31,628,139,214,370 | 5299df5b17a2c606d42ce7a8926b0a6b9935b7e0 | /questionnaire-persist/src/main/java/git/lbk/questionnaire/dao/impl/UserDaoImpl.java | 41c6eefcec2ac79eb8128ee81cddc73a41a42138 | [
"Apache-2.0"
]
| permissive | LiBingKai/questionnaire | https://github.com/LiBingKai/questionnaire | 0a68346f1f27bae911ded6df57dea15ebadf5d81 | df6418c0217e364802eee924f71dbe171e36c2ce | refs/heads/master | 2019-08-20T14:16:57.763000 | 2016-05-07T15:13:16 | 2016-05-07T15:13:16 | 44,946,895 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2015 LBK
*
* 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 git.lbk.questionnaire.dao.impl;
import git.lbk.questionnaire.entity.User;
import org.springframework.stereotype.Repository;
@Repository("userDao")
public class UserDaoImpl extends BaseDaoImpl<User> {
/**
* 获得指定邮箱或者手机号的用户信息
*
* @param account 邮箱或者手机号
* @return 已被注册返回true, 否则返回false
*/
public User getUserByAccount(String account){
return (User) uniqueResult("from User u where (u.email = ? or u.mobile = ?)",
account, account);
}
/**
* 验证用户登录信息是否匹配
*
* @param identity 用户邮箱或者用户手机
* @param password 用户密码
* @return 如果验证通过则返回用户的信息, 否则返回null
*/
public User validateLoginInfo(String identity, String password){
return (User) uniqueResult("from User u where (u.email = ? or u.mobile = ?) and u.password = ? ",
identity, identity, password);
}
/**
* 验证用户自动登录信息是否匹配
*
* @param autoLoginCode 用户自动登录码
* @return 如果验证通过则返回用户的信息, 否则返回null
*/
public User validateAutoLoginInfo(String autoLoginCode) {
return (User) uniqueResult("from User u where u.autoLogin = ?", autoLoginCode);
}
}
| UTF-8 | Java | 1,861 | java | UserDaoImpl.java | Java | []
| null | []
| /*
* Copyright 2015 LBK
*
* 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 git.lbk.questionnaire.dao.impl;
import git.lbk.questionnaire.entity.User;
import org.springframework.stereotype.Repository;
@Repository("userDao")
public class UserDaoImpl extends BaseDaoImpl<User> {
/**
* 获得指定邮箱或者手机号的用户信息
*
* @param account 邮箱或者手机号
* @return 已被注册返回true, 否则返回false
*/
public User getUserByAccount(String account){
return (User) uniqueResult("from User u where (u.email = ? or u.mobile = ?)",
account, account);
}
/**
* 验证用户登录信息是否匹配
*
* @param identity 用户邮箱或者用户手机
* @param password 用户密码
* @return 如果验证通过则返回用户的信息, 否则返回null
*/
public User validateLoginInfo(String identity, String password){
return (User) uniqueResult("from User u where (u.email = ? or u.mobile = ?) and u.password = ? ",
identity, identity, password);
}
/**
* 验证用户自动登录信息是否匹配
*
* @param autoLoginCode 用户自动登录码
* @return 如果验证通过则返回用户的信息, 否则返回null
*/
public User validateAutoLoginInfo(String autoLoginCode) {
return (User) uniqueResult("from User u where u.autoLogin = ?", autoLoginCode);
}
}
| 1,861 | 0.71639 | 0.711479 | 58 | 27.086206 | 27.178392 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.051724 | false | false | 1 |
d74332cf7c53623f00252d718376d55213a69ce6 | 29,033,978,962,356 | 7d64c8ac28e58dac1cff9d55de95a6475c365b11 | /src/test/java/com/codedifferently/SciCalculatorTest.java | ddaba7ca8a5b156eb13a78edd85b8fd959470b32 | []
| no_license | fcamarillo18/StayReadyLab02 | https://github.com/fcamarillo18/StayReadyLab02 | 127d0887af4609e73e7d1dac4be304fe6650ca9e | 52b15de3f527c8444ba64539bbd0fb19eb22e676 | refs/heads/master | 2022-11-12T02:13:04.838000 | 2020-07-05T21:09:09 | 2020-07-05T21:09:09 | 277,380,279 | 0 | 0 | null | true | 2020-07-05T20:43:11 | 2020-07-05T20:43:10 | 2020-06-16T21:41:32 | 2020-07-05T17:19:01 | 7 | 0 | 0 | 0 | null | false | false | package com.codedifferently;
import static org.junit.Assert.assertTrue;
import org.junit.Assert;
import org.junit.Test;
public class SciCalculatorTest
{
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
public void sciCalcTest(){
//Given
double resultDis = 0.0;
double resultMem = 0.0;
String displayMode="decimal";
String setMode = "Degrees";
//When
SciCalculator testC = new SciCalculator();
double actualDis = testC.getDisplayResult();
double actualMem = testC.getMem();
String actualDisplayMode = testC.getDisplayMode();
String actualSetMode = testC.getTrigUnitsMode();
//Then
Assert.assertEquals(resultDis, actualDis,0.00001);
Assert.assertEquals(resultMem, actualMem, 0.00001);
Assert.assertEquals(displayMode, actualDisplayMode);
Assert.assertEquals(setMode, actualSetMode);
}
@Test
public void memAddTest(){
//Given
double resultMem = 10.00;
//When
SciCalculator testC = new SciCalculator();
testC.addMem(10.00);
double actualMem = testC.getMem();
//Then
Assert.assertEquals(resultMem, actualMem, 0.00001);
}
@Test
public void memClearTest(){
//Given
double resultMem = 0.0;
//When
SciCalculator testC = new SciCalculator();
testC.addMem(10.00);
testC.resetMemory();
double actualMem = testC.getMem();
//Then
Assert.assertEquals(resultMem, actualMem, 0.00001);
}
@Test
public void switchDisplayTest(){
//Given
String mode = "hexadecimal";
//When
SciCalculator testC = new SciCalculator();
testC.switchDisplayMode();
String actualMode=testC.getDisplayMode();
//Then
Assert.assertEquals(mode,actualMode);
}
@Test
public void assignDisplayTest(){
//Given
String mode = "binary";
//When
SciCalculator testC = new SciCalculator();
testC.switchDisplayMode("binary");
String actualMode=testC.getDisplayMode();
//Then
Assert.assertEquals(mode,actualMode);
}
@Test
public void changeTrigUnitsTest(){
//Given
String trigMode = "Radians";
//When
SciCalculator calc = new SciCalculator();
calc.switchTrigUnits();
String actualMode = calc.getTrigUnitsMode();
//Then
Assert.assertEquals(trigMode, actualMode);
}
@Test
public void changeTrigUnitsStringTest(){
//Given
String trigMode = "Radians";
//When
SciCalculator calc = new SciCalculator();
calc.switchTrigUnits("Radians");
String actualMode = calc.getTrigUnitsMode();
//Then
Assert.assertEquals(trigMode, actualMode);
}
@Test
public void sinTest(){
//Given
double num= Math.sin(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.sine(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.sine(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void cosTest(){
//Given
double num= Math.cos(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.cos(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.cos(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void tanTest(){
//Given
double num= Math.tan(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.tan(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.tan(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void inverseTanTest(){
//Given
double num= Math.atan(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.inverseTan(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.inverseTan(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void inverseCosTest(){
//Given
double num= Math.acos(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.inverseCos(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.inverseCos(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void inverseSinTest(){
//Given
double num= Math.asin(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.inverseSin(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.inverseSin(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void absTest(){
//Given
double result=-24.23;
result=Math.abs(result);
//When
SciCalculator testC = new SciCalculator();
testC.abs(-24.23);
double actual = testC.getDisplayResult();
//Then
Assert.assertEquals(result, actual,0.00001);
}
@Test
public void factorialTest(){
//Given
double result=720.0;
//When
SciCalculator testC = new SciCalculator();
testC.factorial(6);
double actual = testC.getDisplayResult();
//Then
Assert.assertEquals(result, actual,0.00001);
}
} | UTF-8 | Java | 7,089 | java | SciCalculatorTest.java | Java | []
| null | []
| package com.codedifferently;
import static org.junit.Assert.assertTrue;
import org.junit.Assert;
import org.junit.Test;
public class SciCalculatorTest
{
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
public void sciCalcTest(){
//Given
double resultDis = 0.0;
double resultMem = 0.0;
String displayMode="decimal";
String setMode = "Degrees";
//When
SciCalculator testC = new SciCalculator();
double actualDis = testC.getDisplayResult();
double actualMem = testC.getMem();
String actualDisplayMode = testC.getDisplayMode();
String actualSetMode = testC.getTrigUnitsMode();
//Then
Assert.assertEquals(resultDis, actualDis,0.00001);
Assert.assertEquals(resultMem, actualMem, 0.00001);
Assert.assertEquals(displayMode, actualDisplayMode);
Assert.assertEquals(setMode, actualSetMode);
}
@Test
public void memAddTest(){
//Given
double resultMem = 10.00;
//When
SciCalculator testC = new SciCalculator();
testC.addMem(10.00);
double actualMem = testC.getMem();
//Then
Assert.assertEquals(resultMem, actualMem, 0.00001);
}
@Test
public void memClearTest(){
//Given
double resultMem = 0.0;
//When
SciCalculator testC = new SciCalculator();
testC.addMem(10.00);
testC.resetMemory();
double actualMem = testC.getMem();
//Then
Assert.assertEquals(resultMem, actualMem, 0.00001);
}
@Test
public void switchDisplayTest(){
//Given
String mode = "hexadecimal";
//When
SciCalculator testC = new SciCalculator();
testC.switchDisplayMode();
String actualMode=testC.getDisplayMode();
//Then
Assert.assertEquals(mode,actualMode);
}
@Test
public void assignDisplayTest(){
//Given
String mode = "binary";
//When
SciCalculator testC = new SciCalculator();
testC.switchDisplayMode("binary");
String actualMode=testC.getDisplayMode();
//Then
Assert.assertEquals(mode,actualMode);
}
@Test
public void changeTrigUnitsTest(){
//Given
String trigMode = "Radians";
//When
SciCalculator calc = new SciCalculator();
calc.switchTrigUnits();
String actualMode = calc.getTrigUnitsMode();
//Then
Assert.assertEquals(trigMode, actualMode);
}
@Test
public void changeTrigUnitsStringTest(){
//Given
String trigMode = "Radians";
//When
SciCalculator calc = new SciCalculator();
calc.switchTrigUnits("Radians");
String actualMode = calc.getTrigUnitsMode();
//Then
Assert.assertEquals(trigMode, actualMode);
}
@Test
public void sinTest(){
//Given
double num= Math.sin(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.sine(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.sine(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void cosTest(){
//Given
double num= Math.cos(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.cos(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.cos(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void tanTest(){
//Given
double num= Math.tan(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.tan(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.tan(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void inverseTanTest(){
//Given
double num= Math.atan(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.inverseTan(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.inverseTan(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void inverseCosTest(){
//Given
double num= Math.acos(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.inverseCos(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.inverseCos(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void inverseSinTest(){
//Given
double num= Math.asin(10.0);
double degree=Math.toDegrees(num);
double radians=Math.toRadians(num);
//When
SciCalculator calc = new SciCalculator();
calc.inverseSin(10.0);
double actualDegree = calc.getDisplayResult();
calc.switchTrigUnits();
calc.inverseSin(10.0);
double actualRadians= calc.getDisplayResult();
//Then
Assert.assertEquals(degree, actualDegree,0.00001);
Assert.assertEquals(radians, actualRadians,0.00001);
}
@Test
public void absTest(){
//Given
double result=-24.23;
result=Math.abs(result);
//When
SciCalculator testC = new SciCalculator();
testC.abs(-24.23);
double actual = testC.getDisplayResult();
//Then
Assert.assertEquals(result, actual,0.00001);
}
@Test
public void factorialTest(){
//Given
double result=720.0;
//When
SciCalculator testC = new SciCalculator();
testC.factorial(6);
double actual = testC.getDisplayResult();
//Then
Assert.assertEquals(result, actual,0.00001);
}
} | 7,089 | 0.601354 | 0.574129 | 259 | 26.374517 | 19.422817 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.648649 | false | false | 1 |
104107d5dafefa980f619b369dd4acc3d40bb6ab | 6,966,437,001,716 | 40814539ee6f3576d9efed5ef8b7426869ac6090 | /JAVA/Day9/day9b/Cat.java | 3386ad4d4a4f7e8fdee19acbef24ff0c95d7e834 | []
| no_license | advensod1002/JAVA_PROJECT | https://github.com/advensod1002/JAVA_PROJECT | 9cb472b935e1076b8ca3966a0603528c1d8cdaec | 010d3f20e83fb9ea6a6be711aba97ca5449dddd8 | refs/heads/main | 2023-07-16T10:35:01.486000 | 2021-09-01T09:56:52 | 2021-09-01T09:56:52 | 401,984,883 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jcp.day9b;
public class Cat extends Animal {
static final String TYPE = "고양이";
public String getType() {
return "고양이";
}
@Override
public void sound() {
System.out.println(this.getColor() + " 고양이는 🐱 야옹하고 소리를 냅니다.");
}
}
| UTF-8 | Java | 308 | java | Cat.java | Java | []
| null | []
| package com.jcp.day9b;
public class Cat extends Animal {
static final String TYPE = "고양이";
public String getType() {
return "고양이";
}
@Override
public void sound() {
System.out.println(this.getColor() + " 고양이는 🐱 야옹하고 소리를 냅니다.");
}
}
| 308 | 0.611321 | 0.607547 | 16 | 14.5625 | 17.549818 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 1 |
fd08269b80dc39c8566ce58b7d6c4276c1e8b47d | 28,346,784,214,834 | 4708c88a7da95eee795853422625d6c9f6c7783e | /GameSTZB/app/src/main/java/com/itgowo/gamestzb/wxapi/WXEntryActivity.java | 92bf374f70ca51d9c91f910542d9b8a591cd5e6e | [
"Apache-2.0"
]
| permissive | MengXin-9/GameSTZB | https://github.com/MengXin-9/GameSTZB | 4bd17ec6385a07985095bc0731b1dbd14654a8dd | 3385fc1213a4a345f9b931eccfda615394018a06 | refs/heads/master | 2023-09-01T06:45:09.785000 | 2018-06-19T10:45:33 | 2018-06-19T10:45:33 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.itgowo.gamestzb.wxapi;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.itgowo.gamestzb.Manager.UserManager;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
public class WXEntryActivity extends AppCompatActivity implements IWXAPIEventHandler{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
UserManager.mWeixinAPI.handleIntent(getIntent(), this);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
UserManager.mWeixinAPI.handleIntent(intent, this);
}
@Override
public void onReq(BaseReq baseReq) {
finish();
}
@Override
public void onResp(BaseResp baseResp) {
finish();
}
}
| UTF-8 | Java | 1,069 | java | WXEntryActivity.java | Java | []
| null | []
| package com.itgowo.gamestzb.wxapi;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.itgowo.gamestzb.Manager.UserManager;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
public class WXEntryActivity extends AppCompatActivity implements IWXAPIEventHandler{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
UserManager.mWeixinAPI.handleIntent(getIntent(), this);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
UserManager.mWeixinAPI.handleIntent(intent, this);
}
@Override
public void onReq(BaseReq baseReq) {
finish();
}
@Override
public void onResp(BaseResp baseResp) {
finish();
}
}
| 1,069 | 0.698784 | 0.697848 | 40 | 25.725 | 22.259815 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.45 | false | false | 1 |
994354572b8bcc161072c6913142ca56b6490450 | 7,868,380,150,082 | 75625c9915648b0abb70bafb498989aeee529bd6 | /app/src/main/java/com/max/basepasta/Activitys/Resultados2.java | 8f52969cfe300269c3eb93fa78a2199c3a78ce74 | []
| no_license | vloxomire/BasePasta | https://github.com/vloxomire/BasePasta | e88b659d95f11b0eecaa9c8f6b48c608ff174e9b | 6118e7cb52080fff0b996356d3c9f220d34d6c51 | refs/heads/master | 2020-04-05T10:10:03.937000 | 2018-11-13T03:57:44 | 2018-11-13T03:57:44 | 156,789,911 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.max.basepasta.Activitys;
import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.max.basepasta.Dao.AdminSQLiteOpenHelper;
import com.max.basepasta.Listener.ListenerLista;
import com.max.basepasta.R;
public class Resultados2 extends AppCompatActivity {
private TextView editTuMasa,editTuEstado,editTuPesoIdeal,editTuRiesgo;
private Button bGuardarSql, listaSql;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
editTuMasa = findViewById(R.id.editTuMasa);
editTuEstado = findViewById(R.id.editTuEstado);
editTuPesoIdeal = findViewById(R.id.editTuPesoIdeal);
editTuRiesgo = findViewById(R.id.editTuRiesgo);
bGuardarSql= findViewById(R.id.buttGuardarSql);
listaSql= findViewById(R.id.listaSql);
ListenerLista listenerLista= new ListenerLista(this);
listaSql.setOnClickListener(listenerLista);
SharedPreferences sharedPreferences = getSharedPreferences("miShared", Context.MODE_PRIVATE);
String masa = sharedPreferences.getString("value","");
String estado = sharedPreferences.getString("status","");
String pesoIdeal = sharedPreferences.getString("ideal_weight","");
String riesgo = sharedPreferences.getString("risk","");
editTuMasa.setText(masa);
editTuEstado.setText(estado);
editTuPesoIdeal.setText(pesoIdeal);
editTuRiesgo.setText(riesgo);
}
public void guardar(View v){
AdminSQLiteOpenHelper admin = new AdminSQLiteOpenHelper(this,"MasaCorp",null,1);
SQLiteDatabase db = admin.getWritableDatabase();
String masaCV = editTuMasa.getText().toString();
String estadoCV = editTuEstado.getText().toString();
String pesoIdealCV = editTuPesoIdeal.getText().toString();
String riesgoCV = editTuRiesgo.getText().toString();
ContentValues registroCV= new ContentValues();
registroCV.put("masa",masaCV);
registroCV.put("estado",estadoCV);
registroCV.put("pesoIdeal",pesoIdealCV);
registroCV.put("riesgo",riesgoCV);
db.insert("MasaCorporal",null,registroCV);
db.close();
editTuMasa.setText("");
editTuEstado.setText("");
editTuPesoIdeal.setText("");
editTuRiesgo.setText("");
Toast.makeText(this,"Se cargaron los datos...",Toast.LENGTH_LONG).show();
}
public void consulta(View v){
AdminSQLiteOpenHelper Admin = new AdminSQLiteOpenHelper(this,"Masa Corp",null,1);
SQLiteDatabase db = Admin.getWritableDatabase();
String masaCV = editTuMasa.getText().toString();
Cursor fila = db.rawQuery("SELECT Masa Corporal,Estado,Peso Ideal,Riesgo FROM MasaCorporal WHERE =" +masaCV,null);
if (fila.moveToFirst()){
editTuEstado.setText(fila.getString(0));
editTuPesoIdeal.setText(fila.getString(1));
editTuRiesgo.setText(fila.getString(2));
} else
Toast.makeText(this,"No existe dicho valor",Toast.LENGTH_LONG).show();
db.close();
}
}
| UTF-8 | Java | 3,513 | java | Resultados2.java | Java | []
| null | []
|
package com.max.basepasta.Activitys;
import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.max.basepasta.Dao.AdminSQLiteOpenHelper;
import com.max.basepasta.Listener.ListenerLista;
import com.max.basepasta.R;
public class Resultados2 extends AppCompatActivity {
private TextView editTuMasa,editTuEstado,editTuPesoIdeal,editTuRiesgo;
private Button bGuardarSql, listaSql;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
editTuMasa = findViewById(R.id.editTuMasa);
editTuEstado = findViewById(R.id.editTuEstado);
editTuPesoIdeal = findViewById(R.id.editTuPesoIdeal);
editTuRiesgo = findViewById(R.id.editTuRiesgo);
bGuardarSql= findViewById(R.id.buttGuardarSql);
listaSql= findViewById(R.id.listaSql);
ListenerLista listenerLista= new ListenerLista(this);
listaSql.setOnClickListener(listenerLista);
SharedPreferences sharedPreferences = getSharedPreferences("miShared", Context.MODE_PRIVATE);
String masa = sharedPreferences.getString("value","");
String estado = sharedPreferences.getString("status","");
String pesoIdeal = sharedPreferences.getString("ideal_weight","");
String riesgo = sharedPreferences.getString("risk","");
editTuMasa.setText(masa);
editTuEstado.setText(estado);
editTuPesoIdeal.setText(pesoIdeal);
editTuRiesgo.setText(riesgo);
}
public void guardar(View v){
AdminSQLiteOpenHelper admin = new AdminSQLiteOpenHelper(this,"MasaCorp",null,1);
SQLiteDatabase db = admin.getWritableDatabase();
String masaCV = editTuMasa.getText().toString();
String estadoCV = editTuEstado.getText().toString();
String pesoIdealCV = editTuPesoIdeal.getText().toString();
String riesgoCV = editTuRiesgo.getText().toString();
ContentValues registroCV= new ContentValues();
registroCV.put("masa",masaCV);
registroCV.put("estado",estadoCV);
registroCV.put("pesoIdeal",pesoIdealCV);
registroCV.put("riesgo",riesgoCV);
db.insert("MasaCorporal",null,registroCV);
db.close();
editTuMasa.setText("");
editTuEstado.setText("");
editTuPesoIdeal.setText("");
editTuRiesgo.setText("");
Toast.makeText(this,"Se cargaron los datos...",Toast.LENGTH_LONG).show();
}
public void consulta(View v){
AdminSQLiteOpenHelper Admin = new AdminSQLiteOpenHelper(this,"Masa Corp",null,1);
SQLiteDatabase db = Admin.getWritableDatabase();
String masaCV = editTuMasa.getText().toString();
Cursor fila = db.rawQuery("SELECT Masa Corporal,Estado,Peso Ideal,Riesgo FROM MasaCorporal WHERE =" +masaCV,null);
if (fila.moveToFirst()){
editTuEstado.setText(fila.getString(0));
editTuPesoIdeal.setText(fila.getString(1));
editTuRiesgo.setText(fila.getString(2));
} else
Toast.makeText(this,"No existe dicho valor",Toast.LENGTH_LONG).show();
db.close();
}
}
| 3,513 | 0.699402 | 0.697125 | 92 | 37.163044 | 26.694845 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 1 |
3a06ec732e400f63847448eec7563563903589dc | 7,868,380,148,245 | 14328856349dbf90731de4a824d588d539bfcacb | /test/TestDAO/JunitDAO.java | 7f858616c8d79a1c5d963001f2c655ba8075d686 | []
| no_license | Jbejaranos/Proyecto-Citas | https://github.com/Jbejaranos/Proyecto-Citas | e91a1c6d052c12a0b6d6b61e4838bec2ae6f2868 | fe31d3f18934a4c975b6072b467d1d0840b534d5 | refs/heads/master | 2022-11-17T06:05:40.663000 | 2020-07-13T18:24:13 | 2020-07-13T18:24:13 | 263,082,020 | 0 | 0 | null | false | 2020-07-13T18:24:15 | 2020-05-11T15:27:17 | 2020-07-13T17:15:22 | 2020-07-13T18:24:14 | 26,477 | 0 | 0 | 0 | Java | false | false | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package TestDAO;
/**
*
* @author USER
*/
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
import DAO.*;
import Modelo.*;
import java.util.Calendar;
public class JunitDAO {
private static AdministradorDAO adminDAO = new AdministradorDAO();
private static CitaDAO citaDAO = new CitaDAO();
private static ConsultorioDAO consDAO = new ConsultorioDAO();
private static HistoriaClinicaDAO histDAO = new HistoriaClinicaDAO();
private static MedicoDAO medDAO = new MedicoDAO();
private static PacienteDAO pacDAO = new PacienteDAO();
private static Medico med = new Medico(21,"House","12345","M",null,"General");
private static Paciente pac = new Paciente(11,"Pepito","12345","M",null);
private static Administrador admin = new Administrador(31,"Alejo","12345","M",null);
private static Consultorio con = new Consultorio(101, "f", "Sede");
private static Cita ct = new Cita(null,pac,med,con,"General");
private static HistoriaClinica hc = new HistoriaClinica(null,pac,null);
public JunitDAO() {
}
@BeforeClass
public static void setUpClass() {
pac.setHistoriaClinica(hc);
//med.asignarCita(ct);
//pac.asignarCita(ct);
adminDAO.crearAdministrador(admin);
citaDAO.crearCita(ct);
consDAO.crearConsultorio(con);
histDAO.crearHistoriaClinica(hc);
medDAO.crearMedico(med);
pacDAO.crearPaciente(pac);
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
public void testLecturaAdmin() {
Administrador ts = adminDAO.leerAdministrador(31);
assertEquals(ts,admin);
}
}
| UTF-8 | Java | 2,237 | java | JunitDAO.java | Java | [
{
"context": "e editor.\n */\npackage TestDAO;\n\n\n/**\n *\n * @author USER\n */\nimport org.junit.After;\nimport org.junit.Afte",
"end": 226,
"score": 0.9939964413642883,
"start": 222,
"tag": "USERNAME",
"value": "USER"
}
]
| null | []
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package TestDAO;
/**
*
* @author USER
*/
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
import DAO.*;
import Modelo.*;
import java.util.Calendar;
public class JunitDAO {
private static AdministradorDAO adminDAO = new AdministradorDAO();
private static CitaDAO citaDAO = new CitaDAO();
private static ConsultorioDAO consDAO = new ConsultorioDAO();
private static HistoriaClinicaDAO histDAO = new HistoriaClinicaDAO();
private static MedicoDAO medDAO = new MedicoDAO();
private static PacienteDAO pacDAO = new PacienteDAO();
private static Medico med = new Medico(21,"House","12345","M",null,"General");
private static Paciente pac = new Paciente(11,"Pepito","12345","M",null);
private static Administrador admin = new Administrador(31,"Alejo","12345","M",null);
private static Consultorio con = new Consultorio(101, "f", "Sede");
private static Cita ct = new Cita(null,pac,med,con,"General");
private static HistoriaClinica hc = new HistoriaClinica(null,pac,null);
public JunitDAO() {
}
@BeforeClass
public static void setUpClass() {
pac.setHistoriaClinica(hc);
//med.asignarCita(ct);
//pac.asignarCita(ct);
adminDAO.crearAdministrador(admin);
citaDAO.crearCita(ct);
consDAO.crearConsultorio(con);
histDAO.crearHistoriaClinica(hc);
medDAO.crearMedico(med);
pacDAO.crearPaciente(pac);
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
public void testLecturaAdmin() {
Administrador ts = adminDAO.leerAdministrador(31);
assertEquals(ts,admin);
}
}
| 2,237 | 0.665624 | 0.654001 | 80 | 26.9625 | 24.449154 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.7375 | false | false | 1 |
6627052595771a78fa18abd9e2bfd14f2f57a0dc | 12,661,563,608,725 | 7859a657d32a847cbedb83265bb49383573cebb2 | /src/com/xys/cenxi/customer/exception/CusException.java | c22a6feb3d441cde1c513edb6211a516d702cadb | []
| no_license | kanonwu/com.xys.cenxi.customer | https://github.com/kanonwu/com.xys.cenxi.customer | a13dd86088a6c72fea290182ec97b7839b4d0a0b | 2ba46c88395431baea56f75c60ece8a4be409996 | refs/heads/master | 2021-01-25T12:24:13.010000 | 2012-10-21T12:50:25 | 2012-10-21T12:50:25 | 5,734,775 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xys.cenxi.customer.exception;
public class CusException extends RuntimeException{
/**
*
*/
private static final long serialVersionUID = 4047869169657653130L;
public CusException(){
}
public CusException(Throwable e){
super(e);
}
public CusException(String mes){
super(mes);
}
public CusException(String mes, Throwable e){
super(mes, e);
}
}
| UTF-8 | Java | 386 | java | CusException.java | Java | []
| null | []
| package com.xys.cenxi.customer.exception;
public class CusException extends RuntimeException{
/**
*
*/
private static final long serialVersionUID = 4047869169657653130L;
public CusException(){
}
public CusException(Throwable e){
super(e);
}
public CusException(String mes){
super(mes);
}
public CusException(String mes, Throwable e){
super(mes, e);
}
}
| 386 | 0.704663 | 0.65544 | 25 | 14.44 | 19.043278 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.2 | false | false | 1 |
2ff6992e81b6fca139e7f4942430bffb2942ac77 | 14,164,802,190,209 | 0b6bc613af44fc8df6b31b63d4dad0335a78f8a1 | /src/main/java/com/group14/termproject/server/api/GameController.java | dc7f045dd7794b2419c8365ccc0eae5c9d70a9bc | []
| no_license | onurarrii/space-invaders-server | https://github.com/onurarrii/space-invaders-server | 0e6e247d84ec771a8a1f0b0105cf0fc6d75c5f6e | 2fd8d2128147ff2a8ccf9b81c79c0e17aed8f24e | refs/heads/master | 2023-02-01T03:20:45.906000 | 2020-05-06T08:58:15 | 2020-05-06T08:58:15 | 323,422,416 | 0 | 0 | null | false | 2020-12-21T18:54:36 | 2020-12-21T18:53:56 | 2020-12-21T18:54:13 | 2020-12-21T18:54:35 | 0 | 0 | 0 | 1 | Java | false | false | package com.group14.termproject.server.api;
import com.group14.termproject.server.game.management.GameRoomService;
import com.group14.termproject.server.game.util.Vector2D;
import com.group14.termproject.server.model.GameStatusDTO;
import com.group14.termproject.server.service.JwtService;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Collections;
import java.util.Map;
@RestController
@RequestMapping("game")
public class GameController {
private final GameRoomService gameRoomService;
private final JwtService jwtService;
public GameController(GameRoomService gameRoomService, JwtService jwtService) {
this.gameRoomService = gameRoomService;
this.jwtService = jwtService;
}
private ResponseEntity<Map<String, String>> getSuccessResponse() {
return new ResponseEntity<>(Collections.singletonMap("message", "Success"), HttpStatus.OK);
}
private long getUserId(String authorizationHeader) {
return jwtService.getUserId(jwtService.extractToken(authorizationHeader));
}
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ApiOperation(value = "Creates a new game room",
notes = "Must provide the authorization token that is given to user user when logging in",
response = Map.class)
public ResponseEntity<Map<String, String>> createRoom(@RequestHeader("Authorization") String authorizationHeader) {
gameRoomService.createGameRoom(getUserId(authorizationHeader));
return getSuccessResponse();
}
@ApiOperation(value = "Starts the game on previously created game room",
notes = "Must provide the authorization token that is given to user user when logging in",
response = Map.class)
@RequestMapping(value = "/start", method = RequestMethod.POST)
public ResponseEntity<Map<String, String>> startGame(@RequestHeader("Authorization") String authorizationHeader)
throws IllegalAccessException {
gameRoomService.startGame(getUserId(authorizationHeader));
return getSuccessResponse();
}
@ApiOperation(value = "Returns a game status json including game objects, current level and the state of the game",
notes = "Must provide the authorization token that is given to user user when logging in",
response = GameStatusDTO.class)
@RequestMapping(value = "/status", method = RequestMethod.GET)
public GameStatusDTO getGameStatus(@RequestHeader("Authorization") String authorizationHeader)
throws IllegalAccessException {
return gameRoomService.getGameStatus(getUserId(authorizationHeader));
}
@ApiOperation(value = "Repositions the player depending on mouse input",
notes = "Must provide the authorization token that is given to user user when logging in and a vector" +
" that contains x,y coordinates",
response = Map.class)
@RequestMapping(value = "/reposition", method = RequestMethod.POST)
public ResponseEntity<Map<String, String>> notifyNewMousePosition(@RequestHeader("Authorization") String authorizationHeader,
@RequestBody Vector2D newPosition) throws IllegalAccessException {
gameRoomService.notifyMousePositionChange(getUserId(authorizationHeader), newPosition);
return getSuccessResponse();
}
@ApiOperation(value = "Applies a cheat that kills all the enemies in the current level and passes to the next level",
notes = "Must provide the authorization token that is given to user user when logging in",
response = Map.class)
@RequestMapping(value = "/cheat", method = RequestMethod.POST)
public ResponseEntity<Map<String, String>> applyCheat(@RequestHeader("Authorization") String authorizationHeader)
throws IllegalAccessException {
gameRoomService.cheat(getUserId(authorizationHeader));
return getSuccessResponse();
}
}
| UTF-8 | Java | 4,163 | java | GameController.java | Java | []
| null | []
| package com.group14.termproject.server.api;
import com.group14.termproject.server.game.management.GameRoomService;
import com.group14.termproject.server.game.util.Vector2D;
import com.group14.termproject.server.model.GameStatusDTO;
import com.group14.termproject.server.service.JwtService;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Collections;
import java.util.Map;
@RestController
@RequestMapping("game")
public class GameController {
private final GameRoomService gameRoomService;
private final JwtService jwtService;
public GameController(GameRoomService gameRoomService, JwtService jwtService) {
this.gameRoomService = gameRoomService;
this.jwtService = jwtService;
}
private ResponseEntity<Map<String, String>> getSuccessResponse() {
return new ResponseEntity<>(Collections.singletonMap("message", "Success"), HttpStatus.OK);
}
private long getUserId(String authorizationHeader) {
return jwtService.getUserId(jwtService.extractToken(authorizationHeader));
}
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ApiOperation(value = "Creates a new game room",
notes = "Must provide the authorization token that is given to user user when logging in",
response = Map.class)
public ResponseEntity<Map<String, String>> createRoom(@RequestHeader("Authorization") String authorizationHeader) {
gameRoomService.createGameRoom(getUserId(authorizationHeader));
return getSuccessResponse();
}
@ApiOperation(value = "Starts the game on previously created game room",
notes = "Must provide the authorization token that is given to user user when logging in",
response = Map.class)
@RequestMapping(value = "/start", method = RequestMethod.POST)
public ResponseEntity<Map<String, String>> startGame(@RequestHeader("Authorization") String authorizationHeader)
throws IllegalAccessException {
gameRoomService.startGame(getUserId(authorizationHeader));
return getSuccessResponse();
}
@ApiOperation(value = "Returns a game status json including game objects, current level and the state of the game",
notes = "Must provide the authorization token that is given to user user when logging in",
response = GameStatusDTO.class)
@RequestMapping(value = "/status", method = RequestMethod.GET)
public GameStatusDTO getGameStatus(@RequestHeader("Authorization") String authorizationHeader)
throws IllegalAccessException {
return gameRoomService.getGameStatus(getUserId(authorizationHeader));
}
@ApiOperation(value = "Repositions the player depending on mouse input",
notes = "Must provide the authorization token that is given to user user when logging in and a vector" +
" that contains x,y coordinates",
response = Map.class)
@RequestMapping(value = "/reposition", method = RequestMethod.POST)
public ResponseEntity<Map<String, String>> notifyNewMousePosition(@RequestHeader("Authorization") String authorizationHeader,
@RequestBody Vector2D newPosition) throws IllegalAccessException {
gameRoomService.notifyMousePositionChange(getUserId(authorizationHeader), newPosition);
return getSuccessResponse();
}
@ApiOperation(value = "Applies a cheat that kills all the enemies in the current level and passes to the next level",
notes = "Must provide the authorization token that is given to user user when logging in",
response = Map.class)
@RequestMapping(value = "/cheat", method = RequestMethod.POST)
public ResponseEntity<Map<String, String>> applyCheat(@RequestHeader("Authorization") String authorizationHeader)
throws IllegalAccessException {
gameRoomService.cheat(getUserId(authorizationHeader));
return getSuccessResponse();
}
}
| 4,163 | 0.724237 | 0.721355 | 83 | 49.156628 | 38.225861 | 136 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.638554 | false | false | 1 |
021784677e24c0fc33d3bdb1e2ba12fb10e4134e | 5,196,910,428,198 | 7dfe54fb4de0a717ef439e5f6f002bd8f4ccd447 | /src/main/java/com/landian/sql/jpa/criterion/Restrictions.java | ce800235015da2dcc3b84ec1ff08c5c3eeea4f9f | [
"Apache-2.0"
]
| permissive | caojieliang/sql-jpa | https://github.com/caojieliang/sql-jpa | 7aabc11ac83fe749f51176997efff2d98472ba93 | 5dd0e071fc8ffd727d707b334fd6cad9d0ecd545 | refs/heads/master | 2021-01-11T03:21:39.791000 | 2017-08-02T02:17:24 | 2017-08-02T02:17:24 | 71,042,126 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.landian.sql.jpa.criterion;
import com.landian.sql.jpa.annotation.DateRangeTypePolicy;
import com.landian.sql.jpa.context.JavaType;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
/**
* 条件建造厂(限制建造器)
* to be continue
*/
public class Restrictions {
/**
* isNull
*/
public static Criterion isNull(String column){
return new CriterionIsNull(column);
}
/**
* 等于
*/
public static Criterion eq(String column, String value){
return new CriterionEqual(column, value, JavaType.STRING);
}
/**
* 等于
*/
public static Criterion eq(String column, int value){
return new CriterionEqual(column, value, JavaType.INT);
}
/**
* 等于
*/
public static Criterion eq(String column, long value){
return new CriterionEqual(column, value, JavaType.LONG);
}
private static Object getFirst(Collection values){
//Object object = values.stream().findFirst().get();
Object object = values.iterator().next();
return object;
}
/**
*
* @param column
* @param values
*/
public static Criterion notIn(String column, Collection values){
if(CollectionUtils.isEmpty(values)){
throw new RuntimeException("条件列表对像不能为空!");
}
// Object object = values.stream().findFirst().get();
Object object = getFirst(values);
JavaType type;
if(object instanceof Integer){
type = JavaType.INT;
}else if(object instanceof Long){
type = JavaType.LONG;
}else if(object instanceof String){
type = JavaType.STRING;
}else{
throw new RuntimeException("条件列表类型不合法!");
}
return new CriterionNotIn(column, values, type);
}
/**
*
* @param column
* @param valueArray
*/
public static Criterion notIn(String column, Object[] valueArray) {
if(null == valueArray || valueArray.length < 1){
throw new RuntimeException("条件列表对像不能为空!");
}
Object object = valueArray[0];
JavaType type;
if(object instanceof Integer){
type = JavaType.INT;
}else if(object instanceof Long){
type = JavaType.LONG;
}else if(object instanceof String){
type = JavaType.STRING;
}else{
throw new RuntimeException("条件列表类型不合法!");
}
return new CriterionNotIn(column, valueArray, type);
}
/**
*
* @param column
* @param values
* @param defaultValue 默认值
* @return
*/
public static Criterion notIn(String column, Collection values, int defaultValue){
if(CollectionUtils.isEmpty(values)){
values = new ArrayList();
values.add(defaultValue);
}
return new CriterionNotIn(column, values, JavaType.INT);
}
/**
*
* @param column
* @param values
* @param defaultValue 默认值
* @return
*/
public static Criterion notIn(String column, Collection values, long defaultValue){
if(CollectionUtils.isEmpty(values)){
values = new ArrayList();
values.add(defaultValue);
}
return new CriterionNotIn(column, values, JavaType.LONG);
}
/**
*
* @param column
* @param valueArray
*/
public static Criterion notIn(String column, Object[] valueArray, long defaultValue) {
List<Long> values = new ArrayList();
if(null != valueArray){
for(int i=0; i<valueArray.length; i++){
Object value = valueArray[i];
if(value instanceof Long){
values.add((Long)value);
}
}
}
return notIn(column, values, defaultValue);
}
/**
*
* @param column
* @param valueArray
*/
public static Criterion notIn(String column, Object[] valueArray, int defaultValue) {
List<Integer> values = new ArrayList<Integer>();
if(null != valueArray){
for(int i=0; i<valueArray.length; i++){
Object value = valueArray[i];
if(value instanceof Integer){
values.add((Integer)value);
}
}
}
return notIn(column, values, defaultValue);
}
/**
*
* @param column
* @param values
* @return
*/
public static Criterion in(String column, int... values){
List<Integer> collections = new ArrayList<Integer>();
for (int value : values) {
collections.add(value);
}
return in(column, collections);
}
/**
*
* @param column
* @param values
* @param defaultValue 默认值
* @return
*/
public static Criterion in(String column, Collection values, int defaultValue){
if(CollectionUtils.isEmpty(values)){
values = new ArrayList();
values.add(defaultValue);
}
return in(column, values);
}
/**
*
* @param column
* @param values
* @param defaultValue 默认值
* @return
*/
public static Criterion in(String column, Collection values, long defaultValue){
if(CollectionUtils.isEmpty(values)){
values = new ArrayList();
values.add(defaultValue);
}
return in(column, values);
}
/**
* IN
* date 15/12/30
*/
public static Criterion in(String column, Collection values){
if(CollectionUtils.isEmpty(values)){
throw new RuntimeException("条件列表对像不能为空!");
}
Object object = getFirst(values);
JavaType type;
if(object instanceof Integer){
type = JavaType.INT;
}else if(object instanceof Long){
type = JavaType.LONG;
}else if(object instanceof String){
type = JavaType.STRING;
}else{
throw new RuntimeException("条件列表类型不合法!");
}
return new CriterionIn(column, values, type);
}
/**
* IN
* date 15/12/30
*/
public static Criterion in(String column, Object[] valueArray) {
if(null == valueArray || valueArray.length < 1){
throw new RuntimeException("条件列表对像不能为空!");
}
Object object = valueArray[0];
JavaType type;
if(object instanceof Integer){
type = JavaType.INT;
}else if(object instanceof Long){
type = JavaType.LONG;
}else if(object instanceof String){
type = JavaType.STRING;
}else{
throw new RuntimeException("条件列表类型不合法!");
}
return new CriterionIn(column, valueArray, type);
}
/**
* like
*/
public static Criterion like(String column, String value){
return new CriterionLike(column, value);
}
/**
* 日期范围
* 目前只支持日期型 yyyy-MM-dd
* see com.qmsk.bossRefator.base.proxy.annotation.DateRangeTypePolicy
*/
public static Criterion dateBetween(String column, String beginTime, String endTime){
return new CriterionDateBetween(column, beginTime, endTime, DateRangeTypePolicy.DATE);
}
/**
* 大于等于某个日期
* 目前只支持日期型 yyyy-MM-dd
*/
public static Criterion dateGe(String column, String dateTime){
return new CriterionDateGe(column, dateTime);
}
/**
* 大于等于某个日期
* 目前只支持日期型 yyyy-MM-dd
*/
public static Criterion dateGe(String column, Date date){
return new CriterionDateGe(column, date);
}
/**
* 大于等于某个日期
* 目前只支持日期型 yyyy-MM-dd HH:mm:ss
*/
public static Criterion dateTimeGe(String column, Date date){
return new CriterionDateTimeGe(column, date);
}
/**
* 大于等于
*/
public static Criterion ge(String column, int value){
return new CriterionGe(column, value);
}
/**
* 小于等于
*/
public static Criterion le(String column, int value){
return new CriterionLe(column, value);
}
/**
* 小于等于某个日期
* 目前只支持日期型 yyyy-MM-dd
*/
public static Criterion dateLe(String column, String dateTime){
return new CriterionDateLe(column, dateTime);
}
/**
* 小于等于某个日期
* 目前只支持日期型 yyyy-MM-dd
*/
public static Criterion dateLe(String column, Date date){
return new CriterionDateLe(column, date);
}
/**
* 小于等于某个日期
* 目前只支持日期型 yyyy-MM-dd HH:mm:ss
*/
public static Criterion dateTimeLe(String column, Date date){
return new CriterionDateTimeLe(column, date);
}
/**
* 或
* date 15/08/26
*/
public static Criterion or(Criterion firstCriterion, Criterion secondCriterion){
return new CriterionOr(firstCriterion, secondCriterion);
}
/**
* 自定义
*/
public static Criterion sql(String sql){
return new CriterionSQL(sql);
}
}
| UTF-8 | Java | 8,105 | java | Restrictions.java | Java | []
| null | []
| package com.landian.sql.jpa.criterion;
import com.landian.sql.jpa.annotation.DateRangeTypePolicy;
import com.landian.sql.jpa.context.JavaType;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
/**
* 条件建造厂(限制建造器)
* to be continue
*/
public class Restrictions {
/**
* isNull
*/
public static Criterion isNull(String column){
return new CriterionIsNull(column);
}
/**
* 等于
*/
public static Criterion eq(String column, String value){
return new CriterionEqual(column, value, JavaType.STRING);
}
/**
* 等于
*/
public static Criterion eq(String column, int value){
return new CriterionEqual(column, value, JavaType.INT);
}
/**
* 等于
*/
public static Criterion eq(String column, long value){
return new CriterionEqual(column, value, JavaType.LONG);
}
private static Object getFirst(Collection values){
//Object object = values.stream().findFirst().get();
Object object = values.iterator().next();
return object;
}
/**
*
* @param column
* @param values
*/
public static Criterion notIn(String column, Collection values){
if(CollectionUtils.isEmpty(values)){
throw new RuntimeException("条件列表对像不能为空!");
}
// Object object = values.stream().findFirst().get();
Object object = getFirst(values);
JavaType type;
if(object instanceof Integer){
type = JavaType.INT;
}else if(object instanceof Long){
type = JavaType.LONG;
}else if(object instanceof String){
type = JavaType.STRING;
}else{
throw new RuntimeException("条件列表类型不合法!");
}
return new CriterionNotIn(column, values, type);
}
/**
*
* @param column
* @param valueArray
*/
public static Criterion notIn(String column, Object[] valueArray) {
if(null == valueArray || valueArray.length < 1){
throw new RuntimeException("条件列表对像不能为空!");
}
Object object = valueArray[0];
JavaType type;
if(object instanceof Integer){
type = JavaType.INT;
}else if(object instanceof Long){
type = JavaType.LONG;
}else if(object instanceof String){
type = JavaType.STRING;
}else{
throw new RuntimeException("条件列表类型不合法!");
}
return new CriterionNotIn(column, valueArray, type);
}
/**
*
* @param column
* @param values
* @param defaultValue 默认值
* @return
*/
public static Criterion notIn(String column, Collection values, int defaultValue){
if(CollectionUtils.isEmpty(values)){
values = new ArrayList();
values.add(defaultValue);
}
return new CriterionNotIn(column, values, JavaType.INT);
}
/**
*
* @param column
* @param values
* @param defaultValue 默认值
* @return
*/
public static Criterion notIn(String column, Collection values, long defaultValue){
if(CollectionUtils.isEmpty(values)){
values = new ArrayList();
values.add(defaultValue);
}
return new CriterionNotIn(column, values, JavaType.LONG);
}
/**
*
* @param column
* @param valueArray
*/
public static Criterion notIn(String column, Object[] valueArray, long defaultValue) {
List<Long> values = new ArrayList();
if(null != valueArray){
for(int i=0; i<valueArray.length; i++){
Object value = valueArray[i];
if(value instanceof Long){
values.add((Long)value);
}
}
}
return notIn(column, values, defaultValue);
}
/**
*
* @param column
* @param valueArray
*/
public static Criterion notIn(String column, Object[] valueArray, int defaultValue) {
List<Integer> values = new ArrayList<Integer>();
if(null != valueArray){
for(int i=0; i<valueArray.length; i++){
Object value = valueArray[i];
if(value instanceof Integer){
values.add((Integer)value);
}
}
}
return notIn(column, values, defaultValue);
}
/**
*
* @param column
* @param values
* @return
*/
public static Criterion in(String column, int... values){
List<Integer> collections = new ArrayList<Integer>();
for (int value : values) {
collections.add(value);
}
return in(column, collections);
}
/**
*
* @param column
* @param values
* @param defaultValue 默认值
* @return
*/
public static Criterion in(String column, Collection values, int defaultValue){
if(CollectionUtils.isEmpty(values)){
values = new ArrayList();
values.add(defaultValue);
}
return in(column, values);
}
/**
*
* @param column
* @param values
* @param defaultValue 默认值
* @return
*/
public static Criterion in(String column, Collection values, long defaultValue){
if(CollectionUtils.isEmpty(values)){
values = new ArrayList();
values.add(defaultValue);
}
return in(column, values);
}
/**
* IN
* date 15/12/30
*/
public static Criterion in(String column, Collection values){
if(CollectionUtils.isEmpty(values)){
throw new RuntimeException("条件列表对像不能为空!");
}
Object object = getFirst(values);
JavaType type;
if(object instanceof Integer){
type = JavaType.INT;
}else if(object instanceof Long){
type = JavaType.LONG;
}else if(object instanceof String){
type = JavaType.STRING;
}else{
throw new RuntimeException("条件列表类型不合法!");
}
return new CriterionIn(column, values, type);
}
/**
* IN
* date 15/12/30
*/
public static Criterion in(String column, Object[] valueArray) {
if(null == valueArray || valueArray.length < 1){
throw new RuntimeException("条件列表对像不能为空!");
}
Object object = valueArray[0];
JavaType type;
if(object instanceof Integer){
type = JavaType.INT;
}else if(object instanceof Long){
type = JavaType.LONG;
}else if(object instanceof String){
type = JavaType.STRING;
}else{
throw new RuntimeException("条件列表类型不合法!");
}
return new CriterionIn(column, valueArray, type);
}
/**
* like
*/
public static Criterion like(String column, String value){
return new CriterionLike(column, value);
}
/**
* 日期范围
* 目前只支持日期型 yyyy-MM-dd
* see com.qmsk.bossRefator.base.proxy.annotation.DateRangeTypePolicy
*/
public static Criterion dateBetween(String column, String beginTime, String endTime){
return new CriterionDateBetween(column, beginTime, endTime, DateRangeTypePolicy.DATE);
}
/**
* 大于等于某个日期
* 目前只支持日期型 yyyy-MM-dd
*/
public static Criterion dateGe(String column, String dateTime){
return new CriterionDateGe(column, dateTime);
}
/**
* 大于等于某个日期
* 目前只支持日期型 yyyy-MM-dd
*/
public static Criterion dateGe(String column, Date date){
return new CriterionDateGe(column, date);
}
/**
* 大于等于某个日期
* 目前只支持日期型 yyyy-MM-dd HH:mm:ss
*/
public static Criterion dateTimeGe(String column, Date date){
return new CriterionDateTimeGe(column, date);
}
/**
* 大于等于
*/
public static Criterion ge(String column, int value){
return new CriterionGe(column, value);
}
/**
* 小于等于
*/
public static Criterion le(String column, int value){
return new CriterionLe(column, value);
}
/**
* 小于等于某个日期
* 目前只支持日期型 yyyy-MM-dd
*/
public static Criterion dateLe(String column, String dateTime){
return new CriterionDateLe(column, dateTime);
}
/**
* 小于等于某个日期
* 目前只支持日期型 yyyy-MM-dd
*/
public static Criterion dateLe(String column, Date date){
return new CriterionDateLe(column, date);
}
/**
* 小于等于某个日期
* 目前只支持日期型 yyyy-MM-dd HH:mm:ss
*/
public static Criterion dateTimeLe(String column, Date date){
return new CriterionDateTimeLe(column, date);
}
/**
* 或
* date 15/08/26
*/
public static Criterion or(Criterion firstCriterion, Criterion secondCriterion){
return new CriterionOr(firstCriterion, secondCriterion);
}
/**
* 自定义
*/
public static Criterion sql(String sql){
return new CriterionSQL(sql);
}
}
| 8,105 | 0.683749 | 0.680612 | 345 | 21.171015 | 21.546371 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.846377 | false | false | 1 |
934bef1069a4ea7fe051a6b7bb68772b10fc47a4 | 1,434,519,131,261 | 9bbb86d1c2217ac103f437753fb561fa4d111714 | /src/main/java/com/superstar/model/system/SysAreaExample.java | 2a2b44d97b66e70144218ebf45d3759a41ae214d | []
| no_license | venbill/huizhou-server | https://github.com/venbill/huizhou-server | 24797b6c95ff5c6eb37f4b9adf016bb1573b67ea | fb857a86905b53a50b3756014bd554bd7d2114b5 | refs/heads/master | 2020-03-31T11:26:01.563000 | 2018-10-20T07:05:27 | 2018-10-20T07:05:27 | 152,176,451 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.superstar.model.system;
import java.util.ArrayList;
import java.util.List;
public class SysAreaExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public SysAreaExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andCodeIsNull() {
addCriterion("code is null");
return (Criteria) this;
}
public Criteria andCodeIsNotNull() {
addCriterion("code is not null");
return (Criteria) this;
}
public Criteria andCodeEqualTo(Integer value) {
addCriterion("code =", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotEqualTo(Integer value) {
addCriterion("code <>", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThan(Integer value) {
addCriterion("code >", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThanOrEqualTo(Integer value) {
addCriterion("code >=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThan(Integer value) {
addCriterion("code <", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThanOrEqualTo(Integer value) {
addCriterion("code <=", value, "code");
return (Criteria) this;
}
public Criteria andCodeIn(List<Integer> values) {
addCriterion("code in", values, "code");
return (Criteria) this;
}
public Criteria andCodeNotIn(List<Integer> values) {
addCriterion("code not in", values, "code");
return (Criteria) this;
}
public Criteria andCodeBetween(Integer value1, Integer value2) {
addCriterion("code between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andCodeNotBetween(Integer value1, Integer value2) {
addCriterion("code not between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("name is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("name is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("name =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("name <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("name >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("name >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("name <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("name <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("name like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("name not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("name in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("name not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("name between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("name not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andProvinceIdIsNull() {
addCriterion("province_id is null");
return (Criteria) this;
}
public Criteria andProvinceIdIsNotNull() {
addCriterion("province_id is not null");
return (Criteria) this;
}
public Criteria andProvinceIdEqualTo(Integer value) {
addCriterion("province_id =", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdNotEqualTo(Integer value) {
addCriterion("province_id <>", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdGreaterThan(Integer value) {
addCriterion("province_id >", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdGreaterThanOrEqualTo(Integer value) {
addCriterion("province_id >=", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdLessThan(Integer value) {
addCriterion("province_id <", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdLessThanOrEqualTo(Integer value) {
addCriterion("province_id <=", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdIn(List<Integer> values) {
addCriterion("province_id in", values, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdNotIn(List<Integer> values) {
addCriterion("province_id not in", values, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdBetween(Integer value1, Integer value2) {
addCriterion("province_id between", value1, value2, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdNotBetween(Integer value1, Integer value2) {
addCriterion("province_id not between", value1, value2, "provinceId");
return (Criteria) this;
}
public Criteria andCityIdIsNull() {
addCriterion("city_id is null");
return (Criteria) this;
}
public Criteria andCityIdIsNotNull() {
addCriterion("city_id is not null");
return (Criteria) this;
}
public Criteria andCityIdEqualTo(Integer value) {
addCriterion("city_id =", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdNotEqualTo(Integer value) {
addCriterion("city_id <>", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdGreaterThan(Integer value) {
addCriterion("city_id >", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdGreaterThanOrEqualTo(Integer value) {
addCriterion("city_id >=", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdLessThan(Integer value) {
addCriterion("city_id <", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdLessThanOrEqualTo(Integer value) {
addCriterion("city_id <=", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdIn(List<Integer> values) {
addCriterion("city_id in", values, "cityId");
return (Criteria) this;
}
public Criteria andCityIdNotIn(List<Integer> values) {
addCriterion("city_id not in", values, "cityId");
return (Criteria) this;
}
public Criteria andCityIdBetween(Integer value1, Integer value2) {
addCriterion("city_id between", value1, value2, "cityId");
return (Criteria) this;
}
public Criteria andCityIdNotBetween(Integer value1, Integer value2) {
addCriterion("city_id not between", value1, value2, "cityId");
return (Criteria) this;
}
public Criteria andCountyIdIsNull() {
addCriterion("county_id is null");
return (Criteria) this;
}
public Criteria andCountyIdIsNotNull() {
addCriterion("county_id is not null");
return (Criteria) this;
}
public Criteria andCountyIdEqualTo(Integer value) {
addCriterion("county_id =", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdNotEqualTo(Integer value) {
addCriterion("county_id <>", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdGreaterThan(Integer value) {
addCriterion("county_id >", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdGreaterThanOrEqualTo(Integer value) {
addCriterion("county_id >=", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdLessThan(Integer value) {
addCriterion("county_id <", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdLessThanOrEqualTo(Integer value) {
addCriterion("county_id <=", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdIn(List<Integer> values) {
addCriterion("county_id in", values, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdNotIn(List<Integer> values) {
addCriterion("county_id not in", values, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdBetween(Integer value1, Integer value2) {
addCriterion("county_id between", value1, value2, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdNotBetween(Integer value1, Integer value2) {
addCriterion("county_id not between", value1, value2, "countyId");
return (Criteria) this;
}
public Criteria andParentNodeIsNull() {
addCriterion("parent_node is null");
return (Criteria) this;
}
public Criteria andParentNodeIsNotNull() {
addCriterion("parent_node is not null");
return (Criteria) this;
}
public Criteria andParentNodeEqualTo(Integer value) {
addCriterion("parent_node =", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeNotEqualTo(Integer value) {
addCriterion("parent_node <>", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeGreaterThan(Integer value) {
addCriterion("parent_node >", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeGreaterThanOrEqualTo(Integer value) {
addCriterion("parent_node >=", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeLessThan(Integer value) {
addCriterion("parent_node <", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeLessThanOrEqualTo(Integer value) {
addCriterion("parent_node <=", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeIn(List<Integer> values) {
addCriterion("parent_node in", values, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeNotIn(List<Integer> values) {
addCriterion("parent_node not in", values, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeBetween(Integer value1, Integer value2) {
addCriterion("parent_node between", value1, value2, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeNotBetween(Integer value1, Integer value2) {
addCriterion("parent_node not between", value1, value2, "parentNode");
return (Criteria) this;
}
public Criteria andProvinceNameIsNull() {
addCriterion("province_name is null");
return (Criteria) this;
}
public Criteria andProvinceNameIsNotNull() {
addCriterion("province_name is not null");
return (Criteria) this;
}
public Criteria andProvinceNameEqualTo(String value) {
addCriterion("province_name =", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotEqualTo(String value) {
addCriterion("province_name <>", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameGreaterThan(String value) {
addCriterion("province_name >", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameGreaterThanOrEqualTo(String value) {
addCriterion("province_name >=", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameLessThan(String value) {
addCriterion("province_name <", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameLessThanOrEqualTo(String value) {
addCriterion("province_name <=", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameLike(String value) {
addCriterion("province_name like", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotLike(String value) {
addCriterion("province_name not like", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameIn(List<String> values) {
addCriterion("province_name in", values, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotIn(List<String> values) {
addCriterion("province_name not in", values, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameBetween(String value1, String value2) {
addCriterion("province_name between", value1, value2, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotBetween(String value1, String value2) {
addCriterion("province_name not between", value1, value2, "provinceName");
return (Criteria) this;
}
public Criteria andCityNameIsNull() {
addCriterion("city_name is null");
return (Criteria) this;
}
public Criteria andCityNameIsNotNull() {
addCriterion("city_name is not null");
return (Criteria) this;
}
public Criteria andCityNameEqualTo(String value) {
addCriterion("city_name =", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameNotEqualTo(String value) {
addCriterion("city_name <>", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameGreaterThan(String value) {
addCriterion("city_name >", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameGreaterThanOrEqualTo(String value) {
addCriterion("city_name >=", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameLessThan(String value) {
addCriterion("city_name <", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameLessThanOrEqualTo(String value) {
addCriterion("city_name <=", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameLike(String value) {
addCriterion("city_name like", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameNotLike(String value) {
addCriterion("city_name not like", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameIn(List<String> values) {
addCriterion("city_name in", values, "cityName");
return (Criteria) this;
}
public Criteria andCityNameNotIn(List<String> values) {
addCriterion("city_name not in", values, "cityName");
return (Criteria) this;
}
public Criteria andCityNameBetween(String value1, String value2) {
addCriterion("city_name between", value1, value2, "cityName");
return (Criteria) this;
}
public Criteria andCityNameNotBetween(String value1, String value2) {
addCriterion("city_name not between", value1, value2, "cityName");
return (Criteria) this;
}
public Criteria andCountyNameIsNull() {
addCriterion("county_name is null");
return (Criteria) this;
}
public Criteria andCountyNameIsNotNull() {
addCriterion("county_name is not null");
return (Criteria) this;
}
public Criteria andCountyNameEqualTo(String value) {
addCriterion("county_name =", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameNotEqualTo(String value) {
addCriterion("county_name <>", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameGreaterThan(String value) {
addCriterion("county_name >", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameGreaterThanOrEqualTo(String value) {
addCriterion("county_name >=", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameLessThan(String value) {
addCriterion("county_name <", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameLessThanOrEqualTo(String value) {
addCriterion("county_name <=", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameLike(String value) {
addCriterion("county_name like", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameNotLike(String value) {
addCriterion("county_name not like", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameIn(List<String> values) {
addCriterion("county_name in", values, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameNotIn(List<String> values) {
addCriterion("county_name not in", values, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameBetween(String value1, String value2) {
addCriterion("county_name between", value1, value2, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameNotBetween(String value1, String value2) {
addCriterion("county_name not between", value1, value2, "countyName");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("type is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Integer value) {
addCriterion("type =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Integer value) {
addCriterion("type <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Integer value) {
addCriterion("type >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("type >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Integer value) {
addCriterion("type <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Integer value) {
addCriterion("type <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Integer> values) {
addCriterion("type in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Integer> values) {
addCriterion("type not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Integer value1, Integer value2) {
addCriterion("type between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Integer value1, Integer value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
} | UTF-8 | Java | 28,874 | java | SysAreaExample.java | Java | []
| null | []
| package com.superstar.model.system;
import java.util.ArrayList;
import java.util.List;
public class SysAreaExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public SysAreaExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andCodeIsNull() {
addCriterion("code is null");
return (Criteria) this;
}
public Criteria andCodeIsNotNull() {
addCriterion("code is not null");
return (Criteria) this;
}
public Criteria andCodeEqualTo(Integer value) {
addCriterion("code =", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotEqualTo(Integer value) {
addCriterion("code <>", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThan(Integer value) {
addCriterion("code >", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThanOrEqualTo(Integer value) {
addCriterion("code >=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThan(Integer value) {
addCriterion("code <", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThanOrEqualTo(Integer value) {
addCriterion("code <=", value, "code");
return (Criteria) this;
}
public Criteria andCodeIn(List<Integer> values) {
addCriterion("code in", values, "code");
return (Criteria) this;
}
public Criteria andCodeNotIn(List<Integer> values) {
addCriterion("code not in", values, "code");
return (Criteria) this;
}
public Criteria andCodeBetween(Integer value1, Integer value2) {
addCriterion("code between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andCodeNotBetween(Integer value1, Integer value2) {
addCriterion("code not between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("name is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("name is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("name =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("name <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("name >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("name >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("name <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("name <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("name like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("name not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("name in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("name not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("name between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("name not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andProvinceIdIsNull() {
addCriterion("province_id is null");
return (Criteria) this;
}
public Criteria andProvinceIdIsNotNull() {
addCriterion("province_id is not null");
return (Criteria) this;
}
public Criteria andProvinceIdEqualTo(Integer value) {
addCriterion("province_id =", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdNotEqualTo(Integer value) {
addCriterion("province_id <>", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdGreaterThan(Integer value) {
addCriterion("province_id >", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdGreaterThanOrEqualTo(Integer value) {
addCriterion("province_id >=", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdLessThan(Integer value) {
addCriterion("province_id <", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdLessThanOrEqualTo(Integer value) {
addCriterion("province_id <=", value, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdIn(List<Integer> values) {
addCriterion("province_id in", values, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdNotIn(List<Integer> values) {
addCriterion("province_id not in", values, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdBetween(Integer value1, Integer value2) {
addCriterion("province_id between", value1, value2, "provinceId");
return (Criteria) this;
}
public Criteria andProvinceIdNotBetween(Integer value1, Integer value2) {
addCriterion("province_id not between", value1, value2, "provinceId");
return (Criteria) this;
}
public Criteria andCityIdIsNull() {
addCriterion("city_id is null");
return (Criteria) this;
}
public Criteria andCityIdIsNotNull() {
addCriterion("city_id is not null");
return (Criteria) this;
}
public Criteria andCityIdEqualTo(Integer value) {
addCriterion("city_id =", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdNotEqualTo(Integer value) {
addCriterion("city_id <>", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdGreaterThan(Integer value) {
addCriterion("city_id >", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdGreaterThanOrEqualTo(Integer value) {
addCriterion("city_id >=", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdLessThan(Integer value) {
addCriterion("city_id <", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdLessThanOrEqualTo(Integer value) {
addCriterion("city_id <=", value, "cityId");
return (Criteria) this;
}
public Criteria andCityIdIn(List<Integer> values) {
addCriterion("city_id in", values, "cityId");
return (Criteria) this;
}
public Criteria andCityIdNotIn(List<Integer> values) {
addCriterion("city_id not in", values, "cityId");
return (Criteria) this;
}
public Criteria andCityIdBetween(Integer value1, Integer value2) {
addCriterion("city_id between", value1, value2, "cityId");
return (Criteria) this;
}
public Criteria andCityIdNotBetween(Integer value1, Integer value2) {
addCriterion("city_id not between", value1, value2, "cityId");
return (Criteria) this;
}
public Criteria andCountyIdIsNull() {
addCriterion("county_id is null");
return (Criteria) this;
}
public Criteria andCountyIdIsNotNull() {
addCriterion("county_id is not null");
return (Criteria) this;
}
public Criteria andCountyIdEqualTo(Integer value) {
addCriterion("county_id =", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdNotEqualTo(Integer value) {
addCriterion("county_id <>", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdGreaterThan(Integer value) {
addCriterion("county_id >", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdGreaterThanOrEqualTo(Integer value) {
addCriterion("county_id >=", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdLessThan(Integer value) {
addCriterion("county_id <", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdLessThanOrEqualTo(Integer value) {
addCriterion("county_id <=", value, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdIn(List<Integer> values) {
addCriterion("county_id in", values, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdNotIn(List<Integer> values) {
addCriterion("county_id not in", values, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdBetween(Integer value1, Integer value2) {
addCriterion("county_id between", value1, value2, "countyId");
return (Criteria) this;
}
public Criteria andCountyIdNotBetween(Integer value1, Integer value2) {
addCriterion("county_id not between", value1, value2, "countyId");
return (Criteria) this;
}
public Criteria andParentNodeIsNull() {
addCriterion("parent_node is null");
return (Criteria) this;
}
public Criteria andParentNodeIsNotNull() {
addCriterion("parent_node is not null");
return (Criteria) this;
}
public Criteria andParentNodeEqualTo(Integer value) {
addCriterion("parent_node =", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeNotEqualTo(Integer value) {
addCriterion("parent_node <>", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeGreaterThan(Integer value) {
addCriterion("parent_node >", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeGreaterThanOrEqualTo(Integer value) {
addCriterion("parent_node >=", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeLessThan(Integer value) {
addCriterion("parent_node <", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeLessThanOrEqualTo(Integer value) {
addCriterion("parent_node <=", value, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeIn(List<Integer> values) {
addCriterion("parent_node in", values, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeNotIn(List<Integer> values) {
addCriterion("parent_node not in", values, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeBetween(Integer value1, Integer value2) {
addCriterion("parent_node between", value1, value2, "parentNode");
return (Criteria) this;
}
public Criteria andParentNodeNotBetween(Integer value1, Integer value2) {
addCriterion("parent_node not between", value1, value2, "parentNode");
return (Criteria) this;
}
public Criteria andProvinceNameIsNull() {
addCriterion("province_name is null");
return (Criteria) this;
}
public Criteria andProvinceNameIsNotNull() {
addCriterion("province_name is not null");
return (Criteria) this;
}
public Criteria andProvinceNameEqualTo(String value) {
addCriterion("province_name =", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotEqualTo(String value) {
addCriterion("province_name <>", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameGreaterThan(String value) {
addCriterion("province_name >", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameGreaterThanOrEqualTo(String value) {
addCriterion("province_name >=", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameLessThan(String value) {
addCriterion("province_name <", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameLessThanOrEqualTo(String value) {
addCriterion("province_name <=", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameLike(String value) {
addCriterion("province_name like", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotLike(String value) {
addCriterion("province_name not like", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameIn(List<String> values) {
addCriterion("province_name in", values, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotIn(List<String> values) {
addCriterion("province_name not in", values, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameBetween(String value1, String value2) {
addCriterion("province_name between", value1, value2, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotBetween(String value1, String value2) {
addCriterion("province_name not between", value1, value2, "provinceName");
return (Criteria) this;
}
public Criteria andCityNameIsNull() {
addCriterion("city_name is null");
return (Criteria) this;
}
public Criteria andCityNameIsNotNull() {
addCriterion("city_name is not null");
return (Criteria) this;
}
public Criteria andCityNameEqualTo(String value) {
addCriterion("city_name =", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameNotEqualTo(String value) {
addCriterion("city_name <>", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameGreaterThan(String value) {
addCriterion("city_name >", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameGreaterThanOrEqualTo(String value) {
addCriterion("city_name >=", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameLessThan(String value) {
addCriterion("city_name <", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameLessThanOrEqualTo(String value) {
addCriterion("city_name <=", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameLike(String value) {
addCriterion("city_name like", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameNotLike(String value) {
addCriterion("city_name not like", value, "cityName");
return (Criteria) this;
}
public Criteria andCityNameIn(List<String> values) {
addCriterion("city_name in", values, "cityName");
return (Criteria) this;
}
public Criteria andCityNameNotIn(List<String> values) {
addCriterion("city_name not in", values, "cityName");
return (Criteria) this;
}
public Criteria andCityNameBetween(String value1, String value2) {
addCriterion("city_name between", value1, value2, "cityName");
return (Criteria) this;
}
public Criteria andCityNameNotBetween(String value1, String value2) {
addCriterion("city_name not between", value1, value2, "cityName");
return (Criteria) this;
}
public Criteria andCountyNameIsNull() {
addCriterion("county_name is null");
return (Criteria) this;
}
public Criteria andCountyNameIsNotNull() {
addCriterion("county_name is not null");
return (Criteria) this;
}
public Criteria andCountyNameEqualTo(String value) {
addCriterion("county_name =", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameNotEqualTo(String value) {
addCriterion("county_name <>", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameGreaterThan(String value) {
addCriterion("county_name >", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameGreaterThanOrEqualTo(String value) {
addCriterion("county_name >=", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameLessThan(String value) {
addCriterion("county_name <", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameLessThanOrEqualTo(String value) {
addCriterion("county_name <=", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameLike(String value) {
addCriterion("county_name like", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameNotLike(String value) {
addCriterion("county_name not like", value, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameIn(List<String> values) {
addCriterion("county_name in", values, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameNotIn(List<String> values) {
addCriterion("county_name not in", values, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameBetween(String value1, String value2) {
addCriterion("county_name between", value1, value2, "countyName");
return (Criteria) this;
}
public Criteria andCountyNameNotBetween(String value1, String value2) {
addCriterion("county_name not between", value1, value2, "countyName");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("type is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Integer value) {
addCriterion("type =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Integer value) {
addCriterion("type <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Integer value) {
addCriterion("type >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("type >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Integer value) {
addCriterion("type <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Integer value) {
addCriterion("type <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Integer> values) {
addCriterion("type in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Integer> values) {
addCriterion("type not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Integer value1, Integer value2) {
addCriterion("type between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Integer value1, Integer value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
} | 28,874 | 0.576297 | 0.572972 | 900 | 31.083334 | 25.465767 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.726667 | false | false | 1 |
4dca521770772b95c19a49bf18e3e13053a4683a | 30,099,130,849,695 | 039f1b836052b409d9335b17a7ae624b8c8d144a | /src/main/java/dataworkers/MDWorker.java | 60b40b82804118d478c4487cf0c80953daed017c | []
| no_license | aaa4/GUIPLAY | https://github.com/aaa4/GUIPLAY | cecf7ff21699fbfa67e74835dc9417b25afb0ed3 | 4a25e54360ebbb32e702818e8a992bfa5bd8d135 | refs/heads/master | 2016-09-17T13:32:02.650000 | 2016-08-12T20:46:57 | 2016-08-12T20:46:57 | 65,220,817 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package dataworkers;
import java.util.Date;
/**
* Created by Nyansus on 24.07.2016.
*
* МДшку наследуем от Шастика, т.к. далее
* потрбуется и номер шастика и номер МДшки
*/
public class MDWorker extends ShaWorker {
private String mdNumber;
public String getMdNumber() {
return mdNumber;
}
public void setMdNumber(String mdNumber) {
this.mdNumber = mdNumber;
}
@Override
public String toString(){
return "Мдшка = " +mdNumber+"; "+super.toString();
}
public void addToNull(ShaWorker sw){
super.setBlockNumber(sw.getBlockNumber());
super.setBlockType(sw.getBlockType());
super.setShaNumber(sw.getShaNumber());
super.setShaNumber(sw.getShaNumber());
super.setnDate(sw.getnDate());
super.setNote(sw.getNote());
super.setObj(sw.getObj());
}
public static void main(String[] args) {
MDWorker mdWorker = new MDWorker();
mdWorker.setObj("2203");
mdWorker.setnDate(new Date());
mdWorker.setMdNumber("6745A");
System.out.println(mdWorker);
}
}
| UTF-8 | Java | 1,183 | java | MDWorker.java | Java | [
{
"context": "orkers;\n\nimport java.util.Date;\n\n/**\n * Created by Nyansus on 24.07.2016.\n *\n * МДшку наследуем от Шастика, ",
"end": 71,
"score": 0.9995402693748474,
"start": 64,
"tag": "USERNAME",
"value": "Nyansus"
}
]
| null | []
| package dataworkers;
import java.util.Date;
/**
* Created by Nyansus on 24.07.2016.
*
* МДшку наследуем от Шастика, т.к. далее
* потрбуется и номер шастика и номер МДшки
*/
public class MDWorker extends ShaWorker {
private String mdNumber;
public String getMdNumber() {
return mdNumber;
}
public void setMdNumber(String mdNumber) {
this.mdNumber = mdNumber;
}
@Override
public String toString(){
return "Мдшка = " +mdNumber+"; "+super.toString();
}
public void addToNull(ShaWorker sw){
super.setBlockNumber(sw.getBlockNumber());
super.setBlockType(sw.getBlockType());
super.setShaNumber(sw.getShaNumber());
super.setShaNumber(sw.getShaNumber());
super.setnDate(sw.getnDate());
super.setNote(sw.getNote());
super.setObj(sw.getObj());
}
public static void main(String[] args) {
MDWorker mdWorker = new MDWorker();
mdWorker.setObj("2203");
mdWorker.setnDate(new Date());
mdWorker.setMdNumber("6745A");
System.out.println(mdWorker);
}
}
| 1,183 | 0.629264 | 0.614901 | 45 | 23.755556 | 18.608427 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 1 |
e3619b43b2244368c891156759666168bb9b9fd1 | 8,383,776,212,977 | 061888f70fbed842b85496d6d5095c4dbc2c7f01 | /cloud-admin/cloud-admin-api/src/main/java/com/cloud/admin/beans/po/SysDict.java | 1b0e0789e0a063887a2a831c88d956dedc52a3fc | [
"Apache-2.0"
]
| permissive | pro-cloud/pro-cloud | https://github.com/pro-cloud/pro-cloud | 0c220eed9b669bc0e9928c1670980518e0045172 | 09a6f6c6820b09aa7451c60402dde545eef82322 | refs/heads/master | 2022-06-23T13:12:33.638000 | 2021-09-26T01:57:02 | 2021-09-26T01:57:02 | 247,095,111 | 22 | 9 | Apache-2.0 | false | 2022-06-17T03:01:07 | 2020-03-13T14:51:13 | 2022-06-15T12:20:57 | 2022-06-17T03:01:06 | 3,025 | 18 | 8 | 4 | Java | false | false | package com.cloud.admin.beans.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 字典表
*
* @author Aijm
* @date 2019-09-05 16:53:21
*/
@Data
@TableName("sys_dict")
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "字典表")
public class SysDict extends BaseEntity<SysDict> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "类型字典/树")
private String name;
@ApiModelProperty(value = "类型字典/树")
private Integer type;
@ApiModelProperty(value = "类型编码")
private String typeCode;
@ApiModelProperty(value = "是否是系统级别数据 0 普通 1 系统")
private Integer system;
}
| UTF-8 | Java | 891 | java | SysDict.java | Java | [
{
"context": "ombok.EqualsAndHashCode;\n\n/**\n * 字典表\n *\n * @author Aijm\n * @date 2019-09-05 16:53:21\n */\n@Data\n@TableName",
"end": 303,
"score": 0.9997120499610901,
"start": 299,
"tag": "USERNAME",
"value": "Aijm"
}
]
| null | []
| package com.cloud.admin.beans.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 字典表
*
* @author Aijm
* @date 2019-09-05 16:53:21
*/
@Data
@TableName("sys_dict")
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "字典表")
public class SysDict extends BaseEntity<SysDict> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "类型字典/树")
private String name;
@ApiModelProperty(value = "类型字典/树")
private Integer type;
@ApiModelProperty(value = "类型编码")
private String typeCode;
@ApiModelProperty(value = "是否是系统级别数据 0 普通 1 系统")
private Integer system;
}
| 891 | 0.733333 | 0.712727 | 36 | 21.916666 | 18.477276 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 1 |
df171e7018017177e0ec8943d07765a84101ba78 | 10,239,202,103,740 | 7401b9c41aef061b21bb7d08f0cee8eeee7f740d | /src/pdp_lessons/module1/extraTask/hackpassword/FindPassword2.java | 0970a1cd003dd3795246d850c12c79ee7fb82384 | []
| no_license | KhamzaKuranbayev/PDP | https://github.com/KhamzaKuranbayev/PDP | 2f39c830a6b9c71e9e9c07e7e820e64542ff0771 | 68918f9336621405302b948f887fb46f50950c07 | refs/heads/master | 2023-01-06T11:23:56.446000 | 2020-11-06T19:08:53 | 2020-11-06T19:08:53 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pdp_lessons.module1.extraTask.hackpassword;
import java.util.Random;
import java.util.Scanner;
public class FindPassword2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
String random_password = getRandomPassword();
System.out.println(random_password);
System.out.print("Please enter your password (exit - stop process): ");
String user_password = scanner.nextLine();
user_password = user_password.toUpperCase();
if (user_password.equals("EXIT"))
System.exit(0);
if (user_password.length() != 4 && isNumberLetter(user_password)) {
System.out.println("Error!!! Password must 4 digits length\n");
} else if (user_password.length() == 4 && !isNumberLetter(user_password)) {
System.out.println("Error!!! Password must be numeric and letter\n");
} else if (user_password.equals(random_password)) {
System.out.println("Welcome to system!!!\n");
} else {
System.out.println("Error!!! Your password does not match. Password is " + random_password + "\n");
}
}
}
public static boolean isNumberLetter(String str) {
int countDigit = 0;
int countLetter = 0;
for (char c : str.toCharArray()) {
if (Character.isDigit(c))
countDigit++;
if (Character.isLetter(c))
countLetter++;
}
return countDigit != 0 && countLetter != 0;
}
public static String getRandomPassword() {
String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
StringBuilder stringBuilder = new StringBuilder();
Random random = new Random();
for (int i = 0; i < 4; i++) {
stringBuilder.append(str.charAt(random.nextInt(str.length())));
}
return stringBuilder.toString();
}
}
| UTF-8 | Java | 2,008 | java | FindPassword2.java | Java | [
{
"context": "r!!! Your password does not match. Password is \" + random_password + \"\\n\");\n }\n }\n }\n\n",
"end": 1214,
"score": 0.5751614570617676,
"start": 1208,
"tag": "PASSWORD",
"value": "random"
},
{
"context": " String str = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\";\n StringBuilder stringBuilder = ne",
"end": 1725,
"score": 0.5021122097969055,
"start": 1724,
"tag": "PASSWORD",
"value": "3"
},
{
"context": " String str = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\";\n StringBuilder stringBuilder = new St",
"end": 1729,
"score": 0.5336624979972839,
"start": 1726,
"tag": "PASSWORD",
"value": "567"
}
]
| null | []
| package pdp_lessons.module1.extraTask.hackpassword;
import java.util.Random;
import java.util.Scanner;
public class FindPassword2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
String random_password = getRandomPassword();
System.out.println(random_password);
System.out.print("Please enter your password (exit - stop process): ");
String user_password = scanner.nextLine();
user_password = user_password.toUpperCase();
if (user_password.equals("EXIT"))
System.exit(0);
if (user_password.length() != 4 && isNumberLetter(user_password)) {
System.out.println("Error!!! Password must 4 digits length\n");
} else if (user_password.length() == 4 && !isNumberLetter(user_password)) {
System.out.println("Error!!! Password must be numeric and letter\n");
} else if (user_password.equals(random_password)) {
System.out.println("Welcome to system!!!\n");
} else {
System.out.println("Error!!! Your password does not match. Password is " + <PASSWORD>_password + "\n");
}
}
}
public static boolean isNumberLetter(String str) {
int countDigit = 0;
int countLetter = 0;
for (char c : str.toCharArray()) {
if (Character.isDigit(c))
countDigit++;
if (Character.isLetter(c))
countLetter++;
}
return countDigit != 0 && countLetter != 0;
}
public static String getRandomPassword() {
String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
StringBuilder stringBuilder = new StringBuilder();
Random random = new Random();
for (int i = 0; i < 4; i++) {
stringBuilder.append(str.charAt(random.nextInt(str.length())));
}
return stringBuilder.toString();
}
}
| 2,012 | 0.576195 | 0.565239 | 57 | 34.228069 | 28.277458 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.45614 | false | false | 1 |
791b10c800846524bcc924448df706501d2d61fe | 24,240,795,472,340 | d6b7c227a3286f7d1f56c62a68427491d15e8f47 | /src/main/java/br/com/actia/gson/ListPoiAdapter.java | 20654147d7ae57be3a1d56a5e73a116a9993935b | []
| no_license | aaarmani/GeradorDeConteudo | https://github.com/aaarmani/GeradorDeConteudo | 721e738d00e4e43a403cc358994bd590125e35d2 | 8f86343b976e1e4ff334dbd5ce7336655fb50077 | refs/heads/master | 2016-09-05T13:03:59.427000 | 2015-12-21T13:35:22 | 2015-12-21T13:35:22 | 33,634,575 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.actia.gson;
import br.com.actia.model.Poi;
import br.com.actia.model.ListPoi;
import br.com.actia.model.PoiType;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
/**
*
* @author Armani <anderson.armani@actia.com.br>
*/
public class ListPoiAdapter extends TypeAdapter<ListPoi>{
final GsonBuilder gBuilder = new GsonBuilder().registerTypeAdapter(PoiType.class, new PoiTypeAdapter());
final Gson embedded = gBuilder.excludeFieldsWithoutExposeAnnotation().create();
@Override
public void write(JsonWriter writer, ListPoi listPoi) throws IOException {
// embedded.toJson(embedded.toJsonTree(listPoi.getListPoi()), writer);
writer.beginArray();
if(listPoi != null) {
for(Poi poi: listPoi.getListPoi()){
writer.beginObject();
writer.name("name").value(poi.getName());
writer.name("type").value(poi.getType().getType());
writer.endObject();
}
}
writer.endArray();
}
@Override
public ListPoi read(JsonReader reader) throws IOException {
return null;
}
}
| UTF-8 | Java | 1,337 | java | ListPoiAdapter.java | Java | [
{
"context": "er;\nimport java.io.IOException;\n\n/**\n *\n * @author Armani <anderson.armani@actia.com.br>\n */\npublic class L",
"end": 367,
"score": 0.9998459815979004,
"start": 361,
"tag": "NAME",
"value": "Armani"
},
{
"context": "t java.io.IOException;\n\n/**\n *\n * @author Armani <anderson.armani@actia.com.br>\n */\npublic class ListPoiAdapter extends TypeAdap",
"end": 397,
"score": 0.999935507774353,
"start": 369,
"tag": "EMAIL",
"value": "anderson.armani@actia.com.br"
}
]
| null | []
| package br.com.actia.gson;
import br.com.actia.model.Poi;
import br.com.actia.model.ListPoi;
import br.com.actia.model.PoiType;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
/**
*
* @author Armani <<EMAIL>>
*/
public class ListPoiAdapter extends TypeAdapter<ListPoi>{
final GsonBuilder gBuilder = new GsonBuilder().registerTypeAdapter(PoiType.class, new PoiTypeAdapter());
final Gson embedded = gBuilder.excludeFieldsWithoutExposeAnnotation().create();
@Override
public void write(JsonWriter writer, ListPoi listPoi) throws IOException {
// embedded.toJson(embedded.toJsonTree(listPoi.getListPoi()), writer);
writer.beginArray();
if(listPoi != null) {
for(Poi poi: listPoi.getListPoi()){
writer.beginObject();
writer.name("name").value(poi.getName());
writer.name("type").value(poi.getType().getType());
writer.endObject();
}
}
writer.endArray();
}
@Override
public ListPoi read(JsonReader reader) throws IOException {
return null;
}
}
| 1,316 | 0.65445 | 0.65445 | 44 | 29.386364 | 26.015045 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.522727 | false | false | 1 |
79bc9d3b138c6264b1a9e502bdad91535fdd15a5 | 1,872,605,795,377 | 210e772cc30bcf112413726d3c2b4cb72a373fe8 | /src/main/java/reciter/database/dynamodb/repository/ScienceMetrixDepartmentCategoryRepository.java | c8cbc53a79a2cecf3c3dc6e4c23bd009e29563df | [
"Apache-2.0"
]
| permissive | wcmc-its/ReCiter | https://github.com/wcmc-its/ReCiter | 4a73593c97b0002459ca01615a3f2d43753f731a | 4b16b4d18f2dde909ae85e92eeb6bff730cdb2c9 | refs/heads/master | 2023-05-05T10:50:13.119000 | 2023-03-15T20:03:36 | 2023-03-15T20:03:36 | 33,040,796 | 40 | 40 | Apache-2.0 | false | 2023-04-19T22:39:21 | 2015-03-28T16:30:11 | 2023-03-27T23:40:54 | 2023-04-19T22:39:19 | 242,269 | 39 | 23 | 19 | Java | false | false | package reciter.database.dynamodb.repository;
import java.util.List;
import org.socialsignin.spring.data.dynamodb.repository.EnableScan;
import org.springframework.data.repository.CrudRepository;
import reciter.database.dynamodb.model.ScienceMetrixDepartmentCategory;
@EnableScan
public interface ScienceMetrixDepartmentCategoryRepository extends CrudRepository<ScienceMetrixDepartmentCategory, Long> {
List<ScienceMetrixDepartmentCategory> findByScienceMetrixJournalSubfieldId(Long subfieldId);
}
| UTF-8 | Java | 506 | java | ScienceMetrixDepartmentCategoryRepository.java | Java | []
| null | []
| package reciter.database.dynamodb.repository;
import java.util.List;
import org.socialsignin.spring.data.dynamodb.repository.EnableScan;
import org.springframework.data.repository.CrudRepository;
import reciter.database.dynamodb.model.ScienceMetrixDepartmentCategory;
@EnableScan
public interface ScienceMetrixDepartmentCategoryRepository extends CrudRepository<ScienceMetrixDepartmentCategory, Long> {
List<ScienceMetrixDepartmentCategory> findByScienceMetrixJournalSubfieldId(Long subfieldId);
}
| 506 | 0.871542 | 0.871542 | 15 | 32.733334 | 39.146675 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 1 |
923e8749f9a18eec29eb6fa30363013e0919993e | 36,919,538,902,172 | a361c593eb69ab6108bfd79a2d63c09bf58940e7 | /MedRepActivitiesService/src/main/java/com/leosal/medrep/rest/ActivitiesRestController.java | f4d4726162134cba8e95bae54ef400916980adc0 | []
| no_license | Leonidsalaur/medical-representatives | https://github.com/Leonidsalaur/medical-representatives | 5ba74e9c20649a715535f514fc1d69d653f1fa34 | 0e9e0c8525e686b12fe19c1ef3125c2def643d2d | refs/heads/master | 2022-02-18T08:56:28.136000 | 2020-05-17T09:39:48 | 2020-05-17T09:39:48 | 150,423,762 | 1 | 0 | null | false | 2022-02-09T22:29:40 | 2018-09-26T12:33:40 | 2020-05-17T09:45:38 | 2022-02-09T22:29:39 | 69,684 | 1 | 0 | 12 | Java | false | false | package com.leosal.medrep.rest;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
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.bind.annotation.RestController;
import com.leosal.dbutils.GenericCRUD;
import com.leosal.medrep.entity.Activity;
import com.leosal.medrep.services.ActivitiesService;
@RestController
public class ActivitiesRestController implements GenericCRUD<Activity>{
@Autowired
private ActivitiesService activitiesService;
@RequestMapping("/ping")
public String ping() {
return "Activities ping succeed!";
}
@Override
@RequestMapping("/find")
@PreAuthorize("hasAuthority('ROLE_ADMIN') or hasAuthority('ROLE_OPERATOR') or hasAuthority('ROLE_USER')")
public @ResponseBody Activity findById(@RequestParam Long id) {
return activitiesService.findById(id);
}
@Override
@RequestMapping("/findall")
@PreAuthorize("hasAuthority('ROLE_ADMIN') or hasAuthority('ROLE_OPERATOR') or hasAuthority('ROLE_USER')")
public @ResponseBody List<Activity> findAll() {
return activitiesService.findAll();
}
@Override
@RequestMapping("/save")
@PreAuthorize("hasAuthority('ROLE_ADMIN') or hasAuthority('ROLE_OPERATOR') or hasAuthority('ROLE_USER')")
public @ResponseBody Activity saveOrUpdate(@RequestBody Activity entity) {
return activitiesService.saveOrUpdate(entity);
}
@Override
@RequestMapping("/remove")
@PreAuthorize("hasAuthority('ROLE_ADMIN') or hasAuthority('ROLE_OPERATOR') or hasAuthority('ROLE_USER')")
public void remove(@RequestBody Activity entity) {
activitiesService.remove(entity);
}
}
| UTF-8 | Java | 1,876 | java | ActivitiesRestController.java | Java | []
| null | []
| package com.leosal.medrep.rest;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
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.bind.annotation.RestController;
import com.leosal.dbutils.GenericCRUD;
import com.leosal.medrep.entity.Activity;
import com.leosal.medrep.services.ActivitiesService;
@RestController
public class ActivitiesRestController implements GenericCRUD<Activity>{
@Autowired
private ActivitiesService activitiesService;
@RequestMapping("/ping")
public String ping() {
return "Activities ping succeed!";
}
@Override
@RequestMapping("/find")
@PreAuthorize("hasAuthority('ROLE_ADMIN') or hasAuthority('ROLE_OPERATOR') or hasAuthority('ROLE_USER')")
public @ResponseBody Activity findById(@RequestParam Long id) {
return activitiesService.findById(id);
}
@Override
@RequestMapping("/findall")
@PreAuthorize("hasAuthority('ROLE_ADMIN') or hasAuthority('ROLE_OPERATOR') or hasAuthority('ROLE_USER')")
public @ResponseBody List<Activity> findAll() {
return activitiesService.findAll();
}
@Override
@RequestMapping("/save")
@PreAuthorize("hasAuthority('ROLE_ADMIN') or hasAuthority('ROLE_OPERATOR') or hasAuthority('ROLE_USER')")
public @ResponseBody Activity saveOrUpdate(@RequestBody Activity entity) {
return activitiesService.saveOrUpdate(entity);
}
@Override
@RequestMapping("/remove")
@PreAuthorize("hasAuthority('ROLE_ADMIN') or hasAuthority('ROLE_OPERATOR') or hasAuthority('ROLE_USER')")
public void remove(@RequestBody Activity entity) {
activitiesService.remove(entity);
}
}
| 1,876 | 0.792111 | 0.792111 | 54 | 33.740742 | 31.053827 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 1 |
99b4bf74e7875487c327a10798487a129a69fd01 | 20,289,425,509,053 | f0c9f2c1e648d44db712324301b555e0d230dd50 | /src/test/java/web/ProductResourceTest.java | 92572868a6bd515128b6f7cff17af6c203db0b0c | []
| no_license | flaremew/21_CDIOFinal | https://github.com/flaremew/21_CDIOFinal | 419d04c10ed6d1038f6a5f00b3a6e8603aefe44f | aeead230bd5a26541d80175efa2e82fd1c3bf681 | refs/heads/master | 2020-08-07T01:29:16.309000 | 2019-06-25T18:02:56 | 2019-06-25T18:02:56 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package web;
import dto.Product;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Test;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ProductResourceTest extends JerseyTest {
@Override
protected Application configure() {
return new ResourceConfig(ProductResource.class);
}
// @Test
public void get() {
Response response = target("products/1").request().get(Response.class);
Product content = response.readEntity(Product.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE));
assertEquals(1, content.getProductId());
assertEquals("Kebabeeee", content.getProductName());
}
// @Test
public void getAll() {
Response response = target("products").request().get(Response.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE));
}
// @Test
public void create() {
}
// @Test
public void update() {
}
// @Test
public void delete() {
}
} | UTF-8 | Java | 1,462 | java | ProductResourceTest.java | Java | []
| null | []
| package web;
import dto.Product;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Test;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ProductResourceTest extends JerseyTest {
@Override
protected Application configure() {
return new ResourceConfig(ProductResource.class);
}
// @Test
public void get() {
Response response = target("products/1").request().get(Response.class);
Product content = response.readEntity(Product.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE));
assertEquals(1, content.getProductId());
assertEquals("Kebabeeee", content.getProductName());
}
// @Test
public void getAll() {
Response response = target("products").request().get(Response.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE));
}
// @Test
public void create() {
}
// @Test
public void update() {
}
// @Test
public void delete() {
}
} | 1,462 | 0.697674 | 0.696306 | 52 | 27.134615 | 28.455788 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 1 |
f13424be6727fc55f50e73786670b97ba49774e0 | 31,628,139,223,981 | 32d24d8fe542fccd24e5403ef3c88437df396572 | /src/io/github/manoj/methodcalling/Student.java | 243d0880a96f3d58c4ee2be60064f674e7b1cb53 | []
| no_license | manoj3018/test01 | https://github.com/manoj3018/test01 | 4875236af436fe9222d352e9f3e46a369bab5faa | 203d419d74d2ef750cd30be106bd478cce181ad5 | refs/heads/main | 2023-07-15T02:49:16.751000 | 2021-08-25T14:07:11 | 2021-08-25T14:07:11 | 399,700,806 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.github.manoj.methodcalling;
public class Student {
String name;
int age;
String address;
public Student(String name, int age, String address) {
super();
this.name = name;
this.age = age;
this.address = address;
}
public String getName() { // We have the flexibility to change the modifier
return name;
}
// public String getName() {
//
//
//
// int i = 1;
// String returnVar = null;
// if(i == 1) {
// returnVar = "test";
// } else {
// returnVar = name;
// }
// return returnVar;
// }
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
| UTF-8 | Java | 840 | java | Student.java | Java | [
{
"context": "package io.github.manoj.methodcalling;\n\npublic class Student {\n\t\n\tString ",
"end": 23,
"score": 0.9644935131072998,
"start": 18,
"tag": "USERNAME",
"value": "manoj"
}
]
| null | []
| package io.github.manoj.methodcalling;
public class Student {
String name;
int age;
String address;
public Student(String name, int age, String address) {
super();
this.name = name;
this.age = age;
this.address = address;
}
public String getName() { // We have the flexibility to change the modifier
return name;
}
// public String getName() {
//
//
//
// int i = 1;
// String returnVar = null;
// if(i == 1) {
// returnVar = "test";
// } else {
// returnVar = name;
// }
// return returnVar;
// }
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
| 840 | 0.604762 | 0.602381 | 64 | 12.125 | 14.938938 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.46875 | false | false | 1 |
ad6d087506177e6a9a398f3070120cbb6561dada | 26,139,171,018,766 | 4db048132ade6f26a079f47900a4f655faf6ef04 | /JiraPlugins/atlassian-jira-5.1.1-source/jira-importers-plugin/src/main/java/com/atlassian/jira/plugins/importer/imports/csv/mappers/ExternalMapper.java | 759ac4098e0ee38e3e1cf1041ea50fe78efc4f28 | []
| no_license | JCVI-VIRIFX/SampleTracking | https://github.com/JCVI-VIRIFX/SampleTracking | 045f3a690161cd6735dda6cf53964a89910c2d32 | 8f68cf385a083dcef055605dc040a224576a16fe | refs/heads/master | 2018-01-07T23:30:42.211000 | 2015-12-11T04:23:38 | 2015-12-11T04:23:38 | 47,804,829 | 1 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (c) 2012. Atlassian
* All rights reserved
*/
package com.atlassian.jira.plugins.importer.imports.csv.mappers;
import com.atlassian.jira.plugins.importer.imports.importer.ImportLogger;
import com.google.common.collect.Multimap;
public interface ExternalMapper<T> {
Iterable<T> buildFromMultiMap(Multimap<String, String> bean, ImportLogger log);
}
| UTF-8 | Java | 368 | java | ExternalMapper.java | Java | []
| null | []
| /*
* Copyright (c) 2012. Atlassian
* All rights reserved
*/
package com.atlassian.jira.plugins.importer.imports.csv.mappers;
import com.atlassian.jira.plugins.importer.imports.importer.ImportLogger;
import com.google.common.collect.Multimap;
public interface ExternalMapper<T> {
Iterable<T> buildFromMultiMap(Multimap<String, String> bean, ImportLogger log);
}
| 368 | 0.788043 | 0.777174 | 13 | 27.307692 | 28.70643 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.538462 | false | false | 1 |
35a4863a4a2aa63e9e67fab46f1514d5a1c4f0e6 | 26,139,171,016,576 | ad7902995cee0e874938464676854cf2cb7b04c5 | /Chapter01/DynamoDBLocalSamples/src/com/packtpub/mastering/dynamodb/AmazonDynamoDBSample.java | 9543009b7121b313d6539774cc9491568cfed405 | [
"MIT"
]
| permissive | PacktPublishing/Mastering-DynamoDB | https://github.com/PacktPublishing/Mastering-DynamoDB | 2ac6f798793f5b0d445121b3a0a4a040222013a5 | 3e92ff6b24da21e3da5626e4b6f2cbc132473af8 | refs/heads/master | 2023-02-07T05:26:03.482000 | 2023-01-30T10:03:06 | 2023-01-30T10:03:06 | 186,392,494 | 1 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.packtpub.mastering.dynamodb;
import java.util.HashMap;
import java.util.Map;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
import com.amazonaws.services.dynamodbv2.model.AttributeDefinition;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
import com.amazonaws.services.dynamodbv2.model.DescribeTableRequest;
import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
import com.amazonaws.services.dynamodbv2.model.KeyType;
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
import com.amazonaws.services.dynamodbv2.model.PutItemRequest;
import com.amazonaws.services.dynamodbv2.model.PutItemResult;
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType;
import com.amazonaws.services.dynamodbv2.model.ScanRequest;
import com.amazonaws.services.dynamodbv2.model.ScanResult;
import com.amazonaws.services.dynamodbv2.model.TableDescription;
import com.amazonaws.services.dynamodbv2.util.Tables;
/**
* This is a sample Class which demonstrates how to use DynamoDB Local
*
* @author Tanmay_Deshpande
*
*/
public class AmazonDynamoDBSample {
static AmazonDynamoDBClient dynamoDBClient;
private static void init() throws Exception {
// Instantiate AWS Client with proper credentials
dynamoDBClient = new AmazonDynamoDBClient(
new ClasspathPropertiesFileCredentialsProvider());
Region usWest2 = Region.getRegion(Regions.US_WEST_2);
dynamoDBClient.setRegion(usWest2);
// Set DynamoDB Local Endpoint
dynamoDBClient.setEndpoint("http://localhost:8000");
}
public static void main(String[] args) throws Exception {
init();
try {
String tableName = "student_table";
// Create a table with a primary hash key named 'name'
CreateTableRequest createTableRequest = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(
new KeySchemaElement().withAttributeName("name")
.withKeyType(KeyType.HASH))
.withAttributeDefinitions(
new AttributeDefinition().withAttributeName("name")
.withAttributeType(ScalarAttributeType.S))
.withProvisionedThroughput(
new ProvisionedThroughput().withReadCapacityUnits(
1L).withWriteCapacityUnits(1L));
TableDescription createdTableDescription = dynamoDBClient
.createTable(createTableRequest).getTableDescription();
System.out.println("Created Table: " + createdTableDescription);
// Wait for it to become active
System.out.println("Waiting for " + tableName
+ " to become ACTIVE...");
Tables.waitForTableToBecomeActive(dynamoDBClient, tableName);
// Describe our new table
DescribeTableRequest describeTableRequest = new DescribeTableRequest()
.withTableName(tableName);
TableDescription tableDescription = dynamoDBClient.describeTable(
describeTableRequest).getTable();
System.out.println("Table Description: " + tableDescription);
// Add an item
Map<String, AttributeValue> item = newItem("James Bond", 86, "XI");
PutItemRequest putItemRequest = new PutItemRequest(tableName, item);
PutItemResult putItemResult = dynamoDBClient
.putItem(putItemRequest);
System.out.println("Result: " + putItemResult);
// Scan items for all values
ScanRequest scanRequest = new ScanRequest(tableName);
ScanResult scanResult = dynamoDBClient.scan(scanRequest);
System.out.println("Result: " + scanResult);
} catch (AmazonServiceException ase) {
System.out.println("Error Message:" + ase.getMessage());
} catch (AmazonClientException ace) {
System.out.println("Error Message: " + ace.getMessage());
}
}
private static Map<String, AttributeValue> newItem(String name, int marks,
String rating) {
Map<String, AttributeValue> item = new HashMap<String, AttributeValue>();
item.put("name", new AttributeValue(name));
item.put("marks", new AttributeValue().withN(Integer.toString(marks)));
item.put("class", new AttributeValue(rating));
return item;
}
} | UTF-8 | Java | 4,269 | java | AmazonDynamoDBSample.java | Java | [
{
"context": "onstrates how to use DynamoDB Local\n * \n * @author Tanmay_Deshpande\n * \n */\npublic class AmazonDynamoDBSample {\n\n\tsta",
"end": 1384,
"score": 0.9998311400413513,
"start": 1368,
"tag": "NAME",
"value": "Tanmay_Deshpande"
},
{
"context": "em\n\t\t\tMap<String, AttributeValue> item = newItem(\"James Bond\", 86, \"XI\");\n\t\t\tPutItemRequest putItemRequest = n",
"end": 3281,
"score": 0.993107795715332,
"start": 3271,
"tag": "NAME",
"value": "James Bond"
}
]
| null | []
| package com.packtpub.mastering.dynamodb;
import java.util.HashMap;
import java.util.Map;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
import com.amazonaws.services.dynamodbv2.model.AttributeDefinition;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
import com.amazonaws.services.dynamodbv2.model.DescribeTableRequest;
import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
import com.amazonaws.services.dynamodbv2.model.KeyType;
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
import com.amazonaws.services.dynamodbv2.model.PutItemRequest;
import com.amazonaws.services.dynamodbv2.model.PutItemResult;
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType;
import com.amazonaws.services.dynamodbv2.model.ScanRequest;
import com.amazonaws.services.dynamodbv2.model.ScanResult;
import com.amazonaws.services.dynamodbv2.model.TableDescription;
import com.amazonaws.services.dynamodbv2.util.Tables;
/**
* This is a sample Class which demonstrates how to use DynamoDB Local
*
* @author Tanmay_Deshpande
*
*/
public class AmazonDynamoDBSample {
static AmazonDynamoDBClient dynamoDBClient;
private static void init() throws Exception {
// Instantiate AWS Client with proper credentials
dynamoDBClient = new AmazonDynamoDBClient(
new ClasspathPropertiesFileCredentialsProvider());
Region usWest2 = Region.getRegion(Regions.US_WEST_2);
dynamoDBClient.setRegion(usWest2);
// Set DynamoDB Local Endpoint
dynamoDBClient.setEndpoint("http://localhost:8000");
}
public static void main(String[] args) throws Exception {
init();
try {
String tableName = "student_table";
// Create a table with a primary hash key named 'name'
CreateTableRequest createTableRequest = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(
new KeySchemaElement().withAttributeName("name")
.withKeyType(KeyType.HASH))
.withAttributeDefinitions(
new AttributeDefinition().withAttributeName("name")
.withAttributeType(ScalarAttributeType.S))
.withProvisionedThroughput(
new ProvisionedThroughput().withReadCapacityUnits(
1L).withWriteCapacityUnits(1L));
TableDescription createdTableDescription = dynamoDBClient
.createTable(createTableRequest).getTableDescription();
System.out.println("Created Table: " + createdTableDescription);
// Wait for it to become active
System.out.println("Waiting for " + tableName
+ " to become ACTIVE...");
Tables.waitForTableToBecomeActive(dynamoDBClient, tableName);
// Describe our new table
DescribeTableRequest describeTableRequest = new DescribeTableRequest()
.withTableName(tableName);
TableDescription tableDescription = dynamoDBClient.describeTable(
describeTableRequest).getTable();
System.out.println("Table Description: " + tableDescription);
// Add an item
Map<String, AttributeValue> item = newItem("<NAME>", 86, "XI");
PutItemRequest putItemRequest = new PutItemRequest(tableName, item);
PutItemResult putItemResult = dynamoDBClient
.putItem(putItemRequest);
System.out.println("Result: " + putItemResult);
// Scan items for all values
ScanRequest scanRequest = new ScanRequest(tableName);
ScanResult scanResult = dynamoDBClient.scan(scanRequest);
System.out.println("Result: " + scanResult);
} catch (AmazonServiceException ase) {
System.out.println("Error Message:" + ase.getMessage());
} catch (AmazonClientException ace) {
System.out.println("Error Message: " + ace.getMessage());
}
}
private static Map<String, AttributeValue> newItem(String name, int marks,
String rating) {
Map<String, AttributeValue> item = new HashMap<String, AttributeValue>();
item.put("name", new AttributeValue(name));
item.put("marks", new AttributeValue().withN(Integer.toString(marks)));
item.put("class", new AttributeValue(rating));
return item;
}
} | 4,265 | 0.774655 | 0.768564 | 109 | 38.174313 | 24.716314 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.504587 | false | false | 1 |
f16bb4b8eea24aef58ff8085acbe022afad66d27 | 23,596,550,385,297 | 05e9da57a775ab629355d08c98ef8a99653edb2d | /inkuire-integration-tests/src/test/resources/projects/basic-multiplatform/src/jvmMain/java/tests/SomeJavaClass.java | 7bc354373ee0b04bba152e4651fd86b707e16d86 | []
| no_license | pikinier20/Inkuire | https://github.com/pikinier20/Inkuire | caf25d7d340985db5f90165047735f08060455a9 | ba24e961fa1cfb72d467a28e6a0b73943e3f7354 | refs/heads/master | 2022-12-15T04:13:17.516000 | 2020-09-02T10:40:33 | 2020-09-02T10:40:33 | 293,044,758 | 0 | 0 | null | true | 2020-09-05T09:33:10 | 2020-09-05T09:33:09 | 2020-09-02T10:40:37 | 2020-09-04T14:16:24 | 294 | 0 | 0 | 0 | null | false | false | package tests
interface JavaGenericInheritingClass<T extends Number, R extends CharSequence> extends Comparable<List<T>>, Collection<R> {
} | UTF-8 | Java | 142 | java | SomeJavaClass.java | Java | []
| null | []
| package tests
interface JavaGenericInheritingClass<T extends Number, R extends CharSequence> extends Comparable<List<T>>, Collection<R> {
} | 142 | 0.802817 | 0.802817 | 6 | 22.833334 | 45.038563 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 1 |
595908cb5021a8a9499f3621cf97bbc41d555f97 | 37,976,100,853,455 | 5e6d3d24db090891ca0209b1629334f768460f3c | /app/controllers/Application.java | 428db387f510a9090159db2039aa223461392a71 | []
| no_license | caiomarinhodev/out | https://github.com/caiomarinhodev/out | 0200b62605f365944fc44099a9d44aff783cb154 | d614c0b59bc9b00f034960e95d60be574cbd0456 | refs/heads/master | 2016-08-06T07:57:24.566000 | 2015-03-02T15:02:22 | 2015-03-02T15:02:22 | 31,545,592 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package controllers;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import models.*;
import play.data.DynamicForm;
import play.data.Form;
import play.db.jpa.Transactional;
import play.mvc.*;
import views.html.*;
public class Application extends Controller {
private static GenericDAO dao = new GenericDAO();
private static Sistema sistema = null;
@Transactional
public static Result login(){
return ok(login.render("Log in"));
}
@Transactional
public static Result auth() {
List<Admin> admins = dao.findAllByClassName(Admin.class.getName());
List<Creator> creators = dao.findAllByClassName(Creator.class.getName());
List<Atleta> atletas = dao.findAllByClassName(Atleta.class.getName());
List<Evento> eventos = dao.findAllByClassName(Evento.class.getName());
Admin ad=null;
Creator cr=null;
Atleta at=null;
DynamicForm requestData = Form.form().bindFromRequest();
String l = requestData.get("login");
String s = requestData.get("senha");
for(Creator c: creators){
if(c.getLogin().equals(l) && c.getSenha().equals(s)){
cr = c;
}
}
for(Atleta a: atletas){
if(a.getLogin().equals(l) && a.getSenha().equals(s)){
at = a;
}
}
for(Admin admin: admins){
if(admin.getLogin().equals(l) && admin.getSenha().equals(s)){
ad = admin;
}
}
if(ad!=null){
sistema = new Sistema(creators,atletas,eventos);
return ok(dash.render("Nosso Tatame", sistema, ad));
}else if(cr!=null){
sistema = new Sistema(creators,atletas,eventos);
return ok(dash.render("Nosso Tatame", sistema, cr));
}else if(at!=null){
sistema = new Sistema(creators,atletas,eventos);
return ok(dash.render("Nosso Tatame", sistema, at));
}else{
return ok(login.render("Login"));
}
}
@Transactional
public static Result register(){
return ok(register.render("Register"));
}
@Transactional
public static Result cadastraUsuario(){
DynamicForm requestData = Form.form().bindFromRequest();
String nome, login, senha, email;
int tipoLogin = getTipoLogin(requestData.get("tipologin"));
nome = requestData.get("nome");
login = requestData.get("login");
senha = requestData.get("senha");
email = requestData.get("email");
createUsuario(tipoLogin,nome,login,senha,email);
return ok(views.html.login.render("Log in"));
}
@Transactional
private static void createUsuario(int t, String nome, String login,
String senha, String email){
if(t==1){
Creator c = new Creator(nome,login,senha,null,null,null,null,null,t,email,null);
dao.persist(c);
}else{
Atleta a = new Atleta(nome,email,null,null,0,0,0,0,0,login,senha,t,false);
dao.persist(a);
}
}
private static int getTipoLogin(String t){
if(t.equals("Atleta")){
return 2;
}else{
return 1;
}
}
@Transactional
public static Creator pesquisaUsuario(String l){
List<Creator> atletas = dao.findAllByClassName(Creator.class.getName());
if(!atletas.isEmpty()){
for (Creator u: atletas){
if(u.getLogin().equals(l)){
return u;
}
}
}
return null;
}
}
| UTF-8 | Java | 3,680 | java | Application.java | Java | [
{
"context": "ta.get(\"login\");\n senha = requestData.get(\"senha\");\n email = requestData.get(\"email\");\n ",
"end": 2546,
"score": 0.7811175584793091,
"start": 2543,
"tag": "PASSWORD",
"value": "sen"
}
]
| null | []
| package controllers;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import models.*;
import play.data.DynamicForm;
import play.data.Form;
import play.db.jpa.Transactional;
import play.mvc.*;
import views.html.*;
public class Application extends Controller {
private static GenericDAO dao = new GenericDAO();
private static Sistema sistema = null;
@Transactional
public static Result login(){
return ok(login.render("Log in"));
}
@Transactional
public static Result auth() {
List<Admin> admins = dao.findAllByClassName(Admin.class.getName());
List<Creator> creators = dao.findAllByClassName(Creator.class.getName());
List<Atleta> atletas = dao.findAllByClassName(Atleta.class.getName());
List<Evento> eventos = dao.findAllByClassName(Evento.class.getName());
Admin ad=null;
Creator cr=null;
Atleta at=null;
DynamicForm requestData = Form.form().bindFromRequest();
String l = requestData.get("login");
String s = requestData.get("senha");
for(Creator c: creators){
if(c.getLogin().equals(l) && c.getSenha().equals(s)){
cr = c;
}
}
for(Atleta a: atletas){
if(a.getLogin().equals(l) && a.getSenha().equals(s)){
at = a;
}
}
for(Admin admin: admins){
if(admin.getLogin().equals(l) && admin.getSenha().equals(s)){
ad = admin;
}
}
if(ad!=null){
sistema = new Sistema(creators,atletas,eventos);
return ok(dash.render("Nosso Tatame", sistema, ad));
}else if(cr!=null){
sistema = new Sistema(creators,atletas,eventos);
return ok(dash.render("Nosso Tatame", sistema, cr));
}else if(at!=null){
sistema = new Sistema(creators,atletas,eventos);
return ok(dash.render("Nosso Tatame", sistema, at));
}else{
return ok(login.render("Login"));
}
}
@Transactional
public static Result register(){
return ok(register.render("Register"));
}
@Transactional
public static Result cadastraUsuario(){
DynamicForm requestData = Form.form().bindFromRequest();
String nome, login, senha, email;
int tipoLogin = getTipoLogin(requestData.get("tipologin"));
nome = requestData.get("nome");
login = requestData.get("login");
senha = requestData.get("senha");
email = requestData.get("email");
createUsuario(tipoLogin,nome,login,senha,email);
return ok(views.html.login.render("Log in"));
}
@Transactional
private static void createUsuario(int t, String nome, String login,
String senha, String email){
if(t==1){
Creator c = new Creator(nome,login,senha,null,null,null,null,null,t,email,null);
dao.persist(c);
}else{
Atleta a = new Atleta(nome,email,null,null,0,0,0,0,0,login,senha,t,false);
dao.persist(a);
}
}
private static int getTipoLogin(String t){
if(t.equals("Atleta")){
return 2;
}else{
return 1;
}
}
@Transactional
public static Creator pesquisaUsuario(String l){
List<Creator> atletas = dao.findAllByClassName(Creator.class.getName());
if(!atletas.isEmpty()){
for (Creator u: atletas){
if(u.getLogin().equals(l)){
return u;
}
}
}
return null;
}
}
| 3,680 | 0.57337 | 0.571196 | 121 | 29.413223 | 23.647434 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.85124 | false | false | 1 |
ed47dfd8f3d1ce657d3fb25e33865e0475e775fe | 33,354,716,081,841 | e46ed1735930f08e369a90260a60af091dbdaf66 | /src/main/java/io/github/bloepiloepi/pvp/projectile/ProjectileListener.java | b0032d55e71ba192d57e296c08043cfc879b608a | [
"Apache-2.0"
]
| permissive | NoChars/MinestomPvP | https://github.com/NoChars/MinestomPvP | f2e26e62f8840a8f2a24babfba6cffcbd2a7de68 | 4dd7a3f3292817b9dd9b641236a1ad0da4bf9fae | refs/heads/master | 2023-08-15T21:02:07.088000 | 2021-10-09T18:37:57 | 2021-10-09T18:37:57 | 379,217,383 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.github.bloepiloepi.pvp.projectile;
import io.github.bloepiloepi.pvp.enchantment.EnchantmentUtils;
import io.github.bloepiloepi.pvp.entities.EntityUtils;
import io.github.bloepiloepi.pvp.entities.Tracker;
import io.github.bloepiloepi.pvp.utils.SoundManager;
import it.unimi.dsi.fastutil.Pair;
import net.kyori.adventure.sound.Sound;
import net.minestom.server.MinecraftServer;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.coordinate.Vec;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Player;
import net.minestom.server.event.EventDispatcher;
import net.minestom.server.event.EventFilter;
import net.minestom.server.event.EventListener;
import net.minestom.server.event.EventNode;
import net.minestom.server.event.entity.EntityShootEvent;
import net.minestom.server.event.item.ItemUpdateStateEvent;
import net.minestom.server.event.player.PlayerItemAnimationEvent;
import net.minestom.server.event.player.PlayerTickEvent;
import net.minestom.server.event.player.PlayerUseItemEvent;
import net.minestom.server.event.trait.PlayerEvent;
import net.minestom.server.item.Enchantment;
import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material;
import net.minestom.server.item.metadata.CrossbowMeta;
import net.minestom.server.sound.SoundEvent;
import net.minestom.server.tag.Tag;
import net.minestom.server.utils.MathUtils;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
public class ProjectileListener {
private static final Tag<Byte> START_SOUND_PLAYED = Tag.Byte("StartSoundPlayed");
private static final Tag<Byte> MID_LOAD_SOUND_PLAYED = Tag.Byte("MidLoadSoundPlayed");
// Please, don't look at the random hardcoded numbers in this class, even I am confused
public static EventNode<PlayerEvent> events(boolean legacy) {
EventNode<PlayerEvent> node = EventNode.type("projectile-events", EventFilter.PLAYER);
node.addListener(EventListener.builder(PlayerUseItemEvent.class).handler(event -> {
ThreadLocalRandom random = ThreadLocalRandom.current();
Player player = event.getPlayer();
if (FishingBobber.fishingBobbers.containsKey(player.getUuid())) {
int durability = FishingBobber.fishingBobbers.get(player.getUuid()).retrieve();
//TODO damage fishing rod
SoundManager.sendToAround(player, SoundEvent.ENTITY_FISHING_BOBBER_RETRIEVE, Sound.Source.NEUTRAL,
1.0F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
} else {
SoundManager.sendToAround(player, SoundEvent.ENTITY_FISHING_BOBBER_THROW, Sound.Source.NEUTRAL,
0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
FishingBobber bobber = new FishingBobber(player, legacy);
FishingBobber.fishingBobbers.put(player.getUuid(), bobber);
EntityShootEvent shootEvent = new EntityShootEvent(player, bobber,
player.getPosition(), 0, 1.0);
EventDispatcher.call(shootEvent);
if (shootEvent.isCancelled()) {
bobber.remove();
return;
}
double spread = shootEvent.getSpread() * (legacy ? 0.0075 : 0.0045);
Pos playerPos = player.getPosition();
float playerPitch = playerPos.pitch();
float playerYaw = playerPos.yaw();
float zDir = (float) Math.cos(Math.toRadians(-playerYaw) - Math.PI);
float xDir = (float) Math.sin(Math.toRadians(-playerYaw) - Math.PI);
double x = playerPos.x() - (double) xDir * 0.3D;
double y = playerPos.y() + player.getEyeHeight();
double z = playerPos.z() - (double) zDir * 0.3D;
bobber.setInstance(Objects.requireNonNull(player.getInstance()), new Pos(x, y, z));
Vec velocity;
if (!legacy) {
velocity = new Vec(
-xDir,
MathUtils.clamp(-(
(float) Math.sin(Math.toRadians(-playerPitch)) /
(float) -Math.cos(Math.toRadians(-playerPitch))
), -5.0F, 5.0F),
-zDir
);
double length = velocity.length();
velocity = velocity.mul(
0.6D / length + 0.5D + random.nextGaussian() * spread,
0.6D / length + 0.5D + random.nextGaussian() * spread,
0.6D / length + 0.5D + random.nextGaussian() * spread
);
} else {
double maxVelocity = 0.4F;
velocity = new Vec(
-Math.sin(playerYaw / 180.0F * (float) Math.PI)
* Math.cos(playerPitch / 180.0F * (float) Math.PI) * maxVelocity,
-Math.sin(playerPitch / 180.0F * (float) Math.PI) * maxVelocity,
Math.cos(playerYaw / 180.0F * (float) Math.PI)
* Math.cos(playerPitch / 180.0F * (float) Math.PI) * maxVelocity
);
double length = velocity.length();
velocity = velocity
.div(length)
.add(
random.nextGaussian() * spread,
random.nextGaussian() * spread,
random.nextGaussian() * spread
)
.mul(1.5);
}
bobber.setVelocity(velocity.mul(MinecraftServer.TICK_PER_SECOND * 0.75));
}
}).filter(event -> event.getItemStack().getMaterial() == Material.FISHING_ROD).build());
node.addListener(EventListener.builder(PlayerUseItemEvent.class).handler(event -> {
Player player = event.getPlayer();
ItemStack stack = event.getItemStack();
if (Tracker.hasCooldown(player, stack.getMaterial())) {
event.setCancelled(true);
return;
}
boolean snowball = stack.getMaterial() == Material.SNOWBALL;
boolean enderpearl = stack.getMaterial() == Material.ENDER_PEARL;
SoundEvent soundEvent;
EntityHittableProjectile projectile;
if (snowball) {
soundEvent = SoundEvent.ENTITY_SNOWBALL_THROW;
projectile = new Snowball(player);
} else if (enderpearl) {
soundEvent = SoundEvent.ENTITY_ENDER_PEARL_THROW;
projectile = new ThrownEnderpearl(player);
} else {
soundEvent = SoundEvent.ENTITY_EGG_THROW;
projectile = new ThrownEgg(player);
}
projectile.setItem(stack);
ThreadLocalRandom random = ThreadLocalRandom.current();
SoundManager.sendToAround(player, soundEvent,
snowball || enderpearl ? Sound.Source.NEUTRAL : Sound.Source.PLAYER,
0.5f, 0.4f / (random.nextFloat() * 0.4f + 0.8f));
if (enderpearl) {
Tracker.setCooldown(player, Material.ENDER_PEARL, 20);
}
Pos position = player.getPosition().add(0D, player.getEyeHeight(), 0D);
projectile.setInstance(Objects.requireNonNull(player.getInstance()), position);
Vec direction = position.direction();
position = position.add(direction).sub(0, 0.2, 0); //????????
projectile.shoot(position, 1.5, 1.0);
Vec playerVel = player.getVelocity();
projectile.setVelocity(projectile.getVelocity().add(playerVel.x(),
player.isOnGround() ? 0.0D : playerVel.y(), playerVel.z()));
if (!player.isCreative()) {
player.setItemInHand(event.getHand(), stack.withAmount(stack.getAmount() - 1));
}
}).filter(event -> event.getItemStack().getMaterial() == Material.SNOWBALL
|| event.getItemStack().getMaterial() == Material.EGG
|| event.getItemStack().getMaterial() == Material.ENDER_PEARL)
.build());
node.addListener(EventListener.builder(PlayerUseItemEvent.class).handler(event -> {
ItemStack stack = event.getItemStack();
if (crossbow(stack).isCharged()) {
// Make sure the animation event is not called, because this is not an animation
event.setCancelled(true);
stack = performCrossbowShooting(event.getPlayer(), event.getHand(), stack,
getCrossbowPower(stack), 1.0, legacy);
event.getPlayer().setItemInHand(event.getHand(), setCrossbowCharged(stack, false));
} else {
if (EntityUtils.getProjectile(event.getPlayer(),
Arrow.ARROW_OR_FIREWORK_PREDICATE, Arrow.ARROW_PREDICATE).first().isAir()) {
event.setCancelled(true);
} else {
ItemStack newStack = stack
.withTag(START_SOUND_PLAYED, (byte) 0)
.withTag(MID_LOAD_SOUND_PLAYED, (byte) 0);
event.getPlayer().setItemInHand(event.getHand(), newStack);
Tracker.itemUseHand.put(event.getPlayer().getUuid(), event.getHand());
}
}
}).filter(event -> event.getItemStack().getMaterial() == Material.CROSSBOW).build());
node.addListener(PlayerItemAnimationEvent.class, event -> {
if (event.getArmAnimationType() == PlayerItemAnimationEvent.ItemAnimationType.BOW) {
if (!event.getPlayer().isCreative()
&& EntityUtils.getProjectile(event.getPlayer(), Arrow.ARROW_PREDICATE).first().isAir()) {
event.setCancelled(true);
}
}
});
node.addListener(PlayerTickEvent.class, event -> {
Player player = event.getPlayer();
if (EntityUtils.isChargingCrossbow(player)) {
Player.Hand hand = EntityUtils.getActiveHand(player);
ItemStack stack = player.getItemInHand(hand);
int quickCharge = EnchantmentUtils.getLevel(Enchantment.QUICK_CHARGE, stack);
long useDuration = System.currentTimeMillis() - Tracker.itemUseStartTime.get(player.getUuid());
long useTicks = useDuration / MinecraftServer.TICK_MS;
double progress = (getCrossbowUseDuration(stack) - useTicks) / (double) getCrossbowChargeDuration(stack);
Byte startSoundPlayed = stack.getTag(START_SOUND_PLAYED);
Byte midLoadSoundPlayed = stack.getTag(MID_LOAD_SOUND_PLAYED);
if (startSoundPlayed == null) startSoundPlayed = (byte) 0;
if (midLoadSoundPlayed == null) midLoadSoundPlayed = (byte) 0;
if (progress >= 0.2 && startSoundPlayed == (byte) 0) {
SoundEvent startSound = getCrossbowStartSound(quickCharge);
SoundManager.sendToAround(player, startSound, Sound.Source.PLAYER, 0.5F, 1.0F);
stack = stack.withTag(START_SOUND_PLAYED, (byte) 1);
player.setItemInHand(hand, stack);
}
SoundEvent midLoadSound = quickCharge == 0 ? SoundEvent.ITEM_CROSSBOW_LOADING_MIDDLE : null;
if (progress >= 0.5F && midLoadSound != null && midLoadSoundPlayed == (byte) 0) {
SoundManager.sendToAround(player, midLoadSound, Sound.Source.PLAYER, 0.5F, 1.0F);
stack = stack.withTag(MID_LOAD_SOUND_PLAYED, (byte) 1);
player.setItemInHand(hand, stack);
}
}
});
node.addListener(EventListener.builder(ItemUpdateStateEvent.class).handler(event -> {
Player player = event.getPlayer();
ItemStack stack = event.getItemStack();
boolean infinite = player.isCreative() || EnchantmentUtils.getLevel(Enchantment.INFINITY, stack) > 0;
Pair<ItemStack, Integer> projectilePair = EntityUtils.getProjectile(player, Arrow.ARROW_PREDICATE);
ItemStack projectile = projectilePair.first();
int projectileSlot = projectilePair.second();
if (!infinite && projectile.isAir()) return;
if (projectile.isAir()) {
projectile = Arrow.DEFAULT_ARROW;
projectileSlot = -1;
}
long useDuration = System.currentTimeMillis() - Tracker.itemUseStartTime.get(player.getUuid());
double power = getBowPower(useDuration);
if (power < 0.1) return;
// Arrow creation
AbstractArrow arrow = createArrow(projectile, player, legacy);
if (power >= 1) {
arrow.setCritical(true);
}
int powerEnchantment = EnchantmentUtils.getLevel(Enchantment.POWER, stack);
if (powerEnchantment > 0) {
arrow.setBaseDamage(arrow.getBaseDamage() + (double) powerEnchantment * 0.5 + 0.5);
}
int punchEnchantment = EnchantmentUtils.getLevel(Enchantment.PUNCH, stack);
if (punchEnchantment > 0) {
arrow.setKnockback(punchEnchantment);
}
if (EnchantmentUtils.getLevel(Enchantment.FLAME, stack) > 0) {
EntityUtils.setOnFireForSeconds(arrow, 100);
}
//TODO damage bow item
boolean reallyInfinite = infinite && projectile.getMaterial() == Material.ARROW;
if (reallyInfinite || player.isCreative()
&& (projectile.getMaterial() == Material.SPECTRAL_ARROW
|| projectile.getMaterial() == Material.TIPPED_ARROW)) {
arrow.pickupMode = AbstractArrow.PickupMode.CREATIVE_ONLY;
}
// Arrow shooting
Pos position = player.getPosition().add(0D, player.getEyeHeight(), 0D);
arrow.setInstance(Objects.requireNonNull(player.getInstance()),
position.sub(0, 0.10000000149011612D, 0)); // Yeah wait what
Vec direction = position.direction();
position = position.add(direction).sub(0, 0.2, 0); //????????
arrow.shoot(position, power * 3, 1.0);
Vec playerVel = player.getVelocity();
arrow.setVelocity(arrow.getVelocity().add(playerVel.x(),
player.isOnGround() ? 0.0D : playerVel.y(), playerVel.z()));
ThreadLocalRandom random = ThreadLocalRandom.current();
SoundManager.sendToAround(player, SoundEvent.ENTITY_ARROW_SHOOT, Sound.Source.PLAYER,
1.0f, 1.0f / (random.nextFloat() * 0.4f + 1.2f) + (float) power * 0.5f);
if (!reallyInfinite && !player.isCreative() && projectileSlot >= 0) {
player.getInventory().setItemStack(projectileSlot,
projectile.withAmount(projectile.getAmount() - 1));
}
}).filter(event -> event.getItemStack().getMaterial() == Material.BOW).build());
node.addListener(EventListener.builder(ItemUpdateStateEvent.class).handler(event -> {
Player player = event.getPlayer();
ItemStack stack = event.getItemStack();
int quickCharge = EnchantmentUtils.getLevel(Enchantment.QUICK_CHARGE, stack);
if (quickCharge < 6) {
long useDuration = System.currentTimeMillis() - Tracker.itemUseStartTime.get(player.getUuid());
double power = getCrossbowPowerForTime(useDuration, stack);
if (!(power >= 1.0F) || crossbow(stack).isCharged())
return;
}
stack = loadCrossbowProjectiles(player, stack);
if (stack == null) return;
stack = setCrossbowCharged(stack, true);
ThreadLocalRandom random = ThreadLocalRandom.current();
SoundManager.sendToAround(player, SoundEvent.ITEM_CROSSBOW_LOADING_END, Sound.Source.PLAYER,
1.0F, 1.0F / (random.nextFloat() * 0.5F + 1.0F) + 0.2F);
player.setItemInHand(event.getHand(), stack);
}).filter(event -> event.getItemStack().getMaterial() == Material.CROSSBOW).build());
return node;
}
public static double getBowPower(long useDurationMillis) {
double seconds = useDurationMillis / 1000.0;
double power = (seconds * seconds + seconds * 2.0) / 3.0;
if (power > 1) {
power = 1;
}
return power;
}
public static AbstractArrow createArrow(ItemStack stack, @Nullable Entity shooter, boolean legacy) {
if (stack.getMaterial() == Material.SPECTRAL_ARROW) {
return new SpectralArrow(shooter);
} else {
Arrow arrow = new Arrow(shooter, legacy);
arrow.inheritEffects(stack);
return arrow;
}
}
public static double getCrossbowPower(ItemStack stack) {
return crossbowContainsProjectile(stack, Material.FIREWORK_ROCKET) ? 1.6 : 3.15;
}
public static double getCrossbowPowerForTime(long useDurationMillis, ItemStack stack) {
long ticks = useDurationMillis / MinecraftServer.TICK_MS;
double power = ticks / (double) getCrossbowChargeDuration(stack);
if (power > 1) {
power = 1;
}
return power;
}
public static ItemStack setCrossbowCharged(ItemStack stack, boolean charged) {
return stack.withMeta(meta -> ((CrossbowMeta.Builder) meta).charged(charged));
}
public static ItemStack setCrossbowProjectile(ItemStack stack, ItemStack projectile) {
return stack.withMeta(meta -> ((CrossbowMeta.Builder) meta).projectile(projectile));
}
public static ItemStack setCrossbowProjectiles(ItemStack stack, ItemStack projectile1,
ItemStack projectile2, ItemStack projectile3) {
return stack.withMeta(meta -> ((CrossbowMeta.Builder) meta)
.projectiles(projectile1, projectile2, projectile3));
}
public static boolean crossbowContainsProjectile(ItemStack stack, Material projectile) {
CrossbowMeta meta = crossbow(stack);
if (meta.getProjectile1().getMaterial() == projectile) return true;
if (meta.getProjectile2().getMaterial() == projectile) return true;
return meta.getProjectile3().getMaterial() == projectile;
}
public static int getCrossbowUseDuration(ItemStack stack) {
return getCrossbowChargeDuration(stack) + 3;
}
public static int getCrossbowChargeDuration(ItemStack stack) {
int quickCharge = EnchantmentUtils.getLevel(Enchantment.QUICK_CHARGE, stack);
return quickCharge == 0 ? 25 : 25 - 5 * quickCharge;
}
public static SoundEvent getCrossbowStartSound(int quickCharge) {
switch (quickCharge) {
case 1:
return SoundEvent.ITEM_CROSSBOW_QUICK_CHARGE_1;
case 2:
return SoundEvent.ITEM_CROSSBOW_QUICK_CHARGE_2;
case 3:
return SoundEvent.ITEM_CROSSBOW_QUICK_CHARGE_3;
default:
return SoundEvent.ITEM_CROSSBOW_LOADING_START;
}
}
public static ItemStack loadCrossbowProjectiles(Player player, ItemStack stack) {
boolean multiShot = EnchantmentUtils.getLevel(Enchantment.MULTISHOT, stack) > 0;
Pair<ItemStack, Integer> pair = EntityUtils.getProjectile(player,
Arrow.ARROW_OR_FIREWORK_PREDICATE, Arrow.ARROW_PREDICATE);
ItemStack projectile = pair.first();
int projectileSlot = pair.second();
if (projectile.isAir() && player.isCreative()) {
projectile = Arrow.DEFAULT_ARROW;
projectileSlot = -1;
}
if (multiShot) {
stack = setCrossbowProjectiles(stack, projectile, projectile, projectile);
} else {
stack = setCrossbowProjectile(stack, projectile);
}
if (!player.isCreative() && projectileSlot >= 0) {
player.getInventory().setItemStack(projectileSlot, projectile.withAmount(projectile.getAmount() - 1));
}
return stack;
}
public static CrossbowMeta crossbow(ItemStack stack) {
return (CrossbowMeta) stack.getMeta();
}
public static ItemStack performCrossbowShooting(Player player, Player.Hand hand, ItemStack stack,
double power, double spread, boolean legacy) {
CrossbowMeta meta = crossbow(stack);
ItemStack projectile = meta.getProjectile1();
if (!projectile.isAir()) {
shootCrossbowProjectile(player, hand, stack, projectile, 1.0F, power, spread, 0.0F, legacy);
}
if (meta.isTriple()) {
ThreadLocalRandom random = ThreadLocalRandom.current();
boolean firstHighPitch = random.nextBoolean();
float firstPitch = getRandomShotPitch(firstHighPitch, random);
float secondPitch = getRandomShotPitch(!firstHighPitch, random);
projectile = meta.getProjectile2();
if (!projectile.isAir()) {
shootCrossbowProjectile(player, hand, stack, projectile, firstPitch, power, spread, -10.0F, legacy);
}
projectile = meta.getProjectile3();
if (!projectile.isAir()) {
shootCrossbowProjectile(player, hand, stack, projectile, secondPitch, power, spread, 10.0F, legacy);
}
}
return setCrossbowProjectile(stack, ItemStack.AIR);
}
public static void shootCrossbowProjectile(Player player, Player.Hand hand, ItemStack crossbowStack,
ItemStack projectile, float soundPitch,
double power, double spread, float yaw, boolean legacy) {
boolean firework = projectile.getMaterial() == Material.FIREWORK_ROCKET;
if (firework) return; //TODO firework
AbstractArrow arrow = getCrossbowArrow(player, crossbowStack, projectile, legacy);
if (player.isCreative() || yaw != 0.0) {
arrow.pickupMode = AbstractArrow.PickupMode.CREATIVE_ONLY;
}
Pos position = player.getPosition().add(0D, player.getEyeHeight(), 0D);
arrow.setInstance(Objects.requireNonNull(player.getInstance()),
position.sub(0, 0.10000000149011612D, 0)); // Yeah wait what
position = position.withYaw(position.yaw() + yaw);
Vec direction = position.direction();
position = position.add(direction).sub(0, 0.2, 0); //????????
arrow.shoot(position, power, spread);
//TODO damage crossbow
SoundManager.sendToAround(player, SoundEvent.ITEM_CROSSBOW_SHOOT, Sound.Source.PLAYER, 1.0F, soundPitch);
}
public static AbstractArrow getCrossbowArrow(Player player, ItemStack crossbowStack, ItemStack projectile, boolean legacy) {
AbstractArrow arrow = createArrow(projectile, player, legacy);
arrow.setCritical(true); // Player shooter is always critical
arrow.setSound(SoundEvent.ITEM_CROSSBOW_HIT);
int piercing = EnchantmentUtils.getLevel(Enchantment.PIERCING, crossbowStack);
if (piercing > 0) {
arrow.setPiercingLevel((byte) piercing);
}
return arrow;
}
public static float getRandomShotPitch(boolean high, ThreadLocalRandom random) {
float base = high ? 0.63F : 0.43F;
return 1.0F / (random.nextFloat() * 0.5F + 1.8F) + base;
}
}
| UTF-8 | Java | 20,462 | java | ProjectileListener.java | Java | [
{
"context": "package io.github.bloepiloepi.pvp.projectile;\n\nimport io.github.bloepiloepi.pvp",
"end": 29,
"score": 0.9991447329521179,
"start": 18,
"tag": "USERNAME",
"value": "bloepiloepi"
},
{
"context": "hub.bloepiloepi.pvp.projectile;\n\nimport io.github.bloepiloepi.pvp.enchantment.EnchantmentUtils;\nimport io.githu",
"end": 75,
"score": 0.9990973472595215,
"start": 64,
"tag": "USERNAME",
"value": "bloepiloepi"
},
{
"context": "vp.enchantment.EnchantmentUtils;\nimport io.github.bloepiloepi.pvp.entities.EntityUtils;\nimport io.github.bloepi",
"end": 138,
"score": 0.9990770220756531,
"start": 127,
"tag": "USERNAME",
"value": "bloepiloepi"
},
{
"context": "iloepi.pvp.entities.EntityUtils;\nimport io.github.bloepiloepi.pvp.entities.Tracker;\nimport io.github.bloepiloep",
"end": 193,
"score": 0.998955249786377,
"start": 182,
"tag": "USERNAME",
"value": "bloepiloepi"
},
{
"context": "loepiloepi.pvp.entities.Tracker;\nimport io.github.bloepiloepi.pvp.utils.SoundManager;\nimport it.unimi.dsi.fastu",
"end": 244,
"score": 0.9987457394599915,
"start": 233,
"tag": "USERNAME",
"value": "bloepiloepi"
}
]
| null | []
| package io.github.bloepiloepi.pvp.projectile;
import io.github.bloepiloepi.pvp.enchantment.EnchantmentUtils;
import io.github.bloepiloepi.pvp.entities.EntityUtils;
import io.github.bloepiloepi.pvp.entities.Tracker;
import io.github.bloepiloepi.pvp.utils.SoundManager;
import it.unimi.dsi.fastutil.Pair;
import net.kyori.adventure.sound.Sound;
import net.minestom.server.MinecraftServer;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.coordinate.Vec;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Player;
import net.minestom.server.event.EventDispatcher;
import net.minestom.server.event.EventFilter;
import net.minestom.server.event.EventListener;
import net.minestom.server.event.EventNode;
import net.minestom.server.event.entity.EntityShootEvent;
import net.minestom.server.event.item.ItemUpdateStateEvent;
import net.minestom.server.event.player.PlayerItemAnimationEvent;
import net.minestom.server.event.player.PlayerTickEvent;
import net.minestom.server.event.player.PlayerUseItemEvent;
import net.minestom.server.event.trait.PlayerEvent;
import net.minestom.server.item.Enchantment;
import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material;
import net.minestom.server.item.metadata.CrossbowMeta;
import net.minestom.server.sound.SoundEvent;
import net.minestom.server.tag.Tag;
import net.minestom.server.utils.MathUtils;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
public class ProjectileListener {
private static final Tag<Byte> START_SOUND_PLAYED = Tag.Byte("StartSoundPlayed");
private static final Tag<Byte> MID_LOAD_SOUND_PLAYED = Tag.Byte("MidLoadSoundPlayed");
// Please, don't look at the random hardcoded numbers in this class, even I am confused
public static EventNode<PlayerEvent> events(boolean legacy) {
EventNode<PlayerEvent> node = EventNode.type("projectile-events", EventFilter.PLAYER);
node.addListener(EventListener.builder(PlayerUseItemEvent.class).handler(event -> {
ThreadLocalRandom random = ThreadLocalRandom.current();
Player player = event.getPlayer();
if (FishingBobber.fishingBobbers.containsKey(player.getUuid())) {
int durability = FishingBobber.fishingBobbers.get(player.getUuid()).retrieve();
//TODO damage fishing rod
SoundManager.sendToAround(player, SoundEvent.ENTITY_FISHING_BOBBER_RETRIEVE, Sound.Source.NEUTRAL,
1.0F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
} else {
SoundManager.sendToAround(player, SoundEvent.ENTITY_FISHING_BOBBER_THROW, Sound.Source.NEUTRAL,
0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
FishingBobber bobber = new FishingBobber(player, legacy);
FishingBobber.fishingBobbers.put(player.getUuid(), bobber);
EntityShootEvent shootEvent = new EntityShootEvent(player, bobber,
player.getPosition(), 0, 1.0);
EventDispatcher.call(shootEvent);
if (shootEvent.isCancelled()) {
bobber.remove();
return;
}
double spread = shootEvent.getSpread() * (legacy ? 0.0075 : 0.0045);
Pos playerPos = player.getPosition();
float playerPitch = playerPos.pitch();
float playerYaw = playerPos.yaw();
float zDir = (float) Math.cos(Math.toRadians(-playerYaw) - Math.PI);
float xDir = (float) Math.sin(Math.toRadians(-playerYaw) - Math.PI);
double x = playerPos.x() - (double) xDir * 0.3D;
double y = playerPos.y() + player.getEyeHeight();
double z = playerPos.z() - (double) zDir * 0.3D;
bobber.setInstance(Objects.requireNonNull(player.getInstance()), new Pos(x, y, z));
Vec velocity;
if (!legacy) {
velocity = new Vec(
-xDir,
MathUtils.clamp(-(
(float) Math.sin(Math.toRadians(-playerPitch)) /
(float) -Math.cos(Math.toRadians(-playerPitch))
), -5.0F, 5.0F),
-zDir
);
double length = velocity.length();
velocity = velocity.mul(
0.6D / length + 0.5D + random.nextGaussian() * spread,
0.6D / length + 0.5D + random.nextGaussian() * spread,
0.6D / length + 0.5D + random.nextGaussian() * spread
);
} else {
double maxVelocity = 0.4F;
velocity = new Vec(
-Math.sin(playerYaw / 180.0F * (float) Math.PI)
* Math.cos(playerPitch / 180.0F * (float) Math.PI) * maxVelocity,
-Math.sin(playerPitch / 180.0F * (float) Math.PI) * maxVelocity,
Math.cos(playerYaw / 180.0F * (float) Math.PI)
* Math.cos(playerPitch / 180.0F * (float) Math.PI) * maxVelocity
);
double length = velocity.length();
velocity = velocity
.div(length)
.add(
random.nextGaussian() * spread,
random.nextGaussian() * spread,
random.nextGaussian() * spread
)
.mul(1.5);
}
bobber.setVelocity(velocity.mul(MinecraftServer.TICK_PER_SECOND * 0.75));
}
}).filter(event -> event.getItemStack().getMaterial() == Material.FISHING_ROD).build());
node.addListener(EventListener.builder(PlayerUseItemEvent.class).handler(event -> {
Player player = event.getPlayer();
ItemStack stack = event.getItemStack();
if (Tracker.hasCooldown(player, stack.getMaterial())) {
event.setCancelled(true);
return;
}
boolean snowball = stack.getMaterial() == Material.SNOWBALL;
boolean enderpearl = stack.getMaterial() == Material.ENDER_PEARL;
SoundEvent soundEvent;
EntityHittableProjectile projectile;
if (snowball) {
soundEvent = SoundEvent.ENTITY_SNOWBALL_THROW;
projectile = new Snowball(player);
} else if (enderpearl) {
soundEvent = SoundEvent.ENTITY_ENDER_PEARL_THROW;
projectile = new ThrownEnderpearl(player);
} else {
soundEvent = SoundEvent.ENTITY_EGG_THROW;
projectile = new ThrownEgg(player);
}
projectile.setItem(stack);
ThreadLocalRandom random = ThreadLocalRandom.current();
SoundManager.sendToAround(player, soundEvent,
snowball || enderpearl ? Sound.Source.NEUTRAL : Sound.Source.PLAYER,
0.5f, 0.4f / (random.nextFloat() * 0.4f + 0.8f));
if (enderpearl) {
Tracker.setCooldown(player, Material.ENDER_PEARL, 20);
}
Pos position = player.getPosition().add(0D, player.getEyeHeight(), 0D);
projectile.setInstance(Objects.requireNonNull(player.getInstance()), position);
Vec direction = position.direction();
position = position.add(direction).sub(0, 0.2, 0); //????????
projectile.shoot(position, 1.5, 1.0);
Vec playerVel = player.getVelocity();
projectile.setVelocity(projectile.getVelocity().add(playerVel.x(),
player.isOnGround() ? 0.0D : playerVel.y(), playerVel.z()));
if (!player.isCreative()) {
player.setItemInHand(event.getHand(), stack.withAmount(stack.getAmount() - 1));
}
}).filter(event -> event.getItemStack().getMaterial() == Material.SNOWBALL
|| event.getItemStack().getMaterial() == Material.EGG
|| event.getItemStack().getMaterial() == Material.ENDER_PEARL)
.build());
node.addListener(EventListener.builder(PlayerUseItemEvent.class).handler(event -> {
ItemStack stack = event.getItemStack();
if (crossbow(stack).isCharged()) {
// Make sure the animation event is not called, because this is not an animation
event.setCancelled(true);
stack = performCrossbowShooting(event.getPlayer(), event.getHand(), stack,
getCrossbowPower(stack), 1.0, legacy);
event.getPlayer().setItemInHand(event.getHand(), setCrossbowCharged(stack, false));
} else {
if (EntityUtils.getProjectile(event.getPlayer(),
Arrow.ARROW_OR_FIREWORK_PREDICATE, Arrow.ARROW_PREDICATE).first().isAir()) {
event.setCancelled(true);
} else {
ItemStack newStack = stack
.withTag(START_SOUND_PLAYED, (byte) 0)
.withTag(MID_LOAD_SOUND_PLAYED, (byte) 0);
event.getPlayer().setItemInHand(event.getHand(), newStack);
Tracker.itemUseHand.put(event.getPlayer().getUuid(), event.getHand());
}
}
}).filter(event -> event.getItemStack().getMaterial() == Material.CROSSBOW).build());
node.addListener(PlayerItemAnimationEvent.class, event -> {
if (event.getArmAnimationType() == PlayerItemAnimationEvent.ItemAnimationType.BOW) {
if (!event.getPlayer().isCreative()
&& EntityUtils.getProjectile(event.getPlayer(), Arrow.ARROW_PREDICATE).first().isAir()) {
event.setCancelled(true);
}
}
});
node.addListener(PlayerTickEvent.class, event -> {
Player player = event.getPlayer();
if (EntityUtils.isChargingCrossbow(player)) {
Player.Hand hand = EntityUtils.getActiveHand(player);
ItemStack stack = player.getItemInHand(hand);
int quickCharge = EnchantmentUtils.getLevel(Enchantment.QUICK_CHARGE, stack);
long useDuration = System.currentTimeMillis() - Tracker.itemUseStartTime.get(player.getUuid());
long useTicks = useDuration / MinecraftServer.TICK_MS;
double progress = (getCrossbowUseDuration(stack) - useTicks) / (double) getCrossbowChargeDuration(stack);
Byte startSoundPlayed = stack.getTag(START_SOUND_PLAYED);
Byte midLoadSoundPlayed = stack.getTag(MID_LOAD_SOUND_PLAYED);
if (startSoundPlayed == null) startSoundPlayed = (byte) 0;
if (midLoadSoundPlayed == null) midLoadSoundPlayed = (byte) 0;
if (progress >= 0.2 && startSoundPlayed == (byte) 0) {
SoundEvent startSound = getCrossbowStartSound(quickCharge);
SoundManager.sendToAround(player, startSound, Sound.Source.PLAYER, 0.5F, 1.0F);
stack = stack.withTag(START_SOUND_PLAYED, (byte) 1);
player.setItemInHand(hand, stack);
}
SoundEvent midLoadSound = quickCharge == 0 ? SoundEvent.ITEM_CROSSBOW_LOADING_MIDDLE : null;
if (progress >= 0.5F && midLoadSound != null && midLoadSoundPlayed == (byte) 0) {
SoundManager.sendToAround(player, midLoadSound, Sound.Source.PLAYER, 0.5F, 1.0F);
stack = stack.withTag(MID_LOAD_SOUND_PLAYED, (byte) 1);
player.setItemInHand(hand, stack);
}
}
});
node.addListener(EventListener.builder(ItemUpdateStateEvent.class).handler(event -> {
Player player = event.getPlayer();
ItemStack stack = event.getItemStack();
boolean infinite = player.isCreative() || EnchantmentUtils.getLevel(Enchantment.INFINITY, stack) > 0;
Pair<ItemStack, Integer> projectilePair = EntityUtils.getProjectile(player, Arrow.ARROW_PREDICATE);
ItemStack projectile = projectilePair.first();
int projectileSlot = projectilePair.second();
if (!infinite && projectile.isAir()) return;
if (projectile.isAir()) {
projectile = Arrow.DEFAULT_ARROW;
projectileSlot = -1;
}
long useDuration = System.currentTimeMillis() - Tracker.itemUseStartTime.get(player.getUuid());
double power = getBowPower(useDuration);
if (power < 0.1) return;
// Arrow creation
AbstractArrow arrow = createArrow(projectile, player, legacy);
if (power >= 1) {
arrow.setCritical(true);
}
int powerEnchantment = EnchantmentUtils.getLevel(Enchantment.POWER, stack);
if (powerEnchantment > 0) {
arrow.setBaseDamage(arrow.getBaseDamage() + (double) powerEnchantment * 0.5 + 0.5);
}
int punchEnchantment = EnchantmentUtils.getLevel(Enchantment.PUNCH, stack);
if (punchEnchantment > 0) {
arrow.setKnockback(punchEnchantment);
}
if (EnchantmentUtils.getLevel(Enchantment.FLAME, stack) > 0) {
EntityUtils.setOnFireForSeconds(arrow, 100);
}
//TODO damage bow item
boolean reallyInfinite = infinite && projectile.getMaterial() == Material.ARROW;
if (reallyInfinite || player.isCreative()
&& (projectile.getMaterial() == Material.SPECTRAL_ARROW
|| projectile.getMaterial() == Material.TIPPED_ARROW)) {
arrow.pickupMode = AbstractArrow.PickupMode.CREATIVE_ONLY;
}
// Arrow shooting
Pos position = player.getPosition().add(0D, player.getEyeHeight(), 0D);
arrow.setInstance(Objects.requireNonNull(player.getInstance()),
position.sub(0, 0.10000000149011612D, 0)); // Yeah wait what
Vec direction = position.direction();
position = position.add(direction).sub(0, 0.2, 0); //????????
arrow.shoot(position, power * 3, 1.0);
Vec playerVel = player.getVelocity();
arrow.setVelocity(arrow.getVelocity().add(playerVel.x(),
player.isOnGround() ? 0.0D : playerVel.y(), playerVel.z()));
ThreadLocalRandom random = ThreadLocalRandom.current();
SoundManager.sendToAround(player, SoundEvent.ENTITY_ARROW_SHOOT, Sound.Source.PLAYER,
1.0f, 1.0f / (random.nextFloat() * 0.4f + 1.2f) + (float) power * 0.5f);
if (!reallyInfinite && !player.isCreative() && projectileSlot >= 0) {
player.getInventory().setItemStack(projectileSlot,
projectile.withAmount(projectile.getAmount() - 1));
}
}).filter(event -> event.getItemStack().getMaterial() == Material.BOW).build());
node.addListener(EventListener.builder(ItemUpdateStateEvent.class).handler(event -> {
Player player = event.getPlayer();
ItemStack stack = event.getItemStack();
int quickCharge = EnchantmentUtils.getLevel(Enchantment.QUICK_CHARGE, stack);
if (quickCharge < 6) {
long useDuration = System.currentTimeMillis() - Tracker.itemUseStartTime.get(player.getUuid());
double power = getCrossbowPowerForTime(useDuration, stack);
if (!(power >= 1.0F) || crossbow(stack).isCharged())
return;
}
stack = loadCrossbowProjectiles(player, stack);
if (stack == null) return;
stack = setCrossbowCharged(stack, true);
ThreadLocalRandom random = ThreadLocalRandom.current();
SoundManager.sendToAround(player, SoundEvent.ITEM_CROSSBOW_LOADING_END, Sound.Source.PLAYER,
1.0F, 1.0F / (random.nextFloat() * 0.5F + 1.0F) + 0.2F);
player.setItemInHand(event.getHand(), stack);
}).filter(event -> event.getItemStack().getMaterial() == Material.CROSSBOW).build());
return node;
}
public static double getBowPower(long useDurationMillis) {
double seconds = useDurationMillis / 1000.0;
double power = (seconds * seconds + seconds * 2.0) / 3.0;
if (power > 1) {
power = 1;
}
return power;
}
public static AbstractArrow createArrow(ItemStack stack, @Nullable Entity shooter, boolean legacy) {
if (stack.getMaterial() == Material.SPECTRAL_ARROW) {
return new SpectralArrow(shooter);
} else {
Arrow arrow = new Arrow(shooter, legacy);
arrow.inheritEffects(stack);
return arrow;
}
}
public static double getCrossbowPower(ItemStack stack) {
return crossbowContainsProjectile(stack, Material.FIREWORK_ROCKET) ? 1.6 : 3.15;
}
public static double getCrossbowPowerForTime(long useDurationMillis, ItemStack stack) {
long ticks = useDurationMillis / MinecraftServer.TICK_MS;
double power = ticks / (double) getCrossbowChargeDuration(stack);
if (power > 1) {
power = 1;
}
return power;
}
public static ItemStack setCrossbowCharged(ItemStack stack, boolean charged) {
return stack.withMeta(meta -> ((CrossbowMeta.Builder) meta).charged(charged));
}
public static ItemStack setCrossbowProjectile(ItemStack stack, ItemStack projectile) {
return stack.withMeta(meta -> ((CrossbowMeta.Builder) meta).projectile(projectile));
}
public static ItemStack setCrossbowProjectiles(ItemStack stack, ItemStack projectile1,
ItemStack projectile2, ItemStack projectile3) {
return stack.withMeta(meta -> ((CrossbowMeta.Builder) meta)
.projectiles(projectile1, projectile2, projectile3));
}
public static boolean crossbowContainsProjectile(ItemStack stack, Material projectile) {
CrossbowMeta meta = crossbow(stack);
if (meta.getProjectile1().getMaterial() == projectile) return true;
if (meta.getProjectile2().getMaterial() == projectile) return true;
return meta.getProjectile3().getMaterial() == projectile;
}
public static int getCrossbowUseDuration(ItemStack stack) {
return getCrossbowChargeDuration(stack) + 3;
}
public static int getCrossbowChargeDuration(ItemStack stack) {
int quickCharge = EnchantmentUtils.getLevel(Enchantment.QUICK_CHARGE, stack);
return quickCharge == 0 ? 25 : 25 - 5 * quickCharge;
}
public static SoundEvent getCrossbowStartSound(int quickCharge) {
switch (quickCharge) {
case 1:
return SoundEvent.ITEM_CROSSBOW_QUICK_CHARGE_1;
case 2:
return SoundEvent.ITEM_CROSSBOW_QUICK_CHARGE_2;
case 3:
return SoundEvent.ITEM_CROSSBOW_QUICK_CHARGE_3;
default:
return SoundEvent.ITEM_CROSSBOW_LOADING_START;
}
}
public static ItemStack loadCrossbowProjectiles(Player player, ItemStack stack) {
boolean multiShot = EnchantmentUtils.getLevel(Enchantment.MULTISHOT, stack) > 0;
Pair<ItemStack, Integer> pair = EntityUtils.getProjectile(player,
Arrow.ARROW_OR_FIREWORK_PREDICATE, Arrow.ARROW_PREDICATE);
ItemStack projectile = pair.first();
int projectileSlot = pair.second();
if (projectile.isAir() && player.isCreative()) {
projectile = Arrow.DEFAULT_ARROW;
projectileSlot = -1;
}
if (multiShot) {
stack = setCrossbowProjectiles(stack, projectile, projectile, projectile);
} else {
stack = setCrossbowProjectile(stack, projectile);
}
if (!player.isCreative() && projectileSlot >= 0) {
player.getInventory().setItemStack(projectileSlot, projectile.withAmount(projectile.getAmount() - 1));
}
return stack;
}
public static CrossbowMeta crossbow(ItemStack stack) {
return (CrossbowMeta) stack.getMeta();
}
public static ItemStack performCrossbowShooting(Player player, Player.Hand hand, ItemStack stack,
double power, double spread, boolean legacy) {
CrossbowMeta meta = crossbow(stack);
ItemStack projectile = meta.getProjectile1();
if (!projectile.isAir()) {
shootCrossbowProjectile(player, hand, stack, projectile, 1.0F, power, spread, 0.0F, legacy);
}
if (meta.isTriple()) {
ThreadLocalRandom random = ThreadLocalRandom.current();
boolean firstHighPitch = random.nextBoolean();
float firstPitch = getRandomShotPitch(firstHighPitch, random);
float secondPitch = getRandomShotPitch(!firstHighPitch, random);
projectile = meta.getProjectile2();
if (!projectile.isAir()) {
shootCrossbowProjectile(player, hand, stack, projectile, firstPitch, power, spread, -10.0F, legacy);
}
projectile = meta.getProjectile3();
if (!projectile.isAir()) {
shootCrossbowProjectile(player, hand, stack, projectile, secondPitch, power, spread, 10.0F, legacy);
}
}
return setCrossbowProjectile(stack, ItemStack.AIR);
}
public static void shootCrossbowProjectile(Player player, Player.Hand hand, ItemStack crossbowStack,
ItemStack projectile, float soundPitch,
double power, double spread, float yaw, boolean legacy) {
boolean firework = projectile.getMaterial() == Material.FIREWORK_ROCKET;
if (firework) return; //TODO firework
AbstractArrow arrow = getCrossbowArrow(player, crossbowStack, projectile, legacy);
if (player.isCreative() || yaw != 0.0) {
arrow.pickupMode = AbstractArrow.PickupMode.CREATIVE_ONLY;
}
Pos position = player.getPosition().add(0D, player.getEyeHeight(), 0D);
arrow.setInstance(Objects.requireNonNull(player.getInstance()),
position.sub(0, 0.10000000149011612D, 0)); // Yeah wait what
position = position.withYaw(position.yaw() + yaw);
Vec direction = position.direction();
position = position.add(direction).sub(0, 0.2, 0); //????????
arrow.shoot(position, power, spread);
//TODO damage crossbow
SoundManager.sendToAround(player, SoundEvent.ITEM_CROSSBOW_SHOOT, Sound.Source.PLAYER, 1.0F, soundPitch);
}
public static AbstractArrow getCrossbowArrow(Player player, ItemStack crossbowStack, ItemStack projectile, boolean legacy) {
AbstractArrow arrow = createArrow(projectile, player, legacy);
arrow.setCritical(true); // Player shooter is always critical
arrow.setSound(SoundEvent.ITEM_CROSSBOW_HIT);
int piercing = EnchantmentUtils.getLevel(Enchantment.PIERCING, crossbowStack);
if (piercing > 0) {
arrow.setPiercingLevel((byte) piercing);
}
return arrow;
}
public static float getRandomShotPitch(boolean high, ThreadLocalRandom random) {
float base = high ? 0.63F : 0.43F;
return 1.0F / (random.nextFloat() * 0.5F + 1.8F) + base;
}
}
| 20,462 | 0.70174 | 0.687421 | 523 | 38.124283 | 30.632683 | 125 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.780115 | false | false | 1 |
611b1057f9f5a233b75e093b9aeb71ca84c658f5 | 31,404,800,917,270 | 296a7022766c5f66b1e358426c67b1f46076a07d | /scm-core/src/main/java/sonia/scm/repository/api/PushCommandBuilder.java | fabe938ff7d1426097f7fadd32054b478a6e6bed | [
"BSD-2-Clause"
]
| permissive | sdorra/scm-manager | https://github.com/sdorra/scm-manager | c034e0d46338d39e87a90b1819a140f5fc3a429a | 1b68efa89e4d65889b785969b204925057de5525 | refs/heads/one.dot.x | 2020-01-22T13:42:55.341000 | 2018-04-05T17:56:15 | 2018-04-05T17:56:15 | 1,572,027 | 37 | 13 | NOASSERTION | false | 2020-02-11T16:08:37 | 2011-04-05T13:10:42 | 2020-01-30T08:37:04 | 2019-10-14T14:46:06 | 14,168 | 40 | 13 | 2 | Java | false | false | /**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.repository.PermissionType;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.PushCommand;
import sonia.scm.repository.spi.PushCommandRequest;
import sonia.scm.security.RepositoryPermission;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.net.URL;
/**
* The push command push changes to a other repository.
*
* @author Sebastian Sdorra
* @since 1.31
*/
public final class PushCommandBuilder
{
/**
* the logger for PushCommandBuilder
*/
private static final Logger logger =
LoggerFactory.getLogger(PushCommandBuilder.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new PushCommandBuilder.
*
* @param command implementation of the {@link PushCommand}
*/
PushCommandBuilder(PushCommand command)
{
this.command = command;
}
//~--- methods --------------------------------------------------------------
/**
* Push all changes to the given remote repository.
*
* @param remoteRepository remote repository
*
* @return informations of the executed push command
*
* @throws IOException
* @throws RepositoryException
*/
public PushResponse push(Repository remoteRepository)
throws IOException, RepositoryException
{
Subject subject = SecurityUtils.getSubject();
//J-
subject.checkPermission(
new RepositoryPermission(remoteRepository, PermissionType.WRITE)
);
//J+
logger.info("push changes to repository {}", remoteRepository.getId());
request.reset();
request.setRemoteRepository(remoteRepository);
return command.push(request);
}
/**
* Push all changes to the given remote url.
*
* @param url url of a remote repository
*
* @return informations of the executed push command
*
* @throws IOException
* @throws RepositoryException
*
* @since 1.43
*/
public PushResponse push(String url) throws IOException, RepositoryException
{
URL remoteUrl = new URL(url);
logger.info("push changes to url {}", url);
request.reset();
request.setRemoteUrl(remoteUrl);
return command.push(request);
}
//~--- fields ---------------------------------------------------------------
/** push command implementation */
private PushCommand command;
/** push command request */
private PushCommandRequest request = new PushCommandRequest();
}
| UTF-8 | Java | 4,417 | java | PushCommandBuilder.java | Java | [
{
"context": "/**\n * Copyright (c) 2010, Sebastian Sdorra\n * All rights reserved.\n *\n * Redistribution and ",
"end": 43,
"score": 0.999869704246521,
"start": 27,
"tag": "NAME",
"value": "Sebastian Sdorra"
},
{
"context": " push changes to a other repository.\n *\n * @author Sebastian Sdorra\n * @since 1.31\n */\npublic final class PushCommand",
"end": 2372,
"score": 0.9998770952224731,
"start": 2356,
"tag": "NAME",
"value": "Sebastian Sdorra"
}
]
| null | []
| /**
* Copyright (c) 2010, <NAME>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.repository.PermissionType;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.PushCommand;
import sonia.scm.repository.spi.PushCommandRequest;
import sonia.scm.security.RepositoryPermission;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.net.URL;
/**
* The push command push changes to a other repository.
*
* @author <NAME>
* @since 1.31
*/
public final class PushCommandBuilder
{
/**
* the logger for PushCommandBuilder
*/
private static final Logger logger =
LoggerFactory.getLogger(PushCommandBuilder.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new PushCommandBuilder.
*
* @param command implementation of the {@link PushCommand}
*/
PushCommandBuilder(PushCommand command)
{
this.command = command;
}
//~--- methods --------------------------------------------------------------
/**
* Push all changes to the given remote repository.
*
* @param remoteRepository remote repository
*
* @return informations of the executed push command
*
* @throws IOException
* @throws RepositoryException
*/
public PushResponse push(Repository remoteRepository)
throws IOException, RepositoryException
{
Subject subject = SecurityUtils.getSubject();
//J-
subject.checkPermission(
new RepositoryPermission(remoteRepository, PermissionType.WRITE)
);
//J+
logger.info("push changes to repository {}", remoteRepository.getId());
request.reset();
request.setRemoteRepository(remoteRepository);
return command.push(request);
}
/**
* Push all changes to the given remote url.
*
* @param url url of a remote repository
*
* @return informations of the executed push command
*
* @throws IOException
* @throws RepositoryException
*
* @since 1.43
*/
public PushResponse push(String url) throws IOException, RepositoryException
{
URL remoteUrl = new URL(url);
logger.info("push changes to url {}", url);
request.reset();
request.setRemoteUrl(remoteUrl);
return command.push(request);
}
//~--- fields ---------------------------------------------------------------
/** push command implementation */
private PushCommand command;
/** push command request */
private PushCommandRequest request = new PushCommandRequest();
}
| 4,397 | 0.678515 | 0.675119 | 147 | 29.047619 | 28.345135 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.387755 | false | false | 1 |
9db623b6e652384f87fdfe00fd96028a5f633287 | 14,431,090,179,214 | a222456a966a0e5055fbfbbbd3c09b6eb9bacf98 | /components/processor/src/main/java/org/ballerinalang/artifactgen/ArtifactGenConstants.java | f2d7702ca18bdb88607350271f076679e789ac4b | [
"Apache-2.0"
]
| permissive | anuruddhal/kuberina | https://github.com/anuruddhal/kuberina | 4a6c55d0e3791ea877fa38bd2050b86c2bbd7d8e | 0ddb6a1e3f6fe7b0df89aa2313dfee5f8be2d523 | refs/heads/master | 2021-05-08T18:13:34.761000 | 2018-03-02T15:05:53 | 2018-03-02T15:05:53 | 119,505,175 | 0 | 1 | Apache-2.0 | false | 2018-02-26T08:10:33 | 2018-01-30T08:22:35 | 2018-01-30T08:32:44 | 2018-02-26T04:06:04 | 226 | 0 | 1 | 1 | Java | false | null | /*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.ballerinalang.artifactgen;
/**
* Constants used in kuberina.
*/
public class ArtifactGenConstants {
public static final String ENABLE_DEBUG_LOGS = "debugKuberina";
public static final String KUBERNETES_SVC_PROTOCOL = "TCP";
public static final String KUBERNETES_SELECTOR_KEY = "app";
// Annotation package constants
public static final String KUBERNETES_ANNOTATION_PACKAGE = "ballerina.kubernetes";
public static final String DOCKER_ANNOTATION_PACKAGE = "ballerina.docker";
public static final String DEPLOYMENT_ANNOTATION = "deployment";
public static final String HPA_ANNOTATION = "hpa";
public static final String SERVICE_ANNOTATION = "svc";
public static final String INGRESS_ANNOTATION = "ingress";
public static final String DOCKER_ANNOTATION = "configuration";
//Docker annotation constants
public static final String DOCKER_NAME = "name";
public static final String DOCKER_REGISTRY = "registry";
public static final String DOCKER_TAG = "tag";
public static final String DOCKER_USERNAME = "username";
public static final String DOCKER_PASSWORD = "password";
public static final String DOCKER_PUSH = "push";
public static final String DOCKER_TAG_LATEST = "latest";
public static final String DOCKER_IMAGE_BUILD = "imageBuild";
public static final String DOCKER_DEBUG_ENABLE = "debugEnable";
public static final String DOCKER_DEBUG_PORT = "debugPort";
public static final String DOCKER_BASE_IMAGE = "baseImage";
//Deployment annotation constants
public static final String DEPLOYMENT_NAME = "name";
public static final String DEPLOYMENT_LABELS = "labels";
public static final String DEPLOYMENT_REPLICAS = "replicas";
public static final String DEPLOYMENT_LIVENESS = "liveness";
public static final String DEPLOYMENT_INITIAL_DELAY_SECONDS = "initialDelaySeconds";
public static final String DEPLOYMENT_PERIOD_SECONDS = "periodSeconds";
public static final String DEPLOYMENT_LIVENESS_PORT = "livenessPort";
public static final String DEPLOYMENT_IMAGE_PULL_POLICY = "imagePullPolicy";
public static final String DEPLOYMENT_NAMESPACE = "namespace";
public static final String DEPLOYMENT_IMAGE = "image";
public static final String DEPLOYMENT_IMAGE_BUILD = "imageBuild";
public static final String DEPLOYMENT_NAMESPACE_DEFAULT = "default";
public static final String DEPLOYMENT_IMAGE_PULL_POLICY_DEFAULT = "IfNotPresent";
public static final String DEPLOYMENT_LIVENESS_DISABLE = "disable";
public static final String DEPLOYMENT_LIVENESS_ENABLE = "enable";
public static final String DEPLOYMENT_ENV_VARS = "env";
//Kubernetes service constants
public static final String SVC_NAME = "name";
public static final String SVC_LABELS = "labels";
public static final String SVC_SERVICE_TYPE = "serviceType";
public static final String SVC_PORT = "port";
//Kubernetes ingress constants
public static final String INGRESS_NAME = "name";
public static final String INGRESS_LABELS = "labels";
public static final String INGRESS_HOSTNAME = "hostname";
public static final String INGRESS_PATH = "path";
public static final String INGRESS_TARGET_PATH = "targetPath";
public static final String INGRESS_CLASS = "ingressClass";
public static final String INGRESS_ENABLE_TLS = "enableTLS";
//Kubernetes Pod Autoscaler constants
public static final String AUTOSCALER_NAME = "name";
public static final String AUTOSCALER_LABELS = "labels";
public static final String AUTOSCALER_MIN_REPLICAS = "minReplicas";
public static final String AUTOSCALER_MAX_REPLICAS = "maxReplicas";
public static final String AUTOSCALER_CPU_PERCENTAGE = "cpuPercentage";
public static final String AUTOSCALER_DEPLOYMENT = "deployment";
}
| UTF-8 | Java | 4,530 | java | ArtifactGenConstants.java | Java | [
{
"context": "ic static final String KUBERNETES_SELECTOR_KEY = \"app\";\n\n // Annotation package constants\n public",
"end": 980,
"score": 0.5677492022514343,
"start": 977,
"tag": "KEY",
"value": "app"
},
{
"context": " public static final String DOCKER_USERNAME = \"username\";\n public static final String DOCKER_PASSWORD ",
"end": 1758,
"score": 0.999133288860321,
"start": 1750,
"tag": "USERNAME",
"value": "username"
},
{
"context": " public static final String DOCKER_PASSWORD = \"password\";\n public static final String DOCKER_PUSH = \"p",
"end": 1819,
"score": 0.9993295073509216,
"start": 1811,
"tag": "PASSWORD",
"value": "password"
}
]
| null | []
| /*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.ballerinalang.artifactgen;
/**
* Constants used in kuberina.
*/
public class ArtifactGenConstants {
public static final String ENABLE_DEBUG_LOGS = "debugKuberina";
public static final String KUBERNETES_SVC_PROTOCOL = "TCP";
public static final String KUBERNETES_SELECTOR_KEY = "app";
// Annotation package constants
public static final String KUBERNETES_ANNOTATION_PACKAGE = "ballerina.kubernetes";
public static final String DOCKER_ANNOTATION_PACKAGE = "ballerina.docker";
public static final String DEPLOYMENT_ANNOTATION = "deployment";
public static final String HPA_ANNOTATION = "hpa";
public static final String SERVICE_ANNOTATION = "svc";
public static final String INGRESS_ANNOTATION = "ingress";
public static final String DOCKER_ANNOTATION = "configuration";
//Docker annotation constants
public static final String DOCKER_NAME = "name";
public static final String DOCKER_REGISTRY = "registry";
public static final String DOCKER_TAG = "tag";
public static final String DOCKER_USERNAME = "username";
public static final String DOCKER_PASSWORD = "<PASSWORD>";
public static final String DOCKER_PUSH = "push";
public static final String DOCKER_TAG_LATEST = "latest";
public static final String DOCKER_IMAGE_BUILD = "imageBuild";
public static final String DOCKER_DEBUG_ENABLE = "debugEnable";
public static final String DOCKER_DEBUG_PORT = "debugPort";
public static final String DOCKER_BASE_IMAGE = "baseImage";
//Deployment annotation constants
public static final String DEPLOYMENT_NAME = "name";
public static final String DEPLOYMENT_LABELS = "labels";
public static final String DEPLOYMENT_REPLICAS = "replicas";
public static final String DEPLOYMENT_LIVENESS = "liveness";
public static final String DEPLOYMENT_INITIAL_DELAY_SECONDS = "initialDelaySeconds";
public static final String DEPLOYMENT_PERIOD_SECONDS = "periodSeconds";
public static final String DEPLOYMENT_LIVENESS_PORT = "livenessPort";
public static final String DEPLOYMENT_IMAGE_PULL_POLICY = "imagePullPolicy";
public static final String DEPLOYMENT_NAMESPACE = "namespace";
public static final String DEPLOYMENT_IMAGE = "image";
public static final String DEPLOYMENT_IMAGE_BUILD = "imageBuild";
public static final String DEPLOYMENT_NAMESPACE_DEFAULT = "default";
public static final String DEPLOYMENT_IMAGE_PULL_POLICY_DEFAULT = "IfNotPresent";
public static final String DEPLOYMENT_LIVENESS_DISABLE = "disable";
public static final String DEPLOYMENT_LIVENESS_ENABLE = "enable";
public static final String DEPLOYMENT_ENV_VARS = "env";
//Kubernetes service constants
public static final String SVC_NAME = "name";
public static final String SVC_LABELS = "labels";
public static final String SVC_SERVICE_TYPE = "serviceType";
public static final String SVC_PORT = "port";
//Kubernetes ingress constants
public static final String INGRESS_NAME = "name";
public static final String INGRESS_LABELS = "labels";
public static final String INGRESS_HOSTNAME = "hostname";
public static final String INGRESS_PATH = "path";
public static final String INGRESS_TARGET_PATH = "targetPath";
public static final String INGRESS_CLASS = "ingressClass";
public static final String INGRESS_ENABLE_TLS = "enableTLS";
//Kubernetes Pod Autoscaler constants
public static final String AUTOSCALER_NAME = "name";
public static final String AUTOSCALER_LABELS = "labels";
public static final String AUTOSCALER_MIN_REPLICAS = "minReplicas";
public static final String AUTOSCALER_MAX_REPLICAS = "maxReplicas";
public static final String AUTOSCALER_CPU_PERCENTAGE = "cpuPercentage";
public static final String AUTOSCALER_DEPLOYMENT = "deployment";
}
| 4,532 | 0.74106 | 0.738631 | 93 | 47.709679 | 25.932741 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.655914 | false | false | 1 |
1028507219de433cf1ac62711ee778c21d89717d | 6,133,213,350,664 | 1ebdf9fae028120cc4b72a52ff67ac3f5e0bd9f2 | /8958.java | be48c3907a17bb8b0b15a0c0765bb1767b0d8df0 | []
| no_license | U-WangE/Java-Study_Coding | https://github.com/U-WangE/Java-Study_Coding | ee3291ac3ce5f930ead73fd27d1bd0840fa12eab | 966c3e3cfc14f84f6736355b6a40bd1a7d537d6d | refs/heads/main | 2023-03-19T03:16:59.251000 | 2021-03-11T04:19:17 | 2021-03-11T04:19:17 | 341,948,261 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
char[][] arr = new char[n][80];
int[] score = new int[n];
for(int i = 0; i < n; i++) {
String s = sc.next();
for(int j = 0; j < s.length(); j++) {
arr[i][j] = s.charAt(j);
}
}
for(int i = 0; i < n; i++) {
int cnt = 0;
int j = 0;
while(arr[i][j] != '\0') {
if(arr[i][j] == 'O') {
cnt++;
score[i] += cnt;
} else
cnt = 0;
j++;
}
}
for(int i = 0; i < n; i++)
System.out.format(score[i] + "\n");
}
} | UTF-8 | Java | 894 | java | 8958.java | Java | []
| null | []
| import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
char[][] arr = new char[n][80];
int[] score = new int[n];
for(int i = 0; i < n; i++) {
String s = sc.next();
for(int j = 0; j < s.length(); j++) {
arr[i][j] = s.charAt(j);
}
}
for(int i = 0; i < n; i++) {
int cnt = 0;
int j = 0;
while(arr[i][j] != '\0') {
if(arr[i][j] == 'O') {
cnt++;
score[i] += cnt;
} else
cnt = 0;
j++;
}
}
for(int i = 0; i < n; i++)
System.out.format(score[i] + "\n");
}
} | 894 | 0.314318 | 0.303132 | 33 | 25.151516 | 14.058581 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 1 |
c59694ef90f2b86921525a9e38e5a1aac762f281 | 7,172,595,440,176 | ccccef8d3c560e5d4201c97804423127cc7b49b6 | /2017-03-15-largest-value-in-tree-row/syip-largest-value-in-tree-row.java | 157afbbcbdeaecc5c929d9866149d4d4853956b8 | []
| no_license | opentable/ot-daily-algorithm | https://github.com/opentable/ot-daily-algorithm | 33fc3eda15a05e1e5fa998bb39317c718a62ff3e | 10d36fbf387158ff437cc7d5e6d9cf47f37151f1 | refs/heads/master | 2021-01-18T18:41:47.926000 | 2020-02-28T11:33:42 | 2020-02-28T11:33:42 | 79,590,280 | 20 | 18 | null | false | 2020-02-28T11:33:43 | 2017-01-20T19:24:08 | 2020-02-28T10:30:48 | 2020-02-28T11:33:42 | 194 | 22 | 19 | 0 | Java | false | false | package largestvalueintreerow;
import java.util.*;
/**
* @author syip
* Find Largest Value in Each Tree Row
* You need to find the largest value in each row of a binary tree.
* Input:
* 1
* / \
* 3 2
* / \ \
* 5 3 9
* Output: [1, 3, 9]
*
* Solution: Traverse tree, maintain highest value for each row O(n)
*/
public class LargestValueInTreeRow {
public static class TreeNode {
TreeNode left;
TreeNode right;
Integer value;
TreeNode(Integer value) {this.value = value;}
}
public static void getLargestValuesList(TreeNode root, Integer rowNumber, List<Integer> largestValuesList) {
if (root == null) return;
if (largestValuesList.size() <= rowNumber) {
largestValuesList.add(rowNumber, root.value);
} else if (largestValuesList.get(rowNumber) < root.value)
largestValuesList.set(rowNumber, root.value);
getLargestValuesList(root.left, rowNumber+1, largestValuesList);
getLargestValuesList(root.right, rowNumber+1, largestValuesList);
}
public static void main(String[] args) {
TreeNode treeNode = new TreeNode(1);
List<Integer> largestValues = new ArrayList<>();
getLargestValuesList(treeNode, 0, largestValues);
assert largestValues.equals(new ArrayList<Integer>(Arrays.asList(1)));
largestValues = new ArrayList<>();
treeNode.left = new TreeNode(3);
treeNode.right = new TreeNode(2);
treeNode.left.left = new TreeNode(5);
getLargestValuesList(treeNode, 0, largestValues);
assert largestValues.equals(new ArrayList<Integer>(Arrays.asList(1, 3, 5)));
largestValues = new ArrayList<>();
treeNode.left.right = new TreeNode(3);
treeNode.right.right = new TreeNode(9);
getLargestValuesList(treeNode, 0, largestValues);
assert largestValues.equals(new ArrayList<Integer>(Arrays.asList(1, 3, 9)));
}
}
| UTF-8 | Java | 2,020 | java | syip-largest-value-in-tree-row.java | Java | [
{
"context": "valueintreerow;\nimport java.util.*;\n/**\n * @author syip\n * Find Largest Value in Each Tree Row\n * You nee",
"end": 70,
"score": 0.9934200048446655,
"start": 66,
"tag": "USERNAME",
"value": "syip"
}
]
| null | []
| package largestvalueintreerow;
import java.util.*;
/**
* @author syip
* Find Largest Value in Each Tree Row
* You need to find the largest value in each row of a binary tree.
* Input:
* 1
* / \
* 3 2
* / \ \
* 5 3 9
* Output: [1, 3, 9]
*
* Solution: Traverse tree, maintain highest value for each row O(n)
*/
public class LargestValueInTreeRow {
public static class TreeNode {
TreeNode left;
TreeNode right;
Integer value;
TreeNode(Integer value) {this.value = value;}
}
public static void getLargestValuesList(TreeNode root, Integer rowNumber, List<Integer> largestValuesList) {
if (root == null) return;
if (largestValuesList.size() <= rowNumber) {
largestValuesList.add(rowNumber, root.value);
} else if (largestValuesList.get(rowNumber) < root.value)
largestValuesList.set(rowNumber, root.value);
getLargestValuesList(root.left, rowNumber+1, largestValuesList);
getLargestValuesList(root.right, rowNumber+1, largestValuesList);
}
public static void main(String[] args) {
TreeNode treeNode = new TreeNode(1);
List<Integer> largestValues = new ArrayList<>();
getLargestValuesList(treeNode, 0, largestValues);
assert largestValues.equals(new ArrayList<Integer>(Arrays.asList(1)));
largestValues = new ArrayList<>();
treeNode.left = new TreeNode(3);
treeNode.right = new TreeNode(2);
treeNode.left.left = new TreeNode(5);
getLargestValuesList(treeNode, 0, largestValues);
assert largestValues.equals(new ArrayList<Integer>(Arrays.asList(1, 3, 5)));
largestValues = new ArrayList<>();
treeNode.left.right = new TreeNode(3);
treeNode.right.right = new TreeNode(9);
getLargestValuesList(treeNode, 0, largestValues);
assert largestValues.equals(new ArrayList<Integer>(Arrays.asList(1, 3, 9)));
}
}
| 2,020 | 0.635149 | 0.621782 | 55 | 35.727272 | 26.340052 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.854545 | false | false | 1 |
61d450f4d81b57a95ce853cc93d8e8949d31d2bb | 26,379,689,185,909 | 3f480d487f5e88acf6b64e1e424f64e2b0705d53 | /fr/thisismac/injector/customclass/ModelScouteurHat.java | f1be3aa84499b2b827b12dd55d1caf6aaef661d2 | []
| no_license | a3535ed54a5ee6917a46cfa6c3f12679/bde748d8_obsifight_client_2016 | https://github.com/a3535ed54a5ee6917a46cfa6c3f12679/bde748d8_obsifight_client_2016 | 2aecdb987054e44db89d6a7c101ace1bb047f003 | cc65846780c262dc8568f1d18a14aac282439c66 | refs/heads/master | 2021-04-30T11:46:25.656000 | 2018-02-12T15:10:50 | 2018-02-12T15:10:50 | 121,261,090 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package fr.thisismac.injector.customclass;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelScouteurHat extends ModelBase {
ModelRenderer Band;
ModelRenderer BandLeft;
ModelRenderer Shape1;
ModelRenderer Shape3;
ModelRenderer Shape2;
ModelRenderer BandLeft2;
ModelRenderer BandLeft3;
ModelRenderer BandLeft4;
ModelRenderer BandLeft5;
ModelRenderer BandLeft6;
ModelRenderer BandLeft7;
ModelRenderer BandLeft8;
public ModelScouteurHat() {
this.textureWidth = 64;
this.textureHeight = 32;
this.Band = new ModelRenderer(this, 16, 5);
this.Band.addBox(-4.5F, 0.0F, -0.5F, 9, 1, 1);
this.Band.setRotationPoint(0.0F, 15.0F, 0.0F);
this.Band.setTextureSize(64, 32);
this.Band.mirror = true;
this.setRotation(this.Band, 0.0F, 0.0F, 0.0F);
this.BandLeft = new ModelRenderer(this, 16, 8);
this.BandLeft.addBox(0.0F, -1.0F, -1.0F, 1, 2, 2);
this.BandLeft.setRotationPoint(-5.0F, 17.0F, 0.0F);
this.BandLeft.setTextureSize(64, 32);
this.BandLeft.mirror = true;
this.setRotation(this.BandLeft, ((float)Math.PI / 4F), 0.0F, 0.0F);
this.Shape1 = new ModelRenderer(this, 0, 13);
this.Shape1.addBox(0.0F, 0.0F, -6.0F, 0, 1, 6);
this.Shape1.setRotationPoint(5.0F, 17.5F, 0.0F);
this.Shape1.setTextureSize(64, 32);
this.Shape1.mirror = true;
this.setRotation(this.Shape1, 0.0F, 0.0F, 0.0F);
this.Shape3 = new ModelRenderer(this, 1, 22);
this.Shape3.addBox(-1.0F, -1.0F, 0.0F, 1, 1, 4);
this.Shape3.setRotationPoint(5.0F, 18.0F, -5.0F);
this.Shape3.setTextureSize(64, 32);
this.Shape3.mirror = true;
this.setRotation(this.Shape3, 0.0F, -((float)Math.PI / 2F), 0.0F);
this.Shape2 = new ModelRenderer(this, 1, 28);
this.Shape2.addBox(-4.0F, 0.0F, 0.0F, 4, 3, 0);
this.Shape2.setRotationPoint(4.0F, 18.0F, -5.5F);
this.Shape2.setTextureSize(64, 32);
this.Shape2.mirror = true;
this.setRotation(this.Shape2, 0.0F, 0.0F, 0.0F);
this.BandLeft2 = new ModelRenderer(this, 0, 9);
this.BandLeft2.addBox(0.0F, -0.5F, -0.5F, 1, 1, 1);
this.BandLeft2.setRotationPoint(4.5F, 17.0F, 0.0F);
this.BandLeft2.setTextureSize(64, 32);
this.BandLeft2.mirror = true;
this.setRotation(this.BandLeft2, ((float)Math.PI / 4F), 0.0F, 0.0F);
this.BandLeft3 = new ModelRenderer(this, 16, 8);
this.BandLeft3.addBox(0.0F, -1.0F, -1.0F, 1, 2, 2);
this.BandLeft3.setRotationPoint(4.0F, 17.0F, 0.0F);
this.BandLeft3.setTextureSize(64, 32);
this.BandLeft3.mirror = true;
this.setRotation(this.BandLeft3, ((float)Math.PI / 4F), 0.0F, 0.0F);
this.BandLeft4 = new ModelRenderer(this, 0, 9);
this.BandLeft4.addBox(0.0F, -0.5F, -0.5F, 1, 1, 1);
this.BandLeft4.setRotationPoint(-5.5F, 17.0F, 0.0F);
this.BandLeft4.setTextureSize(64, 32);
this.BandLeft4.mirror = true;
this.setRotation(this.BandLeft4, ((float)Math.PI / 4F), 0.0F, 0.0F);
this.BandLeft5 = new ModelRenderer(this, 24, 8);
this.BandLeft5.addBox(0.0F, -0.5F, -0.5F, 0, 1, 6);
this.BandLeft5.setRotationPoint(-5.0F, 17.5F, 0.0F);
this.BandLeft5.setTextureSize(64, 32);
this.BandLeft5.mirror = true;
this.setRotation(this.BandLeft5, -2.141282F, 0.0F, 0.0F);
this.BandLeft6 = new ModelRenderer(this, 31, 26);
this.BandLeft6.addBox(0.0F, -0.5F, -0.5F, 0, 1, 3);
this.BandLeft6.setRotationPoint(-4.5F, 22.0F, -6.5F);
this.BandLeft6.setTextureSize(64, 32);
this.BandLeft6.mirror = true;
this.setRotation(this.BandLeft6, 0.0F, ((float)Math.PI / 2F), 0.0F);
this.BandLeft7 = new ModelRenderer(this, 28, 16);
this.BandLeft7.addBox(0.0F, -0.5F, -4.5F, 0, 1, 4);
this.BandLeft7.setRotationPoint(-5.0F, 22.0F, -2.0F);
this.BandLeft7.setTextureSize(64, 32);
this.BandLeft7.mirror = true;
this.setRotation(this.BandLeft7, 0.0F, 0.0F, 0.0F);
this.BandLeft8 = new ModelRenderer(this, 26, 28);
this.BandLeft8.addBox(2.0F, -0.5F, -0.5F, 1, 1, 1);
this.BandLeft8.setRotationPoint(-4.5F, 22.0F, -6.5F);
this.BandLeft8.setTextureSize(64, 32);
this.BandLeft8.mirror = true;
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.Band.render(f5);
this.BandLeft.render(f5);
this.Shape1.render(f5);
this.Shape3.render(f5);
this.Shape2.render(f5);
this.BandLeft2.render(f5);
this.BandLeft3.render(f5);
this.BandLeft4.render(f5);
this.BandLeft5.render(f5);
this.BandLeft6.render(f5);
this.BandLeft7.render(f5);
this.BandLeft8.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}
| UTF-8 | Java | 5,285 | java | ModelScouteurHat.java | Java | []
| null | []
| package fr.thisismac.injector.customclass;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelScouteurHat extends ModelBase {
ModelRenderer Band;
ModelRenderer BandLeft;
ModelRenderer Shape1;
ModelRenderer Shape3;
ModelRenderer Shape2;
ModelRenderer BandLeft2;
ModelRenderer BandLeft3;
ModelRenderer BandLeft4;
ModelRenderer BandLeft5;
ModelRenderer BandLeft6;
ModelRenderer BandLeft7;
ModelRenderer BandLeft8;
public ModelScouteurHat() {
this.textureWidth = 64;
this.textureHeight = 32;
this.Band = new ModelRenderer(this, 16, 5);
this.Band.addBox(-4.5F, 0.0F, -0.5F, 9, 1, 1);
this.Band.setRotationPoint(0.0F, 15.0F, 0.0F);
this.Band.setTextureSize(64, 32);
this.Band.mirror = true;
this.setRotation(this.Band, 0.0F, 0.0F, 0.0F);
this.BandLeft = new ModelRenderer(this, 16, 8);
this.BandLeft.addBox(0.0F, -1.0F, -1.0F, 1, 2, 2);
this.BandLeft.setRotationPoint(-5.0F, 17.0F, 0.0F);
this.BandLeft.setTextureSize(64, 32);
this.BandLeft.mirror = true;
this.setRotation(this.BandLeft, ((float)Math.PI / 4F), 0.0F, 0.0F);
this.Shape1 = new ModelRenderer(this, 0, 13);
this.Shape1.addBox(0.0F, 0.0F, -6.0F, 0, 1, 6);
this.Shape1.setRotationPoint(5.0F, 17.5F, 0.0F);
this.Shape1.setTextureSize(64, 32);
this.Shape1.mirror = true;
this.setRotation(this.Shape1, 0.0F, 0.0F, 0.0F);
this.Shape3 = new ModelRenderer(this, 1, 22);
this.Shape3.addBox(-1.0F, -1.0F, 0.0F, 1, 1, 4);
this.Shape3.setRotationPoint(5.0F, 18.0F, -5.0F);
this.Shape3.setTextureSize(64, 32);
this.Shape3.mirror = true;
this.setRotation(this.Shape3, 0.0F, -((float)Math.PI / 2F), 0.0F);
this.Shape2 = new ModelRenderer(this, 1, 28);
this.Shape2.addBox(-4.0F, 0.0F, 0.0F, 4, 3, 0);
this.Shape2.setRotationPoint(4.0F, 18.0F, -5.5F);
this.Shape2.setTextureSize(64, 32);
this.Shape2.mirror = true;
this.setRotation(this.Shape2, 0.0F, 0.0F, 0.0F);
this.BandLeft2 = new ModelRenderer(this, 0, 9);
this.BandLeft2.addBox(0.0F, -0.5F, -0.5F, 1, 1, 1);
this.BandLeft2.setRotationPoint(4.5F, 17.0F, 0.0F);
this.BandLeft2.setTextureSize(64, 32);
this.BandLeft2.mirror = true;
this.setRotation(this.BandLeft2, ((float)Math.PI / 4F), 0.0F, 0.0F);
this.BandLeft3 = new ModelRenderer(this, 16, 8);
this.BandLeft3.addBox(0.0F, -1.0F, -1.0F, 1, 2, 2);
this.BandLeft3.setRotationPoint(4.0F, 17.0F, 0.0F);
this.BandLeft3.setTextureSize(64, 32);
this.BandLeft3.mirror = true;
this.setRotation(this.BandLeft3, ((float)Math.PI / 4F), 0.0F, 0.0F);
this.BandLeft4 = new ModelRenderer(this, 0, 9);
this.BandLeft4.addBox(0.0F, -0.5F, -0.5F, 1, 1, 1);
this.BandLeft4.setRotationPoint(-5.5F, 17.0F, 0.0F);
this.BandLeft4.setTextureSize(64, 32);
this.BandLeft4.mirror = true;
this.setRotation(this.BandLeft4, ((float)Math.PI / 4F), 0.0F, 0.0F);
this.BandLeft5 = new ModelRenderer(this, 24, 8);
this.BandLeft5.addBox(0.0F, -0.5F, -0.5F, 0, 1, 6);
this.BandLeft5.setRotationPoint(-5.0F, 17.5F, 0.0F);
this.BandLeft5.setTextureSize(64, 32);
this.BandLeft5.mirror = true;
this.setRotation(this.BandLeft5, -2.141282F, 0.0F, 0.0F);
this.BandLeft6 = new ModelRenderer(this, 31, 26);
this.BandLeft6.addBox(0.0F, -0.5F, -0.5F, 0, 1, 3);
this.BandLeft6.setRotationPoint(-4.5F, 22.0F, -6.5F);
this.BandLeft6.setTextureSize(64, 32);
this.BandLeft6.mirror = true;
this.setRotation(this.BandLeft6, 0.0F, ((float)Math.PI / 2F), 0.0F);
this.BandLeft7 = new ModelRenderer(this, 28, 16);
this.BandLeft7.addBox(0.0F, -0.5F, -4.5F, 0, 1, 4);
this.BandLeft7.setRotationPoint(-5.0F, 22.0F, -2.0F);
this.BandLeft7.setTextureSize(64, 32);
this.BandLeft7.mirror = true;
this.setRotation(this.BandLeft7, 0.0F, 0.0F, 0.0F);
this.BandLeft8 = new ModelRenderer(this, 26, 28);
this.BandLeft8.addBox(2.0F, -0.5F, -0.5F, 1, 1, 1);
this.BandLeft8.setRotationPoint(-4.5F, 22.0F, -6.5F);
this.BandLeft8.setTextureSize(64, 32);
this.BandLeft8.mirror = true;
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.Band.render(f5);
this.BandLeft.render(f5);
this.Shape1.render(f5);
this.Shape3.render(f5);
this.Shape2.render(f5);
this.BandLeft2.render(f5);
this.BandLeft3.render(f5);
this.BandLeft4.render(f5);
this.BandLeft5.render(f5);
this.BandLeft6.render(f5);
this.BandLeft7.render(f5);
this.BandLeft8.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}
| 5,285 | 0.644087 | 0.55667 | 123 | 41.96748 | 19.651407 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.382114 | false | false | 1 |
a4db3eed0a447a90898bc1c0e4705e5541e938d7 | 17,334,488,071,020 | 0bc2b46ac64795b3874131ee2e34feff2663b369 | /app/src/main/java/com/example/savageworldscompanionapp/TestActivity.java | 41b2810439230f8dd43cadb60e2d63a965ecdbf2 | []
| no_license | CodyGardner/SavageWorldsCompanionApp | https://github.com/CodyGardner/SavageWorldsCompanionApp | 2017f91dd62b162feae4b086037cc56a6da35751 | 0e0b4bd2b98b29a050437ac0dddd3b77ddbce2a6 | refs/heads/master | 2020-06-16T21:10:13.920000 | 2019-08-04T06:09:12 | 2019-08-04T06:09:12 | 195,704,750 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.savageworldscompanionapp;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import java.util.ArrayList;
public class TestActivity extends AppCompatActivity {
ArrayList<Attribute> attrs;
ArrayList<EditAttributeListItem> attrListItems;
RecyclerView recyclerView;
RecyclerView.Adapter adapter;
RecyclerView.LayoutManager layoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
attrs = new ArrayList<>();
attrListItems = new ArrayList<>();
attrs.add(new Attribute(getString(R.string.attrAg), getString(R.string.attrAgShort)));
attrs.add(new Attribute(getString(R.string.attrSm), getString(R.string.attrSmShort)));
attrs.add(new Attribute(getString(R.string.attrSp), getString(R.string.attrSpShort)));
attrs.add(new Attribute(getString(R.string.attrSt), getString(R.string.attrStShort)));
attrs.add(new Attribute(getString(R.string.attrVi), getString(R.string.attrViShort)));
for (int i = 0; i < attrs.size(); ++i)
attrListItems.add(new EditAttributeListItem(attrs.get(i)));
recyclerView = findViewById(R.id.AttributeRecyclerView);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
adapter = new EditAttributeAdapter(attrListItems);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
}
}
| UTF-8 | Java | 1,677 | java | TestActivity.java | Java | []
| null | []
| package com.example.savageworldscompanionapp;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import java.util.ArrayList;
public class TestActivity extends AppCompatActivity {
ArrayList<Attribute> attrs;
ArrayList<EditAttributeListItem> attrListItems;
RecyclerView recyclerView;
RecyclerView.Adapter adapter;
RecyclerView.LayoutManager layoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
attrs = new ArrayList<>();
attrListItems = new ArrayList<>();
attrs.add(new Attribute(getString(R.string.attrAg), getString(R.string.attrAgShort)));
attrs.add(new Attribute(getString(R.string.attrSm), getString(R.string.attrSmShort)));
attrs.add(new Attribute(getString(R.string.attrSp), getString(R.string.attrSpShort)));
attrs.add(new Attribute(getString(R.string.attrSt), getString(R.string.attrStShort)));
attrs.add(new Attribute(getString(R.string.attrVi), getString(R.string.attrViShort)));
for (int i = 0; i < attrs.size(); ++i)
attrListItems.add(new EditAttributeListItem(attrs.get(i)));
recyclerView = findViewById(R.id.AttributeRecyclerView);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
adapter = new EditAttributeAdapter(attrListItems);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
}
}
| 1,677 | 0.731664 | 0.731067 | 43 | 38 | 29.678118 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.790698 | false | false | 1 |
88a4e5b50c4ed74d2c25ef28c15c2b04d6238c0a | 24,764,781,492,803 | eff08ecbf9fb9800db9c48a3e331286881d72c56 | /src/main/java/org/gtri/arfam/acs/data/UserInsert.java | 659a17a43f4918f66f41211ce06f177f246d7c90 | []
| no_license | drewctaylor/fpinjava | https://github.com/drewctaylor/fpinjava | 63a1fb35faf04dd0b0e1872c4f5d91968f6d127f | bcb431b2571bc0487f355d88268dac7dcd7508e2 | refs/heads/master | 2018-01-08T23:50:43.242000 | 2016-03-25T15:00:30 | 2016-03-25T15:00:30 | 54,511,303 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.gtri.arfam.acs.data;
import fj.data.NonEmptyList;
import fj.data.Validation;
import org.gtri.framework.Operation;
public class UserInsert implements Operation<Validation<NonEmptyList<Error>, User>> {
public final User user;
public UserInsert(User user) {
this.user = user;
}
}
| UTF-8 | Java | 313 | java | UserInsert.java | Java | []
| null | []
| package org.gtri.arfam.acs.data;
import fj.data.NonEmptyList;
import fj.data.Validation;
import org.gtri.framework.Operation;
public class UserInsert implements Operation<Validation<NonEmptyList<Error>, User>> {
public final User user;
public UserInsert(User user) {
this.user = user;
}
}
| 313 | 0.731629 | 0.731629 | 14 | 21.357143 | 22.607227 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 1 |
27eb42377fc59afa4836b8da649aab8e9f2fab64 | 33,105,607,984,561 | af2834154e49517d21dc80802ead6f5802562f66 | /src/runMain.java | 01df1234ca0e71e092a008f77b8923ad53b53754 | []
| no_license | AndriMar/TrainStationWeb | https://github.com/AndriMar/TrainStationWeb | 6fed37676f66680ffdff7e2fd99fef52325743a0 | 0d33e0f2ca9a8121b45bc77a9735e221463a8fa1 | refs/heads/master | 2021-01-02T23:14:00.498000 | 2010-12-11T17:23:16 | 2010-12-11T17:23:16 | 1,157,552 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Created by IntelliJ IDEA.
* User: Andri
* Date: 12/9/10
* Time: 11:05 PM
* To change this template use File | Settings | File Templates.
*/
public class runMain {
public static void main(String[] args) {
businessLogic BL = new businessLogic();
BL.createUser("Andri Mar Björgvinsson","andri","andri","0408823919");
}
}
| UTF-8 | Java | 359 | java | runMain.java | Java | [
{
"context": "/**\n * Created by IntelliJ IDEA.\n * User: Andri\n * Date: 12/9/10\n * Time: 11:05 PM\n * To change t",
"end": 47,
"score": 0.9997369050979614,
"start": 42,
"tag": "NAME",
"value": "Andri"
},
{
"context": " BL = new businessLogic();\n BL.createUser(\"Andri Mar Björgvinsson\",\"andri\",\"andri\",\"0408823919\");\n\n\n }\n}\n",
"end": 315,
"score": 0.9998576641082764,
"start": 293,
"tag": "NAME",
"value": "Andri Mar Björgvinsson"
},
{
"context": ";\n BL.createUser(\"Andri Mar Björgvinsson\",\"andri\",\"andri\",\"0408823919\");\n\n\n }\n}\n",
"end": 323,
"score": 0.8512997031211853,
"start": 318,
"tag": "NAME",
"value": "andri"
},
{
"context": " BL.createUser(\"Andri Mar Björgvinsson\",\"andri\",\"andri\",\"0408823919\");\n\n\n }\n}\n",
"end": 331,
"score": 0.9044921398162842,
"start": 326,
"tag": "NAME",
"value": "andri"
}
]
| null | []
| /**
* Created by IntelliJ IDEA.
* User: Andri
* Date: 12/9/10
* Time: 11:05 PM
* To change this template use File | Settings | File Templates.
*/
public class runMain {
public static void main(String[] args) {
businessLogic BL = new businessLogic();
BL.createUser("<NAME>","andri","andri","0408823919");
}
}
| 342 | 0.636872 | 0.583799 | 17 | 20.058823 | 23.493355 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.411765 | false | false | 1 |
fbdc007eb1d24e022777ea5e4faeb72efe9ff569 | 33,217,277,128,060 | 0f3bf97595ca48518040c82608926a82a2d69e8d | /mogu_base/src/main/java/com/moxi/mougblog/base/global/BaseMessageConf.java | 51f3be81c7a21dce652a616762d673f345bb3711 | [
"Apache-2.0"
]
| permissive | mzxssg/mogu_blog_v2 | https://github.com/mzxssg/mogu_blog_v2 | 855d37b7cf559aa225bd50223cc5a6b3c13d29e3 | 1c2d1f5896ac546e3c1647fdfafbec6ed457d9be | refs/heads/master | 2020-12-13T17:54:15.519000 | 2020-02-09T03:39:35 | 2020-02-09T03:39:35 | 234,487,905 | 1 | 0 | Apache-2.0 | true | 2020-01-17T06:43:35 | 2020-01-17T06:43:35 | 2020-01-17T06:21:06 | 2020-01-17T06:21:04 | 18,345 | 0 | 0 | 0 | null | false | false | package com.moxi.mougblog.base.global;
/**
* 消息通知
*
* @author: 陌溪
* @create: 2019-12-29-20:16
*/
public class BaseMessageConf {
public static final String OPERATION_SUCCESS = "操作成功";
public static final String OPERATION_FAIL = "操作失败";
public static final String INSERT_SUCCESS = "插入成功";
public static final String INSERT_FAIL = "插入失败";
public static final String UPDATE_SUCCESS = "更新成功";
public static final String UPDATE_FAIL = "更新失败";
public static final String DELETE_SUCCESS = "删除成功";
public static final String DELETE_FAIL = "删除失败";
public static final String ENTITY_EXIST = "该实体已存在";
public static final String LOGIN_DISABLE = "该账号已被封禁";
public static final String LOGIN_ERROR = "登录失败,用户名或密码错误";
public static final String NO_ROLE = "没有分配角色权限";
public static final String INTERFACE_FREQUENTLY = "接口过于频繁调用";
public static final String PARAM_INCORRECT = "传入参数有误!";
public final static String INVALID_TOKEN = "token令牌未被识别";
public static final String DATA_NO_PRIVILEGE = "该数据无权限访问";
public static final String ACCESS_NO_PRIVILEGE = "该资源无权限访问";
public static final String LOGIN_TIMEOUT = "您已退出,请重新登录";
}
| UTF-8 | Java | 1,425 | java | BaseMessageConf.java | Java | [
{
"context": "mougblog.base.global;\n\n/**\n * 消息通知\n *\n * @author: 陌溪\n * @create: 2019-12-29-20:16\n */\npublic class Bas",
"end": 69,
"score": 0.9996681213378906,
"start": 67,
"tag": "NAME",
"value": "陌溪"
}
]
| null | []
| package com.moxi.mougblog.base.global;
/**
* 消息通知
*
* @author: 陌溪
* @create: 2019-12-29-20:16
*/
public class BaseMessageConf {
public static final String OPERATION_SUCCESS = "操作成功";
public static final String OPERATION_FAIL = "操作失败";
public static final String INSERT_SUCCESS = "插入成功";
public static final String INSERT_FAIL = "插入失败";
public static final String UPDATE_SUCCESS = "更新成功";
public static final String UPDATE_FAIL = "更新失败";
public static final String DELETE_SUCCESS = "删除成功";
public static final String DELETE_FAIL = "删除失败";
public static final String ENTITY_EXIST = "该实体已存在";
public static final String LOGIN_DISABLE = "该账号已被封禁";
public static final String LOGIN_ERROR = "登录失败,用户名或密码错误";
public static final String NO_ROLE = "没有分配角色权限";
public static final String INTERFACE_FREQUENTLY = "接口过于频繁调用";
public static final String PARAM_INCORRECT = "传入参数有误!";
public final static String INVALID_TOKEN = "token令牌未被识别";
public static final String DATA_NO_PRIVILEGE = "该数据无权限访问";
public static final String ACCESS_NO_PRIVILEGE = "该资源无权限访问";
public static final String LOGIN_TIMEOUT = "您已退出,请重新登录";
}
| 1,425 | 0.710194 | 0.700084 | 31 | 37.290321 | 25.10005 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.612903 | false | false | 1 |
9d361ffb38957e101fe3d7fd7fb13180ce24cb5c | 33,389,075,823,178 | 695140488747c4e8a3e038d549f5cc9a90cafdca | /src/main/java/net/earthcomputer/multiconnect/protocols/v1_13_2/mixin/ChunkSectionAccessor.java | 9533595c7691219f452672a56364668ea4f4b0f6 | [
"MIT"
]
| permissive | hYdos/multiconnect | https://github.com/hYdos/multiconnect | 6c3a1afba5fea996b1642f22ebb888bf9e84d687 | 56d1332bb9d550c260f768015e62fbd8470d962d | refs/heads/master | 2020-12-23T14:52:59.315000 | 2020-08-31T12:53:19 | 2020-08-31T12:53:19 | 237,183,464 | 0 | 0 | MIT | true | 2020-01-30T09:51:38 | 2020-01-30T09:51:37 | 2020-01-29T15:26:08 | 2020-01-22T00:30:10 | 580 | 0 | 0 | 0 | null | false | false | package net.earthcomputer.multiconnect.protocols.v1_13_2.mixin;
import net.earthcomputer.multiconnect.impl.MixinHelper;
import net.minecraft.block.BlockState;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.Palette;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ChunkSection.class)
public interface ChunkSectionAccessor {
@Accessor
static Palette<BlockState> getPalette() {
return MixinHelper.fakeInstance();
}
}
| UTF-8 | Java | 519 | java | ChunkSectionAccessor.java | Java | []
| null | []
| package net.earthcomputer.multiconnect.protocols.v1_13_2.mixin;
import net.earthcomputer.multiconnect.impl.MixinHelper;
import net.minecraft.block.BlockState;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.Palette;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ChunkSection.class)
public interface ChunkSectionAccessor {
@Accessor
static Palette<BlockState> getPalette() {
return MixinHelper.fakeInstance();
}
}
| 519 | 0.797688 | 0.789981 | 16 | 31.4375 | 20.291527 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 1 |
7d5bc789a61a22927736334db81f7bf155dfdd39 | 33,389,075,822,538 | 67a90cb1da56e3a9b6eb85e6a52381a73aa7cbd0 | /src/main/java/com/db2g/Projetdb2g/Service/CongesService.java | aee3a4562ab444ea1e0e00fb2d315554789da88d | []
| no_license | IbrahimaDiaw/GestionPersonnelle | https://github.com/IbrahimaDiaw/GestionPersonnelle | 5b668fcce0d86ad5fa35b2d4aebcab82d7490601 | e125a955b157c10ec84eaa917b36d5417adb15e7 | refs/heads/master | 2023-03-17T23:16:08.765000 | 2021-03-10T15:52:41 | 2021-03-10T15:52:41 | 346,407,676 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.db2g.Projetdb2g.Service;
import java.util.List;
import java.util.Optional;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Service;
import com.db2g.Projetdb2g.model.Conges;
/**
* @author ibrahima
*
*/
@Service
public interface CongesService{
public List<Conges> listeConges();
public Optional<Conges> detailConges(ObjectId id);
public void sauvegardeConges(Conges conges);
public void supprimerConges(ObjectId id);
public Conges get(ObjectId id);
}
| UTF-8 | Java | 497 | java | CongesService.java | Java | [
{
"context": "t com.db2g.Projetdb2g.model.Conges;\n/**\n * @author ibrahima\n *\n */\n@Service\npublic interface CongesService{\n\t",
"end": 233,
"score": 0.9990688562393188,
"start": 225,
"tag": "USERNAME",
"value": "ibrahima"
}
]
| null | []
| package com.db2g.Projetdb2g.Service;
import java.util.List;
import java.util.Optional;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Service;
import com.db2g.Projetdb2g.model.Conges;
/**
* @author ibrahima
*
*/
@Service
public interface CongesService{
public List<Conges> listeConges();
public Optional<Conges> detailConges(ObjectId id);
public void sauvegardeConges(Conges conges);
public void supprimerConges(ObjectId id);
public Conges get(ObjectId id);
}
| 497 | 0.780684 | 0.772636 | 23 | 20.608696 | 17.953417 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.73913 | false | false | 1 |
287babbebdeb645beada01c0aded95bfebeccd05 | 19,353,122,676,645 | 532a381c1686b69dc0d8b093fe3abf6c6a36e52f | /src/main/java/com/robsonapsilva/security/WebSecurityConfig.java | 4ef9760154cc13689a257ed0e8f05da5758aa8ee | []
| no_license | robsonapsilva/spring-auth-jwt | https://github.com/robsonapsilva/spring-auth-jwt | 41c9f487423b53edac2692d7fd04d86f908c9d7e | 760b189f8860d01e172ebb90b2e16b0beaf60892 | refs/heads/master | 2020-01-09T08:05:31.660000 | 2017-04-23T21:51:45 | 2017-04-23T21:51:45 | 70,107,400 | 0 | 0 | null | false | 2016-10-13T04:56:11 | 2016-10-05T23:24:45 | 2016-10-13T04:28:47 | 2016-10-13T04:56:09 | 5 | 0 | 0 | 0 | Java | null | null | package com.robsonapsilva.security;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import com.robsonapsilva.service.LoginService;
/**
* Class to configure spring security to implement JWT-base authentication and
* other configuration as regards to security
*
* @author robsonapsilva
*
*/
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private StatelessAuthenticationFilter statelessAuthenticationFilter;
@Autowired
private JwtAuthenticationSuccessHandler jwtAuthenticationSuccessHandler;
@Autowired
private JwtAuthenticationFailureHandler jwtAuthenticationFailureHandler;
@Autowired
private LoginService loginService;
/**
* Disable custom configuration of Spring Security
*/
public WebSecurityConfig() {
super(true);
}
/**
* configure security for JWT-based authentication
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
this.filter(http);
this.formLogin(http);
this.authorizeRequests(http);
this.sessionManagment(http);
}
/**
* Configure filter to implement JWT-base authentication
*
* @param http
* HttpSecurity class to configure filter
* @throws Exception
*/
private void filter(HttpSecurity http) throws Exception {
http.addFilterBefore(statelessAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
}
/**
* Configure form login to implement JWT-base authentication
*
* @param http
* HttpSecurity class to configure form login
* @throws Exception
*/
private void formLogin(HttpSecurity http) throws Exception {
http.formLogin().loginProcessingUrl("/login").successHandler(jwtAuthenticationSuccessHandler)
.failureHandler(jwtAuthenticationFailureHandler);
}
/**
* Configure authorizeRequests
*
* @param http
* HttpSecurity class to configure authorize requests
* @throws Exception
*/
private void authorizeRequests(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/login").permitAll();
}
/**
* Configure session management.
*
* @param http
* HttpSecurity class to configure session management
* @throws Exception
*/
private void sessionManagment(HttpSecurity http) throws Exception {
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
/**
* Ignore all HttpMethod.OPTIONS requests
*/
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**");
}
/**
* Configure global authentication manager
*
* @param auth
* AuthenticationManagerBuilder class to configure global
* authentication manager, this configuration override
* configuration of spring security
* @throws Exception
*/
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(loginService).passwordEncoder(passwordEncoder());
}
/**
* Encode passwords with BCrypt, passwords must be in base64 before.
*
* @return
*/
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
| UTF-8 | Java | 4,308 | java | WebSecurityConfig.java | Java | [
{
"context": "onfiguration as regards to security\n * \n * @author robsonapsilva\n *\n */\n@Configuration\n@EnableWebSecurity\n@EnableG",
"end": 1334,
"score": 0.9992971420288086,
"start": 1321,
"tag": "USERNAME",
"value": "robsonapsilva"
}
]
| null | []
| package com.robsonapsilva.security;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import com.robsonapsilva.service.LoginService;
/**
* Class to configure spring security to implement JWT-base authentication and
* other configuration as regards to security
*
* @author robsonapsilva
*
*/
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private StatelessAuthenticationFilter statelessAuthenticationFilter;
@Autowired
private JwtAuthenticationSuccessHandler jwtAuthenticationSuccessHandler;
@Autowired
private JwtAuthenticationFailureHandler jwtAuthenticationFailureHandler;
@Autowired
private LoginService loginService;
/**
* Disable custom configuration of Spring Security
*/
public WebSecurityConfig() {
super(true);
}
/**
* configure security for JWT-based authentication
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
this.filter(http);
this.formLogin(http);
this.authorizeRequests(http);
this.sessionManagment(http);
}
/**
* Configure filter to implement JWT-base authentication
*
* @param http
* HttpSecurity class to configure filter
* @throws Exception
*/
private void filter(HttpSecurity http) throws Exception {
http.addFilterBefore(statelessAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
}
/**
* Configure form login to implement JWT-base authentication
*
* @param http
* HttpSecurity class to configure form login
* @throws Exception
*/
private void formLogin(HttpSecurity http) throws Exception {
http.formLogin().loginProcessingUrl("/login").successHandler(jwtAuthenticationSuccessHandler)
.failureHandler(jwtAuthenticationFailureHandler);
}
/**
* Configure authorizeRequests
*
* @param http
* HttpSecurity class to configure authorize requests
* @throws Exception
*/
private void authorizeRequests(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/login").permitAll();
}
/**
* Configure session management.
*
* @param http
* HttpSecurity class to configure session management
* @throws Exception
*/
private void sessionManagment(HttpSecurity http) throws Exception {
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
/**
* Ignore all HttpMethod.OPTIONS requests
*/
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**");
}
/**
* Configure global authentication manager
*
* @param auth
* AuthenticationManagerBuilder class to configure global
* authentication manager, this configuration override
* configuration of spring security
* @throws Exception
*/
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(loginService).passwordEncoder(passwordEncoder());
}
/**
* Encode passwords with BCrypt, passwords must be in base64 before.
*
* @return
*/
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
| 4,308 | 0.78273 | 0.782266 | 140 | 29.771429 | 30.6595 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.035714 | false | false | 1 |
90ef56299221da8538fb8cb8ed439a76d291dfa5 | 12,824,772,400,404 | 2974dd4e6fd3e0c0966934e5370727a7bbc19cdb | /src/com/potentialbatman/models/BasicPage.java | 06708ee5c2c5f06a54a6667eac428955d29c2dc5 | []
| no_license | tomelm/potential-batman-android | https://github.com/tomelm/potential-batman-android | 396da0b482cec4641dfa16a5be2fa574dd4c05f3 | bbdedf6568ed13775d372256d41d592d80d40567 | refs/heads/master | 2016-08-06T04:08:45.843000 | 2013-11-17T22:59:21 | 2013-11-17T22:59:21 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.potentialbatman.models;
import java.io.Serializable;
public interface BasicPage extends Serializable {
public String getHeading();
public String getContent();
}
| UTF-8 | Java | 177 | java | BasicPage.java | Java | []
| null | []
| package com.potentialbatman.models;
import java.io.Serializable;
public interface BasicPage extends Serializable {
public String getHeading();
public String getContent();
}
| 177 | 0.80226 | 0.80226 | 8 | 21.125 | 17.352503 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.75 | false | false | 1 |
b68eb25049c28590f54fadf63dab1116da3d1e3f | 3,908,420,299,555 | 4382147302d0472e1c4017bd407a86d6e38940da | /src/challenges/chromium2016/bracketSeq/SolutionTest.java | 88e1d32fbb5e5b89abe0aeb4fb1f25cdd3c3b71c | []
| no_license | augustjune/Codility | https://github.com/augustjune/Codility | 4ba3d697da93e51245125a9abbb2060d498307d8 | 5a8c4e84c8c51933663dd76e91617014a3c16928 | refs/heads/master | 2021-09-03T16:36:58.163000 | 2018-01-10T13:45:23 | 2018-01-10T13:45:23 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package challenges.chromium2016.bracketSeq;
import de.bechte.junit.runners.context.HierarchicalContextRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@RunWith(HierarchicalContextRunner.class)
public class SolutionTest {
private Solution solution;
@Before
public void setUp() {
solution = new Solution();
}
public class BracketSequenceValidation {
@Test
public void emptyString_isSeq() {
assertSeq("");
}
@Test
public void singleBracket_isNotSeq() {
assertNotSeq("(");
assertNotSeq(")");
}
@Test
public void doubleBrackets() {
assertSeq("()");
assertNotSeq(")(");
assertNotSeq("((");
assertNotSeq("))");
}
@Test
public void BracketSequenceValidation() {
assertSeq("((()()))");
assertSeq("(((())))");
assertSeq("(())(())");
assertNotSeq("((())(())");
}
private void assertNotSeq(String s) {
assertFalse(solution.isBracketSeq(s));
}
private void assertSeq(String s) {
assertTrue(solution.isBracketSeq(s));
}
}
}
| UTF-8 | Java | 1,154 | java | SolutionTest.java | Java | []
| null | []
| package challenges.chromium2016.bracketSeq;
import de.bechte.junit.runners.context.HierarchicalContextRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@RunWith(HierarchicalContextRunner.class)
public class SolutionTest {
private Solution solution;
@Before
public void setUp() {
solution = new Solution();
}
public class BracketSequenceValidation {
@Test
public void emptyString_isSeq() {
assertSeq("");
}
@Test
public void singleBracket_isNotSeq() {
assertNotSeq("(");
assertNotSeq(")");
}
@Test
public void doubleBrackets() {
assertSeq("()");
assertNotSeq(")(");
assertNotSeq("((");
assertNotSeq("))");
}
@Test
public void BracketSequenceValidation() {
assertSeq("((()()))");
assertSeq("(((())))");
assertSeq("(())(())");
assertNotSeq("((())(())");
}
private void assertNotSeq(String s) {
assertFalse(solution.isBracketSeq(s));
}
private void assertSeq(String s) {
assertTrue(solution.isBracketSeq(s));
}
}
}
| 1,154 | 0.661179 | 0.657712 | 60 | 18.233334 | 16.801157 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.55 | false | false | 1 |
9393ae11cb9b3ec67237b9c55a19e2594211b5a4 | 13,864,154,495,117 | cfa11455272d4de0a3113bc775a3bf2a461730bb | /w3school/narowcast.java | d686921f389cf43a00cc624de00ccf911b60b5ff | []
| no_license | hiteshshebe/java-practice | https://github.com/hiteshshebe/java-practice | 491d00baf3cbb805d2d2c82db6f6a74dc0a009b5 | 0669ddfd8cf5c275e467bb930b59e0faa8b83734 | refs/heads/master | 2022-12-19T03:07:53.601000 | 2020-09-30T19:47:25 | 2020-09-30T19:47:25 | 279,083,503 | 0 | 1 | null | false | 2020-09-30T19:47:27 | 2020-07-12T14:39:42 | 2020-08-17T18:33:32 | 2020-09-30T19:47:26 | 488 | 0 | 1 | 0 | Java | false | false | class Program
{
public static void main(String[] args)
{
double myDouble=9.86;
int myInt=(int)myDouble;//narrowing done via castiing testwho need to narrow.
System.out.println(myDouble);
System.out.println(myInt);
}
}
| UTF-8 | Java | 238 | java | narowcast.java | Java | []
| null | []
| class Program
{
public static void main(String[] args)
{
double myDouble=9.86;
int myInt=(int)myDouble;//narrowing done via castiing testwho need to narrow.
System.out.println(myDouble);
System.out.println(myInt);
}
}
| 238 | 0.697479 | 0.684874 | 18 | 12.222222 | 20.662783 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.833333 | false | false | 1 |
347e431ebc8bbb82b215e5c5a3535a56c0493a5f | 18,391,049,977,388 | 2567ea89d68943ec68d575dc05c703d6e53afe78 | /src/a2/Entity.java | f7a161d4deacba46b25a49f106676eb4163022de | []
| no_license | ivy33/a2 | https://github.com/ivy33/a2 | b9c4125fa3cd159adfac42b3619503acc2a9b321 | b1f7b5eb7a50f6077be75b6c9bdeb217a9929c66 | refs/heads/master | 2021-01-10T10:29:00.979000 | 2015-11-28T00:44:44 | 2015-11-28T00:44:44 | 46,999,516 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package a2;
public class Entity {
final static int SQUARE = 1;
final static int CIRCLE = 2;
final static int STRING = 3;
final static int IMAGE = 4;
private Object ent; // entity to paint (may be null)
private int type; // type of entity
private int x; // x coordinate for painting
private int y; // y coordinate for painting
Entity(Object entArg, int typeArg, int xArg, int yArg)
{
ent = entArg;
type = typeArg;
x = xArg;
y = yArg;
}
public Object getEntity()
{
return ent;
}
public int getType()
{
return type;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
} | UTF-8 | Java | 627 | java | Entity.java | Java | []
| null | []
| package a2;
public class Entity {
final static int SQUARE = 1;
final static int CIRCLE = 2;
final static int STRING = 3;
final static int IMAGE = 4;
private Object ent; // entity to paint (may be null)
private int type; // type of entity
private int x; // x coordinate for painting
private int y; // y coordinate for painting
Entity(Object entArg, int typeArg, int xArg, int yArg)
{
ent = entArg;
type = typeArg;
x = xArg;
y = yArg;
}
public Object getEntity()
{
return ent;
}
public int getType()
{
return type;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
} | 627 | 0.649123 | 0.641148 | 42 | 13.952381 | 15.324976 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.404762 | false | false | 1 |
b935774256d7b58a91312f143fd0261461e859c5 | 1,554,778,163,970 | a238889f32a732dc17fac40ca1e2e4efd30ddd52 | /src/mybeans/CustomerDetails.java | d251739cd2cf15e6cb1268e45536c79622d98886 | []
| no_license | JaswantsinghShekhawat007/E_Wallet | https://github.com/JaswantsinghShekhawat007/E_Wallet | da9aceb0dbb74fc147240a4193da0bf8f561c0dd | 5120e66c2c2d10870c8f6285d8cb2177ce859695 | refs/heads/master | 2023-06-11T06:15:23.556000 | 2021-07-07T05:55:57 | 2021-07-07T05:55:57 | 383,683,658 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package mybeans;
import java.sql.*;
public class CustomerDetails
{
private String userid;
private String name;
private String email;
private String mobileno;
private String secques;
private String secans;
private String dt;
private String walletid;
private String bankaccount;
private String balance;
public CustomerDetails()
{
userid="";
name="";
email="";
mobileno="";
secques="";
secans="";
dt="";
walletid="";
bankaccount="";
balance="";
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public String getMobileno() {
return mobileno;
}
public String getSecques() {
return secques;
}
public String getSecans() {
return secans;
}
public String getDt() {
return dt;
}
public String getWalletid() {
return walletid;
}
public String getBankaccount() {
return bankaccount;
}
public String getBalance() {
return balance;
}
public void setUserid(String userid) {
this.userid = userid;
getData();
}
private void getData()
{
Connection con;
PreparedStatement pst;
ResultSet rs;
try
{
DBConnector dbc = new DBConnector();
con=dbc.getDbconnection();
pst=con.prepareStatement("select * from usersdata where userid=?;");
pst.setString(1, userid);
rs=pst.executeQuery();
if(rs.next())
{
name=rs.getString("name");
email=rs.getString("email");
mobileno=rs.getString("mobileno");
secques=rs.getString("secquestion");
secans=rs.getString("secans");
dt=rs.getString("dt");
walletid=rs.getString("walletid");
bankaccount=rs.getString("bankaccount");
balance=rs.getString("balance");
}
con.close();
}
catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
}
}
}
| UTF-8 | Java | 1,817 | java | CustomerDetails.java | Java | []
| null | []
| package mybeans;
import java.sql.*;
public class CustomerDetails
{
private String userid;
private String name;
private String email;
private String mobileno;
private String secques;
private String secans;
private String dt;
private String walletid;
private String bankaccount;
private String balance;
public CustomerDetails()
{
userid="";
name="";
email="";
mobileno="";
secques="";
secans="";
dt="";
walletid="";
bankaccount="";
balance="";
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public String getMobileno() {
return mobileno;
}
public String getSecques() {
return secques;
}
public String getSecans() {
return secans;
}
public String getDt() {
return dt;
}
public String getWalletid() {
return walletid;
}
public String getBankaccount() {
return bankaccount;
}
public String getBalance() {
return balance;
}
public void setUserid(String userid) {
this.userid = userid;
getData();
}
private void getData()
{
Connection con;
PreparedStatement pst;
ResultSet rs;
try
{
DBConnector dbc = new DBConnector();
con=dbc.getDbconnection();
pst=con.prepareStatement("select * from usersdata where userid=?;");
pst.setString(1, userid);
rs=pst.executeQuery();
if(rs.next())
{
name=rs.getString("name");
email=rs.getString("email");
mobileno=rs.getString("mobileno");
secques=rs.getString("secquestion");
secans=rs.getString("secans");
dt=rs.getString("dt");
walletid=rs.getString("walletid");
bankaccount=rs.getString("bankaccount");
balance=rs.getString("balance");
}
con.close();
}
catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
}
}
}
| 1,817 | 0.654375 | 0.653825 | 115 | 14.8 | 13.630656 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.026087 | false | false | 1 |
c96b368f3a0fea79e0e4ef200bef5967f9355bb7 | 32,839,320,012,544 | 5631712ea9f2f16ceaed876ea85463449b14bd3b | /app/src/main/java/com/vmloft/develop/library/simple/widget/VMDotLineActivity.java | 8d37a7b4e6833fde55d8aa0d7c7374ad885320d0 | []
| no_license | xuepeng123/VMLibraryManager | https://github.com/xuepeng123/VMLibraryManager | d129bad0878cae00ec3682fae9744802082dd465 | e1fd732b9d4e1f2615a02b34b158f44aafbdd4bf | refs/heads/master | 2021-01-16T19:23:50.448000 | 2017-07-07T10:47:46 | 2017-07-07T10:47:46 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.vmloft.develop.library.simple.widget;
import android.graphics.Point;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.vmloft.develop.library.simple.R;
import com.vmloft.develop.library.tools.VMBaseActivity;
import com.vmloft.develop.library.tools.widget.VMDotLineView;
/**
* Created by lzan13 on 2017/3/22.
* 测试点线相连控件界面
*/
public class VMDotLineActivity extends VMBaseActivity {
private Button testBtn;
private VMDotLineView dotLineView;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dot_line);
dotLineView = (VMDotLineView) findViewById(R.id.view_dot_line);
findViewById(R.id.btn_big_dipper).setOnClickListener(viewListener);
findViewById(R.id.btn_square).setOnClickListener(viewListener);
findViewById(R.id.btn_dot_color).setOnClickListener(viewListener);
findViewById(R.id.btn_line_color).setOnClickListener(viewListener);
dotLineView.addPoint(new Point(100, 100));
dotLineView.addPoint(new Point(200, 200));
dotLineView.addPoint(new Point(400, 400));
dotLineView.addPoint(new Point(600, 600));
dotLineView.addPoint(new Point(600, 300));
dotLineView.addPoint(new Point(300, 600));
dotLineView.addPoint(new Point(300, 700));
dotLineView.addPoint(new Point(300, 400));
}
private View.OnClickListener viewListener = new View.OnClickListener() {
@Override public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_big_dipper:
drawBigDipper();
break;
case R.id.btn_square:
drawSquare();
break;
case R.id.btn_dot_color:
dotLineView.setDotColor(0xddfe8729);
break;
case R.id.btn_line_color:
dotLineView.setLineColor(0xddfe8729);
break;
}
dotLineView.refresh();
}
};
/**
* 绘制北斗七星
*/
private void drawBigDipper() {
dotLineView.clearPoints();
dotLineView.setClosure( false);
dotLineView.addPoint(new Point(100, 100));
dotLineView.addPoint(new Point(300, 150));
dotLineView.addPoint(new Point(390, 250));
dotLineView.addPoint(new Point(500, 360));
dotLineView.addPoint(new Point(495, 475));
dotLineView.addPoint(new Point(710, 550));
dotLineView.addPoint(new Point(790, 410));
}
/**
* 绘制正方形
*/
private void drawSquare() {
dotLineView.clearPoints();
dotLineView.setClosure(true);
dotLineView.addPoint(new Point(200, 200));
dotLineView.addPoint(new Point(600, 200));
dotLineView.addPoint(new Point(600, 600));
dotLineView.addPoint(new Point(200, 600));
}
}
| UTF-8 | Java | 3,037 | java | VMDotLineActivity.java | Java | [
{
"context": "ary.tools.widget.VMDotLineView;\n\n/**\n * Created by lzan13 on 2017/3/22.\n * 测试点线相连控件界面\n */\npublic class VMDo",
"end": 351,
"score": 0.9993550181388855,
"start": 345,
"tag": "USERNAME",
"value": "lzan13"
}
]
| null | []
| package com.vmloft.develop.library.simple.widget;
import android.graphics.Point;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.vmloft.develop.library.simple.R;
import com.vmloft.develop.library.tools.VMBaseActivity;
import com.vmloft.develop.library.tools.widget.VMDotLineView;
/**
* Created by lzan13 on 2017/3/22.
* 测试点线相连控件界面
*/
public class VMDotLineActivity extends VMBaseActivity {
private Button testBtn;
private VMDotLineView dotLineView;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dot_line);
dotLineView = (VMDotLineView) findViewById(R.id.view_dot_line);
findViewById(R.id.btn_big_dipper).setOnClickListener(viewListener);
findViewById(R.id.btn_square).setOnClickListener(viewListener);
findViewById(R.id.btn_dot_color).setOnClickListener(viewListener);
findViewById(R.id.btn_line_color).setOnClickListener(viewListener);
dotLineView.addPoint(new Point(100, 100));
dotLineView.addPoint(new Point(200, 200));
dotLineView.addPoint(new Point(400, 400));
dotLineView.addPoint(new Point(600, 600));
dotLineView.addPoint(new Point(600, 300));
dotLineView.addPoint(new Point(300, 600));
dotLineView.addPoint(new Point(300, 700));
dotLineView.addPoint(new Point(300, 400));
}
private View.OnClickListener viewListener = new View.OnClickListener() {
@Override public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_big_dipper:
drawBigDipper();
break;
case R.id.btn_square:
drawSquare();
break;
case R.id.btn_dot_color:
dotLineView.setDotColor(0xddfe8729);
break;
case R.id.btn_line_color:
dotLineView.setLineColor(0xddfe8729);
break;
}
dotLineView.refresh();
}
};
/**
* 绘制北斗七星
*/
private void drawBigDipper() {
dotLineView.clearPoints();
dotLineView.setClosure( false);
dotLineView.addPoint(new Point(100, 100));
dotLineView.addPoint(new Point(300, 150));
dotLineView.addPoint(new Point(390, 250));
dotLineView.addPoint(new Point(500, 360));
dotLineView.addPoint(new Point(495, 475));
dotLineView.addPoint(new Point(710, 550));
dotLineView.addPoint(new Point(790, 410));
}
/**
* 绘制正方形
*/
private void drawSquare() {
dotLineView.clearPoints();
dotLineView.setClosure(true);
dotLineView.addPoint(new Point(200, 200));
dotLineView.addPoint(new Point(600, 200));
dotLineView.addPoint(new Point(600, 600));
dotLineView.addPoint(new Point(200, 600));
}
}
| 3,037 | 0.627045 | 0.582638 | 89 | 32.651684 | 22.465004 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.775281 | false | false | 1 |
2c4616b22406b50787f8a86b9be99b4e90cd9b5b | 28,518,582,912,090 | bf1da22d478c001f4e46680ff5c2a740241c0c04 | /src/test/java/au/com/charleswu/wechatbot/WechatbotApplicationTests.java | b30aef9ba3ed153be629a2835a9d1077480aaa76 | []
| no_license | Charles-Wu-Chen/wechatbot-refactor | https://github.com/Charles-Wu-Chen/wechatbot-refactor | 85b4458ac4241cb76083189350c239ccaec9cbe1 | 6a74e58f067f22e16892ee76a8e90be0555c515e | refs/heads/main | 2023-04-17T06:20:23.538000 | 2021-04-29T01:41:33 | 2021-04-29T01:41:33 | 335,595,868 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package au.com.charleswu.wechatbot;
import au.com.charleswu.wechatbot.adaptor.in.web.MessageController;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest
@ActiveProfiles("test")
class WechatbotApplicationTests {
@Autowired
private MessageController controller;
@Test
public void contextLoads() throws Exception {
assertThat(controller).isNotNull();
}
}
| UTF-8 | Java | 605 | java | WechatbotApplicationTests.java | Java | []
| null | []
| package au.com.charleswu.wechatbot;
import au.com.charleswu.wechatbot.adaptor.in.web.MessageController;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest
@ActiveProfiles("test")
class WechatbotApplicationTests {
@Autowired
private MessageController controller;
@Test
public void contextLoads() throws Exception {
assertThat(controller).isNotNull();
}
}
| 605 | 0.821488 | 0.821488 | 23 | 25.304348 | 23.585985 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.695652 | false | false | 1 |
252e9a974b1cd129b888b62719fc87a616a8b9a1 | 34,170,759,809,075 | 9f7994ed0b8caa3014c0b6254d5ccfaeb97dafd4 | /tags/2.0.1/maven-php-dependency/src/main/java/org/phpmaven/dependency/IActionExtractAndInclude.java | f16cd19b333f1d979de5c907d5756969e9f4e879 | [
"Apache-2.0"
]
| permissive | tomask-de/maven-php-plugin | https://github.com/tomask-de/maven-php-plugin | fe830c742d4cc980094531358c215ecb063aa814 | 5bcf36c6d66ff3aa18a11968c79d18eec4164aeb | refs/heads/master | 2021-01-18T09:04:20.028000 | 2012-08-04T09:10:41 | 2013-06-20T16:48:01 | 4,183,438 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Copyright 2010-2012 by PHP-maven.org
*
* 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.phpmaven.dependency;
/**
* A php dependency configuration.
*
* <p>If you do not provide additional configuration this action behaves the same as classic action.
* You can specify a relative path inside the phar file or an alternative path (or both). The
* include path is relative to target path. Example:</p>
*
* <pre>
* <actions><br />
* <extract><br />
* <pharPath>/my/local/path/inside/phar</pharPath><br />
* <targetPath>${project.build.directory}/anotherPath</targetPath><br />
* <includePath>/special</includePath><br />
* </extract><br />
* </actions><br />
* </pre>
*
* <p>This example will extract the "/my/local/path/inside/phar" into the "target/anotherPath" folder and
* will add "target/anotherPath/special" onto php include path.</p>
*
* @author Martin Eisengardt <Martin.Eisengardt@googlemail.com>
* @since 2.0.1
*/
public interface IActionExtractAndInclude extends IAction {
/**
* Returns the local path inside the phar file
*
* @return local path.
*/
String getPharPath();
/**
* Returns the target path
*
* @return target path.
*/
String getTargetPath();
/**
* Returns the include path
*
* @return target path.
*/
String getIncludePath();
}
| UTF-8 | Java | 2,174 | java | IActionExtractAndInclude.java | Java | [
{
"context": "ecial\" onto php include path.</p>\r\n * \r\n * @author Martin Eisengardt <Martin.Eisengardt@googlemail.com>\r\n * @since 2.0",
"end": 1673,
"score": 0.9998189806938171,
"start": 1656,
"tag": "NAME",
"value": "Martin Eisengardt"
},
{
"context": "ude path.</p>\r\n * \r\n * @author Martin Eisengardt <Martin.Eisengardt@googlemail.com>\r\n * @since 2.0.1\r\n */\r\npublic interface IActionE",
"end": 1707,
"score": 0.9999332427978516,
"start": 1675,
"tag": "EMAIL",
"value": "Martin.Eisengardt@googlemail.com"
}
]
| null | []
| /**
* Copyright 2010-2012 by PHP-maven.org
*
* 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.phpmaven.dependency;
/**
* A php dependency configuration.
*
* <p>If you do not provide additional configuration this action behaves the same as classic action.
* You can specify a relative path inside the phar file or an alternative path (or both). The
* include path is relative to target path. Example:</p>
*
* <pre>
* <actions><br />
* <extract><br />
* <pharPath>/my/local/path/inside/phar</pharPath><br />
* <targetPath>${project.build.directory}/anotherPath</targetPath><br />
* <includePath>/special</includePath><br />
* </extract><br />
* </actions><br />
* </pre>
*
* <p>This example will extract the "/my/local/path/inside/phar" into the "target/anotherPath" folder and
* will add "target/anotherPath/special" onto php include path.</p>
*
* @author <NAME> <<EMAIL>>
* @since 2.0.1
*/
public interface IActionExtractAndInclude extends IAction {
/**
* Returns the local path inside the phar file
*
* @return local path.
*/
String getPharPath();
/**
* Returns the target path
*
* @return target path.
*/
String getTargetPath();
/**
* Returns the include path
*
* @return target path.
*/
String getIncludePath();
}
| 2,138 | 0.653634 | 0.646734 | 66 | 30.939394 | 31.463243 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.742424 | false | false | 1 |
e4b33d39d8a622d568fe485969132aa7056dd466 | 8,701,603,812,159 | 9ae5965121f143fa5a5781b413d686311b734a2c | /src/main/java/com/xceptance/xlt/api/engine/DataSetIndex.java | 54eb69ed7a4677d3287df654cb6f8862fb05889c | [
"EPL-2.0",
"MIT",
"EPL-1.0",
"LGPL-2.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"MPL-2.0",
"CDDL-1.1",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause"
]
| permissive | andre-becker/XLT | https://github.com/andre-becker/XLT | 41395ec5b673193412b26df35cc64e05ac55c9b4 | 174f9f467ab3094bcdbf80bcea818134a9d1180a | refs/heads/master | 2022-04-21T09:20:03.443000 | 2020-03-12T09:48:41 | 2020-03-12T09:48:41 | 257,584,910 | 0 | 0 | Apache-2.0 | true | 2020-04-21T12:14:39 | 2020-04-21T12:14:38 | 2020-04-03T19:16:18 | 2020-04-21T11:15:47 | 69,595 | 0 | 0 | 0 | null | false | false | package com.xceptance.xlt.api.engine;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation to specify the index of the test data set that should be use for a run.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface DataSetIndex
{
int value() default -1;
}
| UTF-8 | Java | 420 | java | DataSetIndex.java | Java | []
| null | []
| package com.xceptance.xlt.api.engine;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation to specify the index of the test data set that should be use for a run.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface DataSetIndex
{
int value() default -1;
}
| 420 | 0.780952 | 0.778571 | 16 | 25.25 | 22.495832 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 1 |
5fcb15d035630fe45c3d4fd0a50f1478adeab703 | 3,667,902,072,513 | eb27f57346919f876eebc3b0e45e434f6221dd5e | /glaze-core/src/test/java/glaze/spi/TestRegistry.java | f661f825932a15a7ee88c3d0b3362ee4f862c777 | [
"Apache-2.0"
]
| permissive | mukesh-2013/glaze-http | https://github.com/mukesh-2013/glaze-http | 0f81d5bd74ae28bbc999dca365eea5cfd28f6c24 | 41fbf2f017b3fdb24d7b430cd68eed9fd50357a9 | refs/heads/master | 2020-03-19T11:15:40.193000 | 2013-07-28T18:31:40 | 2013-07-28T18:31:40 | 136,443,027 | 1 | 0 | null | true | 2018-06-07T08:01:00 | 2018-06-07T08:01:00 | 2015-11-04T22:44:45 | 2013-07-28T18:31:52 | 548 | 0 | 0 | 0 | null | false | null | package glaze.spi;
import glaze.client.sync.SyncClient;
import glaze.mime.ContentTypeEx;
import glaze.spi.Named;
import glaze.spi.Registry;
import glaze.spi.ServiceProvider;
import org.apache.http.entity.ContentType;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
public class TestRegistry
{
@Named("myapi")
private class MyProvider implements ServiceProvider<String>
{
@Override
public Class<String> serviceClass()
{
return String.class;
}
@Override
public String serviceImpl()
{
return "Hello";
}
}
@Test
public void init()
{
Assert.assertNotNull(Registry.lookup(SyncClient.class));
Assert.assertNotNull(Registry.lookupMapper(ContentType.APPLICATION_JSON));
Assert.assertNotNull(Registry.lookupMapper(ContentType.APPLICATION_JSON.getMimeType()));
}
@Test
public void namespace()
{
MyProvider stringProvider = new MyProvider();
Registry reg = Registry.getOrCreate(stringProvider);
reg.register(String.class, stringProvider.serviceImpl());
reg.logState();
Assert.assertEquals(reg.namespace(), "myapi");
Assert.assertEquals(Registry.lookup("myapi", String.class).toString(), "Hello");
Registry.reset();
}
@Test
public void register()
{
Registry registry = Registry.instance();
registry.register(String.class, "Hello");
Assert.assertEquals(registry.unregister(String.class), "Hello");
Assert.assertFalse(registry.isMapperRegistered(ContentTypeEx.SMILE));
Assert.assertTrue(registry.isMapperRegistered(ContentType.APPLICATION_JSON));
ObjectMapper mapper = new ObjectMapper();
registry.registerMapper("any/one", mapper);
Assert.assertEquals(registry.unregisterMapper("any/one"), mapper);
registry.registerMapper(ContentType.APPLICATION_SVG_XML, mapper);
Assert.assertEquals(registry.unregisterMapper(ContentType.APPLICATION_SVG_XML), mapper);
Registry.reset();
}
}
| UTF-8 | Java | 2,085 | java | TestRegistry.java | Java | []
| null | []
| package glaze.spi;
import glaze.client.sync.SyncClient;
import glaze.mime.ContentTypeEx;
import glaze.spi.Named;
import glaze.spi.Registry;
import glaze.spi.ServiceProvider;
import org.apache.http.entity.ContentType;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
public class TestRegistry
{
@Named("myapi")
private class MyProvider implements ServiceProvider<String>
{
@Override
public Class<String> serviceClass()
{
return String.class;
}
@Override
public String serviceImpl()
{
return "Hello";
}
}
@Test
public void init()
{
Assert.assertNotNull(Registry.lookup(SyncClient.class));
Assert.assertNotNull(Registry.lookupMapper(ContentType.APPLICATION_JSON));
Assert.assertNotNull(Registry.lookupMapper(ContentType.APPLICATION_JSON.getMimeType()));
}
@Test
public void namespace()
{
MyProvider stringProvider = new MyProvider();
Registry reg = Registry.getOrCreate(stringProvider);
reg.register(String.class, stringProvider.serviceImpl());
reg.logState();
Assert.assertEquals(reg.namespace(), "myapi");
Assert.assertEquals(Registry.lookup("myapi", String.class).toString(), "Hello");
Registry.reset();
}
@Test
public void register()
{
Registry registry = Registry.instance();
registry.register(String.class, "Hello");
Assert.assertEquals(registry.unregister(String.class), "Hello");
Assert.assertFalse(registry.isMapperRegistered(ContentTypeEx.SMILE));
Assert.assertTrue(registry.isMapperRegistered(ContentType.APPLICATION_JSON));
ObjectMapper mapper = new ObjectMapper();
registry.registerMapper("any/one", mapper);
Assert.assertEquals(registry.unregisterMapper("any/one"), mapper);
registry.registerMapper(ContentType.APPLICATION_SVG_XML, mapper);
Assert.assertEquals(registry.unregisterMapper(ContentType.APPLICATION_SVG_XML), mapper);
Registry.reset();
}
}
| 2,085 | 0.704556 | 0.704556 | 77 | 26.077923 | 27.088488 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.558442 | false | false | 1 |
d96a2b65367f8108439c83ef3eb27f1ee012b11a | 24,240,795,426,969 | 83b1876c2252c1cc4aa0f23591206619c0aab510 | /xc-service-manage-media/src/test/java/com/xuecheng/manage_media/TestFile.java | 68cfd547627a116fd083bcefac206e0de89f32a3 | []
| no_license | galaxy-fy/xc_ | https://github.com/galaxy-fy/xc_ | 37b2df81f8352dea05aab7121aea173b8b004462 | 8ebdc64d7cf813f1e86601cccbd182dcd88e6852 | refs/heads/master | 2022-03-03T03:43:59.609000 | 2019-08-22T10:08:51 | 2019-08-22T10:08:52 | 203,762,301 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xuecheng.manage_media;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
*
*/
public class TestFile {
/**
* 测试文件分块方法
*
* @throws IOException
*/
@Test
public void testcChunk() throws IOException {
//源文件
File sourceFile = new File("F:\\develop\\video\\lucene.avi");
//块文件目录
String chunkFileFolder = "F:\\develop\\video\\chunks\\";
//定义块文件的大小
long chunkFileSize = 1 * 1024 * 1024;
//求出源文件的块数
long chunkFileNum = (long) Math.ceil(sourceFile.length() * 1.0 / chunkFileSize);
//创建读文件的对象,指定读取的文件,和方式 r:只读
RandomAccessFile raf_r = new RandomAccessFile(sourceFile, "r");
//创建一个字节数组(用于缓冲)
byte[] b = new byte[1024];
for (long i = 0; i < chunkFileNum; i++) {
//块文件
File chunkFile = new File(chunkFileFolder + i);
//创建向块文件的写对象
RandomAccessFile raf_w = new RandomAccessFile(chunkFile, "rw");
int len = -1;
while ((len = raf_r.read(b)) != -1) {
//还有内容
raf_w.write(b, 0, len);
//如果块文件的大小达到了1M,就进行下一次循环
if (chunkFile.length() >= chunkFileSize) {
break;
}
}
raf_w.close();
}
raf_r.close();
}
/**
* 合并文件
*/
@Test
public void testMergeFile() throws IOException {
//找到块文件的目录
File chunkFolder = new File("F:\\develop\\video\\chunks\\");
//合并文件
File mergeFile = new File("F:\\develop\\video\\lucene_merge.avi");
//对文件进行判断,存在删除后在创建
if (mergeFile.exists()) {
mergeFile.delete();
}
//创建新的合并文件
mergeFile.createNewFile();
//写文件
RandomAccessFile raf_w = new RandomAccessFile(mergeFile,"rw");
//指针指向文件顶端
raf_w.seek(0);
//缓冲区
byte[] b = new byte[1024];
//分块列表
File[] files = chunkFolder.listFiles();
//把数组转为集合,然后进行排序
List<File> fileList = Arrays.asList(files);
//从小到大排序
Collections.sort(fileList, new Comparator<File>() {
@Override
public int compare(File o1, File o2) {
if(Integer.parseInt(o1.getName())<Integer.parseInt(o2.getName())){
return -1;
}
return 1;
}
});
//合并文件
for (File chunkFile : fileList) {
RandomAccessFile raf_r=new RandomAccessFile(chunkFile,"rw");
int len = -1;
while ((len=raf_r.read(b))!=-1){
raf_w.write(b,0,len);
}
raf_r.close();
}
raf_w.close();
}
}
| UTF-8 | Java | 3,273 | java | TestFile.java | Java | []
| null | []
| package com.xuecheng.manage_media;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
*
*/
public class TestFile {
/**
* 测试文件分块方法
*
* @throws IOException
*/
@Test
public void testcChunk() throws IOException {
//源文件
File sourceFile = new File("F:\\develop\\video\\lucene.avi");
//块文件目录
String chunkFileFolder = "F:\\develop\\video\\chunks\\";
//定义块文件的大小
long chunkFileSize = 1 * 1024 * 1024;
//求出源文件的块数
long chunkFileNum = (long) Math.ceil(sourceFile.length() * 1.0 / chunkFileSize);
//创建读文件的对象,指定读取的文件,和方式 r:只读
RandomAccessFile raf_r = new RandomAccessFile(sourceFile, "r");
//创建一个字节数组(用于缓冲)
byte[] b = new byte[1024];
for (long i = 0; i < chunkFileNum; i++) {
//块文件
File chunkFile = new File(chunkFileFolder + i);
//创建向块文件的写对象
RandomAccessFile raf_w = new RandomAccessFile(chunkFile, "rw");
int len = -1;
while ((len = raf_r.read(b)) != -1) {
//还有内容
raf_w.write(b, 0, len);
//如果块文件的大小达到了1M,就进行下一次循环
if (chunkFile.length() >= chunkFileSize) {
break;
}
}
raf_w.close();
}
raf_r.close();
}
/**
* 合并文件
*/
@Test
public void testMergeFile() throws IOException {
//找到块文件的目录
File chunkFolder = new File("F:\\develop\\video\\chunks\\");
//合并文件
File mergeFile = new File("F:\\develop\\video\\lucene_merge.avi");
//对文件进行判断,存在删除后在创建
if (mergeFile.exists()) {
mergeFile.delete();
}
//创建新的合并文件
mergeFile.createNewFile();
//写文件
RandomAccessFile raf_w = new RandomAccessFile(mergeFile,"rw");
//指针指向文件顶端
raf_w.seek(0);
//缓冲区
byte[] b = new byte[1024];
//分块列表
File[] files = chunkFolder.listFiles();
//把数组转为集合,然后进行排序
List<File> fileList = Arrays.asList(files);
//从小到大排序
Collections.sort(fileList, new Comparator<File>() {
@Override
public int compare(File o1, File o2) {
if(Integer.parseInt(o1.getName())<Integer.parseInt(o2.getName())){
return -1;
}
return 1;
}
});
//合并文件
for (File chunkFile : fileList) {
RandomAccessFile raf_r=new RandomAccessFile(chunkFile,"rw");
int len = -1;
while ((len=raf_r.read(b))!=-1){
raf_w.write(b,0,len);
}
raf_r.close();
}
raf_w.close();
}
}
| 3,273 | 0.5115 | 0.499828 | 105 | 26.742857 | 21.063183 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.533333 | false | false | 1 |
095ec0a56158292885d06f9f3e54399f50010dcc | 24,687,472,030,848 | fb6a7519b549cd88bb19f5b5f06bc2e7e97f2fe7 | /src/main/java/com/weiqi/dota2/dota2apiwrapper/PersonaState.java | e526eb5b1960c6545f21e020f6c81ea411201ab8 | [
"MIT"
]
| permissive | weiqi1028/dota2apiwrapper | https://github.com/weiqi1028/dota2apiwrapper | 13bc74f030406ebd1e7ad63a2390e2c2ee1285a1 | 6646fba2d6f8cef808745a9b0b5432146ddb4671 | refs/heads/master | 2020-12-24T14:45:23.087000 | 2015-04-29T06:43:16 | 2015-04-29T06:43:16 | 34,709,443 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.weiqi.dota2.dota2apiwrapper;
public enum PersonaState {
OFFLINE(0), ONLINE(1), BUSY(2), AWAY(3), SNOOZE(4), LOOKING_TO_TRADE(5), LOOKING_TO_PLAY(6);
private int value;
private PersonaState(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
| UTF-8 | Java | 334 | java | PersonaState.java | Java | []
| null | []
| package com.weiqi.dota2.dota2apiwrapper;
public enum PersonaState {
OFFLINE(0), ONLINE(1), BUSY(2), AWAY(3), SNOOZE(4), LOOKING_TO_TRADE(5), LOOKING_TO_PLAY(6);
private int value;
private PersonaState(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
| 334 | 0.60479 | 0.577844 | 15 | 21.266666 | 23.887142 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.733333 | false | false | 1 |
d1c2f75c7c00d4b1568197fcdfd7ad9df95a328c | 1,623,497,677,314 | 51bf1b36d883e542b072b31e9212417511cb3e20 | /src/me/chiller/chatrooms/CrListener.java | a43e467aa4616d89c1de5c312fa26433ae5a993c | []
| no_license | TheChillerCraft/Chat-Rooms | https://github.com/TheChillerCraft/Chat-Rooms | 228556db8c4f8171cad6c09f727a8fe0e3bcc098 | 114cbe24b4d707f3e15d6c20e8dbc1f326e03ee6 | refs/heads/master | 2016-09-08T20:13:38 | 2015-08-28T18:18:35 | 2015-08-28T18:18:35 | 41,562,295 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package me.chiller.chatrooms;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
public class CrListener implements Listener
{
private ChatRooms cr;
public Map<Player, Location> clicks = new HashMap<Player, Location>();
public CrListener(ChatRooms plugin)
{
cr = plugin;
}
@EventHandler
public void onPlayerInteractEvent(final PlayerInteractEvent event)
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getItem() != null)
{
if (event.getItem().getType().equals(Material.STICK) && clicks.containsKey(event.getPlayer()) && event.getPlayer().hasPermission("chatrooms.create"))
{
if (clicks.get(event.getPlayer()) == null)
{
event.getPlayer().sendMessage(ChatColor.AQUA + "[ChatRooms] " + ChatColor.GOLD + "First point selected, now select the second");
clicks.put(event.getPlayer(), event.getClickedBlock().getLocation());
} else
{
Location fc = (Location) clicks.get(event.getPlayer());
Location sc = event.getClickedBlock().getLocation();
if (fc.getWorld().equals(sc.getWorld()))
{
cr.tChannel.put(event.getPlayer(), new ChatChannel("", fc, sc));
event.getPlayer().sendMessage(ChatColor.AQUA + "[ChatRooms] " + ChatColor.GOLD + "Second point selected, type /cr create <chatroom name>");
clicks.remove(event.getPlayer());
} else
{
event.getPlayer().sendMessage(ChatColor.AQUA + "[ChatRooms] " + ChatColor.GOLD + "The second point you selected was not in the same world as the first point");
}
}
}
}
}
@EventHandler(priority=EventPriority.HIGHEST)
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
{
if (cr.pChannel.containsKey(event.getPlayer()))
{
for (Player pl : event.getRecipients())
{
if (cr.pChannel.containsKey(pl))
{
if (((ChatChannel) cr.pChannel.get(pl)).equals(cr.pChannel.get(event.getPlayer())))
{
pl.sendMessage(cr.getConfig().getString("message-format").replaceAll("%chatroom%", ((ChatChannel) cr.pChannel.get(event.getPlayer())).getTitle()).replaceAll("%playername%", event.getPlayer().getDisplayName()).replaceAll("%message%", event.getMessage()));
}
}
}
} else
{
for (Player pl : event.getRecipients())
{
if (!cr.pChannel.containsKey(pl))
{
pl.sendMessage(cr.getConfig().getString("message-format").replaceAll("%chatroom%", "Global").replaceAll("%playername%", event.getPlayer().getDisplayName()).replaceAll("%message%", event.getMessage()));
}
}
}
event.setCancelled(true);
}
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent event)
{
Player player = event.getPlayer();
if (!player.hasPermission("chatrooms.nojoin"))
{
if (!cr.pChannel.containsKey(player))
{
for (ChatChannel cc : cr.oChannel.keySet())
{
if (cc.isLocInside(event.getTo()))
{
cr.pChannel.put(player, cc);
player.sendMessage(ChatColor.AQUA + "[ChatRooms] " + ChatColor.GOLD + "You have joined the " + cc.getTitle() + " Chat Room");
}
}
} else
{
ChatChannel cc = (ChatChannel) cr.pChannel.get(player);
if (!cc.isLocInside(event.getTo()))
{
cr.pChannel.remove(player);
player.sendMessage(ChatColor.AQUA + "[ChatRooms] " + ChatColor.GOLD + "You have left the " + cc.getTitle() + " Chat Room");
}
}
} else if (cr.pChannel.containsKey(player))
{
ChatChannel cc = (ChatChannel) cr.pChannel.get(player);
if (cc != null)
{
cr.pChannel.remove(player);
}
}
}
} | UTF-8 | Java | 4,062 | java | CrListener.java | Java | []
| null | []
| package me.chiller.chatrooms;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
public class CrListener implements Listener
{
private ChatRooms cr;
public Map<Player, Location> clicks = new HashMap<Player, Location>();
public CrListener(ChatRooms plugin)
{
cr = plugin;
}
@EventHandler
public void onPlayerInteractEvent(final PlayerInteractEvent event)
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getItem() != null)
{
if (event.getItem().getType().equals(Material.STICK) && clicks.containsKey(event.getPlayer()) && event.getPlayer().hasPermission("chatrooms.create"))
{
if (clicks.get(event.getPlayer()) == null)
{
event.getPlayer().sendMessage(ChatColor.AQUA + "[ChatRooms] " + ChatColor.GOLD + "First point selected, now select the second");
clicks.put(event.getPlayer(), event.getClickedBlock().getLocation());
} else
{
Location fc = (Location) clicks.get(event.getPlayer());
Location sc = event.getClickedBlock().getLocation();
if (fc.getWorld().equals(sc.getWorld()))
{
cr.tChannel.put(event.getPlayer(), new ChatChannel("", fc, sc));
event.getPlayer().sendMessage(ChatColor.AQUA + "[ChatRooms] " + ChatColor.GOLD + "Second point selected, type /cr create <chatroom name>");
clicks.remove(event.getPlayer());
} else
{
event.getPlayer().sendMessage(ChatColor.AQUA + "[ChatRooms] " + ChatColor.GOLD + "The second point you selected was not in the same world as the first point");
}
}
}
}
}
@EventHandler(priority=EventPriority.HIGHEST)
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
{
if (cr.pChannel.containsKey(event.getPlayer()))
{
for (Player pl : event.getRecipients())
{
if (cr.pChannel.containsKey(pl))
{
if (((ChatChannel) cr.pChannel.get(pl)).equals(cr.pChannel.get(event.getPlayer())))
{
pl.sendMessage(cr.getConfig().getString("message-format").replaceAll("%chatroom%", ((ChatChannel) cr.pChannel.get(event.getPlayer())).getTitle()).replaceAll("%playername%", event.getPlayer().getDisplayName()).replaceAll("%message%", event.getMessage()));
}
}
}
} else
{
for (Player pl : event.getRecipients())
{
if (!cr.pChannel.containsKey(pl))
{
pl.sendMessage(cr.getConfig().getString("message-format").replaceAll("%chatroom%", "Global").replaceAll("%playername%", event.getPlayer().getDisplayName()).replaceAll("%message%", event.getMessage()));
}
}
}
event.setCancelled(true);
}
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent event)
{
Player player = event.getPlayer();
if (!player.hasPermission("chatrooms.nojoin"))
{
if (!cr.pChannel.containsKey(player))
{
for (ChatChannel cc : cr.oChannel.keySet())
{
if (cc.isLocInside(event.getTo()))
{
cr.pChannel.put(player, cc);
player.sendMessage(ChatColor.AQUA + "[ChatRooms] " + ChatColor.GOLD + "You have joined the " + cc.getTitle() + " Chat Room");
}
}
} else
{
ChatChannel cc = (ChatChannel) cr.pChannel.get(player);
if (!cc.isLocInside(event.getTo()))
{
cr.pChannel.remove(player);
player.sendMessage(ChatColor.AQUA + "[ChatRooms] " + ChatColor.GOLD + "You have left the " + cc.getTitle() + " Chat Room");
}
}
} else if (cr.pChannel.containsKey(player))
{
ChatChannel cc = (ChatChannel) cr.pChannel.get(player);
if (cc != null)
{
cr.pChannel.remove(player);
}
}
}
} | 4,062 | 0.65485 | 0.65485 | 128 | 29.75 | 42.406513 | 260 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.007813 | false | false | 1 |
0ceba1e631c3daa6d075129cb591560c647ff7b0 | 31,284,541,784,551 | 5345259f82a8ec70f846b1d2ac4774c64328473f | /crnk-data/crnk-data-activiti/src/test/java/io/crnk/data/activiti/repository/ActivitiModuleTest.java | 7882da3e510a0c0b19b889d221226db41441e0c2 | [
"Apache-2.0"
]
| permissive | crnk-project/crnk-framework | https://github.com/crnk-project/crnk-framework | 3da60c2f99b97a0a70eb85217d06a49c10a21fe9 | 4e4dd8970d2bc1bb63970093e2049689d6189f30 | refs/heads/master | 2023-01-21T18:18:36.466000 | 2022-09-06T12:01:49 | 2022-10-06T04:39:08 | 91,683,656 | 300 | 199 | Apache-2.0 | false | 2023-01-12T08:23:38 | 2017-05-18T11:06:31 | 2023-01-10T22:47:58 | 2023-01-12T08:23:38 | 9,337 | 273 | 143 | 233 | Java | false | false | package io.crnk.data.activiti.repository;
import io.crnk.data.activiti.ActivitiModule;
import io.crnk.data.activiti.example.model.ApproveForm;
import io.crnk.data.activiti.example.model.ApproveTask;
import io.crnk.data.activiti.example.model.ScheduleApprovalProcessInstance;
import org.junit.Assert;
import org.junit.Test;
public class ActivitiModuleTest extends ActivitiTestBase {
@Test
public void checkGetRepositories() {
ActivitiModule module = boot.getModuleRegistry().getModule(ActivitiModule.class).get();
Assert.assertNotNull(module.getTaskRepository(ApproveTask.class));
Assert.assertNotNull(module.getFormRepository(ApproveForm.class));
Assert.assertNotNull(module.getProcessInstanceRepository(ScheduleApprovalProcessInstance.class));
}
}
| UTF-8 | Java | 798 | java | ActivitiModuleTest.java | Java | []
| null | []
| package io.crnk.data.activiti.repository;
import io.crnk.data.activiti.ActivitiModule;
import io.crnk.data.activiti.example.model.ApproveForm;
import io.crnk.data.activiti.example.model.ApproveTask;
import io.crnk.data.activiti.example.model.ScheduleApprovalProcessInstance;
import org.junit.Assert;
import org.junit.Test;
public class ActivitiModuleTest extends ActivitiTestBase {
@Test
public void checkGetRepositories() {
ActivitiModule module = boot.getModuleRegistry().getModule(ActivitiModule.class).get();
Assert.assertNotNull(module.getTaskRepository(ApproveTask.class));
Assert.assertNotNull(module.getFormRepository(ApproveForm.class));
Assert.assertNotNull(module.getProcessInstanceRepository(ScheduleApprovalProcessInstance.class));
}
}
| 798 | 0.795739 | 0.795739 | 21 | 37 | 33.577202 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.52381 | false | false | 1 |
6d1fa70a1d9aee3a0e6725b162615a5101874687 | 29,274,497,091,464 | 972bfb9cfe210de7bd5e614909ef71ccb051ec0f | /src/main/java/com/mapily/model/user/User.java | 0367a3d3700d91c47ca497b589ee3e2877c3c258 | []
| no_license | giacomomarciani/mapily | https://github.com/giacomomarciani/mapily | d5632c5f29c5ac1787b1b6e91ed447e98a1984eb | 06eb1ac6f73fa52b84ed644889882241e17416e9 | refs/heads/master | 2015-08-09T08:03:53.584000 | 2013-11-09T09:57:56 | 2013-11-09T09:57:56 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mapily.model.user;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GenerationType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import com.mapily.model.spot.Spot;
@Entity
@Table(name = "users")
public class User implements Serializable {
private static final long serialVersionUID = -7351729135012380019L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "user_id")
private Integer id;
@Column(name = "username", unique = true)
@Length(min = 3, max = 20)
@NotBlank
private String username;
@Column(name = "password")
@Length(min = 3, max = 20)
@NotBlank
private String password;
@Enumerated(EnumType.STRING)
@Column(name = "role", nullable = false)
@NotNull
private Role role;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "profile_id", nullable = false)
@ForeignKey(name = "fk_user_profile")
private UserProfile profile;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
private Set<Spot> spots = new HashSet<Spot>(0);
public User(String username, String password, Role role, UserProfile profile) {
this.setUsername(username);
this.setPassword(password);
this.setRole(role);
this.setProfile(profile);
}
public User(String username, String password, UserProfile profile) {
this.setUsername(username);
this.setPassword(password);
this.setProfile(profile);
}
public User(String username, String password, Role role) {
this.setUsername(username);
this.setPassword(password);
this.setRole(role);
}
public User(String username, String password) {
this.setUsername(username);
this.setPassword(password);
}
public User() {}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public Role getRole() {
return this.role;
}
public void setRole(Role role) {
this.role = role;
}
public UserProfile getProfile() {
return this.profile;
}
public void setProfile(UserProfile profile) {
this.profile = profile;
}
@Override
public String toString() {
return "User(" +
this.getUsername() + " " +
this.getPassword() + " " +
this.getRole().toString() + ")";
}
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return this.getUsername().equals(user.getUsername());
}
@Override
public int hashCode() {
return 13 * this.getUsername().hashCode();
}
}
| UTF-8 | Java | 3,533 | java | User.java | Java | [
{
"context": " role, UserProfile profile) {\r\n\t\tthis.setUsername(username);\r\n\t\tthis.setPassword(password);\r\n\t\tthis.setRole(",
"end": 1802,
"score": 0.9974431991577148,
"start": 1794,
"tag": "USERNAME",
"value": "username"
},
{
"context": "\t\tthis.setUsername(username);\r\n\t\tthis.setPassword(password);\r\n\t\tthis.setRole(role);\r\n\t\tthis.setProfile(profi",
"end": 1833,
"score": 0.9670270085334778,
"start": 1825,
"tag": "PASSWORD",
"value": "password"
},
{
"context": "sword, UserProfile profile) {\r\n\t\tthis.setUsername(username);\r\n\t\tthis.setPassword(password);\r\n\t\tthis.setProfi",
"end": 1994,
"score": 0.9852136969566345,
"start": 1986,
"tag": "USERNAME",
"value": "username"
},
{
"context": "\t\tthis.setUsername(username);\r\n\t\tthis.setPassword(password);\r\n\t\tthis.setProfile(profile);\r\n\t}\r\n\t\r\n\tpublic Us",
"end": 2025,
"score": 0.6837760210037231,
"start": 2017,
"tag": "PASSWORD",
"value": "password"
},
{
"context": "String password, Role role) {\r\n\t\tthis.setUsername(username);\r\n\t\tthis.setPassword(password);\r\n\t\tthis.setRole(",
"end": 2153,
"score": 0.996530294418335,
"start": 2145,
"tag": "USERNAME",
"value": "username"
},
{
"context": " username, String password) {\r\n\t\tthis.setUsername(username);\r\n\t\tthis.setPassword(password);\r\n\t}\r\n\t\r\n\tpublic ",
"end": 2295,
"score": 0.9956631064414978,
"start": 2287,
"tag": "USERNAME",
"value": "username"
},
{
"context": " setPassword(String password) {\r\n\t\tthis.password = password;\r\n\t}\r\n\t\r\n\tpublic Role getRole() {\r\n\t\treturn this.",
"end": 2751,
"score": 0.8676365613937378,
"start": 2743,
"tag": "PASSWORD",
"value": "password"
}
]
| null | []
| package com.mapily.model.user;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GenerationType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import com.mapily.model.spot.Spot;
@Entity
@Table(name = "users")
public class User implements Serializable {
private static final long serialVersionUID = -7351729135012380019L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "user_id")
private Integer id;
@Column(name = "username", unique = true)
@Length(min = 3, max = 20)
@NotBlank
private String username;
@Column(name = "password")
@Length(min = 3, max = 20)
@NotBlank
private String password;
@Enumerated(EnumType.STRING)
@Column(name = "role", nullable = false)
@NotNull
private Role role;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "profile_id", nullable = false)
@ForeignKey(name = "fk_user_profile")
private UserProfile profile;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
private Set<Spot> spots = new HashSet<Spot>(0);
public User(String username, String password, Role role, UserProfile profile) {
this.setUsername(username);
this.setPassword(<PASSWORD>);
this.setRole(role);
this.setProfile(profile);
}
public User(String username, String password, UserProfile profile) {
this.setUsername(username);
this.setPassword(<PASSWORD>);
this.setProfile(profile);
}
public User(String username, String password, Role role) {
this.setUsername(username);
this.setPassword(password);
this.setRole(role);
}
public User(String username, String password) {
this.setUsername(username);
this.setPassword(password);
}
public User() {}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = <PASSWORD>;
}
public Role getRole() {
return this.role;
}
public void setRole(Role role) {
this.role = role;
}
public UserProfile getProfile() {
return this.profile;
}
public void setProfile(UserProfile profile) {
this.profile = profile;
}
@Override
public String toString() {
return "User(" +
this.getUsername() + " " +
this.getPassword() + " " +
this.getRole().toString() + ")";
}
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return this.getUsername().equals(user.getUsername());
}
@Override
public int hashCode() {
return 13 * this.getUsername().hashCode();
}
}
| 3,539 | 0.686669 | 0.678743 | 150 | 21.553333 | 18.276957 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.426667 | false | false | 1 |
5c38fa32d26766850ec04a46a683d5435a0d8886 | 19,318,762,927,610 | 930ce948b109a2a5c755c8a1b75ef90c44d0167b | /Codeforces-Solution-JAVA/Problem118A.java | 3a0129002fd5963e6401edd79ffd70dce5f2bf52 | [
"MIT"
]
| permissive | rajpratyush/Hacktober-CP-contributions | https://github.com/rajpratyush/Hacktober-CP-contributions | 73d84bbca26d97c828dc4afa7f54bcd5c4cfefb4 | 0ecc29c80aa98cf8ae46059e1991bb753c638791 | refs/heads/main | 2022-12-30T02:53:22.235000 | 2020-10-20T05:47:18 | 2020-10-20T05:47:18 | 305,602,288 | 1 | 0 | MIT | true | 2020-10-20T05:44:07 | 2020-10-20T05:44:06 | 2020-10-18T19:08:54 | 2020-10-18T19:08:52 | 415 | 0 | 0 | 0 | null | false | false | import java.util.Scanner;
public class Problem118A{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s = sc.next();
int x = s.length();
//Character chars[] = new Character[x];
for(int i=0;i<x;i++){
if(s.charAt(i) == 'A' || s.charAt(i) == 'E' || s.charAt(i) == 'I' || s.charAt(i) == 'O' || s.charAt(i) == 'U' ||
s.charAt(i) == 'a' || s.charAt(i) == 'e' || s.charAt(i) == 'i' || s.charAt(i) == 'o' || s.charAt(i) == 'u'
|| s.charAt(i) == 'y' || s.charAt(i) == 'Y'){
continue;
}else{
//chars[i] = Character.toLowerCase(s.charAt(i));
System.out.print(".");
int c = (int)s.charAt(i);
if(c>=65 && c<=90){
c = c +32;
System.out.print((char)c);
}else{
System.out.print(s.charAt(i));
}
}
}
}
} | UTF-8 | Java | 812 | java | Problem118A.java | Java | []
| null | []
| import java.util.Scanner;
public class Problem118A{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s = sc.next();
int x = s.length();
//Character chars[] = new Character[x];
for(int i=0;i<x;i++){
if(s.charAt(i) == 'A' || s.charAt(i) == 'E' || s.charAt(i) == 'I' || s.charAt(i) == 'O' || s.charAt(i) == 'U' ||
s.charAt(i) == 'a' || s.charAt(i) == 'e' || s.charAt(i) == 'i' || s.charAt(i) == 'o' || s.charAt(i) == 'u'
|| s.charAt(i) == 'y' || s.charAt(i) == 'Y'){
continue;
}else{
//chars[i] = Character.toLowerCase(s.charAt(i));
System.out.print(".");
int c = (int)s.charAt(i);
if(c>=65 && c<=90){
c = c +32;
System.out.print((char)c);
}else{
System.out.print(s.charAt(i));
}
}
}
}
} | 812 | 0.497537 | 0.485222 | 38 | 20.394737 | 26.646358 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.078947 | false | false | 1 |
1e6de77e233c849e6ea23f486d861d9c4f7f0fe2 | 17,197,049,076,508 | bffa505c73853acfa1b7bee1b944c4544f624c5d | /modules/uob-cis-assignment-server/src/main/java/org/s1n7ax/feedback/service/QuestionService.java | 0dc8f857acc041926a4210a10bf4c107e476da3f | []
| no_license | s1n7ax/uob-cis-assignment | https://github.com/s1n7ax/uob-cis-assignment | 1a135a7ee50acedd8894f667577fd8f44db967b3 | 814822de057a541b15160ae44fa5be9dd4b817b3 | refs/heads/master | 2023-02-05T02:43:13.583000 | 2020-12-16T21:44:34 | 2020-12-16T21:44:34 | 310,474,036 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.s1n7ax.feedback.service;
import java.util.ArrayList;
import java.util.List;
import org.s1n7ax.feedback.entity.Question;
import org.s1n7ax.feedback.repository.QuestionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* QuestionService provide services related to questions
*/
@Service
public class QuestionService {
@Autowired
private QuestionRepository questionRepo;
List<Question> getDefultQuestionList() {
Iterable<Question> questionIterable = questionRepo.findAll();
List<Question> questionList = new ArrayList<>();
questionIterable.forEach(questionList::add);
return questionList;
}
}
| UTF-8 | Java | 698 | java | QuestionService.java | Java | []
| null | []
| package org.s1n7ax.feedback.service;
import java.util.ArrayList;
import java.util.List;
import org.s1n7ax.feedback.entity.Question;
import org.s1n7ax.feedback.repository.QuestionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* QuestionService provide services related to questions
*/
@Service
public class QuestionService {
@Autowired
private QuestionRepository questionRepo;
List<Question> getDefultQuestionList() {
Iterable<Question> questionIterable = questionRepo.findAll();
List<Question> questionList = new ArrayList<>();
questionIterable.forEach(questionList::add);
return questionList;
}
}
| 698 | 0.80086 | 0.792264 | 28 | 23.928572 | 22.527647 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.857143 | false | false | 1 |
fb8b1943f5230d0bbdc4c125cee5e5a8bffa5b9e | 18,726,057,435,622 | 511ce71236a95d45584acef57982b3c842b0dfde | /app/src/main/java/com/example/pmiexamen201910110022/ActivityInsert.java | 5dc3d173d41e10a6c7a823edd3831bad7188318e | []
| no_license | jairo-perdomo/promovil-examen | https://github.com/jairo-perdomo/promovil-examen | a786be1fce6a6f407e974f7494c417a42dba1de6 | c0ccd78380fec0160eaf2c41ae188663af67bc80 | refs/heads/master | 2023-05-30T13:23:19.596000 | 2021-06-19T02:05:11 | 2021-06-19T02:05:11 | 378,033,376 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.pmiexamen201910110022;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.example.pmiexamen201910110022.transactions.Transactions;
import java.util.ArrayList;
public class ActivityInsert extends AppCompatActivity {
EditText name, phone, note;
Spinner spinnerCountries;
String country;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_insert);
spinnerCountries = findViewById(R.id.viewSpinnerCountries);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.array_countries, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerCountries.setAdapter(adapter);
Button btnSave = findViewById(R.id.viewBtnSaveContact);
spinnerCountries = findViewById(R.id.viewSpinnerCountries);
name = findViewById(R.id.etName);
phone = findViewById(R.id.etPhone);
note = findViewById(R.id.etNote);
country = spinnerCountries.getSelectedItem().toString();
btnSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addContact();
}
});
Button savedContacts = findViewById(R.id.viewBtnSavedContacts);
savedContacts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), ActivityListView.class);
startActivity(intent);
}
});
}
private void addContact() {
SQLiteConexion connection = new SQLiteConexion(this, Transactions.nameDataBase, null, 1);
SQLiteDatabase db = connection.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Transactions.country, country = spinnerCountries.getSelectedItem().toString());
name.setError(null);
phone.setError(null);
note.setError(null);
String verifiedName = name.getText().toString();
String verifiedPhone = phone.getText().toString();
String verifiedNote = note.getText().toString();
// String onlyLetterSpaces = "[a-zA-Z][a-zA-Z ]*"; Expresion regular para solo letras y espacios
if(verifiedName.trim().isEmpty() || verifiedName.length() > 50) {
name.setError("Ingrese su nombre completo porfavor (Maximo 50 caracteres)");
} else if(verifiedPhone.trim().isEmpty() || verifiedPhone.length() > 15){
phone.setError("Ingrese su telefono porfavor (Maximo 15 caracteres)");
} else if(verifiedNote.trim().isEmpty() || verifiedNote.length() > 50){
note.setError("Ingrese una nota porfavor (Maximo 50 caracteres)");
} else {
values.put(Transactions.name, verifiedName);
values.put(Transactions.phone, verifiedPhone);
values.put(Transactions.note, verifiedNote);
Long result = db.insert(Transactions.tableContacts, Transactions.id, values);
Toast.makeText(getApplicationContext(),"Contacto guardado correctamente: "+ result.toString(), Toast.LENGTH_LONG).show();
db.close();
ClearFields();
}
}
private void ClearFields() {
name.setText("");
phone.setText("");
note.setText("");
spinnerCountries.setSelection(0);
}
} | UTF-8 | Java | 3,898 | java | ActivityInsert.java | Java | []
| null | []
| package com.example.pmiexamen201910110022;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.example.pmiexamen201910110022.transactions.Transactions;
import java.util.ArrayList;
public class ActivityInsert extends AppCompatActivity {
EditText name, phone, note;
Spinner spinnerCountries;
String country;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_insert);
spinnerCountries = findViewById(R.id.viewSpinnerCountries);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.array_countries, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerCountries.setAdapter(adapter);
Button btnSave = findViewById(R.id.viewBtnSaveContact);
spinnerCountries = findViewById(R.id.viewSpinnerCountries);
name = findViewById(R.id.etName);
phone = findViewById(R.id.etPhone);
note = findViewById(R.id.etNote);
country = spinnerCountries.getSelectedItem().toString();
btnSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addContact();
}
});
Button savedContacts = findViewById(R.id.viewBtnSavedContacts);
savedContacts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), ActivityListView.class);
startActivity(intent);
}
});
}
private void addContact() {
SQLiteConexion connection = new SQLiteConexion(this, Transactions.nameDataBase, null, 1);
SQLiteDatabase db = connection.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Transactions.country, country = spinnerCountries.getSelectedItem().toString());
name.setError(null);
phone.setError(null);
note.setError(null);
String verifiedName = name.getText().toString();
String verifiedPhone = phone.getText().toString();
String verifiedNote = note.getText().toString();
// String onlyLetterSpaces = "[a-zA-Z][a-zA-Z ]*"; Expresion regular para solo letras y espacios
if(verifiedName.trim().isEmpty() || verifiedName.length() > 50) {
name.setError("Ingrese su nombre completo porfavor (Maximo 50 caracteres)");
} else if(verifiedPhone.trim().isEmpty() || verifiedPhone.length() > 15){
phone.setError("Ingrese su telefono porfavor (Maximo 15 caracteres)");
} else if(verifiedNote.trim().isEmpty() || verifiedNote.length() > 50){
note.setError("Ingrese una nota porfavor (Maximo 50 caracteres)");
} else {
values.put(Transactions.name, verifiedName);
values.put(Transactions.phone, verifiedPhone);
values.put(Transactions.note, verifiedNote);
Long result = db.insert(Transactions.tableContacts, Transactions.id, values);
Toast.makeText(getApplicationContext(),"Contacto guardado correctamente: "+ result.toString(), Toast.LENGTH_LONG).show();
db.close();
ClearFields();
}
}
private void ClearFields() {
name.setText("");
phone.setText("");
note.setText("");
spinnerCountries.setSelection(0);
}
} | 3,898 | 0.675475 | 0.665726 | 97 | 39.195877 | 31.317345 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.845361 | false | false | 1 |
4e1fff5d473bd77fc9e880313f75bed0b209a20c | 8,323,646,634,906 | 3c7c8283f1926e11846c9520be441ddea42a65d8 | /src/mydocking/TabClosingListener.java | 39cba1ae13d984f28eb260b09c73879a31e88979 | [
"MIT"
]
| permissive | junwuwei/MyDocking | https://github.com/junwuwei/MyDocking | d82ef4b622c0b899baa82d4ef80a156b026641cf | 9046693ba54c981368f778eb0f57f394dd9a30ed | refs/heads/master | 2020-02-04T09:53:53.265000 | 2015-07-11T07:44:10 | 2015-07-11T07:44:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package mydocking;
import java.util.EventListener;
public interface TabClosingListener extends EventListener {
public boolean tabClosing(Tab tab);
}
| UTF-8 | Java | 155 | java | TabClosingListener.java | Java | []
| null | []
| package mydocking;
import java.util.EventListener;
public interface TabClosingListener extends EventListener {
public boolean tabClosing(Tab tab);
}
| 155 | 0.806452 | 0.806452 | 8 | 18.375 | 20.945988 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 1 |
f50743fb0b71be9434293506acc1e6d395a307ab | 29,669,634,129,272 | b306d8b615d3d76bff12c4f878f80caedd2c23f0 | /Company/Quora/QueryMinInArray.java | a2c3819958c536d298f29675e38cd20f80e0b78e | []
| no_license | eou/Algorithm | https://github.com/eou/Algorithm | d962a196c579c47535fa1b1799d3582fa1d2be2f | ff1b81ab8b4ec18dd3d9307ec5d9b000aa8974f7 | refs/heads/master | 2022-08-28T13:54:08.818000 | 2022-08-22T07:38:44 | 2022-08-22T07:38:44 | 149,525,316 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.*;
/**
* 给⼀个 2d array。其中 array[j] = (i+1)*(j+1)
* 然后给⼀堆 query,有三种不同的 query:
* 第⼀种是返回当前 array 中的最⼩值
* 第⼆种是把某⼀⾏ disable
* 第三种是把某⼀列 disable
*/
class Solution {
public List<Integer> findMin1(int m, int n, int[][] queries) {
List<Integer> res = new ArrayList<>();
PriorityQueue<Integer> pq = new PriorityQueue<>(new Comparator<Integer>() {
public int compare(Integer a, Integer b) {
int x = (a / m + 1) * (a % m + 1);
int y = (b / m + 1) * (b % m + 1);
// compare element value, not their index
return x - y;
}
});2
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
pq.add((i * m) + j); // add index
}
}
Set<Integer> removeRow = new HashSet<>();
Set<Integer> removeCol = new HashSet<>();
for (int[] query : queries) {
if (query.length == 1) {
// return minimum element
int elt = pq.peek();
while (removeRow.contains(elt / m) || removeCol.contains(elt % m)) {
pq.poll();
elt = pq.peek();
}
res.add((elt / m + 1) * (elt % m + 1));
} else {
if (query[0] == 1) {
removeRow.add(query[1]);
} else {
removeCol.add(query[1]);
}
}
}
return res;
}
public List<Integer> findMin2(int m, int n, int[][] queries) {
// ordered map
TreeMap<Integer, Integer> map = new TreeMap<>();
int[][] matrix = new int[m][n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
matrix[i][j] = (i + 1) * (j + 1);
map.put(matrix[i][j], map.getOrDefault(matrix[i][j], 0) + 1);
}
}
List<Integer> res = new ArrayList<>();
for (int[] query : queries) {
if (query.length == 1) {
for (int key : map.keySet()) {
if (map.get(key) != 0) {
res.add(key);
break;
}
}
} else if (query.length == 2) {
if(query[0] == 1) {
// consider the row
int row = query[1];
for(int j = 0; j< n; j++) {
if(matrix[row][j] != -1 && map.containsKey(matrix[row][j])) {
map.put(matrix[row][j], map.get(matrix[row][j]) - 1);
matrix[row][j] = -1;
}
}
} else {
// consider the column
int col = query[1];
for(int i = 0; i < m; i++) {
if(matrix[i][col] != -1 && map.containsKey(matrix[i][col])) {
map.put(matrix[i][col], map.get(matrix[i][col]) - 1);
matrix[i][col] = -1;
}
}
}
}
}
return res;
}
public static void print2D(int m, int n) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print((i + 1) * (j + 1) + ", ");
}
System.out.println();
}
}
public static void main(String[] args) {
Solution s = new Solution();
int[][] queries = new int[][]{{0}, {1, 0}, {0}, {2, 1}, {0}, {2, 0}, {0}};
print2D(3, 4);
for (Integer i : s.findMin1(3, 4, queries)) {
System.out.println(i);
}
}
} | UTF-8 | Java | 3,892 | java | QueryMinInArray.java | Java | []
| null | []
| import java.util.*;
/**
* 给⼀个 2d array。其中 array[j] = (i+1)*(j+1)
* 然后给⼀堆 query,有三种不同的 query:
* 第⼀种是返回当前 array 中的最⼩值
* 第⼆种是把某⼀⾏ disable
* 第三种是把某⼀列 disable
*/
class Solution {
public List<Integer> findMin1(int m, int n, int[][] queries) {
List<Integer> res = new ArrayList<>();
PriorityQueue<Integer> pq = new PriorityQueue<>(new Comparator<Integer>() {
public int compare(Integer a, Integer b) {
int x = (a / m + 1) * (a % m + 1);
int y = (b / m + 1) * (b % m + 1);
// compare element value, not their index
return x - y;
}
});2
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
pq.add((i * m) + j); // add index
}
}
Set<Integer> removeRow = new HashSet<>();
Set<Integer> removeCol = new HashSet<>();
for (int[] query : queries) {
if (query.length == 1) {
// return minimum element
int elt = pq.peek();
while (removeRow.contains(elt / m) || removeCol.contains(elt % m)) {
pq.poll();
elt = pq.peek();
}
res.add((elt / m + 1) * (elt % m + 1));
} else {
if (query[0] == 1) {
removeRow.add(query[1]);
} else {
removeCol.add(query[1]);
}
}
}
return res;
}
public List<Integer> findMin2(int m, int n, int[][] queries) {
// ordered map
TreeMap<Integer, Integer> map = new TreeMap<>();
int[][] matrix = new int[m][n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
matrix[i][j] = (i + 1) * (j + 1);
map.put(matrix[i][j], map.getOrDefault(matrix[i][j], 0) + 1);
}
}
List<Integer> res = new ArrayList<>();
for (int[] query : queries) {
if (query.length == 1) {
for (int key : map.keySet()) {
if (map.get(key) != 0) {
res.add(key);
break;
}
}
} else if (query.length == 2) {
if(query[0] == 1) {
// consider the row
int row = query[1];
for(int j = 0; j< n; j++) {
if(matrix[row][j] != -1 && map.containsKey(matrix[row][j])) {
map.put(matrix[row][j], map.get(matrix[row][j]) - 1);
matrix[row][j] = -1;
}
}
} else {
// consider the column
int col = query[1];
for(int i = 0; i < m; i++) {
if(matrix[i][col] != -1 && map.containsKey(matrix[i][col])) {
map.put(matrix[i][col], map.get(matrix[i][col]) - 1);
matrix[i][col] = -1;
}
}
}
}
}
return res;
}
public static void print2D(int m, int n) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print((i + 1) * (j + 1) + ", ");
}
System.out.println();
}
}
public static void main(String[] args) {
Solution s = new Solution();
int[][] queries = new int[][]{{0}, {1, 0}, {0}, {2, 1}, {0}, {2, 0}, {0}};
print2D(3, 4);
for (Integer i : s.findMin1(3, 4, queries)) {
System.out.println(i);
}
}
} | 3,892 | 0.370195 | 0.354134 | 112 | 32.919643 | 21.725618 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.705357 | false | false | 1 |
0b5a2012c3d9368c79bc6b476f8260ed5de4cc63 | 9,491,877,768,369 | ed5bfc494fa136ba8f29e48502b146d77cc963ca | /src/main/java/org/gbif/ipt/model/converter/UserEmailConverter.java | 906ae2863bf545e44e4cbdd40c27db32ec54006e | [
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
]
| permissive | gbif/ipt | https://github.com/gbif/ipt | 43ffb2d276aa97e42e7ecebf164708c116ad76d8 | f18b047fe8b5254f003469b0b7857954083c23ff | refs/heads/master | 2023-08-17T01:55:26.401000 | 2023-08-16T14:26:09 | 2023-08-16T14:26:09 | 35,240,026 | 129 | 74 | Apache-2.0 | false | 2023-08-30T12:56:51 | 2015-05-07T19:44:39 | 2023-07-18T19:16:27 | 2023-08-30T12:56:50 | 172,521 | 115 | 56 | 119 | Java | false | false | /*
* 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.gbif.ipt.model.converter;
import org.gbif.ipt.model.User;
import org.gbif.ipt.service.admin.UserAccountManager;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
@Singleton
public class UserEmailConverter implements Converter {
private final UserAccountManager userManager;
@Inject
public UserEmailConverter(UserAccountManager userManager) {
this.userManager = userManager;
}
@Override
public boolean canConvert(Class clazz) {
return clazz.equals(User.class);
}
@Override
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
User u = (User) value;
writer.setValue(u.getEmail());
}
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
return userManager.get(reader.getValue());
}
}
| UTF-8 | Java | 1,723 | java | UserEmailConverter.java | Java | []
| null | []
| /*
* 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.gbif.ipt.model.converter;
import org.gbif.ipt.model.User;
import org.gbif.ipt.service.admin.UserAccountManager;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
@Singleton
public class UserEmailConverter implements Converter {
private final UserAccountManager userManager;
@Inject
public UserEmailConverter(UserAccountManager userManager) {
this.userManager = userManager;
}
@Override
public boolean canConvert(Class clazz) {
return clazz.equals(User.class);
}
@Override
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
User u = (User) value;
writer.setValue(u.getEmail());
}
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
return userManager.get(reader.getValue());
}
}
| 1,723 | 0.778874 | 0.776552 | 53 | 31.509434 | 28.233944 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.45283 | false | false | 1 |
5146e0d92f3517c8dcf3a5c00b1f3eb3a5898507 | 23,356,032,204,767 | 923febbd75fcd3e63635423f3421652384b8113c | /src/com/insp/edu/book/oo/medium/charter1/e2_2_5/AccountDemo.java | 69f2d4aa72b615b8c06b7a878e255444d9c7b15e | []
| no_license | annunakichb/ObjectOriented | https://github.com/annunakichb/ObjectOriented | 2ed27eb771316963cee66ad35e11cd0ebbd8dc8c | e511c7c34057e718371eeca34b3a7b12ffae34a3 | refs/heads/master | 2020-07-16T16:54:50.113000 | 2019-09-04T05:54:32 | 2019-09-04T05:54:32 | 205,827,867 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.insp.edu.book.oo.medium.charter1.e2_2_5;
class Account{
private String name;
private double money;
public Account(String client,double initMoney){name=client;money = initMoney;}
public void withdraw(double moneyTaken){
money -= moneyTaken;
System.out.println(name+"账户中被取走"+moneyTaken+",还剩下"+money);
}
public void deposit(double moneySaved){
money += moneySaved;
System.out.println(name+"账户存入"+moneySaved+",目前有"+money);
}
}
class Wife implements Runnable{
public void run(){
while(true){
int time = (int) (Math.random()*3);
try {
Thread.sleep(time*1000);
} catch (InterruptedException e) {}
int moneyTaken = (int) (Math.random()*1000);
AccountDemo.familyAccount.withdraw(moneyTaken);
}
}
}
class Husband implements Runnable{
public void run(){
while(true){
int time = (int) (Math.random()*3);
try {
Thread.sleep(time*1000);
} catch (InterruptedException e) {}
int moneySaved = (int) (Math.random()*1000);
AccountDemo.familyAccount.deposit(moneySaved);
}
}
}
public class AccountDemo {
public static Account familyAccount = new Account("你的",10000);
public static void main(String[] args) {
// TODO Auto-generated method stub
Husband h = new Husband(); //不再是线程
Wife w = new Wife();
Thread t1 = new Thread(h);//直接创建Thread对象,构造方法中参数传递为Runnable的实现类对象
Thread t2 = new Thread(w);
t1.start();
t2.start();
}
}
| UTF-8 | Java | 1,565 | java | AccountDemo.java | Java | []
| null | []
| package com.insp.edu.book.oo.medium.charter1.e2_2_5;
class Account{
private String name;
private double money;
public Account(String client,double initMoney){name=client;money = initMoney;}
public void withdraw(double moneyTaken){
money -= moneyTaken;
System.out.println(name+"账户中被取走"+moneyTaken+",还剩下"+money);
}
public void deposit(double moneySaved){
money += moneySaved;
System.out.println(name+"账户存入"+moneySaved+",目前有"+money);
}
}
class Wife implements Runnable{
public void run(){
while(true){
int time = (int) (Math.random()*3);
try {
Thread.sleep(time*1000);
} catch (InterruptedException e) {}
int moneyTaken = (int) (Math.random()*1000);
AccountDemo.familyAccount.withdraw(moneyTaken);
}
}
}
class Husband implements Runnable{
public void run(){
while(true){
int time = (int) (Math.random()*3);
try {
Thread.sleep(time*1000);
} catch (InterruptedException e) {}
int moneySaved = (int) (Math.random()*1000);
AccountDemo.familyAccount.deposit(moneySaved);
}
}
}
public class AccountDemo {
public static Account familyAccount = new Account("你的",10000);
public static void main(String[] args) {
// TODO Auto-generated method stub
Husband h = new Husband(); //不再是线程
Wife w = new Wife();
Thread t1 = new Thread(h);//直接创建Thread对象,构造方法中参数传递为Runnable的实现类对象
Thread t2 = new Thread(w);
t1.start();
t2.start();
}
}
| 1,565 | 0.655804 | 0.634759 | 55 | 24.781818 | 20.521997 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.309091 | false | false | 1 |
07a2182e050d50cc1adf204e438c046689b02d7f | 8,486,855,400,118 | 2cf4e0d640a654f6787ed151a29a9ffb9bbdd422 | /app/src/main/java/restaurant/restapp_v10/TableEnCoursActivity.java | 19183cf2e7f9b7b65466cef4bcdd582c1557c439 | []
| no_license | JP2-Warrak/Rest_App | https://github.com/JP2-Warrak/Rest_App | 7113cb26b9b961f004b47960d565fa5325c88ada | 9a1b34e8a96c444a54711c70b11f669981ab1638 | refs/heads/master | 2021-01-22T03:44:50.976000 | 2017-05-25T12:16:28 | 2017-05-25T12:16:28 | 92,400,482 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package restaurant.restapp_v10;
/**
* Created by Alexis on 21/05/2017.
*/
public class TableEnCoursActivity {
}
| UTF-8 | Java | 116 | java | TableEnCoursActivity.java | Java | [
{
"context": "package restaurant.restapp_v10;\n\n/**\n * Created by Alexis on 21/05/2017.\n */\n\npublic class TableEnCoursActi",
"end": 57,
"score": 0.9995073080062866,
"start": 51,
"tag": "NAME",
"value": "Alexis"
}
]
| null | []
| package restaurant.restapp_v10;
/**
* Created by Alexis on 21/05/2017.
*/
public class TableEnCoursActivity {
}
| 116 | 0.715517 | 0.62931 | 8 | 13.5 | 15.700318 | 35 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.125 | false | false | 1 |
4d25c3e22864dd8280f3698eabaaf98e129977de | 28,544,352,671,152 | 7f0e3ad0e8caef6f48829db33b9c60f057e95ad9 | /Calisma/src/GenelKonular/NestedClasses/Static.java | 8cf298ae1a8c87a01e945e8e779cf181ed670115 | []
| no_license | T-Tufan/Java-Work-Files | https://github.com/T-Tufan/Java-Work-Files | 7a112e1d82190b6e6895bc362070e318ece92d27 | 9ef3ad62d922305abd4ef8db6b4321e47c59c7e6 | refs/heads/master | 2023-03-13T12:19:54.023000 | 2021-03-06T14:32:55 | 2021-03-06T14:32:55 | 345,094,633 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package GenelKonular.NestedClasses;
public class Static {
private int a = 10;
private static int b = 3;
public static class Inner3 {
int a=1;
public void run() {
System.out.println(a);
System.out.println(this.a);
System.out.println(b);
}
}
}
| UTF-8 | Java | 262 | java | Static.java | Java | []
| null | []
| package GenelKonular.NestedClasses;
public class Static {
private int a = 10;
private static int b = 3;
public static class Inner3 {
int a=1;
public void run() {
System.out.println(a);
System.out.println(this.a);
System.out.println(b);
}
}
}
| 262 | 0.671756 | 0.652672 | 14 | 17.714285 | 11.63387 | 35 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.857143 | false | false | 1 |
3c6bbce97f059f2d403bceedcf264b80a7a2798e | 1,571,958,064,137 | 9ed0cf37c46526256e89b54c79f27475a0e553db | /app/src/main/java/com/ilbod/detection/carte/Objet.java | e592ca08cfb868d82b36fd8184658600bb0a33f9 | []
| no_license | NguyenRichard/ILBOD | https://github.com/NguyenRichard/ILBOD | 38d704e76c188ed57322b6402dc5886ff1309dfe | bc551c1ea5c5df6c7cacd701dfa358956a348e54 | refs/heads/master | 2020-05-22T00:57:04.584000 | 2019-05-30T23:26:17 | 2019-05-30T23:26:17 | 186,182,657 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ilbod.detection.carte;
import android.os.Build;
import android.support.annotation.RequiresApi;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Objects;
import com.ilbod.detection.Exception.ChaineDeCaractereNullOuVide;
import com.ilbod.detection.Exception.LieuDejaPresent;
/**
* Classe référençant un objet détectable.
* @author Arthur Oulmi
*/
public class Objet implements Serializable {
/**
* Serialisation.
*/
private static final long serialVersionUID = 1L;
/**
* Nom de l'objet
*/
String nom;
/**
* Lieux dans lesquel l'objet est référencé
**/
HashMap<String, Lieu> lieux;
/**
* Nombre de lieu de la carte.
*/
public static int nombreObjets=0;
/**
* Constructeur Objet
* @param nom
* @throws ChaineDeCaractereNullOuVide releve une exception si un string est null ou vide
*/
public Objet(String nom) throws ChaineDeCaractereNullOuVide {
if (nom == "" || nom == null) {
throw new ChaineDeCaractereNullOuVide("nom de l'objet null ou vide");
}
this.nom = nom;
this.lieux = new HashMap<String, Lieu>();
nombreObjets++;
assert(invariant());
}
/**
* Ajoute un lieu referençant l'objet.
* @param lieu lieu à ajouter
*/
public void addLieu(Lieu lieu) throws LieuDejaPresent {
if (lieu == null){
throw new IllegalArgumentException("le lieu à ajouter ne peut être null.");
}
if (lieux.containsValue(lieu)) {
throw new LieuDejaPresent("le lieu est déjà dans la liste des lieux");
}
lieux.put(lieu.getNom(),lieu);
assert(invariant());
}
/**
* Ajoute un lieu referençant l'objet, en ajoutant l'objet au lieu.
* @param lieu lieu à ajouter
*/
public void addLieuRecursive(Lieu lieu) throws LieuDejaPresent {
if (lieu == null){
throw new IllegalArgumentException("le lieu à ajouter ne peut être null.");
}
if (lieux.containsValue(lieu)) {
throw new LieuDejaPresent("le lieu est déjà dans la liste des lieux");
}
lieu.addObjet(this);
lieux.put(lieu.getNom(),lieu);
assert(invariant());
}
/**
* Getter nom.
* @return nom de l'objet
**/
public String getNom() {
return nom;
}
@Override
public String toString() {
return "Objet{" +
"nom='" + nom + '\'' +
'}';
}
/**
* Getter lieux
* @return lieux où l'objet est présent.
*/
public HashMap<String, Lieu> getLieux() { return lieux; }
/**
* condition qui doit être vérifier dans toute la vie de l'objet.
* @return renvoit true si l'invariant est vérifié et false sinon.
*/
public boolean invariant(){
return nom!=null & nom!="" & lieux != null;
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Objet objet = (Objet) o;
return Objects.equals(nom, objet.nom);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public int hashCode() {
return Objects.hash(nom);
}
}
| UTF-8 | Java | 3,402 | java | Objet.java | Java | [
{
"context": "Classe référençant un objet détectable.\n * @author Arthur Oulmi\n */\npublic class Objet implements Serializable {\n",
"end": 382,
"score": 0.9998870491981506,
"start": 370,
"tag": "NAME",
"value": "Arthur Oulmi"
}
]
| null | []
| package com.ilbod.detection.carte;
import android.os.Build;
import android.support.annotation.RequiresApi;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Objects;
import com.ilbod.detection.Exception.ChaineDeCaractereNullOuVide;
import com.ilbod.detection.Exception.LieuDejaPresent;
/**
* Classe référençant un objet détectable.
* @author <NAME>
*/
public class Objet implements Serializable {
/**
* Serialisation.
*/
private static final long serialVersionUID = 1L;
/**
* Nom de l'objet
*/
String nom;
/**
* Lieux dans lesquel l'objet est référencé
**/
HashMap<String, Lieu> lieux;
/**
* Nombre de lieu de la carte.
*/
public static int nombreObjets=0;
/**
* Constructeur Objet
* @param nom
* @throws ChaineDeCaractereNullOuVide releve une exception si un string est null ou vide
*/
public Objet(String nom) throws ChaineDeCaractereNullOuVide {
if (nom == "" || nom == null) {
throw new ChaineDeCaractereNullOuVide("nom de l'objet null ou vide");
}
this.nom = nom;
this.lieux = new HashMap<String, Lieu>();
nombreObjets++;
assert(invariant());
}
/**
* Ajoute un lieu referençant l'objet.
* @param lieu lieu à ajouter
*/
public void addLieu(Lieu lieu) throws LieuDejaPresent {
if (lieu == null){
throw new IllegalArgumentException("le lieu à ajouter ne peut être null.");
}
if (lieux.containsValue(lieu)) {
throw new LieuDejaPresent("le lieu est déjà dans la liste des lieux");
}
lieux.put(lieu.getNom(),lieu);
assert(invariant());
}
/**
* Ajoute un lieu referençant l'objet, en ajoutant l'objet au lieu.
* @param lieu lieu à ajouter
*/
public void addLieuRecursive(Lieu lieu) throws LieuDejaPresent {
if (lieu == null){
throw new IllegalArgumentException("le lieu à ajouter ne peut être null.");
}
if (lieux.containsValue(lieu)) {
throw new LieuDejaPresent("le lieu est déjà dans la liste des lieux");
}
lieu.addObjet(this);
lieux.put(lieu.getNom(),lieu);
assert(invariant());
}
/**
* Getter nom.
* @return nom de l'objet
**/
public String getNom() {
return nom;
}
@Override
public String toString() {
return "Objet{" +
"nom='" + nom + '\'' +
'}';
}
/**
* Getter lieux
* @return lieux où l'objet est présent.
*/
public HashMap<String, Lieu> getLieux() { return lieux; }
/**
* condition qui doit être vérifier dans toute la vie de l'objet.
* @return renvoit true si l'invariant est vérifié et false sinon.
*/
public boolean invariant(){
return nom!=null & nom!="" & lieux != null;
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Objet objet = (Objet) o;
return Objects.equals(nom, objet.nom);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public int hashCode() {
return Objects.hash(nom);
}
}
| 3,396 | 0.593722 | 0.59313 | 129 | 25.178295 | 23.374752 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.356589 | false | false | 1 |
c5809a528edbc1f505b541467208b67f6a920d82 | 13,185,549,618,235 | f157ecb6b5f5dc59504babd1ba87f0e46a5c0667 | /Week_02/G20200343030631/LeetCode_144_631.java | 3f6b5ab833cf18a3a7423fa86f855599590181a7 | []
| no_license | algorithm006-class01/algorithm006-class01 | https://github.com/algorithm006-class01/algorithm006-class01 | 891da256a54640cf1820db93380f4253f6aacecd | 7ad9b948f8deecf35dced38a62913e462e699b1c | refs/heads/master | 2020-12-27T14:43:13.449000 | 2020-04-20T06:56:33 | 2020-04-20T06:56:33 | 237,936,958 | 19 | 140 | null | false | 2020-04-20T06:56:34 | 2020-02-03T10:13:53 | 2020-04-20T06:56:21 | 2020-04-20T06:56:34 | 7,802 | 16 | 128 | 697 | Java | false | false | package com.dsx.hundred.forty.four;
import java.util.ArrayList;
import java.util.List;
/**
* 解题思路: 典型递归方式
* 时间复杂度: O(n)
* 空间复杂度: O(1)
* 执行用时: 0 ms, 在所有 Java 提交中击败了100.00%的用户
* 内存消耗: 37.5 MB, 在所有 Java 提交中击败了5.19%的用户
* @Author: loe881@163.com
* @Date: 2020/2/23
*/
public class Version1 {
public static void main(String[] args) {
}
public static List<Integer> preorderTraversal(TreeNode root) {
if (null == root){
return new ArrayList<>();
}
List<Integer> result = new ArrayList<>();
preOrderTraversalInternal(root, result);
return result;
}
private static void preOrderTraversalInternal(TreeNode node, List<Integer> result){
if (null == node){
return;
}
result.add(node.val);
preOrderTraversalInternal(node.left, result);
preOrderTraversalInternal(node.right, result);
}
/**
* Definition for a binary tree node.
*/
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) { val = x; }
}
}
package com.dsx.hundred.forty.four;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
/**
* 解题思路: 使用栈遍历
* 时间复杂度: O(n)
* 空间复杂度: O(n)
* 执行用时: 1 ms, 在所有 Java 提交中击败了60.73%的用户
* 内存消耗: 37.7 MB, 在所有 Java 提交中击败了5.19%的用户
* @Author: loe881@163.com
* @Date: 2020/2/23
*/
public class Version2 {
public static void main(String[] args) {
}
public static List<Integer> preorderTraversal(TreeNode root) {
if (null == root){
return new ArrayList<>();
}
List<Integer> result = new ArrayList<>();
Stack<TreeNode> treeNodeStack = new Stack();
treeNodeStack.add(root);
while (!treeNodeStack.isEmpty()){
TreeNode tmpNode = treeNodeStack.pop();
result.add(tmpNode.val);
if (tmpNode.right != null){
treeNodeStack.add(tmpNode.right);
}
if (tmpNode.left != null){
treeNodeStack.add(tmpNode.left);
}
}
return result;
}
private static void preOrderTraversalInternal(TreeNode root, List<Integer> result) {
}
/**
* Definition for a binary tree node.
*/
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) { val = x; }
}
}
| UTF-8 | Java | 2,632 | java | LeetCode_144_631.java | Java | [
{
"context": "内存消耗: 37.5 MB, 在所有 Java 提交中击败了5.19%的用户\n * @Author: loe881@163.com\n * @Date: 2020/2/23\n */\npublic class Version1 {\n ",
"end": 248,
"score": 0.9999204277992249,
"start": 234,
"tag": "EMAIL",
"value": "loe881@163.com"
},
{
"context": "内存消耗: 37.7 MB, 在所有 Java 提交中击败了5.19%的用户\n * @Author: loe881@163.com\n * @Date: 2020/2/23\n */\npublic class Version2 {\n ",
"end": 1378,
"score": 0.999922513961792,
"start": 1364,
"tag": "EMAIL",
"value": "loe881@163.com"
}
]
| null | []
| package com.dsx.hundred.forty.four;
import java.util.ArrayList;
import java.util.List;
/**
* 解题思路: 典型递归方式
* 时间复杂度: O(n)
* 空间复杂度: O(1)
* 执行用时: 0 ms, 在所有 Java 提交中击败了100.00%的用户
* 内存消耗: 37.5 MB, 在所有 Java 提交中击败了5.19%的用户
* @Author: <EMAIL>
* @Date: 2020/2/23
*/
public class Version1 {
public static void main(String[] args) {
}
public static List<Integer> preorderTraversal(TreeNode root) {
if (null == root){
return new ArrayList<>();
}
List<Integer> result = new ArrayList<>();
preOrderTraversalInternal(root, result);
return result;
}
private static void preOrderTraversalInternal(TreeNode node, List<Integer> result){
if (null == node){
return;
}
result.add(node.val);
preOrderTraversalInternal(node.left, result);
preOrderTraversalInternal(node.right, result);
}
/**
* Definition for a binary tree node.
*/
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) { val = x; }
}
}
package com.dsx.hundred.forty.four;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
/**
* 解题思路: 使用栈遍历
* 时间复杂度: O(n)
* 空间复杂度: O(n)
* 执行用时: 1 ms, 在所有 Java 提交中击败了60.73%的用户
* 内存消耗: 37.7 MB, 在所有 Java 提交中击败了5.19%的用户
* @Author: <EMAIL>
* @Date: 2020/2/23
*/
public class Version2 {
public static void main(String[] args) {
}
public static List<Integer> preorderTraversal(TreeNode root) {
if (null == root){
return new ArrayList<>();
}
List<Integer> result = new ArrayList<>();
Stack<TreeNode> treeNodeStack = new Stack();
treeNodeStack.add(root);
while (!treeNodeStack.isEmpty()){
TreeNode tmpNode = treeNodeStack.pop();
result.add(tmpNode.val);
if (tmpNode.right != null){
treeNodeStack.add(tmpNode.right);
}
if (tmpNode.left != null){
treeNodeStack.add(tmpNode.left);
}
}
return result;
}
private static void preOrderTraversalInternal(TreeNode root, List<Integer> result) {
}
/**
* Definition for a binary tree node.
*/
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) { val = x; }
}
}
| 2,618 | 0.581204 | 0.559769 | 101 | 23.019802 | 19.496119 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.405941 | false | false | 1 |
a878ceeda729cf052891e044e8d40e8eb8baaf95 | 14,027,363,201,036 | e1555026e8cda01f104a522b2e5d0ebfb65f8c76 | /compragames/src/main/java/com/scm/compragames/compragames/service/AbstractService.java | 499d0ec8acd604fe132f02a9d68008642a043053 | []
| no_license | jpdv2010/v2SCM-backend | https://github.com/jpdv2010/v2SCM-backend | 93d2258a1b2c9d4cf9eeae8093adb43b49ec057b | 7d505ec9d127589ded9cd031dd65ff2a4c7869df | refs/heads/master | 2020-04-07T10:17:58.614000 | 2018-11-21T12:27:31 | 2018-11-21T12:27:31 | 158,281,541 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.scm.compragames.compragames.service;
import javassist.NotFoundException;
import java.util.Collection;
public interface AbstractService <T, Y> {
T findById(Y id) throws NotFoundException;
T save(T obj) throws Exception;
T disable(Y id) throws NotFoundException;
Collection<T> findAll() throws Exception;
Collection<T> findAllByActiveTrue() throws Exception;
}
| UTF-8 | Java | 398 | java | AbstractService.java | Java | []
| null | []
| package com.scm.compragames.compragames.service;
import javassist.NotFoundException;
import java.util.Collection;
public interface AbstractService <T, Y> {
T findById(Y id) throws NotFoundException;
T save(T obj) throws Exception;
T disable(Y id) throws NotFoundException;
Collection<T> findAll() throws Exception;
Collection<T> findAllByActiveTrue() throws Exception;
}
| 398 | 0.756281 | 0.756281 | 17 | 22.411764 | 21.822975 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.529412 | false | false | 1 |
b02b79cab3e4fadd04da921095f5c8ade8f74978 | 23,192,823,444,846 | 6a60491a93e2b4606226fefa099b0141f61d7e6d | /src/main/java/com/buzzinate/bshare/points/bean/ProductCategory.java | eee0b09c515f60df5de280f3b4596c91028e6c7f | []
| no_license | lingdongrushui/PointsWebsite | https://github.com/lingdongrushui/PointsWebsite | c467cd5b4695b088e4f2b0cf6de095d6b9697709 | 4adea4959eb357c04140bc4ae15742ce31ea99ac | refs/heads/master | 2021-05-15T02:18:59.536000 | 2014-04-09T15:40:26 | 2014-04-09T15:40:26 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.buzzinate.bshare.points.bean;
import java.io.Serializable;
import java.util.Date;
import com.buzzinate.bshare.points.bean.enums.CategoryStatus;
/**product category
* @author james.chen
* @since 2012-6-4
*/
public class ProductCategory implements Serializable {
public static final ProductCategory ALL = new ProductCategory(-1 , "所有类别" , "all");
public static final int LOTTERY_COUPON = 14;
private static final long serialVersionUID = 4196864908183436674L;
//product Category primary key
private int id;
//product category code
private String code;
//parent id of product category
private int parentId;
//product category name
private String name;
//category english name
private String nameEn;
//insert time
private Date insertTime;
//product status
private CategoryStatus status;
//product Number
private long prodNum;
public ProductCategory() {
}
public ProductCategory(int id, String name, String nameEn) {
this.id = id;
this.nameEn = nameEn;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getParentId() {
return parentId;
}
public void setParentId(int parentId) {
this.parentId = parentId;
}
public Date getInsertTime() {
return insertTime;
}
public void setInsertTime(Date insertTime) {
this.insertTime = insertTime;
}
public long getProdNum() {
return prodNum;
}
public void setProdNum(long prodNum) {
this.prodNum = prodNum;
}
public CategoryStatus getStatus() {
return status;
}
public void setStatus(CategoryStatus status) {
this.status = status;
}
public String getNameEn() {
return nameEn;
}
public void setNameEn(String nameEn) {
this.nameEn = nameEn;
}
}
| UTF-8 | Java | 2,265 | java | ProductCategory.java | Java | [
{
"context": "ms.CategoryStatus;\n\n/**product category\n * @author james.chen\n * @since 2012-6-4\n */\npublic class Prod",
"end": 191,
"score": 0.6899425983428955,
"start": 190,
"tag": "NAME",
"value": "j"
},
{
"context": ".CategoryStatus;\n\n/**product category\n * @author james.chen\n * @since 2012-6-4\n */\npublic class ProductCatego",
"end": 200,
"score": 0.9581155776977539,
"start": 191,
"tag": "USERNAME",
"value": "ames.chen"
}
]
| null | []
| package com.buzzinate.bshare.points.bean;
import java.io.Serializable;
import java.util.Date;
import com.buzzinate.bshare.points.bean.enums.CategoryStatus;
/**product category
* @author james.chen
* @since 2012-6-4
*/
public class ProductCategory implements Serializable {
public static final ProductCategory ALL = new ProductCategory(-1 , "所有类别" , "all");
public static final int LOTTERY_COUPON = 14;
private static final long serialVersionUID = 4196864908183436674L;
//product Category primary key
private int id;
//product category code
private String code;
//parent id of product category
private int parentId;
//product category name
private String name;
//category english name
private String nameEn;
//insert time
private Date insertTime;
//product status
private CategoryStatus status;
//product Number
private long prodNum;
public ProductCategory() {
}
public ProductCategory(int id, String name, String nameEn) {
this.id = id;
this.nameEn = nameEn;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getParentId() {
return parentId;
}
public void setParentId(int parentId) {
this.parentId = parentId;
}
public Date getInsertTime() {
return insertTime;
}
public void setInsertTime(Date insertTime) {
this.insertTime = insertTime;
}
public long getProdNum() {
return prodNum;
}
public void setProdNum(long prodNum) {
this.prodNum = prodNum;
}
public CategoryStatus getStatus() {
return status;
}
public void setStatus(CategoryStatus status) {
this.status = status;
}
public String getNameEn() {
return nameEn;
}
public void setNameEn(String nameEn) {
this.nameEn = nameEn;
}
}
| 2,265 | 0.620292 | 0.607887 | 107 | 20.093458 | 17.599667 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.35514 | false | false | 1 |
67ac57bcb14f733654f1fa1844ec155dfa41aa75 | 11,020,886,099,888 | 1a32d704493deb99d3040646afbd0f6568d2c8e7 | /BOOT-INF/lib/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java | d1277ba2dfc764924322609284b5dbb8ea850766 | []
| no_license | yanrumei/bullet-zone-server-2.0 | https://github.com/yanrumei/bullet-zone-server-2.0 | e748ff40f601792405143ec21d3f77aa4d34ce69 | 474c4d1a8172a114986d16e00f5752dc019cdcd2 | refs/heads/master | 2020-05-19T11:16:31.172000 | 2019-03-25T17:38:31 | 2019-03-25T17:38:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* */ package org.springframework.boot.autoconfigure.gson;
/* */
/* */ import com.google.gson.Gson;
/* */ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
/* */ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
/* */ import org.springframework.context.annotation.Bean;
/* */ import org.springframework.context.annotation.Configuration;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Configuration
/* */ @ConditionalOnClass({Gson.class})
/* */ public class GsonAutoConfiguration
/* */ {
/* */ @Bean
/* */ @ConditionalOnMissingBean
/* */ public Gson gson()
/* */ {
/* 40 */ return new Gson();
/* */ }
/* */ }
/* Location: C:\Users\ikatwal\Downloads\bullet-zone-server-2.0.jar!\BOOT-INF\lib\spring-boot-autoconfigure-1.5.10.RELEASE.jar!\org\springframework\boot\autoconfigure\gson\GsonAutoConfiguration.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | UTF-8 | Java | 1,216 | java | GsonAutoConfiguration.java | Java | [
{
"context": "}\n/* */ }\n\n\n/* Location: C:\\Users\\ikatwal\\Downloads\\bullet-zone-server-2.0.jar!\\BOOT-INF\\li",
"end": 976,
"score": 0.9888612627983093,
"start": 969,
"tag": "USERNAME",
"value": "ikatwal"
}
]
| null | []
| /* */ package org.springframework.boot.autoconfigure.gson;
/* */
/* */ import com.google.gson.Gson;
/* */ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
/* */ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
/* */ import org.springframework.context.annotation.Bean;
/* */ import org.springframework.context.annotation.Configuration;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Configuration
/* */ @ConditionalOnClass({Gson.class})
/* */ public class GsonAutoConfiguration
/* */ {
/* */ @Bean
/* */ @ConditionalOnMissingBean
/* */ public Gson gson()
/* */ {
/* 40 */ return new Gson();
/* */ }
/* */ }
/* Location: C:\Users\ikatwal\Downloads\bullet-zone-server-2.0.jar!\BOOT-INF\lib\spring-boot-autoconfigure-1.5.10.RELEASE.jar!\org\springframework\boot\autoconfigure\gson\GsonAutoConfiguration.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | 1,216 | 0.527138 | 0.514803 | 48 | 24.354166 | 34.397488 | 211 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.145833 | false | false | 1 |
ed93d8ab0072ff04e2a8b10fc2281256b315afb3 | 24,068,996,745,266 | 8da61b095e4dad44c0b1336592dd95950d65e2e5 | /src/main/java/com/wsgcya/coder/common/util/EmojiFilter.java | 105f4f28208150618ab93436d94a9b15d61e0f3d | []
| no_license | wsgcya/coder | https://github.com/wsgcya/coder | d542e12d2fa55695365a66a3fc7d6f5ba7926ca7 | cce44569000004672b5c3cd24fb69d929d89d84d | refs/heads/master | 2020-04-04T22:30:17.992000 | 2018-12-13T04:32:47 | 2018-12-13T04:32:47 | 156,326,174 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wsgcya.coder.common.util;
public class EmojiFilter {
/**
*
* @Title filter
* @Class EmojiFilter
* @return String
* @param str
* @return
* @Description 过滤特殊字符
* @author qinshijiang@telincn.com
* @Date 2016年10月27日
*/
public static String filter(String str){
if(str == null || str.length() == 0){
return "";
}
StringBuffer sb = new StringBuffer();
for(int i=0;i<str.length()-1;i++){
int ch = str.charAt(i);
int min = Integer.parseInt("E001", 16);
int max = Integer.parseInt("E537", 16);
if(ch >= min && ch <= max){
sb.append("");
}else{
sb.append((char)ch);
}
}
return sb.toString();
}
/*@Test
public void test(){
String test = StringUtils.urlDecode("test%E2%AC%86%EF%B8%8F中文");
System.out.println(test);
}*/
}
| UTF-8 | Java | 995 | java | EmojiFilter.java | Java | [
{
"context": " @return\n * @Description 过滤特殊字符\n * @author qinshijiang@telincn.com\n * @Date 2016年10月27日\n */\n public stati",
"end": 255,
"score": 0.9999303817749023,
"start": 232,
"tag": "EMAIL",
"value": "qinshijiang@telincn.com"
}
]
| null | []
| package com.wsgcya.coder.common.util;
public class EmojiFilter {
/**
*
* @Title filter
* @Class EmojiFilter
* @return String
* @param str
* @return
* @Description 过滤特殊字符
* @author <EMAIL>
* @Date 2016年10月27日
*/
public static String filter(String str){
if(str == null || str.length() == 0){
return "";
}
StringBuffer sb = new StringBuffer();
for(int i=0;i<str.length()-1;i++){
int ch = str.charAt(i);
int min = Integer.parseInt("E001", 16);
int max = Integer.parseInt("E537", 16);
if(ch >= min && ch <= max){
sb.append("");
}else{
sb.append((char)ch);
}
}
return sb.toString();
}
/*@Test
public void test(){
String test = StringUtils.urlDecode("test%E2%AC%86%EF%B8%8F中文");
System.out.println(test);
}*/
}
| 979 | 0.494347 | 0.467626 | 40 | 23.325001 | 16.285557 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.475 | false | false | 1 |
3b736641e4f135f47b38fbe908ab4284bf3640d1 | 22,282,290,393,275 | aeebb8b1b42dfd6f653d82e47a10f777eb09d53e | /tools/src/test/java/training/tools/test/RedisDemoTest.java | eaba560c91fc3dcfec3e65298da34df48089d001 | []
| no_license | Roilka-Manager/training | https://github.com/Roilka-Manager/training | b47d9ca57571178aa7c511497b60425406292410 | b5ebc015d5eefb405f5ec355e790b98ac336dd2f | refs/heads/master | 2022-08-18T09:02:20.413000 | 2020-11-30T17:43:26 | 2020-11-30T17:43:26 | 198,631,546 | 0 | 0 | null | false | 2022-06-29T18:12:05 | 2019-07-24T12:29:37 | 2020-11-30T17:44:18 | 2022-06-29T18:12:05 | 8,223 | 0 | 0 | 4 | JavaScript | false | false | package training.tools.test;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class RedisDemoTest {
@Test
public void a(){
}
}
| UTF-8 | Java | 190 | java | RedisDemoTest.java | Java | []
| null | []
| package training.tools.test;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class RedisDemoTest {
@Test
public void a(){
}
}
| 190 | 0.715789 | 0.715789 | 15 | 11.666667 | 17.051556 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 1 |
b0550d8cd0acc038e660a15efcc6a1f9d9311034 | 15,650,860,869,324 | 2df3a85312475fb780ddbad5cfc369a96a4e3699 | /client/src/com/neevin/Commands/PrintFieldAscendingDistanceCommand.java | b8ae0f8faae451967659a5f315bfdf5c64ec1497 | []
| no_license | neevink/prog-lab5 | https://github.com/neevink/prog-lab5 | 8f2714bcf1eb41da0b5d9ffda58d4c09c1c88c6b | 444d93dcc684d25c42301c4200fa78372c2d3a35 | refs/heads/master | 2023-04-29T12:24:33.166000 | 2021-05-25T13:07:49 | 2021-05-25T13:07:49 | 343,090,591 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.neevin.Commands;
import com.neevin.Net.CommandResult;
import com.neevin.Net.Request;
import com.neevin.Net.ResultStatus;
import com.neevin.Parser.InputHelper;
import com.neevin.Parser.Token;
import com.neevin.Programm.RequestSender;
import java.util.AbstractList;
/**
* Вывести значения поля distance всех элементов в порядке возрастания
*/
public class PrintFieldAscendingDistanceCommand implements Command{
private RequestSender requestSender;
public PrintFieldAscendingDistanceCommand(RequestSender requestSender){
this.requestSender = requestSender;
}
@Override
public String getName() {
return "print_field_ascending_distance";
}
@Override
public String getDescription() {
return "вывести значения поля distance всех элементов в порядке возрастания";
}
@Override
public void execute(AbstractList<Token> tokens) throws Exception {
InputHelper.displayInput(tokens);
Request<?> request = new Request<Object>(this.getName(), null, requestSender.getUserLogin(), requestSender.getUserPassword());
CommandResult result = requestSender.sendRequest(request);
if(result.status == ResultStatus.OK){
System.out.println(result.message);
}
else{
System.out.println("Произошла ошибка: " + result.message);
}
}
}
| UTF-8 | Java | 1,495 | java | PrintFieldAscendingDistanceCommand.java | Java | []
| null | []
| package com.neevin.Commands;
import com.neevin.Net.CommandResult;
import com.neevin.Net.Request;
import com.neevin.Net.ResultStatus;
import com.neevin.Parser.InputHelper;
import com.neevin.Parser.Token;
import com.neevin.Programm.RequestSender;
import java.util.AbstractList;
/**
* Вывести значения поля distance всех элементов в порядке возрастания
*/
public class PrintFieldAscendingDistanceCommand implements Command{
private RequestSender requestSender;
public PrintFieldAscendingDistanceCommand(RequestSender requestSender){
this.requestSender = requestSender;
}
@Override
public String getName() {
return "print_field_ascending_distance";
}
@Override
public String getDescription() {
return "вывести значения поля distance всех элементов в порядке возрастания";
}
@Override
public void execute(AbstractList<Token> tokens) throws Exception {
InputHelper.displayInput(tokens);
Request<?> request = new Request<Object>(this.getName(), null, requestSender.getUserLogin(), requestSender.getUserPassword());
CommandResult result = requestSender.sendRequest(request);
if(result.status == ResultStatus.OK){
System.out.println(result.message);
}
else{
System.out.println("Произошла ошибка: " + result.message);
}
}
}
| 1,495 | 0.714078 | 0.714078 | 46 | 28.956522 | 29.418242 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.434783 | false | false | 1 |
7fc860bfb71972c213c99b01ef6688e52a0e57ae | 12,094,627,907,910 | fbbaf9e8032a95631da18e7af1bf148d3e980421 | /src/test/java/pl/lodz/p/pas/service/auth/NoJwtTokenFailTest.java | e59498e30c1efd8cee1b4f2e84325e75ac2027c9 | []
| no_license | TULbaghia/PAS-hotel | https://github.com/TULbaghia/PAS-hotel | 46a337eb527a591a07c013a18b2d2d4ecc8aba8a | 420272dadc17239108929b45ee852c3312516023 | refs/heads/master | 2023-04-21T15:06:59.427000 | 2021-04-29T21:47:02 | 2021-04-29T21:47:02 | 362,954,879 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pl.lodz.p.pas.service.auth;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static io.restassured.RestAssured.given;
public class NoJwtTokenFailTest {
@BeforeClass
public void setup() {
RestAssured.baseURI = "https://localhost/pas-1.0-SNAPSHOT/api/";
RestAssured.port = 8181;
RestAssured.useRelaxedHTTPSValidation();
}
@Test
public void noJwtTokenFailTest() {
String res = given().contentType(ContentType.JSON)
.get("self")
.then()
.assertThat()
.statusCode(401)
.extract()
.body()
.asString();
Assert.assertEquals(res, "\"UNAUTHORIZED\"");
}
}
| UTF-8 | Java | 943 | java | NoJwtTokenFailTest.java | Java | []
| null | []
| package pl.lodz.p.pas.service.auth;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static io.restassured.RestAssured.given;
public class NoJwtTokenFailTest {
@BeforeClass
public void setup() {
RestAssured.baseURI = "https://localhost/pas-1.0-SNAPSHOT/api/";
RestAssured.port = 8181;
RestAssured.useRelaxedHTTPSValidation();
}
@Test
public void noJwtTokenFailTest() {
String res = given().contentType(ContentType.JSON)
.get("self")
.then()
.assertThat()
.statusCode(401)
.extract()
.body()
.asString();
Assert.assertEquals(res, "\"UNAUTHORIZED\"");
}
}
| 943 | 0.630965 | 0.621421 | 35 | 25.942858 | 18.435902 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 1 |
2302e6102169c1f743e68b461c8e3953207ae312 | 5,970,004,575,798 | 4e7ccd641dbbb797d2e67c730c058f20d645c6e1 | /src/ui/frames/StergeStudentFrame.java | ca33cb31d913bd197a8339b30ab0a82da3dd0cb8 | []
| no_license | TomutaPaul/Studenti | https://github.com/TomutaPaul/Studenti | 7a6ae5f9129a276c65a682aa4f75e5b382becddf | e3a4883ab08893effe1dfd8a3f9635cc9af9de8c | refs/heads/main | 2023-05-26T06:12:21.152000 | 2021-06-16T07:49:48 | 2021-06-16T07:49:48 | 371,003,557 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ui.frames;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import combo.ComboStudenti;
import ui.Command;
import ui.buttons.StergeStudentButton;
public class StergeStudentFrame extends JFrame implements ActionListener {
JPanel mainPannel;
JPanel firstPannel;
ComboStudenti numeText;
JLabel numeLabel;
JLabel studenti;
StergeStudentButton butonStergere;
public StergeStudentFrame() {
this.mainPannel = new JPanel();
this.firstPannel = new JPanel();
BoxLayout layout = new BoxLayout(mainPannel, BoxLayout.Y_AXIS);
this.mainPannel.setLayout(layout);
this.numeLabel = new JLabel("Nume");
this.firstPannel.add(numeLabel);
this.studenti = new JLabel();
this.numeText = new ComboStudenti(studenti);
this.numeText.addActionListener(this);
this.firstPannel.add(numeText);
this.firstPannel.add(studenti);
this.butonStergere = new StergeStudentButton(this.numeText);
this.butonStergere.addActionListener(this);
this.firstPannel.add(butonStergere);
this.mainPannel.add(firstPannel);
this.add(mainPannel);
this.pack();
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
((Command) e.getSource()).execute();
}
}
| UTF-8 | Java | 1,436 | java | StergeStudentFrame.java | Java | []
| null | []
| package ui.frames;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import combo.ComboStudenti;
import ui.Command;
import ui.buttons.StergeStudentButton;
public class StergeStudentFrame extends JFrame implements ActionListener {
JPanel mainPannel;
JPanel firstPannel;
ComboStudenti numeText;
JLabel numeLabel;
JLabel studenti;
StergeStudentButton butonStergere;
public StergeStudentFrame() {
this.mainPannel = new JPanel();
this.firstPannel = new JPanel();
BoxLayout layout = new BoxLayout(mainPannel, BoxLayout.Y_AXIS);
this.mainPannel.setLayout(layout);
this.numeLabel = new JLabel("Nume");
this.firstPannel.add(numeLabel);
this.studenti = new JLabel();
this.numeText = new ComboStudenti(studenti);
this.numeText.addActionListener(this);
this.firstPannel.add(numeText);
this.firstPannel.add(studenti);
this.butonStergere = new StergeStudentButton(this.numeText);
this.butonStergere.addActionListener(this);
this.firstPannel.add(butonStergere);
this.mainPannel.add(firstPannel);
this.add(mainPannel);
this.pack();
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
((Command) e.getSource()).execute();
}
}
| 1,436 | 0.770891 | 0.770891 | 64 | 21.4375 | 18.845486 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.390625 | false | false | 1 |
73329eedb3e821bc19b66e9d2c7b5bfab57bbbc5 | 15,032,385,552,987 | b4d3cacd6ccf3d6fc3df28499641bcb55d8c3a25 | /src/ankita/assignment/collection/NumberFrequency.java | 913e139f7e4bb7bdd5772d07f78dbaabb0026fd9 | []
| no_license | KrishnaKTechnocredits/JAVATechnoOct2020 | https://github.com/KrishnaKTechnocredits/JAVATechnoOct2020 | 6d0c2b03c09572a22d6126b0bcd8c5b4ac47fb0c | 1f5750b88408f524482e7c1798bd54d9d8852213 | refs/heads/main | 2023-03-15T20:36:09.613000 | 2021-03-10T02:53:26 | 2021-03-10T02:53:26 | 306,812,633 | 0 | 2 | null | false | 2021-03-10T02:53:27 | 2020-10-24T05:27:27 | 2021-03-10T02:47:10 | 2021-03-10T02:53:26 | 3,212 | 0 | 2 | 26 | Java | false | false | /*
Assignment 44 :
Program 2:
Find frequency of each number from the Array
Integer arr[] = {23,12,45,67,23,12,67,33};
*/
package ankita.assignment.collection;
import java.util.Arrays;
import java.util.HashMap;
public class NumberFrequency {
void getNumberFrequency(int[] arr) {
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
System.out.println("Input :" + Arrays.toString(arr));
for (int i = 0; i < arr.length; i++) {
if (map.containsKey(arr[i])) {
map.put(arr[i], map.get(arr[i]) + 1);
} else {
map.put(arr[i], 1);
}
}
System.out.println(map);
}
public static void main(String[] args) {
int arr[] = { 23, 12, 45, 67, 23, 12, 67, 33 };
new NumberFrequency().getNumberFrequency(arr);
}
}
| UTF-8 | Java | 744 | java | NumberFrequency.java | Java | []
| null | []
| /*
Assignment 44 :
Program 2:
Find frequency of each number from the Array
Integer arr[] = {23,12,45,67,23,12,67,33};
*/
package ankita.assignment.collection;
import java.util.Arrays;
import java.util.HashMap;
public class NumberFrequency {
void getNumberFrequency(int[] arr) {
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
System.out.println("Input :" + Arrays.toString(arr));
for (int i = 0; i < arr.length; i++) {
if (map.containsKey(arr[i])) {
map.put(arr[i], map.get(arr[i]) + 1);
} else {
map.put(arr[i], 1);
}
}
System.out.println(map);
}
public static void main(String[] args) {
int arr[] = { 23, 12, 45, 67, 23, 12, 67, 33 };
new NumberFrequency().getNumberFrequency(arr);
}
}
| 744 | 0.647849 | 0.596774 | 31 | 23 | 19.650166 | 66 | false | false | 23 | 0.030914 | 0 | 0 | 0 | 0 | 2.129032 | false | false | 1 |
b2834dd50e6fdf87199df6f2c087e86be21665f3 | 4,303,557,262,828 | bc0d2026d5e76bffb3384a4a7e48ac33dfd65544 | /app/src/main/java/com/example/rilu_pc/shoppyfy/DetailActivity.java | 6fd9d53226abe73fb38310ecd2b5bc0078754f4f | []
| no_license | RiluGrace/Shoppyfy | https://github.com/RiluGrace/Shoppyfy | b19c87a63ecada860ab829fea7dd9ea835a06190 | a581a9d1b91c9850440112b46e758059843e0c55 | refs/heads/master | 2021-09-06T17:59:13.658000 | 2018-02-08T07:18:52 | 2018-02-08T07:18:52 | 118,863,227 | 0 | 0 | null | false | 2018-02-08T07:18:53 | 2018-01-25T04:41:55 | 2018-01-25T04:50:02 | 2018-02-08T07:18:53 | 292 | 0 | 0 | 0 | Java | false | null | package com.example.rilu_pc.shoppyfy;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import java.util.ArrayList;
public class DetailActivity extends AppCompatActivity
{
private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
DatabaseHandler db = new DatabaseHandler(this);
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
mRecyclerView.setHasFixedSize(true);
// use a linear layout manager
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
ArrayList<Merchant> merchantlist=new ArrayList<>();
merchantlist=(ArrayList) db.getAllMerchant();
// specify an adapter (see also next example)
mAdapter = new MyAdapter(merchantlist,this);
mRecyclerView.setAdapter(mAdapter);
Toolbar mToolbar = (Toolbar) findViewById(R.id.mToolbar4);
mToolbar.setTitle("Merchant Details");
mToolbar.setTitleTextColor(Color.WHITE);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_keyboard_arrow_left);
mToolbar.setNavigationOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
startActivity(new Intent(DetailActivity.this, HomeActivity.class));
}
});
}
}
| UTF-8 | Java | 2,168 | java | DetailActivity.java | Java | []
| null | []
| package com.example.rilu_pc.shoppyfy;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import java.util.ArrayList;
public class DetailActivity extends AppCompatActivity
{
private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
DatabaseHandler db = new DatabaseHandler(this);
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
mRecyclerView.setHasFixedSize(true);
// use a linear layout manager
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
ArrayList<Merchant> merchantlist=new ArrayList<>();
merchantlist=(ArrayList) db.getAllMerchant();
// specify an adapter (see also next example)
mAdapter = new MyAdapter(merchantlist,this);
mRecyclerView.setAdapter(mAdapter);
Toolbar mToolbar = (Toolbar) findViewById(R.id.mToolbar4);
mToolbar.setTitle("Merchant Details");
mToolbar.setTitleTextColor(Color.WHITE);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_keyboard_arrow_left);
mToolbar.setNavigationOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
startActivity(new Intent(DetailActivity.this, HomeActivity.class));
}
});
}
}
| 2,168 | 0.714022 | 0.711716 | 59 | 35.745762 | 24.812923 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.59322 | false | false | 1 |
8b78206af294c01c7ca2870fe2fd1bbbf1e0ceda | 20,942,260,560,635 | d83241e987687a7343de3f32274fa6643102c623 | /src/Team.java | 6164140d12996783baeaf6cdb7d2ef2351735cea | []
| no_license | Sportus/Football-Simulator | https://github.com/Sportus/Football-Simulator | 80a2ef76f5d4f744c55523f1dfd0bbc411c83391 | 84a74f6c1d25d2253ddad0bf526fc729cdb26b6c | refs/heads/master | 2020-12-25T13:44:37.264000 | 2016-07-20T23:26:06 | 2016-07-20T23:26:06 | 63,821,258 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Random;
public class Team {
private double _playCallConstant;
//Depth chart storing player index of player for each position
private int[] _depthChart = new int[Constants.NUM_POSITIONS];
private String _teamName;
private int _teamNum;
private boolean _needPlayers;
//Could potentially use this if a player retires
private int _playerCount = 0;
private Player[] _players = new Player[Constants.MAX_PLAYERS_ON_TEAM];
public Team(int teamNum, String teamName){
_teamName = teamName;
_teamNum = teamNum;
_needPlayers = true;
Random random = new Random();
//Plays are chosen based on less than 1.5 run, more than 1.5 pass. This makes it a multiplier of either .5 to 1.5.
_playCallConstant = random.nextDouble() + .5;
}
public Player[] getPlayers(){
return _players;
}
public boolean getNeedPlayers(){
return _needPlayers;
}
public void setTeamName(String teamName){
_teamName = teamName;
}
public String getTeamName(){
return _teamName;
}
// public void setQuarterback(Player player){
// _players[_depthChart[Constants.QUARTERBACK]] = player;
// }
// public void setLineman(Player player){
// _players[_depthChart[Constants.LINEMAN]] = player;
// }
//
// public void setWideout(Player player){
// _players[_depthChart[Constants.WIDEOUT]] = player;
// }
public Player getPlayer(int index){
return _players[index];
}
//Changed this so that the player is found using the teams depth chart
public Player getQuarterback(){
return _players[_depthChart[Constants.QUARTERBACK]];
}
public Player getWideout(){
return _players[_depthChart[Constants.WIDEOUT]];
}
public Player getLineman(){
return _players[_depthChart[Constants.LINEMAN]];
}
public double getPlayCallConstant(){
return _playCallConstant;
}
public void setPlayCallConstant(double playCallConstant){
_playCallConstant = playCallConstant;
}
//Goes through every player, and picks a player that is not on a team and with the highest cumulative attribute ratings
//Repetative method and should be refactored
//Returns an int of Player chosen in array
public int choosePlayer(Player[] players){
int bestPlayer = 0;
int bestAttribute = 0;
for(int i = 0; i<Constants.NUMBER_OF_PLAYERS; i++){
if(players[i].getOnTeam()==false){
int[] attributes = players[i].getAttributes();
int attributeScore = 0;
for(int x = 0; x<Constants.NUM_ATTRIBUTES; x++){
attributeScore+=attributes[x];
}
if(attributeScore>bestAttribute){
bestAttribute = attributeScore;
bestPlayer = i;
}
}
}
return bestPlayer;
}
//Goes through every player, and picks a Quarterback that is not on a team and with the highest Speed, Intel and Passing
//Returns the index of the best quarterback
public int chooseQuarterback(Player[] players){
int bestQuarterback = 0;
int bestAttribute = 0;
for(int i = 0; i<Constants.NUMBER_OF_PLAYERS; i++){
if(players[i].getOnTeam()==false){
int[] attributes = players[i].getAttributes();
int attributeScore = 0;
attributeScore+=attributes[Constants.PASSING];
attributeScore+=attributes[Constants.INTEL];
attributeScore+=attributes[Constants.SPEED];
if(attributeScore>bestAttribute){
bestAttribute = attributeScore;
bestQuarterback = i;
}
}
}
return bestQuarterback;
}
public int chooseWideout(Player[] players){
int bestWideout = 0;
int bestAttribute = 0;
for(int i = 0; i<Constants.NUMBER_OF_PLAYERS; i++){
if(players[i].getOnTeam()==false){
int[] attributes = players[i].getAttributes();
int attributeScore = 0;
attributeScore+=attributes[Constants.SPEED];
attributeScore+=attributes[Constants.CATCHING];
attributeScore+=attributes[Constants.STRENGTH];
if(attributeScore>bestAttribute){
bestAttribute = attributeScore;
bestWideout = i;
}
}
}
return bestWideout;
}
public int chooseLineman(Player[] players){
int bestLineman = 0;
int bestAttribute = 0;
for(int i = 0; i<Constants.NUMBER_OF_PLAYERS; i++){
if(players[i].getOnTeam()==false){
int[] attributes = players[i].getAttributes();
int attributeScore = 0;
attributeScore+=attributes[Constants.INTEL];
attributeScore+=attributes[Constants.STRENGTH];
if(attributeScore>bestAttribute){
bestAttribute = attributeScore;
bestLineman = i;
}
}
}
return bestLineman;
}
public void updateDepthChart(Player[] players){
//Finds players that have same team num, creates array with those players
int playerCount = 0;
for(int i = 0; i<Constants.NUMBER_OF_PLAYERS; i++){
if(players[i].getTeamNum() == _teamNum){
_players[playerCount] = players[i];
playerCount++;
}
}
getHighestQuarterback(_players);
getHighestLineman(_players);
getHighestWideout(_players);
// for(int i = 0; i < Constants.MAX_PLAYERS_ON_TEAM; i++){
//
// if(_players[i].getPositionNumber() == Constants.QUARTERBACK){
// setQuarterback(_players[i]);
// }
// else if(_players[i].getPositionNumber() == Constants.LINEMAN){
// setLineman(_players[i]);
// }
// else if(_players[i].getPositionNumber() == Constants.WIDEOUT){
// setWideout(_players[i]);
// }
// else {
//
// }
//
//
// }
System.out.println("Quarterback " + _players[_depthChart[Constants.QUARTERBACK]].getName());
System.out.println("Wideout " + _players[_depthChart[Constants.WIDEOUT]].getName());
System.out.println("Lineman " + _players[_depthChart[Constants.LINEMAN]].getName());
}
//Could use some refactoring...potentially make a position class????
//Should be used first. Assigns highest quarterback to have a position, quarterback, returning the position in the player array
public int getHighestQuarterback(Player[] players){
int quarterbackSkillHighest = 0;
int playerIndex = 0;
for(int i = 0; i<Constants.MAX_PLAYERS_ON_TEAM; i++){
int quarterbackSkill = (players[i].getQuarterbackPass()+ players[i].getQuarterbackRun());
if(quarterbackSkill>quarterbackSkillHighest){
quarterbackSkillHighest = quarterbackSkill;
playerIndex = i;
}
}
_players[playerIndex].setPositionNumber(Constants.QUARTERBACK);
_depthChart[Constants.QUARTERBACK] = playerIndex;
return playerIndex;
}
//Usually used last, finds all available players without position and chooses highest wideout, returning the position in the player array
public int getHighestWideout(Player[] players){
int wideoutkSkillHighest = 0;
int playerIndex = 0;
for(int i = 0; i<Constants.MAX_PLAYERS_ON_TEAM; i++){
int wideoutSkill = (players[i].getWideoutCatching()+ players[i].getWideoutRun());
if(wideoutSkill>wideoutkSkillHighest && players[i].getPositionNumber() == Constants.POSITION_UNASSIGNED){
wideoutkSkillHighest = wideoutSkill;
playerIndex = i;
}
}
_players[playerIndex].setPositionNumber(Constants.WIDEOUT);
_depthChart[Constants.WIDEOUT] = playerIndex;
return playerIndex;
}
//Usually second, finds all available players without position and chooses highest wideout, returning the position in the player array
public int getHighestLineman(Player[] players){
int linemanSkillHighest = 0;
int playerIndex = 0;
for(int i = 0; i<Constants.MAX_PLAYERS_ON_TEAM; i++){
int linemanSkill = (players[i].getBlocking());
if(linemanSkill>linemanSkillHighest && players[i].getPositionNumber() == Constants.POSITION_UNASSIGNED){
linemanSkillHighest = linemanSkill;
playerIndex = i;
}
}
_players[playerIndex].setPositionNumber(Constants.LINEMAN);
_depthChart[Constants.LINEMAN] = playerIndex;
return playerIndex;
}
}
| UTF-8 | Java | 7,634 | java | Team.java | Java | [
{
"context": "thChart[Constants.WIDEOUT]];\n\t}\n\tpublic Player getLineman(){\n\t\treturn _players[_depthChart[Constants.LINEMA",
"end": 1664,
"score": 0.8064118027687073,
"start": 1657,
"tag": "NAME",
"value": "Lineman"
}
]
| null | []
| import java.util.Random;
public class Team {
private double _playCallConstant;
//Depth chart storing player index of player for each position
private int[] _depthChart = new int[Constants.NUM_POSITIONS];
private String _teamName;
private int _teamNum;
private boolean _needPlayers;
//Could potentially use this if a player retires
private int _playerCount = 0;
private Player[] _players = new Player[Constants.MAX_PLAYERS_ON_TEAM];
public Team(int teamNum, String teamName){
_teamName = teamName;
_teamNum = teamNum;
_needPlayers = true;
Random random = new Random();
//Plays are chosen based on less than 1.5 run, more than 1.5 pass. This makes it a multiplier of either .5 to 1.5.
_playCallConstant = random.nextDouble() + .5;
}
public Player[] getPlayers(){
return _players;
}
public boolean getNeedPlayers(){
return _needPlayers;
}
public void setTeamName(String teamName){
_teamName = teamName;
}
public String getTeamName(){
return _teamName;
}
// public void setQuarterback(Player player){
// _players[_depthChart[Constants.QUARTERBACK]] = player;
// }
// public void setLineman(Player player){
// _players[_depthChart[Constants.LINEMAN]] = player;
// }
//
// public void setWideout(Player player){
// _players[_depthChart[Constants.WIDEOUT]] = player;
// }
public Player getPlayer(int index){
return _players[index];
}
//Changed this so that the player is found using the teams depth chart
public Player getQuarterback(){
return _players[_depthChart[Constants.QUARTERBACK]];
}
public Player getWideout(){
return _players[_depthChart[Constants.WIDEOUT]];
}
public Player getLineman(){
return _players[_depthChart[Constants.LINEMAN]];
}
public double getPlayCallConstant(){
return _playCallConstant;
}
public void setPlayCallConstant(double playCallConstant){
_playCallConstant = playCallConstant;
}
//Goes through every player, and picks a player that is not on a team and with the highest cumulative attribute ratings
//Repetative method and should be refactored
//Returns an int of Player chosen in array
public int choosePlayer(Player[] players){
int bestPlayer = 0;
int bestAttribute = 0;
for(int i = 0; i<Constants.NUMBER_OF_PLAYERS; i++){
if(players[i].getOnTeam()==false){
int[] attributes = players[i].getAttributes();
int attributeScore = 0;
for(int x = 0; x<Constants.NUM_ATTRIBUTES; x++){
attributeScore+=attributes[x];
}
if(attributeScore>bestAttribute){
bestAttribute = attributeScore;
bestPlayer = i;
}
}
}
return bestPlayer;
}
//Goes through every player, and picks a Quarterback that is not on a team and with the highest Speed, Intel and Passing
//Returns the index of the best quarterback
public int chooseQuarterback(Player[] players){
int bestQuarterback = 0;
int bestAttribute = 0;
for(int i = 0; i<Constants.NUMBER_OF_PLAYERS; i++){
if(players[i].getOnTeam()==false){
int[] attributes = players[i].getAttributes();
int attributeScore = 0;
attributeScore+=attributes[Constants.PASSING];
attributeScore+=attributes[Constants.INTEL];
attributeScore+=attributes[Constants.SPEED];
if(attributeScore>bestAttribute){
bestAttribute = attributeScore;
bestQuarterback = i;
}
}
}
return bestQuarterback;
}
public int chooseWideout(Player[] players){
int bestWideout = 0;
int bestAttribute = 0;
for(int i = 0; i<Constants.NUMBER_OF_PLAYERS; i++){
if(players[i].getOnTeam()==false){
int[] attributes = players[i].getAttributes();
int attributeScore = 0;
attributeScore+=attributes[Constants.SPEED];
attributeScore+=attributes[Constants.CATCHING];
attributeScore+=attributes[Constants.STRENGTH];
if(attributeScore>bestAttribute){
bestAttribute = attributeScore;
bestWideout = i;
}
}
}
return bestWideout;
}
public int chooseLineman(Player[] players){
int bestLineman = 0;
int bestAttribute = 0;
for(int i = 0; i<Constants.NUMBER_OF_PLAYERS; i++){
if(players[i].getOnTeam()==false){
int[] attributes = players[i].getAttributes();
int attributeScore = 0;
attributeScore+=attributes[Constants.INTEL];
attributeScore+=attributes[Constants.STRENGTH];
if(attributeScore>bestAttribute){
bestAttribute = attributeScore;
bestLineman = i;
}
}
}
return bestLineman;
}
public void updateDepthChart(Player[] players){
//Finds players that have same team num, creates array with those players
int playerCount = 0;
for(int i = 0; i<Constants.NUMBER_OF_PLAYERS; i++){
if(players[i].getTeamNum() == _teamNum){
_players[playerCount] = players[i];
playerCount++;
}
}
getHighestQuarterback(_players);
getHighestLineman(_players);
getHighestWideout(_players);
// for(int i = 0; i < Constants.MAX_PLAYERS_ON_TEAM; i++){
//
// if(_players[i].getPositionNumber() == Constants.QUARTERBACK){
// setQuarterback(_players[i]);
// }
// else if(_players[i].getPositionNumber() == Constants.LINEMAN){
// setLineman(_players[i]);
// }
// else if(_players[i].getPositionNumber() == Constants.WIDEOUT){
// setWideout(_players[i]);
// }
// else {
//
// }
//
//
// }
System.out.println("Quarterback " + _players[_depthChart[Constants.QUARTERBACK]].getName());
System.out.println("Wideout " + _players[_depthChart[Constants.WIDEOUT]].getName());
System.out.println("Lineman " + _players[_depthChart[Constants.LINEMAN]].getName());
}
//Could use some refactoring...potentially make a position class????
//Should be used first. Assigns highest quarterback to have a position, quarterback, returning the position in the player array
public int getHighestQuarterback(Player[] players){
int quarterbackSkillHighest = 0;
int playerIndex = 0;
for(int i = 0; i<Constants.MAX_PLAYERS_ON_TEAM; i++){
int quarterbackSkill = (players[i].getQuarterbackPass()+ players[i].getQuarterbackRun());
if(quarterbackSkill>quarterbackSkillHighest){
quarterbackSkillHighest = quarterbackSkill;
playerIndex = i;
}
}
_players[playerIndex].setPositionNumber(Constants.QUARTERBACK);
_depthChart[Constants.QUARTERBACK] = playerIndex;
return playerIndex;
}
//Usually used last, finds all available players without position and chooses highest wideout, returning the position in the player array
public int getHighestWideout(Player[] players){
int wideoutkSkillHighest = 0;
int playerIndex = 0;
for(int i = 0; i<Constants.MAX_PLAYERS_ON_TEAM; i++){
int wideoutSkill = (players[i].getWideoutCatching()+ players[i].getWideoutRun());
if(wideoutSkill>wideoutkSkillHighest && players[i].getPositionNumber() == Constants.POSITION_UNASSIGNED){
wideoutkSkillHighest = wideoutSkill;
playerIndex = i;
}
}
_players[playerIndex].setPositionNumber(Constants.WIDEOUT);
_depthChart[Constants.WIDEOUT] = playerIndex;
return playerIndex;
}
//Usually second, finds all available players without position and chooses highest wideout, returning the position in the player array
public int getHighestLineman(Player[] players){
int linemanSkillHighest = 0;
int playerIndex = 0;
for(int i = 0; i<Constants.MAX_PLAYERS_ON_TEAM; i++){
int linemanSkill = (players[i].getBlocking());
if(linemanSkill>linemanSkillHighest && players[i].getPositionNumber() == Constants.POSITION_UNASSIGNED){
linemanSkillHighest = linemanSkill;
playerIndex = i;
}
}
_players[playerIndex].setPositionNumber(Constants.LINEMAN);
_depthChart[Constants.LINEMAN] = playerIndex;
return playerIndex;
}
}
| 7,634 | 0.706052 | 0.701074 | 240 | 30.808332 | 27.740402 | 138 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.770833 | false | false | 1 |
b04fc9fd5bd56a3724d027e225d6c39a50ff578e | 16,758,962,426,320 | c5f0756b7c99044c3b1d60598ecf39c2e70664e0 | /MiniGames API/MinigamesAPI/src/main/me/aaron/PermissionStrings.java | e02ab6dd6593b100a3f74e1118c735884aec69bb | []
| no_license | SeekingHearts/SaltyGamesAPI | https://github.com/SeekingHearts/SaltyGamesAPI | 957dce029e05c0482fd86c553b768943a4240671 | 0567769aec5ca6d8238977c5b584b9e239c73558 | refs/heads/master | 2021-08-29T17:34:54.459000 | 2017-12-14T13:28:47 | 2017-12-14T13:28:47 | 114,253,298 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package main.me.aaron;
public interface PermissionStrings {
String MINIGAMES_PARTY = ".party";
String MINIGAMES_START = ".start";
}
| UTF-8 | Java | 149 | java | PermissionStrings.java | Java | []
| null | []
| package main.me.aaron;
public interface PermissionStrings {
String MINIGAMES_PARTY = ".party";
String MINIGAMES_START = ".start";
}
| 149 | 0.671141 | 0.671141 | 9 | 14.555555 | 16.076975 | 36 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.777778 | false | false | 1 |
36885d4dc366f1b106325c83be62d45831db5f94 | 21,139,829,059,363 | 7b0236fb9109d2eca48ea51ae32c812ada34880b | /app/src/main/java/kr/kaist/resl/kitchenhubproducthandler/datasource/DataSource.java | f6b8e398228d514253ca231eed662a684fd6299c | []
| no_license | NicolaiS/KitchenHubProductHandler | https://github.com/NicolaiS/KitchenHubProductHandler | 64d9faa16c367a59f608c62d1dd45ae104901e9d | a453e2b95ae70536c9fe0616b399f0c385a56d03 | refs/heads/master | 2021-01-18T19:16:58.112000 | 2015-06-14T22:06:54 | 2015-06-14T22:06:54 | 37,431,404 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package kr.kaist.resl.kitchenhubproducthandler.datasource;
import android.content.Context;
import java.io.BufferedReader;
import java.util.List;
import java.util.Map;
import kr.kaist.resl.kitchenhubproducthandler.model.DetectedProduct;
/**
* Created by NicolaiSonne on 22-05-2015.
* <p/>
* DataSource abstraction
*/
public abstract class DataSource {
public abstract List<DetectedProduct> handleConnection(Context context, BufferedReader in, Map<Integer, Integer> dataSourceContainerMap) throws Exception;
/**
* Convert Hex String to byte array
*
* @param s Hex String
* @return Byte array
*/
protected static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16));
}
return data;
}
}
| UTF-8 | Java | 965 | java | DataSource.java | Java | [
{
"context": "thandler.model.DetectedProduct;\n\n/**\n * Created by NicolaiSonne on 22-05-2015.\n * <p/>\n * DataSource abstrac",
"end": 265,
"score": 0.7342348694801331,
"start": 258,
"tag": "NAME",
"value": "Nicolai"
},
{
"context": ".model.DetectedProduct;\n\n/**\n * Created by NicolaiSonne on 22-05-2015.\n * <p/>\n * DataSource abstractio",
"end": 268,
"score": 0.6432825922966003,
"start": 265,
"tag": "USERNAME",
"value": "Son"
},
{
"context": "del.DetectedProduct;\n\n/**\n * Created by NicolaiSonne on 22-05-2015.\n * <p/>\n * DataSource abstraction\n",
"end": 270,
"score": 0.730215847492218,
"start": 268,
"tag": "NAME",
"value": "ne"
}
]
| null | []
| package kr.kaist.resl.kitchenhubproducthandler.datasource;
import android.content.Context;
import java.io.BufferedReader;
import java.util.List;
import java.util.Map;
import kr.kaist.resl.kitchenhubproducthandler.model.DetectedProduct;
/**
* Created by NicolaiSonne on 22-05-2015.
* <p/>
* DataSource abstraction
*/
public abstract class DataSource {
public abstract List<DetectedProduct> handleConnection(Context context, BufferedReader in, Map<Integer, Integer> dataSourceContainerMap) throws Exception;
/**
* Convert Hex String to byte array
*
* @param s Hex String
* @return Byte array
*/
protected static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16));
}
return data;
}
}
| 965 | 0.658031 | 0.639378 | 34 | 27.382353 | 33.447952 | 158 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.529412 | false | false | 1 |
6c2a79a564811f5c5bda7acc24bab1e6b9038f33 | 5,016,521,866,343 | 5658ebba9fefa040a0d2cd6f0e7f9b8565feadfe | /src/main/java/com/github/ConcordiaSOEN341/Parser/ILineStatement.java | ad57b6310cf729c5730777f437c3ee3779d5bb89 | [
"MIT"
]
| permissive | CONCORDIASOEN341/CrossCompiler | https://github.com/CONCORDIASOEN341/CrossCompiler | 47fb287b04ba4e551b3a2e4c476c1194bcb72f0a | a92e4160962ecc36bca1630903da445f3e84cf08 | refs/heads/master | 2023-04-18T06:43:15.558000 | 2021-04-23T20:41:06 | 2021-04-23T20:41:06 | 340,248,020 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.github.ConcordiaSOEN341.Parser;
import com.github.ConcordiaSOEN341.Lexer.IToken;
public interface ILineStatement {
IToken getLabel();
IInstruction getInstruction();
IToken getEOL();
IDirective getDirective();
IToken getComment();
void setLabel(IToken label);
void setInstruction(IInstruction instruction);
void setEOL(IToken EOL);
void setDirective(IDirective directive);
void setComment(IToken comment);
}
| UTF-8 | Java | 471 | java | ILineStatement.java | Java | []
| null | []
| package com.github.ConcordiaSOEN341.Parser;
import com.github.ConcordiaSOEN341.Lexer.IToken;
public interface ILineStatement {
IToken getLabel();
IInstruction getInstruction();
IToken getEOL();
IDirective getDirective();
IToken getComment();
void setLabel(IToken label);
void setInstruction(IInstruction instruction);
void setEOL(IToken EOL);
void setDirective(IDirective directive);
void setComment(IToken comment);
}
| 471 | 0.730361 | 0.717622 | 26 | 17.115385 | 18.27425 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.461538 | false | false | 1 |
98562f13ad801090f6418923cf5aadeb71e9e4c7 | 25,469,156,091,723 | 39959dfc86eae899d71a4a0dcb7415dea98e122e | /src/admin/controller/AdminController.java | 5a979212d21f194a3096c19718b64754f1060d9d | []
| no_license | SanghooMoon/First-JSP-Project | https://github.com/SanghooMoon/First-JSP-Project | 2974c768fec1e24ce0b95226e73948f76e1d6a35 | 334c27250668a9598c785c633691505dd7990bc5 | refs/heads/master | 2022-11-29T08:10:03.334000 | 2020-08-03T01:41:03 | 2020-08-03T01:41:03 | 283,513,781 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package admin.controller;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import admin.model.service.AdminService;
import admin.model.service.AdminServiceImpl;
import member.model.dto.Member;
@WebServlet("/admin/*")
public class AdminController extends HttpServlet {
private static final long serialVersionUID = 1L;
private AdminService aService;
@Override
public void init() throws ServletException {
// TODO Auto-generated method stub
aService = new AdminServiceImpl();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("utf-8");
String nextPage = null; // 이동할 페이지
String path = request.getPathInfo();
System.out.println("AdminController : " + path);
HttpSession session = request.getSession();
Member member = (Member) session.getAttribute("loginUserInfo");
// 로그인상태가 아니거나, 관리자가 아닌 유저이면 사용자 메인페이지로 이동
if(member==null || !member.getGrade().equals("ADMIN")) {
nextPage = "/index";
request.getRequestDispatcher(nextPage).forward(request, response);
}
if(path.equals("/home")) { // 관리자화면으로 이동
nextPage = "/indexAdmin.jsp";
} else if(path.equals("/approval")) { // 회원가입 승인 페이지로 이동
nextPage = "/administrator/approval.jsp";
ArrayList<Member> list = aService.approvalList();
request.setAttribute("list", list);
} else if(path.equals("/update/approval")) { // 가입 승인
nextPage = "/admin/approval";
// 선택되어온 회원들의 아이디
String[] checked = request.getParameterValues("checked");
if(checked==null) {
request.getRequestDispatcher(nextPage).forward(request, response);
return;
}
for(String chk : checked) {
System.out.println("체크된 id : " + chk);
aService.approvalMember(chk);
}
} else if(path.equals("/update/reject")) { // 가입 거절
nextPage = "/admin/approval";
String[] checked = request.getParameterValues("checked");
if(checked==null) {
request.getRequestDispatcher(nextPage).forward(request, response);
return;
}
for(String chk : checked) {
System.out.println("삭제 시 체크된 id : " + chk);
aService.rejectMember(chk);
}
} else if(path.equals("/management")) { // 가입 승인된 회원 리스트
nextPage = "/administrator/memberList.jsp";
// 가입된 목록 확인
ArrayList<Member> list = aService.MemberList();
request.setAttribute("list", list);
} else if(path.equals("/update/modify")) { // 회원 등급 수정
nextPage = "/administrator/memberList.jsp";
System.out.println("회원등급 수정");
String[] grades = request.getParameterValues("grade");
String[] ids = request.getParameterValues("id");
for(int i=0; i<grades.length; i++) {
aService.modifyGrade(grades[i], ids[i]);
}
// 목록 확인
ArrayList<Member> list = aService.MemberList();
request.setAttribute("list", list);
}
request.getRequestDispatcher(nextPage).forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| UTF-8 | Java | 3,797 | java | AdminController.java | Java | []
| null | []
| package admin.controller;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import admin.model.service.AdminService;
import admin.model.service.AdminServiceImpl;
import member.model.dto.Member;
@WebServlet("/admin/*")
public class AdminController extends HttpServlet {
private static final long serialVersionUID = 1L;
private AdminService aService;
@Override
public void init() throws ServletException {
// TODO Auto-generated method stub
aService = new AdminServiceImpl();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("utf-8");
String nextPage = null; // 이동할 페이지
String path = request.getPathInfo();
System.out.println("AdminController : " + path);
HttpSession session = request.getSession();
Member member = (Member) session.getAttribute("loginUserInfo");
// 로그인상태가 아니거나, 관리자가 아닌 유저이면 사용자 메인페이지로 이동
if(member==null || !member.getGrade().equals("ADMIN")) {
nextPage = "/index";
request.getRequestDispatcher(nextPage).forward(request, response);
}
if(path.equals("/home")) { // 관리자화면으로 이동
nextPage = "/indexAdmin.jsp";
} else if(path.equals("/approval")) { // 회원가입 승인 페이지로 이동
nextPage = "/administrator/approval.jsp";
ArrayList<Member> list = aService.approvalList();
request.setAttribute("list", list);
} else if(path.equals("/update/approval")) { // 가입 승인
nextPage = "/admin/approval";
// 선택되어온 회원들의 아이디
String[] checked = request.getParameterValues("checked");
if(checked==null) {
request.getRequestDispatcher(nextPage).forward(request, response);
return;
}
for(String chk : checked) {
System.out.println("체크된 id : " + chk);
aService.approvalMember(chk);
}
} else if(path.equals("/update/reject")) { // 가입 거절
nextPage = "/admin/approval";
String[] checked = request.getParameterValues("checked");
if(checked==null) {
request.getRequestDispatcher(nextPage).forward(request, response);
return;
}
for(String chk : checked) {
System.out.println("삭제 시 체크된 id : " + chk);
aService.rejectMember(chk);
}
} else if(path.equals("/management")) { // 가입 승인된 회원 리스트
nextPage = "/administrator/memberList.jsp";
// 가입된 목록 확인
ArrayList<Member> list = aService.MemberList();
request.setAttribute("list", list);
} else if(path.equals("/update/modify")) { // 회원 등급 수정
nextPage = "/administrator/memberList.jsp";
System.out.println("회원등급 수정");
String[] grades = request.getParameterValues("grade");
String[] ids = request.getParameterValues("id");
for(int i=0; i<grades.length; i++) {
aService.modifyGrade(grades[i], ids[i]);
}
// 목록 확인
ArrayList<Member> list = aService.MemberList();
request.setAttribute("list", list);
}
request.getRequestDispatcher(nextPage).forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| 3,797 | 0.674164 | 0.67332 | 120 | 27.641666 | 24.693048 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.641667 | false | false | 1 |
df067544f21dc1c430f2275924c8228539d92b71 | 19,765,439,561,816 | 32b72e1dc8b6ee1be2e80bb70a03a021c83db550 | /ast_results/tjg1_nori/norilib/src/androidTest/java/io/github/tjg1/library/norilib/test/ServiceTypeDetectionServiceTest.java | 8579c4cfabecd38720e92edcb5243d380f1344f6 | []
| no_license | cmFodWx5YWRhdjEyMTA5/smell-and-machine-learning | https://github.com/cmFodWx5YWRhdjEyMTA5/smell-and-machine-learning | d90c41a17e88fcd99d543124eeb6e93f9133cb4a | 0564143d92f8024ff5fa6b659c2baebf827582b1 | refs/heads/master | 2020-07-13T13:53:40.297000 | 2019-01-11T11:51:18 | 2019-01-11T11:51:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // isComment
package io.github.tjg1.library.norilib.test;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.test.InstrumentationTestCase;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import io.github.tjg1.library.norilib.clients.Danbooru;
import io.github.tjg1.library.norilib.clients.DanbooruLegacy;
import io.github.tjg1.library.norilib.clients.E621;
import io.github.tjg1.library.norilib.clients.Flickr;
import io.github.tjg1.library.norilib.clients.FlickrUser;
import io.github.tjg1.library.norilib.clients.Gelbooru;
import io.github.tjg1.library.norilib.clients.Shimmie;
import io.github.tjg1.library.norilib.service.ServiceTypeDetectionService;
import static org.fest.assertions.api.Assertions.assertThat;
/**
* isComment
*/
public class isClassOrIsInterface extends InstrumentationTestCase {
/**
* isComment
*/
private static final int isVariable = isIntegerConstant;
/**
* isComment
*/
private static final IntentFilter isVariable = new IntentFilter(isNameExpr.isFieldAccessExpr);
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isMethod().isMethod(), isNameExpr.isMethod("isStringConstant"), isNameExpr);
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isMethod().isMethod(), isNameExpr.isMethod("isStringConstant"), isNameExpr);
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isMethod().isMethod(), isNameExpr.isMethod("isStringConstant"), isNameExpr);
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
// isComment
// isComment
// isComment
// isComment
// isComment
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isMethod().isMethod(), isNameExpr.isMethod("isStringConstant"), isNameExpr);
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isNameExpr.isMethod("isStringConstant"));
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isNameExpr.isMethod("isStringConstant"));
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isNameExpr.isMethod("isStringConstant"));
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isNameExpr.isMethod("isStringConstant"));
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
// isComment
final CountDownLatch isVariable = new CountDownLatch(isIntegerConstant);
// isComment
// isComment
final int[] isVariable = new int[isIntegerConstant];
isMethod(new Runnable() {
@Override
public void isMethod() {
// isComment
isMethod().isMethod().isMethod(new BroadcastReceiver() {
@Override
public void isMethod(Context isParameter, Intent isParameter) {
// isComment
isNameExpr[isIntegerConstant] = isNameExpr.isMethod(isNameExpr.isFieldAccessExpr, -isIntegerConstant);
// isComment
isMethod().isMethod().isMethod(this);
// isComment
isNameExpr.isMethod();
}
}, isNameExpr);
// isComment
isMethod().isMethod().isMethod(new Intent(isMethod().isMethod(), ServiceTypeDetectionService.class).isMethod(isNameExpr.isFieldAccessExpr, "isStringConstant"));
}
});
// isComment
isNameExpr.isMethod(isNameExpr, isNameExpr.isFieldAccessExpr);
isMethod(isNameExpr[isIntegerConstant]).isMethod(isNameExpr.isFieldAccessExpr);
}
/**
* isComment
*/
public void isMethod() throws Throwable {
// isComment
final CountDownLatch isVariable = new CountDownLatch(isIntegerConstant);
// isComment
// isComment
final int[] isVariable = new int[isIntegerConstant];
isMethod(new Runnable() {
@Override
public void isMethod() {
// isComment
isMethod().isMethod().isMethod(new BroadcastReceiver() {
@Override
public void isMethod(Context isParameter, Intent isParameter) {
// isComment
isNameExpr[isIntegerConstant] = isNameExpr.isMethod(isNameExpr.isFieldAccessExpr, -isIntegerConstant);
// isComment
isMethod().isMethod().isMethod(this);
// isComment
isNameExpr.isMethod();
}
}, isNameExpr);
// isComment
isMethod().isMethod().isMethod(new Intent(isMethod().isMethod(), ServiceTypeDetectionService.class).isMethod(isNameExpr.isFieldAccessExpr, "isStringConstant"));
}
});
// isComment
isNameExpr.isMethod(isNameExpr, isNameExpr.isFieldAccessExpr);
isMethod(isNameExpr[isIntegerConstant]).isMethod(isNameExpr.isFieldAccessExpr);
}
}
| UTF-8 | Java | 6,550 | java | ServiceTypeDetectionServiceTest.java | Java | [
{
"context": "brary.norilib.clients.Danbooru;\nimport io.github.tjg1.library.norilib.clients.DanbooruLegacy;\nimport i",
"end": 428,
"score": 0.5906771421432495,
"start": 426,
"tag": "USERNAME",
"value": "jg"
}
]
| null | []
| // isComment
package io.github.tjg1.library.norilib.test;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.test.InstrumentationTestCase;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import io.github.tjg1.library.norilib.clients.Danbooru;
import io.github.tjg1.library.norilib.clients.DanbooruLegacy;
import io.github.tjg1.library.norilib.clients.E621;
import io.github.tjg1.library.norilib.clients.Flickr;
import io.github.tjg1.library.norilib.clients.FlickrUser;
import io.github.tjg1.library.norilib.clients.Gelbooru;
import io.github.tjg1.library.norilib.clients.Shimmie;
import io.github.tjg1.library.norilib.service.ServiceTypeDetectionService;
import static org.fest.assertions.api.Assertions.assertThat;
/**
* isComment
*/
public class isClassOrIsInterface extends InstrumentationTestCase {
/**
* isComment
*/
private static final int isVariable = isIntegerConstant;
/**
* isComment
*/
private static final IntentFilter isVariable = new IntentFilter(isNameExpr.isFieldAccessExpr);
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isMethod().isMethod(), isNameExpr.isMethod("isStringConstant"), isNameExpr);
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isMethod().isMethod(), isNameExpr.isMethod("isStringConstant"), isNameExpr);
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isMethod().isMethod(), isNameExpr.isMethod("isStringConstant"), isNameExpr);
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
// isComment
// isComment
// isComment
// isComment
// isComment
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isMethod().isMethod(), isNameExpr.isMethod("isStringConstant"), isNameExpr);
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isNameExpr.isMethod("isStringConstant"));
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isNameExpr.isMethod("isStringConstant"));
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isNameExpr.isMethod("isStringConstant"));
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
String isVariable = isNameExpr.isMethod(isNameExpr.isMethod("isStringConstant"));
isMethod(isNameExpr).isMethod();
isMethod(isNameExpr).isMethod("isStringConstant");
}
/**
* isComment
*/
public void isMethod() throws Throwable {
// isComment
final CountDownLatch isVariable = new CountDownLatch(isIntegerConstant);
// isComment
// isComment
final int[] isVariable = new int[isIntegerConstant];
isMethod(new Runnable() {
@Override
public void isMethod() {
// isComment
isMethod().isMethod().isMethod(new BroadcastReceiver() {
@Override
public void isMethod(Context isParameter, Intent isParameter) {
// isComment
isNameExpr[isIntegerConstant] = isNameExpr.isMethod(isNameExpr.isFieldAccessExpr, -isIntegerConstant);
// isComment
isMethod().isMethod().isMethod(this);
// isComment
isNameExpr.isMethod();
}
}, isNameExpr);
// isComment
isMethod().isMethod().isMethod(new Intent(isMethod().isMethod(), ServiceTypeDetectionService.class).isMethod(isNameExpr.isFieldAccessExpr, "isStringConstant"));
}
});
// isComment
isNameExpr.isMethod(isNameExpr, isNameExpr.isFieldAccessExpr);
isMethod(isNameExpr[isIntegerConstant]).isMethod(isNameExpr.isFieldAccessExpr);
}
/**
* isComment
*/
public void isMethod() throws Throwable {
// isComment
final CountDownLatch isVariable = new CountDownLatch(isIntegerConstant);
// isComment
// isComment
final int[] isVariable = new int[isIntegerConstant];
isMethod(new Runnable() {
@Override
public void isMethod() {
// isComment
isMethod().isMethod().isMethod(new BroadcastReceiver() {
@Override
public void isMethod(Context isParameter, Intent isParameter) {
// isComment
isNameExpr[isIntegerConstant] = isNameExpr.isMethod(isNameExpr.isFieldAccessExpr, -isIntegerConstant);
// isComment
isMethod().isMethod().isMethod(this);
// isComment
isNameExpr.isMethod();
}
}, isNameExpr);
// isComment
isMethod().isMethod().isMethod(new Intent(isMethod().isMethod(), ServiceTypeDetectionService.class).isMethod(isNameExpr.isFieldAccessExpr, "isStringConstant"));
}
});
// isComment
isNameExpr.isMethod(isNameExpr, isNameExpr.isFieldAccessExpr);
isMethod(isNameExpr[isIntegerConstant]).isMethod(isNameExpr.isFieldAccessExpr);
}
}
| 6,550 | 0.63145 | 0.629618 | 189 | 33.656086 | 33.12767 | 176 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 1 |
edc3932364652288d211c9354fb0f9a8814eb41f | 14,104,672,632,525 | e5896e7f86320d80ca78a6851c8158441a9ad46f | /app/src/main/java/com/mycompany/mynews/Query.java | ad9cea8e11b7ddfad2fc47ef9447350a1bc560c1 | []
| no_license | wenzhifeifeidetutu/MyNews | https://github.com/wenzhifeifeidetutu/MyNews | 4b9abba8cb23780065a92b52522ea1d46d2a4ae3 | d680eedda43291e7e34389e22e8642bda37e1271 | refs/heads/master | 2020-02-28T23:30:44.455000 | 2018-01-05T11:50:48 | 2018-01-05T11:50:48 | 88,165,348 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mycompany.mynews;
import android.text.TextUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Administrator on 2017/4/11.
*/
public class Query {
public Query(){
}
//创建Url
private static URL creatUrl(String urlString){
URL url = null;
try {
url = new URL(urlString);
} catch (MalformedURLException e) {
e.printStackTrace();
}
return url;
}
//进行http请求
private String makeHttpRequest(URL url) throws IOException {
String jsonResponseString = "";
if (url == null ) {
return null;
}
//开始http请求
HttpURLConnection httpURLConnection = null;
InputStream inputStream = null;
try {
httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setReadTimeout(10000);
httpURLConnection.setConnectTimeout(15000);
httpURLConnection.connect();
if (httpURLConnection.getResponseCode() == 200){
inputStream = httpURLConnection.getInputStream();
jsonResponseString = readStream(inputStream);
}
} catch (IOException e) {
e.printStackTrace();
}finally {
if (httpURLConnection != null){
httpURLConnection.disconnect();
}
if (inputStream != null){
inputStream.close();
}
}
return jsonResponseString;
}
//进行返回的input流优化
private String readStream(InputStream inputStream) throws IOException {
StringBuilder outer = new StringBuilder();
if (inputStream != null) {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, Charset.forName("UTF-8"));
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String line = bufferedReader.readLine();
while (line != null){
outer.append(line);
line = bufferedReader.readLine();
}
}
return outer.toString();
}
//json对象的解析
private List<News> jsonExtract(String jsonResponseString){
if (TextUtils.isEmpty(jsonResponseString)){
return null;
}
List<News> list_news = new ArrayList<News>();
try{
JSONObject baseObject = new JSONObject(jsonResponseString);
JSONArray newslistArray = baseObject.getJSONArray("newslist");
//遍历json数组
for (int i = 0; i<newslistArray.length(); i++){
JSONObject itemObject = newslistArray.getJSONObject(i);
String ctime = itemObject.getString("ctime");
String title = itemObject.getString("title");
String description = itemObject.getString("description");
String picUrl = itemObject.getString("picUrl");
String url = itemObject.getString("url");
list_news.add(new News(title,description,url, picUrl,ctime));
}
} catch (JSONException e) {
e.printStackTrace();
}
return list_news;
}
//查询函数的开始
public List<News> fetchNews(String requsetUrl){
URL url = creatUrl(requsetUrl);
String jsonResponse = null;
try{
jsonResponse = makeHttpRequest(url);
} catch (IOException e) {
e.printStackTrace();
}
List<News> myNews = jsonExtract(jsonResponse);
return myNews;
}
}
| UTF-8 | Java | 4,082 | java | Query.java | Java | [
{
"context": "rayList;\nimport java.util.List;\n\n/**\n * Created by Administrator on 2017/4/11.\n */\n\npublic class Query {\n\n\n pub",
"end": 482,
"score": 0.6734167337417603,
"start": 469,
"tag": "USERNAME",
"value": "Administrator"
}
]
| null | []
| package com.mycompany.mynews;
import android.text.TextUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Administrator on 2017/4/11.
*/
public class Query {
public Query(){
}
//创建Url
private static URL creatUrl(String urlString){
URL url = null;
try {
url = new URL(urlString);
} catch (MalformedURLException e) {
e.printStackTrace();
}
return url;
}
//进行http请求
private String makeHttpRequest(URL url) throws IOException {
String jsonResponseString = "";
if (url == null ) {
return null;
}
//开始http请求
HttpURLConnection httpURLConnection = null;
InputStream inputStream = null;
try {
httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setReadTimeout(10000);
httpURLConnection.setConnectTimeout(15000);
httpURLConnection.connect();
if (httpURLConnection.getResponseCode() == 200){
inputStream = httpURLConnection.getInputStream();
jsonResponseString = readStream(inputStream);
}
} catch (IOException e) {
e.printStackTrace();
}finally {
if (httpURLConnection != null){
httpURLConnection.disconnect();
}
if (inputStream != null){
inputStream.close();
}
}
return jsonResponseString;
}
//进行返回的input流优化
private String readStream(InputStream inputStream) throws IOException {
StringBuilder outer = new StringBuilder();
if (inputStream != null) {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, Charset.forName("UTF-8"));
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String line = bufferedReader.readLine();
while (line != null){
outer.append(line);
line = bufferedReader.readLine();
}
}
return outer.toString();
}
//json对象的解析
private List<News> jsonExtract(String jsonResponseString){
if (TextUtils.isEmpty(jsonResponseString)){
return null;
}
List<News> list_news = new ArrayList<News>();
try{
JSONObject baseObject = new JSONObject(jsonResponseString);
JSONArray newslistArray = baseObject.getJSONArray("newslist");
//遍历json数组
for (int i = 0; i<newslistArray.length(); i++){
JSONObject itemObject = newslistArray.getJSONObject(i);
String ctime = itemObject.getString("ctime");
String title = itemObject.getString("title");
String description = itemObject.getString("description");
String picUrl = itemObject.getString("picUrl");
String url = itemObject.getString("url");
list_news.add(new News(title,description,url, picUrl,ctime));
}
} catch (JSONException e) {
e.printStackTrace();
}
return list_news;
}
//查询函数的开始
public List<News> fetchNews(String requsetUrl){
URL url = creatUrl(requsetUrl);
String jsonResponse = null;
try{
jsonResponse = makeHttpRequest(url);
} catch (IOException e) {
e.printStackTrace();
}
List<News> myNews = jsonExtract(jsonResponse);
return myNews;
}
}
| 4,082 | 0.591928 | 0.586447 | 146 | 26.493151 | 23.777002 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.458904 | false | false | 1 |
7a1b97c5a1c2396640ee5ce3f4f12150ba9588ce | 14,104,672,630,390 | 7a5f5c723bbbb123746143a5fb32a64a02670f25 | /src/bml/servlet/HeroAddServlet.java | 71241070a1ac1c3f57be17e2c494bc8016bcf8f5 | []
| no_license | bianyueying/How2j-MVC-CRUD | https://github.com/bianyueying/How2j-MVC-CRUD | 10409f62d71deb6e1a2e4f1440c5268427acdb30 | 011e642882d6154d6cee3c586b9149afd5b2a671 | refs/heads/master | 2020-09-15T19:17:03.156000 | 2019-11-23T05:36:00 | 2019-11-23T05:36:00 | 223,536,968 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package bml.servlet;
import bml.bean.Hero;
import bml.dao.HeroDao;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* User: 月影
* Date: 2019/11/12 9:54
*/
public class HeroAddServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String name = req.getParameter("name");
float hp = Float.parseFloat(req.getParameter("hp"));
int damage = Integer.parseInt(req.getParameter("damage"));
Hero hero = new Hero();
hero.setName(name);
hero.setHp(hp);
hero.setDamage(damage);
HeroDao heroDao = new HeroDao();
heroDao.add(hero);
//重定向到列表
resp.sendRedirect("listHero");
}
}
| UTF-8 | Java | 881 | java | HeroAddServlet.java | Java | [
{
"context": "sponse;\nimport java.io.IOException;\n\n/**\n * User: 月影\n * Date: 2019/11/12 9:54\n */\npublic class HeroAdd",
"end": 245,
"score": 0.9955942630767822,
"start": 243,
"tag": "USERNAME",
"value": "月影"
}
]
| null | []
| package bml.servlet;
import bml.bean.Hero;
import bml.dao.HeroDao;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* User: 月影
* Date: 2019/11/12 9:54
*/
public class HeroAddServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String name = req.getParameter("name");
float hp = Float.parseFloat(req.getParameter("hp"));
int damage = Integer.parseInt(req.getParameter("damage"));
Hero hero = new Hero();
hero.setName(name);
hero.setHp(hp);
hero.setDamage(damage);
HeroDao heroDao = new HeroDao();
heroDao.add(hero);
//重定向到列表
resp.sendRedirect("listHero");
}
}
| 881 | 0.675144 | 0.662428 | 34 | 24.441177 | 22.631565 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.529412 | false | false | 1 |
73e42241bb76b18091b9e8bcda61f35742a82231 | 14,766,097,580,645 | 52cbbda87a5172530095402e83244d7d4027b14c | /src/round1and2and3/Test33.java | c79853fb5f5f7555e7865dbab3959a7bff6a9c5a | []
| no_license | bit3125/CodingInterviewsJava | https://github.com/bit3125/CodingInterviewsJava | 09e7921fb81a5f250405b8459076cc0476d13961 | 4b3bb53856e23a63b0e6f2ed317c0054827b2eef | refs/heads/master | 2020-07-01T02:10:16.392000 | 2019-10-05T12:06:32 | 2019-10-05T12:06:32 | 201,015,303 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package round1and2and3;
public class Test33 {
/* 默认左小右大?
* */
public boolean VerifySquenceOfBST(int [] sequence) {
if (sequence.length==0) //robust
return false;//牛客认为空树不是BST
return isBST(sequence, 0, sequence.length);
}
public boolean isBST(int[] sequence, int start, int end){
if (start==end)
return true;
boolean is ;
int rootVal = sequence[end-1];
int idx = start;
while(idx<end-1 && sequence[idx]<rootVal){//***bug:idx<end-1才行,因为要扣掉rootVal所在
idx++;
}//当 (idx==end || sequence[idx]>pRoot.val) (即idx为理论上左右子树的分界点)时退出
return moreThan(sequence, idx, end-1, rootVal)//***bug:end-1
&& isBST(sequence, start, idx)
&& isBST(sequence, idx, end-1);//***bug:end-1
// 逻辑表达式子式的执行与否,一般是按序执行,若前面已满足后面就不会继续执行
}
public boolean moreThan(int[] sequence, int start, int end, int rootVal){
if (start==end)
return true;
for (int i=start;i<end;i++){
if (sequence[i]<rootVal)
return false;
}
return true;
}
public static void main(String[] args) {
Test33 test = new Test33();
// int[] sequence = {5,7,6,9,11,10,8};
int[] sequence = {1,2};
System.out.println(test.VerifySquenceOfBST(sequence));
}
}
| GB18030 | Java | 1,349 | java | Test33.java | Java | []
| null | []
| package round1and2and3;
public class Test33 {
/* 默认左小右大?
* */
public boolean VerifySquenceOfBST(int [] sequence) {
if (sequence.length==0) //robust
return false;//牛客认为空树不是BST
return isBST(sequence, 0, sequence.length);
}
public boolean isBST(int[] sequence, int start, int end){
if (start==end)
return true;
boolean is ;
int rootVal = sequence[end-1];
int idx = start;
while(idx<end-1 && sequence[idx]<rootVal){//***bug:idx<end-1才行,因为要扣掉rootVal所在
idx++;
}//当 (idx==end || sequence[idx]>pRoot.val) (即idx为理论上左右子树的分界点)时退出
return moreThan(sequence, idx, end-1, rootVal)//***bug:end-1
&& isBST(sequence, start, idx)
&& isBST(sequence, idx, end-1);//***bug:end-1
// 逻辑表达式子式的执行与否,一般是按序执行,若前面已满足后面就不会继续执行
}
public boolean moreThan(int[] sequence, int start, int end, int rootVal){
if (start==end)
return true;
for (int i=start;i<end;i++){
if (sequence[i]<rootVal)
return false;
}
return true;
}
public static void main(String[] args) {
Test33 test = new Test33();
// int[] sequence = {5,7,6,9,11,10,8};
int[] sequence = {1,2};
System.out.println(test.VerifySquenceOfBST(sequence));
}
}
| 1,349 | 0.636211 | 0.611903 | 49 | 23.346939 | 22.106007 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.44898 | false | false | 1 |
188600bd20095237fd018718138c6e425159b296 | 28,157,805,637,288 | fff3302fe8193d13360f12e5b13d376ef76cf4d6 | /AppLock/com/google/android/gms/internal/bx.java | 7c7b4b1d79ed1691803eee641929468ddada3680 | []
| no_license | shaolin-example-com-my-shopify-com/KidWatcher | https://github.com/shaolin-example-com-my-shopify-com/KidWatcher | 2912950b7ca4773c3d29005b9d231ad6035b4912 | f67a81b757043159ea358b7f9e4b16fd6be0e0c0 | refs/heads/master | 2022-04-25T17:19:28.800000 | 2020-04-30T02:53:20 | 2020-04-30T02:53:20 | 260,098,439 | 0 | 0 | null | true | 2020-04-30T02:51:49 | 2020-04-30T02:51:48 | 2020-04-30T02:51:30 | 2017-10-10T11:34:53 | 27,484 | 0 | 0 | 0 | null | false | false | package com.google.android.gms.internal;
import android.content.Context;
import com.google.android.gms.internal.bw.C2738d;
import java.util.ArrayList;
import java.util.Collection;
public class bx {
private final Collection<bw> f8170a = new ArrayList();
private final Collection<C2738d> f8171b = new ArrayList();
private final Collection<C2738d> f8172c = new ArrayList();
public static void m9250a(Context context) {
ca.m9278b().m9253a(context);
}
public void m9251a(bw bwVar) {
this.f8170a.add(bwVar);
}
}
| UTF-8 | Java | 554 | java | bx.java | Java | []
| null | []
| package com.google.android.gms.internal;
import android.content.Context;
import com.google.android.gms.internal.bw.C2738d;
import java.util.ArrayList;
import java.util.Collection;
public class bx {
private final Collection<bw> f8170a = new ArrayList();
private final Collection<C2738d> f8171b = new ArrayList();
private final Collection<C2738d> f8172c = new ArrayList();
public static void m9250a(Context context) {
ca.m9278b().m9253a(context);
}
public void m9251a(bw bwVar) {
this.f8170a.add(bwVar);
}
}
| 554 | 0.711191 | 0.631769 | 20 | 26.700001 | 21.594212 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 1 |
3402e5d02181547e3f6817f6bcc501e3062b0878 | 6,519,760,400,098 | 4a13af2a6fa6349aaa50959c092f91adc7555b39 | /app/src/main/java/com/project/android_kidstories/Views/main/BaseActivity.java | f72c49ad65beb6e30db7245db8a74f652311ecac | []
| no_license | Geniuzzz/android-kidstories | https://github.com/Geniuzzz/android-kidstories | 4b383c01beca83d0fb83449c989e07d75a2d8898 | ac04b5ce44df9f64ebbab95b52c061aaed8daf48 | refs/heads/master | 2020-08-10T18:44:26.382000 | 2019-10-21T02:46:54 | 2019-10-21T02:46:54 | 214,398,561 | 0 | 0 | null | true | 2019-10-11T09:37:27 | 2019-10-11T09:37:26 | 2019-10-11T08:40:28 | 2019-10-11T08:40:25 | 1,782 | 0 | 0 | 0 | null | false | false | package com.project.android_kidstories.Views.main;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.project.android_kidstories.sharePref.SharePref;
public class BaseActivity extends AppCompatActivity {
private SharePref sharePref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sharePref= SharePref.getINSTANCE(this);
}
public SharePref getSharePref() {
return sharePref;
}
}
| UTF-8 | Java | 523 | java | BaseActivity.java | Java | []
| null | []
| package com.project.android_kidstories.Views.main;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.project.android_kidstories.sharePref.SharePref;
public class BaseActivity extends AppCompatActivity {
private SharePref sharePref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sharePref= SharePref.getINSTANCE(this);
}
public SharePref getSharePref() {
return sharePref;
}
}
| 523 | 0.743786 | 0.743786 | 25 | 19.92 | 22.012579 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.32 | false | false | 1 |
4030bd3a31773209fce7007d604e6a44b8fa2fe4 | 22,428,319,245,335 | 2f5f4ad12827c73d923d7e1ac7fabc0b31d46f83 | /lab9/build/generated-sources/ap-source-output/com/me/pojo/Leave_.java | 436fc227a9c3d950feec4c819384f90490b5f7cc | []
| no_license | sojitradharti/FinalProject | https://github.com/sojitradharti/FinalProject | 28de8ad5895130f12be29cf6a3f5b1c988685f01 | 0b832b375c22f30b68d72079f3ea1d0604cc1cc2 | refs/heads/master | 2022-03-17T03:13:32.861000 | 2019-11-30T03:56:22 | 2019-11-30T03:56:22 | 224,049,458 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.me.pojo;
import java.util.Date;
import javax.annotation.Generated;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(Leave.class)
public abstract class Leave_ {
public static volatile SingularAttribute<Leave, String> Status;
public static volatile SingularAttribute<Leave, String> reason;
public static volatile SingularAttribute<Leave, String> leavetype;
public static volatile SingularAttribute<Leave, Date> enddate;
public static volatile SingularAttribute<Leave, Integer> days;
public static volatile SingularAttribute<Leave, Integer> id;
public static volatile SingularAttribute<Leave, Date> startdate;
public static volatile SingularAttribute<Leave, Employee> employee;
public static final String STATUS = "Status";
public static final String REASON = "reason";
public static final String LEAVETYPE = "leavetype";
public static final String ENDDATE = "enddate";
public static final String DAYS = "days";
public static final String ID = "id";
public static final String STARTDATE = "startdate";
public static final String EMPLOYEE = "employee";
}
| UTF-8 | Java | 1,235 | java | Leave_.java | Java | []
| null | []
| package com.me.pojo;
import java.util.Date;
import javax.annotation.Generated;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(Leave.class)
public abstract class Leave_ {
public static volatile SingularAttribute<Leave, String> Status;
public static volatile SingularAttribute<Leave, String> reason;
public static volatile SingularAttribute<Leave, String> leavetype;
public static volatile SingularAttribute<Leave, Date> enddate;
public static volatile SingularAttribute<Leave, Integer> days;
public static volatile SingularAttribute<Leave, Integer> id;
public static volatile SingularAttribute<Leave, Date> startdate;
public static volatile SingularAttribute<Leave, Employee> employee;
public static final String STATUS = "Status";
public static final String REASON = "reason";
public static final String LEAVETYPE = "leavetype";
public static final String ENDDATE = "enddate";
public static final String DAYS = "days";
public static final String ID = "id";
public static final String STARTDATE = "startdate";
public static final String EMPLOYEE = "employee";
}
| 1,235 | 0.803239 | 0.803239 | 30 | 40.133335 | 24.039875 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.5 | false | false | 1 |
5d6ff4a51ae0a0c6503048bc86a50bca0f87683e | 22,428,319,245,915 | 59d891c2d0eafb36e20c98dbb1409c8b494a4eb4 | /src/OBST.java | 37913a07c8ccf2b5c7d660344ed285a80d517053 | []
| no_license | clintjohnson168/cs721-OBST | https://github.com/clintjohnson168/cs721-OBST | 8dced01f48e2475bcc58b8b15f51133ce485b3b1 | f58c7ddc31e2568a89b1664a79f7d958e2f57862 | refs/heads/master | 2020-06-11T12:40:09.344000 | 2016-12-05T20:47:53 | 2016-12-05T20:47:53 | 75,664,262 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Random;
// class to implement Optimal Binary Search Tree
public class OBST {
public double p[]; //contains probabilities of elements in tree
public double q[]; //contains probabilities of elements not in tree
public double w[][]; //weight w[i,j] of a tree having r[i,j]
public double e[][]; //cost e[i,j] of a tree having r[i,j]
public int R[][]; //represents root
public int n; //n nodes
public int keys[]; //contains all the keys
private OptimalBST root;
public OBST(int x){
p = new double[x];
q = new double[x];
w = new double[x][x];
e = new double[x][x];
R = new int[x][x];
n = x;
root = null;
keys = new int[x];
}
private OptimalBST constructTree(int i, int j){
OptimalBST node;
if(i == j){
node = null;
}
else{
node = new OptimalBST();
node.key = keys[R[i][j]];
node.left = constructTree(i, R[i][j] - 1);
node.right = constructTree(R[i][j], j);
}
return node;
}
// This function will calculate the w, r and e matrices
public void calcWRE(){
calcW();
calcER();
}
// This function will calculate the w matrix
private void calcW(){
int i, j;
double sumI = 0;
double sumJ = 0;
for(i = 0; i < p.length; i ++){
if(i < p.length-1){
sumI = p[i+1];
}
else sumI = 0;
for(j = 0; j < q.length; j++){
if(j == i){
w[i][j] = q[j];
}
else if(j > i){
if(j == i + 1){
sumJ = sumI + q[j-1];
if(j < p.length){
sumJ += q[j];
}
w[i][j] = sumJ;
}
else{
w[i][j] = w[i][j-1] + p[j] + q[j];
}
}
}
}
}
// This function will calculate the e and r matrices given that w has been calculate
private void calcER(){
int i, j, r, h, m;
double x, minVal;
//set the diagonal of the matrix root and e
for(i = 0; i < n; i ++){
e[i][i] = q[i];
}
for(i = 0; i < n -1; i++){
j = i + 1;
e[i][j] = e[i][i] + e[j][j] + w[i][j];
R[i][j] = j;
}
for(h = 2; h <= n; h++){
for(i = 0; i < n - h; i++){
j = i + h;
m = R[i][j-1];
minVal = e[i][m-1] + e[m][j];
for(r = m+1; r <= R[i+1][j]; r++){
x = e[i][r-1] + e[r][j];
if(x < minVal){
m = r;
minVal = x;
}
}
e[i][j] = w[i][j] + minVal;
R[i][j] = m;
}
}
}
// This function will print out the matrix w
public void printW(){
int i;
int j;
for(i = 0; i < w.length; i++){
for(j = 0; j < w.length; j++){
double val = w[i][j];
System.out.print("\t");
System.out.printf("%.2f", val);
}
System.out.println("");
}
}
// This function will print out the matrix e
public void printE(){
int i;
int j;
for(i = 0; i < e.length; i++){
for(j = 0; j < e.length; j++){
double val = e[i][j];
System.out.print("\t");
System.out.printf("%.2f", val);
}
System.out.println("");
}
}
// This function will print out the matrix R
public void printR(){
int i;
int j;
for(i = 0; i < R.length; i++){
for(j = 0; j < R.length; j++){
double val = R[i][j];
System.out.print("\t");
System.out.printf("%.2f", val);
}
System.out.println("");
}
}
// this function will print out the given double array
public void print(double[] a){
for (int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println("");
}
// this function will print out the given integer array
public void print(int[] a){
for(int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println("");
}
// will print out the tree based on the root node of the tree
// level is used to print the key value at the correct height of the tree
private void printTree(OptimalBST root, int level){
int i, x;
if(root != null){
printTree(root.right, level + 1);
for(i = 0; i <= level; i ++){
if(level == 0){
System.out.print("Root-> ");
}
else{
System.out.print(" ");
}
}
x = root.key;
System.out.printf("%d\n", x);
printTree(root.left, level + 1);
}
}
// Print out the tree from the root node
public void printTree(){
this.root = this.constructTree(0, this.n-1);
this.printTree(this.root, 0);
}
// this function will take a given tree with a given number of and give values
// to p, q, and keys array and will print out the amount of time to
// generate this OBST tree with the given number of nodes
public static void time(OBST tree, int nNodes){
Random rand = new Random();
long start, stop, duration;
int keyVal, pVal, qVal, sum = 0;
start = System.currentTimeMillis(); //start timer
//compute the arrays p, q, and the key values for array p
for(int i = 0; i < nNodes; i++){
keyVal = rand.nextInt(1000);
pVal = rand.nextInt(3);
sum += pVal; // add pVal to sum to calculate probability
qVal = rand.nextInt(3);
sum += qVal; // add qVal to sum to calculate probability
//add values to tree
if(i != 0){
tree.keys[i] = keyVal;
tree.p[i] = pVal;
}
tree.q[i] = qVal;
}
//set p and q to probabilities instead of occurrences
for(int i = 0; i < tree.n; i++){
if(i != 0){
tree.p[i] = tree.p[i] / sum;
}
tree.q[i] = tree.q[i] / sum;
}
//construct 3 matrices
tree.calcWRE();
stop = System.currentTimeMillis(); //stop timer
duration = stop - start;
System.out.println("Time to add " + nNodes + " nodes: " + duration + " miliseconds.");
}
public static void main(String []args){
OBST myTree = new OBST(7);
myTree.p[0] = 0;
myTree.p[1] = 10;
myTree.p[2] = 3;
myTree.p[3] = 9;
myTree.p[4] = 2;
myTree.p[5] = 0;
myTree.p[6] = 10;
System.out.print("Probabilitys: ");
myTree.print(myTree.p);
myTree.keys[1] = 4;
myTree.keys[2] = 8;
myTree.keys[3] = 2;
myTree.keys[4] = 15;
myTree.keys[5] = 9;
myTree.keys[6] = 6;
System.out.print("Key values: ");
myTree.print(myTree.keys);
myTree.q[0] = 5;
myTree.q[1] = 6;
myTree.q[2] = 4;
myTree.q[3] = 4;
myTree.q[4] = 3;
myTree.q[5] = 8;
myTree.q[6] = 0;
System.out.print("Failure pribabilities :");
myTree.print(myTree.q);
myTree.calcWRE();
System.out.println("W:");
myTree.printW();
System.out.println("Root:");
myTree.printR();
System.out.println("e:");
myTree.printE();
System.out.println("Displaying Tree: \n");
myTree.printTree();
System.out.println("\n");
// create and time OBST tree with 10 nodes
myTree = new OBST(10);
OBST.time(myTree, myTree.n);
//System.out.println("E: ");
//myTree.printE();
//myTree.printTree();
//create tree with 100 nodes
myTree = new OBST(100);
OBST.time(myTree, myTree.n);
//create tree with 1000 nodes
myTree = new OBST(1000);
OBST.time(myTree, myTree.n);
//create tree with 10000 nodes
myTree = new OBST(10000);
OBST.time(myTree, myTree.n);
//create tree with 100000 nodes
//myTree = new OBST(100000); //ran out of memory space
System.out.println("Not enough memory space for 100000 nodes.");
//OBST.time(myTree, myTree.n);
}
}
| UTF-8 | Java | 7,376 | java | OBST.java | Java | []
| null | []
| import java.util.Random;
// class to implement Optimal Binary Search Tree
public class OBST {
public double p[]; //contains probabilities of elements in tree
public double q[]; //contains probabilities of elements not in tree
public double w[][]; //weight w[i,j] of a tree having r[i,j]
public double e[][]; //cost e[i,j] of a tree having r[i,j]
public int R[][]; //represents root
public int n; //n nodes
public int keys[]; //contains all the keys
private OptimalBST root;
public OBST(int x){
p = new double[x];
q = new double[x];
w = new double[x][x];
e = new double[x][x];
R = new int[x][x];
n = x;
root = null;
keys = new int[x];
}
private OptimalBST constructTree(int i, int j){
OptimalBST node;
if(i == j){
node = null;
}
else{
node = new OptimalBST();
node.key = keys[R[i][j]];
node.left = constructTree(i, R[i][j] - 1);
node.right = constructTree(R[i][j], j);
}
return node;
}
// This function will calculate the w, r and e matrices
public void calcWRE(){
calcW();
calcER();
}
// This function will calculate the w matrix
private void calcW(){
int i, j;
double sumI = 0;
double sumJ = 0;
for(i = 0; i < p.length; i ++){
if(i < p.length-1){
sumI = p[i+1];
}
else sumI = 0;
for(j = 0; j < q.length; j++){
if(j == i){
w[i][j] = q[j];
}
else if(j > i){
if(j == i + 1){
sumJ = sumI + q[j-1];
if(j < p.length){
sumJ += q[j];
}
w[i][j] = sumJ;
}
else{
w[i][j] = w[i][j-1] + p[j] + q[j];
}
}
}
}
}
// This function will calculate the e and r matrices given that w has been calculate
private void calcER(){
int i, j, r, h, m;
double x, minVal;
//set the diagonal of the matrix root and e
for(i = 0; i < n; i ++){
e[i][i] = q[i];
}
for(i = 0; i < n -1; i++){
j = i + 1;
e[i][j] = e[i][i] + e[j][j] + w[i][j];
R[i][j] = j;
}
for(h = 2; h <= n; h++){
for(i = 0; i < n - h; i++){
j = i + h;
m = R[i][j-1];
minVal = e[i][m-1] + e[m][j];
for(r = m+1; r <= R[i+1][j]; r++){
x = e[i][r-1] + e[r][j];
if(x < minVal){
m = r;
minVal = x;
}
}
e[i][j] = w[i][j] + minVal;
R[i][j] = m;
}
}
}
// This function will print out the matrix w
public void printW(){
int i;
int j;
for(i = 0; i < w.length; i++){
for(j = 0; j < w.length; j++){
double val = w[i][j];
System.out.print("\t");
System.out.printf("%.2f", val);
}
System.out.println("");
}
}
// This function will print out the matrix e
public void printE(){
int i;
int j;
for(i = 0; i < e.length; i++){
for(j = 0; j < e.length; j++){
double val = e[i][j];
System.out.print("\t");
System.out.printf("%.2f", val);
}
System.out.println("");
}
}
// This function will print out the matrix R
public void printR(){
int i;
int j;
for(i = 0; i < R.length; i++){
for(j = 0; j < R.length; j++){
double val = R[i][j];
System.out.print("\t");
System.out.printf("%.2f", val);
}
System.out.println("");
}
}
// this function will print out the given double array
public void print(double[] a){
for (int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println("");
}
// this function will print out the given integer array
public void print(int[] a){
for(int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println("");
}
// will print out the tree based on the root node of the tree
// level is used to print the key value at the correct height of the tree
private void printTree(OptimalBST root, int level){
int i, x;
if(root != null){
printTree(root.right, level + 1);
for(i = 0; i <= level; i ++){
if(level == 0){
System.out.print("Root-> ");
}
else{
System.out.print(" ");
}
}
x = root.key;
System.out.printf("%d\n", x);
printTree(root.left, level + 1);
}
}
// Print out the tree from the root node
public void printTree(){
this.root = this.constructTree(0, this.n-1);
this.printTree(this.root, 0);
}
// this function will take a given tree with a given number of and give values
// to p, q, and keys array and will print out the amount of time to
// generate this OBST tree with the given number of nodes
public static void time(OBST tree, int nNodes){
Random rand = new Random();
long start, stop, duration;
int keyVal, pVal, qVal, sum = 0;
start = System.currentTimeMillis(); //start timer
//compute the arrays p, q, and the key values for array p
for(int i = 0; i < nNodes; i++){
keyVal = rand.nextInt(1000);
pVal = rand.nextInt(3);
sum += pVal; // add pVal to sum to calculate probability
qVal = rand.nextInt(3);
sum += qVal; // add qVal to sum to calculate probability
//add values to tree
if(i != 0){
tree.keys[i] = keyVal;
tree.p[i] = pVal;
}
tree.q[i] = qVal;
}
//set p and q to probabilities instead of occurrences
for(int i = 0; i < tree.n; i++){
if(i != 0){
tree.p[i] = tree.p[i] / sum;
}
tree.q[i] = tree.q[i] / sum;
}
//construct 3 matrices
tree.calcWRE();
stop = System.currentTimeMillis(); //stop timer
duration = stop - start;
System.out.println("Time to add " + nNodes + " nodes: " + duration + " miliseconds.");
}
public static void main(String []args){
OBST myTree = new OBST(7);
myTree.p[0] = 0;
myTree.p[1] = 10;
myTree.p[2] = 3;
myTree.p[3] = 9;
myTree.p[4] = 2;
myTree.p[5] = 0;
myTree.p[6] = 10;
System.out.print("Probabilitys: ");
myTree.print(myTree.p);
myTree.keys[1] = 4;
myTree.keys[2] = 8;
myTree.keys[3] = 2;
myTree.keys[4] = 15;
myTree.keys[5] = 9;
myTree.keys[6] = 6;
System.out.print("Key values: ");
myTree.print(myTree.keys);
myTree.q[0] = 5;
myTree.q[1] = 6;
myTree.q[2] = 4;
myTree.q[3] = 4;
myTree.q[4] = 3;
myTree.q[5] = 8;
myTree.q[6] = 0;
System.out.print("Failure pribabilities :");
myTree.print(myTree.q);
myTree.calcWRE();
System.out.println("W:");
myTree.printW();
System.out.println("Root:");
myTree.printR();
System.out.println("e:");
myTree.printE();
System.out.println("Displaying Tree: \n");
myTree.printTree();
System.out.println("\n");
// create and time OBST tree with 10 nodes
myTree = new OBST(10);
OBST.time(myTree, myTree.n);
//System.out.println("E: ");
//myTree.printE();
//myTree.printTree();
//create tree with 100 nodes
myTree = new OBST(100);
OBST.time(myTree, myTree.n);
//create tree with 1000 nodes
myTree = new OBST(1000);
OBST.time(myTree, myTree.n);
//create tree with 10000 nodes
myTree = new OBST(10000);
OBST.time(myTree, myTree.n);
//create tree with 100000 nodes
//myTree = new OBST(100000); //ran out of memory space
System.out.println("Not enough memory space for 100000 nodes.");
//OBST.time(myTree, myTree.n);
}
}
| 7,376 | 0.535927 | 0.516676 | 308 | 21.948051 | 17.404953 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.194805 | false | false | 1 |
d5733a5c132c7c7e7772c88922fd6049f6217d73 | 22,428,319,248,160 | 182668282aac1247235dce3ab97683606d8cfe72 | /corelib/videoRecorder/src/main/java/cc/eguid/cv/videoRecorder/recorder/Recorder.java | b989f2590018eae2149de3ac4413557c53a08c36 | [
"Apache-2.0"
]
| permissive | wesker0918/easyCV | https://github.com/wesker0918/easyCV | 49ea2d63e6afc4174686523668ddb4086277ac38 | 00b04823137bf478f032fb5486df37c83119a012 | refs/heads/master | 2023-01-19T19:46:23.610000 | 2020-11-20T08:44:57 | 2020-11-20T08:44:57 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cc.eguid.cv.videoRecorder.recorder;
import java.io.IOException;
import org.bytedeco.javacv.FrameGrabber.Exception;
/**
* 录制器接口
*
* @author eguid
*
*/
public interface Recorder {
/**
* 设置视频源
*
* @param src
* 视频源(文件或流媒体拉流地址)
* @return
*/
Recorder from(String src) throws Exception;
/**
* 设置输出文件或推流到流媒体服务
*
* @param out
* 输出文件或流媒体服务推流地址
* @return
* @throws IOException
*/
Recorder to(String out) throws IOException;
/**
* 转发源视频到输出(复制)
*
* @param src
* 视频源
* @param out
* 输出文件或流媒体服务推流地址
* @return
* @throws IOException
*/
Recorder stream(String src, String out) throws IOException;
/**
* 设置音频参数
*
* @param audioChannels
* @param audioBitrate
* @param sampleRate
* @return
*/
Recorder audioParam(int audioChannels, int audioBitrate, int sampleRate);
/**
* 设置视频参数
*
* @param width
* @param height
* @param framerate
* @param bitrate
* @return
*/
Recorder videoParam(Integer width, Integer height, int framerate, int bitrate);
/**
* 开始录制
*
* @return
*/
Recorder start();
/**
* 暂停录制
*
* @return
*/
Recorder pause();
/**
* 继续录制(从暂停中恢复)
*
* @return
*/
Recorder carryon();
/**
* 停止录制
*
* @return
*/
Recorder stop();
/**
* 线程是否可用
* @return
*/
boolean alive();
/**
* 工作线程实时状态,用于保活(状态码:0-初始状态,1-运行,2-停止)
* @return
*/
int status();
}
| UTF-8 | Java | 1,748 | java | Recorder.java | Java | [
{
"context": "ameGrabber.Exception;\n\n/**\n * 录制器接口\n * \n * @author eguid\n *\n */\npublic interface Recorder {\n\n\t/**\n\t * 设置视频",
"end": 159,
"score": 0.9995619058609009,
"start": 154,
"tag": "USERNAME",
"value": "eguid"
}
]
| null | []
| package cc.eguid.cv.videoRecorder.recorder;
import java.io.IOException;
import org.bytedeco.javacv.FrameGrabber.Exception;
/**
* 录制器接口
*
* @author eguid
*
*/
public interface Recorder {
/**
* 设置视频源
*
* @param src
* 视频源(文件或流媒体拉流地址)
* @return
*/
Recorder from(String src) throws Exception;
/**
* 设置输出文件或推流到流媒体服务
*
* @param out
* 输出文件或流媒体服务推流地址
* @return
* @throws IOException
*/
Recorder to(String out) throws IOException;
/**
* 转发源视频到输出(复制)
*
* @param src
* 视频源
* @param out
* 输出文件或流媒体服务推流地址
* @return
* @throws IOException
*/
Recorder stream(String src, String out) throws IOException;
/**
* 设置音频参数
*
* @param audioChannels
* @param audioBitrate
* @param sampleRate
* @return
*/
Recorder audioParam(int audioChannels, int audioBitrate, int sampleRate);
/**
* 设置视频参数
*
* @param width
* @param height
* @param framerate
* @param bitrate
* @return
*/
Recorder videoParam(Integer width, Integer height, int framerate, int bitrate);
/**
* 开始录制
*
* @return
*/
Recorder start();
/**
* 暂停录制
*
* @return
*/
Recorder pause();
/**
* 继续录制(从暂停中恢复)
*
* @return
*/
Recorder carryon();
/**
* 停止录制
*
* @return
*/
Recorder stop();
/**
* 线程是否可用
* @return
*/
boolean alive();
/**
* 工作线程实时状态,用于保活(状态码:0-初始状态,1-运行,2-停止)
* @return
*/
int status();
}
| 1,748 | 0.579167 | 0.577083 | 106 | 12.584906 | 14.697495 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.95283 | false | false | 1 |
9787fee41362ae1f480537a2485f1c17072ebb2c | 21,225,728,417,895 | 06dd0a597a00de6c1399bc99829be652e8766c32 | /core/nuts-runtime/src/main/java/net/thevpc/nuts/runtime/standalone/io/util/AbstractMultiReadNInputSource.java | b25147d15a8feaceadf1ae54bbb03e1048db0283 | [
"Apache-2.0"
]
| permissive | thevpc/nuts | https://github.com/thevpc/nuts | 8703455fb84663e006012856ab34de230869d596 | d3b9aed973c7604362439484098fd4c313623b69 | refs/heads/master | 2023-08-19T10:15:26.234000 | 2023-08-18T14:59:30 | 2023-08-18T14:59:30 | 98,169,854 | 107 | 4 | NOASSERTION | false | 2023-08-15T17:41:23 | 2017-07-24T08:51:47 | 2023-07-27T15:12:57 | 2023-08-15T17:41:22 | 272,236 | 96 | 4 | 17 | Java | false | false | package net.thevpc.nuts.runtime.standalone.io.util;
import net.thevpc.nuts.NSession;
public abstract class AbstractMultiReadNInputSource extends AbstractNInputSource{
public AbstractMultiReadNInputSource(NSession session) {
super(session);
}
@Override
public boolean isMultiRead() {
return true;
}
}
| UTF-8 | Java | 339 | java | AbstractMultiReadNInputSource.java | Java | []
| null | []
| package net.thevpc.nuts.runtime.standalone.io.util;
import net.thevpc.nuts.NSession;
public abstract class AbstractMultiReadNInputSource extends AbstractNInputSource{
public AbstractMultiReadNInputSource(NSession session) {
super(session);
}
@Override
public boolean isMultiRead() {
return true;
}
}
| 339 | 0.734513 | 0.734513 | 14 | 23.214285 | 24.707369 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 1 |
3effea075fc06fcd0e264b6c6af9ef73b22e0215 | 15,144,054,720,165 | 1aab778faf3ee39bcbd7384c69a7391b35b29c86 | /src/main/java/com/juzuan/advertiser/rpts/mapper/AdvertiserCampaignRptsDayGetMapper.java | 4ff5e1c111067c88c6424e232ccd2122bed13ec8 | []
| no_license | raoweidong/yunrao2 | https://github.com/raoweidong/yunrao2 | 0bb3651be76ec7b5a72dacfae5572072c0d47d3a | f9a41a39a9fec7624092f077a4ec3f8410f8f2ae | refs/heads/master | 2020-04-09T08:04:50.769000 | 2018-12-28T12:39:18 | 2018-12-28T12:39:18 | 160,181,521 | 0 | 3 | null | false | 2018-12-14T01:44:01 | 2018-12-03T11:37:03 | 2018-12-13T09:54:17 | 2018-12-13T09:54:16 | 76,229 | 0 | 1 | 1 | Java | false | null | package com.juzuan.advertiser.rpts.mapper;
import com.juzuan.advertiser.rpts.model.AdvertiserCampaignRptsDayGet;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AdvertiserCampaignRptsDayGetMapper {
int deleteByPrimaryKey(Integer id);
int insert(AdvertiserCampaignRptsDayGet record);
int insertSelective(AdvertiserCampaignRptsDayGet record);
AdvertiserCampaignRptsDayGet selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AdvertiserCampaignRptsDayGet record);
int updateByPrimaryKey(AdvertiserCampaignRptsDayGet record);
void deleteAll();
} | UTF-8 | Java | 609 | java | AdvertiserCampaignRptsDayGetMapper.java | Java | []
| null | []
| package com.juzuan.advertiser.rpts.mapper;
import com.juzuan.advertiser.rpts.model.AdvertiserCampaignRptsDayGet;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AdvertiserCampaignRptsDayGetMapper {
int deleteByPrimaryKey(Integer id);
int insert(AdvertiserCampaignRptsDayGet record);
int insertSelective(AdvertiserCampaignRptsDayGet record);
AdvertiserCampaignRptsDayGet selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AdvertiserCampaignRptsDayGet record);
int updateByPrimaryKey(AdvertiserCampaignRptsDayGet record);
void deleteAll();
} | 609 | 0.825944 | 0.825944 | 20 | 29.5 | 28.127388 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 1 |
628e09c22fd8f308d9d68c107bf693443551b6b4 | 27,771,258,564,907 | aadc05cccbccea45085121f9664e06d4de9d1e5f | /src/main/java/com/equinix/nocc/api/MetroController.java | 669efa2e450d4b5c39cfd1869f159565e4cbf196 | []
| no_license | equinix-santosh/nocc-microservice-api | https://github.com/equinix-santosh/nocc-microservice-api | 0e0181f1a251109cd02eb7b8baa319f2f3732360 | 0182d626508b19d18c43c56b29eabff1056796b7 | refs/heads/master | 2015-08-23T21:45:53.284000 | 2015-05-01T20:59:30 | 2015-05-01T20:59:30 | 34,822,071 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.equinix.nocc.api;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.equinix.nocc.dao.MetroDAO;
import com.equinix.nocc.model.Metro;
import com.equinix.nocc.utils.Constants;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/services/metro")
@Api("Metro API")
public class MetroController {
protected final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
private MetroDAO metroDAO;
@RequestMapping(method=RequestMethod.GET,produces={Constants.CONTENT_JSON} )
@ApiOperation(position=2,value = "Get Metro Details By Region",notes="Example: AMER,EMEA,APAC")
public ResponseEntity<List<Metro>> getByRegion(
@RequestParam(value="regionCode",required=false) String regionCode ){
log.info("In Metro Controller");
return new ResponseEntity<List<Metro>>(metroDAO.getByRegion(regionCode),HttpStatus.OK);
}
@RequestMapping(value="/code",method=RequestMethod.GET,produces={Constants.CONTENT_JSON} )
@ApiOperation(position=2,value = "Get Metro Details By Metro-Code",notes="Example: AT,LD,SY")
public ResponseEntity<Metro> getByCode(
@RequestParam(value="metroCode",required=false) String metroCode ){
log.info("In Metro Controller");
return new ResponseEntity<Metro>(metroDAO.getByCode(metroCode),HttpStatus.OK);
}
}
| UTF-8 | Java | 1,844 | java | MetroController.java | Java | []
| null | []
| package com.equinix.nocc.api;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.equinix.nocc.dao.MetroDAO;
import com.equinix.nocc.model.Metro;
import com.equinix.nocc.utils.Constants;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/services/metro")
@Api("Metro API")
public class MetroController {
protected final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
private MetroDAO metroDAO;
@RequestMapping(method=RequestMethod.GET,produces={Constants.CONTENT_JSON} )
@ApiOperation(position=2,value = "Get Metro Details By Region",notes="Example: AMER,EMEA,APAC")
public ResponseEntity<List<Metro>> getByRegion(
@RequestParam(value="regionCode",required=false) String regionCode ){
log.info("In Metro Controller");
return new ResponseEntity<List<Metro>>(metroDAO.getByRegion(regionCode),HttpStatus.OK);
}
@RequestMapping(value="/code",method=RequestMethod.GET,produces={Constants.CONTENT_JSON} )
@ApiOperation(position=2,value = "Get Metro Details By Metro-Code",notes="Example: AT,LD,SY")
public ResponseEntity<Metro> getByCode(
@RequestParam(value="metroCode",required=false) String metroCode ){
log.info("In Metro Controller");
return new ResponseEntity<Metro>(metroDAO.getByCode(metroCode),HttpStatus.OK);
}
}
| 1,844 | 0.777115 | 0.774946 | 52 | 34.46154 | 30.997185 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.480769 | false | false | 1 |
1df93951fe0866ee3e7cfa1bb95bdb32c21a39b8 | 3,856,880,685,084 | 0208dc692b4c1d7138142db2a280986de679ad78 | /src/main/java/com/fradou/nutrition/mvc/controller/SecurityController.java | 059ede010048348546c5145c8465ef137e6a6a81 | []
| no_license | alexandrefradet/my-nutrition-api | https://github.com/alexandrefradet/my-nutrition-api | 84e5268db1fa2303279c297a6c88bb1c0df10c82 | c0044a664fd2eaf37620a770c644e49279944ca5 | refs/heads/master | 2021-09-22T01:32:42.044000 | 2018-08-29T15:38:32 | 2018-08-29T15:38:32 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.fradou.nutrition.mvc.controller;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import com.fradou.nutrition.mvc.entity.security.CustomUser;
import com.fradou.nutrition.mvc.entity.security.Role;
import com.fradou.nutrition.mvc.service.impl.RoleServiceImpl;
import com.fradou.nutrition.mvc.service.impl.UserServiceImpl;
@Controller
public class SecurityController {
@Autowired
private UserServiceImpl uService;
@Autowired
private RoleServiceImpl rService;
@GetMapping("/login")
public String login() {
return "customLogin";
}
@GetMapping("/access-denied")
public String accessDeniedPage() {
return "accessDenied";
}
@GetMapping(value="/register")
public String registerUser(Model model) {
CustomUser user = new CustomUser();
model.addAttribute("newUser", user);
return "user/registration";
}
@PostMapping(value="/register")
public String registerUserValidation(Model model,@Valid @ModelAttribute("newUser") CustomUser user, BindingResult validationResult) {
boolean hasError = false;
if(validationResult.hasErrors()) {
hasError = true;
}
if(uService.alreadyExists("username",user.getUsername())) {
validationResult.addError(new FieldError("newUser", "username", "Username déjà utilisé dommage!"));
hasError = true;
}
if(uService.alreadyExists("email", user.getEmail())) {
validationResult.addError(new FieldError("newUser", "email", "Email déjà utilisé dommage!"));
hasError = true;
}
if(hasError) {
return "user/registration";
}
setupUser(user);
uService.create(user);
return "user/welcome";
}
/**
* Method used to treat user data before persistance
* @param user
*/
private void setupUser(CustomUser user) {
// Password hash
String hash_pw = BCrypt.hashpw(user.getPassword(), BCrypt.gensalt());
user.setPassword("{bcrypt}" + hash_pw);
// User disable by default user
user.setEnabled(false);
// Give basic use role
Role role = rService.findUniqueBy("authority", "ROLE_USER");
user.addRole(role);
}
}
| UTF-8 | Java | 2,540 | java | SecurityController.java | Java | [
{
"context": "ssword(), BCrypt.gensalt());\n\t\tuser.setPassword(\"{bcrypt}\" + hash_pw);\n\t\t\n\t\t// User disable by default use",
"end": 2338,
"score": 0.8753296136856079,
"start": 2332,
"tag": "PASSWORD",
"value": "bcrypt"
},
{
"context": "t.gensalt());\n\t\tuser.setPassword(\"{bcrypt}\" + hash_pw);\n\t\t\n\t\t// User disable by default user\n\t\tuser.set",
"end": 2350,
"score": 0.6444534063339233,
"start": 2348,
"tag": "PASSWORD",
"value": "pw"
}
]
| null | []
| package com.fradou.nutrition.mvc.controller;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import com.fradou.nutrition.mvc.entity.security.CustomUser;
import com.fradou.nutrition.mvc.entity.security.Role;
import com.fradou.nutrition.mvc.service.impl.RoleServiceImpl;
import com.fradou.nutrition.mvc.service.impl.UserServiceImpl;
@Controller
public class SecurityController {
@Autowired
private UserServiceImpl uService;
@Autowired
private RoleServiceImpl rService;
@GetMapping("/login")
public String login() {
return "customLogin";
}
@GetMapping("/access-denied")
public String accessDeniedPage() {
return "accessDenied";
}
@GetMapping(value="/register")
public String registerUser(Model model) {
CustomUser user = new CustomUser();
model.addAttribute("newUser", user);
return "user/registration";
}
@PostMapping(value="/register")
public String registerUserValidation(Model model,@Valid @ModelAttribute("newUser") CustomUser user, BindingResult validationResult) {
boolean hasError = false;
if(validationResult.hasErrors()) {
hasError = true;
}
if(uService.alreadyExists("username",user.getUsername())) {
validationResult.addError(new FieldError("newUser", "username", "Username déjà utilisé dommage!"));
hasError = true;
}
if(uService.alreadyExists("email", user.getEmail())) {
validationResult.addError(new FieldError("newUser", "email", "Email déjà utilisé dommage!"));
hasError = true;
}
if(hasError) {
return "user/registration";
}
setupUser(user);
uService.create(user);
return "user/welcome";
}
/**
* Method used to treat user data before persistance
* @param user
*/
private void setupUser(CustomUser user) {
// Password hash
String hash_pw = BCrypt.hashpw(user.getPassword(), BCrypt.gensalt());
user.setPassword("{<PASSWORD>}" + hash_pw);
// User disable by default user
user.setEnabled(false);
// Give basic use role
Role role = rService.findUniqueBy("authority", "ROLE_USER");
user.addRole(role);
}
}
| 2,544 | 0.747435 | 0.747435 | 94 | 25.957447 | 26.094719 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.787234 | false | false | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.