blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
332
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
50
| license_type
stringclasses 2
values | repo_name
stringlengths 7
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 557
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
684M
⌀ | star_events_count
int64 0
77.7k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 82
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
5.41M
| extension
stringclasses 11
values | content
stringlengths 7
5.41M
| authors
listlengths 1
1
| author
stringlengths 0
161
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9d6563a0a289b8a47ddeebcc18f12adb1b7d91ba
|
e9e1360db4f6b0db271a3c316651f1f6e15bbcb6
|
/src/main/java/models/Opinion.java
|
08b2eac3880c61533f21fd33b1b2eec6d2da922b
|
[] |
no_license
|
enmanuelm19/AmericanTech
|
3679f70fbbbc66b6c23c7d268e54e9d897eb61c7
|
8507956e416f374f1bf830852b5a5390d2755005
|
refs/heads/master
| 2021-12-29T18:07:23.583481
| 2021-12-28T18:30:40
| 2021-12-28T18:30:40
| 54,125,581
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,418
|
java
|
package models;
import java.util.Date;
public class Opinion {
private int id;
private String descripcion;
private Date fecha;
private int calificacion;
private Postulacion postulacionId;
private Usuario usuarioId;
public Opinion() {
super();
// TODO Auto-generated constructor stub
}
public Opinion(int id, String descripcion, Date fecha, int calificacion,
Postulacion postulacionId, Usuario usuarioId) {
super();
this.id = id;
this.descripcion = descripcion;
this.fecha = fecha;
this.calificacion = calificacion;
this.postulacionId = postulacionId;
this.usuarioId = usuarioId;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public Date getFecha() {
return fecha;
}
public void setFecha(Date fecha) {
this.fecha = fecha;
}
public int getCalificacion() {
return calificacion;
}
public void setCalificacion(int calificacion) {
this.calificacion = calificacion;
}
public Postulacion getPostulacionId() {
return postulacionId;
}
public void setPostulacionId(Postulacion postulacionId) {
this.postulacionId = postulacionId;
}
public Usuario getUsuarioId() {
return usuarioId;
}
public void setUsuarioId(Usuario usuarioId) {
this.usuarioId = usuarioId;
}
}
|
[
"fidel.alejos@gmail.com"
] |
fidel.alejos@gmail.com
|
e12c3ca176508715febf28bcc13f6ac04c50cf90
|
2e5492e248fcbf608920fb02da768dff09a59b2a
|
/Padrões de Projeto Comportamentais/behavioral-patterns/src/main/java/br/com/cod3r/strategy/person/Client.java
|
dbb30a109b62f022d664ca4b4b13a81e440ff37d
|
[] |
no_license
|
lucashsouza/curso-padroes-projeto
|
99c52c01135d8843bd96b5ed66334d32e9d71a5a
|
3f5110d60c8fde1ae8acdbc1cf28c239e22a486b
|
refs/heads/main
| 2023-07-30T12:20:40.074265
| 2021-09-26T21:48:24
| 2021-09-26T21:48:24
| 410,669,694
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,277
|
java
|
package br.com.cod3r.strategy.person;
import br.com.cod3r.strategy.person.strategies.eat.MeatFoodStrategy;
import br.com.cod3r.strategy.person.strategies.eat.VeggieFoodStrategy;
import br.com.cod3r.strategy.person.strategies.transportation.AirplaneStrategy;
import br.com.cod3r.strategy.person.strategies.transportation.BikeStrategy;
import br.com.cod3r.strategy.person.strategies.transportation.CarStrategy;
import br.com.cod3r.strategy.person.strategies.work.DeveloperStrategy;
import br.com.cod3r.strategy.person.strategies.work.PilotStrategy;
public class Client {
public static void presentYourself(Person person) {
System.out.println("Hi, I'm " + person.getName());
person.eat();
person.move();
person.work();
System.out.println("----------------");
}
public static void main(String[] args) {
Person john = new Person(
"John",
new MeatFoodStrategy(),
new CarStrategy(),
new DeveloperStrategy()
);
presentYourself(john);
Person ann = new Person(
"Ann",
new MeatFoodStrategy(),
new AirplaneStrategy(),
new PilotStrategy()
);
presentYourself(ann);
Person carol = new Person(
"Carol",
new VeggieFoodStrategy(),
new BikeStrategy(),
new DeveloperStrategy()
);
presentYourself(carol);
}
}
|
[
"lhenriquesouza00@gmail.com"
] |
lhenriquesouza00@gmail.com
|
4566cfb8cfcdd2a2e464a1c932bba42b6cdb165f
|
ed589ea2c8dededa36d3b6d24fc86472a22322b6
|
/trunk/GoJava4/akhambir/Kickstarter/main/java/com/project/pages/MainPage.java
|
da64fdce56bba08eacc71d70219897c464d8d5dc
|
[] |
no_license
|
baygoit/GoJava
|
dcf884d271a4612051036e4fdc2c882c343ec870
|
a0a07165092bcc60e109c84227b0024f4bca38ed
|
refs/heads/master
| 2020-04-16T01:46:09.808322
| 2016-08-06T06:28:13
| 2016-08-06T06:28:13
| 42,005,479
| 8
| 27
| null | 2016-03-09T11:26:20
| 2015-09-06T14:28:53
|
Java
|
UTF-8
|
Java
| false
| false
| 55
|
java
|
package com.project.pages;
public class MainPage {
}
|
[
"a.khambir@gmail.com@371e26f7-1d5d-4d7b-6139-2def7fa80f1e"
] |
a.khambir@gmail.com@371e26f7-1d5d-4d7b-6139-2def7fa80f1e
|
006c380bbfa69d2f5c640f56da123fb640f774ae
|
d603c08ac66dfac297b62a5691f3b1f332274819
|
/back-end/src/main/java/ola/hd/longtermstorage/domain/TrackingResponse.java
|
dfaddaad9ae5ec4775ea39885ace8822c86c018c
|
[
"Apache-2.0"
] |
permissive
|
subugoe/OLA-HD-IMPL
|
747d71e00db0be3618cd67d3c3c0d163d493a551
|
b944d649237c146efca81de3d45566783fa1e5be
|
refs/heads/master
| 2022-12-15T03:13:00.506730
| 2021-04-16T12:57:27
| 2021-04-16T12:57:27
| 170,673,166
| 10
| 0
|
Apache-2.0
| 2022-12-11T21:35:47
| 2019-02-14T10:28:24
|
Java
|
UTF-8
|
Java
| false
| false
| 953
|
java
|
package ola.hd.longtermstorage.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TrackingResponse {
private TrackingInfo trackingInfo;
private ArchiveResponse archiveResponse;
public TrackingResponse(TrackingInfo trackingInfo) {
this.trackingInfo = trackingInfo;
}
public TrackingResponse(TrackingInfo trackingInfo, ArchiveResponse archiveResponse) {
this.trackingInfo = trackingInfo;
this.archiveResponse = archiveResponse;
}
public TrackingInfo getTrackingInfo() {
return trackingInfo;
}
public void setTrackingInfo(TrackingInfo trackingInfo) {
this.trackingInfo = trackingInfo;
}
public ArchiveResponse getArchiveResponse() {
return archiveResponse;
}
public void setArchiveResponse(ArchiveResponse archiveResponse) {
this.archiveResponse = archiveResponse;
}
}
|
[
"triet.doan@gwdg.de"
] |
triet.doan@gwdg.de
|
66f135d717280f1f78df5e50df4acde502a0ef09
|
32ddc360f42609daf5e4e5f787d1799a8ada3992
|
/app/src/main/java/hezra/wingsnsides/ChickenWings/ChickenFlavour.java
|
e6d82295a5289f58044ea31fdcbab8e22134a752
|
[] |
no_license
|
shadygoneinsane/OnlineDeliveryApp
|
7927645d82ab8a34f804b4c6ad9019275e012dbd
|
0c9f44cfaaba99ba48e047bbb8c159c8c1b0237e
|
refs/heads/master
| 2021-07-17T12:15:02.399555
| 2017-10-26T06:23:49
| 2017-10-26T06:23:49
| 105,480,050
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 752
|
java
|
package hezra.wingsnsides.ChickenWings;
/**
* Created by vikesh on 11-06-2017.
*/
public class ChickenFlavour {
private String pID;
private String pNAME;
private String pDETAIL;
private String cID;
public String getPID() {
return pID;
}
public void setPID(String pID) {
this.pID = pID;
}
public String getPNAME() {
return pNAME;
}
public void setPNAME(String pNAME) {
this.pNAME = pNAME;
}
public String getPDETAIL() {
return pDETAIL;
}
public void setPDETAIL(String pDETAIL) {
this.pDETAIL = pDETAIL;
}
public String getCID() {
return cID;
}
public void setCID(String cID) {
this.cID = cID;
}
}
|
[
"vikeshdass@gmail.com"
] |
vikeshdass@gmail.com
|
91b3fd49acf41b0f8d69599538ce1928b38bc166
|
b93a6242b607e1e20540da0f59a6041f8e3bc28e
|
/java/src/plugins/com/dgrid/plugins/GroovyMapReducePlugin.java
|
c29749da9012baa660760e861c2d819aaaff6e4b
|
[
"Apache-2.0"
] |
permissive
|
samtingleff/dgrid
|
edd9b1fea991023eff89f5bac412249015a2aaed
|
47fb753159e5b6c538e70fef2903c8028d7cf897
|
refs/heads/master
| 2021-01-17T12:47:26.170016
| 2009-05-13T21:56:16
| 2009-05-13T21:56:16
| 51,359
| 2
| 3
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 920
|
java
|
package com.dgrid.plugins;
import java.io.File;
import com.dgrid.gen.Constants;
import com.dgrid.handlers.GroovyMapReduceTypeHandler;
import com.dgrid.plugin.BaseDGridPlugin;
import com.dgrid.service.DGridPluginManager;
public class GroovyMapReducePlugin extends BaseDGridPlugin {
public String getDescription() {
return "Adds support for simple groovy-based map/reduce jobs";
}
public void start() {
DGridPluginManager mgr = (DGridPluginManager) pluginManager;
GroovyMapReduceTypeHandler handler = new GroovyMapReduceTypeHandler(
new File("plugins/groovy/mr"));
mgr.setJobletTypeHandler(Constants.GROOVY_MR_JOB, handler);
mgr.setJobletTypeHandler(Constants.GROOVY_MR_REDUCER, handler);
}
public void stop() {
DGridPluginManager mgr = (DGridPluginManager) pluginManager;
mgr.removeJobletTypeHandler(Constants.GROOVY_MR_JOB);
mgr.removeJobletTypeHandler(Constants.GROOVY_MR_REDUCER);
}
}
|
[
"sam@structure28.com"
] |
sam@structure28.com
|
567c9e8d7636176964b08e3b6ac862bb47e2c7a5
|
0b08e249f66c477b357274f73fa6c1c7b5d41db2
|
/spring-cloud-acm-example/src/main/java/com/zwd/acm/AcmApplication.java
|
177b920c5f21b2191cbf336661c0e1242ef54257
|
[] |
no_license
|
tanglitao/nacos-examples
|
5f3c75ef118e578e00883e3b5c033bd96bb57778
|
7fbfdeb9b62198c307684161ad439b96219dbb1e
|
refs/heads/master
| 2020-06-04T04:06:11.655638
| 2019-01-09T12:33:41
| 2019-01-09T12:33:41
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 751
|
java
|
package com.zwd.acm;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
/**
* @author zwd
* @date 2019/1/7 20:22
* @Email stephen.zwd@gmail.com
*/
@SpringBootApplication
public class AcmApplication {
public static void main(String[] args) {
ConfigurableApplicationContext applicationContext = SpringApplication.run(AcmApplication.class, args);
String userName = applicationContext.getEnvironment().getProperty("user.name");
String userAge = applicationContext.getEnvironment().getProperty("user.age");
System.err.println("user name :"+userName+"; age: "+userAge);
}
}
|
[
"810095178@qq.com"
] |
810095178@qq.com
|
ef5fff99b2e32abdd8dd8ad145b7e56dc5ac9b42
|
e29975c788155ddcd3f0edd4e6d78fa8ba595cc8
|
/de.akra.idocit.java.tests/src/test/resources/source/SpecialException.java
|
fb88e553d094d7783a6913b1cbf89c12d0f8883e
|
[
"Apache-2.0"
] |
permissive
|
jankrause/idocit
|
56aac26673bfa8fabf2a4f30eb0f32f4a33fd232
|
85b90f06d5f07413f900054766570874471a88f0
|
refs/heads/master
| 2020-04-20T14:39:25.204245
| 2012-11-16T11:38:40
| 2012-11-16T11:38:40
| 40,559,111
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,017
|
java
|
/*******************************************************************************
* Copyright 2012 AKRA GmbH
*
* 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 source;
public class SpecialException extends Exception
{
private static final long serialVersionUID = 1L;
private String message;
public String getMessage()
{
return message;
}
public void setMessage(String message)
{
this.message = message;
}
}
|
[
"krausedammann@web.de"
] |
krausedammann@web.de
|
31b43af741e1ff893888be1248bdec5dc734b7c6
|
198628244b481dfae06dfe15fd0ecda5a4849eba
|
/src/main/java/com/example/blockchaininfo/services/ConnectToApiCallable.java
|
7de7ce28d184edec6e32d7fe1e8e15411db05885
|
[] |
no_license
|
Maciass92/Blockchain-Info
|
2e287532a4c313fc1ee5f3f213d05c992fe403f3
|
3fdf4e15b4c4bbc0b12345a84daaeb5eda5f5c35
|
refs/heads/master
| 2020-03-09T12:05:20.859371
| 2018-05-28T10:06:02
| 2018-05-28T10:06:02
| 128,777,203
| 0
| 0
| null | 2018-05-28T10:06:03
| 2018-04-09T13:35:22
|
Java
|
UTF-8
|
Java
| false
| false
| 1,461
|
java
|
package com.example.blockchaininfo.services;
import com.example.blockchaininfo.pojos.ReturnedPoolData;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
import java.time.OffsetDateTime;
import java.util.concurrent.Callable;
@Slf4j
public class ConnectToApiCallable implements Callable<ReturnedPoolData> {
private String url;
private String poolName;
private String poolType;
public ConnectToApiCallable(String url, String poolName, String poolType) {
this.url = url;
this.poolName = poolName;
this.poolType = poolType;
}
@Override
public ReturnedPoolData call(){
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create().build());
clientHttpRequestFactory.setConnectTimeout(4000);
RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory);
ReturnedPoolData stringAndDate = new ReturnedPoolData();
stringAndDate.setJsonString(restTemplate.getForObject(url, String.class));
stringAndDate.setDateTime(OffsetDateTime.now());
stringAndDate.setPoolName(this.poolName);
stringAndDate.setPoolType(this.poolType);
return stringAndDate;
}
}
|
[
"mac.komorowski@gmail.com"
] |
mac.komorowski@gmail.com
|
b343dec52a0fda1def4267ac020582df33db2519
|
f9fcedd4b83165848b3b1c03b5d9c35e9aef0042
|
/app/src/main/java/com/nineleaps/eazipoc/utils/TypeConverterObject.java
|
83471e86e927701d6edc77528563319625491452
|
[] |
no_license
|
KrishnaKumar97/Eazi
|
a2fdd225d9cf3cdf7e06b2da494f4f81bd9ddafc
|
1dd50998857b63c5250186ca200580e5b3fdd6f5
|
refs/heads/master
| 2022-11-29T17:17:14.414112
| 2020-08-07T08:11:02
| 2020-08-07T08:11:02
| 283,494,755
| 0
| 0
| null | 2020-08-07T08:11:04
| 2020-07-29T12:36:17
|
Kotlin
|
UTF-8
|
Java
| false
| false
| 1,296
|
java
|
package com.nineleaps.eazipoc.utils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nineleaps.eazipoc.models.MessageDatabaseModel;
import java.lang.reflect.Type;
import java.util.List;
public class TypeConverterObject {
/**
* Function to convert incoming List object to String
* @return String
*/
@androidx.room.TypeConverter
public String fromMessageDatabaseModelList(List<MessageDatabaseModel> messageDatabaseModelList) {
if (messageDatabaseModelList == null) {
return (null);
}
Gson gson = new Gson();
Type type = new TypeToken<List<MessageDatabaseModel>>() {
}.getType();
return gson.toJson(messageDatabaseModelList, type);
}
/**
* Function to convert incoming String object to List of datamodels
* @return List of datamodels
*/
@androidx.room.TypeConverter
public List<MessageDatabaseModel> toMessageDatabaseModelList(String messageDatabaseModelString) {
if (messageDatabaseModelString == null) {
return (null);
}
Gson gson = new Gson();
Type type = new TypeToken<List<MessageDatabaseModel>>() {
}.getType();
return gson.fromJson(messageDatabaseModelString, type);
}
}
|
[
"krishnakumar.v@nineleaps.com"
] |
krishnakumar.v@nineleaps.com
|
0e49c5e3e04f651e4b9a472ec56c60a092975f44
|
bdf1171e3686190fde6611e79d55ee91d974100e
|
/mongodb_demo/java/mongoDBDemo/src/test/java/test/mrgan/mongodb/repository/CustomerRepositoryTest.java
|
d8061f6c13e65f0204020182dca8b0fbf0c0cd32
|
[] |
no_license
|
mupengfei/demo
|
2eae45836e75d8457d99fd21ce90cf1d1e5d366a
|
efedb764368e470cf399809a729d4ef385a46a80
|
refs/heads/master
| 2022-10-28T13:14:21.880143
| 2019-12-02T00:13:53
| 2019-12-02T00:13:53
| 71,767,383
| 0
| 0
| null | 2022-10-12T20:11:17
| 2016-10-24T08:19:44
|
HTML
|
UTF-8
|
Java
| false
| false
| 1,436
|
java
|
package test.mrgan.mongodb.repository;
import java.util.Date;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import com.mrgan.mongodb.Application;
import com.mrgan.mongodb.model.Customer;
import com.mrgan.mongodb.repository.CustomerRepository;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
//@TestPropertySource(locations = "classpath:/config/test.properties")
public class CustomerRepositoryTest {
@Autowired
private CustomerRepository customerRepository;
@Autowired
private MongoTemplate mongoTemplate;
@Before
public void setUp() throws Exception {
}
@Test
public void save() throws Exception {
customerRepository.save(new Customer("firstName3", "lastName", new Date()));
}
@Test
public void findAll() throws Exception {
for (Customer customer : customerRepository.findAll()) {
System.out.println(customer);
}
}
@Test
public void template() throws Exception {
}
}
|
[
"mupf.zj@gmail.com"
] |
mupf.zj@gmail.com
|
7e11c3e30c962439ed24a896935f926e737d2bd6
|
02fadb57d8c40066e398b6ec524c040d8404f550
|
/reactivex/src/main/java/cc/buddies/component/reactivex/usecase/SingleUseCaseWithParameter.java
|
4bfd8faadbc4db3a5c1949b4cd44ff22536fb64b
|
[] |
no_license
|
zhaowenliang/BuddiesComponent
|
7ab5fbe497b6317a5811e4d0388525f54f810ea6
|
c733841d10f3f2d16b3120ca1b6c1e7987329127
|
refs/heads/master
| 2023-07-02T04:17:15.985755
| 2021-08-12T07:46:08
| 2021-08-12T07:46:08
| 285,260,732
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 181
|
java
|
package cc.buddies.component.reactivex.usecase;
import io.reactivex.rxjava3.core.Single;
public interface SingleUseCaseWithParameter<P, R> {
Single<R> execute(P parameter);
}
|
[
"zwldh123@163.com"
] |
zwldh123@163.com
|
6f2a52280ac2bd5d63453efe7f05089f27ce79e5
|
6c8436eabae3ed862ec7f7c1f1e25e6d19cc1a04
|
/YoutubePlayer/src/main/java/com/youtubeplayer/model/Mixes.java
|
1eb6ce8f972bfeccdd8c22f2f1908f043dfb7207
|
[] |
no_license
|
rizalmf/YoutubePlayer
|
be0b4f50d670504d49e23d3715bb28923ebb9a0f
|
4cc186567c3f27609d237197bf1d6673691f56e2
|
refs/heads/master
| 2022-11-22T22:20:53.768943
| 2020-07-29T10:39:47
| 2020-07-29T10:39:47
| 280,852,245
| 2
| 2
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 916
|
java
|
/*
* Copyright 2020 Java Programmer Indonesia.
*
* 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.youtubeplayer.model;
/**
*
* @author rizal
*/
public class Mixes extends Video{
private String playlistId;
public String getPlaylistId() {
return playlistId;
}
public void setPlaylistId(String playlistId) {
this.playlistId = playlistId;
}
}
|
[
"gorenglahayam@gmail.com"
] |
gorenglahayam@gmail.com
|
79bb147bab50d319ed68a2660df3d954b1b6dbc1
|
f544fb9383f8f6859af5585267fb93448f27e70b
|
/mobile/src/main/java/com/siliconlabs/bledemo/ble/BluetoothLEGatt.java
|
f359159dbd8a5533e687122760337e70650344b6
|
[] |
no_license
|
jeesang7/Bluegecko-android
|
6d5c705bc458056e5435b365c2b826299c90177b
|
5f73f7e1c86660aad052aab2c50ce8370dee1f39
|
refs/heads/master
| 2020-12-09T10:43:25.217534
| 2019-12-18T13:02:35
| 2019-12-18T13:02:35
| 112,364,667
| 0
| 0
| null | 2018-09-06T19:28:48
| 2017-11-28T17:08:23
|
Java
|
UTF-8
|
Java
| false
| false
| 18,583
|
java
|
package com.siliconlabs.bledemo.ble;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCallback;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.util.Log;
import android.util.SparseArray;
import com.siliconlabs.bledemo.BuildConfig;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import timber.log.Timber;
/**
* Handles the BLE communication by serializing connections, discoveries, requests and responses.
*/
class BluetoothLEGatt {
static final SparseArray<GattService> GATT_SERVICE_DESCS = new SparseArray<>();
static final SparseArray<GattCharacteristic> GATT_CHARACTER_DESCS = new SparseArray<>();
// If a gatt's service scan request is pending, cancel it after SCAN_CONNECTION_TIMEOUT milliseconds if there is no answer/response yet.
private static final int SCAN_CONNECTION_TIMEOUT = 10000; //TODO It was 10000
// When reading a remote value from a gatt device, never wait longer than GATT_READ_TIMEOUT to obtain a value.
private static final int GATT_READ_TIMEOUT = 8000; //TODO It was 2
private static ScheduledExecutorService SYNCHRONIZED_GATT_ACCESS_EXECUTOR = Executors.newSingleThreadScheduledExecutor();
protected final BluetoothDevice device;
protected List<BluetoothGattService> interestingServices;
protected volatile boolean isOfInterest;
private final Context context;
private final BluetoothGattCallback gattCallback;
private final Runnable gattScanTimeout = new Runnable() {
@Override
public void run() {
setGattServices(null);
close();
}
};
private ScheduledFuture<?> scanTimeoutFuture;
private BluetoothGatt gatt;
private final Characteristics characteristics = new Characteristics();
static void cancelAll(final Collection<BluetoothLEGatt> leGatts) {
SYNCHRONIZED_GATT_ACCESS_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
for (BluetoothLEGatt leGatt : leGatts) {
if (leGatt != null) {
leGatt.close();
}
}
}
});
}
BluetoothLEGatt(final Context context, BluetoothDevice pDevice) {
this.context = context;
this.device = pDevice;
gattCallback = new BluetoothGattCallback() {
// for Gatt Status codes:
// https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.3_r1.1/stack/include/gatt_api.h
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
if (status != BluetoothGatt.GATT_SUCCESS) {
Log.i("onConnectionStateChange","failed with status: " + status + " (newState =" + newState + ") " + device.getAddress());
Timber.w("onConnectionStateChange failed with status " + status + " (newState =" + newState + ") " + device.getAddress());
SYNCHRONIZED_GATT_ACCESS_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
setGattServices(null);
}
});
return;
}
Log.i("onConnectionStateChange","(newState =" + newState + ") " + device.getAddress());
Timber.w("onConnectionStateChange (newState =" + newState + ") " + device.getAddress());
switch (newState) {
case BluetoothProfile.STATE_CONNECTED:
SYNCHRONIZED_GATT_ACCESS_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
discoverServices();
}
});
break;
case BluetoothProfile.STATE_DISCONNECTED:
SYNCHRONIZED_GATT_ACCESS_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
setGattServices(null);
}
});
break;
}
}
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Log.i("onServicesDiscovered","onServicesDiscovered " + device.getAddress());
Timber.w("onServicesDiscovered " + device.getAddress());
SYNCHRONIZED_GATT_ACCESS_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
displayGattServices();
}
});
} else {
Log.i("onServicesDiscovered","onServicesDiscovered received: " + status + " " + device.getAddress());
Timber.w("onServicesDiscovered received: " + status + " " + device.getAddress());
SYNCHRONIZED_GATT_ACCESS_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
setGattServices(null);
}
});
}
}
@Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Log.i("onCharacteristicRead","Char " + getCharacteristicName(characteristic.getUuid()) + " <- " + getCharacteristicsValue(characteristic));
Timber.d("Char " + getCharacteristicName(characteristic.getUuid()) + " <- " + getCharacteristicsValue(characteristic));
characteristics.onRead(getIdentification(characteristic.getUuid()), getCharacteristicsValue(characteristic), true);
} else {
Timber.w("onCharacteristicRead received: " + status);
Log.i("onCharacteristicRead","onCharacteristicRead received: " + status);
characteristics.onRead(getIdentification(characteristic.getUuid()), null, false);
}
}
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
//Log.d("onCharacteristcWrite","Char " + getCharacteristicsValue(characteristic) + " -> " + getCharacteristicName(characteristic.getUuid()));
Timber.d("Char " + getCharacteristicsValue(characteristic) + " -> " + getCharacteristicName(characteristic.getUuid()));
} else {
//Log.e("onCharacteristcWrite","onCharacteristicWrite received: " + status);
Timber.w("onCharacteristicWrite received: " + status);
}
}
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
notifyCharacteristicChanged(getIdentification(characteristic.getUuid()), getCharacteristicsValue(characteristic));
}
};
/*
* Connect --OK--> Discover --OK--> displayServices & addCharacteristics
* | |
* | +-Err-> reportNoServices
* |
* +-Err-> reportNoServices
*
* Disconnect ---> reportNoServices
*/
SYNCHRONIZED_GATT_ACCESS_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
connect();
}
});
}
private void connect() {
final boolean connectionAttemptFailed;
synchronized (this) {
if (gatt != null) {
return;
}
Log.e("connect()","Gatt connect for " + device.getAddress());
Timber.d("Gatt connect for " + device.getAddress());
scanTimeoutFuture = SYNCHRONIZED_GATT_ACCESS_EXECUTOR.schedule(gattScanTimeout, SCAN_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
gatt = device.connectGatt(context, false, gattCallback);
connectionAttemptFailed = (gatt == null);
}
if (connectionAttemptFailed) {
setGattServices(null);
}
}
private boolean discoverServices() {
final boolean hasServicesCached;
final boolean discoverStartSucceeded;
synchronized (this) {
if (gatt == null) {
return false;
}
//hasServicesCached = !gatt.getServices().isEmpty(); //TODO Uncomment - Trying to awayes discover services
discoverStartSucceeded = /*hasServicesCached ||*/ gatt.discoverServices();
}
/*
if (hasServicesCached) {
displayGattServices();
return true;
}*/
if (!discoverStartSucceeded) {
setGattServices(null);
return false;
}
return true;
}
private void displayGattServices() {
List<BluetoothGattService> gattServices;
synchronized (this) {
if (gatt == null) {
return;
}
gattServices = gatt.getServices();
if (gattServices == null) {
gattServices = new ArrayList<>();
}
boolean hasGattServices = !gattServices.isEmpty();
if (hasGattServices) {
characteristics.clearCharacteristics();
// Loops through available GATT Services.
for (BluetoothGattService gattService : gattServices) {
Timber.d("Device has service: " + getServiceName(gattService.getUuid()));
Log.e("displayGattServices()","Device has service: " + getServiceName(gattService.getUuid()));
characteristics.addCharacteristics(gatt, gattService.getCharacteristics());
Timber.d("==========================\n");
Log.e("displayGattServices()","==========================\n");
}
}
}
setGattServices(gattServices);
}
protected void setGattServices(List<BluetoothGattService> services) {
Timber.d("setGattServices for " + device.getAddress());
//Log.d("displayGattServices()","setGattServices for " + device.getAddress());
if (scanTimeoutFuture != null) {
scanTimeoutFuture.cancel(false);
scanTimeoutFuture = null;
}
if (services == null) {
interestingServices = null;
isOfInterest = false;
return;
}
interestingServices = new ArrayList<>();
for (BluetoothGattService service : services) {
interestingServices.add(service);
}
isOfInterest = !interestingServices.isEmpty();
}
protected void notifyCharacteristicChanged(int characteristicID, Object value) {
}
synchronized BluetoothGatt getGatt() {
return gatt;
}
protected synchronized void close() {
if (gatt == null) {
return;
}
try {
gatt.close();
gatt = null;
} catch (Exception e) {
Timber.w(e, "Error closing Gatt");
Log.e("displayGattServices()","Error closing Gatt: " + e);
}
}
public void cancel() {
SYNCHRONIZED_GATT_ACCESS_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
close();
}
});
}
void read(final int characteristicID) {
SYNCHRONIZED_GATT_ACCESS_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
Object value = characteristics.read(characteristicID);
notifyCharacteristicChanged(characteristicID, value);
}
});
}
synchronized boolean representsConnectedDevice(BluetoothDevice btDevice) {
return (gatt != null) && device.equals(btDevice);
}
private static String getServiceName(UUID uuid) {
GattService service = GATT_SERVICE_DESCS.get(getIdentification(uuid));
return (service != null)? service.type : uuid.toString();
}
private static String getCharacteristicName(UUID uuid) {
GattCharacteristic characteristic = GATT_CHARACTER_DESCS.get(getIdentification(uuid));
return (characteristic != null)? characteristic.type : uuid.toString();
}
private static Object getCharacteristicsValue(BluetoothGattCharacteristic gattCharacteristic) {
if (gattCharacteristic.getValue() == null) {
return null;
}
GattCharacteristic characteristic = GATT_CHARACTER_DESCS.get(getIdentification(gattCharacteristic.getUuid()));
if (characteristic == null) {
return gattCharacteristic.getValue();
}
final int format = characteristic.format;
switch(format) {
case BluetoothGattCharacteristic.FORMAT_UINT8:
case BluetoothGattCharacteristic.FORMAT_UINT16:
case BluetoothGattCharacteristic.FORMAT_UINT32:
case BluetoothGattCharacteristic.FORMAT_SINT8:
case BluetoothGattCharacteristic.FORMAT_SINT16:
case BluetoothGattCharacteristic.FORMAT_SINT32:
return gattCharacteristic.getIntValue(format, 0);
case BluetoothGattCharacteristic.FORMAT_FLOAT:
case BluetoothGattCharacteristic.FORMAT_SFLOAT:
return gattCharacteristic.getFloatValue(format, 0);
case 0:
final String value = gattCharacteristic.getStringValue(0);
final int firstNullCharPos = value.indexOf('\u0000');
return (firstNullCharPos >= 0)? value.substring(0, firstNullCharPos) : value;
default:
return characteristic.createValue(gattCharacteristic);
}
}
private static int getIdentification(UUID uuid) {
return (int)(uuid.getMostSignificantBits() >>> 32);
}
/**
* Handles reading of characteristic values. All its methods, except the {@link #onRead(int, Object, boolean)} method, must
* be executed on the {@link #SYNCHRONIZED_GATT_ACCESS_EXECUTOR}, so access to the gatt is serialized.
*/
class Characteristics {
final SparseArray<BluetoothGattCharacteristic> gattCharacteristics = new SparseArray<>();
final SparseArray<Object> values = new SparseArray<>();
void clearCharacteristics() {
gattCharacteristics.clear();
values.clear();
}
void addCharacteristics(BluetoothGatt gatt, List<BluetoothGattCharacteristic> gattCharacteristics) {
// Loops through available Characteristics.
for (BluetoothGattCharacteristic characteristic : gattCharacteristics) {
if (BuildConfig.DEBUG) {
String characteristicName = getCharacteristicName(characteristic.getUuid());
Timber.d(" char: " + characteristicName);
//Log.d("addCharacteristics"," char: " + characteristicName);
}
final int characteristicID = getIdentification(characteristic.getUuid());
this.gattCharacteristics.put(characteristicID, characteristic);
this.values.put(characteristicID, null);
int properties = characteristic.getProperties();
if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0) {
gatt.setCharacteristicNotification(characteristic, true);
}
}
}
/**
* Instructs the gatt to request the remote device to send a value of the given characteristic.
* It waits until the gatt's callback calls {@link #onRead(int, Object, boolean)} containing the value.
* It will not wait longer than 1000 milliseconds. If it takes longer, the current value stored in memory
* will be returned.
*
* @param characteristicID ID of the characteristic whose remote value is requested.
* @return The value of the characteristic.
*/
Object read(int characteristicID) {
final BluetoothGatt gatt = getGatt();
if (gatt == null) {
return null;
}
final BluetoothGattCharacteristic gattCharacteristic = gattCharacteristics.get(characteristicID);
if (gattCharacteristic == null) {
return null;
}
int properties = gattCharacteristic.getProperties();
if ((properties & BluetoothGattCharacteristic.PROPERTY_READ) == 0) {
return null;
}
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (gattCharacteristic) {
final boolean didRead = gatt.readCharacteristic(gattCharacteristic);
if (didRead) {
try {
gattCharacteristic.wait(GATT_READ_TIMEOUT);
} catch (InterruptedException ignored) {
}
}
return values.get(characteristicID);
}
}
void onRead(int characteristicID, Object value, boolean success) {
final BluetoothGattCharacteristic gattCharacteristic = gattCharacteristics.get(characteristicID);
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (gattCharacteristic) {
if (success) {
values.put(characteristicID, value);
}
gattCharacteristic.notifyAll();
}
}
}
}
|
[
"joao.stange@silabs.com"
] |
joao.stange@silabs.com
|
d28bf49bb0a64e035b408876f2ff0496acf5d14a
|
52d429a7767a2b955abd61e576bfb16b5ee07519
|
/app/src/main/java/com/siddharth/ZeroKata/OnlineActivity.java
|
d514ade6d44a5db3fe5d7c02b6ff91310112383f
|
[] |
no_license
|
SiddharthDeveloper/ZeroKata
|
05b2a83a8884f07cce3dfaed65f15cec4ad155b8
|
82ace1134626ed18c627bf40461b1d7649bf92b9
|
refs/heads/master
| 2021-01-04T09:24:06.581918
| 2020-03-02T11:45:57
| 2020-03-02T11:45:57
| 240,487,504
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 14,223
|
java
|
package com.siddharth.ZeroKata;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.HashMap;
public class OnlineActivity extends AppCompatActivity {
EditText etInviteEmail;
EditText etMyEmail;
Button buLogin;
//Firebase
private FirebaseAnalytics mFirebaseAnalytics;
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
String MyEmail;
String uid;
// Write a message to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_online);
etInviteEmail = findViewById(R.id.etInviteEmail);
etMyEmail = findViewById(R.id.etMyEmail);
buLogin = findViewById(R.id.buLogin);
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
mAuth = FirebaseAuth.getInstance();
mAuthListener = new FirebaseAuth.AuthStateListener() {
static final String TAG = "Login";
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
uid = user.getUid();
// Log.d(TAG, "onAuthStateChanged:signed_in:" + uid);
MyEmail = user.getEmail();
buLogin.setEnabled(false);
etMyEmail.setText(MyEmail);
myRef.child("Users").child(BeforeAt(MyEmail)).child("Request").setValue(uid);
IncommingRequest();
} else {
// User is signed out
//Log.d(TAG, "onAuthStateChanged:signed_out");
}
// ...
}
};
}
String BeforeAt(String Email) {
String[] split = Email.split("@");
return split[0];
}
//Login
@Override
public void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
}
@Override
public void onStop() {
super.onStop();
if (mAuthListener != null) {
mAuth.removeAuthStateListener(mAuthListener);
}
}
void UserLogin(String email, String password) {
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
public static final String TAG = "Register";
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
// Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Toast.makeText(getApplicationContext(), "Login fail", Toast.LENGTH_SHORT).show();
}
// ...
}
});
}
public void BuInvite(View view) {
// Log.d("Invate", etInviteEMail.getText().toString());
myRef.child("Users")
.child(BeforeAt(etInviteEmail.getText().toString())).child("Request").push().setValue(MyEmail);
// sid //rahul ="sid:rahul"
StartGame(BeforeAt(etInviteEmail.getText().toString()) + ":" + BeforeAt(MyEmail));
MySample = "X";
}
void IncommingRequest() {
// Read from the database
myRef.child("Users").child(BeforeAt(MyEmail)).child("Request")
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
try {
HashMap<String, Object> td = (HashMap<String, Object>) dataSnapshot.getValue();
if (td != null) {
String value;
for (String key : td.keySet()) {
value = (String) td.get(key);
Log.d("User request", value);
etInviteEmail.setText(value);
ButtonColor();
myRef.child("Users").child(BeforeAt(MyEmail)).child("Request").setValue(uid);
break;
}
}
} catch (Exception ex) {
}
}
@Override
public void onCancelled(DatabaseError error) {
}
});
}
void ButtonColor() {
etInviteEmail.setBackgroundColor(Color.RED);
}
public void BuAccept(View view) {
// Log.d("Accept", etInviteEmail.getText().toString());
myRef.child("Users")
.child(BeforeAt(etInviteEmail.getText().toString())).child("Request").push().setValue(MyEmail);
//sid// rahul ="sid:rahul"
StartGame(BeforeAt(BeforeAt(MyEmail) + ":" + etInviteEmail.getText().toString()));
MySample = "O";
}
// PlayerGameID= "sid:rahul"
String PlayerSession = "";
String MySample = "X";
void StartGame(String PlayerGameID) {
PlayerSession = PlayerGameID;
//TODO: implement later
myRef.child("Playing").child(PlayerGameID).removeValue();
// Read from the database
myRef.child("Playing").child(PlayerGameID)
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
try {
Player1.clear();
Player2.clear();
ActivePlayer = 2;
HashMap<String, Object> td = (HashMap<String, Object>) dataSnapshot.getValue();
if (td != null) {
String value;
for (String key : td.keySet()) {
value = (String) td.get(key);
if (!value.equals(BeforeAt(MyEmail)))
ActivePlayer = MySample == "X" ? 1 : 2;
else
ActivePlayer = MySample == "X" ? 2 : 1;
String[] splitID = key.split(":");
AutoPlay(Integer.parseInt(splitID[1]));
}
}
} catch (Exception ex) {
}
}
@Override
public void onCancelled(DatabaseError error) {
}
});
}
public void BuLogin(View view) {
// Log.d("Login",etMyEmail.getText().toString());
UserLogin(etMyEmail.getText().toString(), "hussein");
}
public void BuClick(View view) {
// game not started yet
if (PlayerSession.length() <= 0)
return;
Button buSelected = (Button) view;
int CellID = 0;
switch ((buSelected.getId())) {
case R.id.bu1:
CellID = 1;
break;
case R.id.bu2:
CellID = 2;
break;
case R.id.bu3:
CellID = 3;
break;
case R.id.bu4:
CellID = 4;
break;
case R.id.bu5:
CellID = 5;
break;
case R.id.bu6:
CellID = 6;
break;
case R.id.bu7:
CellID = 7;
break;
case R.id.bu8:
CellID = 8;
break;
case R.id.bu9:
CellID = 9;
break;
}
myRef.child("Playing").child(PlayerSession).child("CellID:" + CellID).setValue(BeforeAt(MyEmail));
}
int ActivePlayer = 1; // 1- for first , 2 for second
ArrayList<Integer> Player1 = new ArrayList<Integer>();// hold player 1 data
ArrayList<Integer> Player2 = new ArrayList<Integer>();// hold player 2 data
void PlayGame(int CellID, Button buSelected) {
Log.d("Player:", String.valueOf(CellID));
if (ActivePlayer == 1) {
buSelected.setText("X");
buSelected.setBackgroundColor(Color.GREEN);
Player1.add(CellID);
} else if (ActivePlayer == 2) {
buSelected.setText("O");
buSelected.setBackgroundColor(Color.BLUE);
Player2.add(CellID);
}
buSelected.setEnabled(false);
CheckWiner();
}
void CheckWiner() {
int Winer = -1;
//row 1
if (Player1.contains(1) && Player1.contains(2) && Player1.contains(3)) {
Winer = 1;
}
if (Player2.contains(1) && Player2.contains(2) && Player2.contains(3)) {
Winer = 2;
}
//row 2
if (Player1.contains(4) && Player1.contains(5) && Player1.contains(6)) {
Winer = 1;
}
if (Player2.contains(4) && Player2.contains(5) && Player2.contains(6)) {
Winer = 2;
}
//row 3
if (Player1.contains(7) && Player1.contains(8) && Player1.contains(9)) {
Winer = 1;
}
if (Player2.contains(7) && Player2.contains(8) && Player2.contains(9)) {
Winer = 2;
}
//col 1
if (Player1.contains(1) && Player1.contains(4) && Player1.contains(7)) {
Winer = 1;
}
if (Player2.contains(1) && Player2.contains(4) && Player2.contains(7)) {
Winer = 2;
}
//col 2
if (Player1.contains(2) && Player1.contains(5) && Player1.contains(8)) {
Winer = 1;
}
if (Player2.contains(2) && Player2.contains(5) && Player2.contains(8)) {
Winer = 2;
}
//col 3
if (Player1.contains(3) && Player1.contains(6) && Player1.contains(9)) {
Winer = 1;
}
if (Player2.contains(3) && Player2.contains(6) && Player2.contains(9)) {
Winer = 2;
}
if (Winer != -1) {
// We have winer
if (Winer == 1) {
//Toast.makeText(this, "Player 1 is winner", Toast.LENGTH_LONG).show();
new AlertDialog.Builder(OnlineActivity.this)
.setTitle("Player 1 is winner")
.setMessage("Do you want to play Again??")
.setPositiveButton("yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(OnlineActivity.this,OnlineActivity.class));
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finishAffinity();
System.exit(0);
}
})
.show();
}
if (Winer == 2) {
Toast.makeText(this, "Player 2 is winner", Toast.LENGTH_LONG).show();
}
}
}
void AutoPlay(int CellID) {
Button buSelected;
switch (CellID) {
case 1:
buSelected = findViewById(R.id.bu1);
break;
case 2:
buSelected = findViewById(R.id.bu2);
break;
case 3:
buSelected = findViewById(R.id.bu3);
break;
case 4:
buSelected = findViewById(R.id.bu4);
break;
case 5:
buSelected = findViewById(R.id.bu5);
break;
case 6:
buSelected = findViewById(R.id.bu6);
break;
case 7:
buSelected = findViewById(R.id.bu7);
break;
case 8:
buSelected = findViewById(R.id.bu8);
break;
case 9:
buSelected = findViewById(R.id.bu9);
break;
default:
buSelected = findViewById(R.id.bu1);
break;
}
PlayGame(CellID, buSelected);
}
}
|
[
"sid.syntax@gmail.com"
] |
sid.syntax@gmail.com
|
52ff3fc72cd64006196f15c2c9a812cf2d1fe0fd
|
7f8e0c484c9a5ba6a5230393c2cea8b17947e5e3
|
/ABB/src/clases/ListaS.java
|
712e604bafffa9c2fae6318485832e418753137d
|
[] |
no_license
|
joazlz/ArbolesAVL
|
c0964201ebaee410e684737094fe575f23d244a7
|
ea1a7af9def854e0216235e0c47063a5b21775bc
|
refs/heads/master
| 2022-01-10T16:32:27.043812
| 2019-05-27T21:59:49
| 2019-05-27T21:59:49
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,922
|
java
|
package clases;
import java.util.Iterator;
/**
* Clase que contiene las listas Simples
* @author Joaquin
* @param <T>
*/
public class ListaS<T> implements Iterable<T>{
private Nodo<T> cab;
private int size;
/**
* Agrega el nodo para la lista simple
* @param nodo - Nodo que se agregara
*/
public void addInicio(T nodo){
this.cab=new Nodo<>(nodo, this.cab);
this.size++;
}
/**
* Agrega el nodo al final de la lista Simple
* @param nodo - que se agrega
*/
public void addFin(T nodo) {
if(this.cab==null)
this.addInicio(nodo);
else {
try {
Nodo<T> ult=this.getPos(this.size-1);
ult.setSig(new Nodo<>(nodo, null));
this.size++;
}catch(Exception e) {
System.err.println(e.getMessage());
}
}
}
/**
* Metodo para saber cual es el siguiente en la lista Simple y llenar las listas
* @param i - valor entero para realizar for interno
* @return Retorna un Nodo<> con el valor del siguiente
* @throws Exception
*/
private Nodo<T> getPos(int i) throws Exception {
if(this.esVacia() || i>this.size || i<0)
throw new Exception("El indice solicitado no existe en la Lista Simple");
Nodo<T> t=this.cab;
while(i>0) {
t=t.getSig();
i--;
}
return(t);
}
/**
* metodo para conocer si la lista esta Vacia
* @return
*/
public boolean esVacia() {
return(this.cab==null);
}
/**
* Agrega la lista a un iterator
* @return retorna un iterator<>
*/
@Override
public Iterator<T> iterator() {
return new IteratorLS<T>(this.cab);
}
}
|
[
"noreply@github.com"
] |
noreply@github.com
|
cab6025521e68a20c0d4bb9847ccb0da759005d5
|
e054c1e6903e4b5eb166d107802c0c2cadd2eb03
|
/modules/datex-serializer/src/generated/java/eu/datex2/schema/_2/_2_0/AreaOfInterestEnum.java
|
23a8efb388691cb20153a6243a6cc5808b021396
|
[
"MIT"
] |
permissive
|
svvsaga/gradle-modules-public
|
02dc90ad2feb58aef7629943af3e0d3a9f61d5cf
|
e4ef4e2ed5d1a194ff426411ccb3f81d34ff4f01
|
refs/heads/main
| 2023-05-27T08:25:36.578399
| 2023-05-12T14:15:47
| 2023-05-12T14:33:14
| 411,986,217
| 2
| 1
|
MIT
| 2023-05-12T14:33:15
| 2021-09-30T08:36:11
|
Java
|
UTF-8
|
Java
| false
| false
| 1,613
|
java
|
package eu.datex2.schema._2._2_0;
import jakarta.xml.bind.annotation.XmlEnum;
import jakarta.xml.bind.annotation.XmlEnumValue;
import jakarta.xml.bind.annotation.XmlType;
/**
* <p>Java class for AreaOfInterestEnum.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <pre>
* <simpleType name="AreaOfInterestEnum">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="continentWide"/>
* <enumeration value="national"/>
* <enumeration value="neighbouringCountries"/>
* <enumeration value="notSpecified"/>
* <enumeration value="regional"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "AreaOfInterestEnum")
@XmlEnum
public enum AreaOfInterestEnum {
@XmlEnumValue("continentWide")
CONTINENT_WIDE("continentWide"),
@XmlEnumValue("national")
NATIONAL("national"),
@XmlEnumValue("neighbouringCountries")
NEIGHBOURING_COUNTRIES("neighbouringCountries"),
@XmlEnumValue("notSpecified")
NOT_SPECIFIED("notSpecified"),
@XmlEnumValue("regional")
REGIONAL("regional");
private final String value;
AreaOfInterestEnum(String v) {
value = v;
}
public String value() {
return value;
}
public static AreaOfInterestEnum fromValue(String v) {
for (AreaOfInterestEnum c: AreaOfInterestEnum.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
|
[
"geir.sagberg@gmail.com"
] |
geir.sagberg@gmail.com
|
2cf77f07981600e028e6044cb3c278bf8bf56e45
|
ff2862dad878c0a52116f73c2cf0a96fdc9c82a3
|
/Vaishali/annotationDemo/IOCAnnotation/src/main/java/com/ncu/annotationDemo/IOCAnnotation/RestFortune.java
|
cffa5fbe1688ec35299454cf813de1dec982ba2c
|
[] |
no_license
|
rashigupta19/CODES-
|
75a302b305341b4ce116715bd7d3ff2af0afd3d9
|
a953b37328462f3b03a296731dff3b53fbefd83e
|
refs/heads/main
| 2023-05-11T16:12:09.215676
| 2021-06-04T16:41:29
| 2021-06-04T16:41:29
| 373,861,790
| 0
| 1
| null | 2021-06-04T16:37:00
| 2021-06-04T14:08:16
|
Java
|
UTF-8
|
Java
| false
| false
| 238
|
java
|
package com.ncu.annotationDemo.IOCAnnotation;
import org.springframework.stereotype.Component;
@Component
public class RestFortune implements IFortune{
public String getFortune() {
return "you have a good fortune today";
}
}
|
[
"noreply@github.com"
] |
noreply@github.com
|
8a89a8309752d195c085d3a9146e06b848dab8a3
|
4e7159cf61bf0fa670a5a102424edcc7cb781a36
|
/advancedMapReduce/src/mapreduce/product/MyKey.java
|
1c59f64f5202c9ddff07ccb13f2a3aae69d1c5ab
|
[] |
no_license
|
kim-svadoz/bigdatawork
|
0736ada30909ac02dbb9e25c7a7cf0a7cac9397c
|
a7445589c05246b2869d9ca3d768893aa9384e93
|
refs/heads/master
| 2022-12-28T08:30:58.110809
| 2020-09-16T05:52:25
| 2020-09-16T05:52:25
| 241,572,741
| 0
| 0
| null | 2022-12-16T07:16:53
| 2020-02-19T08:43:15
|
Java
|
UTF-8
|
Java
| false
| false
| 1,273
|
java
|
package mapreduce.product;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableUtils;
public class MyKey implements WritableComparable<MyKey>{
private String productID;
private String userID;
public MyKey() {
}
public MyKey(String productID, String userID) {
super();
this.productID = productID;
this.userID = userID;
}
public String getProductID() {
return productID;
}
public void setProductID(String productID) {
this.productID = productID;
}
public String getUserID() {
return userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
public String toString() {
return productID+"\t"+userID+"\t";
}
@Override
public void write(DataOutput out) throws IOException {
WritableUtils.writeString(out, productID);
WritableUtils.writeString(out, userID);
}
@Override
public void readFields(DataInput in) throws IOException {
productID = WritableUtils.readString(in);
userID = WritableUtils.readString(in);
}
@Override
public int compareTo(MyKey obj) {
int result = productID.compareTo(obj.productID);
if(result==0) {
result = userID.compareTo(obj.userID);
}
return result;
}
}
|
[
"dhkdghehfdl@gmail.com"
] |
dhkdghehfdl@gmail.com
|
de136087525ebb0b70af1d02fb9c5d82dc9c7a2b
|
7b3615d250073ffbc0ccc9f19d4bb8cd50f33d04
|
/afis-cloud-server-auth/src/main/java/com/afis/cloud/auth/model/ApplicationModel.java
|
f87e10fdbcfbaaf9f68a89ec4ccc9237f855542d
|
[] |
no_license
|
zhuoyue9527/auth
|
57dd371c53c7fa14981aafc38236d92f3c5c4cc3
|
ab79aca280e37e3c0c2910cac7eb6281e0bd0c81
|
refs/heads/master
| 2020-04-07T23:24:32.180246
| 2018-11-23T09:46:52
| 2018-11-23T09:46:52
| 158,811,336
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,231
|
java
|
package com.afis.cloud.auth.model;
import java.io.Serializable;
import java.util.Date;
/**
* 存在缓存中的应用信息
*
* @author Chengen
*
*/
public class ApplicationModel implements Serializable{
private long id;
private String appCode;
private String appName;
private String key;
private String urlCallback;
private String logoPath;
private String status;
private String remark;
private Long operateAppId;
private Long operator;
private Date operateTime;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getAppCode() {
return appCode;
}
public void setAppCode(String appCode) {
this.appCode = appCode;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getUrlCallback() {
return urlCallback;
}
public void setUrlCallback(String urlCallback) {
this.urlCallback = urlCallback;
}
public String getLogoPath() {
return logoPath;
}
public void setLogoPath(String logoPath) {
this.logoPath = logoPath;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Long getOperateAppId() {
return operateAppId;
}
public void setOperateAppId(Long operateAppId) {
this.operateAppId = operateAppId;
}
public Long getOperator() {
return operator;
}
public void setOperator(Long operator) {
this.operator = operator;
}
public Date getOperateTime() {
return operateTime;
}
public void setOperateTime(Date operateTime) {
this.operateTime = operateTime;
}
@Override
public String toString() {
return "Application [id=" + id + ", appCode=" + appCode + ", appName=" + appName + ", key=" + key
+ ", urlCallback=" + urlCallback + ", logoPath=" + logoPath + ", status=" + status + ", remark="
+ remark + ", operateAppId=" + operateAppId + ", operator=" + operator + ", operateTime=" + operateTime
+ "]";
}
}
|
[
"zhuoyue9527@163.com"
] |
zhuoyue9527@163.com
|
151813817ead5a43817627cd933c1f93f93a674c
|
064bd6795fcd8eefd5f8c777915cb913b7d7e6e0
|
/src/util/ReflectionUtil.java
|
347b61d01b5f4948e717834c60c3c9267d24b057
|
[] |
no_license
|
Whatder/ReflectionJava
|
7ca513f49854d00425b2894debd4e7286f70a45f
|
6f42a1b993a6264252ad536e64827a0f341ec719
|
refs/heads/master
| 2020-03-28T03:00:45.804814
| 2018-09-06T03:36:58
| 2018-09-06T03:36:58
| 147,613,163
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,870
|
java
|
package util;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class ReflectionUtil {
public static void getAllField(Class clas) {
System.out.println("***********this is all fields**********");
Field[] declaredFields = clas.getDeclaredFields();
for (Field declaredField : declaredFields) {
System.out.println(declaredField.toString());
}
}
public static void getAllConstruct(Class clas) {
System.out.println("***********this is all constructs**********");
Constructor[] declaredConstructors = clas.getDeclaredConstructors();
for (Constructor constructor : declaredConstructors) {
System.out.println(constructor.toString());
}
}
public static void getAllMethod(Class clas) {
System.out.println("***********this is all methods**********");
Method[] methods = clas.getDeclaredMethods();
for (Method method : methods) {
System.out.println(method.toString());
}
}
public static Object newInstance(Class clas, Object... objects) throws Exception {
Constructor[] constructors = clas.getDeclaredConstructors();
for (Constructor constructor : constructors)
if (constructor.getParameterCount() == objects.length) {
//声明为private的需要setAccessible
constructor.setAccessible(true);
return constructor.newInstance(objects);
}
return null;
}
public static void invoke(Object object, String methodName, String params) throws Exception {
Class<?> clas = object.getClass();
Method method = clas.getMethod(methodName, params.getClass());
if (method != null) {
method.invoke(object, params);
}
}
}
|
[
"hjj@picbling.com"
] |
hjj@picbling.com
|
90c2546d86475da292e9dbd80f5a3775589aeecd
|
83ef5503ff1bb287e3525c64e15e7f081e11efcf
|
/test/BinaryDivide/HIndexTest.java
|
846e67ab3a98b5996e3ab55532f8de60035ce48a
|
[] |
no_license
|
huweiye/LeetCode_Medium
|
f01d3ea1c2b51e97f85c61e6b53f2176e080b56f
|
641ccbe6c0840abc68e8ab8522aa8181fdbdda02
|
refs/heads/master
| 2022-11-19T19:16:21.755489
| 2020-07-27T04:20:05
| 2020-07-27T04:20:08
| 282,792,957
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 311
|
java
|
package BinaryDivide;
import org.junit.Test;
import static org.junit.Assert.*;
public class HIndexTest {
@Test
public void hIndex() throws Exception {
HIndex h=new HIndex();
h.hIndex(new int[]{7,7,7,7,7,7,7});
}
@Test
public void is_a_Hindex() throws Exception {
}
}
|
[
"2920566283@qq.com"
] |
2920566283@qq.com
|
1cfbbe627e54cb896fa9f098bbafe7c6d6670fc1
|
33dd81c6afbaf00c4c0637f383323eefc432ae3e
|
/spring-boot-dubbo-consume/src/main/java/com/dady/dubbo/consume/service/UserServiceImpl.java
|
5ddbd8f1103e05de9c7afd48697af859bff2b55e
|
[] |
no_license
|
redey/spring-boot-dubbo
|
ba598420b6b70fb5fb6a1c5e21e2fc7178f68c0e
|
d7dd429157aff9cef018b4f55a391bbcb277a747
|
refs/heads/master
| 2021-05-14T09:49:13.922812
| 2018-01-05T03:44:02
| 2018-01-05T03:44:02
| 116,335,107
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 606
|
java
|
package com.dady.dubbo.consume.service;
import java.util.List;
import org.springframework.stereotype.Component;
import com.alibaba.dubbo.config.annotation.Reference;
import com.dady.dubbo.api.domain.User;
import com.dady.dubbo.api.service.IUserService;
@Component
public class UserServiceImpl {
@Reference(version = "1.0.0")
public IUserService userService;
public List<User> getUsers(){
return userService.getAllUser();
}
public IUserService getUserService() {
return userService;
}
public void setUserService(IUserService userService) {
this.userService = userService;
}
}
|
[
"qiganglin@tethrnet.com"
] |
qiganglin@tethrnet.com
|
15127e8f7a449995177fe08c3aaa4882a59ea356
|
15ac8e5cc5cbde3b6175afd9efa7d772ae193fa1
|
/JavaFX/src/ToDoListFX/Controller.java
|
b9738b535fcefccd87dd388a3e6cc8bf81d48f8a
|
[] |
no_license
|
AnnanVora/Java
|
837e123fad2ce23cff1d18cff72aee40b753b343
|
bf9ea6d03192612073afd023066ee1b9502743f7
|
refs/heads/master
| 2022-11-28T18:23:07.330374
| 2020-08-10T10:45:34
| 2020-08-10T10:45:34
| 261,518,241
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 7,758
|
java
|
package ToDoListFX;
import ToDoListFX.datamodel.TodoData;
import ToDoListFX.datamodel.TodoItem;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.transformation.FilteredList;
import javafx.collections.transformation.SortedList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.util.Callback;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Comparator;
import java.util.Optional;
import java.util.function.Predicate;
public class Controller {
@FXML
private ListView<TodoItem> todoListView;
@FXML
private TextArea itemDetailsTextArea;
@FXML
private Label deadLineLabel;
@FXML
private BorderPane mainBorderPane;
@FXML
private ToggleButton filterToggleButton;
private ContextMenu listContextMenu;
private FilteredList<TodoItem> filteredList;
private Predicate<TodoItem> wantAllItems;
private Predicate<TodoItem> wantTodayItems;
public void initialize() {
listContextMenu = new ContextMenu();
MenuItem deleteMenuItem = new MenuItem("Delete item");
deleteMenuItem.setOnAction(new EventHandler<>() {
@Override
public void handle(ActionEvent actionEvent) {
TodoItem item = todoListView.getSelectionModel().getSelectedItem();
deleteItem(item);
}
});
listContextMenu.getItems().addAll(deleteMenuItem);
todoListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<>() {
@Override
public void changed(ObservableValue<? extends TodoItem> observableValue, TodoItem todoItem, TodoItem newValue) {
if (newValue != null) {
TodoItem item = todoListView.getSelectionModel().getSelectedItem();
itemDetailsTextArea.setText(item.getDetails().replaceAll("###", "\n"));
DateTimeFormatter df = DateTimeFormatter.ofPattern("MMMM d, yyyy");
deadLineLabel.setText(df.format(item.getDeadLine()));
}
}
});
wantAllItems = new Predicate<>() {
@Override
public boolean test(TodoItem item) {
return true;
}
};
wantTodayItems = new Predicate<>() {
@Override
public boolean test(TodoItem item) {
return item.getDeadLine().equals(LocalDate.now());
}
};
filteredList = new FilteredList<>(TodoData.getInstance().getTodoItems(), wantAllItems);
SortedList<TodoItem> sortedList = new SortedList<>(filteredList,
new Comparator<>() {
@Override
public int compare(TodoItem o1, TodoItem o2) {
return o1.getDeadLine().compareTo(o2.getDeadLine());
}
});
todoListView.setItems(sortedList);
todoListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
todoListView.getSelectionModel().selectFirst();
todoListView.setCellFactory(new Callback<>() {
@Override
public ListCell<TodoItem> call(ListView<TodoItem> param) {
ListCell<TodoItem> cell = new ListCell<>() {
@Override
protected void updateItem(TodoItem item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
} else {
setText(item.getShortDescription());
if (item.getDeadLine().isBefore(LocalDate.now().plusDays(1))) {
setTextFill(Color.RED);
} else if (item.getDeadLine().equals(LocalDate.now().plusDays(1))) {
setTextFill(Color.ORANGE);
}
}
}
};
cell.emptyProperty().addListener(
(obs, wasEmpty, isNowEmpty) -> {
if (isNowEmpty) {
cell.setContextMenu(null);
} else {
cell.setContextMenu(listContextMenu);
}
}
);
return cell;
}
});
}
@FXML
public void showNewItemDialog() {
Dialog<ButtonType> dialog = new Dialog<>();
dialog.initOwner(mainBorderPane.getScene().getWindow());
dialog.setTitle("Add New Todo List Item");
dialog.setHeaderText("Use this dialog to create a new Todo Item");
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("todoItemDialog.fxml"));
try {
dialog.getDialogPane().setContent(fxmlLoader.load());
} catch (IOException e) {
System.out.println("Couldn't load the dialog");
e.printStackTrace();
return;
}
dialog.getDialogPane().getButtonTypes().add(ButtonType.CANCEL);
dialog.getDialogPane().getButtonTypes().add(ButtonType.OK);
Optional<ButtonType> result = dialog.showAndWait();
if (result.isPresent() && result.get() == ButtonType.OK) {
DialogController controller = fxmlLoader.getController();
TodoItem newItem = controller.processResults();
todoListView.getSelectionModel().select(newItem);
}
}
@FXML
public void handleKeyPressed(KeyEvent keyEvent) {
TodoItem selectedItem = todoListView.getSelectionModel().getSelectedItem();
if (selectedItem != null && keyEvent.getCode().equals(KeyCode.DELETE)) {
deleteItem(selectedItem);
itemDetailsTextArea.clear();
deadLineLabel.setText("");
}
}
@FXML
public void handleFilterToggle() {
TodoItem selectedItem = todoListView.getSelectionModel().getSelectedItem();
if (filterToggleButton.isSelected()) {
filteredList.setPredicate(wantTodayItems);
if (filteredList.isEmpty()) {
itemDetailsTextArea.clear();
deadLineLabel.setText("");
} else if (filteredList.contains(selectedItem)){
todoListView.getSelectionModel().select(selectedItem);
} else {
todoListView.getSelectionModel().selectFirst();
}
} else {
filteredList.setPredicate(wantAllItems);
todoListView.getSelectionModel().select(selectedItem);
}
}
@FXML
public void handleExit() {
Platform.exit();
}
public void deleteItem(TodoItem item) {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Delete Todo item");
alert.setHeaderText("Delete item: " + item.getShortDescription());
alert.setContentText("Are you sure ? Press OK to confirm, or cancel to back-out.");
Optional<ButtonType> result = alert.showAndWait();
if (result.isPresent() && result.get() == ButtonType.OK) {
TodoData.getInstance().deleteTodoItem(item);
itemDetailsTextArea.clear();
deadLineLabel.setText("");
}
}
}
|
[
"annan.vora@gmail.com"
] |
annan.vora@gmail.com
|
7cc3eeabf0124b9b0d0a0cabcac950efe9733749
|
8d2ad83af21dd890d5f310c65f8edb134cefd84b
|
/src/main/java/com/cn/modules/sys/service/BatchAttachService.java
|
d8cdcb83e09a3ac7173934d0f7775968c392e716
|
[] |
no_license
|
meatbunrst/map-manager
|
8945edf3bee0b9763d7fa96cee4ba21e11893568
|
5aee36ddf0f6c89f299031bfa7319f9cddde2089
|
refs/heads/master
| 2022-12-19T14:31:49.341548
| 2020-04-26T02:09:26
| 2020-04-26T02:09:26
| 222,828,322
| 1
| 0
| null | 2022-07-06T20:43:26
| 2019-11-20T01:56:39
|
Java
|
UTF-8
|
Java
| false
| false
| 5,195
|
java
|
package com.cn.modules.sys.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cn.common.service.AbstractService;
import com.cn.common.utils.ToolUtil;
import com.cn.modules.sys.dao.BatchAttachDao;
import com.cn.modules.sys.entity.BatchAttachEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 基本附件表Service 业务接口
*
* @author zhangheng
* @date 2019-07-26 14:43:48
*/
@Service
@Transactional(readOnly = true,rollbackFor={RuntimeException.class})
@Slf4j
public class BatchAttachService extends AbstractService<BatchAttachDao,BatchAttachEntity>{
/**
* <p>
* 根据 model 条件,查询总记录数
* </p>
*
* @param model 实体对象
* @return int
*/
public Integer selectCount(BatchAttachEntity model){
return count(getWrapper(model));
}
/**
* 根据 model 条件,删除
*
* @param model 实体对象
* @return boolean
*/
@Transactional(rollbackFor={RuntimeException.class})
public boolean deleteByModel(BatchAttachEntity model){
return remove(getWrapper(model));
}
/**
* 根据 model 条件,生成LambdaQueryWrapper
*
* @param model 实体对象
* @return LambdaQueryWrapper
*/
public LambdaQueryWrapper<BatchAttachEntity> getWrapper(BatchAttachEntity model){
LambdaQueryWrapper<BatchAttachEntity> wrapper = new LambdaQueryWrapper<>();
if (model != null){
if (ToolUtil.isNotEmpty(model.getBattchId())){
wrapper.eq(BatchAttachEntity::getBattchId,model.getBattchId());
}
if (ToolUtil.isNotEmpty(model.getModuleRecordId())){
wrapper.eq(BatchAttachEntity::getModuleRecordId,model.getModuleRecordId());
}
if (ToolUtil.isNotEmpty(model.getModuleType())){
wrapper.eq(BatchAttachEntity::getModuleType,model.getModuleType());
}
if (ToolUtil.isNotEmpty(model.getBusinessType())){
wrapper.eq(BatchAttachEntity::getBusinessType,model.getBusinessType());
}
if (ToolUtil.isNotEmpty(model.getFileType())){
wrapper.eq(BatchAttachEntity::getFileType,model.getFileType());
}
if (ToolUtil.isNotEmpty(model.getAttachDesc())){
wrapper.eq(BatchAttachEntity::getAttachDesc,model.getAttachDesc());
}
if (ToolUtil.isNotEmpty(model.getUploadFileName())){
wrapper.eq(BatchAttachEntity::getUploadFileName,model.getUploadFileName());
}
if (ToolUtil.isNotEmpty(model.getLocalSavePath())){
wrapper.eq(BatchAttachEntity::getLocalSavePath,model.getLocalSavePath());
}
if (ToolUtil.isNotEmpty(model.getFsBasePath())){
wrapper.eq(BatchAttachEntity::getFsBasePath,model.getFsBasePath());
}
if (ToolUtil.isNotEmpty(model.getFsDatePath())){
wrapper.eq(BatchAttachEntity::getFsDatePath,model.getFsDatePath());
}
if (ToolUtil.isNotEmpty(model.getFsFileName())){
wrapper.eq(BatchAttachEntity::getFsFileName,model.getFsFileName());
}
if (ToolUtil.isNotEmpty(model.getUploadUserAccount())){
wrapper.eq(BatchAttachEntity::getUploadUserAccount,model.getUploadUserAccount());
}
if (ToolUtil.isNotEmpty(model.getUploadDate())){
wrapper.eq(BatchAttachEntity::getUploadDate,model.getUploadDate());
}
}
return wrapper;
}
/**
* <p>
* 根据 entity 条件,查询全部记录
* </p>
*
* @param model 实体对象封装操作类(可以为 null)
* @return List<BatchAttachEntity>
*/
public List<BatchAttachEntity> selectList(BatchAttachEntity model){
return list(getWrapper(model));
}
/**
* <p>
* 根据 entity 条件,查询全部记录(并翻页)
* </p>
*
* @param pagination 分页查询条件
* @param model 实体对象封装操作可以为 null)
* @param wrapper SQL包装
* @return List<BatchAttachEntity>
*/
public List<BatchAttachEntity> selectPage(Page pagination, BatchAttachEntity model,QueryWrapper<BatchAttachEntity> wrapper){
return dao.selectPage(pagination,model,wrapper);
}
/**
* 根据 entity 条件,查询全部记录(并翻页)
*
* @param pagination 分页查询条件
* @param wrapper SQL包装
* @return List<BatchAttachEntity>
*/
public List<BatchAttachEntity> selectPage(Page pagination,QueryWrapper<BatchAttachEntity> wrapper){
return dao.queryPage(pagination,wrapper);
}
}
|
[
"535792175@qq.com"
] |
535792175@qq.com
|
321431c567bffb46076887d57219f9cd4ae8e280
|
a17833f3d070eb99fc1beca3c5954ec0aab02151
|
/ribbon-service/src/test/java/com/cloud/ribbonservice/service/ProductServiceTest.java
|
66b2bfa90a3a8e73884ced26e49f8e7b8c4bded7
|
[] |
no_license
|
wenfeng611/springcloud-demo
|
b11a77a45b12a7b4b669113761478a0af57b2ecd
|
0d3b82b9c910671dd1f3d81d82ea9da14ec14f2a
|
refs/heads/master
| 2022-11-14T06:34:59.273428
| 2020-07-07T05:39:50
| 2020-07-07T05:39:50
| 276,025,158
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 650
|
java
|
package com.cloud.ribbonservice.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest
@RunWith(SpringRunner.class)
public class ProductServiceTest {
@Autowired
ProductService productService;
@Test
public void geOne() {
for (int i = 0; i < 10 ; i++) {
System.out.println("test..." + i);
Object o = productService.geOne(i);
System.out.println("result: "+o);
}
}
}
|
[
"wenfeng.zhu@ketianyun.com"
] |
wenfeng.zhu@ketianyun.com
|
f762c17eed3a657e35faa55efb83c9f0f7be34ed
|
e4bfec11332d6d879960ffd9e9e81338040d5f3f
|
/java-adv-01-master/src/main/java/dk/cphbusiness/ja/generics/v3/LinkedPath.java
|
9c1448f37064c8cb5989be7e7aba3967609c95c6
|
[] |
no_license
|
Rolf88/school
|
0879fd4367e8dc63e244c6c3b939287d66e36d71
|
3df179e5af3da604f3e22c7fa9c163c84c19a87f
|
refs/heads/master
| 2021-01-16T22:49:01.013932
| 2016-08-14T10:00:26
| 2016-08-14T10:00:26
| 65,660,307
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,591
|
java
|
package dk.cphbusiness.ja.generics.v3;
import java.util.Iterator;
public class LinkedPath<T> implements Path<T> {
private final T first;
private final Path<T> rest;
// <editor-fold desc="LinkedPath operations ">
public LinkedPath(T first) {
this.first = first;
this.rest = EMPTY;
}
public LinkedPath(T first, Path<T> rest) {
this.first = first;
this.rest = rest;
}
public LinkedPath(T first, T... steps) {
Path<T> rest = EMPTY;
for (int index = steps.length - 1; index >= 0; index--) {
rest = new LinkedPath<>(steps[index], rest);
}
this.first = first;
this.rest = rest;
}
public static <T> Path<T> create(Iterable<T> steps) {
return create(steps.iterator());
}
private static <T> Path<T> create(Iterator<T> iterator) {
if (!iterator.hasNext()) return Path.EMPTY;
return new LinkedPath<>(iterator.next(), create(iterator));
}
@Override
public T getFirst() { return first; }
@Override
public Path<T> getRest() { return rest; }
@Override
public boolean isEmpty() { return false; }
// </editor-fold>
@Override
public Iterator<T> iterator() { return new PathIterator<>(this); }
private class PathIterator<T> implements Iterator<T> {
private Path<T> path;
public PathIterator(Path<T> path) {
this.path = path;
}
@Override
public boolean hasNext() { return !path.isEmpty(); }
@Override
public T next() {
T step = path.getFirst();
path = path.getRest();
return step;
}
}
}
|
[
"cb88@jubii.dk"
] |
cb88@jubii.dk
|
51b5a6919d910affec6d5160fbe98b137d05f1ee
|
87f1071b3ae5206c2515cea388ba1e26d28b2b55
|
/5.1Maven/multi-module/webapp/java/com/epam/achapouskaya/dao/BirdDAO.java
|
f32048475594c20928d50ff47e5ff073a025c228
|
[] |
no_license
|
annaachapouskaya/JMP_2017
|
7e9a3e9fea4abf5687b53ff4ca8df890fc7a5389
|
93cbf8b74819e673e5bfa7bafd593a3d1095a4b7
|
refs/heads/master
| 2021-01-19T10:29:04.620752
| 2017-06-20T14:56:22
| 2017-06-20T14:56:22
| 82,183,419
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 136
|
java
|
package com.epam.achapouskaya.dao;
import com.epam.achapouskaya.model.Bird;
public interface BirdDAO extends PetDAO<Bird> {
}
|
[
"anna.achapovskaya@gmail.com"
] |
anna.achapovskaya@gmail.com
|
abeed208b4ac2b387c7c8cd77344f17910cc3ac4
|
e2a1e8432fdfa91aaabdfc45d4d38173a8e293e0
|
/db-upgrader/src/main/java/org/diveintojee/poc/digitaloceancluster/app1/DbMigrationConfiguration.java
|
041c9259673ae5594408c28eb35bdca3dab0eb77
|
[] |
no_license
|
lgueye/app1
|
1d98707d86f6900f00b22f694681a8fd8e1484ea
|
924a01ccea8e4d82085ab64fd6b8c76399fd095d
|
refs/heads/master
| 2016-08-08T06:51:15.003079
| 2015-04-27T22:05:40
| 2015-04-27T22:05:40
| 29,881,802
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,495
|
java
|
package org.diveintojee.poc.digitaloceancluster.app1;
import org.flywaydb.core.Flyway;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import java.sql.Driver;
@Configuration
public class DbMigrationConfiguration {
@Value("${datasource.driverClassName}")
private String driverClassName;
@Value("${datasource.username}")
private String userName;
@Value("${datasource.password}")
private String password;
@Value("${datasource.url}")
private String url;
@Bean
public SimpleDriverDataSource dataSource() throws ClassNotFoundException {
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
dataSource.setDriverClass((Class<? extends Driver>) Class.forName(driverClassName));
dataSource.setUsername(userName);
dataSource.setUrl(url);
dataSource.setPassword(password);
return dataSource;
}
@Bean
public Flyway flyway() throws ClassNotFoundException {
Flyway flyway = new Flyway();
flyway.setLocations("migrations");
flyway.setDataSource(dataSource());
return flyway;
}
@Bean
public JdbcTemplate jdbcTemplate() throws ClassNotFoundException {
return new JdbcTemplate(dataSource());
}
}
|
[
"louis.gueye@gmail.com"
] |
louis.gueye@gmail.com
|
033a2b075a3aeadfd1145564de208a3b70a90bb0
|
433eae1806c7c4a0b2ddbc16bb59d296df2482ea
|
/WMb2b-service/src/main/java/com/wangmeng/redis/XJedisConnectionFactory.java
|
601c9dfcd9f8162dca1bce9cd4c8f2a87e48a8c7
|
[] |
no_license
|
tomdev2008/zxzshop-parent
|
23dbb7dadcf2d342abb8685f8970312a73199d81
|
c08568df051b8e592ac35f7ca13e0d4940780a72
|
refs/heads/master
| 2021-01-12T01:03:25.156508
| 2017-01-06T05:39:40
| 2017-01-06T05:39:40
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,431
|
java
|
package com.wangmeng.redis;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
/**
* <ul>
* <li>
* <p>
* 系统名程 : 浙江网盟B2B平台项目 <br/>
* 子系统名称 : 系统 <br/>
* 类/接口名 : XJedisConnectionFactory <br/>
* 版本信息 : 1.00 <br/>
* 新建日期 : 2016年12月22日 <br/>
* 作者 : 衣奎德 <br/>
* <!-- <b>修改历史(修改者):</b> --> <br/>
*
* redis 连接工厂
* 主要处理密码为空的时候忽略校验的功能
*
* Copyright (c) wangmeng Co., Ltd. 2016. All rights reserved.
* </p>
*
* </li>
* </ul>
*/
public class XJedisConnectionFactory extends JedisConnectionFactory {
/**
* 构造器
* @param poolConfig
*/
public XJedisConnectionFactory(GenericObjectPoolConfig poolConfig) {
super(JedisPoolConfigBuilder.build(poolConfig));
}
@Override
public String getPassword() {
return StringUtils.trimToNull(super.getPassword());
}
@Override
public void setPassword(String password) {
super.setPassword(StringUtils.trimToNull(password));
}
}
|
[
"admin"
] |
admin
|
00cf2ba1e8d77023b9a816cc21e8666d8d884f49
|
018b670a9178eb24d789843c810f4f299e863c63
|
/q53227026-jpa-paging-case-insensitive/src/main/java/sk/ygor/stackoverflow/q53207105/Audi.java
|
8b777f1148d64c139ff376525bbe1ce4458a3aef
|
[] |
no_license
|
hsetiawan/stackoverflow
|
e74a9c94fa4219e396a0a718b1b541ea7744e428
|
c6852b4ab7c445bc8ad410e07c85f9d61adad13e
|
refs/heads/master
| 2023-03-30T01:17:57.384542
| 2021-04-19T19:56:32
| 2021-04-19T19:56:32
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 828
|
java
|
package sk.ygor.stackoverflow.q53207105;
import javax.persistence.*;
@Entity
public class Audi {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(nullable = false)
private String description;
protected Audi() {
}
public Audi(String description) {
this.description = description;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override public String toString() {
return "Audi{" +
"id=" + id +
", description='" + description + '\'' +
'}';
}
}
|
[
"igor.inas@gmail.com"
] |
igor.inas@gmail.com
|
0537733eb624059f0d6bcb5a71ea85576e0be394
|
386f4c2029a8ef18fb198c04163dca79f368bdfe
|
/myutilslibrary/src/main/java/com/myutilslibrary/utils/SavePicSDUtils.java
|
f51d62d19998a8e3ba2a9f800b15fa888ebef0d1
|
[] |
no_license
|
yi12234/MyUtils
|
017a9861cbb4e19ffc2fb565369b658bfa817f1f
|
034926286949b19bff494e97fc2b0ba9074fc1a5
|
refs/heads/master
| 2021-09-05T01:01:27.153511
| 2018-01-23T07:43:50
| 2018-01-23T07:43:50
| 108,076,364
| 2
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,245
|
java
|
package com.myutilslibrary.utils;
import android.graphics.Bitmap;
import android.os.Environment;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* Created by Administrator on 2017/6/28 0028.
* 将图片写入内存 以便存取调用
*/
public class SavePicSDUtils {
private static String path;//sd路径
public SavePicSDUtils(String path) {
SavePicSDUtils.path =path;
}
//将图片写入内存
public static void setPicToView(Bitmap mBitmap,String path,String name) {
String sdStatus = Environment.getExternalStorageState();
if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // 检测sd是否可用
return;
}
FileOutputStream b = null;
File file = new File(path);
file.mkdirs();// 创建文件夹
String fileName =path + name;//图片名字
try {
b = new FileOutputStream(fileName);
mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, b);// 把数据写入文件
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
try {
//关闭流
b.flush();
b.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void setPicToView(Bitmap mBitmap,String name) {
String sdStatus = Environment.getExternalStorageState();
if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // 检测sd是否可用
return;
}
FileOutputStream b = null;
File file = new File(path);
file.mkdirs();// 创建文件夹
String fileName =path + name;//图片名字
try {
b = new FileOutputStream(fileName);
mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, b);// 把数据写入文件
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
try {
//关闭流
b.flush();
b.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
|
[
"18865541037@163.com"
] |
18865541037@163.com
|
405af4581a8e77c9195267418fa1d517a5d0ad7a
|
cb9af2f01ef65c6df1882825494e18a8a07de754
|
/src/ontologyRepresentations/greenContextOntology/Memory.java
|
6f601c9108e62cfb4ac79a374691946fb8177375
|
[] |
no_license
|
moldovanus/selfoptimizingdatacenter
|
6774ebdad77a463672c64834385efb4d144d84c7
|
d42b2d85c125230b147685f40023dc28efeb9c71
|
refs/heads/master
| 2020-04-12T18:02:09.442061
| 2010-08-05T07:32:48
| 2010-08-05T07:32:48
| 32,218,135
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 324
|
java
|
package ontologyRepresentations.greenContextOntology;
/**
* Generated by Protege-OWL (http://protege.stanford.edu/plugins/owl).
* Source OWL Class: http://www.owl-ontologies.com/Datacenter.owl#Memory
*
* @version generated on Sun Mar 07 13:11:11 EET 2010
*/
public interface Memory extends Component {
}
|
[
"Moldovanus@96a9c130-295f-11df-b102-9b0ba5a782e2"
] |
Moldovanus@96a9c130-295f-11df-b102-9b0ba5a782e2
|
99a7a6d63b4b43daf06ce9e7c9e7144d13762af3
|
a7454682c6413d11647e0eacc63704b5c3bc8ee4
|
/SAVOIR_OAuth/src/ca/gc/nrc/iit/oauth/provider/validator/SimpleOAuthValidator.java
|
3204d965951cd7f180c334b98ff49cdb39403536
|
[] |
no_license
|
savoir2013/savoir
|
ffec9b38d2cd41cac689c776bb5c742d0d1dc65a
|
daa80b13475729ba1d490f8dd93d85553bca09aa
|
refs/heads/master
| 2021-01-22T09:47:18.370871
| 2013-01-29T21:26:46
| 2013-01-29T21:26:46
| 7,899,749
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 11,131
|
java
|
/*
* Copyright 2008 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ca.gc.nrc.iit.oauth.provider.validator;
import java.util.Date;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
import ca.gc.nrc.iit.oauth.common.OAuth;
import ca.gc.nrc.iit.oauth.common.OAuthConsumer;
import ca.gc.nrc.iit.oauth.common.OAuthParams;
import ca.gc.nrc.iit.oauth.common.OAuthToken;
import ca.gc.nrc.iit.oauth.common.exception.OAuthException;
import ca.gc.nrc.iit.oauth.common.exception.OAuthProblemException;
import ca.gc.nrc.iit.oauth.common.signature.OAuthSignatureMethod;
/**
* A simple OAuthValidator, which checks the version, whether the timestamp is
* close to now, the nonce hasn't been used before and the signature is valid.
* Each check may be overridden.
* <p>
* This implementation is less than industrial strength:
* <ul>
* <li>Duplicate nonces won't be reliably detected by a service provider running
* in multiple processes, since the used nonces are stored in memory.</li>
* <li>The collection of used nonces is a synchronized choke point</li>
* <li>The used nonces may occupy lots of memory, although you can minimize this
* by calling releaseGarbage periodically.</li>
* <li>The range of acceptable timestamps can't be changed, and there's no
* system for increasing the range smoothly.</li>
* <li>Correcting the clock backward may allow duplicate nonces.</li>
* </ul>
* For a big service provider, it might be better to store used nonces in a
* database.
*
* @author Dirk Balfanz, Google
* @author John Kristian, Netflix
* @author Aaron Moss, NRC-IIT
*/
public class SimpleOAuthValidator implements OAuthValidator, TimestampValidator {
/** The default maximum age of timestamps is 5 minutes. */
public static final long DEFAULT_MAX_TIMESTAMP_AGE = 5 * 60 * 1000L;
public static final long DEFAULT_TIMESTAMP_WINDOW = DEFAULT_MAX_TIMESTAMP_AGE;
/**
* Construct a validator that rejects messages more than five minutes old or
* with a OAuth version other than 1.0.
*/
public SimpleOAuthValidator() {
this(DEFAULT_TIMESTAMP_WINDOW, OAuth.VERSION_1_0);
}
/**
* Public constructor.
*
* @param maxTimestampAgeMsec
* the range of valid timestamps, in milliseconds into the past
* or future. So the total range of valid timestamps is twice
* this value, rounded to the nearest second.
* @param maxVersion
* the maximum valid oauth_version
*/
public SimpleOAuthValidator(long maxTimestampAgeMsec, double maxVersion) {
this.maxTimestampAgeMsec = maxTimestampAgeMsec;
this.maxVersion = maxVersion;
this.timestampValidator = this;
}
protected final double minVersion = 1.0;
protected final double maxVersion;
protected long maxTimestampAgeMsec;
protected TimestampValidator timestampValidator;
private final Set<UsedNonce> usedNonces = new TreeSet<UsedNonce>();
/**
* Allow objects that are no longer useful to become garbage.
*
* @return the earliest point in time at which another call will release
* some garbage, or null to indicate there's nothing currently
* stored that will become garbage in future. This value may change,
* each time releaseGarbage or validateNonce is called.
*/
public Date releaseGarbage() {
return removeOldNonces(currentTimeMsec());
}
/**
* Remove usedNonces with timestamps that are too old to be valid.
*/
private Date removeOldNonces(long currentTimeMsec) {
UsedNonce next = null;
UsedNonce min = new UsedNonce((currentTimeMsec - maxTimestampAgeMsec + 500) / 1000L);
synchronized (usedNonces) {
// Because usedNonces is a TreeSet, its iterator produces
// elements from oldest to newest (their natural order).
for (Iterator<UsedNonce> iter = usedNonces.iterator(); iter.hasNext();) {
UsedNonce used = iter.next();
if (min.compareTo(used) <= 0) {
next = used;
break; // all the rest are also new enough
}
iter.remove(); // too old
}
}
if (next == null)
return null;
return new Date((next.getTimestamp() * 1000L) + maxTimestampAgeMsec + 500);
}
/** {@inherit}
*/
public void validateMessage(OAuthParams params, OAuthToken token, OAuthConsumer consumer)
throws OAuthException {
validateVersion(params);
validateTimestampAndNonce(params);
validateSignature(params, token, consumer);
}
public void setMaxTimestampAgeMsec(long maxTimestampAgeMsec) {
this.maxTimestampAgeMsec = maxTimestampAgeMsec;
}
public void setTimestampValidator(TimestampValidator timestampValidator) {
this.timestampValidator = timestampValidator;
}
protected void validateVersion(OAuthParams params)
throws OAuthException {
double version = params.getVersion();
if (version < minVersion || maxVersion < version) {
OAuthProblemException problem = new OAuthProblemException(OAuth.Problems.VERSION_REJECTED);
problem.setParameter(OAuth.Problems.OAUTH_ACCEPTABLE_VERSIONS, minVersion + "-" + maxVersion);
throw problem;
}
}
/**
* Throw an exception if the timestamp is out of range or the nonce has been
* validated previously.
*/
protected void validateTimestampAndNonce(OAuthParams params) throws OAuthProblemException {
long now = currentTimeMsec();
timestampValidator.validateTimestamp(params, now);
validateNonce(params, now);
}
/** Throw an exception if the timestamp [sec] is out of range. */
public void validateTimestamp(OAuthParams params, long currentTimeMsec)
throws OAuthProblemException {
long timestamp = params.getTimestamp();
long min = (currentTimeMsec - maxTimestampAgeMsec + 500) / 1000L;
long max = (currentTimeMsec + maxTimestampAgeMsec + 500) / 1000L;
if (timestamp < min || max < timestamp) {
OAuthProblemException problem = new OAuthProblemException(OAuth.Problems.TIMESTAMP_REFUSED);
problem.setParameter(OAuth.Problems.OAUTH_ACCEPTABLE_TIMESTAMPS, min + "-" + max);
throw problem;
}
}
/**
* Throw an exception if the nonce has been validated previously.
*
* @return the earliest point in time at which a call to releaseGarbage
* will actually release some garbage, or null to indicate there's
* nothing currently stored that will become garbage in future.
*/
protected Date validateNonce(OAuthParams params, long currentTimeMsec)
throws OAuthProblemException {
long timestamp = params.getTimestamp();
UsedNonce nonce = new UsedNonce(timestamp, params.getNonce(),
params.getConsumerKey(), params.getToken());
/*
* The OAuth standard requires the token to be omitted from the stored
* nonce. But I include it, to harmonize with a Consumer that generates
* nonces using several independent computers, each with its own token.
*/
boolean valid = false;
synchronized (usedNonces) {
valid = usedNonces.add(nonce);
}
if (!valid) {
throw new OAuthProblemException(OAuth.Problems.NONCE_USED);
}
return removeOldNonces(currentTimeMsec);
}
protected void validateSignature(OAuthParams params, OAuthToken token, OAuthConsumer consumer)
throws OAuthException {
OAuthSignatureMethod.newMethod(params.getSignatureMethod())
.validate(params, token, consumer);
}
/** Get the number of milliseconds since midnight, January 1, 1970 UTC. */
protected long currentTimeMsec() {
return System.currentTimeMillis();
}
/**
* Selected parameters from an OAuth request, in a form suitable for
* detecting duplicate requests. The implementation is optimized for the
* comparison operations (compareTo, equals and hashCode).
*
* @author John Kristian
*/
private static class UsedNonce implements Comparable<UsedNonce> {
/**
* Construct an object containing the given timestamp, nonce and other
* parameters. The order of parameters is significant.
*/
UsedNonce(long timestamp, String... nonceEtc) {
StringBuilder key = new StringBuilder(
String.format("%20d", Long.valueOf(timestamp)));
// The blank padding ensures that timestamps are compared as numbers.
for (String etc : nonceEtc) {
key.append("&").append(etc == null ? " " : OAuth.percentEncode(etc));
// A null value is different from "" or any other String.
}
sortKey = key.toString();
}
private final String sortKey;
long getTimestamp() {
int end = sortKey.indexOf("&");
if (end < 0)
end = sortKey.length();
return Long.parseLong(sortKey.substring(0, end).trim());
}
/**
* Determine the relative order of <code>this</code> and
* <code>that</code>, as specified by Comparable. The timestamp is most
* significant; that is, if the timestamps are different, return 1 or
* -1. If <code>this</code> contains only a timestamp (with no nonce
* etc.), return -1 or 0. The treatment of the nonce etc. is murky,
* although 0 is returned only if they're all equal.
*/
public int compareTo(UsedNonce that) {
return (that == null) ? 1 : sortKey.compareTo(that.sortKey);
}
@Override
public int hashCode() {
return sortKey.hashCode();
}
/**
* Return true iff <code>this</code> and <code>that</code> contain equal
* timestamps, nonce etc., in the same order.
*/
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that == this)
return true;
if (that.getClass() != getClass())
return false;
return sortKey.equals(((UsedNonce) that).sortKey);
}
@Override
public String toString() {
return sortKey;
}
}
}
|
[
"Justin.Hickey@nrc.gc.ca"
] |
Justin.Hickey@nrc.gc.ca
|
04dd7c89924ad9a352c1fceac729dba24b393514
|
e0926dc4bf0ce84a2a421e839f2dd716d8e6ab05
|
/app/src/main/java/com/galvani/egon/connectionmonitor/SplashActivity.java
|
a0735c5ff4aede37884adf461e13007ce92fee93
|
[] |
no_license
|
EgonGalvani/Connection-Monitor
|
8025e54eb0c2d912bed5c8b3f8130fcdaab72e9e
|
e04e2bfa0eec4c23c85469f4d4acb4e37ff3d9c1
|
refs/heads/master
| 2022-05-01T13:10:17.272286
| 2022-03-26T12:24:16
| 2022-03-26T12:24:16
| 150,496,297
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,251
|
java
|
package com.galvani.egon.connectionmonitor;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import com.galvani.egon.connectionmonitor.Utils.ConnectionUtils;
import com.galvani.egon.connectionmonitor.Utils.DatabaseOpenHelper;
import java.io.IOException;
import es.dmoral.toasty.Toasty;
import pl.droidsonroids.gif.GifDrawable;
import pl.droidsonroids.gif.GifImageView;
/*
* @author Egon Galvani
*/
public class SplashActivity extends AppCompatActivity implements DatabaseOpenHelper.DBEvent {
// splash screen duration
private static final int SPLASH_MILLIS = 3000;
// the time when the splashActivity is created is saved
private long millis;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
millis = System.currentTimeMillis();
// Load the gif image
GifImageView gifImageView = (GifImageView) findViewById(R.id.background_gif);
try {
GifDrawable gifFromResource = new GifDrawable(getResources(), R.drawable.world);
gifImageView.setImageDrawable(gifFromResource);
} catch (IOException e) {
e.printStackTrace();
}
// check if the network is available, if it is prepare the database
// otherwise show an error message and close the app
ConnectionUtils connectionUtils = new ConnectionUtils(this);
if (connectionUtils.isNetworkAvailable()) {
// initialize the database helper
((App) getApplication()).databaseOpenHelper = new DatabaseOpenHelper(this, getApplicationContext(), getFilesDir().getAbsolutePath());
// try to prepare the database
try {
((App) getApplication()).databaseOpenHelper.prepareDB();
} catch (IOException e) {
e.printStackTrace();
Toasty.error(this, getString(R.string.open_db_error)).show();
finish();
}
} else {
Toasty.error(this, getString(R.string.no_connection_error)).show();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
}, 2000);
}
}
@Override
public void onDbHelperReady() {
// when the database is prepared check if the splash time is passed,
// if it is start mainActivity otherwise wait until it is passed
long timePassed = System.currentTimeMillis() - millis;
if (timePassed >= SPLASH_MILLIS) {
startMainActivity();
} else {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
startMainActivity();
}
}, SPLASH_MILLIS - timePassed);
}
}
private void startMainActivity() {
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}
|
[
"egon10@libero.it"
] |
egon10@libero.it
|
e87d211855363b0c1a2730f0e0b1e5873e5dc381
|
5878b5dbaadf630488f1c7ed7d0e88332b898792
|
/x10dt.core/src/x10dt/core/builder/migration/ProjectMigrationDialog.java
|
be7a6fb19a0c12ef9bbfc543e870137dad03d4c5
|
[] |
no_license
|
x10-lang/x10dt
|
f5fce37772d0208649f819770b3d0d4d34a60e31
|
ed006bc5a86ade1ec45d04cfcd7653cca7e5e942
|
refs/heads/master
| 2021-06-08T06:14:55.467034
| 2017-06-30T21:06:03
| 2017-06-30T21:06:03
| 41,158,271
| 1
| 0
| null | 2021-04-30T01:01:51
| 2015-08-21T13:48:43
|
Java
|
UTF-8
|
Java
| false
| false
| 7,370
|
java
|
/*******************************************************************************
* Copyright (c) 2010 IBM Corporation. *
* All rights reserved. This program and the accompanying materials *
* are made available under the terms of the Eclipse Public License v1.0 *
* which accompanies this distribution, and is available at *
* http://www.eclipse.org/legal/epl-v10.html *
*******************************************************************************/
package x10dt.core.builder.migration;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
final class ProjectMigrationDialog extends Dialog {
private final Set<IProject> fMigrateProjects;
private final Set<IProject> fBrokenProjects;
private boolean fDontAskAgain;
ProjectMigrationDialog(Shell parentShell, Set<IProject> brokenProjects, Set<IProject> migrateProjects) {
super(parentShell);
this.fMigrateProjects = migrateProjects;
this.fBrokenProjects = brokenProjects;
}
public boolean getDontAskAgain() {
return fDontAskAgain;
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setSize(350, 380);
newShell.setText(Messages.ProjectMigrationDialog_title);
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
// create OK and Cancel buttons by default
createButton(parent, IDialogConstants.OK_ID, Messages.ProjectMigrationDialog_proceedButtonLabel, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
GridLayout topLayout = new GridLayout(1, false);
area.setLayout(topLayout);
Text descriptionText = new Text(area, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
descriptionText.setText(Messages.ProjectMigrationDialog_explanationText);
descriptionText.setBackground(parent.getBackground());
descriptionText.setLayoutData(new GridData(340, 45));
Label topLabel = new Label(area, SWT.NONE);
topLabel.setText(Messages.ProjectMigrationDialog_projectListLabel);
Composite tableButtons = new Composite(area, SWT.NONE);
tableButtons.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
final CheckboxTableViewer cbTableViewer = CheckboxTableViewer.newCheckList(tableButtons, SWT.BORDER | SWT.V_SCROLL);
cbTableViewer.setContentProvider(new IStructuredContentProvider() {
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
public void dispose() {}
public Object[] getElements(Object inputElement) {
return fBrokenProjects.toArray();
}
});
cbTableViewer.setLabelProvider(new ITableLabelProvider() {
public void addListener(ILabelProviderListener listener) {}
public void removeListener(ILabelProviderListener listener) {}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void dispose() {}
public String getColumnText(Object element, int columnIndex) {
return ((IProject) element).getName();
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
});
cbTableViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
IProject p = (IProject) event.getElement();
if (event.getChecked()) {
fMigrateProjects.add(p);
} else {
fMigrateProjects.remove(p);
}
}
});
cbTableViewer.setCheckStateProvider(new ICheckStateProvider() {
public boolean isGrayed(Object element) { return false; }
public boolean isChecked(Object element) {
return fMigrateProjects.contains(element);
}
});
cbTableViewer.setInput(new Object()); // a dummy input just to trigger the initial update
Composite selectButtons = new Composite(tableButtons, SWT.NONE);
GridLayout selectButtonsLayout = new GridLayout(1, true);
selectButtons.setLayout(selectButtonsLayout);
Button selectAllButton = new Button(selectButtons, SWT.PUSH);
selectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
selectAllButton.setText(Messages.ProjectMigrationDialog_selectAllButtonTitle);
selectAllButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
fMigrateProjects.addAll(fBrokenProjects);
cbTableViewer.refresh();
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
Button deselectAllButton = new Button(selectButtons, SWT.PUSH);
deselectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
deselectAllButton.setText(Messages.ProjectMigrationDialog_deselectAllButtonTitle);
deselectAllButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
fMigrateProjects.clear();
cbTableViewer.refresh();
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
GridLayout tableButtonsLayout = new GridLayout(2, false);
GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
gridData.heightHint= 100; // if you don't set this, the vertical scrollbar will never appear!
cbTableViewer.getTable().setLayoutData(gridData);
selectButtons.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
tableButtons.setLayout(tableButtonsLayout);
final Button dontAskAgainCB = new Button(area, SWT.CHECK);
dontAskAgainCB.setText(Messages.ProjectMigrationDialog_dontAskCheckboxTitle);
Text dontAskExplanationText= new Text(area, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
dontAskExplanationText.setBackground(parent.getBackground());
dontAskExplanationText.setLayoutData(new GridData(340, 65));
dontAskExplanationText.setText(Messages.ProjectMigrationDialog_dontAskExplanationText1
+ Messages.ProjectMigrationDialog_dontAskExplanationText2
+ Messages.ProjectMigrationDialog_dontAskExplanationText3);
dontAskAgainCB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
fDontAskAgain = dontAskAgainCB.getSelection();
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
return area;
}
}
|
[
"rfuhrer@us.ibm.com"
] |
rfuhrer@us.ibm.com
|
6c78065531154c855aa2532b9db5dc879432933d
|
a97680356f435ecd86354439bb15f946bfcf179b
|
/src/main/java/ar/com/juanlopez/holamundo/app/domain/AbstractAuditingEntity.java
|
401a1f7c1c7612762b8b91e4911b2dda4b87fc38
|
[] |
no_license
|
BulkSecurityGeneratorProject/HolaMundoTest
|
e98f349ecaeea1de9e58bad21ac339b6ff46f91c
|
a8c089d7b7685740b38752121ee41f655c493b38
|
refs/heads/master
| 2022-12-19T20:38:16.657362
| 2017-12-12T21:30:19
| 2017-12-12T21:30:19
| 296,567,961
| 0
| 0
| null | 2020-09-18T08:55:42
| 2020-09-18T08:55:41
| null |
UTF-8
|
Java
| false
| false
| 2,226
|
java
|
package ar.com.juanlopez.holamundo.app.domain;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.envers.Audited;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.time.Instant;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
/**
* Base abstract class for entities which will hold definitions for created, last modified by and created,
* last modified by date.
*/
@MappedSuperclass
@Audited
@EntityListeners(AuditingEntityListener.class)
public abstract class AbstractAuditingEntity implements Serializable {
private static final long serialVersionUID = 1L;
@CreatedBy
@Column(name = "created_by", nullable = false, length = 50, updatable = false)
@JsonIgnore
private String createdBy;
@CreatedDate
@Column(name = "created_date", nullable = false)
@JsonIgnore
private Instant createdDate = Instant.now();
@LastModifiedBy
@Column(name = "last_modified_by", length = 50)
@JsonIgnore
private String lastModifiedBy;
@LastModifiedDate
@Column(name = "last_modified_date")
@JsonIgnore
private Instant lastModifiedDate = Instant.now();
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Instant getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Instant createdDate) {
this.createdDate = createdDate;
}
public String getLastModifiedBy() {
return lastModifiedBy;
}
public void setLastModifiedBy(String lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
public Instant getLastModifiedDate() {
return lastModifiedDate;
}
public void setLastModifiedDate(Instant lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
}
|
[
"Mostro154122954"
] |
Mostro154122954
|
53bc87ae9e4107930be1c6e3cdb989b95f08da2c
|
88f347574d36979506ca3a523936ea486758efc1
|
/constractaLesson/Book.java
|
ddcd756efd934e2d076d057d6b63f38ed5816842
|
[] |
no_license
|
MiAPho/Java
|
4c274c2af768841382b765fe5c67c61781d3bb1a
|
1ebf10c7447830b5bbfa016e3a488c9d3622904a
|
refs/heads/master
| 2022-12-04T07:38:18.892871
| 2020-09-02T10:19:51
| 2020-09-02T10:19:51
| 292,249,378
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 316
|
java
|
public class Book{
String title;
int price;
public Book(){
this("未定");
}
public Book(String title){
this.title=title;
}
public Book(String title,int price){
this(title);
this.price=price;
}
public void showStatus(){
System.out.printf("タイトル:%s,価格:%d%n",this.title,this.price);
}
}
|
[
"akira.program@gmail.com"
] |
akira.program@gmail.com
|
0d85e427240e6528f2bc4093372473e0bc98f33f
|
743d4bc049d45a83b39cd2e8f2f014ae4a4e459b
|
/src/main/java/com/jhipster/demo/store/web/rest/AccountResource.java
|
d02a93f5d994549a2026d3558c80c5d0684c04d8
|
[] |
no_license
|
Morsi84/store
|
4be44758451ef56a6b622232ca18ca9cb08eb67c
|
59e9ac454a794e521fe4fdf97be6bcd8053baa3a
|
refs/heads/master
| 2023-01-20T11:55:10.050406
| 2020-11-18T14:19:48
| 2020-11-18T14:19:48
| 313,900,226
| 0
| 1
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 7,702
|
java
|
package com.jhipster.demo.store.web.rest;
import com.jhipster.demo.store.domain.User;
import com.jhipster.demo.store.repository.UserRepository;
import com.jhipster.demo.store.security.SecurityUtils;
import com.jhipster.demo.store.service.MailService;
import com.jhipster.demo.store.service.UserService;
import com.jhipster.demo.store.service.dto.PasswordChangeDTO;
import com.jhipster.demo.store.service.dto.UserDTO;
import com.jhipster.demo.store.web.rest.errors.*;
import com.jhipster.demo.store.web.rest.vm.KeyAndPasswordVM;
import com.jhipster.demo.store.web.rest.vm.ManagedUserVM;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.*;
/**
* REST controller for managing the current user's account.
*/
@RestController
@RequestMapping("/api")
public class AccountResource {
private static class AccountResourceException extends RuntimeException {
private AccountResourceException(String message) {
super(message);
}
}
private final Logger log = LoggerFactory.getLogger(AccountResource.class);
private final UserRepository userRepository;
private final UserService userService;
private final MailService mailService;
public AccountResource(UserRepository userRepository, UserService userService, MailService mailService) {
this.userRepository = userRepository;
this.userService = userService;
this.mailService = mailService;
}
/**
* {@code POST /register} : register the user.
*
* @param managedUserVM the managed user View Model.
* @throws InvalidPasswordException {@code 400 (Bad Request)} if the password is incorrect.
* @throws EmailAlreadyUsedException {@code 400 (Bad Request)} if the email is already used.
* @throws LoginAlreadyUsedException {@code 400 (Bad Request)} if the login is already used.
*/
@PostMapping("/register")
@ResponseStatus(HttpStatus.CREATED)
public void registerAccount(@Valid @RequestBody ManagedUserVM managedUserVM) {
if (!checkPasswordLength(managedUserVM.getPassword())) {
throw new InvalidPasswordException();
}
User user = userService.registerUser(managedUserVM, managedUserVM.getPassword());
mailService.sendActivationEmail(user);
}
/**
* {@code GET /activate} : activate the registered user.
*
* @param key the activation key.
* @throws RuntimeException {@code 500 (Internal Server Error)} if the user couldn't be activated.
*/
@GetMapping("/activate")
public void activateAccount(@RequestParam(value = "key") String key) {
Optional<User> user = userService.activateRegistration(key);
if (!user.isPresent()) {
throw new AccountResourceException("No user was found for this activation key");
}
}
/**
* {@code GET /authenticate} : check if the user is authenticated, and return its login.
*
* @param request the HTTP request.
* @return the login if the user is authenticated.
*/
@GetMapping("/authenticate")
public String isAuthenticated(HttpServletRequest request) {
log.debug("REST request to check if the current user is authenticated");
return request.getRemoteUser();
}
/**
* {@code GET /account} : get the current user.
*
* @return the current user.
* @throws RuntimeException {@code 500 (Internal Server Error)} if the user couldn't be returned.
*/
@GetMapping("/account")
public UserDTO getAccount() {
return userService.getUserWithAuthorities()
.map(UserDTO::new)
.orElseThrow(() -> new AccountResourceException("User could not be found"));
}
/**
* {@code POST /account} : update the current user information.
*
* @param userDTO the current user information.
* @throws EmailAlreadyUsedException {@code 400 (Bad Request)} if the email is already used.
* @throws RuntimeException {@code 500 (Internal Server Error)} if the user login wasn't found.
*/
@PostMapping("/account")
public void saveAccount(@Valid @RequestBody UserDTO userDTO) {
String userLogin = SecurityUtils.getCurrentUserLogin().orElseThrow(() -> new AccountResourceException("Current user login not found"));
Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getLogin().equalsIgnoreCase(userLogin))) {
throw new EmailAlreadyUsedException();
}
Optional<User> user = userRepository.findOneByLogin(userLogin);
if (!user.isPresent()) {
throw new AccountResourceException("User could not be found");
}
userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(),
userDTO.getLangKey(), userDTO.getImageUrl());
}
/**
* {@code POST /account/change-password} : changes the current user's password.
*
* @param passwordChangeDto current and new password.
* @throws InvalidPasswordException {@code 400 (Bad Request)} if the new password is incorrect.
*/
@PostMapping(path = "/account/change-password")
public void changePassword(@RequestBody PasswordChangeDTO passwordChangeDto) {
if (!checkPasswordLength(passwordChangeDto.getNewPassword())) {
throw new InvalidPasswordException();
}
userService.changePassword(passwordChangeDto.getCurrentPassword(), passwordChangeDto.getNewPassword());
}
/**
* {@code POST /account/reset-password/init} : Send an email to reset the password of the user.
*
* @param mail the mail of the user.
*/
@PostMapping(path = "/account/reset-password/init")
public void requestPasswordReset(@RequestBody String mail) {
Optional<User> user = userService.requestPasswordReset(mail);
if (user.isPresent()) {
mailService.sendPasswordResetMail(user.get());
} else {
// Pretend the request has been successful to prevent checking which emails really exist
// but log that an invalid attempt has been made
log.warn("Password reset requested for non existing mail");
}
}
/**
* {@code POST /account/reset-password/finish} : Finish to reset the password of the user.
*
* @param keyAndPassword the generated key and the new password.
* @throws InvalidPasswordException {@code 400 (Bad Request)} if the password is incorrect.
* @throws RuntimeException {@code 500 (Internal Server Error)} if the password could not be reset.
*/
@PostMapping(path = "/account/reset-password/finish")
public void finishPasswordReset(@RequestBody KeyAndPasswordVM keyAndPassword) {
if (!checkPasswordLength(keyAndPassword.getNewPassword())) {
throw new InvalidPasswordException();
}
Optional<User> user =
userService.completePasswordReset(keyAndPassword.getNewPassword(), keyAndPassword.getKey());
if (!user.isPresent()) {
throw new AccountResourceException("No user was found for this reset key");
}
}
private static boolean checkPasswordLength(String password) {
return !StringUtils.isEmpty(password) &&
password.length() >= ManagedUserVM.PASSWORD_MIN_LENGTH &&
password.length() <= ManagedUserVM.PASSWORD_MAX_LENGTH;
}
}
|
[
"mtlili@altersis.local"
] |
mtlili@altersis.local
|
68d81f2a47ab531c29e15770cf63d48af208fba6
|
b24ba5152cc2dae1fb3b3ddfd1678109e2f17abc
|
/src/main/java/com/viavarejo/compra/servicos/TaxaSelicServico.java
|
1645ec04284697e1ce67d2bab1cebd4c98abfa71
|
[] |
no_license
|
rubenssleme/desafioAPIViaVarejo
|
8e8741240e693dd79adb993d11355902c132f8ad
|
0edd345e86f8ff24837639c06335ea0b26cf111e
|
refs/heads/main
| 2023-05-03T02:48:33.550977
| 2021-05-19T23:38:56
| 2021-05-19T23:38:56
| 355,226,433
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 763
|
java
|
package com.viavarejo.compra.servicos;
import java.math.BigDecimal;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.viavarejo.compra.entidades.Selic;
import com.viavarejo.compra.entidades.SelicService;
@Service
public class TaxaSelicServico {
@Autowired
private SelicService serviceSelic;
public BigDecimal txSelic() {
BigDecimal TaxaSelic;
Integer quantidadeDeRegistros = 1;
List<Selic> listaTaxaSelic = serviceSelic.buscarTaxaSelic(quantidadeDeRegistros);
if (listaTaxaSelic.isEmpty()) {
TaxaSelic = new BigDecimal("999");
} else {
TaxaSelic = listaTaxaSelic.get(0).getValor();
}
return TaxaSelic;
}
}
|
[
"rubenss.leme@gmail.com"
] |
rubenss.leme@gmail.com
|
53b99a1067a842efa0d665055071e33c969c16b7
|
3554c956ca6e158a91f4d88e7198e0788a7e6140
|
/src/javacore/multithreading/executor/SharedResource.java
|
4392508e007116f1a5c50af1c4ff0bf6137ce865
|
[] |
no_license
|
vudph/CodeJam
|
8bc91832b898d6fd97a58c78791e3bfb4cc08bb5
|
b3e013dda550899b0193dbe1fd50168e79b5a5ff
|
refs/heads/master
| 2022-05-02T18:15:51.880041
| 2022-03-24T14:48:50
| 2022-03-24T14:48:50
| 163,015,197
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 592
|
java
|
package javacore.multithreading.executor;
public class SharedResource {
private int count1 = 0;
private int count2 = 0;
public void increment() {
count1 = count1 + 1;
String threadName = Thread.currentThread().getName();
System.out.println(threadName + ": " + count1);
}
public synchronized void incrementSync() {
count2 = count2 + 1;
String threadName = Thread.currentThread().getName();
System.out.println(threadName + ": " + count2);
}
public int getCount1() {
return count1;
}
public int getCount2() {
return count2;
}
}
|
[
"vu.dong@outlook.com"
] |
vu.dong@outlook.com
|
ee94b874a3ad8fce25681adca31dc8b3b8d74bf0
|
3f69773b6daa1e153c9674f9e524c17ab47f0599
|
/openlibrary/src/main/java/superlib/cjt/co/openlibrary/utils/CrashHandler.java
|
945326a852118de4364de6f3d941dfd4e1c0708e
|
[] |
no_license
|
Mr-SuperChen/SuperLib
|
6f785e356845b77bb1abf0b622317bd8b3cc1d9d
|
29d715e9da794f1ac1c8ba3528a037ad7a857b50
|
refs/heads/master
| 2020-04-14T10:23:49.966817
| 2019-01-02T06:25:55
| 2019-01-02T06:25:55
| 163,785,639
| 4
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 9,007
|
java
|
package superlib.cjt.co.openlibrary.utils;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Environment;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 创 建 人: DavikChen
* 日 期: 2013-1-5 下午4:44:51
* 修 改 人:
* 日 期:
* 描 述: UncaughtException处理类,当程序发生Uncaught异常的时候,有该类来接管程序,并记录发送错误报告.
* 版 本 号:1.0
*/
public class CrashHandler implements UncaughtExceptionHandler {
public static final String TAG = "CrashHandler";
// 系统默认的UncaughtException处理类
private UncaughtExceptionHandler mDefaultHandler;
// CrashHandler实例
private static CrashHandler INSTANCE = new CrashHandler();
// 程序的Context对象
private Context mContext;
//
// 用来存储设备信息和异常信息
private Map<String, String> infos = new HashMap<String, String>();
// 用于格式化日期,作为日志文件名的一部分
private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
// public static String DISK_APP_CRASH_PATH = "/" + AppController.getInstance().getContext().getPackageName() + "/crash/";
public String errorFilePath;
private String diskCachePath; // 缓存目录
// public String getSDPath() {
// File sdDir = null;
// boolean sdCardExist = Environment.getExternalStorageState()
// .equals(Environment.MEDIA_MOUNTED);//判断sd卡是否存在
// if (sdCardExist) {
// sdDir = Environment.getExternalStorageDirectory();//获取跟目录
// } else {
// return "";
// }
// String replace = AppController.getInstance().getContext().getPackageName();
// String path = sdDir.toString() + "/Android/data/" + replace + "/"+ BuildConfig.foldercrash+"/";
// File dbFolder = new File(path);
// // 目录不存在则自动创建目录
// if (!dbFolder.exists()) {
// dbFolder.mkdirs();
// }
// return path;
// }
/**
* 保证只有一个CrashHandler实例
*/
private CrashHandler() {
}
/**
* 获取CrashHandler实例 ,单例模式
*/
public static CrashHandler getInstance() {
return INSTANCE;
}
// /**
// * 初始化
// *
// * @param context
// */
// public void init(Context context) {
// mContext = context;
// // 有sdcard时保存到sdcard中
// if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
// diskCachePath = getSDPath();
// } else { // 使用os 分配的缓存目录
// diskCachePath = mContext.getCacheDir().getAbsolutePath() + DISK_APP_CRASH_PATH;
// }
// // 获取系统默认的UncaughtException处理器
// mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
// // 设置该CrashHandler为程序的默认处理器
// Thread.setDefaultUncaughtExceptionHandler(this);
// }
private int current_exception_num = 0;
/**
* 当UncaughtException发生时会转入该函数来处理
*/
@Override
public void uncaughtException(Thread thread, Throwable ex) {
if (!handleException(ex) && mDefaultHandler != null) {
// 如果用户没有处理则让系统默认的异常处理器来处理
mDefaultHandler.uncaughtException(thread, ex);
} else {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
Log.e(TAG, "error : ", e);
}
if (current_exception_num < 3) {
}
restartApp();
// 发送异常日志邮件
}
}
protected LCSharedPreferencesHelper sharedPreferencesHelper = null;
public void restartApp() {
sharedPreferencesHelper = new LCSharedPreferencesHelper(mContext,
LCSharedPreferencesHelper.SHARED_PATH);
int crash = sharedPreferencesHelper.getIntValue("CRASH");
L.e("报错次数:" + crash);
int crash_count = crash+1;
sharedPreferencesHelper.putInt("CRASH", crash_count);
L.e("报错次数——:" + crash_count);
if (crash < 3) {
// Intent intent = AppController.getInstance().getContext().getPackageManager()
// .getLaunchIntentForPackage(AppController.getInstance().getContext().getPackageName());
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// AppController.getInstance().getContext().startActivity(intent);
}
android.os.Process.killProcess(android.os.Process.myPid()); //结束进程之前可以把你程序的注销或者退出代码放在这段代码之前
}
/**
* 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成.
*
* @param ex
* @return true:如果处理了该异常信息;否则返回false.
*/
private boolean handleException(Throwable ex) {
if (ex == null) {
return false;
}
// 使用Toast来显示异常信息
new Thread() {
@Override
public void run() {
Looper.prepare();
Toast.makeText(mContext, "程序出了点小问题", Toast.LENGTH_LONG).show();
Looper.loop();
}
}.start();
// 收集设备参数信息
collectDeviceInfo(mContext);
// 保存日志文件
errorFilePath = saveCrashInfo2File(ex);
return true;
}
/**
* 收集设备参数信息
*
* @param ctx
*/
public void collectDeviceInfo(Context ctx) {
try {
PackageManager pm = ctx.getPackageManager();
PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES);
if (pi != null) {
String versionName = pi.versionName == null ? "null" : pi.versionName;
String versionCode = pi.versionCode + "";
infos.put("versionName", versionName);
infos.put("versionCode", versionCode);
}
} catch (NameNotFoundException e) {
Log.e(TAG, "an error occured when collect package info", e);
}
Field[] fields = Build.class.getDeclaredFields();
for (Field field : fields) {
try {
field.setAccessible(true);
infos.put(field.getName(), field.get(null).toString());
Log.d(TAG, field.getName() + " : " + field.get(null));
} catch (Exception e) {
Log.e(TAG, "an error occured when collect crash info", e);
}
}
}
/**
* 保存错误信息到文件中
*
* @param ex
* @return 返回文件名称, 便于将文件传送到服务器
*/
private String saveCrashInfo2File(Throwable ex) {
StringBuffer sb = new StringBuffer();
for (Map.Entry<String, String> entry : infos.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
sb.append(key + "=" + value + "\n");
}
Writer writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
Throwable cause = ex.getCause();
while (cause != null) {
cause.printStackTrace(printWriter);
cause = cause.getCause();
}
printWriter.close();
String result = writer.toString();
sb.append(result);
try {
long timestamp = System.currentTimeMillis();
String time = formatter.format(new Date());
String fileName = "crash-" + time + "-" + timestamp + ".log";
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File dir = new File(diskCachePath);
if (!dir.exists()) {
dir.mkdirs();
}
FileOutputStream fos = new FileOutputStream(diskCachePath + fileName);
fos.write(sb.toString().getBytes());
fos.close();
}
return fileName;
} catch (Exception e) {
Log.e(TAG, "an error occured while writing file...", e);
}
return "";
}
}
|
[
"jiantong.chen@ryit.co"
] |
jiantong.chen@ryit.co
|
6284001b0b57f06f0b4719df22c016c43dcc5a4d
|
8d5c6b9dab1bb1230871112a9837fdfc28ededb7
|
/JAVAToddler/src/zero16_ibatis/daoLayer/IObjectCreateDao.java
|
f407697e0c076e6d4b1878bfe7320e49a582ab91
|
[] |
no_license
|
JeongHeesu/JAVAToddler-home-
|
238cc7f021fb106125ee8ba770991c49ae87d180
|
dba338d4190ea37abe4682a375602bcee632abe3
|
refs/heads/master
| 2021-03-31T00:17:50.982248
| 2018-03-12T10:59:25
| 2018-03-12T11:16:15
| 124,874,902
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 269
|
java
|
package zero16_ibatis.daoLayer;
import java.sql.SQLException;
public interface IObjectCreateDao {
public void createGradeTable() throws SQLException;
public void createGradeSequence() throws SQLException;
public void insertGrades() throws SQLException;
}
|
[
"sou2514@gmail.com"
] |
sou2514@gmail.com
|
a82575a6fbaa1cd55365246e196a71d01d6756e9
|
e1ac9ac57f697620bf73ef6b49eff3c027c50825
|
/SystemSplit/repository/Repository.java
|
104db6438bf84d495bb82f4f12e6685a6fd75b9b
|
[] |
no_license
|
vdjalov/JAVA
|
845738bde1fd445b224b7734f8957c2109c8d08d
|
0392faa7e24250d4bd875e707087d7d1cd2f2175
|
refs/heads/master
| 2020-05-02T15:39:35.758690
| 2019-04-12T10:17:48
| 2019-04-12T10:17:48
| 178,048,614
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 5,491
|
java
|
package systemSplit.repository;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import systemSplit.hardwareComponents.BaseHardware;
import systemSplit.softwareComponents.BaseSoftware;
public class Repository {
private Map<String, BaseHardware> repository;
public Repository() {
this.repository = new LinkedHashMap<String, BaseHardware>();
}
public void addHardware(String name, BaseHardware bh) {
this.repository.put(name, bh);
}
public Map <String, BaseHardware> getRepository() {
return Collections.unmodifiableMap(this.repository);
}
public void addSoftware(String hardwareName, BaseSoftware bs) {
if(this.repository.containsKey(hardwareName)) {
int currentAvailableDiskCapacity = this.repository.get(hardwareName).getMaximumCapacity();
int necessaryDiskCapacity = bs.getCapacityConsumption();
int availableDiskCapacity = currentAvailableDiskCapacity - necessaryDiskCapacity;
int currentAvailableMemoryCapacity = this.getRepository().get(hardwareName).getMaximumMemory();
int necessaryMemory = bs.getMemoryConsumption();
int availableMemory = currentAvailableMemoryCapacity - necessaryMemory;
if(availableDiskCapacity >= 0 && availableMemory >= 0) {
this.repository.get(hardwareName).setMaximumCapacity(availableDiskCapacity);
this.repository.get(hardwareName).setMaximumMemory(availableMemory);
this.repository.get(hardwareName).getAllSoftware().add(bs);
}
}
}
public void destroyComponent(String hardwareName, String softwareName) {
if(this.repository.containsKey(hardwareName)) {
for(int i = 0; i < this.repository.get(hardwareName).getAllSoftware().size(); i++) {
String name = this.repository.get(hardwareName).getAllSoftware().get(i).getName();
int memory = this.repository.get(hardwareName).getAllSoftware().get(i).getMemoryConsumption();
int capacity = this.repository.get(hardwareName).getAllSoftware().get(i).getCapacityConsumption();
if(name.equals(softwareName)) {
int currentComponentMemory = this.repository.get(hardwareName).getMaximumMemory();
int currentComponentCapacity = this.repository.get(hardwareName).getMaximumCapacity();
this.repository.get(hardwareName).getAllSoftware().remove(i);
this.repository.get(hardwareName).setMaximumMemory(memory + currentComponentMemory);
this.repository.get(hardwareName).setMaximumCapacity(capacity + currentComponentCapacity);
}
}
}
}
public int getSoftwareComponentsCount() {
int totalComponents = 0;
for(String value: this.repository.keySet()) {
int currentSoftware = this.repository.get(value).getAllSoftware().size();
totalComponents = totalComponents + currentSoftware;
}
return totalComponents;
}
public int getTotalOperationalMemoryInUse() {
int totalMemoryInUse = 0;
for(String value: this.repository.keySet()) {
List<BaseSoftware> currentList = this.repository.get(value).getAllSoftware();
for(int i = 0; i < currentList.size(); i++) {
totalMemoryInUse = totalMemoryInUse + currentList.get(i).getMemoryConsumption();
}
}
return totalMemoryInUse;
}
public int getToatalOperationalMemoryLeft() {
int totalMemoryLeft = 0;
for(String value: this.repository.keySet()) {
totalMemoryLeft = totalMemoryLeft + this.repository.get(value).getMaximumMemory();
}
return totalMemoryLeft;
}
public int getTotalCapacityTaken() {
int totalCapacityTaken = 0;
for(String value: this.repository.keySet()) {
List<BaseSoftware> currentList = this.repository.get(value).getAllSoftware();
for(int i = 0; i < currentList.size(); i++) {
totalCapacityTaken = totalCapacityTaken + currentList.get(i).getCapacityConsumption();
}
}
return totalCapacityTaken;
}
public int getTotalCapacityLeft() {
int totalCapacityLeft = 0;
for(String value: this.repository.keySet()) {
totalCapacityLeft = totalCapacityLeft + this.repository.get(value).getMaximumCapacity();
}
return totalCapacityLeft;
}
public int countExpressComponenst(String key) {
AtomicInteger countExpressComponents = new AtomicInteger();
this.repository.get(key).getAllSoftware().forEach(a -> {
if(a.getType().equals("Express")) {
countExpressComponents.incrementAndGet();
}
});
return countExpressComponents.get();
}
public int countLightComponents(String key) {
AtomicInteger countLightComponents = new AtomicInteger();
this.repository.get(key).getAllSoftware().forEach(a -> {
if(a.getType().equals("Light")) {
countLightComponents.incrementAndGet();
}
});
return countLightComponents.get();
}
public int getUsedMemory(String key) {
int totalMemoryUsed = 0;
List<BaseSoftware> bs = this.repository.get(key).getAllSoftware();
for(int i = 0; i < bs.size(); i++) {
totalMemoryUsed+=bs.get(i).getMemoryConsumption();
}
return totalMemoryUsed;
}
public int getUsedCapacity(String key) {
int totalCapacityUsed = 0;
List<BaseSoftware> bs = this.repository.get(key).getAllSoftware();
for(int i = 0; i < bs.size(); i++) {
totalCapacityUsed+=bs.get(i).getCapacityConsumption();
}
return totalCapacityUsed;
}
public void removeHardwareComponent(String key) {
this.repository.remove(key);
}
}
|
[
"vdjalov@gmail.com"
] |
vdjalov@gmail.com
|
c4561d79a4fa783dd4b606367a2795e59c8f9b26
|
bd1daf45cf784a20e181ade564cac252eb2bc8fa
|
/src/main/java/com/chantake/MituyaProject/Tool/Parsing/Range.java
|
31f3599f303e7c7e27f5291b2a9df3d2771f6e02
|
[] |
no_license
|
N-Magi/MituyaProject
|
98e7ba9b79bd59346adb257d78692d9363f8ac43
|
205e85407452efe250ed4ffc47668911c0bbe2c5
|
refs/heads/master
| 2021-06-13T10:21:03.049428
| 2017-01-29T15:24:28
| 2017-01-29T15:24:28
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 4,422
|
java
|
/*
* MituyaProject
* Copyright (C) 2011-2015 chantake <http://328mss.com/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.chantake.MituyaProject.Tool.Parsing;
import java.util.Arrays;
/**
*
* @author fumitti
*/
public class Range {
double num1 = 0;
double num2 = 0;
boolean has1 = false;
boolean has2 = false;
public enum Type {
CLOSED_ONLY("closed-only"),
OPEN_ALLOWED("open-allowed");
private final String name;
Type(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static Type findType(String name) {
for (Type type : Type.values()) {
if (type.getName().equals(name)) {
return type;
}
}
throw new IllegalArgumentException("Unknown range type: " + name);
}
}
public Range(double[] range) throws IllegalArgumentException {
if (range.length != 2) {
throw new IllegalArgumentException("range array must have 2 elements: " + Arrays.toString(range));
}
num1 = range[0];
num2 = range[1];
has1 = true;
has2 = true;
}
public Range(String range, Type type) throws IllegalArgumentException {
int indexOfDots = range.indexOf("..");
if (indexOfDots == -1) {
try { // int number
int num = Integer.decode(range);
num1 = num;
num2 = num;
has1 = true;
has2 = true;
}
catch (NumberFormatException ne) {
throw new IllegalArgumentException("Invalid range format: " + range);
}
} else {
String sFirst = range.substring(0, indexOfDots).trim();
String sSecond = range.substring(indexOfDots + 2).trim();
try {
if (sFirst.length() > 0) {
num1 = Double.parseDouble(sFirst);
has1 = true;
} else if (type == Type.CLOSED_ONLY) {
throw new IllegalArgumentException("Invalid range format:" + range + " (open range not allowed)");
}
if (sSecond.length() > 0) {
num2 = Double.parseDouble(sSecond);
has2 = true;
} else if (type == Type.CLOSED_ONLY) {
throw new IllegalArgumentException("Invalid range format:" + range + " (open range not allowed)");
}
}
catch (NumberFormatException ne) {
throw new IllegalArgumentException("Invalid range format: " + range);
}
}
}
public boolean hasLowerLimit() {
return has1;
}
public boolean hasUpperLimit() {
return has2;
}
public double[] getOrderedRange() {
if (has1 && has2 && num1 > num2) {
return new double[]{num2, num1};
} else {
return new double[]{num1, num2};
}
}
public double[] getRange() {
return new double[]{num1, num2};
}
public int getDirection() {
if (!has1 || !has2) {
return 0;
} else if (num1 > num2) {
return -1;
} else {
return 1;
}
}
public boolean isInRange(double value) {
if (has1 && value < num1) {
return false;
}
return !has2 || value <= num2;
}
@Override
public String toString() {
return (has1 ? "" + num1 : "") + ".." + (has2 ? "" + num2 : "");
}
}
|
[
"chantake@328mss.com"
] |
chantake@328mss.com
|
902fc8c83f756647aa35eb61af1f724ca645cec6
|
6c2f93acc9a88e0b297fa08b7a0443bf6a493f56
|
/gaoshuai2_19/src/test/java/com/example/gaoshuai2_19/ExampleUnitTest.java
|
4f729417b2207990a8f709d7ac7699ef60d39c94
|
[] |
no_license
|
812237872/weektest
|
96daf055c809bdb653f407c83d97e340a6d4813f
|
9ce10dd14adb2eca279b88b5550e59a064d3e783
|
refs/heads/master
| 2020-04-28T09:32:08.039344
| 2019-04-29T05:47:24
| 2019-04-29T05:47:24
| 175,129,605
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 385
|
java
|
package com.example.gaoshuai2_19;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
|
[
"812237872@qq.com"
] |
812237872@qq.com
|
9b6ed71a695df8fb4661d4bc13db673f0f9b4b80
|
d4ab58e00cd8f67ef6ec455da246cc5103908e4b
|
/NewYorkTimes/src/test/java/NYTest/NYLogInTest.java
|
8695f2ecd4bcdb20f5692c113e55544cb4c1a0c6
|
[] |
no_license
|
Team2Framework/SeleniumFramework
|
b7c972b6d4879fd4cea056bf4055f02fb7b30125
|
bf9b50ae4e5652387ca430e3c7894af0b1b30216
|
refs/heads/master
| 2020-04-16T08:33:54.857701
| 2019-01-20T04:11:16
| 2019-01-20T04:11:16
| 165,429,333
| 0
| 0
| null | 2019-01-25T16:02:33
| 2019-01-12T19:50:54
|
Java
|
UTF-8
|
Java
| false
| false
| 881
|
java
|
package NYTest;
import NYHome.NYLogInPage;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Test;
public class NYLogInTest extends NYLogInPage {
NYLogInPage nylogin = PageFactory.initElements(driver, NYLogInPage.class);
public void setUp2(@Optional("https://www.nytimes.com/") String url){
}
@BeforeMethod
@Test
public void logInPageTitleTest(){
String title = nylogin.validateLoginPageTitle();
Assert.assertEquals(title, "Log In - New York Times");
}
@Test
public void loginLogo(){
boolean logoim = nylogin.validateNYImage();
Assert.assertTrue(logoim);
}
@Test
public void loginTest(){
nylogin.logIn("22abushamma22@gmail.com", "qwerty");
}
}
|
[
"noreply@github.com"
] |
noreply@github.com
|
7e06af36569b3d63f9427a5bf201bc91e5820884
|
aa82c44707cbb70da67c3dabdde11e162e56a1b6
|
/com.jtrent238.jtcraft/src/main/java/anw.java
|
5e38e9f98d02355ea6d9d7033de015a150c867dc
|
[] |
no_license
|
jtrent238/jtcraft
|
c6804899969c7e5776253c5122539848c7de5f50
|
290820012690e87a491eaa450b9154fd9cf96115
|
refs/heads/master
| 2021-01-10T09:28:28.084577
| 2016-03-03T02:52:04
| 2016-03-03T02:52:04
| 53,013,456
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,646
|
java
|
/* */ import java.util.List;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class anw
/* */ extends aji
/* */ {
/* 16 */ public static final String[] a = { "default", "mossy", "cracked", "chiseled" };
/* */
/* */
/* */
/* 20 */ public static final String[] b = { null, "mossy", "cracked", "carved" };
/* */
/* */ private rf[] M;
/* */
/* */
/* */ public anw()
/* */ {
/* 27 */ super(awt.e);
/* 28 */ a(abt.b);
/* */ }
/* */
/* */ public rf a(int paramInt1, int paramInt2)
/* */ {
/* 33 */ if ((paramInt2 < 0) || (paramInt2 >= b.length)) paramInt2 = 0;
/* 34 */ return this.M[paramInt2];
/* */ }
/* */
/* */ public int a(int paramInt)
/* */ {
/* 39 */ return paramInt;
/* */ }
/* */
/* */ public void a(adb paramadb, abt paramabt, List paramList)
/* */ {
/* 44 */ for (int i = 0; i < 4; i++) {
/* 45 */ paramList.add(new add(paramadb, 1, i));
/* */ }
/* */ }
/* */
/* */ public void a(rg paramrg)
/* */ {
/* 51 */ this.M = new rf[b.length];
/* */
/* 53 */ for (int i = 0; i < this.M.length; i++) {
/* 54 */ String str = N();
/* 55 */ if (b[i] != null) str = str + "_" + b[i];
/* 56 */ this.M[i] = paramrg.a(str);
/* */ }
/* */ }
/* */ }
/* Location: C:\Users\trent\.gradle\caches\minecraft\net\minecraft\minecraft\1.7.10\minecraft-1.7.10.jar!\anw.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|
[
"jtrent238@outlook.com"
] |
jtrent238@outlook.com
|
74e64b63160f98deda13623bc637280fd433c418
|
48c28fb32ebd172f2795cb48dd1617d0760e00ae
|
/OS1/src/User/Main.java
|
2894637c48e82d39815acbdea08817dadf2130f2
|
[] |
no_license
|
erlichsefi/PoolManger_Compute
|
4e8568cafea7299e07b81f7e73237079860b459d
|
51f5c11280ba25e0a6c29a45012f2b26c4613e16
|
refs/heads/master
| 2020-06-04T22:54:14.576379
| 2015-06-15T15:56:42
| 2015-06-15T15:56:42
| 37,471,941
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,588
|
java
|
package User;
import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.util.concurrent.Semaphore;
import Base.Feeder;
import Base.poolManger;
import Expressions.*;
import tests.*;
public class Main {
static final int NUMBER_POOLS=20;
public static void Solutin(int k,int r,ArrayList<Integer> nk,ArrayList<Integer> lr,ArrayList<Integer> mr,int t,int s,int m) {
poolManger p1= new poolManger(t,NUMBER_POOLS);
p1.start();
Semaphore ComputeWaiting=new Semaphore(0);
//Perform type (1.1)
ExpressionA first=new ExpressionA();
for (int i = 0; i < k; i++) {
final OneStep r1=new OneStep(nk.get(i),first,m);
r1.Exucte(p1, ComputeWaiting);
}
//Perform type (1.2)
ExpressionB secend=new ExpressionB();
ExpressionC third=new ExpressionC();
for (int i = 0; i < r; i++) {
final TwoStep r1=new TwoStep(lr.get(i),secend,m,mr.get(i),third,s);
r1.Exucte(p1, ComputeWaiting);
}
try {
ComputeWaiting.acquire(k+4*r);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("end");
p1.ShutDown();
}
public static void main(String[] args) {
int k=10; //number of (1.1)
int r=1;//number of (1.2)
int max_mul=2;
int max_sum=2;
int t=1;
ArrayList<Integer> nk=new ArrayList<Integer>(k);//(1.1);
ArrayList<Integer> lr=new ArrayList<Integer>(r);//(1.2)a
ArrayList<Integer> nr=new ArrayList<Integer>(r);//(1.2)b
for (int i = 0; i <10; i++) {
nk.add(1);
}
lr.add(1);
nr.add(2);
Solutin(k,r,nk,lr,nr,t,max_sum,max_mul);
}
}
|
[
"erlichsefi@gmail.com"
] |
erlichsefi@gmail.com
|
3f0966043b5383f830dd60b6265678040115f8df
|
2be7fed9d165a58b86b67a3bba0a9c6cf4e8b780
|
/springboot/springboot_mybatis/src/test/java/com/haitao/MybatisTest.java
|
6548e3a55f9ab8b1ac3337ed5eeaf38f8e326b28
|
[] |
no_license
|
langrentao/sprinbboottest_git
|
8c2ee889f291256471e0e2be034ebf93de0e33a2
|
8653ca58f667d413b3dccb9e675a34cae9c886f7
|
refs/heads/master
| 2022-12-28T21:29:01.923296
| 2020-05-12T13:52:22
| 2020-05-12T13:52:22
| 263,347,149
| 0
| 0
| null | 2020-10-13T21:56:06
| 2020-05-12T13:37:52
|
Java
|
UTF-8
|
Java
| false
| false
| 724
|
java
|
package com.haitao;
import com.haitao.domain.Account;
import com.haitao.mapper.UserMapper;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
/**
* @author 涛
* @create 2020/5/11 - 10:19
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringbootMybatisApplication.class)
public class MybatisTest {
@Autowired
private UserMapper userMapper;
@Test
public void test1(){
List<Account> list = userMapper.queryAccount();
System.out.println(list);
}
}
|
[
"1208151926@qq.com"
] |
1208151926@qq.com
|
c3c5771a20eae302199ad2e92874f16302ab85f5
|
032282776b99ad5d4a5be8a3e0646ece637e9fdc
|
/samples/Folding/Sample/obj/Debug/android/src/cheesebaron/folding/FoldingDrawerLayout.java
|
f316a3ec466393745dadb63d4b2a2d3a1cb7192e
|
[] |
no_license
|
huguodong/Foldinglayout
|
824af0c5f66c8d1080a849aae71b774dd9313e75
|
edb46bd7473cf08efdc224321a63dc1459b712fd
|
refs/heads/master
| 2021-01-10T10:11:02.257221
| 2016-01-12T02:44:33
| 2016-01-12T02:58:57
| 49,042,846
| 2
| 1
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,277
|
java
|
package cheesebaron.folding;
public class FoldingDrawerLayout
extends android.support.v4.widget.DrawerLayout
implements
mono.android.IGCUserPeer
{
static final String __md_methods;
static {
__md_methods =
"n_onAttachedToWindow:()V:GetOnAttachedToWindowHandler\n" +
"n_closeDrawer:(Landroid/view/View;)V:GetCloseDrawer_Landroid_view_View_Handler\n" +
"n_generateLayoutParams:(Landroid/util/AttributeSet;)Landroid/view/ViewGroup$LayoutParams;:GetGenerateLayoutParams_Landroid_util_AttributeSet_Handler\n" +
"";
mono.android.Runtime.register ("Cheesebaron.Folding.FoldingDrawerLayout, Cheesebaron.Folding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", FoldingDrawerLayout.class, __md_methods);
}
public FoldingDrawerLayout (android.content.Context p0) throws java.lang.Throwable
{
super (p0);
if (getClass () == FoldingDrawerLayout.class)
mono.android.TypeManager.Activate ("Cheesebaron.Folding.FoldingDrawerLayout, Cheesebaron.Folding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065", this, new java.lang.Object[] { p0 });
}
public FoldingDrawerLayout (android.content.Context p0, android.util.AttributeSet p1) throws java.lang.Throwable
{
super (p0, p1);
if (getClass () == FoldingDrawerLayout.class)
mono.android.TypeManager.Activate ("Cheesebaron.Folding.FoldingDrawerLayout, Cheesebaron.Folding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:Android.Util.IAttributeSet, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065", this, new java.lang.Object[] { p0, p1 });
}
public FoldingDrawerLayout (android.content.Context p0, android.util.AttributeSet p1, int p2) throws java.lang.Throwable
{
super (p0, p1, p2);
if (getClass () == FoldingDrawerLayout.class)
mono.android.TypeManager.Activate ("Cheesebaron.Folding.FoldingDrawerLayout, Cheesebaron.Folding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:Android.Util.IAttributeSet, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:System.Int32, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", this, new java.lang.Object[] { p0, p1, p2 });
}
public void onAttachedToWindow ()
{
n_onAttachedToWindow ();
}
private native void n_onAttachedToWindow ();
public void closeDrawer (android.view.View p0)
{
n_closeDrawer (p0);
}
private native void n_closeDrawer (android.view.View p0);
public android.view.ViewGroup.LayoutParams generateLayoutParams (android.util.AttributeSet p0)
{
return n_generateLayoutParams (p0);
}
private native android.view.ViewGroup.LayoutParams n_generateLayoutParams (android.util.AttributeSet p0);
java.util.ArrayList refList;
public void monodroidAddReference (java.lang.Object obj)
{
if (refList == null)
refList = new java.util.ArrayList ();
refList.add (obj);
}
public void monodroidClearReferences ()
{
if (refList != null)
refList.clear ();
}
}
|
[
"531035580@QQ.COM"
] |
531035580@QQ.COM
|
a27c6945d684ebbc607cd9c6a7a33d7a13714c7d
|
06393a6c424c6a3f8fa115dadf4eeeea558fccbf
|
/src/com/massivecraft/massivecore/xlib/gson/DefaultDateTypeAdapter.java
|
42135081d62349801b7d281e35e960d0a080918c
|
[] |
no_license
|
grrocks/MassiveCoreX
|
c7872d5509927634c3e8e0fe77a5fbe372462c4b
|
1d5bb16e52149985e0605056f842c5285aed2179
|
refs/heads/master
| 2021-03-24T09:58:48.471308
| 2017-10-22T07:45:34
| 2017-10-22T07:45:34
| 82,631,758
| 0
| 1
| null | 2017-10-22T07:45:35
| 2017-02-21T03:28:37
|
Java
|
UTF-8
|
Java
| false
| false
| 4,039
|
java
|
/*
* Copyright (C) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.massivecraft.massivecore.xlib.gson;
import java.lang.reflect.Type;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
/**
* This type adapter supports three subclasses of date: Date, Timestamp, and
* java.sql.Date.
*
* @author Inderjeet Singh
* @author Joel Leitch
*/
final class DefaultDateTypeAdapter implements JsonSerializer<Date>, JsonDeserializer<Date> {
// TODO: migrate to streaming adapter
private final DateFormat enUsFormat;
private final DateFormat localFormat;
private final DateFormat iso8601Format;
DefaultDateTypeAdapter() {
this(DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US),
DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT));
}
DefaultDateTypeAdapter(String datePattern) {
this(new SimpleDateFormat(datePattern, Locale.US), new SimpleDateFormat(datePattern));
}
DefaultDateTypeAdapter(int style) {
this(DateFormat.getDateInstance(style, Locale.US), DateFormat.getDateInstance(style));
}
public DefaultDateTypeAdapter(int dateStyle, int timeStyle) {
this(DateFormat.getDateTimeInstance(dateStyle, timeStyle, Locale.US),
DateFormat.getDateTimeInstance(dateStyle, timeStyle));
}
DefaultDateTypeAdapter(DateFormat enUsFormat, DateFormat localFormat) {
this.enUsFormat = enUsFormat;
this.localFormat = localFormat;
this.iso8601Format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
this.iso8601Format.setTimeZone(TimeZone.getTimeZone("UTC"));
}
// These methods need to be synchronized since JDK DateFormat classes are not thread-safe
// See issue 162
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
synchronized (localFormat) {
String dateFormatAsString = enUsFormat.format(src);
return new JsonPrimitive(dateFormatAsString);
}
}
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
if (!(json instanceof JsonPrimitive)) {
throw new JsonParseException("The date should be a string value");
}
Date date = deserializeToDate(json);
if (typeOfT == Date.class) {
return date;
} else if (typeOfT == Timestamp.class) {
return new Timestamp(date.getTime());
} else if (typeOfT == java.sql.Date.class) {
return new java.sql.Date(date.getTime());
} else {
throw new IllegalArgumentException(getClass() + " cannot deserialize to " + typeOfT);
}
}
private Date deserializeToDate(JsonElement json) {
synchronized (localFormat) {
try {
return localFormat.parse(json.getAsString());
} catch (ParseException ignored) {
}
try {
return enUsFormat.parse(json.getAsString());
} catch (ParseException ignored) {
}
try {
return iso8601Format.parse(json.getAsString());
} catch (ParseException e) {
throw new JsonSyntaxException(json.getAsString(), e);
}
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(DefaultDateTypeAdapter.class.getSimpleName());
sb.append('(').append(localFormat.getClass().getSimpleName()).append(')');
return sb.toString();
}
}
|
[
"gevin_rai@hotmail.com"
] |
gevin_rai@hotmail.com
|
26cda6aaf823254209c678daaee396fc4a6ca3cf
|
8af1164bac943cef64e41bae312223c3c0e38114
|
/results-java/bazelbuild--bazel/db07436b0112e2aea5e543066d4cdb387536ce7f/before/AndroidDataSerializerAndDeserializerTest.java
|
3c76c36406a6b40eccdc338ac042591b8d509ed2
|
[] |
no_license
|
fracz/refactor-extractor
|
3ae45c97cc63f26d5cb8b92003b12f74cc9973a9
|
dd5e82bfcc376e74a99e18c2bf54c95676914272
|
refs/heads/master
| 2021-01-19T06:50:08.211003
| 2018-11-30T13:00:57
| 2018-11-30T13:00:57
| 87,353,478
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 13,449
|
java
|
// Copyright 2017 The Bazel Authors. All rights reserved.
//
// 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.google.devtools.build.android;
import static com.google.devtools.build.android.ParsedAndroidDataBuilder.file;
import static com.google.devtools.build.android.ParsedAndroidDataBuilder.xml;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.jimfs.Jimfs;
import com.google.common.truth.Truth;
import com.google.devtools.build.android.xml.IdXmlResourceValue;
import com.google.devtools.build.android.xml.ResourcesAttribute;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Tests for the AndroidDataSerializer and AndroidDataDeserializer. */
@RunWith(JUnit4.class)
public class AndroidDataSerializerAndDeserializerTest {
private FileSystem fs;
private FullyQualifiedName.Factory fqnFactory;
private Path source;
private Path manifest;
@Before
public void createCleanEnvironment() throws Exception {
fs = Jimfs.newFileSystem();
fqnFactory = FullyQualifiedName.Factory.from(ImmutableList.<String>of());
source = Files.createDirectory(fs.getPath("source"));
manifest = Files.createFile(source.resolve("AndroidManifest.xml"));
}
@Test
public void serializeAssets() throws Exception {
Path binaryPath = fs.getPath("out.bin");
AndroidDataSerializer serializer = AndroidDataSerializer.create();
UnwrittenMergedAndroidData expected =
UnwrittenMergedAndroidData.of(
manifest,
ParsedAndroidDataBuilder.buildOn(source)
.assets(file().source("hunting/of/the/boojum"))
.build(),
ParsedAndroidDataBuilder.empty());
expected.serializeTo(serializer);
serializer.flushTo(binaryPath);
AndroidDataDeserializer deserializer = AndroidDataDeserializer.create();
TestMapConsumer<DataAsset> assets = TestMapConsumer.ofAssets();
deserializer.read(binaryPath, KeyValueConsumers.of(null, null, assets));
Truth.assertThat(assets).isEqualTo(expected.getPrimary().getAssets());
}
@Test
public void serializeCombiningResource() throws Exception {
Path binaryPath = fs.getPath("out.bin");
AndroidDataSerializer serializer = AndroidDataSerializer.create();
UnwrittenMergedAndroidData expected =
UnwrittenMergedAndroidData.of(
manifest,
ParsedAndroidDataBuilder.buildOn(source, fqnFactory)
.combining(
xml("id/snark").source("values/ids.xml").value(IdXmlResourceValue.of()))
.build(),
ParsedAndroidDataBuilder.empty());
expected.serializeTo(serializer);
serializer.flushTo(binaryPath);
AndroidDataDeserializer deserializer = AndroidDataDeserializer.create();
TestMapConsumer<DataResource> resources = TestMapConsumer.ofResources();
deserializer.read(
binaryPath,
KeyValueConsumers.of(
null, // overwriting
resources, // combining
null // assets
));
Truth.assertThat(resources).isEqualTo(expected.getPrimary().getCombiningResources());
}
@Test
public void serializeOverwritingResource() throws Exception {
Path binaryPath = fs.getPath("out.bin");
AndroidDataSerializer serializer = AndroidDataSerializer.create();
UnwrittenMergedAndroidData expected =
UnwrittenMergedAndroidData.of(
manifest,
ParsedAndroidDataBuilder.buildOn(source, fqnFactory)
.overwritable(file("layout/banker").source("layout/banker.xml"))
.build(),
ParsedAndroidDataBuilder.empty());
expected.serializeTo(serializer);
serializer.flushTo(binaryPath);
AndroidDataDeserializer deserializer = AndroidDataDeserializer.create();
TestMapConsumer<DataResource> resources = TestMapConsumer.ofResources();
deserializer.read(
binaryPath,
KeyValueConsumers.of(
resources, // overwriting
null, // combining
null // assets
));
Truth.assertThat(resources).isEqualTo(expected.getPrimary().getOverwritingResources());
}
@Test
public void serializeFileWithIds() throws Exception {
Path binaryPath = fs.getPath("out.bin");
AndroidDataSerializer serializer = AndroidDataSerializer.create();
ParsedAndroidData direct =
AndroidDataBuilder.of(source)
.addResource(
"layout/some_layout.xml",
AndroidDataBuilder.ResourceType.LAYOUT,
"<TextView android:id=\"@+id/MyTextView\"",
" android:text=\"@string/walrus\"",
" android:layout_width=\"wrap_content\"",
" android:layout_height=\"wrap_content\" />")
// Test what happens if a user accidentally uses the same ID in multiple layouts too.
.addResource(
"layout/another_layout.xml",
AndroidDataBuilder.ResourceType.LAYOUT,
"<TextView android:id=\"@+id/MyTextView\"",
" android:text=\"@string/walrus\"",
" android:layout_width=\"wrap_content\"",
" android:layout_height=\"wrap_content\" />")
// Also check what happens if a value XML file also contains the same ID.
.addResource(
"values/ids.xml",
AndroidDataBuilder.ResourceType.VALUE,
"<item name=\"MyTextView\" type=\"id\"/>",
"<item name=\"OtherId\" type=\"id\"/>")
.addResource(
"values/strings.xml",
AndroidDataBuilder.ResourceType.VALUE,
"<string name=\"walrus\">I has a bucket</string>")
.createManifest("AndroidManifest.xml", "com.carroll.lewis", "")
.buildParsed();
UnwrittenMergedAndroidData expected =
UnwrittenMergedAndroidData.of(
manifest,
direct,
ParsedAndroidDataBuilder.empty());
expected.serializeTo(serializer);
serializer.flushTo(binaryPath);
AndroidDataDeserializer deserializer = AndroidDataDeserializer.create();
TestMapConsumer<DataResource> overwriting = TestMapConsumer.ofResources();
TestMapConsumer<DataResource> combining = TestMapConsumer.ofResources();
deserializer.read(
binaryPath,
KeyValueConsumers.of(
overwriting,
combining,
null // assets
));
Truth.assertThat(overwriting).isEqualTo(expected.getPrimary().getOverwritingResources());
Truth.assertThat(combining).isEqualTo(expected.getPrimary().getCombiningResources());
}
@Test
public void serialize() throws Exception {
Path binaryPath = fs.getPath("out.bin");
AndroidDataSerializer serializer = AndroidDataSerializer.create();
UnwrittenMergedAndroidData expected =
UnwrittenMergedAndroidData.of(
manifest,
ParsedAndroidDataBuilder.buildOn(source, fqnFactory)
.overwritable(
file("layout/banker").source("layout/banker.xml"),
xml("<resources>/foo").source("values/ids.xml")
.value(ResourcesAttribute.of(
fqnFactory.parse("<resources>/foo"), "foo", "fooVal")))
.combining(
xml("id/snark").source("values/ids.xml").value(IdXmlResourceValue.of()))
.assets(file().source("hunting/of/the/boojum"))
.build(),
ParsedAndroidDataBuilder.buildOn(source, fqnFactory)
.overwritable(file("layout/butcher").source("layout/butcher.xml"))
.combining(
xml("id/snark").source("values/ids.xml").value(IdXmlResourceValue.of()))
.assets(file().source("hunting/of/the/snark"))
.build());
expected.serializeTo(serializer);
serializer.flushTo(binaryPath);
KeyValueConsumers primary =
KeyValueConsumers.of(
TestMapConsumer.ofResources(), // overwriting
TestMapConsumer.ofResources(), // combining
TestMapConsumer.ofAssets() // assets
);
AndroidDataDeserializer deserializer = AndroidDataDeserializer.create();
deserializer.read(binaryPath, primary);
Truth.assertThat(primary.overwritingConsumer)
.isEqualTo(expected.getPrimary().getOverwritingResources());
Truth.assertThat(primary.combiningConsumer)
.isEqualTo(expected.getPrimary().getCombiningResources());
Truth.assertThat(primary.assetConsumer).isEqualTo(expected.getPrimary().getAssets());
}
@Test
public void testDeserializeMissing() throws Exception {
Path binaryPath = fs.getPath("out.bin");
AndroidDataSerializer serializer = AndroidDataSerializer.create();
UnwrittenMergedAndroidData expected =
UnwrittenMergedAndroidData.of(
manifest,
ParsedAndroidDataBuilder.buildOn(source, fqnFactory)
.overwritable(
file("layout/banker").source("layout/banker.xml"),
xml("<resources>/foo").source("values/ids.xml")
.value(ResourcesAttribute.of(
fqnFactory.parse("<resources>/foo"), "foo", "fooVal")))
.combining(
xml("id/snark").source("values/ids.xml").value(IdXmlResourceValue.of()))
.assets(file().source("hunting/of/the/boojum"))
.build(),
ParsedAndroidDataBuilder.buildOn(source, fqnFactory)
.overwritable(file("layout/butcher").source("layout/butcher.xml"))
.combining(
xml("id/snark").source("values/ids.xml").value(IdXmlResourceValue.of()))
.assets(file().source("hunting/of/the/snark"))
.build());
expected.serializeTo(serializer);
serializer.flushTo(binaryPath);
AndroidDataDeserializer deserializer =
AndroidDataDeserializer.withFilteredResources(
ImmutableList.of("the/boojum", "values/ids.xml", "layout/banker.xml"));
KeyValueConsumers primary =
KeyValueConsumers.of(
TestMapConsumer.ofResources(), // overwriting
TestMapConsumer.ofResources(), // combining
null // assets
);
deserializer.read(binaryPath, primary);
Truth.assertThat(primary.overwritingConsumer).isEqualTo(Collections.emptyMap());
Truth.assertThat(primary.combiningConsumer).isEqualTo(Collections.emptyMap());
}
private static class TestMapConsumer<T extends DataValue>
implements ParsedAndroidData.KeyValueConsumer<DataKey, T>, Map<DataKey, T> {
Map<DataKey, T> target;
static TestMapConsumer<DataAsset> ofAssets() {
return new TestMapConsumer<>(new HashMap<DataKey, DataAsset>());
}
static TestMapConsumer<DataResource> ofResources() {
return new TestMapConsumer<>(new HashMap<DataKey, DataResource>());
}
public TestMapConsumer(Map<DataKey, T> target) {
this.target = target;
}
@Override
public void consume(DataKey key, T value) {
target.put(key, value);
}
@Override
public int size() {
return target.size();
}
@Override
public boolean isEmpty() {
return target.isEmpty();
}
@Override
public boolean containsKey(Object key) {
return target.containsKey(key);
}
@Override
public boolean containsValue(Object value) {
return target.containsValue(value);
}
@Override
public T get(Object key) {
return target.get(key);
}
@Override
public T put(DataKey key, T value) {
return target.put(key, value);
}
@Override
public T remove(Object key) {
return target.remove(key);
}
@Override
public void putAll(Map<? extends DataKey, ? extends T> m) {
target.putAll(m);
}
@Override
public void clear() {
target.clear();
}
@Override
public Set<DataKey> keySet() {
return target.keySet();
}
@Override
public Collection<T> values() {
return target.values();
}
@Override
public Set<java.util.Map.Entry<DataKey, T>> entrySet() {
return target.entrySet();
}
@Override
public boolean equals(Object o) {
return target.equals(o);
}
@Override
public int hashCode() {
return target.hashCode();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("target", target).toString();
}
}
}
|
[
"fraczwojciech@gmail.com"
] |
fraczwojciech@gmail.com
|
4cc590afe6a651db53f0ead0589b32b018226658
|
d5e896e908d1eb5e655ee9f0f2ed6549136b4ccd
|
/app/src/main/java/oleksii/melnykov/marvelcomics/data/DataModule.java
|
643e9cae8af54d9abfceecf82945d70329c88056
|
[] |
no_license
|
MelnykovOleksii/MarvelsComics
|
57e6f5e145d732f5a80b8d77b5c45249f045e6b5
|
bf671532423759acae1b949c76faebf185a24799
|
refs/heads/master
| 2020-07-12T05:43:28.259422
| 2019-09-19T12:10:16
| 2019-09-19T12:10:16
| 204,733,830
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 997
|
java
|
package oleksii.melnykov.marvelcomics.data;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import oleksii.melnykov.marvelcomics.BuildConfig;
import oleksii.melnykov.marvelcomics.di.AppScope;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
@Module
public class DataModule {
@AppScope
@Provides
Repository provideRepository() {
return new Repository();
}
private Retrofit buildRetrofit() {
Gson gson = new GsonBuilder().create();
GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(gson);
return new Retrofit.Builder()
.baseUrl(BuildConfig.MarvelApiUrl)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(gsonConverterFactory)
.client(new OkHttpClient().newBuilder().build())
.build();
}
}
|
[
"oleksii.melnykov@lineup.com.ua"
] |
oleksii.melnykov@lineup.com.ua
|
b21ce2a52386e7807e0cbba178a7aaf672a19259
|
df6eb3b5d4e7b99c4ae7375fec43413b41d53549
|
/src/main/java/br/com/lotbernardes/tree/api/dto/RequestFailureTransferObject.java
|
888c593a7bbc0ea6670e34a933748e312bba3085
|
[] |
no_license
|
lotbernardes/node-tree-application
|
14776046e731b7c73667236fd24b12bad50bd1e6
|
fcfea30b36a1ab373f1e2800b7b68c010768f798
|
refs/heads/master
| 2021-05-10T19:10:06.283552
| 2018-01-24T15:58:01
| 2018-01-24T15:58:01
| 118,144,537
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 497
|
java
|
package br.com.lotbernardes.tree.api.dto;
import br.com.lotbernardes.tree.api.dto.utils.JsonParser;
import br.com.lotbernardes.tree.api.exception.JsonParsingException;
public class RequestFailureTransferObject {
public String message;
public String status;
public RequestFailureTransferObject(String message, String status) {
this.message = message;
this.status = status;
}
public String serialize() throws JsonParsingException {
return JsonParser.serialize(this);
}
}
|
[
"luis.bernardes@involves.com.br"
] |
luis.bernardes@involves.com.br
|
d7cbec58b1006e1e5107881f5890ed45bac10290
|
bc630be5e6fc83b717f29297b77ce79219b17431
|
/src/main/java/io/scheduller/api/ApiApplication.java
|
88ebc556030aaeabed8ee1936d8bc153889e0568
|
[] |
no_license
|
kiluange/schedullerJava
|
aa62c0cf03a2682849ed4da55587163296d054dc
|
3b576e18443c2842c542cf4026dc7c331cef9f84
|
refs/heads/master
| 2020-04-28T20:46:46.171071
| 2019-04-03T03:20:17
| 2019-04-03T03:20:17
| 175,556,316
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 304
|
java
|
package io.scheduller.api;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ApiApplication {
public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args);
}
}
|
[
"daniel.kiluange@gmail.com"
] |
daniel.kiluange@gmail.com
|
9cb3943810f434e812957b10caf179fd1838eaf2
|
21d70bfeb8139da4c458351463d3059ddeabcdf3
|
/java SE阶段/day01_Object,常用API/代码/day01-code/src/cn/itcast/demo01_object/Demo04ObjectsEquals.java
|
1e593609f7c24f3b327460c446a4095f9fb30941
|
[] |
no_license
|
Zhangxb1111/techSource
|
92322e1fba28da1fa067b629c7926bbde34c3014
|
9e3e690ea380323ff857249a699f62414eb8bfd2
|
refs/heads/master
| 2023-01-20T00:18:50.703877
| 2020-11-17T12:57:47
| 2020-11-17T12:57:47
| 299,050,652
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 949
|
java
|
package cn.itcast.demo01_object;
import java.util.Objects;
/*
Objects中的equals方法。
static boolean equals(Object a, Object b): 比较a和b是否相同。
如果通过Objects调用equals方法,内部会通过第一个对象调用equals和第二个对象进行比较
如果我们想要比较对象的内容,还是要在子类中重写equals
*/
public class Demo04ObjectsEquals {
public static void main(String[] args) {
//创建三个对象
Teacher t1 = new Teacher("小苍老师", 35);
Teacher t2 = new Teacher("小苍老师", 35);
//使用Objects里面的equals方法进行比较
System.out.println(Objects.equals(t1, t2));
System.out.println("-------------------------");
t1 = null;
t2 = null;
//System.out.println(t1.equals(t2)); // java.lang.NullPointerException
System.out.println(Objects.equals(t1, t2)); //true
}
}
|
[
"2955356960@qq.com"
] |
2955356960@qq.com
|
a1b907068d5cf78a75a49483b42c518215e1e6b9
|
f025743bb53127165674963a58b18c153050a144
|
/app/src/main/java/com/truemi/transformaer/transformerLib/PageTransformerOverlap.java
|
a6806106e1005ffd9d60d0c45abd078fa5970e6c
|
[] |
no_license
|
truemi/Transformer_impl
|
960d9ef4d71097f46f403e94c12cae86cde5388d
|
465d0423679d95db5502ddd8298e69d7ffa971ac
|
refs/heads/master
| 2020-03-24T02:52:41.328133
| 2019-11-15T13:24:53
| 2019-11-15T13:24:53
| 142,393,770
| 10
| 6
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,067
|
java
|
package com.truemi.transformaer.transformerLib;
import android.view.View;
/**
* 重叠效果
*/
public class PageTransformerOverlap extends BasePageTransformer {
private float mMaxScale = 0.75f;
public PageTransformerOverlap() {
}
public PageTransformerOverlap(float maxRotation) {
setMaxAlpha(maxRotation);
}
@Override
public void touch2Left(View view, float position) {
}
@Override
public void touch2Right(View view, float position) {
float scaleFactor = mMaxScale+ (1 - mMaxScale) * (1 - Math.abs(position));
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
view.setAlpha(1-position);
view.setTranslationX(view.getMeasuredWidth() * -position);
}
@Override
public void other(View view, float position) {
//view.setScaleX(mMaxScale);
// view.setScaleY(mMaxScale);
}
public void setMaxAlpha(float mMaxScale) {
if (mMaxScale >= 0.0f && mMaxScale <= 1.0f) {
this.mMaxScale = mMaxScale;
}
}
}
|
[
"truemi.73@live.com"
] |
truemi.73@live.com
|
19022daa014d16f52d4c10c37c0c987238f10777
|
201c248d1bdba5e8c9b3565fca2242d7557f5ac5
|
/app/src/main/java/com/cml/cmltinker/SampleApplicationLike.java
|
9e6e11f1b17fd4367c1bbeff86d1f8619149d955
|
[] |
no_license
|
cmlgithub/CmlTinker
|
a524dc54c4192be38d0617e03001f26fbe39d534
|
0bfc145f7d628ad2dcc77d4decf78c74aa054fdb
|
refs/heads/master
| 2021-01-13T02:51:39.987826
| 2016-12-22T09:35:07
| 2016-12-22T09:35:07
| 77,131,499
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,184
|
java
|
package com.cml.cmltinker;
import android.app.Application;
import android.content.Intent;
import android.content.res.AssetManager;
import android.content.res.Resources;
import com.tencent.tinker.anno.DefaultLifeCycle;
import com.tencent.tinker.loader.app.DefaultApplicationLike;
import com.tencent.tinker.loader.shareutil.ShareConstants;
/**
* author:cml on 2016/12/22
* github:https://github.com/cmlgithub
*/
@DefaultLifeCycle(
application = "com.cml.cmltinker.SampleApplicationLike", //application name to generate
flags = ShareConstants.TINKER_ENABLE_ALL) //tinkerFlags above
public class SampleApplicationLike extends DefaultApplicationLike {
public SampleApplicationLike(Application application, int tinkerFlags, boolean tinkerLoadVerifyFlag, long applicationStartElapsedTime, long applicationStartMillisTime, Intent tinkerResultIntent, Resources[] resources, ClassLoader[] classLoader, AssetManager[] assetManager) {
super(application, tinkerFlags, tinkerLoadVerifyFlag, applicationStartElapsedTime, applicationStartMillisTime, tinkerResultIntent, resources, classLoader, assetManager);
}
}
|
[
"229473390@qq.com"
] |
229473390@qq.com
|
36ba87bd7608aa3274e289a1a43fd9c0dc8f130e
|
3bc316340d30b43c946624b64492ab59fc55613a
|
/app/src/main/java/ru/alex9127/app/drawing/StaticImage.java
|
15b48e7fd636ee15e7d55a78772a62fc51247603
|
[
"MIT"
] |
permissive
|
alex9127git/Dungeon-Crawler
|
915726207eca74df6f90d819b40828c513c416bc
|
0617f4c987a6a001da25e5862643a6c04f3a0954
|
refs/heads/main
| 2023-06-19T13:10:42.131539
| 2021-07-20T09:03:01
| 2021-07-20T09:03:01
| 349,039,072
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,686
|
java
|
package ru.alex9127.app.drawing;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
public class StaticImage extends Image {
private final Bitmap bitmap;
private final int width;
private final int height;
private int defaultX;
private int defaultY;
private Rect boundaryRect;
public StaticImage(Bitmap bitmap, int width, int height, int defaultX, int defaultY) {
this.bitmap = bitmap;
this.width = width;
this.height = height;
this.defaultX = defaultX;
this.defaultY = defaultY;
updateBoundaryRect();
}
private void updateBoundaryRect() {
this.boundaryRect = new Rect(defaultX - width / 2, defaultY - height / 2,
defaultX + width / 2, defaultY + height / 2);
}
public void draw(Canvas canvas) {
canvas.drawBitmap(this.bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()),
new Rect(defaultX - width / 2, defaultY - height / 2,
defaultX + width / 2, defaultY + height / 2), new Paint());
}
public Rect getBoundaryRect() {
return boundaryRect;
}
public void setDefaultX(int defaultX) {
this.defaultX = defaultX;
updateBoundaryRect();
}
public void setDefaultY(int defaultY) {
this.defaultY = defaultY;
updateBoundaryRect();
}
public StaticImage clone() {
try {
super.clone();
} catch (CloneNotSupportedException ignored) {}
return new StaticImage(this.bitmap, this.width, this.height, this.defaultX, this.defaultY);
}
}
|
[
"mail.alex9127@yandex.ru"
] |
mail.alex9127@yandex.ru
|
9d2b6aa28601eb71f687c524e320bec41be94eac
|
be73270af6be0a811bca4f1710dc6a038e4a8fd2
|
/crash-reproduction-moho/results/XWIKI-14462-12-28-NSGA_II-WeightedSum:TestLen:CallDiversity/org/xwiki/job/AbstractJob_ESTest_scaffolding.java
|
66c9499e8c7ecc2d6eb71176d2f9169cc1dff0d0
|
[] |
no_license
|
STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application
|
cf118b23ecb87a8bf59643e42f7556b521d1f754
|
3bb39683f9c343b8ec94890a00b8f260d158dfe3
|
refs/heads/master
| 2022-07-29T14:44:00.774547
| 2020-08-10T15:14:49
| 2020-08-10T15:14:49
| 285,804,495
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 429
|
java
|
/**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Fri Apr 03 02:19:16 UTC 2020
*/
package org.xwiki.job;
import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
@EvoSuiteClassExclude
public class AbstractJob_ESTest_scaffolding {
// Empty scaffolding for empty test suite
}
|
[
"pouria.derakhshanfar@gmail.com"
] |
pouria.derakhshanfar@gmail.com
|
ef0828a1f5703e9c80250efa033d0b5d09077ce5
|
26d3787bd96e2d23fdd0e0a8768999325bf27148
|
/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/GrpcImageAnnotatorCallableFactory.java
|
e29b73f3b5526ddb802f3704cbc7b09ad59fffd2
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
ladderlife/google-cloud-java
|
34bd448855e13a2f391ae8dc5ccdbd16becb7af7
|
0e910f51d108377773bccbc7c8a9d3247aff55f2
|
refs/heads/master
| 2020-03-11T00:02:46.620927
| 2018-04-14T01:12:22
| 2018-04-14T01:12:22
| 129,653,759
| 0
| 1
| null | 2018-04-15T21:47:15
| 2018-04-15T21:47:15
| null |
UTF-8
|
Java
| false
| false
| 5,008
|
java
|
/*
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://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.google.cloud.vision.v1.stub;
import com.google.api.core.BetaApi;
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcCallableFactory;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.BatchingCallSettings;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientStreamingCallable;
import com.google.api.gax.rpc.OperationCallSettings;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.ServerStreamingCallSettings;
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.api.gax.rpc.StreamingCallSettings;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.longrunning.Operation;
import com.google.longrunning.stub.OperationsStub;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS
/**
* gRPC callable factory implementation for Google Cloud Vision API.
*
* <p>This class is for advanced usage.
*/
@Generated("by GAPIC v0.0.5")
@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
public class GrpcImageAnnotatorCallableFactory implements GrpcStubCallableFactory {
@Override
public <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createUnaryCallable(
GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
UnaryCallSettings<RequestT, ResponseT> callSettings,
ClientContext clientContext) {
return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext);
}
@Override
public <RequestT, ResponseT, PagedListResponseT>
UnaryCallable<RequestT, PagedListResponseT> createPagedCallable(
GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
PagedCallSettings<RequestT, ResponseT, PagedListResponseT> pagedCallSettings,
ClientContext clientContext) {
return GrpcCallableFactory.createPagedCallable(
grpcCallSettings, pagedCallSettings, clientContext);
}
@Override
public <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createBatchingCallable(
GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
BatchingCallSettings<RequestT, ResponseT> batchingCallSettings,
ClientContext clientContext) {
return GrpcCallableFactory.createBatchingCallable(
grpcCallSettings, batchingCallSettings, clientContext);
}
@Override
public <RequestT, ResponseT, MetadataT>
OperationCallable<RequestT, ResponseT, MetadataT> createOperationCallable(
GrpcCallSettings<RequestT, com.google.longrunning.Operation> grpcCallSettings,
OperationCallSettings<RequestT, ResponseT, MetadataT> operationCallSettings,
ClientContext clientContext,
OperationsStub operationsStub) {
return GrpcCallableFactory.createOperationCallable(
grpcCallSettings, operationCallSettings, clientContext, operationsStub);
}
@Override
public <RequestT, ResponseT>
BidiStreamingCallable<RequestT, ResponseT> createBidiStreamingCallable(
GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
StreamingCallSettings<RequestT, ResponseT> streamingCallSettings,
ClientContext clientContext) {
return GrpcCallableFactory.createBidiStreamingCallable(
grpcCallSettings, streamingCallSettings, clientContext);
}
@Override
public <RequestT, ResponseT>
ServerStreamingCallable<RequestT, ResponseT> createServerStreamingCallable(
GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
ServerStreamingCallSettings<RequestT, ResponseT> streamingCallSettings,
ClientContext clientContext) {
return GrpcCallableFactory.createServerStreamingCallable(
grpcCallSettings, streamingCallSettings, clientContext);
}
@Override
public <RequestT, ResponseT>
ClientStreamingCallable<RequestT, ResponseT> createClientStreamingCallable(
GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
StreamingCallSettings<RequestT, ResponseT> streamingCallSettings,
ClientContext clientContext) {
return GrpcCallableFactory.createClientStreamingCallable(
grpcCallSettings, streamingCallSettings, clientContext);
}
}
|
[
"noreply@github.com"
] |
noreply@github.com
|
b9f1ae1d8d5b1f8de1efc4dc61fae8a8df321237
|
eca1af940e1d4b04f4a3a653e9fc27d047af3b11
|
/src/main/java/com/codegym/AppConfiguration.java
|
370f75f0ba9131cbd42af10619875da84370636d
|
[] |
no_license
|
ducphu4893/hitcounter
|
f6bf5f6da4940cbb9feb864d931447af52a19fff
|
d65b7ea79910642ebc440e4c47e6e72f11a4bfb4
|
refs/heads/master
| 2020-04-16T12:36:28.861232
| 2019-01-14T03:10:22
| 2019-01-14T03:10:22
| 165,587,436
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,001
|
java
|
package com.codegym;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;
@Configuration
@ComponentScan("com.codegym.controller")
@EnableWebMvc
public class AppConfiguration implements ApplicationContextAware {
private ApplicationContext applicationContext;
@Bean
public SpringResourceTemplateResolver templateResolver(){
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
templateResolver.setPrefix("/WEB-INF/views/");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode(TemplateMode.HTML);
return templateResolver;
}
@Bean
public TemplateEngine templateEngine(){
TemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
return templateEngine;
}
@Bean
public ViewResolver viewResolver(){
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(templateEngine());
return viewResolver;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
|
[
"phu2638@gmail.com"
] |
phu2638@gmail.com
|
6f1be0c772f940cc5019f0833c578e8165c8e933
|
f4ae4555388ba43db1f37b1c920d39d5a99d2b0e
|
/src/com/f/AVLTree/AVLTree.java
|
e95bb802109e9b5281b25e83edc838b6e375f7f0
|
[] |
no_license
|
Utkarsh-95/DataStructures
|
a6d22878bc86ad6b8ea2d772fed88bddc7526fa3
|
dc0ca3c939516ef8d48caf06362cda9aa7e71cb9
|
refs/heads/main
| 2023-02-04T17:44:43.631144
| 2022-12-15T10:21:43
| 2022-12-15T10:21:43
| 300,227,129
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 10,517
|
java
|
package com.f.AVLTree;
import java.util.LinkedList;
import java.util.Queue;
import a.com.CustomClass.BinaryNode;
public class AVLTree {
BinaryNode root;
public BinaryNode getRoot() {
return root;
}
AVLTree() {
root = null;
}
// Insert values in AVL Tree
void insert(int value) {
root = hepler_insert(root, value);
}// end of method
// Helper Method
BinaryNode hepler_insert(BinaryNode currentNode, int value) {
// THIS ELSE_IF BLOCK IS BST CONDITION
if (currentNode == null) {
System.out.println("Successfully inserted " + value + " in AVL Tree");
return createNewNode(value);
} else if (value <= currentNode.getData()) {
currentNode.setLeft(hepler_insert(currentNode.getLeft(), value));
} else {
currentNode.setRight(hepler_insert(currentNode.getRight(), value));
}
// THIS IS WHERE WE WILL DO AVL SPECIFIC WORK
int balance = checkBalance(currentNode.getLeft(), currentNode.getRight());
if (balance > 1) {
if (checkBalance(currentNode.getLeft().getLeft(), currentNode.getLeft().getRight()) > 0) {
currentNode = rightRotate(currentNode);// LL Condition
} else {
currentNode.setLeft(leftRotate(currentNode.getLeft())); // LR Condition
currentNode = rightRotate(currentNode);
}
} else if (balance < -1) {
if (checkBalance(currentNode.getRight().getRight(), currentNode.getRight().getLeft()) > 0) {
currentNode = leftRotate(currentNode);// RR Condition
} else {
currentNode.setRight(rightRotate(currentNode.getRight()));// RL Condition
currentNode = leftRotate(currentNode);
}
}
if (currentNode.getLeft() != null) {
currentNode.getLeft().setHeight(calculateHeight(currentNode.getLeft()));
}
if (currentNode.getRight() != null) {
currentNode.getRight().setHeight(calculateHeight(currentNode.getRight()));
}
currentNode.setHeight(calculateHeight(currentNode));
return currentNode;
}// end of method
// Helper Method
private BinaryNode leftRotate(BinaryNode currentNode) {
BinaryNode newRoot = currentNode.getRight();
currentNode.setRight(currentNode.getRight().getLeft());
newRoot.setLeft(currentNode);
currentNode.setHeight(calculateHeight(currentNode));
newRoot.setHeight(calculateHeight(newRoot));
return newRoot;
}// end of method
// Helper Method
private BinaryNode rightRotate(BinaryNode currentNode) {
BinaryNode newRoot = currentNode.getLeft();
currentNode.setLeft(currentNode.getLeft().getRight());
newRoot.setRight(currentNode);
currentNode.setHeight(calculateHeight(currentNode));
newRoot.setHeight(calculateHeight(newRoot));
return newRoot;
}// end of method
// Helper Method
private int checkBalance(BinaryNode rootLeft, BinaryNode rootRight) {
if ((rootLeft == null) && (rootRight == null)) { //if current node is a leaf node then no need to check balance of its children
return 0;
} else if (rootLeft == null) {
return -1 * (rootRight.getHeight() + 1); // if left node node is not there then simply return right node's
// height + 1
// we need to make it -1 because blank height is considered
// having height as '-1'
} else if (rootRight == null) {
return rootLeft.getHeight() + 1;
} else {
return rootLeft.getHeight() - rootRight.getHeight(); // +1 is not required, as both right and left child
// exits and 1 gets nullified
}
}// end of method
// Calculate height of Node
private int calculateHeight(BinaryNode currentNode) {
if (currentNode == null) {
return 0;
}
return Math.max((currentNode.getLeft() != null ? currentNode.getLeft().getHeight() : -1),
(currentNode.getRight() != null ? currentNode.getRight().getHeight() : -1)) + 1;
}// end of method
// creates a new blank new node
public BinaryNode createNewNode(int value) {
BinaryNode node = new BinaryNode();
node.setData(value);
node.setHeight(0);// Since this is a leaf node, its height is 0
return node;
}
// Level order traversal of BST
void levelOrderTraversal() {
Queue<BinaryNode> queue = new LinkedList<>();
queue.add(root);
System.out.println("Printing Level order traversal of AVL Tree...");
if (root == null) {
System.out.println("Tree does not exists !");
return;
}
while (!queue.isEmpty()) {
BinaryNode presentNode = queue.remove();
System.out.print(presentNode.getData() + " ");
if (presentNode.getLeft() != null) {
queue.add(presentNode.getLeft());
}
if (presentNode.getRight() != null) {
queue.add(presentNode.getRight());
}
}
}// end of method
// Deleting a node from BST
public void deleteNodeOfBST(int value) {
System.out.println("Deleting " + value + " from AVL Tree ...");
root = deleteNodeOfBST(root, value);
}
// Helper Method for delete
public BinaryNode deleteNodeOfBST(BinaryNode currentNode, int value) {
// THIS ELSE_IF BLOCK IS BST CONDITION
if (currentNode == null) {
return null;
}
if (value < currentNode.getData()) {
currentNode.setLeft(deleteNodeOfBST(currentNode.getLeft(), value));
} else if (value > currentNode.getData()) {
currentNode.setRight(deleteNodeOfBST(currentNode.getRight(), value));
} else { // If currentNode is the node to be deleted
//System.out.println("currentNode is the node to be deleted");
if (currentNode.getLeft() != null && currentNode.getRight() != null) { // if nodeToBeDeleted have both children
BinaryNode temp = currentNode;
BinaryNode minNodeForRight = minimumElement(temp.getRight());// Finding minimum element from right subtree
currentNode.setData(minNodeForRight.getData()); // Replacing current node with minimum node from right subtree
deleteNodeOfBST(currentNode.getRight(), minNodeForRight.getData());// Deleting minimum node from right now
} else if (currentNode.getLeft() != null) {// if nodeToBeDeleted has only left child
currentNode = currentNode.getLeft();
} else if (currentNode.getRight() != null) {// if nodeToBeDeleted has only right child
currentNode = currentNode.getRight();
} else { // if nodeToBeDeleted do not have child (Leaf node)
//System.out.println("This node is leaf node");
currentNode = null;
}
return currentNode;// if it is a leaf node,then no need to do balancing for this node, do only for its ancestors
}
// THIS IS WHERE WE WILL DO AVL SPECIFIC WORK
int balance = checkBalance(currentNode.getLeft(), currentNode.getRight());
if (balance > 1) {
if (checkBalance(currentNode.getLeft().getLeft(), currentNode.getLeft().getRight()) > 0) {
currentNode = rightRotate(currentNode);// LL Condition
} else {
currentNode.setLeft(leftRotate(currentNode.getLeft())); // LR Condition
currentNode = rightRotate(currentNode);
}
} else if (balance < -1) {
if (checkBalance(currentNode.getRight().getRight(), currentNode.getRight().getLeft()) > 0) {
currentNode = leftRotate(currentNode);// RR Condition
} else {
currentNode.setRight(rightRotate(currentNode.getRight()));// RL Condition
currentNode = leftRotate(currentNode);
}
}
if (currentNode.getLeft() != null) {
currentNode.getLeft().setHeight(calculateHeight(currentNode.getLeft()));
}
if (currentNode.getRight() != null) {
currentNode.getRight().setHeight(calculateHeight(currentNode.getRight()));
}
currentNode.setHeight(calculateHeight(currentNode));
return currentNode;
}// end of method
// Get minimum element in binary search tree
public static BinaryNode minimumElement(BinaryNode root) {
if (root.getLeft() == null) {
return root;
} else {
return minimumElement(root.getLeft());
}
}// end of method
void printTreeGraphically() {
Queue<BinaryNode> queue = new LinkedList<>();
Queue<Integer> level = new LinkedList<>();
int CurrentLevel = 1;
boolean previousLevelWasAllNull = false;
queue.add(root);
level.add(1);
System.out.println("\nPrinting Level order traversal of Tree...");
if (root == null) {
System.out.println("Tree does not exists !");
return;
}
while (!queue.isEmpty()) {
if (CurrentLevel == level.peek()) { //if we are in the same level
if (queue.peek() == null) {
queue.add(null);
level.add(CurrentLevel + 1);
} else {
queue.add(queue.peek().getLeft());
level.add(CurrentLevel + 1);
queue.add(queue.peek().getRight());
level.add(CurrentLevel + 1);
previousLevelWasAllNull = false;
}
System.out.print(queue.remove() + " ");
level.remove();
} else { //level has changed
System.out.println("\n");
CurrentLevel++;
if (previousLevelWasAllNull == true) {
break;
}
previousLevelWasAllNull = true;
}
}//end of loop
}//end of method
}
|
[
"utksingh1993@gmail.com"
] |
utksingh1993@gmail.com
|
648774912d9593403e29273483dbf5e84db88ccc
|
69b04a05d0a478af6e2b5d2e763cb50663bb688f
|
/rakam-aws/src/main/java/org/rakam/aws/lambda/AWSLambdaConfig.java
|
efed6d7dbfe2eedd95c3bc08ce830aeb90cdb547
|
[
"Apache-2.0"
] |
permissive
|
mehhmetoz/rakam
|
f337a4b6a3201632a0aa1f36e4d9dc157edd7941
|
987d4090ac60c02ed260b8bdeeeb2c5e259e3293
|
refs/heads/master
| 2020-06-22T07:16:44.181850
| 2016-11-23T00:23:39
| 2016-11-23T00:23:39
| 74,599,327
| 1
| 0
| null | 2016-11-23T17:28:04
| 2016-11-23T17:28:04
| null |
UTF-8
|
Java
| false
| false
| 911
|
java
|
package org.rakam.aws.lambda;
import io.airlift.configuration.Config;
public class AWSLambdaConfig
{
String marketS3Bucket = "rakam-task-market";
private String roleArn;
private String stackId;
@Config("task.market_s3_bucket")
public AWSLambdaConfig setMarketS3Bucket(String marketS3Bucket)
{
this.marketS3Bucket = marketS3Bucket;
return this;
}
@Config("task.role_arn")
public AWSLambdaConfig setRoleArn(String roleArn)
{
this.roleArn = roleArn;
return this;
}
public String getRoleArn()
{
return roleArn;
}
@Config("task.stack_id")
public AWSLambdaConfig setStackId(String stackId)
{
this.stackId = stackId;
return this;
}
public String getStackId()
{
return stackId;
}
public String getMarketS3Bucket()
{
return marketS3Bucket;
}
}
|
[
"emrekabakci@gmail.com"
] |
emrekabakci@gmail.com
|
7d0479b1a6b8bc7abe81ca80c4ae27222561c754
|
2944b7c8f0bdf350dcefc373c9f7b716c00f83b5
|
/Proyecto5-Controles/Proyecto5-Controles/Proyecto5_Controles.Android/obj/Debug/android/src/mono/MonoPackageManager.java
|
330cf6cf63e1d508cea62e0e6bd60e8029855744
|
[] |
no_license
|
Hachiko92/Xamarin
|
fdb6ce2d8b289243ebb9ed2c0b46f9fba1c385e1
|
f6f6ac49c9a0de8bcfbf4efa0c7dac21ed1c0560
|
refs/heads/master
| 2021-01-01T16:36:35.394044
| 2017-07-28T18:18:41
| 2017-07-28T18:18:41
| 97,512,083
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,566
|
java
|
package mono;
import java.io.*;
import java.lang.String;
import java.util.Locale;
import java.util.HashSet;
import java.util.zip.*;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.res.AssetManager;
import android.util.Log;
import mono.android.Runtime;
public class MonoPackageManager {
static Object lock = new Object ();
static boolean initialized;
static android.content.Context Context;
public static void LoadApplication (Context context, ApplicationInfo runtimePackage, String[] apks)
{
synchronized (lock) {
if (context instanceof android.app.Application) {
Context = context;
}
if (!initialized) {
android.content.IntentFilter timezoneChangedFilter = new android.content.IntentFilter (
android.content.Intent.ACTION_TIMEZONE_CHANGED
);
context.registerReceiver (new mono.android.app.NotifyTimeZoneChanges (), timezoneChangedFilter);
System.loadLibrary("monodroid");
Locale locale = Locale.getDefault ();
String language = locale.getLanguage () + "-" + locale.getCountry ();
String filesDir = context.getFilesDir ().getAbsolutePath ();
String cacheDir = context.getCacheDir ().getAbsolutePath ();
String dataDir = getNativeLibraryPath (context);
ClassLoader loader = context.getClassLoader ();
Runtime.init (
language,
apks,
getNativeLibraryPath (runtimePackage),
new String[]{
filesDir,
cacheDir,
dataDir,
},
loader,
new java.io.File (
android.os.Environment.getExternalStorageDirectory (),
"Android/data/" + context.getPackageName () + "/files/.__override__").getAbsolutePath (),
MonoPackageManager_Resources.Assemblies,
context.getPackageName ());
mono.android.app.ApplicationRegistration.registerApplications ();
initialized = true;
}
}
}
public static void setContext (Context context)
{
// Ignore; vestigial
}
static String getNativeLibraryPath (Context context)
{
return getNativeLibraryPath (context.getApplicationInfo ());
}
static String getNativeLibraryPath (ApplicationInfo ainfo)
{
if (android.os.Build.VERSION.SDK_INT >= 9)
return ainfo.nativeLibraryDir;
return ainfo.dataDir + "/lib";
}
public static String[] getAssemblies ()
{
return MonoPackageManager_Resources.Assemblies;
}
public static String[] getDependencies ()
{
return MonoPackageManager_Resources.Dependencies;
}
public static String getApiPackageName ()
{
return MonoPackageManager_Resources.ApiPackageName;
}
}
class MonoPackageManager_Resources {
public static final String[] Assemblies = new String[]{
/* We need to ensure that "Proyecto5_Controles.Android.dll" comes first in this list. */
"Proyecto5_Controles.Android.dll",
"FormsViewGroup.dll",
"Xamarin.Android.Support.Animated.Vector.Drawable.dll",
"Xamarin.Android.Support.Design.dll",
"Xamarin.Android.Support.v4.dll",
"Xamarin.Android.Support.v7.AppCompat.dll",
"Xamarin.Android.Support.v7.CardView.dll",
"Xamarin.Android.Support.v7.MediaRouter.dll",
"Xamarin.Android.Support.v7.RecyclerView.dll",
"Xamarin.Android.Support.Vector.Drawable.dll",
"Xamarin.Forms.Core.dll",
"Xamarin.Forms.Platform.Android.dll",
"Xamarin.Forms.Platform.dll",
"Xamarin.Forms.Xaml.dll",
"Proyecto5_Controles.dll",
};
public static final String[] Dependencies = new String[]{
};
public static final String ApiPackageName = "Mono.Android.Platform.ApiLevel_25";
}
|
[
"eleonora.franchini@tajamar365.com"
] |
eleonora.franchini@tajamar365.com
|
74eeb223d65cf7cbcc025bb5016217fe75f225a6
|
3de0296164a969abbb1f066e04a194360c9e1c5c
|
/src/main/java/org/jocean/j2se/unit/LocalRef.java
|
c29f596b919f77e0454751d459590b9173082157
|
[] |
no_license
|
isdom/jocean-j2se
|
5c7b55e41b45b2ae78caf50f08c8c57aaf3a01ce
|
bbacc5640ab5d9848f3956a0664bb767c02433b6
|
refs/heads/master
| 2023-09-06T04:30:50.829888
| 2023-08-20T13:19:21
| 2023-08-20T13:19:21
| 18,402,550
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,338
|
java
|
package org.jocean.j2se.unit;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.springframework.core.io.Resource;
import com.google.common.collect.Maps;
public class LocalRef implements UnitKeeperAware {
public void setLocation(final Resource location) {
this._location = location;
}
public void stop() {
if (null != this._unitKeeper) {
this._unitKeeper.deleteUnit("#");
}
}
private static String[] genSourceFrom(final Properties properties) {
final String value = properties.getProperty(SPRING_XML_KEY);
properties.remove(SPRING_XML_KEY);
return null!=value ? value.split(",") : null;
}
@Override
public void setUnitKeeper(final UnitKeeper keeper) {
this._unitKeeper = keeper;
try (final InputStream is = this._location.getInputStream()) {
final Properties props = new Properties();
props.load(is);
final String[] source = genSourceFrom(props);
this._unitKeeper.createOrUpdateUnit("#", source, Maps.fromProperties(props));
} catch (IOException e) {
}
}
private Resource _location;
private UnitKeeper _unitKeeper;
private static final String SPRING_XML_KEY = "__spring.xml";
}
|
[
"isdom.maming@gmail.com"
] |
isdom.maming@gmail.com
|
1f0314607e12547d52c36617d4caa441a772dbd1
|
659b32148d42b244538bc85097670b09c2fe558e
|
/UserProfileShopping/app/src/main/java/com/shopping/lifeplay/activity/ProductDetailActivity.java
|
0c352121ccbef875bf5b2ebc719c035f76e2ef76
|
[] |
no_license
|
OmarAmit/Project_Shopping
|
39ea7fd1f815b9b03e8751adea7681c119641958
|
8e667c70d4bca79be2fb4860d63ea22d9a14649f
|
refs/heads/master
| 2020-03-22T04:15:52.613636
| 2018-07-02T19:33:43
| 2018-07-02T19:33:43
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 17,011
|
java
|
package com.shopping.lifeplay.activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.bumptech.glide.Glide;
import com.user.userprofileshopping.R;
import com.shopping.lifeplay.model.Cart;
import com.shopping.lifeplay.model.WishList;
import com.shopping.lifeplay.utils.BagdeDrawable;
import com.shopping.lifeplay.utils.MyProgressDialog;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.util.HashMap;
import java.util.Map;
import static com.shopping.lifeplay.activity.HomeActivity.itemofcart;
public class ProductDetailActivity extends AppCompatActivity {
private EditText devivery_Edittext;
private TextView delivery_button, cod_available, delivery_days;
private ImageView image1;
private TextView p_price;
private TextView p_name;
private String pincode;
// private String pro_name;
// private String pro_price;
// private String pro_image;
private Cart cart;
private ImageView wishlistIcon;
private WishList wishList;
private int pro_id;
private int key = 0;
// private String s_product_disc, s_product_how_to_apply, s_product_uses;
private TextView product_disc, product_uses, product_how_to_apply;
private static String cartUrl = "http://192.168.1.10/admin_parilok/users/cart.php";
private TextView addToCart;
private String product_detail_name;
private String product_cat_name;
private String product_price;
private String product_cut_price;
private String product_detail_disc;
private String product_detail_uses;
private String product_detail_how_to_apply;
private String product_detail_image;
private String imageUrl = "http://littlejoy.co.in/admin_parilok/api/";
private int product_detail_id;
private String detailUrl = "http://littlejoy.co.in/admin_parilok/users/product.php";
private String cart_status;
private String pinCode_url = "http://192.168.1.10/admin_parilok/users/pincode.php";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product_detail);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getId();
getdatafromIntent();
Toast.makeText(this, pro_id + "", Toast.LENGTH_LONG).show();
product_DetailApi();
devivery_Edittext.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
pincode = s + "";
if (pincode.equals("")) {
delivery_button.setText("");
cod_available.setText("");
delivery_days.setText("");
}
if (pincode.length() != 6) {
delivery_button.setText("");
cod_available.setText("");
delivery_days.setText("");
} else {
delivery_button.setText("Check");
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
delivery_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (delivery_button.getText().equals("Check")) {
pinCodeApiCall();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.cart, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// Get the notifications MenuItem and
// its LayerDrawable (layer-list)
MenuItem itemCart = menu.findItem(R.id.action_cart);
LayerDrawable icon = (LayerDrawable) itemCart.getIcon();
setBadgeCount(this, icon, itemofcart + ""); // force the ActionBar to relayout its MenuItems.
// onCreateOptionsMenu(Menu) will be called again.
invalidateOptionsMenu();
return super.onPrepareOptionsMenu(menu);
}
public static void setBadgeCount(Context context, LayerDrawable icon, String count) {
BagdeDrawable badge;
// Reuse drawable if possible
Drawable reuse = icon.findDrawableByLayerId(R.id.ic_badge);
if (reuse != null && reuse instanceof BagdeDrawable) {
badge = (BagdeDrawable) reuse;
} else {
badge = new BagdeDrawable(context);
}
badge.setCount(count);
icon.mutate();
icon.setDrawableByLayerId(R.id.ic_badge, badge);
}
private void getdatafromIntent() {
if (getIntent() != null) {
pro_id = Integer.parseInt(getIntent().getStringExtra("p_id"));
}
}
private void getId() {
devivery_Edittext = (EditText) findViewById(R.id.devivery_Edittext);
delivery_button = (TextView) findViewById(R.id.delivery_button);
cod_available = (TextView) findViewById(R.id.cod_available);
delivery_days = (TextView) findViewById(R.id.delivery_days);
image1 = (ImageView) findViewById(R.id.image1);
p_name = (TextView) findViewById(R.id.p_name);
p_price = (TextView) findViewById(R.id.p_price);
wishlistIcon = (ImageView) findViewById(R.id.wishlistIcon);
product_disc = (TextView) findViewById(R.id.product_disc);
product_uses = (TextView) findViewById(R.id.product_uses);
product_how_to_apply = (TextView) findViewById(R.id.product_how_to_apply);
addToCart = (TextView) findViewById(R.id.addToCart);
}
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_cart) {
Intent intent = new Intent(ProductDetailActivity.this, CartActivity.class);
startActivity(intent);
} else {
finish();
}
return super.onOptionsItemSelected(item);
}
private void product_DetailApi() {
MyProgressDialog.showPDialog(this);
RequestQueue queue = Volley.newRequestQueue(this);
String response = null;
final String finalResponse = response;
StringRequest postRequest = new StringRequest(Request.Method.POST, detailUrl,
new com.android.volley.Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("amit", response);
try {
Object json = new JSONTokener(response).nextValue();
JSONObject jsonObject = (JSONObject) json;
JSONArray jsonArray = jsonObject.getJSONArray("data");
Log.d("jsonObject", jsonObject + "");
Log.d("jsonArray", jsonArray + "");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject profile = jsonArray.getJSONObject(i);
product_detail_name = profile.getString("pr_name");
product_price = profile.getString("pr_price");
product_cut_price = profile.getString("pr_sp");
product_detail_disc = profile.getString("pr_desc");
product_detail_uses = profile.getString("uses");
product_detail_how_to_apply = profile.getString("how_to_apply");
product_detail_image = profile.getString("image");
product_detail_image = imageUrl + product_detail_image;
product_detail_id = Integer.parseInt(profile.getString("product_id"));
cart_status = profile.getString("user_id");
if (product_detail_id == pro_id) {
product_disc.setText(product_detail_disc);
product_uses.setText(product_detail_uses);
product_how_to_apply.setText(product_detail_how_to_apply);
Glide.with(ProductDetailActivity.this).load(product_detail_image).into(image1);
p_name.setText(product_detail_name);
p_price.setText("Rs. " + product_price);
if (cart_status.equals("6")) {
addToCart.setText("GO TO CART");
Toast.makeText(ProductDetailActivity.this, "GO TO CART", Toast.LENGTH_LONG).show();
} else {
addToCart.setText("ADD TO CART");
}
break;
}
}
MyProgressDialog.hidePDialog();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new com.android.volley.Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(ProductDetailActivity.this, "Network Error", Toast.LENGTH_LONG).show();
MyProgressDialog.hidePDialog();
}
}
) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("user_id", "6");
return params;
}
};
postRequest.setRetryPolicy(new DefaultRetryPolicy(0, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
queue.add(postRequest);
}
private void addtocartApiCall() {
RequestQueue queue = Volley.newRequestQueue(this);
String response = null;
final String finalResponse = response;
StringRequest postRequest = new StringRequest(Request.Method.POST, cartUrl,
new com.android.volley.Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("amit", response);
try {
Object json = new JSONTokener(response).nextValue();
JSONObject jsonObject = (JSONObject) json;
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new com.android.volley.Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(ProductDetailActivity.this, "Network Error", Toast.LENGTH_LONG).show();
}
}
) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("user_id", "6");
params.put("product_id", pro_id + "");
return params;
}
};
postRequest.setRetryPolicy(new DefaultRetryPolicy(0, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
queue.add(postRequest);
}
private void pinCodeApiCall() {
RequestQueue queue = Volley.newRequestQueue(this);
String response = null;
final String finalResponse = response;
StringRequest postRequest = new StringRequest(Request.Method.POST, pinCode_url,
new com.android.volley.Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("amit", response);
try {
Object json = new JSONTokener(response).nextValue();
JSONObject jsonObject = (JSONObject) json;
Toast.makeText(ProductDetailActivity.this, jsonObject.getString("data"), Toast.LENGTH_LONG).show();
if (jsonObject.getString("status").equals("1")) {
cod_available.setText("Delivery Available");
delivery_days.setText("Delivery in 4-5 days");
} else {
cod_available.setText("COD Not Available");
delivery_days.setText("");
}
MyProgressDialog.hidePDialog();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new com.android.volley.Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(ProductDetailActivity.this, "Network Error", Toast.LENGTH_LONG).show();
MyProgressDialog.hidePDialog();
}
}
)
{
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("pincode", pincode);
return params;
}
};
postRequest.setRetryPolicy(new
DefaultRetryPolicy(0, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
queue.add(postRequest);
}
public void addtoCart(View view) {
/*******************Code for RecyclerView****************/
// Toast.makeText(this, "Add to Cart", Toast.LENGTH_LONG).show();
//
// for (Cart cart : cartList) {
//
// if (cart.getProduct_id() == pro_id) {
// key = 1;
// cart.setProduct_quantity(cart.getProduct_quantity() + 1);
// cart.setProduct_price(cart.getProduct_price() + Integer.parseInt(pro_price));
// break;
// }
// }
// if (key == 0) {
// cart = new Cart("Face & beuty", pro_name, pro_id, pro_image, Integer.parseInt(pro_price), 1);
// cartList.add(cart);
// itemofcart++;
// }
// key = 0;
if (addToCart.getText().equals("ADD TO CART")) {
addToCart.setText("GO TO CART");
addtocartApiCall();
} else if (addToCart.getText().equals("GO TO CART")) {
startActivity(new Intent(this, CartActivity.class));
}
}
public void buynow(View view) {
// for (Cart cart : cartList) {
// if (cart.getProduct_id() == pro_id) {
// key = 1;
// startActivity(new Intent(this, CartActivity.class));
// break;
// }
// }
//
// if (key == 0) {
// cart = new Cart("Face & beuty", pro_name, pro_id, pro_image, Integer.parseInt(pro_price), 1);
// cartList.add(cart);
// itemofcart++;
addtocartApiCall();
startActivity(new Intent(this, CartActivity.class));
// }
// key = 0;
}
// public void detailaddtoCart(View view) {
// wishList = new WishList("Face & beuty", pro_name, 1, pro_image, pro_price);
// wishListList.add(wishList);
// Glide.with(this).load(R.drawable.ic_favorite_black_18dp).into(wishlistIcon);
// }
}
|
[
"40773012+AmitOmar56@users.noreply.github.com"
] |
40773012+AmitOmar56@users.noreply.github.com
|
f6b3141a9ce7c48a767ba0263d5cc44278b54b76
|
1a512c1c818823c44b8efb19009e14bf950dde05
|
/project/psychologicalprj/WebContent/src/com/Consultation/appointmentconsult/controller/PaymentResultResponseController.java
|
ad889f85938b4027552a4140677e31cf877c705b
|
[] |
no_license
|
bao9777/Software
|
0af426f09a5ba7e42c2cff86f69ff55996f0c6a2
|
b7d12e3074667aab02b6327e8feefe2b2d343e50
|
refs/heads/master
| 2020-04-01T04:13:44.778795
| 2019-01-04T12:35:45
| 2019-01-04T12:44:56
| 152,854,885
| 0
| 3
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,109
|
java
|
package com.Consultation.appointmentconsult.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.util.ConfigInfo;
import com.util.PaymentUtil;
/**
*
* @desc:支付成功之后的响应,返回给商户一些数据
* @author chunhui
* @date:Nov 26, 201812:57:13 PM
*/
@Controller
public class PaymentResultResponseController {
/**
*
* @desc:一句话描述
* @param request
* @param hmac
* @param sCmd
* 业务类型
* @param sResultCode支付结果
* @param sTrxId
* 第三方支付交易流水号
* @param amount
* 交易金额
* @param currency
* 交易币种
* @param productId
* 商品名称
* @param orderId
* 商品订单号
* @param userId
* 第三方支付会员id
* @param mp
* 商户扩展信息
* @param bType
* 交易结果返回类型
* @param rb_BankId
* 交易的银行编码
* @param rp_PayDate
* 交易时间
* @return
* @return:String
* @trhows
*/
@RequestMapping("/PaymentResultResponseServlet")
public String getResponse(HttpServletRequest request, @RequestParam(value = "hmac", required = false) String hmac,
@RequestParam(value = "r0_Cmd", required = false) String sCmd,
@RequestParam(value = "r1_Code", required = false) String sResultCode,
@RequestParam(value = "r2_TrxId", required = false) String sTrxId,
@RequestParam(value = "r3_Amt", required = false) String amount,
@RequestParam(value = "r4_Cur", required = false) String currency,
@RequestParam(value = "r5_Pid", required = false) String productId,
@RequestParam(value = "r6_Order", required = false) String orderId,
@RequestParam(value = "r7_Uid", required = false) String userId,
@RequestParam(value = "r8_MP", required = false) String mp,
@RequestParam(value = "r9_BType", required = false) String bType,
@RequestParam(value = "rb_BankId", required = false) String rb_BankId,
@RequestParam(value = "rp_PayDate", required = false) String rp_PayDate) {
String merchantID = ConfigInfo.getValue("p1_MerId");
String keyValue = ConfigInfo.getValue("keyValue");
boolean result = PaymentUtil.verifyCallback(hmac, merchantID, sCmd, sResultCode, sTrxId, amount, currency,
productId, orderId, userId, mp, bType, keyValue);
if (result) {
if ("1".equals(sResultCode)) {
// 数据库中的订单的支付状态设成 已支付(考虑用户多次刷新多次更新数据库的问题)
String message = "订单号为" + orderId + "的订单支付成功!";
message += "用户支付了" + amount + "元";
message += "易宝订单流水号为" + sTrxId;
request.setAttribute("message", message);
} else {
request.setAttribute("message", "支付失败");
}
} else {
request.setAttribute("message", "数据被修改,出现错误");
}
return "showpayresult";
}
}
|
[
"977702305@qq.com"
] |
977702305@qq.com
|
2bb2c808a819bfc1e4dc89067df3e0b6514ccc9d
|
f5714a50527d53f288a52983eba0131ac43089f7
|
/UpdateForm.java
|
d6863c30641acd25e7e1515869f8caf72cf11b92
|
[] |
no_license
|
Allrightbrian/AccountBook_JAVA
|
7e41297d0c2748e494bd1f1b8c3ee6403c014b5e
|
6fe77b3bc45e448bb1053d436a3988ecfb0cd0a3
|
refs/heads/main
| 2023-08-21T21:57:43.518759
| 2021-09-22T17:55:42
| 2021-09-22T17:55:42
| null | 0
| 0
| null | null | null | null |
UHC
|
Java
| false
| false
| 2,863
|
java
|
package Prac;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class UpdateForm extends JFrame {
Container cp;
JComboBox<String> cbCate;
JTextField tfContent;
JTextField tfIncome;
JTextField tfDate;
/*JTextField tfYongIncome;
JTextField tfGeupIncome;
JTextField tfGeumIncome;
JTextField tfSaIncome;
JTextField tfGiIncome;*/
JButton btnMod;
JLabel lblWarn;
ImageIcon img;
String num;
public UpdateForm(String title) {
super(title);
cp = this.getContentPane();
this.setBounds(400,250,300,500);
cp.setBackground(new Color(255, 250, 140));
//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.initDesign();
//this.setVisible(true);
}
public void initDesign() {
this.setLayout(null);
JLabel title1 = new JLabel("카테고리");
JLabel title2 = new JLabel("내용");
JLabel title3 = new JLabel("수입");
JLabel title4 = new JLabel("날짜");
lblWarn = new JLabel();
tfContent = new JTextField(20);
tfIncome = new JTextField(10);
tfDate = new JTextField(10);
tfDate.setText(" / ");
String []Category = {"용돈","급여","금융수입","사업수입","기타수입"};
cbCate = new JComboBox<String>(Category);
btnMod = new JButton("데이터 수정");
title1.setBounds(30,30,60,20);
this.add(title1);
cbCate.setBounds(90,30, 170, 20);
this.add(cbCate);
title2.setBounds(55,80,60,20);
this.add(title2);
tfContent.setBounds(90,80,170,20);
this.add(tfContent);
/*cbCate.setBounds(60, 80, 170, 20);
this.add(cbCate);*/
title3.setBounds(55,130,60,20);
this.add(title3);
tfIncome.setBounds(90, 130, 170, 20);
this.add(tfIncome);
title4.setBounds(55,180,60,20);
this.add(title4);
tfDate.setBounds(90, 180, 170, 20);
this.add(tfDate);
/*tfJava.setBounds(60, 130, 170, 20);
this.add(tfJava);
title4.setBounds(30,180,60,20);
this.add(title4);
tfJsp.setBounds(60, 180, 170, 20);
this.add(tfJsp);
title5.setBounds(20,230,60,20);
this.add(title5);
tfSpring.setBounds(60, 230, 170, 20);
this.add(tfSpring);*/
btnMod.setBounds(50, 230, 170, 20);
this.add("Center",btnMod);
img = new ImageIcon("C:\\Users\\zippp\\Desktop\\Summer_PracticalEdu\\swingimage\\제목 없음-5.png");
JLabel imgBox = new JLabel(img);
imgBox.setBounds(0, 0, 300, 500);
cp.add(imgBox);
}
/*public static void main(String[] args) {
new incomeFrame("수입표");
}*/
}
|
[
"noreply@github.com"
] |
noreply@github.com
|
6f7cbf54c794c64ebc96de6ebfc7eeccfb9a3f7e
|
3ac9f9a3a41e2a15fad6516a0858e89a835b0ee7
|
/av1/src/anacarolina/dao/AlunoDAO.java
|
cb726381ba8880ab39289cc39459d2ac47798df6
|
[] |
no_license
|
marciojrtorres/bd-2016
|
19f16fc59e08a22b8ee180bb02106dceab846b5c
|
9a8c9af3b479166997a0556ccd3fd9c23408d0ac
|
refs/heads/master
| 2020-04-12T06:33:03.370735
| 2016-11-01T17:56:56
| 2016-11-01T17:56:56
| 65,318,518
| 0
| 2
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 5,972
|
java
|
package anacarolina.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import anacarolina.Database;
import anacarolina.model.Aluno;
import anacarolina.model.Curso;
public class AlunoDAO {
private static final int LIMIT = 2;
private Database db = new Database();
public void insert(Aluno a){
try (Connection con = db.getConnection() ) {
String sql = "INSERT INTO alunos"
+ "(matricula, nome, sobrenome, data_inicio, id_curso) VALUES"
+ " (?, ?, ?, ?, ?);";
PreparedStatement cmd = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
cmd.setString(1, a.getMatricula());
cmd.setString(2, a.getNome());
cmd.setString(3, a.getSobrenome());
cmd.setDate(4, a.getData_inicio());
cmd.setInt(5, a.getId_curso());
cmd.executeUpdate();
ResultSet key = cmd.getGeneratedKeys();
if(key.next()){
a.setId_aluno(key.getInt(1));
}
} catch (Exception e){
throw new RuntimeException(e);
}
}
public void delete(int id_aluno){
try (Connection con = db.getConnection() ) {
String sql = "DELETE FROM alunos WHERE id_aluno = ?";
PreparedStatement cmd = con.prepareStatement(sql);
cmd.setInt(1, id_aluno);
cmd.execute();
} catch (Exception e){
throw new RuntimeException(e);
}
}
public Aluno select(int id_aluno) {
try (Connection con = db.getConnection() ) {
String sql = "SELECT matricula, nome, sobrenome, data_inicio, id_curso "
+ "FROM alunos WHERE id_aluno = ?";
PreparedStatement cmd = con.prepareStatement(sql);
cmd.setInt(1, id_aluno);
ResultSet rs = cmd.executeQuery();
if(rs.next()){
Aluno aluno = new Aluno();
aluno.setId_aluno(id_aluno);
aluno.setMatricula(rs.getString("matricula"));
aluno.setNome(rs.getString("nome"));
aluno.setSobrenome(rs.getString("sobrenome"));
aluno.setData_inicio(rs.getDate("data_inicio"));
aluno.setId_curso(rs.getInt("id_curso"));
return aluno;
}
return null;
} catch (Exception e){
throw new RuntimeException(e);
}
}
public void update(Aluno aluno){
if (aluno.getId_aluno() == null) {
throw new RuntimeException("O id eh nulo, nao pode atualizar");
}
try (Connection con = db.getConnection()) {
String sql = "UPDATE alunos "
+ "SET matricula = ?, nome = ?, sobrenome = ?, data_inicio = ?, id_curso = ? "
+ "WHERE id_aluno = ?";
PreparedStatement cmd =
con.prepareStatement(sql);
cmd.setString(1, aluno.getMatricula());
cmd.setString(2, aluno.getNome());
cmd.setString(3, aluno.getSobrenome());
cmd.setDate(4, aluno.getData_inicio());
cmd.setInt(5, aluno.getId_curso());
cmd.setInt(6, aluno.getId_aluno());
cmd.execute();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public List<Aluno> selectPage(int pagina) {
try (Connection con = db.getConnection() ) {
String sql = "SELECT id_aluno, matricula, nome, sobrenome, data_inicio, id_curso "
+ "FROM alunos "
+ "ORDER BY nome DESC "
+ "OFFSET ? "
+ "LIMIT " + LIMIT;
PreparedStatement cmd =
con.prepareStatement(sql);
// 1 - 1 = 0 * 2 = 0
// 2 - 1 = 1 * 2 = 2
// 3 - 1 = 2 * 2 = 4
int offset = (pagina - 1) * LIMIT;
cmd.setInt(1, offset);
ResultSet rs = cmd.executeQuery();
List<Aluno> alunos = new ArrayList();
while(rs.next()){
Aluno aluno = new Aluno();
aluno.setId_aluno(rs.getInt("id_aluno"));
aluno.setMatricula(rs.getString("matricula"));
aluno.setNome(rs.getString("nome"));
aluno.setSobrenome(rs.getString("sobrenome"));
aluno.setData_inicio(rs.getDate("data_inicio"));
aluno.setId_curso(rs.getInt("id_curso"));
alunos.add(aluno);
}
return alunos;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public List<Aluno> selectAll(){
try (Connection con = db.getConnection() ) {
String sql = "SELECT id_aluno, matricula, nome, sobrenome, data_inicio, id_curso "
+ "FROM alunos "
+ "ORDER BY nome DESC ";
PreparedStatement cmd =
con.prepareStatement(sql);
ResultSet rs = cmd.executeQuery();
List<Aluno> alunos = new ArrayList();
while(rs.next()){
Aluno aluno = new Aluno();
aluno.setId_aluno(rs.getInt("id_aluno"));
aluno.setMatricula(rs.getString("matricula"));
aluno.setNome(rs.getString("nome"));
aluno.setSobrenome(rs.getString("sobrenome"));
aluno.setData_inicio(rs.getDate("data_inicio"));
aluno.setId_curso(rs.getInt("id_curso"));
alunos.add(aluno);
}
return alunos;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public List<Aluno> selectById_curso(int id_curso){
try (Connection con = db.getConnection() ) {
String sql = "SELECT id_aluno, matricula, nome, sobrenome, data_inicio, id_curso "
+ "FROM alunos "
+ "WHERE id_curso = ? "
+ "ORDER BY nome DESC ";
PreparedStatement cmd =
con.prepareStatement(sql);
cmd.setInt(1, id_curso);
ResultSet rs = cmd.executeQuery();
List<Aluno> alunos = new ArrayList();
while(rs.next()){
Aluno aluno = new Aluno();
aluno.setId_aluno(rs.getInt("id_aluno"));
aluno.setMatricula(rs.getString("matricula"));
aluno.setNome(rs.getString("nome"));
aluno.setSobrenome(rs.getString("sobrenome"));
aluno.setData_inicio(rs.getDate("data_inicio"));
aluno.setId_curso(rs.getInt("id_curso"));
alunos.add(aluno);
}
return alunos;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
|
[
"marciojrtorres@gmail.com"
] |
marciojrtorres@gmail.com
|
dbf4422eccf896b1b3d9a3c22fa4c46bd9f98e7c
|
4b73424fc66127e140bafbd3687e178e4b0544c9
|
/src/main/java/com/example/multiplehikaridatasourcedemo/configuration/BarConfig.java
|
0ab83d7f361b63c845ad3f06773b3487f7ca263b
|
[] |
no_license
|
keybrade/multiple-hikari-datasource-example
|
613fb1c2d170241fdf6b438f900cda60c4a6ea03
|
799eb577639433b7495bce7da2f8d4252b2ee0e9
|
refs/heads/master
| 2022-07-20T02:12:09.453826
| 2020-05-26T01:22:26
| 2020-05-26T01:22:26
| 266,915,448
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,690
|
java
|
package com.example.multiplehikaridatasourcedemo.configuration;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Slf4j
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(entityManagerFactoryRef = "barFactory", transactionManagerRef = "barManager",
basePackages = "com.example.multiplehikaridatasourcedemo.repository.bar")
public class BarConfig {
public final static String PERSISTENCE_UNIT_NAME = "bar";
@Bean
@ConfigurationProperties("spring.datasource.bar")
public DataSource barDs() {
return DataSourceBuilder.create().build();
}
@Bean
@ConfigurationProperties("spring.datasource.bar.jpa")
public JpaProperties barJpaProperties() {
return new JpaProperties();
}
@Bean
@ConfigurationProperties(prefix = "spring.datasource.bar.jpa.hibernate")
public HibernateProperties barHibernateProperties() {
return new HibernateProperties();
}
@Bean
public LocalContainerEntityManagerFactoryBean barFactory(EntityManagerFactoryBuilder builder) {
return builder.dataSource(barDs())
.packages("com.example.multiplehikaridatasourcedemo.entity.bar")
.persistenceUnit(PERSISTENCE_UNIT_NAME)
.properties(barJpaProperties().getProperties())
.properties(barHibernateProperties().determineHibernateProperties(barJpaProperties().getProperties(),
new HibernateSettings()))
.build();
}
@Bean
public PlatformTransactionManager barManager(@Qualifier("barFactory") EntityManagerFactory barFactory) {
return new JpaTransactionManager(barFactory);
}
}
|
[
"kang.xin@yoomigroup.com"
] |
kang.xin@yoomigroup.com
|
ae3b533410f949ae9e2fbc7061e8467b7091d7a4
|
c2479f6fd7f55b3cc34acd3cfdb0dddfce2425ac
|
/PetShelter.java
|
9e067a1dc33a83aab7774d17847f32dacc04e980
|
[] |
no_license
|
BenJammen1986/java
|
471e42857656c850eb6fef4e47701c21066b399f
|
2fbe7eb22044f7a74bbc35578cd7aa0d848e4e9a
|
refs/heads/master
| 2020-05-26T02:05:31.789758
| 2017-03-15T14:49:27
| 2017-03-15T14:49:27
| 84,984,955
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,122
|
java
|
import java.io.Console;
public class PetShelter {
public static void main(String[] args){
Console myConsole = System.console();
Animal shelby = new Animal();
shelby.mName = "Shelby";
shelby.mAge = 2;
shelby.mSpecies = "feline";
shelby.mBreed = "lynx";
Animal bert = new Animal();
bert.mName = "Bert";
bert.mAge = 5;
bert.mSpecies = "canine";
bert.mBreed = "Dalmatian";
Animal jim = new Animal();
jim.mName = "Jim";
jim.mAge = 49;
jim.mSpecies = "rodent";
jim.mBreed = "guinea pig";
Animal rupert = new Animal();
rupert.mName = "Rupert";
rupert.mAge = 108;
rupert.mSpecies = "tortoise";
rupert.mBreed = "old";
Animal[] allAnimals = {shelby,bert,jim,rupert};
for ( Animal eachAnimal : allAnimals ) {
System.out.println("--------------------");
System.out.println("Name: " + eachAnimal.mName);
System.out.println("Age: " + eachAnimal.mAge);
System.out.println("Species: " + eachAnimal.mSpecies);
System.out.println("Breed: " + eachAnimal.mBreed);
}
}
}
|
[
"benschenkenberger@gmail.com"
] |
benschenkenberger@gmail.com
|
3c513e82da67705f7f8dfff8c01125a694d53e49
|
29b3d9c2cc5d7fb9bdd82dd41f0ce3bdc167ad10
|
/chassis-support/src/test/java/com/kixeye/chassis/chassis/test/hystrix/ChassisHystrixTest.java
|
77ac9a0cf4f792e780a97d848ebd21b41017e02e
|
[
"Apache-2.0"
] |
permissive
|
leusonmario/chassis
|
256dc7f7b296825e52f5a1e7c92ff82371ab9901
|
0b41de8e79a9abfc5c029b206f55370269c92052
|
refs/heads/master
| 2021-09-20T12:16:00.989668
| 2014-07-07T22:32:34
| 2014-07-07T22:32:34
| 109,864,550
| 0
| 0
| null | 2017-11-07T16:52:32
| 2017-11-07T16:52:24
|
Java
|
UTF-8
|
Java
| false
| false
| 5,966
|
java
|
package com.kixeye.chassis.chassis.test.hystrix;
/*
* #%L
* Chassis Support
* %%
* Copyright (C) 2014 KIXEYE, Inc
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import rx.Observable;
import rx.Observer;
import com.kixeye.chassis.chassis.ChassisConfiguration;
import com.netflix.config.ConfigurationManager;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.HystrixThreadPoolKey;
import com.netflix.hystrix.exception.HystrixRuntimeException;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ChassisHystrixTestConfiguration.class, ChassisConfiguration.class})
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class ChassisHystrixTest {
private final HystrixCommandGroupKey hxGroupKey= HystrixCommandGroupKey.Factory.asKey("TestGroup");
private final HystrixCommandKey hxTestCommandKey= HystrixCommandKey.Factory.asKey("TestCommand");
private final HystrixCommandKey hxTestTimeoutCommandKey= HystrixCommandKey.Factory.asKey("TestTimeoutCommand");
private final HystrixThreadPoolKey hxTestThreadPoolKey = HystrixThreadPoolKey.Factory.asKey("TestThreadPool");
private final String resultString = "done!!";
@Test
public void testBasicHystrixCommand() throws Exception {
final AtomicBoolean done = new AtomicBoolean(false);
final AtomicReference<String> result = new AtomicReference<>(null);
// kick off async command
Observable<String> observable = new TestCommand().observe();
// Sleep to test what happens if command finishes before subscription
Thread.sleep(2000);
// Add handler
observable.subscribe( new Observer<String>() {
@Override
public void onCompleted() {
done.set(true);
}
@Override
public void onError(Throwable e) {
result.set("error!!");
done.set(true);
}
@Override
public void onNext(String args) {
result.set(args);
done.set(true);
}
});
// spin until done
while (!done.get()) {
Thread.sleep(100);
}
Assert.assertEquals(resultString, result.get());
}
@Test
@SuppressWarnings("unused")
public void testCommandTimeOut() throws InterruptedException {
final AtomicBoolean done = new AtomicBoolean(false);
// kick off async command
Observable<String> observable = new TestTimeOutCommand().observe();
// Add handler
observable.subscribe( new Observer<String>() {
@Override
public void onCompleted() {
Assert.assertNull("Should not complete");
done.set(true);
}
@Override
public void onError(Throwable e) {
done.set(true);
}
@Override
public void onNext(String args) {
Assert.assertNull("Should not get a result");
done.set(true);
}
});
// spin until done
while (!done.get()) {
Thread.sleep(100);
}
}
@Test
public void testCircuitBreaker() {
ConfigurationManager.getConfigInstance().setProperty("hystrix.command.TestCommand.circuitBreaker.forceOpen", true);
boolean gotException = false;
try {
TestCommand cmd = new TestCommand();
cmd.execute();
} catch (HystrixRuntimeException ex) {
gotException = true;
} finally {
ConfigurationManager.getConfigInstance().setProperty("hystrix.command.TestCommand.circuitBreaker.forceOpen", false);
}
Assert.assertTrue(gotException);
}
private class TestCommand extends HystrixCommand<String> {
public TestCommand() {
super(Setter
.withGroupKey(hxGroupKey)
.andThreadPoolKey(hxTestThreadPoolKey)
.andCommandKey(hxTestCommandKey) );
}
@Override
protected String run() {
try {
Thread.sleep(1010);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
return resultString;
}
}
private class TestTimeOutCommand extends HystrixCommand<String> {
public TestTimeOutCommand() {
super(Setter
.withGroupKey(hxGroupKey)
.andThreadPoolKey(hxTestThreadPoolKey)
.andCommandKey(hxTestTimeoutCommandKey) );
}
@Override
protected String run() {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
return resultString;
}
}
}
|
[
"dturner@kixeye.com"
] |
dturner@kixeye.com
|
131ce83f1b7d500277684034d6632b35c62d8a5a
|
947e71b34d21f3c9f5c0a197d91a880f346afa6c
|
/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/metrics/MetricsManager.java
|
f5bc0eb618902b25878b4f6a2cf60630671163df
|
[
"MIT",
"Apache-2.0",
"GPL-1.0-or-later",
"GPL-2.0-or-later",
"OFL-1.1",
"MS-PL",
"AFL-2.1",
"GPL-2.0-only",
"Python-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown"
] |
permissive
|
liuwenru/Apache-Ambari-ZH
|
4bc432d4ea7087bb353a6dd97ffda0a85cb0fef0
|
7879810067f1981209b658ceb675ac76e951b07b
|
refs/heads/master
| 2023-01-14T14:43:06.639598
| 2020-07-28T12:06:25
| 2020-07-28T12:06:25
| 223,551,095
| 38
| 44
|
Apache-2.0
| 2023-01-02T21:55:10
| 2019-11-23T07:43:49
|
Java
|
UTF-8
|
Java
| false
| false
| 6,316
|
java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.ambari.logfeeder.metrics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.TreeMap;
import org.apache.ambari.logfeeder.conf.LogFeederSecurityConfig;
import org.apache.ambari.logfeeder.conf.MetricsCollectorConfig;
import org.apache.ambari.logfeeder.plugin.common.MetricData;
import org.apache.ambari.logfeeder.util.LogFeederUtil;
import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric;
import org.apache.hadoop.metrics2.sink.timeline.TimelineMetrics;
import org.apache.log4j.Logger;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
public class MetricsManager {
private static final Logger LOG = Logger.getLogger(MetricsManager.class);
private boolean isMetricsEnabled = false;
private String appId = "logfeeder";
private long lastPublishTimeMS = 0; // Let's do the first publish immediately
private long lastFailedPublishTimeMS = System.currentTimeMillis(); // Reset the clock
private int publishIntervalMS = 60 * 1000;
private int maxMetricsBuffer = 60 * 60 * 1000; // If AMS is down, we should not keep the metrics in memory forever
private HashMap<String, TimelineMetric> metricsMap = new HashMap<>();
private LogFeederAMSClient amsClient = null;
@Inject
private MetricsCollectorConfig metricsCollectorConfig;
@Inject
private LogFeederSecurityConfig logFeederSecurityConfig;
@PostConstruct
public void init() {
LOG.info("Initializing MetricsManager()");
if (amsClient == null) {
amsClient = new LogFeederAMSClient(metricsCollectorConfig, logFeederSecurityConfig);
}
if (amsClient.getCollectorUri(null) != null) {
if (LogFeederUtil.hostName == null) {
isMetricsEnabled = false;
LOG.error("Failed getting hostname for node. Disabling publishing LogFeeder metrics");
} else {
isMetricsEnabled = true;
LOG.info("LogFeeder Metrics is enabled. Metrics host=" + amsClient.getCollectorUri(null));
}
} else {
LOG.info("LogFeeder Metrics publish is disabled");
}
}
public boolean isMetricsEnabled() {
return isMetricsEnabled;
}
public synchronized void useMetrics(List<MetricData> metricsList) {
if (!isMetricsEnabled) {
return;
}
LOG.info("useMetrics() metrics.size=" + metricsList.size());
long currMS = System.currentTimeMillis();
gatherMetrics(metricsList, currMS);
publishMetrics(currMS);
}
private void gatherMetrics(List<MetricData> metricsList, long currMS) {
Long currMSLong = new Long(currMS);
for (MetricData metric : metricsList) {
if (metric.metricsName == null) {
LOG.debug("metric.metricsName is null");
continue;
}
long currCount = metric.value;
if (!metric.isPointInTime && metric.publishCount > 0 && currCount <= metric.prevPublishValue) {
LOG.debug("Nothing changed. " + metric.metricsName + ", currCount=" + currCount + ", prevPublishCount=" +
metric.prevPublishValue);
continue;
}
metric.publishCount++;
LOG.debug("Ensuring metrics=" + metric.metricsName);
TimelineMetric timelineMetric = metricsMap.get(metric.metricsName);
if (timelineMetric == null) {
LOG.debug("Creating new metric obbject for " + metric.metricsName);
timelineMetric = new TimelineMetric();
timelineMetric.setMetricName(metric.metricsName);
timelineMetric.setHostName(LogFeederUtil.hostName);
timelineMetric.setAppId(appId);
timelineMetric.setStartTime(currMS);
timelineMetric.setType("Long");
timelineMetric.setMetricValues(new TreeMap<Long, Double>());
metricsMap.put(metric.metricsName, timelineMetric);
}
LOG.debug("Adding metrics=" + metric.metricsName);
if (metric.isPointInTime) {
timelineMetric.getMetricValues().put(currMSLong, new Double(currCount));
} else {
Double value = timelineMetric.getMetricValues().get(currMSLong);
if (value == null) {
value = new Double(0);
}
value += (currCount - metric.prevPublishValue);
timelineMetric.getMetricValues().put(currMSLong, value);
metric.prevPublishValue = currCount;
}
}
}
private void publishMetrics(long currMS) {
if (!metricsMap.isEmpty() && currMS - lastPublishTimeMS > publishIntervalMS) {
try {
TimelineMetrics timelineMetrics = new TimelineMetrics();
timelineMetrics.setMetrics(new ArrayList<TimelineMetric>(metricsMap.values()));
amsClient.emitMetrics(timelineMetrics);
LOG.info("Published " + timelineMetrics.getMetrics().size() + " metrics to AMS");
metricsMap.clear();
lastPublishTimeMS = currMS;
} catch (Throwable t) {
LOG.warn("Error sending metrics to AMS.", t);
if (currMS - lastFailedPublishTimeMS > maxMetricsBuffer) {
LOG.error("AMS was not sent for last " + maxMetricsBuffer / 1000 +
" seconds. Purging it and will start rebuilding it again");
metricsMap.clear();
lastFailedPublishTimeMS = currMS;
}
}
} else {
LOG.info("Not publishing metrics. metrics.size()=" + metricsMap.size() + ", lastPublished=" +
(currMS - lastPublishTimeMS) / 1000 + " seconds ago, intervalConfigured=" + publishIntervalMS / 1000);
}
}
public void setAmsClient(LogFeederAMSClient amsClient) {
this.amsClient = amsClient;
}
}
|
[
"ijarvis@sina.com"
] |
ijarvis@sina.com
|
1f1ef1c32a4c8ebb6a035060f2576147a7bb7632
|
596d4d1eddc38ee51e1e8b504de32c97fdfae1e6
|
/src/main/java/week4/day14/test/member/MemberInput.java
|
ef2003f48deed2cd7d3dba410d29ba12c19e8593
|
[] |
no_license
|
raystar9/mavenJava
|
b0befc9366af7120f566e7d15a07df0b95f6eb5a
|
65c67a8e84eabd12d55711c0b93c0ff286597c81
|
refs/heads/master
| 2021-01-25T11:33:18.784874
| 2018-03-07T10:57:44
| 2018-03-07T10:57:44
| 123,405,800
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,076
|
java
|
package week4.day14.test.member;
import java.util.ArrayList;
import java.util.Scanner;
class MemberInput {
public static void main(String[] args) {
ArrayList<MemberInfo> memberList = new ArrayList<>();
Scanner sc = new Scanner(System.in);
String name, email, address;
int age;
MemberInfo member = null;
System.out.print("Input name : ");
name = sc.next();
System.out.print("Input age : ");
age = sc.nextInt();
sc.nextLine();
System.out.print("Input E-Mail : ");
email = sc.nextLine();
System.out.print("Input address : ");
address = sc.nextLine();
member = new MemberInfo(name, age, email, address);
sc.close();
memberList.add(member);
printInfo(member);
}
static void printInfo(MemberInfo memberInfo) {
System.out.println("===============================================");
System.out.println("Name : " + memberInfo.getName());
System.out.println("Age : " + memberInfo.getAge());
System.out.println("E-Mail : " + memberInfo.getEmail());
System.out.println("Address : " + memberInfo.getAddress());
}
}
|
[
"raystar@raystar-PC"
] |
raystar@raystar-PC
|
0459ddd39172336f603bb899fa142141fade2ff4
|
0ec74bd7e3684d178dbd137d162f6e2245518065
|
/suyigou_pojo/src/main/java/com/suyigou/pojo/TbSeller.java
|
7abb7125aa45f0126d064774b95e3f3a65df7726
|
[] |
no_license
|
flymi1991/project_suyigou
|
27dae7d89bce64ac82370068089e5690377f415b
|
ecf4b2cc64643f7d8d90739f6a0bbe90c3aae8c7
|
refs/heads/master
| 2020-03-28T12:46:01.563519
| 2018-10-16T16:05:37
| 2018-10-16T16:05:37
| 148,332,185
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 5,467
|
java
|
package com.suyigou.pojo;
import java.io.Serializable;
import java.util.Date;
public class TbSeller implements Serializable {
private String sellerId;
private String name;
private String nickName;
private String password;
private String email;
private String mobile;
private String telephone;
private String status;
private String addressDetail;
private String linkmanName;
private String linkmanQq;
private String linkmanMobile;
private String linkmanEmail;
private String licenseNumber;
private String taxNumber;
private String orgNumber;
private Long address;
private String logoPic;
private String brief;
private Date createTime;
private String legalPerson;
private String legalPersonCardId;
private String bankUser;
private String bankName;//开户行名称
public String getSellerId() {
return sellerId;
}
public void setSellerId(String sellerId) {
this.sellerId = sellerId == null ? null : sellerId.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName == null ? null : nickName.trim();
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password == null ? null : password.trim();
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email == null ? null : email.trim();
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile == null ? null : mobile.trim();
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone == null ? null : telephone.trim();
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status == null ? null : status.trim();
}
public String getAddressDetail() {
return addressDetail;
}
public void setAddressDetail(String addressDetail) {
this.addressDetail = addressDetail == null ? null : addressDetail.trim();
}
public String getLinkmanName() {
return linkmanName;
}
public void setLinkmanName(String linkmanName) {
this.linkmanName = linkmanName == null ? null : linkmanName.trim();
}
public String getLinkmanQq() {
return linkmanQq;
}
public void setLinkmanQq(String linkmanQq) {
this.linkmanQq = linkmanQq == null ? null : linkmanQq.trim();
}
public String getLinkmanMobile() {
return linkmanMobile;
}
public void setLinkmanMobile(String linkmanMobile) {
this.linkmanMobile = linkmanMobile == null ? null : linkmanMobile.trim();
}
public String getLinkmanEmail() {
return linkmanEmail;
}
public void setLinkmanEmail(String linkmanEmail) {
this.linkmanEmail = linkmanEmail == null ? null : linkmanEmail.trim();
}
public String getLicenseNumber() {
return licenseNumber;
}
public void setLicenseNumber(String licenseNumber) {
this.licenseNumber = licenseNumber == null ? null : licenseNumber.trim();
}
public String getTaxNumber() {
return taxNumber;
}
public void setTaxNumber(String taxNumber) {
this.taxNumber = taxNumber == null ? null : taxNumber.trim();
}
public String getOrgNumber() {
return orgNumber;
}
public void setOrgNumber(String orgNumber) {
this.orgNumber = orgNumber == null ? null : orgNumber.trim();
}
public Long getAddress() {
return address;
}
public void setAddress(Long address) {
this.address = address;
}
public String getLogoPic() {
return logoPic;
}
public void setLogoPic(String logoPic) {
this.logoPic = logoPic == null ? null : logoPic.trim();
}
public String getBrief() {
return brief;
}
public void setBrief(String brief) {
this.brief = brief == null ? null : brief.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getLegalPerson() {
return legalPerson;
}
public void setLegalPerson(String legalPerson) {
this.legalPerson = legalPerson == null ? null : legalPerson.trim();
}
public String getLegalPersonCardId() {
return legalPersonCardId;
}
public void setLegalPersonCardId(String legalPersonCardId) {
this.legalPersonCardId = legalPersonCardId == null ? null : legalPersonCardId.trim();
}
public String getBankUser() {
return bankUser;
}
public void setBankUser(String bankUser) {
this.bankUser = bankUser == null ? null : bankUser.trim();
}
public String getBankName() {
return bankName;
}
public void setBankName(String bankName) {
this.bankName = bankName == null ? null : bankName.trim();
}
}
|
[
"mxc2013@163.com"
] |
mxc2013@163.com
|
e7e20726f88bc0d8a95af5e073209bdb644475e6
|
2d3bde994c72d52183e9e2c80c4e8c9109267abe
|
/StrategyPattern/src/example/GivenGreenLight.java
|
1aa527cfd334461a62ae00f827441fe076761ff7
|
[] |
no_license
|
wangchengming666/DesignPattern
|
1e96b16173302b7ec3ffce34a9bd4cc29dbe803f
|
3cf5701b5b52d2c6ed545123d10dc41002ac9a2e
|
refs/heads/master
| 2022-02-27T22:32:31.067185
| 2019-11-01T01:05:13
| 2019-11-01T01:05:13
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 169
|
java
|
package example;
public class GivenGreenLight implements Strategy {
@Override
public void operate() {
System.out.println("求吴国太开个绿灯,放行");
}
}
|
[
"634749869@qq.com"
] |
634749869@qq.com
|
fc1f400020469da3d6b643ff76e9906eac1f9d0f
|
b83a6760d1a312d490edda720b189974d76ba3b1
|
/grade-calculate/src/main/java/tv/icntv/grade/film/dbcollect/db/IDbCallBack.java
|
daef054e849a87b619ff70fe73ca34daeb552351
|
[] |
no_license
|
leixw0102/grade
|
2a9f4650b1f65faf606e4f14057b70b26a2a860a
|
d2e993aec032a15b98fd553ffe94c65ddfb90a65
|
refs/heads/master
| 2021-01-20T21:53:28.830788
| 2014-07-28T05:59:54
| 2014-07-28T05:59:54
| 29,007,979
| 0
| 1
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 905
|
java
|
/* Copyright 2013 Future TV, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package tv.icntv.grade.film.dbcollect.db;
import java.sql.Connection;
/**
* Created with IntelliJ IDEA.
* User: xiaowu lei
* Date: 13-11-20
* Time: 下午2:53
*/
@Deprecated
public interface IDbCallBack<T> {
public T callback(Connection connection);
}
|
[
"0102lei@163.com"
] |
0102lei@163.com
|
640857e7bdac26305ae11336635a69416e459557
|
700adf37599c324211bd5ec52dfa7235e275f691
|
/app/src/main/java/com/example/zhi/object/DailyPlan.java
|
34e665695c2f4d96b2bc562a9272baf1b42ddc2e
|
[] |
no_license
|
Markmeimei/ZhiXin
|
10864f5fc9ad8550cbec74032280e3938b75c118
|
3eee1546f8df9ad7af9dc23c625827fbf7409e7e
|
refs/heads/master
| 2021-01-10T16:16:10.648804
| 2016-04-28T09:17:21
| 2016-04-28T09:17:21
| 47,959,402
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,385
|
java
|
package com.example.zhi.object;
import java.util.List;
/**
* 每日计划查询实体类
*
* Author: Eron
* Date: 2016/4/5 0005
* Time: 9:53
*/
public class DailyPlan {
private Data data;
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
public class Data {
private int state;
private String text;
private List<Info> info;
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public List<Info> getInfo() {
return info;
}
public void setInfo(List<Info> info) {
this.info = info;
}
public class Info {
private String id;
private String name;
private String content;
private String date;
private String date_nian;
private String date_yue;
private String ip;
private String addtime;
private String ydr;
private String yd_time;
private String userid;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getDate_nian() {
return date_nian;
}
public void setDate_nian(String date_nian) {
this.date_nian = date_nian;
}
public String getDate_yue() {
return date_yue;
}
public void setDate_yue(String date_yue) {
this.date_yue = date_yue;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getAddtime() {
return addtime;
}
public void setAddtime(String addtime) {
this.addtime = addtime;
}
public String getYdr() {
return ydr;
}
public void setYdr(String ydr) {
this.ydr = ydr;
}
public String getYd_time() {
return yd_time;
}
public void setYd_time(String yd_time) {
this.yd_time = yd_time;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
}
}
}
|
[
"w_xuanlong@163.com"
] |
w_xuanlong@163.com
|
5d61b6ffc37374f5d0da717d2aab22628abff715
|
a764137f384cede7b985257a06aa22be2695816b
|
/bee-apm-agent-test/bee-apm-sb-demo/src/main/java/net/beeapm/demo/model/ResultVo.java
|
780327d2a0d55e262bdc816c78fa22e65d722d4f
|
[] |
no_license
|
dizhaung/bee-apm
|
c7ec52b6759b68d6329278b19bf0645e103d0361
|
2c51b3c537eec0b99daae3198c8674f708e874d8
|
refs/heads/master
| 2022-07-08T23:48:37.062873
| 2020-05-13T14:46:26
| 2020-05-13T14:46:26
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 907
|
java
|
package net.beeapm.demo.model;
/**
* @author yuanlong.chen
* @date 2020/01/12
*/
public class ResultVo {
private int code;
private int counter;
private String msg;
private Object data;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public int getCounter() {
return counter;
}
public void setCounter(int counter) {
this.counter = counter;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public static ResultVo OK(int counter, String msg){
ResultVo res = new ResultVo();
res.setMsg(msg);
res.setCounter(counter);
return res;
}
}
|
[
"beetle082@163.com"
] |
beetle082@163.com
|
0243fa6f99ff9207c7198e60a3a3c00e18820f33
|
45e23f388dcf3e7dcfe1b81bc6d771199f17c392
|
/src/main/java/br/edu/ifba/eunapolis/model/ListaCompra.java
|
1d4b977b83089fe34320133a7eb5d88ab4489885
|
[] |
no_license
|
IFBAEunapolisMaisBarato/MaisBaratoFontes
|
2010f35cd322352d1e842d8fe4e19d41365b7b06
|
c4a3add42e68ef10dbdfebac1a54d11db7c35bbf
|
refs/heads/master
| 2020-05-20T18:08:59.367750
| 2017-06-01T00:06:25
| 2017-06-01T00:06:25
| 84,500,572
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,224
|
java
|
package br.edu.ifba.eunapolis.model;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.Fetch;
/**
* @author Vitor
* @version 1.0.0
* @since 29/04/2017
*
*/
@NamedQueries({
@NamedQuery(name = "ListaCompra.consultarPorUsuario", query = "SELECT lista FROM ListaCompra lista WHERE lista.user.fbID =:fbId"),
})
@Entity
public class ListaCompra extends AbstractEntity implements Serializable {
private static final long serialVersionUID = -2916653125263688518L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
private String nome;
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
private List<Produto> produtos;
@OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.ALL)
@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
private List<Orcamento> orcamentos;
@ManyToOne
@JoinColumn(name="user_id")
private User user;
private boolean status;
public Long getId() {
return id;
}
public String getNome() {
return nome;
}
public List<Produto> getProdutos() {
return produtos;
}
public List<Orcamento> getOrcamentos() {
return orcamentos;
}
public void setId(Long id) {
this.id = id;
}
public void setNome(String nome) {
this.nome = nome;
}
public void setProdutos(List<Produto> produtos) {
this.produtos = produtos;
}
public void setOrcamentos(List<Orcamento> orcamentos) {
this.orcamentos = orcamentos;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
|
[
"vitor.benjamin7@gmail.com"
] |
vitor.benjamin7@gmail.com
|
b51325475e15f0f744c56936807b3315ec0187bb
|
c956dd8395b0c3732214ef232e19adb26c13fcd9
|
/src/main/java/com/busekylin/web/ioc/BeansPool.java
|
d51e3c7f7a60962a03de8341786138b1fa05f039
|
[] |
no_license
|
zhaoleigege/webFramework
|
27990e908bfa93f924a08eb519b652cb1bdacf30
|
19f39d066037638a67fca2fae70983edd469994d
|
refs/heads/master
| 2020-04-10T20:34:32.663910
| 2019-01-15T06:58:27
| 2019-01-15T06:58:27
| 161,272,085
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 721
|
java
|
package com.busekylin.web.ioc;
import java.util.HashMap;
import java.util.Map;
/**
* bean对象池
*/
public class BeansPool {
private static class BeansPoolSingleton {
private static final BeansPool INSTANCE = new BeansPool();
}
private BeansPool() {
this.beansMap = new HashMap<>();
}
public static BeansPool getInstance() {
return BeansPoolSingleton.INSTANCE;
}
private Map<Class, Object> beansMap;
public Map<Class, Object> allClass(){
return beansMap;
}
public Object getObject(Class clazz){
return beansMap.get(clazz);
}
public void setObject(Class clazz, Object object){
beansMap.put(clazz, object);
}
}
|
[
"buse@leigedeMAC.mshome.net"
] |
buse@leigedeMAC.mshome.net
|
e42b984857e193de311e8f4da7f390ff698efada
|
bc93c06e06baafecb4c62eb90e25dbbb6af1d489
|
/app/src/main/java/com/rolling/net/ResultCallback.java
|
a696187813afb39a1153a260dc01151a1f0255c9
|
[] |
no_license
|
zhangyao0328/Rolling
|
bdf6c7d3025c7edc73bf0733eabdc855021037e7
|
023562522205fae142bc08d3de0df6b61de62f0e
|
refs/heads/master
| 2021-07-20T15:48:53.764608
| 2021-07-11T06:26:57
| 2021-07-11T06:26:57
| 142,769,409
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,189
|
java
|
package com.rolling.net;
import com.google.gson.internal.$Gson$Types;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import okhttp3.Call;
import okhttp3.Request;
import okhttp3.Response;
/**
* @author zhangyao
* @date 2017/11/20:10:31
* @E-mail android_n@163.com
*/
public abstract class ResultCallback<T> {
Type mType;
public ResultCallback() {
mType = getSuperclassTypeParameter(getClass());
}
static Type getSuperclassTypeParameter(Class<?> subclass) {
Type superclass = subclass.getGenericSuperclass();
if (superclass instanceof Class) {
throw new RuntimeException("Missing type parameter.");
}
ParameterizedType parameterized = (ParameterizedType) superclass;
return $Gson$Types.canonicalize(parameterized.getActualTypeArguments()[0]);
}
public void onBefore(Request request) {
}
public void onAfter() {
}
public abstract void onError(Response response, Exception e, int tag);
public abstract void onResponse(T resbase, int tag);
public abstract void onFailure(Call call, IOException e, int tag);
}
|
[
"oncwnuFJG0UQPeykyBhkbh3gvosw@git.weixin.qq.com"
] |
oncwnuFJG0UQPeykyBhkbh3gvosw@git.weixin.qq.com
|
e4c321aa102e7907f26405b31fd51731bb0ac8ab
|
b7c8618415a99c1e93b6bf943f64332b1a7bc6ea
|
/스크린샷/0108/InstanceVariableDemo.java
|
242a59e12fa0266b5e64f57e898412d2923f56f1
|
[] |
no_license
|
freetic/JavaIntelliJ2
|
2d8f044b51758d881d743a032ab55b936159e3c9
|
9b364b07abefec0788d9fac40c705d73163e7570
|
refs/heads/master
| 2020-12-27T23:26:02.641931
| 2020-02-07T08:54:56
| 2020-02-07T08:54:56
| 238,103,582
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 427
|
java
|
public class InstanceVariableDemo {
static int kor = 90; //static variable/class variable
int eng = 100; //member variable/instance variable
public static void main(String[] args) {
int age = 24; //local variable
System.out.println("age = " + age);
System.out.println("kor = " + InstanceVariableDemo.kor);
InstanceVariableDemo ivd = new InstanceVariableDemo();
System.out.println("eng = " + ivd.eng);
}
}
|
[
"freetic1004@naver.com"
] |
freetic1004@naver.com
|
4457643cfe08ee79abb2b94d464f3924df6e418e
|
732933ecef7bc538230fd02c52f1e4ac7f41c3a5
|
/src/main/java/nettyHttpTest/HttpServerInboundHandler.java
|
0007fd36ba6dbc1bf06645a21e075a7ff6ad187d
|
[] |
no_license
|
stonebrave/nettyserver
|
e29d48c0d9f50301a9d482afa7bfadebffb77024
|
00df8f9ddd10dffc2d8a247bf8f2cf7273bd9b8d
|
refs/heads/master
| 2023-03-30T15:14:08.476688
| 2021-04-02T08:45:21
| 2021-04-02T08:45:21
| 341,741,854
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,363
|
java
|
package nettyHttpTest;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONNECTION;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_LENGTH;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpHeaders.Values;
import io.netty.handler.codec.http.HttpRequest;
public class HttpServerInboundHandler extends ChannelHandlerAdapter {
private HttpRequest request;
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg)
throws Exception {
if (msg instanceof HttpRequest) {
request = (HttpRequest) msg;
String uri = request.getUri();
System.out.println("Uri:" + uri);
}
if (msg instanceof HttpContent) {
HttpContent content = (HttpContent) msg;
ByteBuf buf = content.content();
System.out.println(buf.toString(io.netty.util.CharsetUtil.UTF_8));
buf.release();
String res = "I am OK";
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1,
OK, Unpooled.wrappedBuffer(res.getBytes("UTF-8")));
response.headers().set(CONTENT_TYPE, "text/plain");
response.headers().set(CONTENT_LENGTH,
response.content().readableBytes());
if (HttpHeaders.isKeepAlive(request)) {
response.headers().set(CONNECTION, Values.KEEP_ALIVE);
}
ctx.write(response);
ctx.flush();
}
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
ctx.flush();
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
System.out.println(cause.getMessage());
ctx.close();
}
}
|
[
"situjiuxiang@163.com"
] |
situjiuxiang@163.com
|
6d185efcec4ab93bb024dd3766a2edffb91d0141
|
47a2350b419021424a7d896a81517f1647224a6c
|
/cli/src/main/java/io/github/derekstavis/sl025/test/Constants.java
|
0523da022225938b9152be402bec3ab1c6551dab
|
[
"BSD-3-Clause"
] |
permissive
|
derekstavis/sl025-java
|
da1c4d524f3c1f59f5c3eb855f720e8ae969add0
|
a4c936f73cda06769ac1af5064fa677baf18fd9e
|
refs/heads/master
| 2021-01-25T04:02:59.270397
| 2015-04-17T14:04:40
| 2015-04-17T14:04:40
| 32,091,777
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 375
|
java
|
package io.github.derekstavis.sl025.test;
import io.github.derekstavis.devices.mifare.MifareKey;
import io.github.derekstavis.devices.mifare.stronglink.sl025.MifareKeyType;
class Constants {
public static MifareKey DEFAULT_KEY_A = MifareKey.get(MifareKeyType.KEY_A,
new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF});
}
|
[
"derek@dba.eng.br"
] |
derek@dba.eng.br
|
b6ae1ca63c227ce31259a788de7d738a02c462ab
|
b0a6f83db73501c1e94c4eaf4d63c4c27fc21ce8
|
/src/main/java/org/ed/junit/ju03granularity/Team.java
|
1e094ed0a1a031759d8843561091e6932cc3a6f3
|
[] |
no_license
|
jchacon80/eedd
|
5d059ccd601a3c45591f6ae3b9643644afae9b2d
|
9ec4be2aea96ac577822163080609115d9959e13
|
refs/heads/master
| 2022-12-13T02:15:32.109218
| 2020-09-09T18:08:07
| 2020-09-09T18:08:07
| 294,190,636
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 853
|
java
|
package org.ed.junit.ju03granularity;
import java.util.Vector;
/**
* Represents a team with players. Players are represented by numbers
*/
public class Team {
private Vector<Integer> numbers;
private String name;
public Team(String name) {
numbers = new Vector<Integer>();
this.name = name;
}
public String getName () {
return name;
}
public int totalNumbers () {
return numbers.size();
}
public void addNumber (Integer number) {
if (number >= 0 && number <= 99) {
numbers.addElement(number);
}
}
public Integer numberAt (int position) {
if (totalNumbers() > 0)
return numbers.elementAt(position);
else
return -1;
}
public boolean removeNumber (Integer number) {
return numbers.removeElement(number);
}
public void removeNumberAt (int position) {
numbers.removeElementAt(position);
}
}
|
[
"jchacon80@gmail.com"
] |
jchacon80@gmail.com
|
c9afb82929f2ca55b8ecabf2837b5713d14d78ae
|
225e9c2aebb7b47971c738f45775713d7cfb15f5
|
/jdk/jdk1.8/src/main/org/omg/CORBA/WStringSeqHelper.java
|
20c17ee6bab423760371706d9a8aeccda1eef0ae
|
[] |
no_license
|
smalldoctor/source-code
|
6bb53559840f138a456c160aa22d0d7bba5322a0
|
c7571807e8d29d46a353148de6dfce3e52f5cfe9
|
refs/heads/master
| 2022-11-05T19:01:27.152507
| 2019-07-02T09:57:44
| 2019-07-02T09:57:44
| 106,514,195
| 0
| 0
| null | 2022-10-05T19:09:17
| 2017-10-11T06:27:26
|
Java
|
UTF-8
|
Java
| false
| false
| 1,848
|
java
|
package org.omg.CORBA;
/**
* org/omg/CORBA/WStringSeqHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from /Users/java_re/workspace/8-2-build-macosx-x86_64/jdk8u141/9370/corba/src/share/classes/org/omg/PortableInterceptor/CORBAX.idl
* Wednesday, July 12, 2017 4:36:59 AM PDT
*/
/** An array of WStrings */
abstract public class WStringSeqHelper
{
private static String _id = "IDL:omg.org/CORBA/WStringSeq:1.0";
public static void insert (org.omg.CORBA.Any a, String[] that)
{
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
a.type (type ());
write (out, that);
a.read_value (out.create_input_stream (), type ());
}
public static String[] extract (org.omg.CORBA.Any a)
{
return read (a.create_input_stream ());
}
private static org.omg.CORBA.TypeCode __typeCode = null;
synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
__typeCode = org.omg.CORBA.ORB.init ().create_wstring_tc (0);
__typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
__typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.omg.CORBA.WStringSeqHelper.id (), "WStringSeq", __typeCode);
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static String[] read (org.omg.CORBA.portable.InputStream istream)
{
String value[] = null;
int _len0 = istream.read_long ();
value = new String[_len0];
for (int _o1 = 0;_o1 < value.length; ++_o1)
value[_o1] = istream.read_wstring ();
return value;
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, String[] value)
{
ostream.write_long (value.length);
for (int _i0 = 0;_i0 < value.length; ++_i0)
ostream.write_wstring (value[_i0]);
}
}
|
[
"15312408287@163.com"
] |
15312408287@163.com
|
b5cd87e4fab856d1855c795e8d7489d3c593baf5
|
500430e8e43cace7d497adc011418d1247c6c1ee
|
/core/src/org/pltw/examples/Constants.java
|
dcec6622182bbb2eb227323d259d760c901153f1
|
[] |
no_license
|
devondroberts/EmuOnTheLoose
|
d895d875fc2b87afcc9f4dbe8d715e36cab03005
|
a53a526060b2163292a2cd712705a1d7ff614f2a
|
refs/heads/master
| 2020-03-23T13:10:59.418678
| 2018-07-19T16:18:05
| 2018-07-19T16:18:05
| 141,604,206
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 986
|
java
|
/**
* Project Lead The Way, 2016.
*/
package org.pltw.examples;
public class Constants {
// Visible game world is 5 meters wide
public static final float VIEWPORT_WIDTH = 5.0f;
// Visible game world is 5 meters tall
public static final float VIEWPORT_HEIGHT = 5.0f;
// Path to texture atlas file
public static final String TEXTURE_ATLAS = "EmuOnTheLoose.atlas";
// Tile dimensions
public static final float TILE_WIDTH = 1.0f;
public static final float TILE_HEIGHT = 0.5f;
public static final float X_PADDING_TO_NEXT_TILE = 0.5f;
public static final float Y_PADDING_TO_NEXT_TILE = 0.25f;
// Wall tile dimensions
public static final float WALL_TILE_WIDTH = 0.505f;
public static final float WALL_TILE_HEIGHT = 1.942f;
// sample map dimensions
public static final int SAMPLE_MAP_WIDTH = 5;
public static final int SAMPLE_MAP_HEIGHT = 5;
public static final int WALL_ROW = 0;
public static final int WALL_COL = 0;
}
|
[
"devondroberts@gmail.com"
] |
devondroberts@gmail.com
|
a712041872263f65b0ad3065408ba99707079229
|
83009ec5000fa8578eff41b3162e765ccf1988cb
|
/src/main/java/eu/panic/dont/sensu/NotifySensu.java
|
18e4ef5a45b4c2d5afa7830d3dcd60218867ec33
|
[
"Apache-2.0"
] |
permissive
|
EelcoMeuter/sensu-logger
|
186bd21676f159cd6332f3b965825358644e4a10
|
c5e1c62cbadd80c00b40392ee48bdc430065da2d
|
refs/heads/master
| 2021-01-21T05:00:09.950824
| 2015-07-07T12:25:46
| 2015-07-07T12:25:46
| 38,616,145
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 374
|
java
|
package eu.panic.dont.sensu;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Method annotation to sent the message of the thrown exception to Sensu.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface NotifySensu {
}
|
[
"eelco@jpoint.nl"
] |
eelco@jpoint.nl
|
66b31a4291059dc05f817bd6e53690e6d12f281f
|
7b8c7e6e5082478bd882791c084d160b225a073e
|
/sys-admin/cc-user/src/main/java/com/caicai/user/entity/vo/PositionVO.java
|
c78be977dbcc454edcf8a5818cf45e4057024b8e
|
[] |
no_license
|
mygetjc/caicai-20200827
|
d0fb54a03e6b3ce89657a79fb91fade1c659c138
|
82844e7914c5f481d033a15022a42ade5229f47b
|
refs/heads/master
| 2022-12-06T14:54:12.695070
| 2020-08-31T10:00:02
| 2020-08-31T10:00:02
| 290,749,665
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 856
|
java
|
package com.caicai.user.entity.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* @author jc
* @date 2020-08-28 17:43:34.97
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class PositionVO implements Serializable{
private static final long serialVersionUID = -1L;
/**
* id
*/
private String id;
/**
* 岗位名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 是否已删除Y:已删除,N:未删除
*/
private String deleted;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 创建人
*/
private String createdBy;
/**
* 更新人
*/
private String updatedBy;
}
|
[
"jc19941001"
] |
jc19941001
|
2c1e9a236b331380ef6c06737fdca207532782d3
|
ac94ac4e2dca6cbb698043cef6759e328c2fe620
|
/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudInstanceClientLiveTest.java
|
349711b5e5e4a54ae0fd1abdcb31ef7d2417314a
|
[
"Apache-2.0"
] |
permissive
|
andreisavu/jclouds
|
25c528426c8144d330b07f4b646aa3b47d0b3d17
|
34d9d05eca1ed9ea86a6977c132665d092835364
|
refs/heads/master
| 2021-01-21T00:04:41.914525
| 2012-11-13T18:11:04
| 2012-11-13T18:11:04
| 2,503,585
| 2
| 0
| null | 2012-10-16T21:03:12
| 2011-10-03T09:11:27
|
Java
|
UTF-8
|
Java
| false
| false
| 1,240
|
java
|
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.jclouds.greenqloud.compute.services;
import org.jclouds.ec2.services.InstanceClientLiveTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "GreenQloudInstanceClientLiveTest")
public class GreenQloudInstanceClientLiveTest extends InstanceClientLiveTest {
public GreenQloudInstanceClientLiveTest() {
provider = "greenqloud-compute";
}
}
|
[
"adrian@jclouds.org"
] |
adrian@jclouds.org
|
4153771302e9cd0c67ba484b5956022504d0110d
|
b2ed02fe65e6a31474d37a484be838742d59e626
|
/gxpenses-client/src/main/java/com/nuvola/gxpenses/client/web/application/budget/widget/BudgetSiderUiHandlers.java
|
74f45df57c71b849d09b4ec958299e956b9f2ead
|
[] |
no_license
|
imrabti/gxpenses-old
|
5fdbf558508dbb023d574afdd06a53b46d798f7c
|
2f81421b88d211b23ec3843a1363a3061a228f83
|
refs/heads/master
| 2021-01-13T01:15:09.791346
| 2014-03-25T08:31:31
| 2014-03-25T08:31:31
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 362
|
java
|
package com.nuvola.gxpenses.client.web.application.budget.widget;
import com.google.gwt.user.client.ui.Widget;
import com.gwtplatform.mvp.client.UiHandlers;
import com.nuvola.gxpenses.common.shared.business.Budget;
public interface BudgetSiderUiHandlers extends UiHandlers {
void addNewBudget(Widget relativeTo);
void budgetSelected(Budget budget);
}
|
[
"imrabti@gmail.com"
] |
imrabti@gmail.com
|
51469ec9dcd2c3627b6d671c7d9c53ab83c911a8
|
bc850d71d7baebcc1d502b0eadb41cab13b58a61
|
/src/main/java/cz/muni/fi/pv243/seminar/infinispan/session/CarManager.java
|
b9ddbafdfb221e12ff44511130009693c40df2ea
|
[] |
no_license
|
mcimbora/pv243-2015-infinispan-seminar
|
03fb2b71243651df627fe558d8821955d9e99b89
|
2c9cbdfd945b65193a42883bf072fa1e9be20c30
|
refs/heads/infinispan-00
| 2020-12-31T02:23:54.648322
| 2014-11-10T14:51:11
| 2016-03-15T09:28:13
| 53,940,889
| 0
| 0
| null | 2016-03-15T12:00:04
| 2016-03-15T12:00:03
| null |
UTF-8
|
Java
| false
| false
| 4,840
|
java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package cz.muni.fi.pv243.seminar.infinispan.session;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.LinkedList;
import java.util.List;
import javax.enterprise.inject.Model;
import javax.inject.Inject;
import org.infinispan.commons.api.BasicCache;
import cz.muni.fi.pv243.seminar.infinispan.model.Car;
/**
* Adds, retrieves, removes new cars from the cache. Also returns a list of cars stored in the cache.
*
* @author Martin Gencur
*/
@Model
public class CarManager {
public static final String CACHE_NAME = "carcache";
public static final String CAR_NUMBERS_KEY = "carnumbers";
@Inject
private CacheContainerProvider provider;
private BasicCache<String, Object> carCache;
private String carId;
private Car car = new Car();
public CarManager() {
}
public String addNewCar() {
carCache = provider.getCacheContainer().getCache(CACHE_NAME);
List<String> carNumbers = getNumberPlateList(carCache);
carNumbers.add(car.getNumberPlate());
carCache.put(CAR_NUMBERS_KEY, carNumbers);
carCache.put(CarManager.encode(car.getNumberPlate()), car);
return "home";
}
public String addNewCarWithRollback() {
boolean throwInducedException = true;
carCache = provider.getCacheContainer().getCache(CACHE_NAME);
List<String> carNumbers = getNumberPlateList(carCache);
carNumbers.add(car.getNumberPlate());
// store the new list of car numbers and then throw an exception -> roll-back
// the car number list should not be stored in the cache
carCache.put(CAR_NUMBERS_KEY, carNumbers);
if (throwInducedException) {
throw new RuntimeException("Induced exception");
}
carCache.put(CarManager.encode(car.getNumberPlate()), car);
return "home";
}
/**
* Operate on a clone of car number list
*/
@SuppressWarnings("unchecked")
private List<String> getNumberPlateList(BasicCache<String, Object> carCacheLoc) {
List<String> carNumberList = (List<String>) carCacheLoc.get(CAR_NUMBERS_KEY);
return carNumberList == null ? new LinkedList<>() : new LinkedList<>(carNumberList);
}
public String showCarDetails(String numberPlate) {
carCache = provider.getCacheContainer().getCache(CACHE_NAME);
this.car = (Car) carCache.get(encode(numberPlate));
return "showdetails";
}
public List<String> getCarList() {
// retrieve a cache
carCache = provider.getCacheContainer().getCache(CACHE_NAME);
// retrieve a list of number plates from the cache
return getNumberPlateList(carCache);
}
public String removeCar(String numberPlate) {
carCache = provider.getCacheContainer().getCache(CACHE_NAME);
carCache.remove(encode(numberPlate));
List<String> carNumbers = getNumberPlateList(carCache);
carNumbers.remove(numberPlate);
carCache.put(CAR_NUMBERS_KEY, carNumbers);
return null;
}
public void setCarId(String carId) {
this.carId = carId;
}
public String getCarId() {
return carId;
}
public void setCar(Car car) {
this.car = car;
}
public Car getCar() {
return car;
}
public static String encode(String key) {
try {
return URLEncoder.encode(key, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
public static String decode(String key) {
try {
return URLDecoder.decode(key, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
}
|
[
"mcimbora@redhat.com"
] |
mcimbora@redhat.com
|
3fa92d0a23fc7c6b9768c07b7c62c5397f5ae84a
|
8e258bb851780d11cc5f1615fd2a99f70747f202
|
/sandbox/Bravo10.6_merged/src/com/example/android/opengl/MyGLRenderer.java
|
2b5687f20b390e1d3da3711fdc444a06f521c5fe
|
[
"MIT"
] |
permissive
|
lothas/BTAR
|
c7034d1250e840febdc64efa08d303e4e693abc3
|
fd2454df059451c611237782d8bc3dfcd425bdd8
|
refs/heads/master
| 2020-04-05T14:37:31.008833
| 2016-08-31T16:22:04
| 2016-08-31T16:22:04
| 45,118,981
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 12,662
|
java
|
/*
* Copyright (C) 2011 The Android Open Source Project
*
* 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.example.android.opengl;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.sql.NClob;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import org.opencv.samples.colorblobdetect.MarkerDetector;
import com.example.bravo.MainActivity;
import android.content.Context;
import android.graphics.Point;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.opengl.GLSurfaceView;
import android.opengl.GLU;
import android.util.Log;
import android.view.Display;
import bravo.game.manager.GameManager;
/**
* Provides drawing instructions for a GLSurfaceView object. This class
* must override the OpenGL ES drawing lifecycle methods:
* <ul>
* <li>{@link android.opengl.GLSurfaceView.Renderer#onSurfaceCreated}</li>
* <li>{@link android.opengl.GLSurfaceView.Renderer#onDrawFrame}</li>
* <li>{@link android.opengl.GLSurfaceView.Renderer#onSurfaceChanged}</li>
* </ul>
*/
public class MyGLRenderer implements GLSurfaceView.Renderer {
private static final String TAG = "MyGLRenderer";
//-------------------------Static----------------------------//
private static final int NO_COLOR = -1;
private static final int BLUE_COLOR = 1;
private static final int GREEN_COLOR = 2;
private static final int RED_COLOR = 3;
public final static int SS_SUNLIGHT = GL10.GL_LIGHT0;
//-------------------------Fields--------------------------//
private Triangle mTriangle;
private Square mSquare;
private example mExample;
private BlanderObj mBlanderObj;
private AssetObj mTower;
private AssetObj mCoin;
private AssetObj mTest;
private float mAngle;
private float objX;
private float objY;
private int screenWidth;
private int screenHeight;
private MarkerDetector blueRedDetector;
private MarkerDetector GreenRedDetector;
private MarkerDetector GreenBlueDetector;
SensorManager sensorManager;
int orientationSensor;
float headingAngle;
float pitchAngle;
float rollAngle;
//-------------------------GameManger----------------------//
public GameManager mGameManager;
//-------------------------Activity------------------------//
MainActivity mMainActivity;
private Context appContext;
//-------------------------Methods-------------------------//
public MyGLRenderer(Context context){
appContext = context;
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
// Set the background frame color
gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
load3dObjects();
runOrientationSensor();
mGameManager = mMainActivity.mGameManager;
getScreenSizeInPixels(); // sets screenWidth and screenHeight
//------Light settings--------------
initLighting(gl);
//----------------------------------
objX = -0.5f;
objY = 0.8f;
blueRedDetector = new MarkerDetector();
blueRedDetector.prepareGame(screenWidth, screenHeight, BLUE_COLOR, RED_COLOR, 4);
GreenRedDetector = new MarkerDetector();
GreenRedDetector.prepareGame(screenWidth, screenHeight, GREEN_COLOR, BLUE_COLOR, 4);
GreenBlueDetector = new MarkerDetector();
GreenBlueDetector.prepareGame(screenWidth, screenHeight, GREEN_COLOR, BLUE_COLOR, 4);
int robpId = com.example.bravo.R.drawable.robo;
mGameManager.printBottomRight("screenWidth: " + screenWidth + " screenHeight: " + screenHeight);
mBlanderObj.createTexture(gl, appContext, robpId);
}
private void initLighting(GL10 gl) {
float[] diffuse = {1.0f, 1.0f, 1.0f, 1.0f};
float[] pos = {0.0f, 5.0f, 0.0f, 5.0f};
gl.glLightfv(SS_SUNLIGHT, GL10.GL_POSITION, makeFloatBuffer(pos));
gl.glLightfv(SS_SUNLIGHT, GL10.GL_DIFFUSE, makeFloatBuffer(diffuse));
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glEnable(GL10.GL_LIGHTING);
gl.glEnable(SS_SUNLIGHT);
gl.glEnable(GL10.GL_COLOR_MATERIAL);
float[] colorVector={1f, 1f, 1f, 1f};
gl.glLightModelfv(GL10.GL_LIGHT_MODEL_AMBIENT, makeFloatBuffer(colorVector));
}
protected static FloatBuffer makeFloatBuffer(float[] arr) {
ByteBuffer bb = ByteBuffer.allocateDirect(arr.length*4);
bb.order(ByteOrder.nativeOrder());
FloatBuffer fb = bb.asFloatBuffer();
fb.put(arr);
fb.position(0);
return fb;
}
private void load3dObjects(){
mTriangle = new Triangle();
mSquare = new Square();
mExample = new example();
mBlanderObj = new BlanderObj();
mTower = new AssetObj(mMainActivity, "tower6.obj","tower6.mtl");//TODO
mCoin = new AssetObj(mMainActivity, "coin2.obj","coin2.mtl");
mTest = new AssetObj(mMainActivity, "tower2.obj","tower2.mtl");
}
private void getScreenSizeInPixels(){
Display display = mMainActivity.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenWidth = size.x;
screenHeight = size.y;
}
@Override
public void onDrawFrame(GL10 gl) {
// Clears the screen and depth buffer.
gl.glClearColor(0,0,0,0);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
// Replace the current matrix with the identity matrix
gl.glViewport(0, 0, screenWidth, screenWidth);
gl.glLoadIdentity();
// SQUARE A
drawObj(gl, blueRedDetector);
drawObj(gl, GreenRedDetector);
drawObj(gl, GreenBlueDetector);
drawCoin(gl);
// DRAW GTID
//drawGrid(gl,1,1,false);
//drawGrid(gl,1,-1,false);
//drawGrid(gl,0,1,false);
//drawGrid(gl,1,0,false);
//drawGrid(gl,0,0,true);
//drawGrid(gl,-1,0,false);
//drawGrid(gl,0,-1,false);
//drawGrid(gl,-1,1,false);
//drawGrid(gl,-1,-1,false);
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
// Adjust the viewport based on geometry changes
// such as screen rotations
gl.glViewport(0, 0, width, height);
// make adjustments for screen ratio
float ratio = (float) width / height;
gl.glMatrixMode(GL10.GL_PROJECTION); // set matrix to projection mode
gl.glLoadIdentity(); // reset the matrix to its default state
gl.glFrustumf(-ratio, ratio, -1, 1, 3, 7); // apply the projection matrix
}
/**
* Returns the rotation angle of the triangle shape (mTriangle).
*
* @return - A float representing the rotation angle.
*/
public float getAngle() {
return mAngle;
}
/**
* Sets the rotation angle of the triangle shape (mTriangle).
*/
public void setAngle(float angle) {
mAngle = angle;
}
public void setScreenWidthHeight(int width, int height){
screenWidth = width;
screenHeight = height;
}
public void setCordinates(float x, float y){
objX = x;
objY = y;
}
public float pixel2worldX(int x){
return 2*((float)x) / screenWidth - 1;
}
public float pixel2worldY(float y){
// we want ower world to be scaled 1:1 so points 1 and -1 of the Y axis are out side the screen
//that is why we use (screenHeight/ screenWidth) insted of 1
float hightWidth = ((float)screenHeight / (float)screenWidth); // the (float) are importent.
return y * hightWidth - (1f - hightWidth);
}
/*public float pixel2worldYscaled(int y){
return 1 - 2*((float)y) / screenHeight;
}*/
public float pixel2worldYscaled(int y){// need to add later
float tYemp = 1 - 2*((float)y) / screenHeight;
return pixel2worldY(tYemp);
}
public float scaleTrackObjects(MarkerDetector mDetector){
Log.i(TAG, "MyGLRenderer: mDetector xF - xB = " + (mDetector.getFrontX() - mDetector.getBackX()));
Log.i(TAG, "MyGLRenderer: mDetector yF - yB = " + (mDetector.getFrontY() - mDetector.getBackY()));
Log.i(TAG, "MyGLRenderer: mDetector.getFront2BackLength() = " + mDetector.getFront2BackLength());
return 5*(mDetector.getFront2BackLength()) / mDetector.getFrameWidth();
}
public void setTrackObjects(MarkerDetector mDetector1,MarkerDetector mDetector2,MarkerDetector mDetector3){
blueRedDetector = mDetector1;
GreenRedDetector = mDetector2;
GreenBlueDetector = mDetector3;
}
public void setMainActivityContext(MainActivity activity){
mMainActivity = activity;
}
public void runOrientationSensor(){
sensorManager = (SensorManager) mMainActivity.getSystemService(mMainActivity.SENSOR_SERVICE);
orientationSensor = Sensor.TYPE_ORIENTATION;
sensorManager.registerListener(sensorEventListener,sensorManager.getDefaultSensor(orientationSensor),SensorManager.SENSOR_DELAY_NORMAL);
}
final SensorEventListener sensorEventListener = new SensorEventListener() {
public void onSensorChanged(SensorEvent sensorEvent) {
if (sensorEvent.sensor.getType() == Sensor.TYPE_ORIENTATION) {
headingAngle = sensorEvent.values[0];
pitchAngle = sensorEvent.values[1];
rollAngle = sensorEvent.values[2];
Log.d(TAG, "Heading: " + String.valueOf(headingAngle));
Log.d(TAG, "Pitch: " + String.valueOf(pitchAngle));
Log.d(TAG, "Roll: " + String.valueOf(rollAngle));
}
}
public void onAccuracyChanged(Sensor senor, int accuracy) {
// Not used
}
};
public void drawObj(GL10 gl, MarkerDetector mDetector){
if (mDetector.isDetected() == false) {
return;
}
// Save the current matrix.
gl.glPushMatrix();
gl.glTranslatef(pixel2worldX(mDetector.getMiddleX()), pixel2worldYscaled(mDetector.getMiddleY()), 0);
float scale = 0.4f * scaleTrackObjects(mDetector);
gl.glScalef(scale, scale, scale); //(screenHeight/screenWidth)*
float rotateOnZ = mDetector.getAngleFromXAxis();
gl.glRotatef(rotateOnZ, 0, 0, 1);
gl.glRotatef(rollAngle, (float)Math.cos(Math.toRadians(rotateOnZ)), -(float)Math.sin(Math.toRadians(rotateOnZ)), 0);
// Draw mExample A.
mTower.draw(gl);
// Restore the last matrix.
gl.glPopMatrix();
}
public void drawCoin(GL10 gl){
if (blueRedDetector.hasCoin() == true){
drawCoinToWorld(gl, blueRedDetector);
}
if (GreenRedDetector.hasCoin() == true){
drawCoinToWorld(gl, GreenRedDetector);
}
if (GreenBlueDetector.hasCoin() == true){
drawCoinToWorld(gl, GreenBlueDetector);
}
}
public void drawCoinToWorld(GL10 gl, MarkerDetector mDetector){
gl.glPushMatrix();
gl.glTranslatef(pixel2worldX(mDetector.getCoinX()), pixel2worldYscaled(mDetector.getCoinY()), 0);
float scale = 0.2f * scaleTrackObjects(mDetector);
gl.glScalef(scale, scale, scale);
float rotateOnZ = mDetector.getCoinAngleInDegAroundItSelf() + mDetector.getAngleFromXAxis(); //TODO rotate according to time;
gl.glRotatef(rotateOnZ, 0, 0, 1);
gl.glRotatef(rollAngle, (float)Math.cos(Math.toRadians(rotateOnZ)), -(float)Math.sin(Math.toRadians(rotateOnZ)), 0);
// Draw mExample A.
mCoin.draw(gl);
// Restore the last matrix.
gl.glPopMatrix();
}
public void drawGrid(GL10 gl,float x, float y, boolean flag){
// Save the current matrix.
gl.glPushMatrix();
//gl.glTranslatef(pixel2worldX(mDetector.getMiddleX()), pixel2worldY(mDetector.getMiddleY()), 0);
gl.glTranslatef(x, pixel2worldY(y), 0);
float scale = 0.5f;
Log.i(TAG, "MyGLRenderer: sacle = " + scale);
gl.glScalef(scale, scale, scale);
//gl.glRotatef(45,0,0,1);
// Draw mExample A.
//mExample.draw(gl);
if (flag){
mTriangle.draw(gl);
}
mTower.draw(gl);
// Restore the last matrix.
gl.glPopMatrix();
}
}
|
[
"alonshoshan10@gmail.com"
] |
alonshoshan10@gmail.com
|
f3ff8f3674d4b96823f361111adfd562ba9afa39
|
98becb9c935ec3e36029236c7bb4dbb4d470dcc6
|
/src/main/java/edu/eci/arsw/cinema/persistence/impl/InMemoryCinemaPersistence.java
|
c6e1c3880eb5a5b21b8c5bd9bb923c523a42ddf6
|
[] |
no_license
|
Alejoguzm07/Workshop11
|
3b7191efea3baac821b1eb3f1562ab4816f7d355
|
bb5919f9d6e8579c962b651c74cb0d1a3db481cd
|
refs/heads/master
| 2020-05-17T04:46:13.809069
| 2019-05-07T23:07:26
| 2019-05-07T23:07:26
| 183,516,232
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 5,128
|
java
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package edu.eci.arsw.cinema.persistence.impl;
import edu.eci.arsw.cinema.model.Cinema;
import edu.eci.arsw.cinema.model.CinemaFunction;
import edu.eci.arsw.cinema.model.Movie;
import edu.eci.arsw.cinema.persistence.CinemaException;
import edu.eci.arsw.cinema.persistence.CinemaPersistenceException;
import edu.eci.arsw.cinema.persistence.CinemaPersitence;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
*
* @author cristian
*/
@Service
public class InMemoryCinemaPersistence implements CinemaPersitence{
private final Map<String,Cinema> unsafeCinemas=new HashMap<>();
private Map<String, Cinema> cinemas = Collections.synchronizedMap(unsafeCinemas);
public InMemoryCinemaPersistence() {
//load stub data
String functionDate = "2018-12-18 15:30";
String functionDate1 = "2018";
List<CinemaFunction> functions= new ArrayList<>();
CinemaFunction funct1 = new CinemaFunction(new Movie("SuperHeroes Movie","Action"),functionDate);
CinemaFunction funct2 = new CinemaFunction(new Movie("The Night","Horror"),functionDate);
CinemaFunction funct3 = new CinemaFunction(new Movie("Split","suspense"),functionDate1);
CinemaFunction funct4 = new CinemaFunction(new Movie("Glass","Suspense"),functionDate1);
functions.add(funct3);
functions.add(funct4);
functions.add(funct1);
functions.add(funct2);
Cinema c=new Cinema("cinemaX",functions);
Cinema c1=new Cinema("CineColombia",functions);
Cinema c2= new Cinema("cineMark",functions);
cinemas.put("cinemaX", c);
cinemas.put("CineColombia", c1);
cinemas.put("Cinemark", c2);
}
@Override
public void buyTicket(int row, int col, String cinema, String date, String movieName) throws CinemaException {
Cinema c = cinemas.get(cinema);
List<CinemaFunction> functions = c.getFunctions();
CinemaFunction cf = null;
for(int i = 0; i < functions.size(); i++){
CinemaFunction fun = functions.get(i);
if(fun.getMovie().equals(movieName) && fun.getDate().equals(date)){
cf = fun;
cf.buyTicket(row, col);
break;
}
}
//throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<CinemaFunction> getFunctionsbyCinemaAndDate(String cinema, String date) {
Cinema c = cinemas.get(cinema);
List<CinemaFunction> functions = c.getFunctions();
List<CinemaFunction> rta = new ArrayList<>();
for(int i = 0; i < functions.size(); i++){
CinemaFunction fun = functions.get(i);
if(fun.getDate().equals(date)){
rta.add(fun);
}
}
return rta;
}
@Override
public void saveCinema(Cinema c) throws CinemaPersistenceException {
if (cinemas.containsKey(c.getName())){
throw new CinemaPersistenceException("The given cinema already exists: "+c.getName());
}
else{
cinemas.put(c.getName(),c);
}
}
@Override
public Cinema getCinema(String name) throws CinemaPersistenceException {
return cinemas.get(name);
}
@Override
public Set<Cinema> getAllCinemas() {
Set<Cinema> res = new HashSet<>();
for(String c:cinemas.keySet())
res.add(cinemas.get(c));
return res;
}
@Override
public Cinema getCinemaByName(String name) throws CinemaPersistenceException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void updateCinema(String name, CinemaFunction cinemaFunction) throws CinemaPersistenceException {
Cinema c = cinemas.get(name);
boolean flag=false;
List<List<Boolean>> seats= new ArrayList<>();
List<CinemaFunction> cfs=c.getFunctions();
for(CinemaFunction cf:cfs){
if(cf.getMovie().getName().equals(cinemaFunction.getMovie().getName())){
cf.setDate(cinemaFunction.getDate());
cf.setMovie(cinemaFunction.getMovie());
cf.setSeats(cinemaFunction.getSeats());
flag=true;
}
}
if(!flag) c.addCinemafunction(cinemaFunction);
}
@Override
public CinemaFunction getcinemaFunctionByMovieName(List<CinemaFunction> cfs, String movieName) throws CinemaPersistenceException {
CinemaFunction rst=null;
for(CinemaFunction cf:cfs){
if(cf.getMovie().getName().equals(movieName))rst=cf;
}
return rst;
}
}
|
[
"alejoguzm07@gmail.com"
] |
alejoguzm07@gmail.com
|
e68b53cdb8348ba41845d0e8f352f270818f04f1
|
76c5a17f968da3fd7919f04ef73568ea2ec9ffd1
|
/src/com/qq/common/User.java
|
834d849c7b4ee603f9d148db8e149df3e8df3ed6
|
[
"Apache-2.0"
] |
permissive
|
Mince1007/qq-server-for-java
|
b9a60aaffaa549f029ebe484e7f1b606416afac7
|
ea0a70da55eb924f1fde103b05245e659b36ca63
|
refs/heads/master
| 2021-05-29T05:42:20.879553
| 2015-07-08T00:02:06
| 2015-07-08T00:02:06
| null | 0
| 0
| null | null | null | null |
GB18030
|
Java
| false
| false
| 715
|
java
|
package com.qq.common;
import java.io.Serializable;
public class User implements Serializable{//必须要序列化,这样的对象才能够在网络,流之间进行通信
private String count;//帐号,密码
private String psd;
private String type= "login";//默认账户类型是登录
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public User(String count, String psd) {
super();
this.count = count;
this.psd = psd;
}
public String getCount() {
return count;
}
public void setCount(String count) {
this.count = count;
}
public String getPsd() {
return psd;
}
public void setPsd(String psd) {
this.psd = psd;
}
}
|
[
"Bob1993@github.com"
] |
Bob1993@github.com
|
e0847ee2853eeafc2d9880ece99ba367b387de5d
|
0a92f110dc05fac367cac00777bdfc92ce5c6045
|
/src/com/prashantb/example/MainActivity.java
|
eb9d8db8eab9e20f04fcfca059636d687577fdfd
|
[] |
no_license
|
prashantgbhangre/android-pick-image
|
6f54bd470e082da1c543b5b4e024c40ebc786b51
|
3a17fdd4aa43f5a75474b884cf5bfaae5f8956be
|
refs/heads/master
| 2021-01-22T05:16:28.068718
| 2015-06-16T10:50:34
| 2015-06-16T10:50:34
| 37,524,507
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,119
|
java
|
package com.prashantb.example;
import com.prgguru.example.R;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
public class MainActivity extends Activity {
private static int RESULT_LOAD_IMG = 1;
String imgDecodableString;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void loadImagefromGallery(View view) {
// Create intent to Open Image applications like Gallery, Google Photos
Intent galleryIntent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
// Start the Intent
startActivityForResult(galleryIntent, RESULT_LOAD_IMG);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
// When an Image is picked
if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK
&& null != data) {
// Get the Image from data
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
// Get the cursor
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
// Move to first row
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
imgDecodableString = cursor.getString(columnIndex);
cursor.close();
ImageView imgView = (ImageView) findViewById(R.id.imgView);
// Set the Image in ImageView after decoding the String
imgView.setImageBitmap(BitmapFactory
.decodeFile(imgDecodableString));
} else {
Toast.makeText(this, "You haven't picked Image",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG)
.show();
}
}
}
|
[
"prashantgbhangre@gmail.com"
] |
prashantgbhangre@gmail.com
|
156cbda1384a0ff224eaa44e4c6c1247364eaf19
|
e4d19b117ad2fcbafa47c2d8c430ae5043c7b3bf
|
/src/main/java/com/ljx/blog/bean/Comment.java
|
a49a9bf870dbfd4b5184434d416c01ece081db75
|
[] |
no_license
|
ljx-coder/blog
|
eeeb1cfdd7542957e1b12b72c776f27784738334
|
d000a695271ab0f33609fa2b8f2dbea8744474b5
|
refs/heads/master
| 2022-04-16T22:21:34.166727
| 2020-04-13T03:15:33
| 2020-04-13T03:15:33
| 255,217,430
| 0
| 1
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 924
|
java
|
package com.ljx.blog.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.List;
/**
* @author: Mr.Liu
* @description: 评论实体类
* @date: 2020-04-02 22:29
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_comment")
public class Comment extends BaseBean{
private String nickname;
private String email;
private String content;
private String avatar;
@ManyToOne
private Blog blog;
@OneToMany(mappedBy = "parentComment")
private List<Comment> replyComments=new ArrayList<>();
@ManyToOne
private Comment parentComment;
private boolean adminComment;
}
|
[
"ljx2273672293@163.com"
] |
ljx2273672293@163.com
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.